@myrmidon/gve-snapshot-rendition 2.0.4 → 2.0.5

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.
@@ -41,7 +41,6 @@ export interface RenditionConfig {
41
41
  nodeId: number;
42
42
  count: number;
43
43
  };
44
- textValue?: string;
45
44
  hints?: string[];
46
45
  hintOverrides?: Map<string, HintOverrides>;
47
46
  hintVars?: Map<string, string>;
@@ -73,11 +72,11 @@ export declare class FeatureResolver {
73
72
  * This is used for base text layout adjustments.
74
73
  *
75
74
  * @param features - Features from the first annotate operation (init features)
76
- * @returns Map of node IDs to their offsets (values may be numbers or "Ntw"/"Nth" strings)
75
+ * @returns Map of node IDs to their offsets
77
76
  */
78
77
  extractCharOffsets(features: Feature[] | undefined): Map<number, {
79
- x?: number | string;
80
- y?: number | string;
78
+ x?: number;
79
+ y?: number;
81
80
  }>;
82
81
  /**
83
82
  * Check if features contain a specific rendition feature.
@@ -100,29 +100,8 @@ export declare function getRectCenter(rect: DOMRect | {
100
100
  /**
101
101
  * Get computed text width for a given text and style.
102
102
  * Creates a temporary SVG element to measure.
103
- *
104
- * IMPORTANT: The measurementRoot parameter is critical for correct measurements
105
- * when the component runs inside Angular or other frameworks that apply global
106
- * CSS styles (like font-family) to document.body. Without it, measurements
107
- * happen in document.body where inherited styles may affect font metrics,
108
- * but actual rendering happens inside Shadow DOM where styles are isolated.
109
- * This mismatch causes text positions and hint placements to be incorrect.
110
- *
111
- * When measurementRoot is provided (typically the component's root SVG element),
112
- * measurements happen in the same CSS context as the actual rendering,
113
- * ensuring consistent font metrics.
114
- *
115
- * @param text - The text to measure
116
- * @param fontFamily - Font family to use
117
- * @param fontSize - Font size in pixels
118
- * @param bold - Whether text is bold
119
- * @param italic - Whether text is italic
120
- * @param measurementRoot - Optional SVG element to use as measurement context.
121
- * If provided, a temporary text element is appended here
122
- * for measurement (same CSS context as rendering).
123
- * If not provided, falls back to document.body (legacy behavior).
124
- */
125
- export declare function getTextWidth(text: string, fontFamily: string, fontSize: number, bold?: boolean, italic?: boolean, measurementRoot?: SVGElement): number;
103
+ */
104
+ export declare function getTextWidth(text: string, fontFamily: string, fontSize: number, bold?: boolean, italic?: boolean): number;
126
105
  /**
127
106
  * Move an element to the back (lowest z-index in SVG).
128
107
  */
@@ -19,29 +19,7 @@ export declare class TextLayout {
19
19
  private _settings;
20
20
  private _logger;
21
21
  private _spaceWidth;
22
- /**
23
- * The SVG element used as the measurement context for text width calculations.
24
- * This ensures measurements happen in the same CSS context as actual rendering,
25
- * which is critical when the component runs inside frameworks like Angular
26
- * that may apply global CSS styles affecting font metrics.
27
- *
28
- * When this is undefined, measurements fall back to document.body (legacy behavior)
29
- * which can cause position mismatches if global styles differ from Shadow DOM styles.
30
- */
31
- private _measurementRoot?;
32
22
  constructor(settings: GveRenditionSettings, logger: Logger);
33
- /**
34
- * Set the measurement root for text width calculations.
35
- * This should be called with the root SVG element after it's created,
36
- * before any layout calculations are performed.
37
- *
38
- * IMPORTANT: This ensures text measurements happen in the same CSS context
39
- * as actual rendering (inside Shadow DOM), avoiding position mismatches
40
- * caused by different font metrics in document.body vs Shadow DOM.
41
- *
42
- * @param root - The SVG element to use as measurement context
43
- */
44
- setMeasurementRoot(root: SVGElement): void;
45
23
  /**
46
24
  * Calculate the width of a space character based on reference character.
47
25
  */
@@ -50,14 +28,12 @@ export declare class TextLayout {
50
28
  * Calculate positions for all base text nodes.
51
29
  *
52
30
  * @param nodes - The character nodes to position
53
- * @param charOffsets - Map of node IDs to their offset overrides (from r_char-offsets feature).
54
- * Offset values may be plain numbers (px) or strings with units "tw"/"th"
55
- * (average character width / height of the current font).
31
+ * @param charOffsets - Map of node IDs to their offset overrides (from r_char-offsets feature)
56
32
  * @returns Array of character positions
57
33
  */
58
34
  calculateBaseTextPositions(nodes: CharNode[], charOffsets?: Map<number, {
59
- x?: number | string;
60
- y?: number | string;
35
+ x?: number;
36
+ y?: number;
61
37
  }>): CharPosition[];
62
38
  /**
63
39
  * Calculate position for a single additional text node.
@@ -16,13 +16,6 @@ export declare class TextRenderer {
16
16
  private _spreadingEngine;
17
17
  private _textLayout;
18
18
  private _featureResolver;
19
- /**
20
- * Reference to the root SVG element for text width measurements.
21
- * This ensures measurements happen in the same CSS context as rendering,
22
- * which is critical when running inside Angular or other frameworks
23
- * that apply global CSS styles to document.body.
24
- */
25
- private _measurementRoot?;
26
19
  constructor(settings: GveRenditionSettings, logger: Logger, animationEngine: AnimationEngine, boundsCache: BoundsCache, spreadingEngine: SpreadingEngine);
27
20
  /**
28
21
  * Render base text (v0).
@@ -33,8 +26,8 @@ export declare class TextRenderer {
33
26
  * @returns Promise that resolves when rendering completes
34
27
  */
35
28
  renderBaseText(nodes: CharNode[], rootSvg: SVGElement, charOffsets?: Map<number, {
36
- x?: number | string;
37
- y?: number | string;
29
+ x?: number;
30
+ y?: number;
38
31
  }>): Promise<void>;
39
32
  /**
40
33
  * Render a single character node.
@@ -11,7 +11,6 @@ export declare class DetailsArea {
11
11
  private hoveredElementsSection;
12
12
  private hiddenFeaturesCheckbox;
13
13
  private collapseBtn;
14
- private resizeHandle;
15
14
  private _settings;
16
15
  private _logger;
17
16
  private _summaryService;
@@ -19,11 +18,6 @@ export declare class DetailsArea {
19
18
  private _showHiddenFeatures;
20
19
  private _data;
21
20
  private _currentVersionTag;
22
- private _isResizing;
23
- private _initialHeight;
24
- private _initialMouseY;
25
- private _isPinned;
26
- private _pinnedElements;
27
21
  constructor(settings: GveRenditionSettings, logger: Logger);
28
22
  create(): HTMLElement;
29
23
  /**
@@ -34,18 +28,6 @@ export declare class DetailsArea {
34
28
  * Attach event listeners.
35
29
  */
36
30
  private attachEventListeners;
37
- /**
38
- * Start resizing the details area.
39
- */
40
- private startResize;
41
- /**
42
- * Handle resize drag.
43
- */
44
- private handleResize;
45
- /**
46
- * Stop resizing the details area.
47
- */
48
- private stopResize;
49
31
  /**
50
32
  * Toggle collapse/expand state.
51
33
  */
@@ -72,18 +54,6 @@ export declare class DetailsArea {
72
54
  element: SVGTextElement;
73
55
  node: CharNode;
74
56
  }>): void;
75
- /**
76
- * Render hovered elements with pin button.
77
- */
78
- private renderHoveredElements;
79
- /**
80
- * Toggle pin state.
81
- */
82
- private togglePin;
83
- /**
84
- * Pin a specific element (triggered by click).
85
- */
86
- pinElement(element: SVGTextElement, node: CharNode): void;
87
57
  /**
88
58
  * Filter features based on hidden features setting.
89
59
  */
@@ -13,7 +13,6 @@ export declare class Toolbar {
13
13
  private lastBtn;
14
14
  private versionLabel;
15
15
  private groupBadge;
16
- private logDisplay;
17
16
  private slideshowStartBtn;
18
17
  private slideshowStopBtn;
19
18
  private slideshowReverseBtn;
@@ -22,7 +21,6 @@ export declare class Toolbar {
22
21
  private zoomOutBtn;
23
22
  private fitBtn;
24
23
  private downloadBtn;
25
- private resetLayoutBtn;
26
24
  private _data;
27
25
  private _currentVersionIndex;
28
26
  private _customButtons;
@@ -58,10 +56,6 @@ export declare class Toolbar {
58
56
  * Update version label with current version information.
59
57
  */
60
58
  private updateVersionLabel;
61
- /**
62
- * Update the log display with the current operation's log feature.
63
- */
64
- private updateLogDisplay;
65
59
  /**
66
60
  * Get version information for current step.
67
61
  */
@@ -102,10 +96,6 @@ export declare class Toolbar {
102
96
  * Dispatch display event for parent component to handle.
103
97
  */
104
98
  private dispatchDisplayEvent;
105
- /**
106
- * Dispatch layout event for parent component to handle.
107
- */
108
- private dispatchLayoutEvent;
109
99
  /**
110
100
  * Update data reference (for staged version detection).
111
101
  */
@@ -43,16 +43,12 @@ export declare function filterRenditionFeatures(features: Feature[] | undefined,
43
43
  * Parse char-offsets feature value.
44
44
  * Format: "ID:y=...,x=... ID:y=...,x=..." (multiple patterns separated by space)
45
45
  * Each pattern: ID:y=value,x=value (y and x are optional, can be in any order)
46
- * Values can be plain pixels (e.g. "10") or use font-relative units:
47
- * tw = average character width of the base text font
48
- * th = average character height of the base text font (≈ font size)
49
- * e.g. "0.5th" = half the average character height, "2tw" = twice the average width.
50
46
  *
51
- * @returns Map of node ID to {x?: number|string, y?: number|string}
47
+ * @returns Map of node ID to {x?: number, y?: number}
52
48
  */
53
49
  export declare function parseCharOffsets(value: string): Map<number, {
54
- x?: number | string;
55
- y?: number | string;
50
+ x?: number;
51
+ y?: number;
56
52
  }>;
57
53
  /**
58
54
  * Parse displaced span reference.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@myrmidon/gve-snapshot-rendition",
3
- "version": "2.0.4",
3
+ "version": "2.0.5",
4
4
  "homepage": "https://github.com/vedph/gve-snapshot-rendition",
5
5
  "repository": {
6
6
  "type": "git",
@@ -42,23 +42,23 @@
42
42
  "typescript": "^6.0.3"
43
43
  },
44
44
  "devDependencies": {
45
- "@rollup/plugin-commonjs": "^29.0.2",
45
+ "@rollup/plugin-commonjs": "^29.0.3",
46
46
  "@rollup/plugin-node-resolve": "^16.0.3",
47
47
  "@rollup/plugin-replace": "^6.0.3",
48
48
  "@rollup/plugin-terser": "^1.0.0",
49
49
  "@rollup/plugin-typescript": "^12.3.0",
50
- "@vitest/ui": "^4.1.6",
50
+ "@vitest/ui": "^4.1.9",
51
51
  "concurrency": "^0.1.4",
52
- "concurrently": "^9.2.1",
52
+ "concurrently": "^10.0.3",
53
53
  "lite-server": "^2.6.1",
54
- "rollup": "^4.60.3",
54
+ "rollup": "^4.62.2",
55
55
  "source-map-loader": "^5.0.0",
56
- "ts-loader": "^9.5.7",
56
+ "ts-loader": "^9.6.2",
57
57
  "typescript": "^6.0.3",
58
- "vitest": "^4.1.6"
58
+ "vitest": "^4.1.9"
59
59
  },
60
60
  "optionalDependencies": {
61
- "@rollup/rollup-win32-arm64-msvc": "^4.60.3"
61
+ "@rollup/rollup-win32-arm64-msvc": "^4.62.2"
62
62
  },
63
63
  "scripts": {
64
64
  "build": "rollup -c",
@@ -1,98 +0,0 @@
1
- import { BoundsCache, BoundingRect } from "./bounds-cache";
2
- import { Logger } from "../core/logger";
3
- /**
4
- * Result of spreading calculation.
5
- */
6
- export interface SpreadingResult {
7
- /** Map of element ID to its horizontal shift amount */
8
- horizontalShifts: Map<string, number>;
9
- /** Map of element ID to its vertical shift amount */
10
- verticalShifts: Map<string, number>;
11
- /** Whether any spreading was needed */
12
- hasShifts: boolean;
13
- }
14
- /**
15
- * Metadata about spreading applied to an element for a specific version.
16
- */
17
- export interface SpreadingMetadata {
18
- /** Version index that caused this spreading */
19
- versionIndex: number;
20
- /** Horizontal shift applied (in pixels) */
21
- horizontalShift: number;
22
- /** Vertical shift applied (in pixels) */
23
- verticalShift: number;
24
- }
25
- /**
26
- * Engine for calculating spreading (making room for new elements).
27
- * Implements the "stone in pond" ripple effect to preserve layout.
28
- */
29
- export declare class SpreadingEngine {
30
- private _boundsCache;
31
- private _logger;
32
- /**
33
- * Map of element ID to array of spreading metadata (one per version).
34
- * Each element can be shifted multiple times by different versions.
35
- */
36
- private _spreadingHistory;
37
- constructor(boundsCache: BoundsCache, logger: Logger);
38
- /**
39
- * Track spreading metadata for elements affected by a version.
40
- * Called after spreading is applied to record what happened.
41
- *
42
- * @param versionIndex - Version index that caused the spreading
43
- * @param horizontalShifts - Map of element IDs to horizontal shifts
44
- * @param verticalShifts - Map of element IDs to vertical shifts
45
- */
46
- trackSpreading(versionIndex: number, horizontalShifts: Map<string, number>, verticalShifts: Map<string, number>): void;
47
- /**
48
- * Get spreading metadata for elements affected by a specific version.
49
- * Used when reversing spreading during backward navigation.
50
- *
51
- * @param versionIndex - Version index to get spreading for
52
- * @returns Map of element ID to spreading metadata
53
- */
54
- getSpreadingForVersion(versionIndex: number): Map<string, SpreadingMetadata>;
55
- /**
56
- * Remove spreading history for a specific version.
57
- * Called after spreading is reversed during backward navigation.
58
- *
59
- * @param versionIndex - Version index to remove history for
60
- */
61
- clearSpreadingForVersion(versionIndex: number): void;
62
- /**
63
- * Calculate spreading required to make room for a new element.
64
- *
65
- * @param newElementBounds - Bounds of the element to be added
66
- * @param excludeIds - Element IDs to exclude from shifting (e.g., the new element itself)
67
- * @returns Spreading result with shift amounts for each affected element
68
- */
69
- calculateSpreading(newElementBounds: BoundingRect, excludeIds?: string[]): SpreadingResult;
70
- /**
71
- * Calculate horizontal spreading.
72
- * Elements overlapping on the left are shifted left, those on the right are shifted right.
73
- */
74
- private calculateHorizontalSpreading;
75
- /**
76
- * Calculate vertical spreading.
77
- * Elements overlapping from above are shifted up, those from below are shifted down.
78
- */
79
- private calculateVerticalSpreading;
80
- /**
81
- * Calculate the horizontal overlap between two bounding rectangles.
82
- * Returns 0 if there is no overlap.
83
- */
84
- private calculateHorizontalOverlap;
85
- /**
86
- * Calculate the vertical overlap between two bounding rectangles.
87
- * Returns 0 if there is no overlap.
88
- */
89
- private calculateVerticalOverlap;
90
- /**
91
- * Check if two bounding rectangles overlap.
92
- */
93
- checkOverlap(rect1: BoundingRect, rect2: BoundingRect): boolean;
94
- /**
95
- * Find all elements that overlap with given bounds.
96
- */
97
- findOverlappingElements(bounds: BoundingRect, excludeIds?: string[]): string[];
98
- }