@glassly/miniapp 0.4.3-dev.1267 → 0.4.3-dev.1269
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/README.md +9 -1
- package/dist/host/index.d.ts +1 -0
- package/dist/host/index.d.ts.map +1 -1
- package/dist/host/index.js +1 -0
- package/dist/host/index.js.map +1 -1
- package/dist/host/settingsBridge.d.ts +31 -8
- package/dist/host/settingsBridge.d.ts.map +1 -1
- package/dist/host/settingsBridge.js +63 -11
- package/dist/host/settingsBridge.js.map +1 -1
- package/dist/host/ttsSanitizer.d.ts +5 -0
- package/dist/host/ttsSanitizer.d.ts.map +1 -0
- package/dist/host/ttsSanitizer.js +61 -0
- package/dist/host/ttsSanitizer.js.map +1 -0
- package/dist/modules/cloud.d.ts +2 -0
- package/dist/modules/cloud.d.ts.map +1 -1
- package/dist/modules/cloud.js +17 -7
- package/dist/modules/cloud.js.map +1 -1
- package/dist/modules/settings.d.ts +4 -1
- package/dist/modules/settings.d.ts.map +1 -1
- package/dist/modules/settings.js +4 -1
- package/dist/modules/settings.js.map +1 -1
- package/dist/reader/Reader.d.ts +147 -0
- package/dist/reader/Reader.d.ts.map +1 -0
- package/dist/reader/Reader.js +525 -0
- package/dist/reader/Reader.js.map +1 -0
- package/dist/reader/document.d.ts +54 -0
- package/dist/reader/document.d.ts.map +1 -0
- package/dist/reader/document.js +114 -0
- package/dist/reader/document.js.map +1 -0
- package/dist/reader/index.d.ts +12 -0
- package/dist/reader/index.d.ts.map +1 -0
- package/dist/reader/index.js +9 -0
- package/dist/reader/index.js.map +1 -0
- package/dist/reader/lens.d.ts +55 -0
- package/dist/reader/lens.d.ts.map +1 -0
- package/dist/reader/lens.js +210 -0
- package/dist/reader/lens.js.map +1 -0
- package/dist/sub-path-types.test-d.d.ts +3 -1
- package/dist/sub-path-types.test-d.d.ts.map +1 -1
- package/dist/sub-path-types.test-d.js +1 -7
- package/dist/sub-path-types.test-d.js.map +1 -1
- package/package.json +6 -2
- package/src/host/index.ts +1 -0
- package/src/host/settingsBridge.ts +70 -11
- package/src/host/ttsSanitizer.ts +66 -0
- package/src/modules/cloud.ts +21 -7
- package/src/modules/settings.ts +4 -1
- package/src/reader/Reader.ts +580 -0
- package/src/reader/document.ts +154 -0
- package/src/reader/index.ts +12 -0
- package/src/reader/lens.ts +250 -0
- package/src/sub-path-types.test-d.ts +5 -0
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The text as the lens reads it: every section wrapped into display lines,
|
|
3
|
+
* with each line's word count, where paragraphs end, and the parts between
|
|
4
|
+
* stops (an end screen). Pure: the Reader rebuilds it when the text, the
|
|
5
|
+
* glasses or the highlight style change.
|
|
6
|
+
*/
|
|
7
|
+
export const PARAGRAPH_BEAT_WORDS = 3;
|
|
8
|
+
const countWords = (text) => text.split(/\s+/).filter(Boolean).length;
|
|
9
|
+
export class ReaderDocument {
|
|
10
|
+
constructor(sections, wrapper, wrapWidthPx) {
|
|
11
|
+
this.sections = sections;
|
|
12
|
+
this.lines = [];
|
|
13
|
+
this.parts = [];
|
|
14
|
+
this.before = [];
|
|
15
|
+
const wrap = (text) => wrapper.wrap(text, {
|
|
16
|
+
maxWidthPx: wrapWidthPx,
|
|
17
|
+
maxLines: Infinity,
|
|
18
|
+
maxBytes: Infinity,
|
|
19
|
+
breakMode: "word",
|
|
20
|
+
trimLines: true,
|
|
21
|
+
preserveNewlines: true,
|
|
22
|
+
}).lines;
|
|
23
|
+
sections.forEach((section, index) => {
|
|
24
|
+
if (index > 0 && this.lines.length)
|
|
25
|
+
this.push({ text: "", words: 0, section: index, kind: "blank", paragraphEnd: false });
|
|
26
|
+
if (section.label) {
|
|
27
|
+
for (const text of wrap(section.label))
|
|
28
|
+
this.push({ text, words: countWords(text), section: index, kind: "label", paragraphEnd: false });
|
|
29
|
+
}
|
|
30
|
+
const body = wrap(section.text.trim());
|
|
31
|
+
body.forEach((text, i) => {
|
|
32
|
+
const blank = text.trim() === "";
|
|
33
|
+
const next = body[i + 1];
|
|
34
|
+
this.push({
|
|
35
|
+
text: blank ? "" : text,
|
|
36
|
+
words: blank ? 0 : countWords(text),
|
|
37
|
+
section: index,
|
|
38
|
+
kind: blank ? "blank" : "text",
|
|
39
|
+
paragraphEnd: !blank && (next === undefined || next.trim() === ""),
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
if (!this.lines.length)
|
|
44
|
+
this.push({ text: "", words: 0, section: 0, kind: "blank", paragraphEnd: true });
|
|
45
|
+
let first = 0;
|
|
46
|
+
let words = 0;
|
|
47
|
+
this.lines.forEach((line, i) => {
|
|
48
|
+
this.before.push(words);
|
|
49
|
+
words += line.words;
|
|
50
|
+
const next = this.lines[i + 1];
|
|
51
|
+
const sectionEnds = !next || next.section !== line.section;
|
|
52
|
+
const stops = sectionEnds && (!next || sections[line.section]?.stop !== undefined);
|
|
53
|
+
if (!stops)
|
|
54
|
+
return;
|
|
55
|
+
this.parts.push({ first, last: i, words, stopSection: line.section });
|
|
56
|
+
first = i + 1;
|
|
57
|
+
words = 0;
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
push(line) {
|
|
61
|
+
this.lines.push(line);
|
|
62
|
+
}
|
|
63
|
+
partOf(line) {
|
|
64
|
+
const index = this.parts.findIndex((part) => line <= part.last);
|
|
65
|
+
return index < 0 ? this.parts.length - 1 : index;
|
|
66
|
+
}
|
|
67
|
+
percent(line, finished = false) {
|
|
68
|
+
const part = this.parts[this.partOf(line)];
|
|
69
|
+
if (finished || !part.words)
|
|
70
|
+
return finished ? 100 : 0;
|
|
71
|
+
return Math.min(100, Math.round((this.before[line] / part.words) * 100));
|
|
72
|
+
}
|
|
73
|
+
lineAt(partIndex, percent) {
|
|
74
|
+
const part = this.parts[Math.max(0, Math.min(this.parts.length - 1, partIndex))];
|
|
75
|
+
return this.lineAtWord(partIndex, (Math.max(0, Math.min(100, percent)) / 100) * part.words);
|
|
76
|
+
}
|
|
77
|
+
/** The line holding the part's word at `words` (words read before it); past the end, the part's last line. */
|
|
78
|
+
lineAtWord(partIndex, words) {
|
|
79
|
+
const part = this.parts[Math.max(0, Math.min(this.parts.length - 1, partIndex))];
|
|
80
|
+
for (let i = part.first; i <= part.last; i++) {
|
|
81
|
+
if (this.before[i] + this.lines[i].words > words && this.lines[i].words > 0)
|
|
82
|
+
return i;
|
|
83
|
+
}
|
|
84
|
+
return this.previousReadable(part.last + 1, part.first) ?? part.first;
|
|
85
|
+
}
|
|
86
|
+
wordsBefore(line) {
|
|
87
|
+
return this.before[line] ?? 0;
|
|
88
|
+
}
|
|
89
|
+
nextReadable(line, limit = this.lines.length - 1) {
|
|
90
|
+
for (let i = line + 1; i <= limit; i++)
|
|
91
|
+
if (this.lines[i].words > 0)
|
|
92
|
+
return i;
|
|
93
|
+
return null;
|
|
94
|
+
}
|
|
95
|
+
previousReadable(line, floor = 0) {
|
|
96
|
+
for (let i = line - 1; i >= floor; i--)
|
|
97
|
+
if (this.lines[i].words > 0)
|
|
98
|
+
return i;
|
|
99
|
+
return null;
|
|
100
|
+
}
|
|
101
|
+
wordsLeft(line) {
|
|
102
|
+
const part = this.parts[this.partOf(line)];
|
|
103
|
+
return part.words - this.before[line];
|
|
104
|
+
}
|
|
105
|
+
lineMs(line, wpm, beats) {
|
|
106
|
+
const entry = this.lines[line];
|
|
107
|
+
const beat = beats && entry.paragraphEnd ? PARAGRAPH_BEAT_WORDS : 0;
|
|
108
|
+
return ((entry.words + beat) * 60000) / wpm;
|
|
109
|
+
}
|
|
110
|
+
rowsAround(line, at, count) {
|
|
111
|
+
return Array.from({ length: count }, (_, i) => this.lines[line - at + i]?.text ?? "");
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
//# sourceMappingURL=document.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"document.js","sourceRoot":"","sources":["../../src/reader/document.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AA+BH,MAAM,CAA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CAAA;QACnE,OAAO,CAAC,CAAC,KAAK,CAAC,KAAK,GAAG,IAAI,CAAC,GAAG,KAAM,CAAC,GAAG,GAAG,CAAA;IAC9C,CAAC;IAED,UAAU,CAAC,IAAY,EAAE,EAAU,EAAE,KAAa;QAChD,OAAO,KAAK,CAAC,IAAI,CAAC,EAAC,MAAM,EAAE,KAAK,EAAC,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,GAAG,EAAE,GAAG,CAAC,CAAC,EAAE,IAAI,IAAI,EAAE,CAAC,CAAA;IACrF,CAAC;CACF"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @glassly/miniapp/reader — text that reads itself on the glasses. Open it
|
|
3
|
+
* from the background side with the session and your text; see
|
|
4
|
+
* sdk/docs/reader.md.
|
|
5
|
+
*/
|
|
6
|
+
export { openReader, Reader, READER_WPM } from "./Reader";
|
|
7
|
+
export type { ReaderDeps, ReaderEvent, ReaderOptions, ReaderSession } from "./Reader";
|
|
8
|
+
export { ReaderDocument, PARAGRAPH_BEAT_WORDS } from "./document";
|
|
9
|
+
export type { ReaderLine, ReaderPart, ReaderSection, ReaderStop } from "./document";
|
|
10
|
+
export { LENS_COLOR, lensElements, lensLayout, serializeRows, statusLine, textWrapWidth, usesBrackets } from "./lens";
|
|
11
|
+
export type { LensDisplay, LensFrame, LensHighlight, LensLayout } from "./lens";
|
|
12
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/reader/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAC,UAAU,EAAE,MAAM,EAAE,UAAU,EAAC,MAAM,UAAU,CAAA;AACvD,YAAY,EAAC,UAAU,EAAE,WAAW,EAAE,aAAa,EAAE,aAAa,EAAC,MAAM,UAAU,CAAA;AACnF,OAAO,EAAC,cAAc,EAAE,oBAAoB,EAAC,MAAM,YAAY,CAAA;AAC/D,YAAY,EAAC,UAAU,EAAE,UAAU,EAAE,aAAa,EAAE,UAAU,EAAC,MAAM,YAAY,CAAA;AACjF,OAAO,EAAC,UAAU,EAAE,YAAY,EAAE,UAAU,EAAE,aAAa,EAAE,UAAU,EAAE,aAAa,EAAE,YAAY,EAAC,MAAM,QAAQ,CAAA;AACnH,YAAY,EAAC,WAAW,EAAE,SAAS,EAAE,aAAa,EAAE,UAAU,EAAC,MAAM,QAAQ,CAAA"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @glassly/miniapp/reader — text that reads itself on the glasses. Open it
|
|
3
|
+
* from the background side with the session and your text; see
|
|
4
|
+
* sdk/docs/reader.md.
|
|
5
|
+
*/
|
|
6
|
+
export { openReader, Reader, READER_WPM } from "./Reader";
|
|
7
|
+
export { ReaderDocument, PARAGRAPH_BEAT_WORDS } from "./document";
|
|
8
|
+
export { LENS_COLOR, lensElements, lensLayout, serializeRows, statusLine, textWrapWidth, usesBrackets } from "./lens";
|
|
9
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/reader/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAC,UAAU,EAAE,MAAM,EAAE,UAAU,EAAC,MAAM,UAAU,CAAA;AAEvD,OAAO,EAAC,cAAc,EAAE,oBAAoB,EAAC,MAAM,YAAY,CAAA;AAE/D,OAAO,EAAC,UAAU,EAAE,YAAY,EAAE,UAAU,EAAE,aAAa,EAAE,UAAU,EAAE,aAAa,EAAE,YAAY,EAAC,MAAM,QAAQ,CAAA"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Reader's lens, lifted from Teleprompter's (#51): the text moves up
|
|
3
|
+
* under a fixed marked row just above the middle, lines already read sit
|
|
4
|
+
* dimmed above it, and a status row along the bottom always says the state.
|
|
5
|
+
* Glasses that place elements get a small scene; text-only glasses get one
|
|
6
|
+
* block of rows with the marked row in the same place. Pure: no timers, no I/O.
|
|
7
|
+
*/
|
|
8
|
+
import type { DisplayProfile } from "../display/profiles";
|
|
9
|
+
import type { TextMeasurer } from "../display/measurer";
|
|
10
|
+
import type { RenderElement } from "../modules/display";
|
|
11
|
+
export type LensHighlight = "filled" | "brackets" | "dim";
|
|
12
|
+
export interface LensDisplay {
|
|
13
|
+
width?: number;
|
|
14
|
+
height?: number;
|
|
15
|
+
canPosition?: boolean;
|
|
16
|
+
maxTextElements?: number;
|
|
17
|
+
shapes?: string[];
|
|
18
|
+
}
|
|
19
|
+
export interface LensLayout {
|
|
20
|
+
mode: "scene" | "text";
|
|
21
|
+
width: number;
|
|
22
|
+
height: number;
|
|
23
|
+
pitch: number;
|
|
24
|
+
rows: number;
|
|
25
|
+
marked: number;
|
|
26
|
+
wrapWidthPx: number;
|
|
27
|
+
rect: boolean;
|
|
28
|
+
budget: number;
|
|
29
|
+
rowsPerText: number;
|
|
30
|
+
}
|
|
31
|
+
export interface LensFrame {
|
|
32
|
+
rows: string[];
|
|
33
|
+
status: string;
|
|
34
|
+
detail: string;
|
|
35
|
+
marked: number | null;
|
|
36
|
+
highlight: LensHighlight;
|
|
37
|
+
dimBefore?: number;
|
|
38
|
+
toast?: string | null;
|
|
39
|
+
}
|
|
40
|
+
export declare const LENS_COLOR: {
|
|
41
|
+
readonly read: 5;
|
|
42
|
+
readonly marked: 15;
|
|
43
|
+
readonly coming: 12;
|
|
44
|
+
readonly status: 9;
|
|
45
|
+
readonly bar: 3;
|
|
46
|
+
};
|
|
47
|
+
export declare function usesBrackets(layout: LensLayout, highlight: LensHighlight): boolean;
|
|
48
|
+
/** How the lens fits a model: rows, the marked row, the wrap width, and what it can afford to draw. */
|
|
49
|
+
export declare function lensLayout(profile: DisplayProfile, display: LensDisplay | null | undefined): LensLayout;
|
|
50
|
+
export declare function textWrapWidth(layout: LensLayout, highlight: LensHighlight, measurer: TextMeasurer): number;
|
|
51
|
+
export declare function serializeRows(rows: string[]): string;
|
|
52
|
+
/** The status row as one line: the state, then the detail when both fit, the state shortened first. */
|
|
53
|
+
export declare function statusLine(measurer: TextMeasurer, status: string, detail: string, widthPx: number): string;
|
|
54
|
+
export declare function lensElements(layout: LensLayout, frame: LensFrame, measurer: TextMeasurer): RenderElement[];
|
|
55
|
+
//# sourceMappingURL=lens.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lens.d.ts","sourceRoot":"","sources":["../../src/reader/lens.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,qBAAqB,CAAA;AACvD,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,qBAAqB,CAAA;AAErD,OAAO,KAAK,EAAC,aAAa,EAAC,MAAM,oBAAoB,CAAA;AAErD,MAAM,MAAM,aAAa,GAAG,QAAQ,GAAG,UAAU,GAAG,KAAK,CAAA;AAEzD,MAAM,WAAW,WAAW;IAC1B,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,MAAM,CAAC,EAAE,MAAM,EAAE,CAAA;CAClB;AAED,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,OAAO,GAAG,MAAM,CAAA;IACtB,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,MAAM,CAAA;IACd,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,MAAM,CAAA;IACd,WAAW,EAAE,MAAM,CAAA;IACnB,IAAI,EAAE,OAAO,CAAA;IACb,MAAM,EAAE,MAAM,CAAA;IACd,WAAW,EAAE,MAAM,CAAA;CACpB;AAED,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,EAAE,CAAA;IACd,MAAM,EAAE,MAAM,CAAA;IACd,MAAM,EAAE,MAAM,CAAA;IACd,MAAM,EAAE,MAAM,GAAG,IAAI,CAAA;IACrB,SAAS,EAAE,aAAa,CAAA;IACxB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CACtB;AAWD,eAAO,MAAM,UAAU;;;;;;CAAgE,CAAA;AAMvF,wBAAgB,YAAY,CAAC,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,aAAa,GAAG,OAAO,CAGlF;AAED,uGAAuG;AACvG,wBAAgB,UAAU,CAAC,OAAO,EAAE,cAAc,EAAE,OAAO,EAAE,WAAW,GAAG,IAAI,GAAG,SAAS,GAAG,UAAU,CAkCvG;AAED,wBAAgB,aAAa,CAAC,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,aAAa,EAAE,QAAQ,EAAE,YAAY,GAAG,MAAM,CAG1G;AAED,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,CAEpD;AASD,uGAAuG;AACvG,wBAAgB,UAAU,CAAC,QAAQ,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAO1G;AAMD,wBAAgB,YAAY,CAAC,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,YAAY,GAAG,aAAa,EAAE,CAoH1G"}
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Reader's lens, lifted from Teleprompter's (#51): the text moves up
|
|
3
|
+
* under a fixed marked row just above the middle, lines already read sit
|
|
4
|
+
* dimmed above it, and a status row along the bottom always says the state.
|
|
5
|
+
* Glasses that place elements get a small scene; text-only glasses get one
|
|
6
|
+
* block of rows with the marked row in the same place. Pure: no timers, no I/O.
|
|
7
|
+
*/
|
|
8
|
+
import { textBoxLines } from "../display/profiles";
|
|
9
|
+
const DEFAULT_PITCH = 27;
|
|
10
|
+
const PAD = 6;
|
|
11
|
+
const TEXT_INSET = 4;
|
|
12
|
+
const MAX_ROWS = 11;
|
|
13
|
+
const MIN_ROWS = 3;
|
|
14
|
+
const CANVAS = { width: 576, height: 288 };
|
|
15
|
+
const BRACKET_OPEN = "> ";
|
|
16
|
+
const BRACKET_CLOSE = " <";
|
|
17
|
+
export const LENS_COLOR = { read: 5, marked: 15, coming: 12, status: 9, bar: 3 };
|
|
18
|
+
function markedRow(rows) {
|
|
19
|
+
return Math.floor((rows - 1) / 2);
|
|
20
|
+
}
|
|
21
|
+
export function usesBrackets(layout, highlight) {
|
|
22
|
+
if (highlight === "dim")
|
|
23
|
+
return false;
|
|
24
|
+
return highlight === "brackets" || layout.mode === "text" || !layout.rect;
|
|
25
|
+
}
|
|
26
|
+
/** How the lens fits a model: rows, the marked row, the wrap width, and what it can afford to draw. */
|
|
27
|
+
export function lensLayout(profile, display) {
|
|
28
|
+
const budget = display?.maxTextElements ?? 0;
|
|
29
|
+
if (display?.canPosition && display.width && display.height && budget >= 4) {
|
|
30
|
+
const pitch = profile.lineHeightPx ?? DEFAULT_PITCH;
|
|
31
|
+
const total = Math.max(MIN_ROWS, Math.min(MAX_ROWS, Math.floor(display.height / pitch)));
|
|
32
|
+
return {
|
|
33
|
+
mode: "scene",
|
|
34
|
+
width: display.width,
|
|
35
|
+
height: display.height,
|
|
36
|
+
pitch,
|
|
37
|
+
rows: total - 1,
|
|
38
|
+
marked: markedRow(total - 1),
|
|
39
|
+
wrapWidthPx: Math.floor(Math.min(display.width - 2 * PAD - TEXT_INSET, profile.displayWidthPx)),
|
|
40
|
+
rect: (display.shapes ?? []).includes("rect") && budget >= 5,
|
|
41
|
+
budget,
|
|
42
|
+
rowsPerText: profile.lineHeightPx ? total : profile.maxLines,
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
const width = display?.width ?? CANVAS.width;
|
|
46
|
+
const height = display?.height ?? CANVAS.height;
|
|
47
|
+
const { maxLines } = textBoxLines(profile, { w: width, h: profile.displayHeightPx ?? height });
|
|
48
|
+
const total = Math.max(MIN_ROWS, Math.min(profile.maxLines, maxLines));
|
|
49
|
+
return {
|
|
50
|
+
mode: "text",
|
|
51
|
+
width,
|
|
52
|
+
height,
|
|
53
|
+
pitch: profile.lineHeightPx ?? DEFAULT_PITCH,
|
|
54
|
+
rows: total - 1,
|
|
55
|
+
marked: markedRow(total - 1),
|
|
56
|
+
wrapWidthPx: Math.floor(Math.min(profile.displayWidthPx, width)),
|
|
57
|
+
rect: false,
|
|
58
|
+
budget,
|
|
59
|
+
rowsPerText: total,
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
export function textWrapWidth(layout, highlight, measurer) {
|
|
63
|
+
if (!usesBrackets(layout, highlight))
|
|
64
|
+
return layout.wrapWidthPx;
|
|
65
|
+
return layout.wrapWidthPx - measurer.measureText(BRACKET_OPEN + BRACKET_CLOSE);
|
|
66
|
+
}
|
|
67
|
+
export function serializeRows(rows) {
|
|
68
|
+
return rows.map((row) => (row === "" ? "" : row)).join("\n");
|
|
69
|
+
}
|
|
70
|
+
function fit(measurer, text, widthPx) {
|
|
71
|
+
if (measurer.measureText(text) <= widthPx)
|
|
72
|
+
return text;
|
|
73
|
+
let out = text;
|
|
74
|
+
while (out && measurer.measureText(`${out}…`) > widthPx)
|
|
75
|
+
out = out.slice(0, -1);
|
|
76
|
+
return out ? `${out.trimEnd()}…` : "";
|
|
77
|
+
}
|
|
78
|
+
/** The status row as one line: the state, then the detail when both fit, the state shortened first. */
|
|
79
|
+
export function statusLine(measurer, status, detail, widthPx) {
|
|
80
|
+
if (!detail)
|
|
81
|
+
return fit(measurer, status, widthPx);
|
|
82
|
+
const both = `${status} ${detail}`;
|
|
83
|
+
if (measurer.measureText(both) <= widthPx)
|
|
84
|
+
return both;
|
|
85
|
+
const room = widthPx - measurer.measureText(` ${detail}`);
|
|
86
|
+
const state = room > measurer.measureText("x…") ? fit(measurer, status, room) : "";
|
|
87
|
+
return state ? `${state} ${detail}` : fit(measurer, status, widthPx);
|
|
88
|
+
}
|
|
89
|
+
function markText(layout, frame, row) {
|
|
90
|
+
return row && usesBrackets(layout, frame.highlight) ? `${BRACKET_OPEN}${row}${BRACKET_CLOSE}` : row;
|
|
91
|
+
}
|
|
92
|
+
export function lensElements(layout, frame, measurer) {
|
|
93
|
+
const rows = Array.from({ length: layout.rows }, (_, i) => frame.rows[i] ?? "");
|
|
94
|
+
const marked = frame.marked;
|
|
95
|
+
if (layout.mode === "text") {
|
|
96
|
+
const body = rows.map((row, i) => (i === marked ? markText(layout, frame, row) : row));
|
|
97
|
+
const status = frame.toast
|
|
98
|
+
? fit(measurer, frame.toast.replace(/\n/g, " · "), layout.wrapWidthPx)
|
|
99
|
+
: statusLine(measurer, frame.status, frame.detail, layout.wrapWidthPx);
|
|
100
|
+
return [
|
|
101
|
+
{
|
|
102
|
+
type: "text",
|
|
103
|
+
id: "reader-text",
|
|
104
|
+
box: { x: 0, y: 0, w: layout.width, h: layout.height },
|
|
105
|
+
text: serializeRows([...body, status]),
|
|
106
|
+
},
|
|
107
|
+
];
|
|
108
|
+
}
|
|
109
|
+
const { pitch, width } = layout;
|
|
110
|
+
const textWidth = width - 2 * PAD;
|
|
111
|
+
const statusY = layout.rows * pitch;
|
|
112
|
+
const elements = [];
|
|
113
|
+
const block = (id, from, to, color) => {
|
|
114
|
+
for (let at = from, part = 1; at < to; at += layout.rowsPerText, part++) {
|
|
115
|
+
const end = Math.min(to, at + layout.rowsPerText);
|
|
116
|
+
if (part > 1 && rows.slice(at, end).every((row) => row === ""))
|
|
117
|
+
continue;
|
|
118
|
+
elements.push({
|
|
119
|
+
type: "text",
|
|
120
|
+
id: part === 1 ? id : `${id}-${part}`,
|
|
121
|
+
box: { x: PAD, y: at * pitch, w: textWidth, h: (end - at) * pitch },
|
|
122
|
+
text: serializeRows(rows.slice(at, end)),
|
|
123
|
+
style: { color },
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
if (marked === null) {
|
|
128
|
+
const dim = Math.max(0, Math.min(layout.rows, frame.dimBefore ?? 0));
|
|
129
|
+
block("reader-read", 0, dim, LENS_COLOR.read);
|
|
130
|
+
block("reader-next", dim, layout.rows, LENS_COLOR.marked);
|
|
131
|
+
}
|
|
132
|
+
else {
|
|
133
|
+
block("reader-read", 0, marked, LENS_COLOR.read);
|
|
134
|
+
if (layout.rect && frame.highlight === "filled") {
|
|
135
|
+
elements.push({
|
|
136
|
+
type: "rect",
|
|
137
|
+
id: "reader-bar",
|
|
138
|
+
box: { x: 0, y: marked * pitch, w: width, h: pitch },
|
|
139
|
+
style: { fill: true, color: LENS_COLOR.bar, radius: 4 },
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
elements.push({
|
|
143
|
+
type: "text",
|
|
144
|
+
id: "reader-mark",
|
|
145
|
+
box: { x: PAD, y: marked * pitch, w: textWidth, h: pitch },
|
|
146
|
+
text: serializeRows([markText(layout, frame, rows[marked] ?? "")]),
|
|
147
|
+
style: { color: LENS_COLOR.marked },
|
|
148
|
+
});
|
|
149
|
+
block("reader-next", marked + 1, layout.rows, LENS_COLOR.coming);
|
|
150
|
+
}
|
|
151
|
+
const statusBox = { y: statusY, h: layout.height - statusY };
|
|
152
|
+
const inner = textWidth - TEXT_INSET;
|
|
153
|
+
const toastFits = layout.budget >= elements.length + 2;
|
|
154
|
+
const toast = frame.toast && toastFits ? frame.toast : null;
|
|
155
|
+
if (frame.toast && !toastFits)
|
|
156
|
+
frame = { ...frame, status: frame.toast.replace(/\n/g, " · "), detail: "" };
|
|
157
|
+
const split = !frame.toast && layout.budget > elements.length + 1;
|
|
158
|
+
const detailWidth = frame.detail ? measurer.measureText(frame.detail) : 0;
|
|
159
|
+
if (split && frame.detail && detailWidth + measurer.measureText(frame.status) + 24 <= inner) {
|
|
160
|
+
const detailBox = detailWidth + TEXT_INSET;
|
|
161
|
+
elements.push({
|
|
162
|
+
type: "text",
|
|
163
|
+
id: "reader-status",
|
|
164
|
+
box: { x: PAD, ...statusBox, w: textWidth - detailBox },
|
|
165
|
+
text: frame.status || "",
|
|
166
|
+
style: { color: LENS_COLOR.status },
|
|
167
|
+
}, {
|
|
168
|
+
type: "text",
|
|
169
|
+
id: "reader-detail",
|
|
170
|
+
box: { x: width - PAD - detailBox, ...statusBox, w: detailBox },
|
|
171
|
+
text: frame.detail,
|
|
172
|
+
style: { color: LENS_COLOR.status },
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
else {
|
|
176
|
+
elements.push({
|
|
177
|
+
type: "text",
|
|
178
|
+
id: "reader-status",
|
|
179
|
+
box: { x: PAD, ...statusBox, w: textWidth },
|
|
180
|
+
text: statusLine(measurer, frame.status, frame.detail, inner) || "",
|
|
181
|
+
style: { color: LENS_COLOR.status },
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
if (toast) {
|
|
185
|
+
const lines = toast.split("\n").map((line) => fit(measurer, line, textWidth - 2 * PAD));
|
|
186
|
+
const top = layout.rows - lines.length;
|
|
187
|
+
for (let i = elements.length - 1; i >= 0; i--) {
|
|
188
|
+
const el = elements[i];
|
|
189
|
+
if (el.type !== "text" || !/^reader-(read|next)/.test(el.id ?? ""))
|
|
190
|
+
continue;
|
|
191
|
+
const from = el.box.y / pitch;
|
|
192
|
+
const to = from + el.box.h / pitch;
|
|
193
|
+
if (to <= top)
|
|
194
|
+
continue;
|
|
195
|
+
if (from >= top)
|
|
196
|
+
elements.splice(i, 1);
|
|
197
|
+
else
|
|
198
|
+
elements[i] = { ...el, box: { ...el.box, h: (top - from) * pitch }, text: serializeRows(rows.slice(from, top)) };
|
|
199
|
+
}
|
|
200
|
+
elements.push({
|
|
201
|
+
type: "text",
|
|
202
|
+
id: "reader-toast",
|
|
203
|
+
box: { x: PAD, y: top * pitch, w: textWidth, h: lines.length * pitch },
|
|
204
|
+
text: serializeRows(lines),
|
|
205
|
+
style: { color: LENS_COLOR.marked, border: 2, radius: 6 },
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
return elements;
|
|
209
|
+
}
|
|
210
|
+
//# sourceMappingURL=lens.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lens.js","sourceRoot":"","sources":["../../src/reader/lens.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,OAAO,EAAC,YAAY,EAAC,MAAM,qBAAqB,CAAA;AAoChD,MAAM,aAAa,GAAG,EAAE,CAAA;AACxB,MAAM,GAAG,GAAG,CAAC,CAAA;AACb,MAAM,UAAU,GAAG,CAAC,CAAA;AACpB,MAAM,QAAQ,GAAG,EAAE,CAAA;AACnB,MAAM,QAAQ,GAAG,CAAC,CAAA;AAClB,MAAM,MAAM,GAAG,EAAC,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAC,CAAA;AACxC,MAAM,YAAY,GAAG,IAAI,CAAA;AACzB,MAAM,aAAa,GAAG,IAAI,CAAA;AAE1B,MAAM,CAAC,MAAM,UAAU,GAAG,EAAC,IAAI,EAAE,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAU,CAAA;AAEvF,SAAS,SAAS,CAAC,IAAY;IAC7B,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAA;AACnC,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,MAAkB,EAAE,SAAwB;IACvE,IAAI,SAAS,KAAK,KAAK;QAAE,OAAO,KAAK,CAAA;IACrC,OAAO,SAAS,KAAK,UAAU,IAAI,MAAM,CAAC,IAAI,KAAK,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,CAAA;AAC3E,CAAC;AAED,uGAAuG;AACvG,MAAM,UAAU,UAAU,CAAC,OAAuB,EAAE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CAAC;YAC1B,KAAK,EAAE,EAAC,KAAK,EAAE,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAC;SACxD,CAAC,CAAA;IACJ,CAAC;IACD,OAAO,QAAQ,CAAA;AACjB,CAAC"}
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
* become reachable on the wrong path, which is the contract we want.
|
|
23
23
|
*/
|
|
24
24
|
import { registerMiniapp } from "./background/index";
|
|
25
|
-
import type { UIModule } from "./background/index";
|
|
25
|
+
import type { MiniappSession, UIModule } from "./background/index";
|
|
26
26
|
import type { TypedUiGlobal } from "./ui/index";
|
|
27
27
|
interface _TestChannels {
|
|
28
28
|
ping: {
|
|
@@ -36,5 +36,7 @@ export type _TypedBackground = _Assert<_RegisteredSession["ui"] extends UIModule
|
|
|
36
36
|
export type _Typed = TypedUiGlobal<{
|
|
37
37
|
foo: number;
|
|
38
38
|
}>;
|
|
39
|
+
import type { ReaderSession } from "./reader/index";
|
|
40
|
+
export declare const sessionIsReaderSession: (session: MiniappSession) => ReaderSession;
|
|
39
41
|
export {};
|
|
40
42
|
//# sourceMappingURL=sub-path-types.test-d.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sub-path-types.test-d.d.ts","sourceRoot":"","sources":["../src/sub-path-types.test-d.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAGH,OAAO,EAAC,eAAe,EAAC,MAAM,oBAAoB,CAAA;AAClD,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"sub-path-types.test-d.d.ts","sourceRoot":"","sources":["../src/sub-path-types.test-d.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAGH,OAAO,EAAC,eAAe,EAAC,MAAM,oBAAoB,CAAA;AAClD,OAAO,KAAK,EAAC,cAAc,EAAE,QAAQ,EAAC,MAAM,oBAAoB,CAAA;AAGhE,OAAO,KAAK,EAAW,aAAa,EAAC,MAAM,YAAY,CAAA;AAQvD,UAAU,aAAa;IACrB,IAAI,EAAE;QAAC,EAAE,EAAE,MAAM,CAAA;KAAC,CAAA;CACnB;AACD,KAAK,kBAAkB,GAAG,UAAU,CAAC,OAAO,eAAe,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;AAC9E,KAAK,kBAAkB,GAAG,UAAU,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC,CAAA;AAC3D,KAAK,OAAO,CAAC,CAAC,SAAS,IAAI,IAAI,CAAC,CAAA;AAChC,MAAM,MAAM,gBAAgB,GAAG,OAAO,CAAC,kBAAkB,CAAC,IAAI,CAAC,SAAS,QAAQ,CAAC,aAAa,CAAC,GAAG,IAAI,GAAG,KAAK,CAAC,CAAA;AAS/G,MAAM,MAAM,MAAM,GAAG,aAAa,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAC,CAAC,CAAA;AAWjD,OAAO,KAAK,EAAC,aAAa,EAAC,MAAM,gBAAgB,CAAA;AACjD,eAAO,MAAM,sBAAsB,GAAI,SAAS,cAAc,KAAG,aAAwB,CAAA"}
|
|
@@ -27,11 +27,5 @@ void _bg;
|
|
|
27
27
|
// ✅ UiGlobal is reachable from the ui entry.
|
|
28
28
|
const _ui = undefined;
|
|
29
29
|
void _ui;
|
|
30
|
-
export
|
|
31
|
-
// ----- compile-time guardrails ------------------------------------------
|
|
32
|
-
// (TypeScript doesn't ship a `// @ts-expect-no-error` mirror, so we just
|
|
33
|
-
// rely on the named imports above failing if the corresponding files
|
|
34
|
-
// disappear. The asymmetric exports are enforced by package.json's
|
|
35
|
-
// `exports` map at consumer time; this file proves the source files
|
|
36
|
-
// expose what they should.)
|
|
30
|
+
export const sessionIsReaderSession = (session) => session;
|
|
37
31
|
//# sourceMappingURL=sub-path-types.test-d.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sub-path-types.test-d.js","sourceRoot":"","sources":["../src/sub-path-types.test-d.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AASH,2DAA2D;AAC3D,MAAM,GAAG,GAA+B,SAAS,CAAA;AACjD,KAAK,GAAG,CAAA;AAYR,6CAA6C;AAC7C,MAAM,GAAG,GAAyB,SAAS,CAAA;AAC3C,KAAK,GAAG,CAAA
|
|
1
|
+
{"version":3,"file":"sub-path-types.test-d.js","sourceRoot":"","sources":["../src/sub-path-types.test-d.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AASH,2DAA2D;AAC3D,MAAM,GAAG,GAA+B,SAAS,CAAA;AACjD,KAAK,GAAG,CAAA;AAYR,6CAA6C;AAC7C,MAAM,GAAG,GAAyB,SAAS,CAAA;AAC3C,KAAK,GAAG,CAAA;AAiBR,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,OAAuB,EAAiB,EAAE,CAAC,OAAO,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@glassly/miniapp",
|
|
3
|
-
"version": "0.4.3-dev.
|
|
3
|
+
"version": "0.4.3-dev.1269",
|
|
4
4
|
"description": "SDK for building Glassly local miniapps (browser/WebView)",
|
|
5
5
|
"author": "Glassly Labs",
|
|
6
6
|
"license": "MIT",
|
|
@@ -45,6 +45,10 @@
|
|
|
45
45
|
"types": "./dist/display/index.d.ts",
|
|
46
46
|
"default": "./dist/display/index.js"
|
|
47
47
|
},
|
|
48
|
+
"./reader": {
|
|
49
|
+
"types": "./dist/reader/index.d.ts",
|
|
50
|
+
"default": "./dist/reader/index.js"
|
|
51
|
+
},
|
|
48
52
|
"./host": {
|
|
49
53
|
"types": "./dist/host/index.d.ts",
|
|
50
54
|
"default": "./dist/host/index.js"
|
|
@@ -80,7 +84,7 @@
|
|
|
80
84
|
}
|
|
81
85
|
},
|
|
82
86
|
"dependencies": {
|
|
83
|
-
"@glassly/cloud-protocol": "0.4.3-dev.
|
|
87
|
+
"@glassly/cloud-protocol": "0.4.3-dev.1269",
|
|
84
88
|
"eventemitter3": "^5.0.4"
|
|
85
89
|
},
|
|
86
90
|
"devDependencies": {
|
package/src/host/index.ts
CHANGED
|
@@ -5,6 +5,10 @@
|
|
|
5
5
|
* request validation. Pure, so the runtime's handlers stay thin and this can
|
|
6
6
|
* be tested without the native import surface the runtime pulls in.
|
|
7
7
|
*
|
|
8
|
+
* The wearer's reading preferences (OPEN_SETTINGS_KEYS) are open: every
|
|
9
|
+
* miniapp may read them, and set the reading speed, without the permission,
|
|
10
|
+
* because the SDK's Reader applies them in whichever app is reading.
|
|
11
|
+
*
|
|
8
12
|
* A dashboard miniapp is the usual consumer: it edits the notification,
|
|
9
13
|
* glasses-menu, display-position, brightness and microphone keys the phone's
|
|
10
14
|
* settings screens do, through the store, so persistence, server sync and the
|
|
@@ -39,8 +43,34 @@ export const SETTINGS_BRIDGE_KEYS: Readonly<Record<string, SettingsBridgeAccess>
|
|
|
39
43
|
notification_seen_apps: "read",
|
|
40
44
|
}
|
|
41
45
|
|
|
46
|
+
export const READING_WPM = {min: 100, max: 400, step: 20, default: 220} as const
|
|
47
|
+
export type ReadingHighlight = "filled" | "brackets" | "dim"
|
|
48
|
+
export type ReadingGlassesSpeed = "keep" | "this_read"
|
|
49
|
+
export type ReadingAppSpeed = number | "off"
|
|
50
|
+
export const READING_APP_SPEEDS = "reading_app_speeds"
|
|
51
|
+
export const READING_APP_SPEED = "reading_app_speed"
|
|
52
|
+
|
|
53
|
+
export const OPEN_SETTINGS_KEYS: Readonly<Record<string, SettingsBridgeAccess>> = {
|
|
54
|
+
reading_wpm: "write",
|
|
55
|
+
reading_auto_start: "read",
|
|
56
|
+
reading_pause_paragraphs: "read",
|
|
57
|
+
reading_glasses_speed: "read",
|
|
58
|
+
reading_highlight: "read",
|
|
59
|
+
reading_app_speed: "read",
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export function isOpenSettingsKey(key: unknown): boolean {
|
|
63
|
+
return typeof key === "string" && Object.prototype.hasOwnProperty.call(OPEN_SETTINGS_KEYS, key)
|
|
64
|
+
}
|
|
65
|
+
|
|
42
66
|
// What each stored key holds until someone writes it; the Glassly App's settings store reads these.
|
|
43
67
|
const SETTINGS_BRIDGE_DEFAULTS: Readonly<Record<string, unknown>> = {
|
|
68
|
+
reading_wpm: READING_WPM.default,
|
|
69
|
+
reading_auto_start: true,
|
|
70
|
+
reading_pause_paragraphs: true,
|
|
71
|
+
reading_glasses_speed: "keep",
|
|
72
|
+
reading_highlight: "filled",
|
|
73
|
+
reading_app_speeds: {},
|
|
44
74
|
custom_dashboard_enabled: true,
|
|
45
75
|
head_up_angle: 45,
|
|
46
76
|
dashboard_depth: 2,
|
|
@@ -78,26 +108,39 @@ export function isDerivedSettingsKey(key: string): key is DerivedSettingsKey {
|
|
|
78
108
|
return (DERIVED_SETTINGS_KEYS as readonly string[]).includes(key)
|
|
79
109
|
}
|
|
80
110
|
|
|
81
|
-
/**
|
|
82
|
-
|
|
111
|
+
/**
|
|
112
|
+
* What an app may do with `key`, or null when the bridge does not serve it
|
|
113
|
+
* to that app. `platform` is whether the app holds PLATFORM_SETTINGS (or is
|
|
114
|
+
* a system app); without it only the open keys are served.
|
|
115
|
+
*/
|
|
116
|
+
export function settingsBridgeAccess(key: string, platform = true): SettingsBridgeAccess | null {
|
|
117
|
+
if (isOpenSettingsKey(key)) return OPEN_SETTINGS_KEYS[key]
|
|
118
|
+
if (!platform) return null
|
|
83
119
|
if (isDerivedSettingsKey(key)) return "read"
|
|
84
120
|
return SETTINGS_BRIDGE_KEYS[key] ?? null
|
|
85
121
|
}
|
|
86
122
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
return [...Object.keys(SETTINGS_BRIDGE_KEYS), ...DERIVED_SETTINGS_KEYS]
|
|
123
|
+
export function allSettingsBridgeKeys(platform = true): string[] {
|
|
124
|
+
if (!platform) return Object.keys(OPEN_SETTINGS_KEYS)
|
|
125
|
+
return [...Object.keys(SETTINGS_BRIDGE_KEYS), ...Object.keys(OPEN_SETTINGS_KEYS), ...DERIVED_SETTINGS_KEYS]
|
|
90
126
|
}
|
|
91
127
|
|
|
92
128
|
/**
|
|
93
|
-
* The keys a SETTINGS_GET asks for: everything
|
|
94
|
-
* else the known ones among the requested strings
|
|
95
|
-
* out, never rejected).
|
|
129
|
+
* The keys a SETTINGS_GET asks for: everything the app may read when
|
|
130
|
+
* `requested` is absent, else the known ones among the requested strings
|
|
131
|
+
* (unknown keys are left out, never rejected).
|
|
96
132
|
*/
|
|
97
|
-
export function selectSettingsBridgeKeys(requested: unknown): string[] {
|
|
98
|
-
if (requested === undefined || requested === null) return allSettingsBridgeKeys()
|
|
133
|
+
export function selectSettingsBridgeKeys(requested: unknown, platform = true): string[] {
|
|
134
|
+
if (requested === undefined || requested === null) return allSettingsBridgeKeys(platform)
|
|
99
135
|
if (!Array.isArray(requested)) return []
|
|
100
|
-
return requested.filter(
|
|
136
|
+
return requested.filter(
|
|
137
|
+
(key): key is string => typeof key === "string" && settingsBridgeAccess(key, platform) !== null,
|
|
138
|
+
)
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
export function settingsRequestNeedsPermission(kind: "get" | "set", payload: Record<string, unknown>): boolean {
|
|
142
|
+
if (kind === "set") return !isOpenSettingsKey(payload.key)
|
|
143
|
+
return Array.isArray(payload.keys) && payload.keys.some((key) => !isOpenSettingsKey(key))
|
|
101
144
|
}
|
|
102
145
|
|
|
103
146
|
export type SettingsSetValidation =
|
|
@@ -115,5 +158,21 @@ export function validateSettingsSet(payload: Record<string, unknown>): SettingsS
|
|
|
115
158
|
if (!("value" in payload) || payload.value === undefined) {
|
|
116
159
|
return {ok: false, code: "INVALID_ARGUMENT", message: "settings.set requires a value"}
|
|
117
160
|
}
|
|
161
|
+
if (key === "reading_wpm" && !isReadingWpm(payload.value)) {
|
|
162
|
+
return {
|
|
163
|
+
ok: false,
|
|
164
|
+
code: "INVALID_ARGUMENT",
|
|
165
|
+
message: `reading_wpm is a whole number from ${READING_WPM.min} to ${READING_WPM.max}`,
|
|
166
|
+
}
|
|
167
|
+
}
|
|
118
168
|
return {ok: true, key, value: payload.value}
|
|
119
169
|
}
|
|
170
|
+
|
|
171
|
+
export function readingAppSpeedFor(speeds: unknown, packageName: string): ReadingAppSpeed | null {
|
|
172
|
+
const own = speeds && typeof speeds === "object" ? (speeds as Record<string, unknown>)[packageName] : undefined
|
|
173
|
+
return own === "off" || isReadingWpm(own) ? own : null
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
export function isReadingWpm(value: unknown): value is number {
|
|
177
|
+
return Number.isInteger(value) && (value as number) >= READING_WPM.min && (value as number) <= READING_WPM.max
|
|
178
|
+
}
|