sketchmark 1.3.7 → 1.4.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 +21 -8
- package/dist/ast/types.d.ts +4 -0
- package/dist/ast/types.d.ts.map +1 -1
- package/dist/index.cjs +292 -42
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +292 -42
- package/dist/index.js.map +1 -1
- package/dist/layout/index.d.ts.map +1 -1
- package/dist/parser/index.d.ts.map +1 -1
- package/dist/renderer/canvas/index.d.ts.map +1 -1
- package/dist/renderer/shared.d.ts +16 -0
- package/dist/renderer/shared.d.ts.map +1 -1
- package/dist/renderer/svg/index.d.ts.map +1 -1
- package/dist/scene/index.d.ts +4 -2
- package/dist/scene/index.d.ts.map +1 -1
- package/dist/sketchmark.iife.js +292 -42
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/layout/index.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EACV,UAAU,EACV,SAAS,EAIV,MAAM,UAAU,CAAC;AAClB,OAAO,KAAK,EAAE,UAAU,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/layout/index.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EACV,UAAU,EACV,SAAS,EAIV,MAAM,UAAU,CAAC;AAClB,OAAO,KAAK,EAAE,UAAU,EAA4B,MAAM,cAAc,CAAC;AAsSzE,wBAAgB,SAAS,CAAC,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAmB1E;AAMD,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,EACtE,MAAM,CAAC,EAAE,UAAU,GAAG,MAAM,EAC5B,OAAO,CAAC,EAAE,MAAM,EAChB,OAAO,CAAC,EAAE,MAAM,GACf,CAAC,MAAM,EAAE,MAAM,CAAC,CA6ClB;AA8ID,wBAAgB,MAAM,CAAC,EAAE,EAAE,UAAU,GAAG,UAAU,CA8JjD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/parser/index.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EACV,UAAU,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/parser/index.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EACV,UAAU,EAsBX,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE/C,YAAY,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAqC/C,qBAAa,UAAW,SAAQ,KAAK;IAG1B,IAAI,EAAE,MAAM;IACZ,GAAG,EAAE,MAAM;gBAFlB,GAAG,EAAE,MAAM,EACJ,IAAI,EAAE,MAAM,EACZ,GAAG,EAAE,MAAM;CAKrB;AA0FD,wBAAgB,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,GAAE,YAAiB,GAAG,UAAU,CA6jCzE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/renderer/canvas/index.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACV,UAAU,EAEX,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/renderer/canvas/index.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACV,UAAU,EAEX,MAAM,aAAa,CAAC;AAmCrB,MAAM,WAAW,qBAAqB;IACpC,KAAK,CAAC,EAAQ,MAAM,CAAC;IACrB,UAAU,CAAC,EAAG,MAAM,CAAC;IACrB,SAAS,CAAC,EAAI,MAAM,CAAC;IACrB,MAAM,CAAC,EAAO,MAAM,CAAC;IACrB,KAAK,CAAC,EAAQ,OAAO,GAAG,MAAM,GAAG,MAAM,CAAC;IACxC,OAAO,CAAC,EAAM,OAAO,CAAC;IACtB,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAoGD,wBAAgB,cAAc,CAC5B,EAAE,EAAO,UAAU,EACnB,MAAM,EAAG,iBAAiB,EAC1B,OAAO,GAAE,qBAA0B,GAClC,IAAI,CA2aN;AAGD,wBAAgB,eAAe,CAAC,MAAM,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC,CAOxE;AAED,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,iBAAiB,GAAG,MAAM,CAEpE"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { SceneNode, SceneGroup, SceneTable, SceneChart } from "../scene";
|
|
2
|
+
import type { EdgePoint } from "../ast/types";
|
|
2
3
|
export declare function hashStr(s: string): number;
|
|
3
4
|
export declare function darkenHex(hex: string, amount?: number): string;
|
|
4
5
|
export declare function resolveStyleFont(style: Record<string, unknown>, fallback: string): string;
|
|
@@ -23,5 +24,20 @@ export declare function getConnPoint(src: {
|
|
|
23
24
|
h: number;
|
|
24
25
|
shape?: string;
|
|
25
26
|
}, dstCX: number, dstCY: number, anchor?: string): [number, number];
|
|
27
|
+
export declare function compactPolylinePoints(points: EdgePoint[]): EdgePoint[];
|
|
28
|
+
export declare function polylinePathData(points: EdgePoint[]): string;
|
|
29
|
+
export declare function polylineEndpointDirection(points: EdgePoint[], end: "start" | "end"): EdgePoint;
|
|
30
|
+
export declare function insetPolylineEndpoints(points: EdgePoint[], arrowAt: "end" | "start" | "both" | "none", inset: number): EdgePoint[];
|
|
31
|
+
export declare function polylineLabelPosition(points: EdgePoint[], offset: number, dx?: number, dy?: number): {
|
|
32
|
+
x: number;
|
|
33
|
+
y: number;
|
|
34
|
+
};
|
|
35
|
+
export declare function polylineArrowTipPoint(entity: {
|
|
36
|
+
x: number;
|
|
37
|
+
y: number;
|
|
38
|
+
w: number;
|
|
39
|
+
h: number;
|
|
40
|
+
shape?: string;
|
|
41
|
+
}, points: EdgePoint[], end: "start" | "end"): EdgePoint;
|
|
26
42
|
export declare function groupDepth(g: SceneGroup, gm: Map<string, SceneGroup>): number;
|
|
27
43
|
//# sourceMappingURL=shared.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../../src/renderer/shared.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EACV,SAAS,EACT,UAAU,EACV,UAAU,EACV,UAAU,EACX,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../../src/renderer/shared.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EACV,SAAS,EACT,UAAU,EACV,UAAU,EACV,UAAU,EACX,MAAM,UAAU,CAAC;AAClB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAK9C,wBAAgB,OAAO,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAIzC;AAGD,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,SAAO,GAAG,MAAM,CAK5D;AAGD,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC9B,QAAQ,EAAE,MAAM,GACf,MAAM,CAKR;AAGD,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAUjF,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAIrF;AAGD,wBAAgB,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG;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CAI5D;AAED,wBAAgB,yBAAyB,CACvC,MAAM,EAAE,SAAS,EAAE,EACnB,GAAG,EAAE,OAAO,GAAG,KAAK,GACnB,SAAS,CAiBX;AAED,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,SAAS,EAAE,EACnB,OAAO,EAAE,KAAK,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,EAC1C,KAAK,EAAE,MAAM,GACZ,SAAS,EAAE,CAgBb;AAED,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,SAAS,EAAE,EACnB,MAAM,EAAE,MAAM,EACd,EAAE,SAAI,EACN,EAAE,SAAI,GACL;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,CAiC1B;AAuED,wBAAgB,qBAAqB,CACnC,MAAM,EAAE;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,EACtE,MAAM,EAAE,SAAS,EAAE,EACnB,GAAG,EAAE,OAAO,GAAG,KAAK,GACnB,SAAS,CAaX;AAED,wBAAgB,UAAU,CAAC,CAAC,EAAE,UAAU,EAAE,EAAE,EAAE,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,GAAG,MAAM,CAK7E"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/renderer/svg/index.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACV,UAAU,EAKX,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/renderer/svg/index.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACV,UAAU,EAKX,MAAM,aAAa,CAAC;AA4TrB,MAAM,WAAW,kBAAkB;IACjC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,WAAW,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IACvC,KAAK,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,MAAM,CAAC;IAClC,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAED,wBAAgB,WAAW,CACzB,EAAE,EAAE,UAAU,EACd,SAAS,EAAE,WAAW,GAAG,aAAa,EACtC,OAAO,GAAE,kBAAuB,GAC/B,aAAa,CAylBf;AAED,wBAAgB,WAAW,CAAC,GAAG,EAAE,aAAa,GAAG,MAAM,CAKtD"}
|
package/dist/scene/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { DiagramAST, ASTNode, ASTStepItem, StyleProps, GroupChildRef, RootItemRef, ASTTableRow } from "../ast/types";
|
|
1
|
+
import type { DiagramAST, ASTNode, ASTStepItem, StyleProps, EdgePoint, EdgeRoute, GroupChildRef, RootItemRef, ASTTableRow } from "../ast/types";
|
|
2
2
|
import type { MarkdownLine } from '../markdown/parser';
|
|
3
3
|
export type { GroupChildRef, RootItemRef };
|
|
4
4
|
export interface SceneRect {
|
|
@@ -42,10 +42,12 @@ export interface SceneEdge {
|
|
|
42
42
|
labelDy?: number;
|
|
43
43
|
fromAnchor?: string;
|
|
44
44
|
toAnchor?: string;
|
|
45
|
+
route?: EdgeRoute;
|
|
46
|
+
via?: EdgePoint[];
|
|
45
47
|
dashed: boolean;
|
|
46
48
|
bidirectional: boolean;
|
|
47
49
|
style: StyleProps;
|
|
48
|
-
points?: [
|
|
50
|
+
points?: EdgePoint[];
|
|
49
51
|
}
|
|
50
52
|
export interface SceneGroup {
|
|
51
53
|
id: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/scene/index.ts"],"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AE,CAAC;IAC3B,MAAM,EAAE,UAAU,EAAE,CAAC;IACrB,SAAS,EAAE,cAAc,CAAC;IAC1B,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;IACnC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,CAAC;IAClD,SAAS,EAAE,WAAW,EAAE,CAAC;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAGD,wBAAgB,eAAe,CAAC,GAAG,EAAE,UAAU,GAAG,UAAU,CA+J3D;AAGD,wBAAgB,OAAO,CAAC,EAAE,EAAE,UAAU,GAAG,GAAG,CAAC,MAAM,EAAE,SAAS,CAAC,CAE9D;AAED,wBAAgB,QAAQ,CAAC,EAAE,EAAE,UAAU,GAAG,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,CAEhE;AAED,wBAAgB,QAAQ,CAAC,EAAE,EAAE,UAAU,GAAG,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,CAEhE;AAED,wBAAgB,QAAQ,CAAC,EAAE,EAAE,UAAU,GAAG,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,CAEhE;AAED,wBAAgB,WAAW,CAAC,EAAE,EAAE,UAAU,GAAG,GAAG,CAAC,MAAM,EAAE,aAAa,CAAC,CAEtE"}
|
package/dist/sketchmark.iife.js
CHANGED
|
@@ -360,6 +360,39 @@ var AIDiagram = (function (exports) {
|
|
|
360
360
|
function isPropKeyToken(t) {
|
|
361
361
|
return !!t && (t.type === "IDENT" || t.type === "KEYWORD");
|
|
362
362
|
}
|
|
363
|
+
const NUMBER_RE = /[-+]?(?:\d*\.\d+|\d+)(?:[eE][-+]?\d+)?/g;
|
|
364
|
+
function parseEdgeWaypoints(value, token) {
|
|
365
|
+
if (!value)
|
|
366
|
+
return undefined;
|
|
367
|
+
const numbers = (value.match(NUMBER_RE) ?? []).map((part) => Number(part));
|
|
368
|
+
if (!numbers.length)
|
|
369
|
+
return undefined;
|
|
370
|
+
if (numbers.length % 2 !== 0) {
|
|
371
|
+
throw new ParseError(`Edge via must contain x,y coordinate pairs`, token.line, token.col);
|
|
372
|
+
}
|
|
373
|
+
const points = [];
|
|
374
|
+
for (let index = 0; index < numbers.length; index += 2) {
|
|
375
|
+
const x = numbers[index];
|
|
376
|
+
const y = numbers[index + 1];
|
|
377
|
+
if (!Number.isFinite(x) || !Number.isFinite(y)) {
|
|
378
|
+
throw new ParseError(`Edge via contains a non-numeric coordinate`, token.line, token.col);
|
|
379
|
+
}
|
|
380
|
+
points.push([x, y]);
|
|
381
|
+
}
|
|
382
|
+
return points.length ? points : undefined;
|
|
383
|
+
}
|
|
384
|
+
function normalizeEdgeRoute(value, token) {
|
|
385
|
+
if (!value)
|
|
386
|
+
return undefined;
|
|
387
|
+
const normalized = value.toLowerCase();
|
|
388
|
+
if (normalized === "straight" || normalized === "polyline" || normalized === "orthogonal") {
|
|
389
|
+
return normalized;
|
|
390
|
+
}
|
|
391
|
+
if (normalized === "ortho" || normalized === "elbow") {
|
|
392
|
+
return "orthogonal";
|
|
393
|
+
}
|
|
394
|
+
throw new ParseError(`Unsupported edge route "${value}"; use straight, orthogonal, or polyline`, token.line, token.col);
|
|
395
|
+
}
|
|
363
396
|
function parse(src, options = {}) {
|
|
364
397
|
resetUid();
|
|
365
398
|
const preparedSource = applyPluginPreprocessors(src, options.plugins);
|
|
@@ -718,28 +751,63 @@ var AIDiagram = (function (exports) {
|
|
|
718
751
|
height: props.height !== undefined ? parseFloat(props.height) : undefined,
|
|
719
752
|
};
|
|
720
753
|
}
|
|
721
|
-
function
|
|
722
|
-
const toTok = rest.shift();
|
|
723
|
-
if (!toTok)
|
|
724
|
-
throw new ParseError("Expected edge target", 0, 0);
|
|
754
|
+
function parseEdgeProps(toks) {
|
|
725
755
|
const props = {};
|
|
726
756
|
let j = 0;
|
|
727
|
-
while (j <
|
|
728
|
-
const
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
j += 3;
|
|
757
|
+
while (j < toks.length) {
|
|
758
|
+
const key = toks[j];
|
|
759
|
+
const eq = toks[j + 1];
|
|
760
|
+
if (!isPropKeyToken(key) || eq?.type !== "EQUALS") {
|
|
761
|
+
j++;
|
|
762
|
+
continue;
|
|
734
763
|
}
|
|
735
|
-
|
|
764
|
+
const value = toks[j + 2];
|
|
765
|
+
if (!value) {
|
|
736
766
|
j++;
|
|
767
|
+
continue;
|
|
768
|
+
}
|
|
769
|
+
if (value.type === "LBRACKET") {
|
|
770
|
+
const parts = [];
|
|
771
|
+
let depth = 1;
|
|
772
|
+
j += 3;
|
|
773
|
+
while (j < toks.length && depth > 0) {
|
|
774
|
+
const tok = toks[j];
|
|
775
|
+
if (tok.type === "LBRACKET") {
|
|
776
|
+
depth++;
|
|
777
|
+
}
|
|
778
|
+
else if (tok.type === "RBRACKET") {
|
|
779
|
+
depth--;
|
|
780
|
+
if (depth === 0) {
|
|
781
|
+
j++;
|
|
782
|
+
break;
|
|
783
|
+
}
|
|
784
|
+
}
|
|
785
|
+
if (depth > 0)
|
|
786
|
+
parts.push(tok.value);
|
|
787
|
+
j++;
|
|
788
|
+
}
|
|
789
|
+
if (depth > 0) {
|
|
790
|
+
throw new ParseError(`Unterminated edge property list; expected ']'`, key.line, key.col);
|
|
791
|
+
}
|
|
792
|
+
props[key.value] = parts.join(" ");
|
|
793
|
+
continue;
|
|
737
794
|
}
|
|
795
|
+
props[key.value] = value.value;
|
|
796
|
+
j += 3;
|
|
738
797
|
}
|
|
798
|
+
return props;
|
|
799
|
+
}
|
|
800
|
+
function parseEdge(fromId, connector, rest) {
|
|
801
|
+
const toTok = rest.shift();
|
|
802
|
+
if (!toTok)
|
|
803
|
+
throw new ParseError("Expected edge target", 0, 0);
|
|
804
|
+
const props = parseEdgeProps(rest);
|
|
739
805
|
const dashed = connector.includes("--") ||
|
|
740
806
|
connector.includes(".-") ||
|
|
741
807
|
connector.includes("-.");
|
|
742
808
|
const bidirectional = connector.includes("<") && connector.includes(">");
|
|
809
|
+
const via = parseEdgeWaypoints(props.via, toTok);
|
|
810
|
+
const route = normalizeEdgeRoute(props.route, toTok) ?? (via?.length ? "polyline" : undefined);
|
|
743
811
|
return {
|
|
744
812
|
kind: "edge",
|
|
745
813
|
id: uid("edge"),
|
|
@@ -751,6 +819,8 @@ var AIDiagram = (function (exports) {
|
|
|
751
819
|
labelDy: props["label-dy"] !== undefined ? parseFloat(props["label-dy"]) : undefined,
|
|
752
820
|
fromAnchor: props["anchor-from"],
|
|
753
821
|
toAnchor: props["anchor-to"],
|
|
822
|
+
route,
|
|
823
|
+
via,
|
|
754
824
|
dashed,
|
|
755
825
|
bidirectional,
|
|
756
826
|
style: propsToStyle(props),
|
|
@@ -3684,6 +3754,8 @@ var AIDiagram = (function (exports) {
|
|
|
3684
3754
|
labelDy: e.labelDy,
|
|
3685
3755
|
fromAnchor: e.fromAnchor,
|
|
3686
3756
|
toAnchor: e.toAnchor,
|
|
3757
|
+
route: e.route,
|
|
3758
|
+
via: e.via,
|
|
3687
3759
|
dashed: e.dashed ?? false,
|
|
3688
3760
|
bidirectional: e.bidirectional ?? false,
|
|
3689
3761
|
style: e.style ?? {},
|
|
@@ -4285,6 +4357,151 @@ var AIDiagram = (function (exports) {
|
|
|
4285
4357
|
return anchoredConnPoint(src, anchor, dstCX, dstCY);
|
|
4286
4358
|
}
|
|
4287
4359
|
// ── Group depth (for paint order) ────────────────────────────────────────
|
|
4360
|
+
function segmentLength(a, b) {
|
|
4361
|
+
return Math.hypot(b[0] - a[0], b[1] - a[1]);
|
|
4362
|
+
}
|
|
4363
|
+
function compactPolylinePoints(points) {
|
|
4364
|
+
const compacted = [];
|
|
4365
|
+
for (const point of points) {
|
|
4366
|
+
const previous = compacted[compacted.length - 1];
|
|
4367
|
+
if (!previous || segmentLength(previous, point) > 0.01) {
|
|
4368
|
+
compacted.push(point);
|
|
4369
|
+
}
|
|
4370
|
+
}
|
|
4371
|
+
return compacted;
|
|
4372
|
+
}
|
|
4373
|
+
function polylinePathData(points) {
|
|
4374
|
+
return points
|
|
4375
|
+
.map(([x, y], index) => `${index === 0 ? "M" : "L"} ${x} ${y}`)
|
|
4376
|
+
.join(" ");
|
|
4377
|
+
}
|
|
4378
|
+
function polylineEndpointDirection(points, end) {
|
|
4379
|
+
const step = end === "start" ? 1 : -1;
|
|
4380
|
+
let index = end === "start" ? 0 : points.length - 1;
|
|
4381
|
+
while (index + step >= 0 && index + step < points.length) {
|
|
4382
|
+
const from = points[index];
|
|
4383
|
+
const to = points[index + step];
|
|
4384
|
+
const dx = to[0] - from[0];
|
|
4385
|
+
const dy = to[1] - from[1];
|
|
4386
|
+
const len = Math.hypot(dx, dy);
|
|
4387
|
+
if (len > 0.01) {
|
|
4388
|
+
return end === "start" ? [dx / len, dy / len] : [-dx / len, -dy / len];
|
|
4389
|
+
}
|
|
4390
|
+
index += step;
|
|
4391
|
+
}
|
|
4392
|
+
return [1, 0];
|
|
4393
|
+
}
|
|
4394
|
+
function insetPolylineEndpoints(points, arrowAt, inset) {
|
|
4395
|
+
const next = points.map((point) => [point[0], point[1]]);
|
|
4396
|
+
if (next.length < 2)
|
|
4397
|
+
return next;
|
|
4398
|
+
if (arrowAt === "start" || arrowAt === "both") {
|
|
4399
|
+
const [dx, dy] = polylineEndpointDirection(next, "start");
|
|
4400
|
+
next[0] = [next[0][0] + dx * inset, next[0][1] + dy * inset];
|
|
4401
|
+
}
|
|
4402
|
+
if (arrowAt === "end" || arrowAt === "both") {
|
|
4403
|
+
const [dx, dy] = polylineEndpointDirection(next, "end");
|
|
4404
|
+
const last = next.length - 1;
|
|
4405
|
+
next[last] = [next[last][0] - dx * inset, next[last][1] - dy * inset];
|
|
4406
|
+
}
|
|
4407
|
+
return compactPolylinePoints(next);
|
|
4408
|
+
}
|
|
4409
|
+
function polylineLabelPosition(points, offset, dx = 0, dy = 0) {
|
|
4410
|
+
if (points.length < 2) {
|
|
4411
|
+
const [x, y] = points[0] ?? [0, 0];
|
|
4412
|
+
return { x: x + dx, y: y + dy };
|
|
4413
|
+
}
|
|
4414
|
+
const lengths = points.slice(1).map((point, index) => segmentLength(points[index], point));
|
|
4415
|
+
const total = lengths.reduce((sum, value) => sum + value, 0);
|
|
4416
|
+
if (total <= 0.01) {
|
|
4417
|
+
const [x, y] = points[0];
|
|
4418
|
+
return { x: x + dx, y: y + dy };
|
|
4419
|
+
}
|
|
4420
|
+
let travelled = 0;
|
|
4421
|
+
const target = total / 2;
|
|
4422
|
+
for (let index = 0; index < lengths.length; index += 1) {
|
|
4423
|
+
const length = lengths[index];
|
|
4424
|
+
if (travelled + length >= target) {
|
|
4425
|
+
const from = points[index];
|
|
4426
|
+
const to = points[index + 1];
|
|
4427
|
+
const t = length > 0 ? (target - travelled) / length : 0;
|
|
4428
|
+
const ux = (to[0] - from[0]) / length;
|
|
4429
|
+
const uy = (to[1] - from[1]) / length;
|
|
4430
|
+
return {
|
|
4431
|
+
x: from[0] + (to[0] - from[0]) * t - uy * offset + dx,
|
|
4432
|
+
y: from[1] + (to[1] - from[1]) * t + ux * offset + dy,
|
|
4433
|
+
};
|
|
4434
|
+
}
|
|
4435
|
+
travelled += length;
|
|
4436
|
+
}
|
|
4437
|
+
const [x, y] = points[points.length - 1];
|
|
4438
|
+
return { x: x + dx, y: y + dy };
|
|
4439
|
+
}
|
|
4440
|
+
function rectBoundaryPoint(entity, point, direction) {
|
|
4441
|
+
const [px, py] = point;
|
|
4442
|
+
const [dx, dy] = direction;
|
|
4443
|
+
const candidates = [];
|
|
4444
|
+
const minX = entity.x;
|
|
4445
|
+
const maxX = entity.x + entity.w;
|
|
4446
|
+
const minY = entity.y;
|
|
4447
|
+
const maxY = entity.y + entity.h;
|
|
4448
|
+
const epsilon = 0.01;
|
|
4449
|
+
if (Math.abs(dx) > epsilon) {
|
|
4450
|
+
candidates.push((minX - px) / dx, (maxX - px) / dx);
|
|
4451
|
+
}
|
|
4452
|
+
if (Math.abs(dy) > epsilon) {
|
|
4453
|
+
candidates.push((minY - py) / dy, (maxY - py) / dy);
|
|
4454
|
+
}
|
|
4455
|
+
const valid = candidates
|
|
4456
|
+
.filter((t) => t >= -epsilon)
|
|
4457
|
+
.map((t) => ({
|
|
4458
|
+
t: Math.max(0, t),
|
|
4459
|
+
x: px + dx * t,
|
|
4460
|
+
y: py + dy * t,
|
|
4461
|
+
}))
|
|
4462
|
+
.filter(({ x, y }) => x >= minX - epsilon &&
|
|
4463
|
+
x <= maxX + epsilon &&
|
|
4464
|
+
y >= minY - epsilon &&
|
|
4465
|
+
y <= maxY + epsilon)
|
|
4466
|
+
.sort((a, b) => a.t - b.t);
|
|
4467
|
+
const hit = valid[0];
|
|
4468
|
+
return hit ? [hit.x, hit.y] : point;
|
|
4469
|
+
}
|
|
4470
|
+
function ellipseBoundaryPoint(entity, point, direction) {
|
|
4471
|
+
const [px, py] = point;
|
|
4472
|
+
const [dx, dy] = direction;
|
|
4473
|
+
const cx = entity.x + entity.w / 2;
|
|
4474
|
+
const cy = entity.y + entity.h / 2;
|
|
4475
|
+
const rx = Math.max(1, entity.w * 0.44);
|
|
4476
|
+
const ry = Math.max(1, entity.h * 0.44);
|
|
4477
|
+
const x0 = px - cx;
|
|
4478
|
+
const y0 = py - cy;
|
|
4479
|
+
const a = (dx * dx) / (rx * rx) + (dy * dy) / (ry * ry);
|
|
4480
|
+
const b = 2 * ((x0 * dx) / (rx * rx) + (y0 * dy) / (ry * ry));
|
|
4481
|
+
const c = (x0 * x0) / (rx * rx) + (y0 * y0) / (ry * ry) - 1;
|
|
4482
|
+
const disc = b * b - 4 * a * c;
|
|
4483
|
+
if (a <= 0 || disc < 0)
|
|
4484
|
+
return point;
|
|
4485
|
+
const sqrt = Math.sqrt(disc);
|
|
4486
|
+
const hits = [(-b - sqrt) / (2 * a), (-b + sqrt) / (2 * a)]
|
|
4487
|
+
.filter((t) => t >= -0.01)
|
|
4488
|
+
.sort((left, right) => left - right);
|
|
4489
|
+
const t = Math.max(0, hits[0] ?? 0);
|
|
4490
|
+
return [px + dx * t, py + dy * t];
|
|
4491
|
+
}
|
|
4492
|
+
function polylineArrowTipPoint(entity, points, end) {
|
|
4493
|
+
const point = end === "start" ? points[0] : points[points.length - 1];
|
|
4494
|
+
if (!point)
|
|
4495
|
+
return [0, 0];
|
|
4496
|
+
const [dx, dy] = polylineEndpointDirection(points, end);
|
|
4497
|
+
const outward = end === "start" ? [dx, dy] : [-dx, -dy];
|
|
4498
|
+
if (Math.hypot(outward[0], outward[1]) <= 0.01)
|
|
4499
|
+
return point;
|
|
4500
|
+
if (entity.shape === "circle") {
|
|
4501
|
+
return ellipseBoundaryPoint(entity, point, outward);
|
|
4502
|
+
}
|
|
4503
|
+
return rectBoundaryPoint(entity, point, outward);
|
|
4504
|
+
}
|
|
4288
4505
|
function groupDepth(g, gm) {
|
|
4289
4506
|
let d = 0;
|
|
4290
4507
|
let cur = g;
|
|
@@ -5245,6 +5462,31 @@ var AIDiagram = (function (exports) {
|
|
|
5245
5462
|
const t = Math.min(tx, ty);
|
|
5246
5463
|
return [cx + t * dx, cy + t * dy];
|
|
5247
5464
|
}
|
|
5465
|
+
function distance$1(a, b) {
|
|
5466
|
+
return Math.hypot(b[0] - a[0], b[1] - a[1]);
|
|
5467
|
+
}
|
|
5468
|
+
function compactEdgePoints(points) {
|
|
5469
|
+
const compacted = [];
|
|
5470
|
+
for (const point of points) {
|
|
5471
|
+
const previous = compacted[compacted.length - 1];
|
|
5472
|
+
if (!previous || distance$1(previous, point) > 0.01) {
|
|
5473
|
+
compacted.push(point);
|
|
5474
|
+
}
|
|
5475
|
+
}
|
|
5476
|
+
return compacted;
|
|
5477
|
+
}
|
|
5478
|
+
function orthogonalEdgePoints(start, end) {
|
|
5479
|
+
if (Math.abs(start[0] - end[0]) < 0.01 || Math.abs(start[1] - end[1]) < 0.01) {
|
|
5480
|
+
return [start, end];
|
|
5481
|
+
}
|
|
5482
|
+
const midX = (start[0] + end[0]) / 2;
|
|
5483
|
+
return compactEdgePoints([
|
|
5484
|
+
start,
|
|
5485
|
+
[midX, start[1]],
|
|
5486
|
+
[midX, end[1]],
|
|
5487
|
+
end,
|
|
5488
|
+
]);
|
|
5489
|
+
}
|
|
5248
5490
|
function routeEdges(sg) {
|
|
5249
5491
|
const nm = nodeMap(sg);
|
|
5250
5492
|
const tm = tableMap(sg);
|
|
@@ -5274,10 +5516,17 @@ var AIDiagram = (function (exports) {
|
|
|
5274
5516
|
}
|
|
5275
5517
|
const dstCX = dst.x + dst.w / 2, dstCY = dst.y + dst.h / 2;
|
|
5276
5518
|
const srcCX = src.x + src.w / 2, srcCY = src.y + src.h / 2;
|
|
5277
|
-
e.
|
|
5278
|
-
|
|
5279
|
-
|
|
5280
|
-
|
|
5519
|
+
const start = anchoredConnPoint(src, e.fromAnchor, dstCX, dstCY);
|
|
5520
|
+
const end = anchoredConnPoint(dst, e.toAnchor, srcCX, srcCY);
|
|
5521
|
+
if (e.via?.length) {
|
|
5522
|
+
e.points = compactEdgePoints([start, ...e.via, end]);
|
|
5523
|
+
}
|
|
5524
|
+
else if (e.route === "orthogonal") {
|
|
5525
|
+
e.points = orthogonalEdgePoints(start, end);
|
|
5526
|
+
}
|
|
5527
|
+
else {
|
|
5528
|
+
e.points = [start, end];
|
|
5529
|
+
}
|
|
5281
5530
|
}
|
|
5282
5531
|
}
|
|
5283
5532
|
function computeBounds(sg, margin) {
|
|
@@ -5287,6 +5536,7 @@ var AIDiagram = (function (exports) {
|
|
|
5287
5536
|
...sg.tables.map((t) => t.x + t.w),
|
|
5288
5537
|
...sg.charts.map((c) => c.x + c.w),
|
|
5289
5538
|
...sg.markdowns.map((m) => m.x + m.w),
|
|
5539
|
+
...sg.edges.flatMap((e) => (e.points ?? []).map(([x]) => x)),
|
|
5290
5540
|
];
|
|
5291
5541
|
const allY = [
|
|
5292
5542
|
...sg.nodes.map((n) => n.y + n.h),
|
|
@@ -5294,6 +5544,7 @@ var AIDiagram = (function (exports) {
|
|
|
5294
5544
|
...sg.tables.map((t) => t.y + t.h),
|
|
5295
5545
|
...sg.charts.map((c) => c.y + c.h),
|
|
5296
5546
|
...sg.markdowns.map((m) => m.y + m.h),
|
|
5547
|
+
...sg.edges.flatMap((e) => (e.points ?? []).map(([, y]) => y)),
|
|
5297
5548
|
];
|
|
5298
5549
|
const autoWidth = (allX.length ? Math.max(...allX) : 400) + margin;
|
|
5299
5550
|
const autoHeight = (allY.length ? Math.max(...allY) : 300) + margin;
|
|
@@ -8467,20 +8718,16 @@ var AIDiagram = (function (exports) {
|
|
|
8467
8718
|
const srcCX = src.x + src.w / 2, srcCY = src.y + src.h / 2;
|
|
8468
8719
|
const [x1, y1] = getConnPoint(src, dstCX, dstCY, e.fromAnchor);
|
|
8469
8720
|
const [x2, y2] = getConnPoint(dst, srcCX, srcCY, e.toAnchor);
|
|
8721
|
+
const points = compactPolylinePoints(e.points?.length && e.points.length >= 2 ? e.points : [[x1, y1], [x2, y2]]);
|
|
8470
8722
|
const eg = mkGroup(`edge-${e.from}-${e.to}`, "eg");
|
|
8471
8723
|
setParentGroupData(eg, resolveEdgeParentGroupId(e.from, e.to, nm, tm, gmMap, cm, parentGroups));
|
|
8472
8724
|
if (e.style?.opacity != null)
|
|
8473
8725
|
eg.setAttribute("opacity", String(e.style.opacity));
|
|
8474
|
-
const len = Math.sqrt((x2 - x1) ** 2 + (y2 - y1) ** 2) || 1;
|
|
8475
|
-
const nx = (x2 - x1) / len, ny = (y2 - y1) / len;
|
|
8476
8726
|
const ecol = String(e.style?.stroke ?? palette.edgeStroke);
|
|
8477
8727
|
const { arrowAt, dashed } = connMeta(e.connector);
|
|
8478
8728
|
const HEAD = EDGE.headInset;
|
|
8479
|
-
const
|
|
8480
|
-
const
|
|
8481
|
-
const sx2 = arrowAt === "end" || arrowAt === "both" ? x2 - nx * HEAD : x2;
|
|
8482
|
-
const sy2 = arrowAt === "end" || arrowAt === "both" ? y2 - ny * HEAD : y2;
|
|
8483
|
-
const shaft = rc.line(sx1, sy1, sx2, sy2, {
|
|
8729
|
+
const shaftPoints = insetPolylineEndpoints(points, arrowAt, HEAD);
|
|
8730
|
+
const shaft = rc.path(polylinePathData(shaftPoints), {
|
|
8484
8731
|
...BASE_ROUGH,
|
|
8485
8732
|
roughness: 0.9,
|
|
8486
8733
|
seed: hashStr$3(e.from + e.to),
|
|
@@ -8491,18 +8738,21 @@ var AIDiagram = (function (exports) {
|
|
|
8491
8738
|
shaft.setAttribute("data-edge-role", "shaft");
|
|
8492
8739
|
eg.appendChild(shaft);
|
|
8493
8740
|
if (arrowAt === "end" || arrowAt === "both") {
|
|
8494
|
-
const
|
|
8741
|
+
const [endDx, endDy] = polylineEndpointDirection(points, "end");
|
|
8742
|
+
const [endX, endY] = polylineArrowTipPoint(dst, points, "end");
|
|
8743
|
+
const endHead = arrowHead(rc, endX, endY, Math.atan2(endDy, endDx), ecol, hashStr$3(e.to));
|
|
8495
8744
|
endHead.setAttribute("data-edge-role", "head");
|
|
8496
8745
|
eg.appendChild(endHead);
|
|
8497
8746
|
}
|
|
8498
8747
|
if (arrowAt === "start" || arrowAt === "both") {
|
|
8499
|
-
const
|
|
8748
|
+
const [startDx, startDy] = polylineEndpointDirection(points, "start");
|
|
8749
|
+
const [startX, startY] = polylineArrowTipPoint(src, points, "start");
|
|
8750
|
+
const startHead = arrowHead(rc, startX, startY, Math.atan2(-startDy, -startDx), ecol, hashStr$3(e.from + "back"));
|
|
8500
8751
|
startHead.setAttribute("data-edge-role", "head");
|
|
8501
8752
|
eg.appendChild(startHead);
|
|
8502
8753
|
}
|
|
8503
8754
|
if (e.label) {
|
|
8504
|
-
const
|
|
8505
|
-
const my = (y1 + y2) / 2 + nx * EDGE.labelOffset + (e.labelDy ?? 0);
|
|
8755
|
+
const { x: mx, y: my } = polylineLabelPosition(points, EDGE.labelOffset, e.labelDx ?? 0, e.labelDy ?? 0);
|
|
8506
8756
|
const tw = Math.max(e.label.length * 7 + 12, 36);
|
|
8507
8757
|
const bg = se("rect");
|
|
8508
8758
|
bg.setAttribute("x", String(mx - tw / 2));
|
|
@@ -9214,31 +9464,31 @@ var AIDiagram = (function (exports) {
|
|
|
9214
9464
|
const srcCX = src.x + src.w / 2, srcCY = src.y + src.h / 2;
|
|
9215
9465
|
const [x1, y1] = getConnPoint(src, dstCX, dstCY, e.fromAnchor);
|
|
9216
9466
|
const [x2, y2] = getConnPoint(dst, srcCX, srcCY, e.toAnchor);
|
|
9467
|
+
const points = compactPolylinePoints(e.points?.length && e.points.length >= 2 ? e.points : [[x1, y1], [x2, y2]]);
|
|
9217
9468
|
if (e.style?.opacity != null)
|
|
9218
9469
|
ctx.globalAlpha = Number(e.style.opacity);
|
|
9219
9470
|
const ecol = String(e.style?.stroke ?? palette.edgeStroke);
|
|
9220
9471
|
const { arrowAt, dashed } = connMeta(e.connector);
|
|
9221
|
-
const len = Math.sqrt((x2 - x1) ** 2 + (y2 - y1) ** 2) || 1;
|
|
9222
|
-
const nx = (x2 - x1) / len, ny = (y2 - y1) / len;
|
|
9223
9472
|
const HEAD = EDGE.headInset;
|
|
9224
|
-
const
|
|
9225
|
-
|
|
9226
|
-
const sx2 = arrowAt === 'end' || arrowAt === 'both' ? x2 - nx * HEAD : x2;
|
|
9227
|
-
const sy2 = arrowAt === 'end' || arrowAt === 'both' ? y2 - ny * HEAD : y2;
|
|
9228
|
-
rc.line(sx1, sy1, sx2, sy2, {
|
|
9473
|
+
const shaftPoints = insetPolylineEndpoints(points, arrowAt, HEAD);
|
|
9474
|
+
rc.path(polylinePathData(shaftPoints), {
|
|
9229
9475
|
...R, roughness: 0.9, seed: hashStr$3(e.from + e.to),
|
|
9230
9476
|
stroke: ecol,
|
|
9231
9477
|
strokeWidth: Number(e.style?.strokeWidth ?? 1.6),
|
|
9232
9478
|
...(dashed ? { strokeLineDash: EDGE.dashPattern } : {}),
|
|
9233
9479
|
});
|
|
9234
|
-
|
|
9235
|
-
|
|
9236
|
-
|
|
9237
|
-
|
|
9238
|
-
|
|
9480
|
+
if (arrowAt === 'end' || arrowAt === 'both') {
|
|
9481
|
+
const [endDx, endDy] = polylineEndpointDirection(points, 'end');
|
|
9482
|
+
const [endX, endY] = polylineArrowTipPoint(dst, points, 'end');
|
|
9483
|
+
drawArrowHead(rc, endX, endY, Math.atan2(endDy, endDx), ecol, hashStr$3(e.to));
|
|
9484
|
+
}
|
|
9485
|
+
if (arrowAt === 'start' || arrowAt === 'both') {
|
|
9486
|
+
const [startDx, startDy] = polylineEndpointDirection(points, 'start');
|
|
9487
|
+
const [startX, startY] = polylineArrowTipPoint(src, points, 'start');
|
|
9488
|
+
drawArrowHead(rc, startX, startY, Math.atan2(-startDy, -startDx), ecol, hashStr$3(e.from + 'back'));
|
|
9489
|
+
}
|
|
9239
9490
|
if (e.label) {
|
|
9240
|
-
const
|
|
9241
|
-
const my = (y1 + y2) / 2 + nx * EDGE.labelOffset + (e.labelDy ?? 0);
|
|
9491
|
+
const { x: mx, y: my } = polylineLabelPosition(points, EDGE.labelOffset, e.labelDx ?? 0, e.labelDy ?? 0);
|
|
9242
9492
|
// ── Edge label: font, font-size, letter-spacing ──
|
|
9243
9493
|
// always center-anchored (single line)
|
|
9244
9494
|
const eFontSize = Number(e.style?.fontSize ?? EDGE.labelFontSize);
|
|
@@ -9935,7 +10185,7 @@ var AIDiagram = (function (exports) {
|
|
|
9935
10185
|
}));
|
|
9936
10186
|
}
|
|
9937
10187
|
// ── Edge draw helpers ─────────────────────────────────────
|
|
9938
|
-
const EDGE_SHAFT_SELECTOR = '[data-edge-role="shaft"] path';
|
|
10188
|
+
const EDGE_SHAFT_SELECTOR = '[data-edge-role="shaft"] path, path[data-edge-role="shaft"]';
|
|
9939
10189
|
const EDGE_DECOR_SELECTOR = '[data-edge-role="head"], [data-edge-role="label"], [data-edge-role="label-bg"]';
|
|
9940
10190
|
function edgeShaftPaths(el) {
|
|
9941
10191
|
return Array.from(el.querySelectorAll(EDGE_SHAFT_SELECTOR));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sketchmark",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0",
|
|
4
4
|
"description": "A plain-text DSL for hand-drawn diagrams. Write boxes, edges, and groups as code — renders sketchy SVG/Canvas via rough.js with a built-in step-by-step animation system.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"diagram",
|