@glassly/miniapp 0.3.0-dev.2 → 0.3.0-dev.460

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 (255) hide show
  1. package/README.md +219 -74
  2. package/dist/background/index.d.ts +14 -8
  3. package/dist/background/index.d.ts.map +1 -1
  4. package/dist/background/index.js +4 -0
  5. package/dist/background/index.js.map +1 -1
  6. package/dist/background/register.d.ts +1 -1
  7. package/dist/background/register.js +1 -1
  8. package/dist/display/index.d.ts +23 -0
  9. package/dist/display/index.d.ts.map +1 -0
  10. package/dist/display/index.js +17 -0
  11. package/dist/display/index.js.map +1 -0
  12. package/dist/display/measurer/TextMeasurer.d.ts +160 -0
  13. package/dist/display/measurer/TextMeasurer.d.ts.map +1 -0
  14. package/dist/display/measurer/TextMeasurer.js +272 -0
  15. package/dist/display/measurer/TextMeasurer.js.map +1 -0
  16. package/dist/display/measurer/index.d.ts +10 -0
  17. package/dist/display/measurer/index.d.ts.map +1 -0
  18. package/dist/display/measurer/index.js +11 -0
  19. package/dist/display/measurer/index.js.map +1 -0
  20. package/dist/display/measurer/script-detection.d.ts +53 -0
  21. package/dist/display/measurer/script-detection.d.ts.map +1 -0
  22. package/dist/display/measurer/script-detection.js +184 -0
  23. package/dist/display/measurer/script-detection.js.map +1 -0
  24. package/dist/display/pixelArt.d.ts +22 -0
  25. package/dist/display/pixelArt.d.ts.map +1 -0
  26. package/dist/display/pixelArt.js +126 -0
  27. package/dist/display/pixelArt.js.map +1 -0
  28. package/dist/display/profiles/g1.d.ts +33 -0
  29. package/dist/display/profiles/g1.d.ts.map +1 -0
  30. package/dist/display/profiles/g1.js +214 -0
  31. package/dist/display/profiles/g1.js.map +1 -0
  32. package/dist/display/profiles/g2.d.ts +13 -0
  33. package/dist/display/profiles/g2.d.ts.map +1 -0
  34. package/dist/display/profiles/g2.js +34 -0
  35. package/dist/display/profiles/g2.js.map +1 -0
  36. package/dist/display/profiles/index.d.ts +12 -0
  37. package/dist/display/profiles/index.d.ts.map +1 -0
  38. package/dist/display/profiles/index.js +15 -0
  39. package/dist/display/profiles/index.js.map +1 -0
  40. package/dist/display/profiles/nex.d.ts +10 -0
  41. package/dist/display/profiles/nex.d.ts.map +1 -0
  42. package/dist/display/profiles/nex.js +150 -0
  43. package/dist/display/profiles/nex.js.map +1 -0
  44. package/dist/display/profiles/types.d.ts +103 -0
  45. package/dist/display/profiles/types.d.ts.map +1 -0
  46. package/dist/display/profiles/types.js +2 -0
  47. package/dist/display/profiles/types.js.map +1 -0
  48. package/dist/display/profiles/z100.d.ts +33 -0
  49. package/dist/display/profiles/z100.d.ts.map +1 -0
  50. package/dist/display/profiles/z100.js +182 -0
  51. package/dist/display/profiles/z100.js.map +1 -0
  52. package/dist/display/scene/types.d.ts +292 -0
  53. package/dist/display/scene/types.d.ts.map +1 -0
  54. package/dist/display/scene/types.js +0 -0
  55. package/dist/display/scene/types.js.map +1 -0
  56. package/dist/display/wrapper/TextWrapper.d.ts +102 -0
  57. package/dist/display/wrapper/TextWrapper.d.ts.map +1 -0
  58. package/dist/display/wrapper/TextWrapper.js +469 -0
  59. package/dist/display/wrapper/TextWrapper.js.map +1 -0
  60. package/dist/display/wrapper/index.d.ts +12 -0
  61. package/dist/display/wrapper/index.d.ts.map +1 -0
  62. package/dist/display/wrapper/index.js +12 -0
  63. package/dist/display/wrapper/index.js.map +1 -0
  64. package/dist/display/wrapper/types.d.ts +75 -0
  65. package/dist/display/wrapper/types.d.ts.map +1 -0
  66. package/dist/display/wrapper/types.js +11 -0
  67. package/dist/display/wrapper/types.js.map +1 -0
  68. package/dist/globals.d.ts +5 -5
  69. package/dist/globals.d.ts.map +1 -1
  70. package/dist/globals.js +1 -1
  71. package/dist/globals.js.map +1 -1
  72. package/dist/hardware.d.ts +4 -18
  73. package/dist/hardware.d.ts.map +1 -1
  74. package/dist/hardware.js +2 -13
  75. package/dist/hardware.js.map +1 -1
  76. package/dist/index.d.ts +16 -10
  77. package/dist/index.d.ts.map +1 -1
  78. package/dist/index.js +3 -1
  79. package/dist/index.js.map +1 -1
  80. package/dist/knownApps.d.ts +26 -0
  81. package/dist/knownApps.d.ts.map +1 -0
  82. package/dist/knownApps.js +140 -0
  83. package/dist/knownApps.js.map +1 -0
  84. package/dist/mirror/canvas.d.ts +22 -0
  85. package/dist/mirror/canvas.d.ts.map +1 -0
  86. package/dist/mirror/canvas.js +311 -0
  87. package/dist/mirror/canvas.js.map +1 -0
  88. package/dist/mirror/geometry.d.ts +69 -0
  89. package/dist/mirror/geometry.d.ts.map +1 -0
  90. package/dist/mirror/geometry.js +75 -0
  91. package/dist/mirror/geometry.js.map +1 -0
  92. package/dist/mirror/index.d.ts +3 -0
  93. package/dist/mirror/index.d.ts.map +1 -0
  94. package/dist/mirror/index.js +2 -0
  95. package/dist/mirror/index.js.map +1 -0
  96. package/dist/mirror/types.d.ts +40 -0
  97. package/dist/mirror/types.d.ts.map +1 -0
  98. package/dist/mirror/types.js +2 -0
  99. package/dist/mirror/types.js.map +1 -0
  100. package/dist/modules/auth.d.ts +1 -1
  101. package/dist/modules/auth.d.ts.map +1 -1
  102. package/dist/modules/auth.js +2 -2
  103. package/dist/modules/auth.js.map +1 -1
  104. package/dist/modules/compass.d.ts +47 -0
  105. package/dist/modules/compass.d.ts.map +1 -0
  106. package/dist/modules/compass.js +39 -0
  107. package/dist/modules/compass.js.map +1 -0
  108. package/dist/modules/display.d.ts +192 -8
  109. package/dist/modules/display.d.ts.map +1 -1
  110. package/dist/modules/display.js +40 -3
  111. package/dist/modules/display.js.map +1 -1
  112. package/dist/modules/events.d.ts +30 -2
  113. package/dist/modules/events.d.ts.map +1 -1
  114. package/dist/modules/events.js.map +1 -1
  115. package/dist/modules/input.d.ts +40 -1
  116. package/dist/modules/input.d.ts.map +1 -1
  117. package/dist/modules/input.js +45 -1
  118. package/dist/modules/input.js.map +1 -1
  119. package/dist/modules/latest-render-scheduler.d.ts +19 -0
  120. package/dist/modules/latest-render-scheduler.d.ts.map +1 -0
  121. package/dist/modules/latest-render-scheduler.js +54 -0
  122. package/dist/modules/latest-render-scheduler.js.map +1 -0
  123. package/dist/modules/lightSensor.d.ts +44 -0
  124. package/dist/modules/lightSensor.d.ts.map +1 -0
  125. package/dist/modules/lightSensor.js +33 -0
  126. package/dist/modules/lightSensor.js.map +1 -0
  127. package/dist/modules/mic.d.ts +3 -2
  128. package/dist/modules/mic.d.ts.map +1 -1
  129. package/dist/modules/mic.js +3 -2
  130. package/dist/modules/mic.js.map +1 -1
  131. package/dist/modules/miniapps.d.ts +2 -0
  132. package/dist/modules/miniapps.d.ts.map +1 -1
  133. package/dist/modules/miniapps.js.map +1 -1
  134. package/dist/modules/mirror.d.ts +16 -0
  135. package/dist/modules/mirror.d.ts.map +1 -0
  136. package/dist/modules/mirror.js +40 -0
  137. package/dist/modules/mirror.js.map +1 -0
  138. package/dist/modules/mono-text-rows.d.ts +20 -0
  139. package/dist/modules/mono-text-rows.d.ts.map +1 -0
  140. package/dist/modules/mono-text-rows.js +26 -0
  141. package/dist/modules/mono-text-rows.js.map +1 -0
  142. package/dist/modules/navigation.d.ts.map +1 -1
  143. package/dist/modules/navigation.js +21 -14
  144. package/dist/modules/navigation.js.map +1 -1
  145. package/dist/modules/phone.d.ts +26 -1
  146. package/dist/modules/phone.d.ts.map +1 -1
  147. package/dist/modules/phone.js +28 -0
  148. package/dist/modules/phone.js.map +1 -1
  149. package/dist/modules/settings.d.ts +45 -0
  150. package/dist/modules/settings.d.ts.map +1 -0
  151. package/dist/modules/settings.js +54 -0
  152. package/dist/modules/settings.js.map +1 -0
  153. package/dist/modules/system.d.ts +21 -0
  154. package/dist/modules/system.d.ts.map +1 -1
  155. package/dist/modules/system.js +12 -0
  156. package/dist/modules/system.js.map +1 -1
  157. package/dist/modules/transcription.d.ts +3 -2
  158. package/dist/modules/transcription.d.ts.map +1 -1
  159. package/dist/modules/transcription.js +3 -2
  160. package/dist/modules/transcription.js.map +1 -1
  161. package/dist/protocol.d.ts +65 -5
  162. package/dist/protocol.d.ts.map +1 -1
  163. package/dist/protocol.js +66 -5
  164. package/dist/protocol.js.map +1 -1
  165. package/dist/react/MirrorCanvas.d.ts +10 -0
  166. package/dist/react/MirrorCanvas.d.ts.map +1 -0
  167. package/dist/react/MirrorCanvas.js +23 -0
  168. package/dist/react/MirrorCanvas.js.map +1 -0
  169. package/dist/react/index.d.ts +2 -0
  170. package/dist/react/index.d.ts.map +1 -1
  171. package/dist/react/index.js +1 -0
  172. package/dist/react/index.js.map +1 -1
  173. package/dist/react/useColorScheme.d.ts +2 -3
  174. package/dist/react/useColorScheme.d.ts.map +1 -1
  175. package/dist/react/useColorScheme.js +15 -8
  176. package/dist/react/useColorScheme.js.map +1 -1
  177. package/dist/react/useRpc.js +2 -2
  178. package/dist/react/useRpc.js.map +1 -1
  179. package/dist/react/useSafeArea.d.ts.map +1 -1
  180. package/dist/react/useSafeArea.js +2 -2
  181. package/dist/react/useSafeArea.js.map +1 -1
  182. package/dist/session.d.ts +50 -4
  183. package/dist/session.d.ts.map +1 -1
  184. package/dist/session.js +35 -6
  185. package/dist/session.js.map +1 -1
  186. package/dist/transport/auto.d.ts +2 -2
  187. package/dist/transport/auto.js +2 -2
  188. package/dist/transport/dispatch.d.ts +1 -1
  189. package/dist/transport/dispatch.js +1 -1
  190. package/dist/transport/mock.d.ts +4 -4
  191. package/dist/transport/mock.d.ts.map +1 -1
  192. package/dist/transport/mock.js +31 -7
  193. package/dist/transport/mock.js.map +1 -1
  194. package/dist/ui/index.d.ts +2 -0
  195. package/dist/ui/index.d.ts.map +1 -1
  196. package/dist/ui/index.js +1 -0
  197. package/dist/ui/index.js.map +1 -1
  198. package/package.json +19 -3
  199. package/src/background/index.ts +26 -4
  200. package/src/background/register.ts +1 -1
  201. package/src/display/index.ts +83 -0
  202. package/src/display/measurer/TextMeasurer.ts +346 -0
  203. package/src/display/measurer/index.ts +21 -0
  204. package/src/display/measurer/script-detection.ts +218 -0
  205. package/src/display/pixelArt.ts +141 -0
  206. package/src/display/profiles/g1.ts +237 -0
  207. package/src/display/profiles/g2.ts +39 -0
  208. package/src/display/profiles/index.ts +28 -0
  209. package/src/display/profiles/nex.ts +166 -0
  210. package/src/display/profiles/types.ts +132 -0
  211. package/src/display/profiles/z100.ts +198 -0
  212. package/src/display/scene/types.ts +335 -0
  213. package/src/display/wrapper/TextWrapper.ts +546 -0
  214. package/src/display/wrapper/index.ts +15 -0
  215. package/src/display/wrapper/types.ts +102 -0
  216. package/src/globals.ts +5 -5
  217. package/src/hardware.ts +6 -21
  218. package/src/index.ts +34 -6
  219. package/src/knownApps.ts +170 -0
  220. package/src/mirror/canvas.ts +322 -0
  221. package/src/mirror/geometry.ts +128 -0
  222. package/src/mirror/index.ts +2 -0
  223. package/src/mirror/types.ts +38 -0
  224. package/src/modules/auth.ts +2 -2
  225. package/src/modules/compass.ts +69 -0
  226. package/src/modules/display.ts +222 -12
  227. package/src/modules/events.ts +27 -1
  228. package/src/modules/input.ts +55 -2
  229. package/src/modules/latest-render-scheduler.ts +55 -0
  230. package/src/modules/lightSensor.ts +61 -0
  231. package/src/modules/mic.ts +3 -2
  232. package/src/modules/miniapps.ts +2 -0
  233. package/src/modules/mirror.ts +42 -0
  234. package/src/modules/mono-text-rows.ts +30 -0
  235. package/src/modules/navigation.ts +20 -14
  236. package/src/modules/phone.ts +40 -1
  237. package/src/modules/settings.ts +64 -0
  238. package/src/modules/system.ts +30 -1
  239. package/src/modules/transcription.ts +3 -2
  240. package/src/protocol.ts +72 -5
  241. package/src/react/MirrorCanvas.tsx +35 -0
  242. package/src/react/index.ts +3 -0
  243. package/src/react/useColorScheme.ts +17 -8
  244. package/src/react/useRpc.ts +2 -2
  245. package/src/react/useSafeArea.ts +2 -2
  246. package/src/session.ts +78 -8
  247. package/src/transport/auto.ts +2 -2
  248. package/src/transport/dispatch.ts +1 -1
  249. package/src/transport/mock.ts +42 -11
  250. package/src/ui/index.ts +3 -0
  251. package/dist/modules/heading.d.ts +0 -16
  252. package/dist/modules/heading.d.ts.map +0 -1
  253. package/dist/modules/heading.js +0 -20
  254. package/dist/modules/heading.js.map +0 -1
  255. package/src/modules/heading.ts +0 -23
@@ -0,0 +1,469 @@
1
+ import { isCJKCharacter, needsHyphenForBreak } from "../measurer/script-detection";
2
+ import { DEFAULT_WRAP_OPTIONS } from "./types";
3
+ /**
4
+ * Wraps text to fit display constraints.
5
+ *
6
+ * Supports multiple break modes:
7
+ * - 'character': Break mid-word with hyphen for 100% line utilization
8
+ * - 'word': Break at word boundaries, hyphenate only if word > line width
9
+ * - 'strict-word': Break at word boundaries only, no hyphenation
10
+ *
11
+ * Key features:
12
+ * - Pixel-accurate wrapping (no abstract units)
13
+ * - Hyphen-aware breaking (accounts for hyphen width)
14
+ * - CJK support (breaks anywhere without hyphen)
15
+ * - Preserves explicit newlines
16
+ * - Respects byte limits for BLE transmission
17
+ */
18
+ export class TextWrapper {
19
+ constructor(measurer, defaultOptions) {
20
+ this.measurer = measurer;
21
+ const profile = measurer.getProfile();
22
+ this.defaultOptions = {
23
+ maxWidthPx: profile.displayWidthPx,
24
+ maxLines: profile.maxLines,
25
+ maxBytes: profile.maxPayloadBytes,
26
+ ...DEFAULT_WRAP_OPTIONS,
27
+ ...defaultOptions,
28
+ };
29
+ }
30
+ /**
31
+ * Wrap text to fit within constraints.
32
+ *
33
+ * @param text - Text to wrap (may contain \n for explicit breaks)
34
+ * @param options - Override default options
35
+ * @returns Wrap result with lines and metadata
36
+ */
37
+ wrap(text, options) {
38
+ const opts = this.mergeOptions(options);
39
+ const { maxWidthPx, maxLines, maxBytes, breakMode, preserveNewlines } = opts;
40
+ if (!text || text.length === 0) {
41
+ return this.createEmptyResult(opts);
42
+ }
43
+ // Split by explicit newlines if preserving them
44
+ const paragraphs = preserveNewlines ? text.split("\n") : [text];
45
+ const allLines = [];
46
+ const allMetrics = [];
47
+ let totalBytes = 0;
48
+ let truncated = false;
49
+ for (let pIndex = 0; pIndex < paragraphs.length; pIndex++) {
50
+ const paragraph = paragraphs[pIndex];
51
+ const isFromNewline = pIndex > 0;
52
+ // Wrap this paragraph
53
+ const paragraphLines = this.wrapParagraph(paragraph, maxWidthPx, breakMode, opts);
54
+ for (let lIndex = 0; lIndex < paragraphLines.length; lIndex++) {
55
+ const line = paragraphLines[lIndex];
56
+ const lineBytes = this.measurer.getByteSize(line);
57
+ // Check if we've exceeded limits
58
+ if (allLines.length >= maxLines) {
59
+ truncated = true;
60
+ break;
61
+ }
62
+ if (totalBytes + lineBytes > maxBytes) {
63
+ truncated = true;
64
+ break;
65
+ }
66
+ const widthPx = this.measurer.measureText(line);
67
+ const metrics = {
68
+ text: line,
69
+ widthPx,
70
+ bytes: lineBytes,
71
+ utilizationPercent: Math.round((widthPx / maxWidthPx) * 100),
72
+ endsWithHyphen: line.endsWith(opts.hyphenChar) && lIndex < paragraphLines.length - 1,
73
+ fromExplicitNewline: isFromNewline && lIndex === 0,
74
+ };
75
+ allLines.push(line);
76
+ allMetrics.push(metrics);
77
+ totalBytes += lineBytes;
78
+ // Add newline byte between lines
79
+ if (allLines.length < maxLines) {
80
+ totalBytes += 1; // \n is 1 byte
81
+ }
82
+ }
83
+ if (truncated)
84
+ break;
85
+ }
86
+ // Find max line width
87
+ const maxLineWidthPx = allMetrics.reduce((max, m) => Math.max(max, m.widthPx), 0);
88
+ return {
89
+ lines: allLines,
90
+ truncated,
91
+ maxLineWidthPx,
92
+ totalBytes,
93
+ lineMetrics: allMetrics,
94
+ originalText: text,
95
+ breakMode,
96
+ };
97
+ }
98
+ /**
99
+ * Simple wrap returning just lines (convenience method).
100
+ *
101
+ * @param text - Text to wrap
102
+ * @param options - Override default options
103
+ * @returns Array of wrapped lines
104
+ */
105
+ wrapToLines(text, options) {
106
+ return this.wrap(text, options).lines;
107
+ }
108
+ /**
109
+ * Check if text needs wrapping.
110
+ *
111
+ * @param text - Text to check
112
+ * @param maxWidthPx - Optional width override
113
+ * @returns true if text exceeds single line
114
+ */
115
+ needsWrap(text, maxWidthPx) {
116
+ const width = maxWidthPx ?? this.defaultOptions.maxWidthPx;
117
+ return this.measurer.measureText(text) > width || text.includes("\n");
118
+ }
119
+ /**
120
+ * Get current default options.
121
+ */
122
+ getOptions() {
123
+ return { ...this.defaultOptions };
124
+ }
125
+ /**
126
+ * Get the measurer instance.
127
+ */
128
+ getMeasurer() {
129
+ return this.measurer;
130
+ }
131
+ /**
132
+ * Wrap a single paragraph (no newlines) according to break mode.
133
+ */
134
+ wrapParagraph(paragraph, maxWidthPx, breakMode, opts) {
135
+ const trimmed = opts.trimLines ? paragraph.trim() : paragraph;
136
+ if (!trimmed) {
137
+ return [""];
138
+ }
139
+ // Check if it fits on one line
140
+ if (this.measurer.fitsInWidth(trimmed, maxWidthPx)) {
141
+ return [trimmed];
142
+ }
143
+ switch (breakMode) {
144
+ case "character":
145
+ return this.wrapCharacterMode(trimmed, maxWidthPx, opts);
146
+ case "character-no-hyphen":
147
+ return this.wrapCharacterNoHyphenMode(trimmed, maxWidthPx, opts);
148
+ case "word":
149
+ return this.wrapWordMode(trimmed, maxWidthPx, opts);
150
+ case "strict-word":
151
+ return this.wrapStrictWordMode(trimmed, maxWidthPx, opts);
152
+ default:
153
+ return this.wrapCharacterMode(trimmed, maxWidthPx, opts);
154
+ }
155
+ }
156
+ /**
157
+ * Character break mode: Break mid-word with hyphen for 100% line utilization.
158
+ */
159
+ wrapCharacterMode(text, maxWidthPx, opts) {
160
+ return this.wrapCharacterModeInternal(text, maxWidthPx, opts, true);
161
+ }
162
+ /**
163
+ * Character break mode without hyphen: Break mid-word cleanly without adding hyphen.
164
+ */
165
+ wrapCharacterNoHyphenMode(text, maxWidthPx, opts) {
166
+ return this.wrapCharacterModeInternal(text, maxWidthPx, opts, false);
167
+ }
168
+ /**
169
+ * Internal character break implementation with configurable hyphenation.
170
+ */
171
+ wrapCharacterModeInternal(text, maxWidthPx, opts, useHyphen) {
172
+ const lines = [];
173
+ const hyphenWidth = this.measurer.measureChar(opts.hyphenChar);
174
+ let currentLine = "";
175
+ let currentWidth = 0;
176
+ const chars = Array.from(text);
177
+ for (let i = 0; i < chars.length; i++) {
178
+ const char = chars[i];
179
+ const charWidth = this.measurer.measureChar(char);
180
+ // Would this character fit?
181
+ if (currentWidth + charWidth <= maxWidthPx) {
182
+ currentLine += char;
183
+ currentWidth += charWidth;
184
+ }
185
+ else {
186
+ // Character doesn't fit - need to break
187
+ // Determine if we need a hyphen
188
+ const prevChar = currentLine.length > 0 ? currentLine[currentLine.length - 1] : "";
189
+ const needsHyphen = useHyphen && currentLine.length >= opts.minCharsBeforeHyphen && needsHyphenForBreak(prevChar, char);
190
+ if (needsHyphen) {
191
+ // Back off characters until hyphen fits
192
+ const result = this.backoffForHyphen(currentLine, currentWidth, maxWidthPx, hyphenWidth, opts);
193
+ if (result.skipHyphen) {
194
+ // Found a natural word boundary while backing off - no hyphen needed
195
+ lines.push(result.line);
196
+ }
197
+ else {
198
+ lines.push(result.line + opts.hyphenChar);
199
+ }
200
+ // Start new line with backed-off chars + current char
201
+ currentLine = result.remainder + char;
202
+ currentWidth = this.measurer.measureText(currentLine);
203
+ }
204
+ else if (useHyphen === false && !isCJKCharacter(char) && char !== " ") {
205
+ // No-hyphen mode: just break cleanly without hyphen
206
+ const trimmedLine = opts.trimLines ? currentLine.trimEnd() : currentLine;
207
+ if (trimmedLine) {
208
+ lines.push(trimmedLine);
209
+ }
210
+ currentLine = char;
211
+ currentWidth = charWidth;
212
+ }
213
+ else {
214
+ // No hyphen needed (CJK, space, punctuation)
215
+ const trimmedLine = opts.trimLines ? currentLine.trimEnd() : currentLine;
216
+ if (trimmedLine) {
217
+ lines.push(trimmedLine);
218
+ }
219
+ currentLine = char === " " ? "" : char;
220
+ currentWidth = char === " " ? 0 : charWidth;
221
+ }
222
+ }
223
+ }
224
+ // Add remaining text
225
+ if (currentLine) {
226
+ const trimmedLine = opts.trimLines ? currentLine.trim() : currentLine;
227
+ if (trimmedLine) {
228
+ lines.push(trimmedLine);
229
+ }
230
+ }
231
+ return lines.length > 0 ? lines : [""];
232
+ }
233
+ /**
234
+ * Word break mode: Break at word boundaries, hyphenate only if word > line width.
235
+ */
236
+ wrapWordMode(text, maxWidthPx, opts) {
237
+ const lines = [];
238
+ const words = this.splitIntoWords(text);
239
+ const spaceWidth = this.measurer.getSpaceWidth();
240
+ let currentLine = "";
241
+ let currentWidth = 0;
242
+ for (const word of words) {
243
+ const wordWidth = this.measurer.measureText(word);
244
+ const needsSpace = currentLine.length > 0;
245
+ const totalWidth = currentWidth + (needsSpace ? spaceWidth : 0) + wordWidth;
246
+ if (totalWidth <= maxWidthPx) {
247
+ // Word fits on current line
248
+ if (needsSpace) {
249
+ currentLine += " ";
250
+ currentWidth += spaceWidth;
251
+ }
252
+ currentLine += word;
253
+ currentWidth += wordWidth;
254
+ }
255
+ else {
256
+ // Word doesn't fit
257
+ if (currentLine.length > 0) {
258
+ // Push current line and start new one
259
+ lines.push(opts.trimLines ? currentLine.trim() : currentLine);
260
+ currentLine = "";
261
+ currentWidth = 0;
262
+ }
263
+ // Check if word itself exceeds line width
264
+ if (wordWidth > maxWidthPx) {
265
+ // Word is too long - hyphenate it
266
+ const hyphenatedLines = this.hyphenateLongWord(word, maxWidthPx, opts);
267
+ for (let i = 0; i < hyphenatedLines.length - 1; i++) {
268
+ lines.push(hyphenatedLines[i]);
269
+ }
270
+ // Last piece becomes start of current line
271
+ currentLine = hyphenatedLines[hyphenatedLines.length - 1];
272
+ currentWidth = this.measurer.measureText(currentLine);
273
+ }
274
+ else {
275
+ // Word fits on new line
276
+ currentLine = word;
277
+ currentWidth = wordWidth;
278
+ }
279
+ }
280
+ }
281
+ // Add remaining text
282
+ if (currentLine) {
283
+ const trimmedLine = opts.trimLines ? currentLine.trim() : currentLine;
284
+ if (trimmedLine) {
285
+ lines.push(trimmedLine);
286
+ }
287
+ }
288
+ return lines.length > 0 ? lines : [""];
289
+ }
290
+ /**
291
+ * Strict word break mode: Break at word boundaries only, no hyphenation.
292
+ * Long words will overflow the line.
293
+ */
294
+ wrapStrictWordMode(text, maxWidthPx, opts) {
295
+ const lines = [];
296
+ const words = this.splitIntoWords(text);
297
+ const spaceWidth = this.measurer.getSpaceWidth();
298
+ let currentLine = "";
299
+ let currentWidth = 0;
300
+ for (const word of words) {
301
+ const wordWidth = this.measurer.measureText(word);
302
+ const needsSpace = currentLine.length > 0;
303
+ const totalWidth = currentWidth + (needsSpace ? spaceWidth : 0) + wordWidth;
304
+ if (totalWidth <= maxWidthPx) {
305
+ // Word fits on current line
306
+ if (needsSpace) {
307
+ currentLine += " ";
308
+ currentWidth += spaceWidth;
309
+ }
310
+ currentLine += word;
311
+ currentWidth += wordWidth;
312
+ }
313
+ else {
314
+ // Word doesn't fit
315
+ if (currentLine.length > 0) {
316
+ // Push current line
317
+ lines.push(opts.trimLines ? currentLine.trim() : currentLine);
318
+ }
319
+ // Start new line with word (even if it overflows)
320
+ currentLine = word;
321
+ currentWidth = wordWidth;
322
+ }
323
+ }
324
+ // Add remaining text
325
+ if (currentLine) {
326
+ const trimmedLine = opts.trimLines ? currentLine.trim() : currentLine;
327
+ if (trimmedLine) {
328
+ lines.push(trimmedLine);
329
+ }
330
+ }
331
+ return lines.length > 0 ? lines : [""];
332
+ }
333
+ /**
334
+ * Split text into words, handling CJK characters specially.
335
+ * CJK characters are treated as individual "words" since they can break anywhere.
336
+ */
337
+ splitIntoWords(text) {
338
+ const words = [];
339
+ let currentWord = "";
340
+ for (const char of text) {
341
+ if (char === " " || char === "\t") {
342
+ if (currentWord) {
343
+ words.push(currentWord);
344
+ currentWord = "";
345
+ }
346
+ }
347
+ else if (isCJKCharacter(char)) {
348
+ // CJK characters are individual words
349
+ if (currentWord) {
350
+ words.push(currentWord);
351
+ currentWord = "";
352
+ }
353
+ words.push(char);
354
+ }
355
+ else {
356
+ currentWord += char;
357
+ }
358
+ }
359
+ if (currentWord) {
360
+ words.push(currentWord);
361
+ }
362
+ return words;
363
+ }
364
+ /**
365
+ * Hyphenate a word that's too long to fit on a single line.
366
+ */
367
+ hyphenateLongWord(word, maxWidthPx, opts) {
368
+ const lines = [];
369
+ const hyphenWidth = this.measurer.measureChar(opts.hyphenChar);
370
+ const chars = Array.from(word);
371
+ let currentLine = "";
372
+ let currentWidth = 0;
373
+ for (let i = 0; i < chars.length; i++) {
374
+ const char = chars[i];
375
+ const charWidth = this.measurer.measureChar(char);
376
+ const isLastChar = i === chars.length - 1;
377
+ // Check if we need to break (leaving room for hyphen if not last char)
378
+ const widthNeeded = isLastChar ? charWidth : charWidth + hyphenWidth;
379
+ if (currentWidth + widthNeeded <= maxWidthPx) {
380
+ currentLine += char;
381
+ currentWidth += charWidth;
382
+ }
383
+ else {
384
+ // Need to break - back off if needed to fit hyphen
385
+ if (currentLine.length >= opts.minCharsBeforeHyphen) {
386
+ const result = this.backoffForHyphen(currentLine, currentWidth, maxWidthPx, hyphenWidth, opts);
387
+ if (result.skipHyphen) {
388
+ lines.push(result.line);
389
+ }
390
+ else {
391
+ lines.push(result.line + opts.hyphenChar);
392
+ }
393
+ currentLine = result.remainder + char;
394
+ currentWidth = this.measurer.measureText(currentLine);
395
+ }
396
+ else {
397
+ // Not enough chars for hyphen, just break
398
+ if (currentLine) {
399
+ lines.push(currentLine);
400
+ }
401
+ currentLine = char;
402
+ currentWidth = charWidth;
403
+ }
404
+ }
405
+ }
406
+ if (currentLine) {
407
+ lines.push(currentLine);
408
+ }
409
+ return lines.length > 0 ? lines : [word];
410
+ }
411
+ /**
412
+ * Back off characters from line end until hyphen fits.
413
+ * Returns null if we back off to a space (natural break point - no hyphen needed).
414
+ */
415
+ backoffForHyphen(line, lineWidth, maxWidthPx, hyphenWidth, opts) {
416
+ let adjustedLine = line;
417
+ let adjustedWidth = lineWidth;
418
+ let remainder = "";
419
+ // Remove characters until hyphen fits
420
+ while (adjustedWidth + hyphenWidth > maxWidthPx && adjustedLine.length > opts.minCharsBeforeHyphen) {
421
+ const lastChar = adjustedLine[adjustedLine.length - 1];
422
+ const lastCharWidth = this.measurer.measureChar(lastChar);
423
+ adjustedLine = adjustedLine.slice(0, -1);
424
+ adjustedWidth -= lastCharWidth;
425
+ remainder = lastChar + remainder;
426
+ // If we've backed off to a space, we've found a natural word boundary
427
+ // No hyphen is needed - just trim the space and break there
428
+ if (adjustedLine.length > 0 && adjustedLine[adjustedLine.length - 1] === " ") {
429
+ // Trim trailing space from the line
430
+ adjustedLine = adjustedLine.trimEnd();
431
+ return { line: adjustedLine, remainder, skipHyphen: true };
432
+ }
433
+ }
434
+ return { line: adjustedLine, remainder, skipHyphen: false };
435
+ }
436
+ /**
437
+ * Merge user options with defaults.
438
+ */
439
+ mergeOptions(options) {
440
+ return {
441
+ ...this.defaultOptions,
442
+ ...options,
443
+ };
444
+ }
445
+ /**
446
+ * Create an empty result for empty input.
447
+ */
448
+ createEmptyResult(opts) {
449
+ return {
450
+ lines: [""],
451
+ truncated: false,
452
+ maxLineWidthPx: 0,
453
+ totalBytes: 0,
454
+ lineMetrics: [
455
+ {
456
+ text: "",
457
+ widthPx: 0,
458
+ bytes: 0,
459
+ utilizationPercent: 0,
460
+ endsWithHyphen: false,
461
+ fromExplicitNewline: false,
462
+ },
463
+ ],
464
+ originalText: "",
465
+ breakMode: opts.breakMode,
466
+ };
467
+ }
468
+ }
469
+ //# sourceMappingURL=TextWrapper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TextWrapper.js","sourceRoot":"","sources":["../../../src/display/wrapper/TextWrapper.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,cAAc,EAAE,mBAAmB,EAAC,MAAM,8BAA8B,CAAA;AAEhF,OAAO,EAAC,oBAAoB,EAAC,MAAM,SAAS,CAAA;AAE5C;;;;;;;;;;;;;;GAcG;AACH,MAAM,OAAO,WAAW;IAItB,YAAY,QAAsB,EAAE,cAA4B;QAC9D,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAA;QAExB,MAAM,OAAO,GAAG,QAAQ,CAAC,UAAU,EAAE,CAAA;QACrC,IAAI,CAAC,cAAc,GAAG;YACp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AAG,YAAY,CAAC,OAAO,EAAE,CAAA;gBACrC,OAAO,EAAC,IAAI,EAAE,YAAY,EAAE,SAAS,EAAE,UAAU,EAAE,IAAI,EAAC,CAAA;YAC1D,CAAC;QACH,CAAC;QAED,OAAO,EAAC,IAAI,EAAE,YAAY,EAAE,SAAS,EAAE,UAAU,EAAE,KAAK,EAAC,CAAA;IAC3D,CAAC;IAED;;OAEG;IACK,YAAY,CAAC,OAAqB;QACxC,OAAO;YACL,GAAG,IAAI,CAAC,cAAc;YACtB,GAAG,OAAO;SACX,CAAA;IACH,CAAC;IAED;;OAEG;IACK,iBAAiB,CAAC,IAA2B;QACnD,OAAO;YACL,KAAK,EAAE,CAAC,EAAE,CAAC;YACX,SAAS,EAAE,KAAK;YAChB,cAAc,EAAE,CAAC;YACjB,UAAU,EAAE,CAAC;YACb,WAAW,EAAE;gBACX;oBACE,IAAI,EAAE,EAAE;oBACR,OAAO,EAAE,CAAC;oBACV,KAAK,EAAE,CAAC;oBACR,kBAAkB,EAAE,CAAC;oBACrB,cAAc,EAAE,KAAK;oBACrB,mBAAmB,EAAE,KAAK;iBAC3B;aACF;YACD,YAAY,EAAE,EAAE;YAChB,SAAS,EAAE,IAAI,CAAC,SAAS;SAC1B,CAAA;IACH,CAAC;CACF"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Text Wrapper Module
3
+ *
4
+ * Provides text wrapping with multiple break modes:
5
+ * - 'character': Break mid-word with hyphen for 100% line utilization
6
+ * - 'word': Break at word boundaries, hyphenate only if word > line width
7
+ * - 'strict-word': Break at word boundaries only, no hyphenation
8
+ */
9
+ export { TextWrapper } from "./TextWrapper";
10
+ export type { WrapOptions, WrapResult, LineMetrics, BreakMode } from "./types";
11
+ export { DEFAULT_WRAP_OPTIONS } from "./types";
12
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/display/wrapper/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,EAAC,WAAW,EAAC,MAAM,eAAe,CAAA;AAGzC,YAAY,EAAC,WAAW,EAAE,UAAU,EAAE,WAAW,EAAE,SAAS,EAAC,MAAM,SAAS,CAAA;AAC5E,OAAO,EAAC,oBAAoB,EAAC,MAAM,SAAS,CAAA"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Text Wrapper Module
3
+ *
4
+ * Provides text wrapping with multiple break modes:
5
+ * - 'character': Break mid-word with hyphen for 100% line utilization
6
+ * - 'word': Break at word boundaries, hyphenate only if word > line width
7
+ * - 'strict-word': Break at word boundaries only, no hyphenation
8
+ */
9
+ // Main class
10
+ export { TextWrapper } from "./TextWrapper";
11
+ export { DEFAULT_WRAP_OPTIONS } from "./types";
12
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/display/wrapper/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,aAAa;AACb,OAAO,EAAC,WAAW,EAAC,MAAM,eAAe,CAAA;AAIzC,OAAO,EAAC,oBAAoB,EAAC,MAAM,SAAS,CAAA"}
@@ -0,0 +1,75 @@
1
+ /**
2
+ * Options for text wrapping.
3
+ */
4
+ export interface WrapOptions {
5
+ /** Maximum width in pixels (defaults to profile's displayWidthPx) */
6
+ maxWidthPx?: number;
7
+ /** Maximum number of lines (defaults to profile's maxLines) */
8
+ maxLines?: number;
9
+ /** Maximum total bytes (defaults to profile's maxPayloadBytes) */
10
+ maxBytes?: number;
11
+ /**
12
+ * Break mode:
13
+ * - 'character': Break mid-word with hyphen for 100% utilization
14
+ * - 'word': Break at word boundaries, hyphenate only if word > line
15
+ * - 'strict-word': Break at word boundaries only, truncate long words
16
+ */
17
+ breakMode?: BreakMode;
18
+ /** Character to use for hyphenation (default: '-') */
19
+ hyphenChar?: string;
20
+ /** Minimum characters before allowing hyphen break (default: 3) */
21
+ minCharsBeforeHyphen?: number;
22
+ /** Whether to trim whitespace from line ends (default: true) */
23
+ trimLines?: boolean;
24
+ /** Whether to preserve explicit newlines in input (default: true) */
25
+ preserveNewlines?: boolean;
26
+ }
27
+ /**
28
+ * Break mode for text wrapping.
29
+ * - 'character': Break mid-word with hyphen for 100% utilization
30
+ * - 'character-no-hyphen': Break mid-word without hyphen (clean break)
31
+ * - 'word': Break at word boundaries, hyphenate only if word > line
32
+ * - 'strict-word': Break at word boundaries only, truncate long words
33
+ */
34
+ export type BreakMode = "character" | "character-no-hyphen" | "word" | "strict-word";
35
+ /**
36
+ * Result of wrapping operation.
37
+ */
38
+ export interface WrapResult {
39
+ /** Wrapped lines */
40
+ lines: string[];
41
+ /** Whether content was truncated to fit constraints */
42
+ truncated: boolean;
43
+ /** Total pixel width of widest line */
44
+ maxLineWidthPx: number;
45
+ /** Total byte size of all lines */
46
+ totalBytes: number;
47
+ /** Per-line metadata */
48
+ lineMetrics: LineMetrics[];
49
+ /** Original input text */
50
+ originalText: string;
51
+ /** Break mode used */
52
+ breakMode: BreakMode;
53
+ }
54
+ /**
55
+ * Per-line metrics from wrapping.
56
+ */
57
+ export interface LineMetrics {
58
+ /** The line text */
59
+ text: string;
60
+ /** Width in pixels */
61
+ widthPx: number;
62
+ /** Byte size of this line */
63
+ bytes: number;
64
+ /** Utilization percentage (widthPx / maxWidthPx * 100) */
65
+ utilizationPercent: number;
66
+ /** Whether this line ends with a hyphen from breaking */
67
+ endsWithHyphen: boolean;
68
+ /** Whether this line was created from an explicit newline */
69
+ fromExplicitNewline: boolean;
70
+ }
71
+ /**
72
+ * Default wrap options.
73
+ */
74
+ export declare const DEFAULT_WRAP_OPTIONS: Required<Omit<WrapOptions, "maxWidthPx" | "maxLines" | "maxBytes">>;
75
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/display/wrapper/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,qEA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MAAM,oBAAoB,EAAE,QAAQ,CAAC,IAAI,CAAC,WAAW,EAAE,YAAY,GAAG,UAAU,GAAG,UAAU,CAAC,CAMpG,CAAA"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Default wrap options.
3
+ */
4
+ export const DEFAULT_WRAP_OPTIONS = {
5
+ breakMode: "character-no-hyphen",
6
+ hyphenChar: "-",
7
+ minCharsBeforeHyphen: 3,
8
+ trimLines: true,
9
+ preserveNewlines: true,
10
+ };
11
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/display/wrapper/types.ts"],"names":[],"mappings":"AA4FA;;GAEG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAwE;IACvG,SAAS,EAAE,qBAAqB;IAChC,UAAU,EAAE,GAAG;IACf,oBAAoB,EAAE,CAAC;IACvB,SAAS,EAAE,IAAI;IACf,gBAAgB,EAAE,IAAI;CACvB,CAAA"}
package/dist/globals.d.ts CHANGED
@@ -18,7 +18,7 @@ export interface MiniappCapsuleMenuRect {
18
18
  height: number;
19
19
  }
20
20
  export type MiniappColorScheme = "light" | "dark";
21
- export interface GlasslyGlobals {
21
+ export interface HostGlobals {
22
22
  /** Package id the host assigned to this miniapp (e.g. "com.glassly.example"). */
23
23
  packageName?: string;
24
24
  /** "ios" | "android" | other. */
@@ -39,16 +39,16 @@ export interface GlasslyGlobals {
39
39
  capsuleMenu?: MiniappCapsuleMenuRect;
40
40
  /**
41
41
  * The host's current color scheme. Miniapps can follow this to match the
42
- * phone's appearance. Updates at runtime arrive via the session's
43
- * `colorScheme` event — see `useColorScheme()` in @glassly/miniapp/react.
42
+ * phone's appearance. The host updates this value and dispatches
43
+ * `glassly:color-scheme-change` — see `useColorScheme()` in @glassly/miniapp/ui.
44
44
  */
45
45
  colorScheme?: MiniappColorScheme;
46
46
  }
47
47
  declare global {
48
48
  interface Window {
49
- Glassly?: GlasslyGlobals;
49
+ Glassly?: HostGlobals;
50
50
  }
51
51
  }
52
52
  /** Reads window.Glassly safely — returns an empty object if not set. */
53
- export declare function getGlasslyGlobals(): GlasslyGlobals;
53
+ export declare function getHostGlobals(): HostGlobals;
54
54
  //# sourceMappingURL=globals.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"globals.d.ts","sourceRoot":"","sources":["../src/globals.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,MAAM,WAAW,qBAAqB;IACpC,GAAG,EAAE,MAAM,CAAA;IACX,MAAM,EAAE,MAAM,CAAA;IACd,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,MAAM,CAAA;CACd;AAED,MAAM,WAAW,sBAAsB;IACrC,GAAG,EAAE,MAAM,CAAA;IACX,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,MAAM,CAAA;IACd,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,MAAM,CAAA;CACf;AAED,MAAM,MAAM,kBAAkB,GAAG,OAAO,GAAG,MAAM,CAAA;AAEjD,MAAM,WAAW,cAAc;IAC7B,iFAAiF;IACjF,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,iCAAiC;IACjC,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,kFAAkF;IAClF,YAAY,CAAC,EAAE,MAAM,EAAE,CAAA;IACvB,qFAAqF;IACrF,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB,2EAA2E;IAC3E,oBAAoB,CAAC,EAAE,OAAO,CAAA;IAC9B,oFAAoF;IACpF,cAAc,CAAC,EAAE,qBAAqB,CAAA;IACtC;;;;OAIG;IACH,WAAW,CAAC,EAAE,sBAAsB,CAAA;IACpC;;;;OAIG;IACH,WAAW,CAAC,EAAE,kBAAkB,CAAA;CACjC;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,MAAM;QACd,OAAO,CAAC,EAAE,cAAc,CAAA;KACzB;CACF;AAED,wEAAwE;AACxE,wBAA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