@yalehwang/plantuml-js 0.2.2 → 0.3.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.
Files changed (64) hide show
  1. package/README.md +20 -0
  2. package/dist/core.d.ts +102 -9
  3. package/dist/core.js +91 -51
  4. package/dist/foundation/layers.d.ts +25 -0
  5. package/dist/foundation/layers.js +101 -0
  6. package/dist/foundation/layout.d.ts +116 -0
  7. package/dist/foundation/layout.js +298 -0
  8. package/dist/{model.d.ts → foundation/model.d.ts} +20 -0
  9. package/dist/foundation/relation-semantics.d.ts +49 -0
  10. package/dist/foundation/relation-semantics.js +112 -0
  11. package/dist/{text-measure.d.ts → foundation/text-measure.d.ts} +2 -0
  12. package/dist/{text-measure.js → foundation/text-measure.js} +20 -1
  13. package/dist/index.d.ts +2 -2
  14. package/dist/index.js +1 -1
  15. package/dist/layout/compound.d.ts +59 -0
  16. package/dist/layout/compound.js +1178 -0
  17. package/dist/layout/elk-graph.d.ts +36 -0
  18. package/dist/layout/elk-graph.js +220 -0
  19. package/dist/layout/elk-result.d.ts +18 -0
  20. package/dist/layout/elk-result.js +127 -0
  21. package/dist/layout/elk.d.ts +63 -33
  22. package/dist/layout/elk.js +215 -321
  23. package/dist/layout/fanout-trunk.d.ts +18 -0
  24. package/dist/layout/fanout-trunk.js +380 -0
  25. package/dist/layout/grid-router.d.ts +69 -0
  26. package/dist/layout/grid-router.js +615 -0
  27. package/dist/layout/lane-spread.d.ts +11 -0
  28. package/dist/layout/lane-spread.js +302 -0
  29. package/dist/layout/layout-metrics.d.ts +183 -0
  30. package/dist/layout/layout-metrics.js +766 -0
  31. package/dist/layout/package-endpoints.d.ts +10 -0
  32. package/dist/layout/package-endpoints.js +54 -0
  33. package/dist/layout/placement-strategy.d.ts +98 -0
  34. package/dist/layout/placement-strategy.js +26 -0
  35. package/dist/layout/strategy.d.ts +27 -0
  36. package/dist/layout/strategy.js +19 -0
  37. package/dist/layout/trunk-lanes.d.ts +29 -0
  38. package/dist/layout/trunk-lanes.js +308 -0
  39. package/dist/layout/viz.d.ts +3 -3
  40. package/dist/layout/viz.js +13 -17
  41. package/dist/parser.d.ts +27 -1
  42. package/dist/parser.js +111 -5
  43. package/dist/render/labels.d.ts +44 -0
  44. package/dist/render/labels.js +231 -0
  45. package/dist/render/legend.d.ts +15 -0
  46. package/dist/render/legend.js +42 -0
  47. package/dist/render/svg.d.ts +60 -3
  48. package/dist/render/svg.js +326 -98
  49. package/dist/render/theme.d.ts +109 -0
  50. package/dist/render/theme.js +99 -0
  51. package/dist/serialize.d.ts +32 -0
  52. package/dist/serialize.js +218 -0
  53. package/dist/transform.d.ts +55 -1
  54. package/dist/transform.js +277 -29
  55. package/package.json +4 -3
  56. package/dist/layout-metrics.d.ts +0 -42
  57. package/dist/layout-metrics.js +0 -241
  58. package/dist/layout.d.ts +0 -75
  59. package/dist/layout.js +0 -51
  60. /package/dist/{edge-router.d.ts → foundation/edge-router.d.ts} +0 -0
  61. /package/dist/{edge-router.js → foundation/edge-router.js} +0 -0
  62. /package/dist/{model.js → foundation/model.js} +0 -0
  63. /package/dist/{render-dot.d.ts → foundation/render-dot.d.ts} +0 -0
  64. /package/dist/{render-dot.js → foundation/render-dot.js} +0 -0
package/dist/layout.d.ts DELETED
@@ -1,75 +0,0 @@
1
- /**
2
- * LayoutEngine — the pluggable layout contract. A LayoutEngine is a pure
3
- * function from PlantUmlModel to concrete positions; the parser never talks
4
- * to a layout engine and the renderer never talks to the parser, so swapping
5
- * engines (elkjs, @viz-js/viz, a custom tuner) is an injection, not a rewrite.
6
- */
7
- import { PlantUmlModel, PlantUmlEntity } from './model.js';
8
- export interface Point {
9
- x: number;
10
- y: number;
11
- }
12
- export interface NodeLayout {
13
- id: string;
14
- x: number;
15
- y: number;
16
- width: number;
17
- height: number;
18
- }
19
- export interface EdgeLayout {
20
- id: string;
21
- source: string;
22
- target: string;
23
- points: Point[];
24
- }
25
- export interface PackageLayout {
26
- id: string;
27
- x: number;
28
- y: number;
29
- width: number;
30
- height: number;
31
- }
32
- export interface LayoutResult {
33
- nodes: NodeLayout[];
34
- edges: EdgeLayout[];
35
- /** Package frames; engines without container support may omit this. */
36
- packages?: PackageLayout[];
37
- width: number;
38
- height: number;
39
- }
40
- export interface LayoutEngine {
41
- layout(model: PlantUmlModel): Promise<LayoutResult>;
42
- }
43
- /**
44
- * Shared drawing metrics. The renderer reads these so entity sizing and the
45
- * emitted SVG stay in lockstep: the font family and size are bound to the same
46
- * monospace advance [[../text-measure]] measures with.
47
- */
48
- export declare const METRICS: {
49
- readonly fontFamily: "monospace";
50
- readonly fontSize: 13;
51
- readonly lineHeight: 18;
52
- readonly paddingX: 10;
53
- readonly paddingY: 8;
54
- readonly minWidth: 60;
55
- };
56
- /**
57
- * Package label-tab geometry, shared by the renderer and the layout-metrics
58
- * overlap counter so a drawn tab and a measured tab are the same rectangle.
59
- */
60
- export declare const PACKAGE_LABEL: {
61
- readonly tabHeight: 18;
62
- readonly fontSize: 12;
63
- readonly tabPadding: 12;
64
- };
65
- /** Reconstruct the name drawn in the title compartment, generics expanded. */
66
- export declare function displayName(entity: PlantUmlEntity): string;
67
- /**
68
- * Approximate the on-canvas size of an entity box. The title plus every member
69
- * line contributes one row; the width is the longest rendered line measured
70
- * through the text table plus padding, never below MIN_WIDTH.
71
- */
72
- export declare function estimateEntitySize(entity: PlantUmlEntity): {
73
- width: number;
74
- height: number;
75
- };
package/dist/layout.js DELETED
@@ -1,51 +0,0 @@
1
- /**
2
- * LayoutEngine — the pluggable layout contract. A LayoutEngine is a pure
3
- * function from PlantUmlModel to concrete positions; the parser never talks
4
- * to a layout engine and the renderer never talks to the parser, so swapping
5
- * engines (elkjs, @viz-js/viz, a custom tuner) is an injection, not a rewrite.
6
- */
7
- import { measureTextWidth, MONOSPACE_FONT_SIZE } from './text-measure.js';
8
- /**
9
- * Shared drawing metrics. The renderer reads these so entity sizing and the
10
- * emitted SVG stay in lockstep: the font family and size are bound to the same
11
- * monospace advance [[../text-measure]] measures with.
12
- */
13
- export const METRICS = {
14
- fontFamily: 'monospace',
15
- fontSize: MONOSPACE_FONT_SIZE,
16
- lineHeight: 18,
17
- paddingX: 10,
18
- paddingY: 8,
19
- minWidth: 60,
20
- };
21
- /**
22
- * Package label-tab geometry, shared by the renderer and the layout-metrics
23
- * overlap counter so a drawn tab and a measured tab are the same rectangle.
24
- */
25
- export const PACKAGE_LABEL = {
26
- tabHeight: 18,
27
- fontSize: 12,
28
- tabPadding: 12,
29
- };
30
- /** Reconstruct the name drawn in the title compartment, generics expanded. */
31
- export function displayName(entity) {
32
- const generics = entity.generics;
33
- if (!generics || generics.length === 0)
34
- return entity.name;
35
- return `${entity.name}<${generics.join(', ')}>`;
36
- }
37
- /**
38
- * Approximate the on-canvas size of an entity box. The title plus every member
39
- * line contributes one row; the width is the longest rendered line measured
40
- * through the text table plus padding, never below MIN_WIDTH.
41
- */
42
- export function estimateEntitySize(entity) {
43
- const lines = [
44
- displayName(entity),
45
- ...entity.members.map((m) => m.raw),
46
- ];
47
- const longest = lines.reduce((max, line) => Math.max(max, measureTextWidth(line, METRICS.fontSize)), 0);
48
- const width = Math.max(METRICS.minWidth, longest + METRICS.paddingX * 2);
49
- const height = lines.length * METRICS.lineHeight + METRICS.paddingY * 2;
50
- return { width, height };
51
- }
File without changes