@myrmidon/gve-snapshot-rendition 0.0.1

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 (42) hide show
  1. package/LICENSE +4 -0
  2. package/README.md +135 -0
  3. package/dist/adapter/adapter-models.d.ts +171 -0
  4. package/dist/adapter/data-feature-adapter.d.ts +31 -0
  5. package/dist/adapter/feature-adapter.d.ts +34 -0
  6. package/dist/adapter/index.d.ts +6 -0
  7. package/dist/adapter/matcher.d.ts +38 -0
  8. package/dist/adapter/parser.d.ts +58 -0
  9. package/dist/adapter/tokenizer.d.ts +55 -0
  10. package/dist/animation/animation-engine.d.ts +118 -0
  11. package/dist/animation/animation-factory.d.ts +49 -0
  12. package/dist/core/color-palette.d.ts +39 -0
  13. package/dist/core/gve-snapshot-rendition.d.ts +318 -0
  14. package/dist/core/logger.d.ts +37 -0
  15. package/dist/hint-designer/gve-hint-designer.d.ts +298 -0
  16. package/dist/hint-designer/hint-designer-models.d.ts +32 -0
  17. package/dist/index.cjs.min.js +348 -0
  18. package/dist/index.cjs.min.js.map +1 -0
  19. package/dist/index.d.ts +16 -0
  20. package/dist/index.js +83396 -0
  21. package/dist/index.js.map +1 -0
  22. package/dist/models.d.ts +200 -0
  23. package/dist/rendering/bounds-cache.d.ts +62 -0
  24. package/dist/rendering/feature-resolver.d.ts +98 -0
  25. package/dist/rendering/hint-renderer.d.ts +109 -0
  26. package/dist/rendering/spreading-engine.d.ts +98 -0
  27. package/dist/rendering/svg-utils.d.ts +112 -0
  28. package/dist/rendering/text-layout.d.ts +75 -0
  29. package/dist/rendering/text-renderer.d.ts +73 -0
  30. package/dist/settings/hint-models.d.ts +66 -0
  31. package/dist/settings/settings.d.ts +122 -0
  32. package/dist/ui/details-area.d.ts +81 -0
  33. package/dist/ui/hilites.d.ts +69 -0
  34. package/dist/ui/operation-summary-service.d.ts +76 -0
  35. package/dist/ui/toolbar.d.ts +131 -0
  36. package/dist/ui/version-text-area.d.ts +131 -0
  37. package/dist/ui/versions-list-area.d.ts +88 -0
  38. package/dist/utils/color-palette.d.ts +36 -0
  39. package/dist/utils/feature-utils.d.ts +76 -0
  40. package/dist/utils/node-utils.d.ts +47 -0
  41. package/dist/utils/text-utils.d.ts +35 -0
  42. package/package.json +79 -0
@@ -0,0 +1,131 @@
1
+ import { GveRenditionSettings } from "../settings/settings";
2
+ import { Logger } from "../core/logger";
3
+ /**
4
+ * Version text area component - displays plain text for current version.
5
+ * Can be collapsed/expanded and includes toolbar for text manipulation.
6
+ * Now includes previous text (Text B), pinning, and diff view.
7
+ */
8
+ export declare class VersionTextArea {
9
+ private container;
10
+ private textAreaA;
11
+ private textAreaB;
12
+ private diffPanel;
13
+ private textPanelA;
14
+ private textPanelB;
15
+ private textPanelDiff;
16
+ private copyBtn;
17
+ private wrapBtn;
18
+ private increaseFontBtn;
19
+ private decreaseFontBtn;
20
+ private pinBtn;
21
+ private diffDirectionBtn;
22
+ private collapseBtn;
23
+ private resizeHandle;
24
+ private _settings;
25
+ private _logger;
26
+ private _isCollapsed;
27
+ private _wordWrap;
28
+ private _currentFontSize;
29
+ private _isDragging;
30
+ private _startY;
31
+ private _startHeight;
32
+ private _isPinned;
33
+ private _diffDirection;
34
+ private _previousText;
35
+ private _panelResizing;
36
+ constructor(settings: GveRenditionSettings, logger: Logger);
37
+ /**
38
+ * Create and return the version text area container.
39
+ */
40
+ create(): HTMLElement;
41
+ /**
42
+ * Replace feather icon placeholders with actual SVG icons.
43
+ */
44
+ private replaceFeatherIcons;
45
+ /**
46
+ * Apply text styles from settings.
47
+ */
48
+ private applyTextStyles;
49
+ /**
50
+ * Attach event listeners to toolbar buttons.
51
+ */
52
+ private attachEventListeners;
53
+ /**
54
+ * Copy current text (A) to clipboard.
55
+ */
56
+ private copyText;
57
+ /**
58
+ * Toggle word wrap for text areas.
59
+ */
60
+ private toggleWordWrap;
61
+ /**
62
+ * Increase font size.
63
+ */
64
+ private increaseFontSize;
65
+ /**
66
+ * Decrease font size.
67
+ */
68
+ private decreaseFontSize;
69
+ /**
70
+ * Toggle pin state for previous text (B).
71
+ */
72
+ private togglePin;
73
+ /**
74
+ * Toggle diff direction (B→A or A→B).
75
+ */
76
+ private toggleDiffDirection;
77
+ /**
78
+ * Toggle collapse/expand state.
79
+ */
80
+ private toggleCollapse;
81
+ /**
82
+ * Update the displayed text.
83
+ * @param text - The plain text to display
84
+ */
85
+ updateText(text: string): void;
86
+ /**
87
+ * Update the diff panel.
88
+ */
89
+ private updateDiff;
90
+ /**
91
+ * Render diff results as HTML.
92
+ * @param diffs - Array of diff operations
93
+ */
94
+ private renderDiff;
95
+ /**
96
+ * Escape HTML special characters.
97
+ */
98
+ private escapeHtml;
99
+ /**
100
+ * Clear the text area.
101
+ */
102
+ clear(): void;
103
+ /**
104
+ * Update settings.
105
+ */
106
+ updateSettings(settings: GveRenditionSettings): void;
107
+ /**
108
+ * Start resize operation.
109
+ */
110
+ private startResize;
111
+ /**
112
+ * Handle resize during drag.
113
+ */
114
+ private handleResize;
115
+ /**
116
+ * End resize operation.
117
+ */
118
+ private endResize;
119
+ /**
120
+ * Start panel resize operation.
121
+ */
122
+ private startPanelResize;
123
+ /**
124
+ * Handle panel resize during drag.
125
+ */
126
+ private handlePanelResize;
127
+ /**
128
+ * End panel resize operation.
129
+ */
130
+ private endPanelResize;
131
+ }
@@ -0,0 +1,88 @@
1
+ import { GveRenditionSettings } from "../settings/settings";
2
+ import { Logger } from "../core/logger";
3
+ import { CharChainResult } from "../models";
4
+ /**
5
+ * Versions list area component - displays list of all versions with hilite and navigation.
6
+ */
7
+ export declare class VersionsListArea {
8
+ private container;
9
+ private listContainer;
10
+ private stagedOnlyCheckbox;
11
+ private collapseBtn;
12
+ private _settings;
13
+ private _logger;
14
+ private _colorPalette;
15
+ private _isCollapsed;
16
+ private _showStagedOnly;
17
+ private _data;
18
+ private _currentVersionTag;
19
+ private _hilitedVersionTag;
20
+ private _versions;
21
+ private _hasStagedVersions;
22
+ private _onNavigate?;
23
+ private _onHiliteToggle?;
24
+ constructor(settings: GveRenditionSettings, logger: Logger);
25
+ create(): HTMLElement;
26
+ /**
27
+ * Replace feather icon placeholders with actual SVG icons.
28
+ */
29
+ private replaceFeatherIcons;
30
+ /**
31
+ * Attach event listeners.
32
+ */
33
+ private attachEventListeners;
34
+ /**
35
+ * Toggle collapse/expand state.
36
+ */
37
+ private toggleCollapse;
38
+ /**
39
+ * Set navigation callback.
40
+ */
41
+ setNavigateCallback(callback: (versionTag: string) => void): void;
42
+ /**
43
+ * Set hilite toggle callback.
44
+ */
45
+ setHiliteToggleCallback(callback: (versionTag: string | null) => void): void;
46
+ /**
47
+ * Update with new data.
48
+ * @param data - The CharChainResult data
49
+ */
50
+ updateData(data: CharChainResult | null): void;
51
+ /**
52
+ * Update current version tag.
53
+ * @param versionTag - Current version tag
54
+ */
55
+ updateCurrentVersion(versionTag: string): void;
56
+ /**
57
+ * Clear hilites (e.g., when navigating to another version).
58
+ */
59
+ clearHilites(): void;
60
+ /**
61
+ * Build the versions list from data.
62
+ */
63
+ private buildVersionsList;
64
+ /**
65
+ * Render the versions list.
66
+ */
67
+ private renderVersionsList;
68
+ /**
69
+ * Create a version list item.
70
+ */
71
+ private createVersionItem;
72
+ /**
73
+ * Get color for a version tag.
74
+ */
75
+ getVersionColor(versionTag: string): string;
76
+ /**
77
+ * Handle navigate button click.
78
+ */
79
+ private handleNavigate;
80
+ /**
81
+ * Handle hilite toggle on version link click.
82
+ */
83
+ private handleHiliteToggle;
84
+ /**
85
+ * Update settings.
86
+ */
87
+ updateSettings(settings: GveRenditionSettings): void;
88
+ }
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Generates pastel colors for version tags with maximum visual distinction.
3
+ * Uses HSL color space to ensure consistent saturation and lightness
4
+ * while varying hue to maximize differentiation.
5
+ */
6
+ /**
7
+ * Generate a deterministic pastel color for a version tag.
8
+ * The same version tag will always produce the same color.
9
+ *
10
+ * @param versionTag - The version tag (e.g., "v0", "v1", "v2")
11
+ * @returns A CSS color string in HSL format
12
+ */
13
+ export declare function getVersionColor(versionTag: string): string;
14
+ /**
15
+ * Generate a pastel color by index using golden ratio distribution.
16
+ * This ensures maximum visual distinction between colors.
17
+ *
18
+ * @param index - The index (0-based)
19
+ * @returns A CSS color string in HSL format
20
+ */
21
+ export declare function getColorByIndex(index: number): string;
22
+ /**
23
+ * Generate a color palette for all version tags.
24
+ *
25
+ * @param versionTags - Array of version tags
26
+ * @returns Map of version tag to color string
27
+ */
28
+ export declare function generateVersionPalette(versionTags: string[]): Map<string, string>;
29
+ /**
30
+ * Get a darker variant of a color for hover/active states.
31
+ *
32
+ * @param hslColor - HSL color string
33
+ * @param lightnessReduction - How much to reduce lightness (default: 10%)
34
+ * @returns Darker HSL color string
35
+ */
36
+ export declare function getDarkerVariant(hslColor: string, lightnessReduction?: number): string;
@@ -0,0 +1,76 @@
1
+ import { Feature, OperationFeature } from "../models";
2
+ /**
3
+ * Utility functions for working with features.
4
+ */
5
+ /**
6
+ * Get the value of a feature by name from a feature array.
7
+ * Returns undefined if not found.
8
+ */
9
+ export declare function getFeatureValue(features: Feature[] | undefined, name: string): string | undefined;
10
+ /**
11
+ * Check if a feature exists in a feature array.
12
+ */
13
+ export declare function hasFeature(features: Feature[] | undefined, name: string): boolean;
14
+ /**
15
+ * Get all features with names starting with a specific prefix.
16
+ */
17
+ export declare function getFeaturesByPrefix(features: Feature[] | undefined, prefix: string): Feature[];
18
+ /**
19
+ * Get all rendition features (those starting with "r_").
20
+ */
21
+ export declare function getRenditionFeatures(features: Feature[] | undefined): Feature[];
22
+ /**
23
+ * Get all trace features (those starting with "$").
24
+ */
25
+ export declare function getTraceFeatures(features: Feature[] | undefined): Feature[];
26
+ /**
27
+ * Check if a feature is a trace feature.
28
+ */
29
+ export declare function isTraceFeature(feature: Feature): boolean;
30
+ /**
31
+ * Check if a feature is a rendition feature.
32
+ */
33
+ export declare function isRenditionFeature(feature: Feature): boolean;
34
+ /**
35
+ * Filter out trace features from a feature array.
36
+ */
37
+ export declare function filterTraceFeatures(features: Feature[] | undefined): Feature[];
38
+ /**
39
+ * Filter out rendition features from a feature array (unless debug mode is on).
40
+ */
41
+ export declare function filterRenditionFeatures(features: Feature[] | undefined, debug: boolean): Feature[];
42
+ /**
43
+ * Parse char-offsets feature value.
44
+ * Format: "ID:y=...,x=... ID:y=...,x=..." (multiple patterns separated by space)
45
+ * Each pattern: ID:y=value,x=value (y and x are optional, can be in any order)
46
+ *
47
+ * @returns Map of node ID to {x?: number, y?: number}
48
+ */
49
+ export declare function parseCharOffsets(value: string): Map<number, {
50
+ x?: number;
51
+ y?: number;
52
+ }>;
53
+ /**
54
+ * Parse displaced span reference.
55
+ * Format: "IDxN" where ID is node ID and N is count
56
+ * Example: "21x7" means starting from node 21, include 7 characters
57
+ *
58
+ * @returns {nodeId, count} or undefined if invalid
59
+ */
60
+ export declare function parseDisplacedSpan(value: string): {
61
+ nodeId: number;
62
+ count: number;
63
+ } | undefined;
64
+ /**
65
+ * Parse hint variable assignments from r_hint-vars feature.
66
+ * Format: "name=value name=value ..."
67
+ * Example: "color=red bold=1"
68
+ *
69
+ * @returns Map of variable name to value
70
+ */
71
+ export declare function parseHintVars(value: string): Map<string, string>;
72
+ /**
73
+ * Get node features for a specific node at a specific version.
74
+ * Node features are keyed as "vTAG_NODEID" in the nodeFeatures map.
75
+ */
76
+ export declare function getNodeFeatures(nodeFeatures: Record<string, OperationFeature[]>, versionTag: string, nodeId: number): OperationFeature[];
@@ -0,0 +1,47 @@
1
+ import { CharNode } from "../models";
2
+ /**
3
+ * Utility functions for working with character nodes.
4
+ */
5
+ /**
6
+ * Generate character nodes from a string.
7
+ * Each character gets a node with a sequential ID starting from 1.
8
+ *
9
+ * @param text - The text to convert to nodes
10
+ * @returns Array of character nodes
11
+ */
12
+ export declare function stringToNodes(text: string): CharNode[];
13
+ /**
14
+ * Get a label for a character node suitable for display.
15
+ * Uses special symbols for whitespace characters.
16
+ */
17
+ export declare function getNodeLabel(node: CharNode): string;
18
+ /**
19
+ * Check if a node represents a line break.
20
+ */
21
+ export declare function isLineBreak(node: CharNode): boolean;
22
+ /**
23
+ * Check if a node represents a space.
24
+ */
25
+ export declare function isSpace(node: CharNode): boolean;
26
+ /**
27
+ * Check if a node is printable (not a space or line break).
28
+ */
29
+ export declare function isPrintable(node: CharNode): boolean;
30
+ /**
31
+ * Find a node by ID in an array of nodes.
32
+ */
33
+ export declare function findNodeById(nodes: CharNode[], id: number): CharNode | undefined;
34
+ /**
35
+ * Get a range of nodes starting from a specific node ID.
36
+ * Used for processing displaced spans (IDxN format).
37
+ *
38
+ * @param nodes - All available nodes
39
+ * @param startId - Starting node ID
40
+ * @param count - Number of nodes to include
41
+ * @returns Array of nodes in the span, or empty array if not found
42
+ */
43
+ export declare function getNodeSpan(nodes: CharNode[], startId: number, count: number): CharNode[];
44
+ /**
45
+ * Get nodes by their IDs.
46
+ */
47
+ export declare function getNodesByIds(nodes: CharNode[], ids: number[]): CharNode[];
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Text processing utilities.
3
+ */
4
+ /**
5
+ * Escape HTML special characters to prevent injection.
6
+ */
7
+ export declare function escapeHtml(text: string): string;
8
+ /**
9
+ * Parse an offset value which can be either:
10
+ * - A number (e.g., 10)
11
+ * - A suffixed number with "th" (text height) or "tw" (text width)
12
+ *
13
+ * @param value - The offset value (number or string)
14
+ * @param textHeight - The height of reference text bounds
15
+ * @param textWidth - The width of reference text bounds
16
+ * @returns The computed offset in pixels
17
+ */
18
+ export declare function parseOffset(value: number | string, textHeight: number, textWidth: number): number;
19
+ /**
20
+ * Replace placeholders in SVG content.
21
+ * Placeholders are in the format {{featureName}}.
22
+ *
23
+ * @param svgContent - The SVG content with placeholders
24
+ * @param variables - Map of variable names to values
25
+ * @returns SVG content with placeholders replaced
26
+ */
27
+ export declare function resolvePlaceholders(svgContent: string, variables: Map<string, string>): string;
28
+ /**
29
+ * Generate a unique ID by combining prefix and suffix.
30
+ */
31
+ export declare function generateId(prefix: string, suffix: string | number): string;
32
+ /**
33
+ * Truncate a string to a maximum length, adding ellipsis if needed.
34
+ */
35
+ export declare function truncate(text: string, maxLength: number): string;
package/package.json ADDED
@@ -0,0 +1,79 @@
1
+ {
2
+ "name": "@myrmidon/gve-snapshot-rendition",
3
+ "version": "0.0.1",
4
+ "homepage": "https://github.com/vedph/gve-snapshot-rendition",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "https://github.com/vedph/gve-snapshot-rendition"
8
+ },
9
+ "author": "Daniele Fusi",
10
+ "license": "",
11
+ "description": "Web components for rendering interactive text transformations with hint designer. This package is an early version published for internal evaluation and staging use only. A final open-source license will be published later.",
12
+ "keywords": [
13
+ "snapshot",
14
+ "rendition",
15
+ "VEdition",
16
+ "genetic-philology",
17
+ "hint-designer",
18
+ "text-transformation"
19
+ ],
20
+ "main": "./dist/index.js",
21
+ "type": "module",
22
+ "types": "./dist/index.d.ts",
23
+ "scripts": {
24
+ "build": "rollup -c",
25
+ "watch": "rollup -c -w",
26
+ "start": "concurrently \"rollup -c -w\" \"lite-server\"",
27
+ "start:designer": "concurrently \"rollup -c -w\" \"lite-server -c bs-config.designer.json\"",
28
+ "test": "vitest run",
29
+ "test:watch": "vitest",
30
+ "test-ui": "vitest --ui",
31
+ "prepublishOnly": "npm run test && npm run build",
32
+ "prepack": "npm run build",
33
+ "publish:public": "npm publish --access=public"
34
+ },
35
+ "exports": {
36
+ ".": {
37
+ "import": "./dist/index.js",
38
+ "types": "./dist/index.d.ts"
39
+ }
40
+ },
41
+ "files": [
42
+ "dist",
43
+ "README.md",
44
+ "LICENSE"
45
+ ],
46
+ "packageManager": "pnpm@10.24.0",
47
+ "dependencies": {
48
+ "fast-diff": "^1.3.0",
49
+ "feather-icons": "^4.29.2",
50
+ "gsap": "^3.13.0",
51
+ "highlight.js": "^11.11.1",
52
+ "svg-pan-zoom": "^3.6.2",
53
+ "tslib": "^2.8.1",
54
+ "typescript": "^5.7.2"
55
+ },
56
+ "devDependencies": {
57
+ "@rollup/plugin-commonjs": "^29.0.0",
58
+ "@rollup/plugin-node-resolve": "^16.0.3",
59
+ "@rollup/plugin-terser": "^0.4.4",
60
+ "@rollup/plugin-typescript": "^12.3.0",
61
+ "@vitest/ui": "^4.0.14",
62
+ "concurrency": "^0.1.4",
63
+ "concurrently": "^9.2.1",
64
+ "lite-server": "^2.6.1",
65
+ "rollup": "^4.53.3",
66
+ "source-map-loader": "^5.0.0",
67
+ "ts-loader": "^9.5.4",
68
+ "typescript": "^5.9.3",
69
+ "vitest": "^4.0.14"
70
+ },
71
+ "optionalDependencies": {
72
+ "@rollup/rollup-win32-arm64-msvc": "^4.53.3"
73
+ },
74
+ "pnpm": {
75
+ "overrides": {
76
+ "rollup": "npm:@rollup/wasm-node"
77
+ }
78
+ }
79
+ }