@mentra/sdk 2.1.29-beta.1 → 2.1.29-beta.2
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/dist/display-utils/helpers/DisplayHelpers.d.ts +165 -0
- package/dist/display-utils/helpers/DisplayHelpers.d.ts.map +1 -0
- package/dist/display-utils/helpers/ScrollView.d.ts +183 -0
- package/dist/display-utils/helpers/ScrollView.d.ts.map +1 -0
- package/dist/display-utils/helpers/index.d.ts +11 -0
- package/dist/display-utils/helpers/index.d.ts.map +1 -0
- package/dist/display-utils/index.d.ts +108 -0
- package/dist/display-utils/index.d.ts.map +1 -0
- package/dist/display-utils/measurer/TextMeasurer.d.ts +160 -0
- package/dist/display-utils/measurer/TextMeasurer.d.ts.map +1 -0
- package/dist/display-utils/measurer/index.d.ts +10 -0
- package/dist/display-utils/measurer/index.d.ts.map +1 -0
- package/dist/display-utils/measurer/script-detection.d.ts +53 -0
- package/dist/display-utils/measurer/script-detection.d.ts.map +1 -0
- package/dist/display-utils/profiles/g1.d.ts +33 -0
- package/dist/display-utils/profiles/g1.d.ts.map +1 -0
- package/dist/display-utils/profiles/index.d.ts +9 -0
- package/dist/display-utils/profiles/index.d.ts.map +1 -0
- package/dist/display-utils/profiles/types.d.ts +95 -0
- package/dist/display-utils/profiles/types.d.ts.map +1 -0
- package/dist/display-utils/test/ScrollView.test.d.ts +2 -0
- package/dist/display-utils/test/ScrollView.test.d.ts.map +1 -0
- package/dist/display-utils/test/TextMeasurer.test.d.ts +2 -0
- package/dist/display-utils/test/TextMeasurer.test.d.ts.map +1 -0
- package/dist/display-utils/test/TextWrapper.test.d.ts +2 -0
- package/dist/display-utils/test/TextWrapper.test.d.ts.map +1 -0
- package/dist/display-utils/wrapper/TextWrapper.d.ts +94 -0
- package/dist/display-utils/wrapper/TextWrapper.d.ts.map +1 -0
- package/dist/display-utils/wrapper/index.d.ts +12 -0
- package/dist/display-utils/wrapper/index.d.ts.map +1 -0
- package/dist/display-utils/wrapper/types.d.ts +71 -0
- package/dist/display-utils/wrapper/types.d.ts.map +1 -0
- package/dist/display-utils.d.ts +27 -986
- package/dist/display-utils.d.ts.map +1 -1
- package/dist/display-utils.js +9 -9
- package/dist/display-utils.js.map +2 -2
- package/package.json +4 -7
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import type { DisplayProfile } from "../profiles/types";
|
|
2
|
+
import { TextMeasurer } from "../measurer/TextMeasurer";
|
|
3
|
+
import { TextWrapper } from "../wrapper/TextWrapper";
|
|
4
|
+
import type { WrapOptions, WrapResult } from "../wrapper/types";
|
|
5
|
+
/**
|
|
6
|
+
* Truncation result with metadata.
|
|
7
|
+
*/
|
|
8
|
+
export interface TruncateResult {
|
|
9
|
+
/** The truncated text */
|
|
10
|
+
text: string;
|
|
11
|
+
/** Whether text was truncated */
|
|
12
|
+
wasTruncated: boolean;
|
|
13
|
+
/** Width in pixels of truncated text */
|
|
14
|
+
widthPx: number;
|
|
15
|
+
/** Original text length */
|
|
16
|
+
originalLength: number;
|
|
17
|
+
/** Truncated text length */
|
|
18
|
+
truncatedLength: number;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Page result for pagination.
|
|
22
|
+
*/
|
|
23
|
+
export interface Page {
|
|
24
|
+
/** Lines on this page */
|
|
25
|
+
lines: string[];
|
|
26
|
+
/** Page number (1-indexed) */
|
|
27
|
+
pageNumber: number;
|
|
28
|
+
/** Total number of pages */
|
|
29
|
+
totalPages: number;
|
|
30
|
+
/** Whether this is the first page */
|
|
31
|
+
isFirst: boolean;
|
|
32
|
+
/** Whether this is the last page */
|
|
33
|
+
isLast: boolean;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Chunk result for BLE transmission.
|
|
37
|
+
*/
|
|
38
|
+
export interface Chunk {
|
|
39
|
+
/** The chunk text */
|
|
40
|
+
text: string;
|
|
41
|
+
/** Chunk index (0-indexed) */
|
|
42
|
+
index: number;
|
|
43
|
+
/** Total number of chunks */
|
|
44
|
+
totalChunks: number;
|
|
45
|
+
/** Byte size of this chunk */
|
|
46
|
+
bytes: number;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Optional helper utilities for common display operations.
|
|
50
|
+
* Built on top of TextMeasurer and TextWrapper for convenience.
|
|
51
|
+
*/
|
|
52
|
+
export declare class DisplayHelpers {
|
|
53
|
+
private readonly measurer;
|
|
54
|
+
private readonly wrapper;
|
|
55
|
+
private readonly profile;
|
|
56
|
+
constructor(measurer: TextMeasurer, wrapper: TextWrapper);
|
|
57
|
+
/**
|
|
58
|
+
* Truncate lines array to max count.
|
|
59
|
+
*
|
|
60
|
+
* @param lines - Array of lines
|
|
61
|
+
* @param maxLines - Maximum lines to keep
|
|
62
|
+
* @param fromEnd - If true, keep last N lines; if false, keep first N (default: false)
|
|
63
|
+
* @returns Truncated lines array
|
|
64
|
+
*/
|
|
65
|
+
truncateToLines(lines: string[], maxLines: number, fromEnd?: boolean): string[];
|
|
66
|
+
/**
|
|
67
|
+
* Truncate text to fit within pixel width, adding ellipsis if needed.
|
|
68
|
+
*
|
|
69
|
+
* @param text - Text to truncate
|
|
70
|
+
* @param maxWidthPx - Maximum width in pixels
|
|
71
|
+
* @param ellipsis - Ellipsis string (default: '...')
|
|
72
|
+
* @returns Truncation result
|
|
73
|
+
*/
|
|
74
|
+
truncateWithEllipsis(text: string, maxWidthPx?: number, ellipsis?: string): TruncateResult;
|
|
75
|
+
/**
|
|
76
|
+
* Estimate how many lines text will need without fully wrapping.
|
|
77
|
+
* This is a quick estimate based on average character width.
|
|
78
|
+
*
|
|
79
|
+
* @param text - Text to estimate
|
|
80
|
+
* @param maxWidthPx - Optional width override
|
|
81
|
+
* @returns Estimated line count
|
|
82
|
+
*/
|
|
83
|
+
estimateLineCount(text: string, maxWidthPx?: number): number;
|
|
84
|
+
/**
|
|
85
|
+
* Wrap and truncate text to fit screen in one call.
|
|
86
|
+
*
|
|
87
|
+
* @param text - Text to fit
|
|
88
|
+
* @param options - Wrap options
|
|
89
|
+
* @returns Lines that fit on screen
|
|
90
|
+
*/
|
|
91
|
+
fitToScreen(text: string, options?: WrapOptions): string[];
|
|
92
|
+
/**
|
|
93
|
+
* Wrap text and paginate into screen-sized pages.
|
|
94
|
+
*
|
|
95
|
+
* @param text - Text to paginate
|
|
96
|
+
* @param options - Wrap options (maxLines will be used as page size)
|
|
97
|
+
* @returns Array of pages
|
|
98
|
+
*/
|
|
99
|
+
paginate(text: string, options?: WrapOptions): Page[];
|
|
100
|
+
/**
|
|
101
|
+
* Calculate UTF-8 byte size of text.
|
|
102
|
+
*
|
|
103
|
+
* @param text - Text to measure
|
|
104
|
+
* @returns Byte size
|
|
105
|
+
*/
|
|
106
|
+
calculateByteSize(text: string): number;
|
|
107
|
+
/**
|
|
108
|
+
* Check if text exceeds byte limit.
|
|
109
|
+
*
|
|
110
|
+
* @param text - Text to check
|
|
111
|
+
* @param maxBytes - Optional override (defaults to profile)
|
|
112
|
+
* @returns true if exceeds limit
|
|
113
|
+
*/
|
|
114
|
+
exceedsByteLimit(text: string, maxBytes?: number): boolean;
|
|
115
|
+
/**
|
|
116
|
+
* Split text into BLE-safe chunks.
|
|
117
|
+
* Tries to split at word/line boundaries when possible.
|
|
118
|
+
*
|
|
119
|
+
* @param text - Text to chunk
|
|
120
|
+
* @param chunkSize - Optional override (defaults to profile)
|
|
121
|
+
* @returns Array of chunks
|
|
122
|
+
*/
|
|
123
|
+
splitIntoChunks(text: string, chunkSize?: number): Chunk[];
|
|
124
|
+
/**
|
|
125
|
+
* Calculate line utilization statistics.
|
|
126
|
+
*
|
|
127
|
+
* @param result - Wrap result to analyze
|
|
128
|
+
* @returns Utilization statistics
|
|
129
|
+
*/
|
|
130
|
+
calculateUtilization(result: WrapResult): {
|
|
131
|
+
averageUtilization: number;
|
|
132
|
+
minUtilization: number;
|
|
133
|
+
maxUtilization: number;
|
|
134
|
+
totalWastedPx: number;
|
|
135
|
+
};
|
|
136
|
+
/**
|
|
137
|
+
* Pad lines array to exact count with empty strings.
|
|
138
|
+
*
|
|
139
|
+
* @param lines - Lines to pad
|
|
140
|
+
* @param targetCount - Target number of lines
|
|
141
|
+
* @param padAtEnd - If true, pad at end; if false, pad at start (default: true)
|
|
142
|
+
* @returns Padded lines array
|
|
143
|
+
*/
|
|
144
|
+
padToLineCount(lines: string[], targetCount: number, padAtEnd?: boolean): string[];
|
|
145
|
+
/**
|
|
146
|
+
* Join lines with newlines for display.
|
|
147
|
+
*
|
|
148
|
+
* @param lines - Lines to join
|
|
149
|
+
* @returns Joined string
|
|
150
|
+
*/
|
|
151
|
+
joinLines(lines: string[]): string;
|
|
152
|
+
/**
|
|
153
|
+
* Get the measurer instance.
|
|
154
|
+
*/
|
|
155
|
+
getMeasurer(): TextMeasurer;
|
|
156
|
+
/**
|
|
157
|
+
* Get the wrapper instance.
|
|
158
|
+
*/
|
|
159
|
+
getWrapper(): TextWrapper;
|
|
160
|
+
/**
|
|
161
|
+
* Get the display profile.
|
|
162
|
+
*/
|
|
163
|
+
getProfile(): DisplayProfile;
|
|
164
|
+
}
|
|
165
|
+
//# sourceMappingURL=DisplayHelpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DisplayHelpers.d.ts","sourceRoot":"","sources":["../../../src/display-utils/helpers/DisplayHelpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAA;AACvD,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAA;AACpD,OAAO,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAE/D;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,yBAAyB;IACzB,IAAI,EAAE,MAAM,CAAA;IACZ,iCAAiC;IACjC,YAAY,EAAE,OAAO,CAAA;IACrB,wCAAwC;IACxC,OAAO,EAAE,MAAM,C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EAAE,WAAW,GAAG,MAAM,EAAE;IAK1D;;;;;;OAMG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,IAAI,EAAE;IAuCrD;;;;;OAKG;IACH,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;IAIvC;;;;;;OAMG;IACH,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO;IAK1D;;;;;;;OAOG;IACH,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,KAAK,EAAE;IAgE1D;;;;;OAKG;IACH,oBAAoB,CAAC,MAAM,EAAE,UAAU,GAAG;QACxC,kBAAkB,EAAE,MAAM,CAAA;QAC1B,cAAc,EAAE,MAAM,CAAA;QACtB,cAAc,EAAE,MAAM,CAAA;QACtB,aAAa,EAAE,MAAM,CAAA;KACtB;IA+BD;;;;;;;OAOG;IACH,cAAc,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,WAAW,EAAE,MAAM,EAAE,QAAQ,GAAE,OAAc,GAAG,MAAM,EAAE;IAcxF;;;;;OAKG;IACH,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM;IAIlC;;OAEG;IACH,WAAW,IAAI,YAAY;IAI3B;;OAEG;IACH,UAAU,IAAI,WAAW;IAIzB;;OAEG;IACH,UAAU,IAAI,cAAc;CAG7B"}
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
import type { DisplayProfile } from "../profiles/types";
|
|
2
|
+
import { TextMeasurer } from "../measurer/TextMeasurer";
|
|
3
|
+
import { TextWrapper } from "../wrapper/TextWrapper";
|
|
4
|
+
import type { WrapOptions } from "../wrapper/types";
|
|
5
|
+
/**
|
|
6
|
+
* Scroll position information.
|
|
7
|
+
*/
|
|
8
|
+
export interface ScrollPosition {
|
|
9
|
+
/** Current scroll offset (0 = top) */
|
|
10
|
+
offset: number;
|
|
11
|
+
/** Total number of lines in content */
|
|
12
|
+
totalLines: number;
|
|
13
|
+
/** Number of visible lines (viewport size) */
|
|
14
|
+
visibleLines: number;
|
|
15
|
+
/** Maximum scroll offset */
|
|
16
|
+
maxOffset: number;
|
|
17
|
+
/** Whether we're at the top */
|
|
18
|
+
atTop: boolean;
|
|
19
|
+
/** Whether we're at the bottom */
|
|
20
|
+
atBottom: boolean;
|
|
21
|
+
/** Scroll percentage (0-100) */
|
|
22
|
+
scrollPercent: number;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Visible content from the scroll view.
|
|
26
|
+
*/
|
|
27
|
+
export interface ScrollViewport {
|
|
28
|
+
/** Lines currently visible */
|
|
29
|
+
lines: string[];
|
|
30
|
+
/** Scroll position info */
|
|
31
|
+
position: ScrollPosition;
|
|
32
|
+
/** Whether content was truncated during wrapping */
|
|
33
|
+
contentTruncated: boolean;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* ScrollView provides a scrollable viewport into long wrapped text.
|
|
37
|
+
*
|
|
38
|
+
* Unlike pagination (discrete pages), scrolling allows continuous
|
|
39
|
+
* movement through content line by line.
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* ```typescript
|
|
43
|
+
* const scrollView = new ScrollView(measurer, wrapper)
|
|
44
|
+
* scrollView.setContent("Very long text that wraps to many lines...")
|
|
45
|
+
*
|
|
46
|
+
* // Get initial view (top)
|
|
47
|
+
* let view = scrollView.getViewport()
|
|
48
|
+
* console.log(view.lines) // First 5 lines
|
|
49
|
+
*
|
|
50
|
+
* // Scroll down
|
|
51
|
+
* scrollView.scrollDown(2) // Move down 2 lines
|
|
52
|
+
* view = scrollView.getViewport()
|
|
53
|
+
*
|
|
54
|
+
* // Scroll to bottom
|
|
55
|
+
* scrollView.scrollToBottom()
|
|
56
|
+
*
|
|
57
|
+
* // Scroll to specific position
|
|
58
|
+
* scrollView.scrollTo(10) // Line 10 at top of viewport
|
|
59
|
+
* ```
|
|
60
|
+
*/
|
|
61
|
+
export declare class ScrollView {
|
|
62
|
+
private readonly measurer;
|
|
63
|
+
private readonly wrapper;
|
|
64
|
+
private readonly profile;
|
|
65
|
+
private readonly viewportSize;
|
|
66
|
+
private allLines;
|
|
67
|
+
private wrapResult;
|
|
68
|
+
private scrollOffset;
|
|
69
|
+
constructor(measurer: TextMeasurer, wrapper: TextWrapper, viewportSize?: number);
|
|
70
|
+
/**
|
|
71
|
+
* Set the content to display in the scroll view.
|
|
72
|
+
* Wraps the text and resets scroll position to top.
|
|
73
|
+
*
|
|
74
|
+
* @param text - Text content to display
|
|
75
|
+
* @param options - Optional wrap options
|
|
76
|
+
*/
|
|
77
|
+
setContent(text: string, options?: Omit<WrapOptions, "maxLines">): void;
|
|
78
|
+
/**
|
|
79
|
+
* Append content to the existing scroll view.
|
|
80
|
+
* Useful for streaming/live content like captions.
|
|
81
|
+
*
|
|
82
|
+
* @param text - Text to append
|
|
83
|
+
* @param options - Optional wrap options
|
|
84
|
+
* @param autoScroll - If true, scroll to show new content (default: true)
|
|
85
|
+
*/
|
|
86
|
+
appendContent(text: string, options?: Omit<WrapOptions, "maxLines">, autoScroll?: boolean): void;
|
|
87
|
+
/**
|
|
88
|
+
* Get the current viewport (visible lines).
|
|
89
|
+
*/
|
|
90
|
+
getViewport(): ScrollViewport;
|
|
91
|
+
/**
|
|
92
|
+
* Get current scroll position information.
|
|
93
|
+
*/
|
|
94
|
+
getPosition(): ScrollPosition;
|
|
95
|
+
/**
|
|
96
|
+
* Scroll to a specific line offset.
|
|
97
|
+
*
|
|
98
|
+
* @param offset - Line offset (0 = top)
|
|
99
|
+
*/
|
|
100
|
+
scrollTo(offset: number): void;
|
|
101
|
+
/**
|
|
102
|
+
* Scroll down by a number of lines.
|
|
103
|
+
*
|
|
104
|
+
* @param lines - Number of lines to scroll (default: 1)
|
|
105
|
+
*/
|
|
106
|
+
scrollDown(lines?: number): void;
|
|
107
|
+
/**
|
|
108
|
+
* Scroll up by a number of lines.
|
|
109
|
+
*
|
|
110
|
+
* @param lines - Number of lines to scroll (default: 1)
|
|
111
|
+
*/
|
|
112
|
+
scrollUp(lines?: number): void;
|
|
113
|
+
/**
|
|
114
|
+
* Scroll down by one viewport (page down).
|
|
115
|
+
*/
|
|
116
|
+
pageDown(): void;
|
|
117
|
+
/**
|
|
118
|
+
* Scroll up by one viewport (page up).
|
|
119
|
+
*/
|
|
120
|
+
pageUp(): void;
|
|
121
|
+
/**
|
|
122
|
+
* Scroll to the top.
|
|
123
|
+
*/
|
|
124
|
+
scrollToTop(): void;
|
|
125
|
+
/**
|
|
126
|
+
* Scroll to the bottom.
|
|
127
|
+
*/
|
|
128
|
+
scrollToBottom(): void;
|
|
129
|
+
/**
|
|
130
|
+
* Scroll to show a specific line in the viewport.
|
|
131
|
+
*
|
|
132
|
+
* @param lineIndex - The line index to show
|
|
133
|
+
* @param position - Where in viewport: 'top', 'center', 'bottom' (default: 'top')
|
|
134
|
+
*/
|
|
135
|
+
scrollToLine(lineIndex: number, position?: "top" | "center" | "bottom"): void;
|
|
136
|
+
/**
|
|
137
|
+
* Scroll by a percentage of total content.
|
|
138
|
+
*
|
|
139
|
+
* @param percent - Percentage (0-100)
|
|
140
|
+
*/
|
|
141
|
+
scrollToPercent(percent: number): void;
|
|
142
|
+
/**
|
|
143
|
+
* Check if currently at the top.
|
|
144
|
+
*/
|
|
145
|
+
isAtTop(): boolean;
|
|
146
|
+
/**
|
|
147
|
+
* Check if currently at the bottom.
|
|
148
|
+
*/
|
|
149
|
+
isAtBottom(): boolean;
|
|
150
|
+
/**
|
|
151
|
+
* Check if content is scrollable (more lines than viewport).
|
|
152
|
+
*/
|
|
153
|
+
isScrollable(): boolean;
|
|
154
|
+
/**
|
|
155
|
+
* Get all lines (not just visible).
|
|
156
|
+
*/
|
|
157
|
+
getAllLines(): string[];
|
|
158
|
+
/**
|
|
159
|
+
* Get total line count.
|
|
160
|
+
*/
|
|
161
|
+
getTotalLines(): number;
|
|
162
|
+
/**
|
|
163
|
+
* Get the viewport size.
|
|
164
|
+
*/
|
|
165
|
+
getViewportSize(): number;
|
|
166
|
+
/**
|
|
167
|
+
* Clear all content and reset scroll position.
|
|
168
|
+
*/
|
|
169
|
+
clear(): void;
|
|
170
|
+
/**
|
|
171
|
+
* Get the measurer instance.
|
|
172
|
+
*/
|
|
173
|
+
getMeasurer(): TextMeasurer;
|
|
174
|
+
/**
|
|
175
|
+
* Get the wrapper instance.
|
|
176
|
+
*/
|
|
177
|
+
getWrapper(): TextWrapper;
|
|
178
|
+
/**
|
|
179
|
+
* Get the display profile.
|
|
180
|
+
*/
|
|
181
|
+
getProfile(): DisplayProfile;
|
|
182
|
+
}
|
|
183
|
+
//# sourceMappingURL=ScrollView.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ScrollView.d.ts","sourceRoot":"","sources":["../../../src/display-utils/helpers/ScrollView.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,mBAAmB,CAAA;AACrD,OAAO,EAAC,YAAY,EAAC,MAAM,0BAA0B,CAAA;AACrD,OAAO,EAAC,WAAW,EAAC,MAAM,wBAAwB,CAAA;AAClD,OAAO,KAAK,EAAC,WAAW,EAAa,MAAM,kBAAkB,CAAA;AAE7D;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,sCAAsC;IACtC,MAAM,EAAE,MAAM,CAAA;IACd,uCAAuC;IACvC,UAAU,EAAE,MAAM,CAAA;IAClB,8CAA8C;IAC9C,YAAY,EAAE,MAAM,CAAA;IACpB,4BAA4B;IAC5B,SAAS,EAAE,MAAM,CAAA;IACjB,+BAA+B;IAC/B,KAAK,EAAE,OAAO,CAAA;IACd,kCAAkC;IAClC,QAAQ,EAAE,OAAO,CAAA;IACjB,gCAAgC;IAChC,aAAa,EAAE,MAAM,CAAA;CACtB;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,8BAA8B;IAC9B,KAAK,EAA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;;;;OAKG;IACH,YAAY,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,GAAE,KAAK,GAAG,QAAQ,GAAG,QAAgB,GAAG,IAAI;IAkBpF;;;;OAIG;IACH,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAMtC;;OAEG;IACH,OAAO,IAAI,OAAO;IAIlB;;OAEG;IACH,UAAU,IAAI,OAAO;IAKrB;;OAEG;IACH,YAAY,IAAI,OAAO;IAIvB;;OAEG;IACH,WAAW,IAAI,MAAM,EAAE;IAIvB;;OAEG;IACH,aAAa,IAAI,MAAM;IAIvB;;OAEG;IACH,eAAe,IAAI,MAAM;IAIzB;;OAEG;IACH,KAAK,IAAI,IAAI;IAMb;;OAEG;IACH,WAAW,IAAI,YAAY;IAI3B;;OAEG;IACH,UAAU,IAAI,WAAW;IAIzB;;OAEG;IACH,UAAU,IAAI,cAAc;CAG7B"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Display Helpers Module
|
|
3
|
+
*
|
|
4
|
+
* Optional convenience utilities for common display operations.
|
|
5
|
+
* Built on top of TextMeasurer and TextWrapper.
|
|
6
|
+
*/
|
|
7
|
+
export { DisplayHelpers } from "./DisplayHelpers";
|
|
8
|
+
export { ScrollView } from "./ScrollView";
|
|
9
|
+
export type { TruncateResult, Page, Chunk } from "./DisplayHelpers";
|
|
10
|
+
export type { ScrollPosition, ScrollViewport } from "./ScrollView";
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/display-utils/helpers/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAC,cAAc,EAAC,MAAM,kBAAkB,CAAA;AAC/C,OAAO,EAAC,UAAU,EAAC,MAAM,cAAc,CAAA;AAGvC,YAAY,EAAC,cAAc,EAAE,IAAI,EAAE,KAAK,EAAC,MAAM,kBAAkB,CAAA;AACjE,YAAY,EAAC,cAAc,EAAE,cAAc,EAAC,MAAM,cAAc,CAAA"}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @mentra/display-utils
|
|
3
|
+
*
|
|
4
|
+
* Glasses-agnostic, pixel-accurate text measurement and wrapping library
|
|
5
|
+
* for smart glasses displays.
|
|
6
|
+
*
|
|
7
|
+
* Key features:
|
|
8
|
+
* - Pixel-perfect measurement (no abstract units or averages)
|
|
9
|
+
* - Multiple break modes (character, word, strict-word)
|
|
10
|
+
* - Full script support (Latin, CJK, Korean, Cyrillic)
|
|
11
|
+
* - Configurable display profiles for different glasses hardware
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```typescript
|
|
15
|
+
* import {
|
|
16
|
+
* TextMeasurer,
|
|
17
|
+
* TextWrapper,
|
|
18
|
+
* DisplayHelpers,
|
|
19
|
+
* G1_PROFILE
|
|
20
|
+
* } from '@mentra/display-utils'
|
|
21
|
+
*
|
|
22
|
+
* // Create measurer and wrapper for G1 glasses
|
|
23
|
+
* const measurer = new TextMeasurer(G1_PROFILE)
|
|
24
|
+
* const wrapper = new TextWrapper(measurer, { breakMode: 'character' })
|
|
25
|
+
* const helpers = new DisplayHelpers(measurer, wrapper)
|
|
26
|
+
*
|
|
27
|
+
* // Wrap text for display
|
|
28
|
+
* const result = wrapper.wrap("Hello, world! This is a long text.")
|
|
29
|
+
* console.log(result.lines)
|
|
30
|
+
* // ["Hello, world! This is a long text th-", "at needs wrapping."]
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
export type { DisplayProfile, FontMetrics, UniformScriptWidths, FallbackConfig, DisplayConstraints, ScriptType, } from "./profiles";
|
|
34
|
+
export { G1_PROFILE, G1_PROFILE_LEGACY, G1_HYPHEN_WIDTH_PX, G1_SPACE_WIDTH_PX } from "./profiles";
|
|
35
|
+
export { TextMeasurer } from "./measurer";
|
|
36
|
+
export type { CharMeasurement, TextMeasurement } from "./measurer";
|
|
37
|
+
export { detectScript, isCJKCharacter, isKoreanCharacter, isUniformWidthScript, isUnsupportedScript, needsHyphenForBreak, SCRIPT_RANGES, } from "./measurer";
|
|
38
|
+
export { TextWrapper } from "./wrapper";
|
|
39
|
+
export type { WrapOptions, WrapResult, LineMetrics, BreakMode } from "./wrapper";
|
|
40
|
+
export { DEFAULT_WRAP_OPTIONS } from "./wrapper";
|
|
41
|
+
export { DisplayHelpers, ScrollView } from "./helpers";
|
|
42
|
+
export type { TruncateResult, Page, Chunk, ScrollPosition, ScrollViewport } from "./helpers";
|
|
43
|
+
import { TextMeasurer } from "./measurer";
|
|
44
|
+
import { TextWrapper } from "./wrapper";
|
|
45
|
+
import { DisplayHelpers } from "./helpers";
|
|
46
|
+
import type { DisplayProfile } from "./profiles";
|
|
47
|
+
import type { WrapOptions } from "./wrapper";
|
|
48
|
+
/**
|
|
49
|
+
* Create a complete display toolkit for a given profile.
|
|
50
|
+
*
|
|
51
|
+
* @param profile - Display profile (defaults to G1)
|
|
52
|
+
* @param wrapOptions - Default wrap options
|
|
53
|
+
* @returns Object with measurer, wrapper, and helpers
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* ```typescript
|
|
57
|
+
* const { measurer, wrapper, helpers } = createDisplayToolkit()
|
|
58
|
+
* const lines = wrapper.wrapToLines("Hello, world!")
|
|
59
|
+
* ```
|
|
60
|
+
*/
|
|
61
|
+
export declare function createDisplayToolkit(profile?: DisplayProfile, wrapOptions?: WrapOptions): {
|
|
62
|
+
measurer: TextMeasurer;
|
|
63
|
+
wrapper: TextWrapper;
|
|
64
|
+
helpers: DisplayHelpers;
|
|
65
|
+
profile: DisplayProfile;
|
|
66
|
+
};
|
|
67
|
+
/**
|
|
68
|
+
* Create a G1-configured display toolkit with character breaking.
|
|
69
|
+
* This is the recommended setup for captions and similar high-utilization use cases.
|
|
70
|
+
*
|
|
71
|
+
* @returns Object with measurer, wrapper, and helpers configured for G1
|
|
72
|
+
*
|
|
73
|
+
* @example
|
|
74
|
+
* ```typescript
|
|
75
|
+
* const { wrapper } = createG1Toolkit()
|
|
76
|
+
* const result = wrapper.wrap("Your text here")
|
|
77
|
+
* ```
|
|
78
|
+
*/
|
|
79
|
+
export declare function createG1Toolkit(): {
|
|
80
|
+
measurer: TextMeasurer;
|
|
81
|
+
wrapper: TextWrapper;
|
|
82
|
+
helpers: DisplayHelpers;
|
|
83
|
+
profile: DisplayProfile;
|
|
84
|
+
};
|
|
85
|
+
/**
|
|
86
|
+
* Create a G1-configured display toolkit for LEGACY mobile clients.
|
|
87
|
+
*
|
|
88
|
+
* Use this when the mobile client has old wrapping logic that re-wraps
|
|
89
|
+
* text received from the cloud. This profile uses a reduced display width
|
|
90
|
+
* (~522px instead of 576px) to prevent double-wrapping overflow.
|
|
91
|
+
*
|
|
92
|
+
* @returns Object with measurer, wrapper, and helpers configured for legacy G1 clients
|
|
93
|
+
*
|
|
94
|
+
* @example
|
|
95
|
+
* ```typescript
|
|
96
|
+
* // For old mobile clients that double-wrap
|
|
97
|
+
* const { wrapper } = createG1LegacyToolkit()
|
|
98
|
+
* const result = wrapper.wrap("Your text here")
|
|
99
|
+
* // Lines will be shorter to account for mobile re-wrapping
|
|
100
|
+
* ```
|
|
101
|
+
*/
|
|
102
|
+
export declare function createG1LegacyToolkit(): {
|
|
103
|
+
measurer: TextMeasurer;
|
|
104
|
+
wrapper: TextWrapper;
|
|
105
|
+
helpers: DisplayHelpers;
|
|
106
|
+
profile: DisplayProfile;
|
|
107
|
+
};
|
|
108
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/display-utils/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAMH,YAAY,EACV,cAAc,EACd,WAAW,EACX,mBAAmB,EACnB,cAAc,EACd,kBAAkB,EAClB,UAAU,GACX,MAAM,YAAY,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AQ,EAAE,YAAY,CAAA;IACtB,OAAO,EAAE,WAAW,CAAA;IACpB,OAAO,EAAE,cAAc,CAAA;IACvB,OAAO,EAAE,cAAc,CAAA;CACxB,CAMA;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,qBAAqB,IAAI;IACvC,QAAQ,EAAE,YAAY,CAAA;IACtB,OAAO,EAAE,WAAW,CAAA;IACpB,OAAO,EAAE,cAAc,CAAA;IACvB,OAAO,EAAE,cAAc,CAAA;CACxB,CAMA"}
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import type { DisplayProfile, ScriptType } from "../profiles/types";
|
|
2
|
+
/**
|
|
3
|
+
* Character measurement result with detailed breakdown.
|
|
4
|
+
*/
|
|
5
|
+
export interface CharMeasurement {
|
|
6
|
+
/** The character measured */
|
|
7
|
+
char: string;
|
|
8
|
+
/** Width in rendered pixels */
|
|
9
|
+
widthPx: number;
|
|
10
|
+
/** The script type of the character */
|
|
11
|
+
script: ScriptType;
|
|
12
|
+
/** Whether width came from glyph map (true) or fallback (false) */
|
|
13
|
+
fromGlyphMap: boolean;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Text measurement result with detailed breakdown.
|
|
17
|
+
*/
|
|
18
|
+
export interface TextMeasurement {
|
|
19
|
+
/** The text measured */
|
|
20
|
+
text: string;
|
|
21
|
+
/** Total width in rendered pixels */
|
|
22
|
+
totalWidthPx: number;
|
|
23
|
+
/** Number of characters */
|
|
24
|
+
charCount: number;
|
|
25
|
+
/** Per-character measurements (optional, for debugging) */
|
|
26
|
+
chars?: CharMeasurement[];
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Measures text width in pixels based on a DisplayProfile.
|
|
30
|
+
* All measurements are in actual rendered pixels, not abstract units.
|
|
31
|
+
*
|
|
32
|
+
* Key features:
|
|
33
|
+
* - Pixel-perfect measurement for mapped characters
|
|
34
|
+
* - Uniform-width handling for CJK, Korean, Cyrillic
|
|
35
|
+
* - Safe fallback for unmapped Latin characters
|
|
36
|
+
* - Caching for performance
|
|
37
|
+
*/
|
|
38
|
+
export declare class TextMeasurer {
|
|
39
|
+
private readonly profile;
|
|
40
|
+
private readonly charCache;
|
|
41
|
+
constructor(profile: DisplayProfile);
|
|
42
|
+
/**
|
|
43
|
+
* Pre-compute rendered widths for all known glyphs.
|
|
44
|
+
*/
|
|
45
|
+
private buildCharCache;
|
|
46
|
+
/**
|
|
47
|
+
* Measure the total pixel width of a text string.
|
|
48
|
+
*
|
|
49
|
+
* @param text - The text to measure
|
|
50
|
+
* @returns Width in rendered pixels
|
|
51
|
+
*/
|
|
52
|
+
measureText(text: string): number;
|
|
53
|
+
/**
|
|
54
|
+
* Measure text with detailed breakdown of each character.
|
|
55
|
+
*
|
|
56
|
+
* @param text - The text to measure
|
|
57
|
+
* @returns Detailed measurement result
|
|
58
|
+
*/
|
|
59
|
+
measureTextDetailed(text: string): TextMeasurement;
|
|
60
|
+
/**
|
|
61
|
+
* Measure a single character's pixel width.
|
|
62
|
+
*
|
|
63
|
+
* IMPORTANT: This is PIXEL-PERFECT measurement, not averaging!
|
|
64
|
+
* - Mapped characters: exact width from glyph map
|
|
65
|
+
* - Uniform scripts (CJK, Korean, Cyrillic): verified uniform width
|
|
66
|
+
* - Unmapped Latin: MAX width fallback (safe, never overflow)
|
|
67
|
+
*
|
|
68
|
+
* @param char - Single character to measure
|
|
69
|
+
* @returns Width in rendered pixels
|
|
70
|
+
*/
|
|
71
|
+
measureChar(char: string): number;
|
|
72
|
+
/**
|
|
73
|
+
* Calculate character width (called when not in cache).
|
|
74
|
+
*/
|
|
75
|
+
private calculateCharWidth;
|
|
76
|
+
/**
|
|
77
|
+
* Get the raw glyph width (before render formula).
|
|
78
|
+
* Returns undefined for unmapped characters.
|
|
79
|
+
*
|
|
80
|
+
* @param char - Single character
|
|
81
|
+
* @returns Glyph width in pixels, or undefined if not in glyph map
|
|
82
|
+
*/
|
|
83
|
+
getGlyphWidth(char: string): number | undefined;
|
|
84
|
+
/**
|
|
85
|
+
* Check if text fits within a pixel width.
|
|
86
|
+
*
|
|
87
|
+
* @param text - Text to check
|
|
88
|
+
* @param maxWidthPx - Maximum width in pixels
|
|
89
|
+
* @returns true if text fits
|
|
90
|
+
*/
|
|
91
|
+
fitsInWidth(text: string, maxWidthPx: number): boolean;
|
|
92
|
+
/**
|
|
93
|
+
* Find how many characters fit within a pixel width.
|
|
94
|
+
*
|
|
95
|
+
* @param text - Text to measure
|
|
96
|
+
* @param maxWidthPx - Maximum width in pixels
|
|
97
|
+
* @param startIndex - Starting index (default: 0)
|
|
98
|
+
* @returns Number of characters that fit
|
|
99
|
+
*/
|
|
100
|
+
charsThatFit(text: string, maxWidthPx: number, startIndex?: number): number;
|
|
101
|
+
/**
|
|
102
|
+
* Find the pixel position of a character index in text.
|
|
103
|
+
*
|
|
104
|
+
* @param text - Text to measure
|
|
105
|
+
* @param index - Character index
|
|
106
|
+
* @returns Pixel offset from start of text
|
|
107
|
+
*/
|
|
108
|
+
getPixelOffset(text: string, index: number): number;
|
|
109
|
+
/**
|
|
110
|
+
* Detect the script type of a character.
|
|
111
|
+
*
|
|
112
|
+
* @param char - Single character
|
|
113
|
+
* @returns Script type
|
|
114
|
+
*/
|
|
115
|
+
detectScript(char: string): ScriptType;
|
|
116
|
+
/**
|
|
117
|
+
* Check if a character is from a uniform-width script.
|
|
118
|
+
*
|
|
119
|
+
* @param char - Single character
|
|
120
|
+
* @returns true if character is from CJK, Korean, or Cyrillic
|
|
121
|
+
*/
|
|
122
|
+
isUniformWidth(char: string): boolean;
|
|
123
|
+
/**
|
|
124
|
+
* Get the display profile.
|
|
125
|
+
*/
|
|
126
|
+
getProfile(): DisplayProfile;
|
|
127
|
+
/**
|
|
128
|
+
* Get the display width in pixels.
|
|
129
|
+
*/
|
|
130
|
+
getDisplayWidthPx(): number;
|
|
131
|
+
/**
|
|
132
|
+
* Get the maximum number of lines.
|
|
133
|
+
*/
|
|
134
|
+
getMaxLines(): number;
|
|
135
|
+
/**
|
|
136
|
+
* Get the maximum payload size in bytes.
|
|
137
|
+
*/
|
|
138
|
+
getMaxPayloadBytes(): number;
|
|
139
|
+
/**
|
|
140
|
+
* Calculate the UTF-8 byte size of text.
|
|
141
|
+
*
|
|
142
|
+
* @param text - Text to measure
|
|
143
|
+
* @returns Byte size
|
|
144
|
+
*/
|
|
145
|
+
getByteSize(text: string): number;
|
|
146
|
+
/**
|
|
147
|
+
* Get the width of a hyphen character in rendered pixels.
|
|
148
|
+
*/
|
|
149
|
+
getHyphenWidth(): number;
|
|
150
|
+
/**
|
|
151
|
+
* Get the width of a space character in rendered pixels.
|
|
152
|
+
*/
|
|
153
|
+
getSpaceWidth(): number;
|
|
154
|
+
/**
|
|
155
|
+
* Clear the character cache.
|
|
156
|
+
* Useful if profile metrics change at runtime.
|
|
157
|
+
*/
|
|
158
|
+
clearCache(): void;
|
|
159
|
+
}
|
|
160
|
+
//# sourceMappingURL=TextMeasurer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TextMeasurer.d.ts","sourceRoot":"","sources":["../../../src/display-utils/measurer/TextMeasurer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAGnE;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,6BAA6B;IAC7B,IAAI,EAAE,MAAM,CAAA;IACZ,+BAA+B;IAC/B,OAAO,EAAE,MAAM,CAAA;IACf,uCAAuC;IACvC,MAAM,EAAE,UAAU,CAAA;IAClB,mEAAmE;IACnE,YAAY,EAAE,OAAO,CAAA;CACtB;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,wBAAwB;IACxB,IAAI,EAAE,MAAM,CAAA;IACZ,qCAAqC;IACrC,YAAY,EAAE,MAAM,CAAA;IACpB,2BAA2B;IAC3B,SAAS,EAAE,MAAM,CAAA;IACjB,2DAA2D;IAC3D,KAAK,CAAC,EAAE,eAA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,aAAa,IAAI,MAAM;IAIvB;;;OAGG;IACH,UAAU,IAAI,IAAI;CAInB"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Text Measurer Module
|
|
3
|
+
*
|
|
4
|
+
* Provides pixel-accurate text measurement based on display profiles.
|
|
5
|
+
* All measurements are in actual rendered pixels, not abstract units.
|
|
6
|
+
*/
|
|
7
|
+
export { TextMeasurer } from "./TextMeasurer";
|
|
8
|
+
export type { CharMeasurement, TextMeasurement } from "./TextMeasurer";
|
|
9
|
+
export { detectScript, isCJKCharacter, isKoreanCharacter, isUniformWidthScript, isUnsupportedScript, needsHyphenForBreak, SCRIPT_RANGES, } from "./script-detection";
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/display-utils/measurer/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAC7C,YAAY,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAGtE,OAAO,EACL,YAAY,EACZ,cAAc,EACd,iBAAiB,EACjB,oBAAoB,EACpB,mBAAmB,EACnB,mBAAmB,EACnB,aAAa,GACd,MAAM,oBAAoB,CAAA"}
|