@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
package/README.md
CHANGED
|
@@ -83,6 +83,14 @@ from `@glassly/miniapp/display`. These pure TypeScript primitives share the
|
|
|
83
83
|
host's implementation and work in either miniapp layer. See the
|
|
84
84
|
[display primitives reference](../../../sdk/docs/display-primitives.md).
|
|
85
85
|
|
|
86
|
+
### The Reader
|
|
87
|
+
|
|
88
|
+
`openReader(session, {title, sections, hold?, leaveLabel?})` from
|
|
89
|
+
`@glassly/miniapp/reader` reads long text on the glasses line by line at the
|
|
90
|
+
wearer's reading speed, with tap to pause, swipes to step or change speed,
|
|
91
|
+
hold for your action and double tap to leave. See the
|
|
92
|
+
[Reader reference](../../../sdk/docs/reader.md).
|
|
93
|
+
|
|
86
94
|
### Opt-in display helpers
|
|
87
95
|
|
|
88
96
|
Both the main and `/background` entry points export:
|
|
@@ -189,7 +197,7 @@ All event subscribers return an `UnsubscribeFn`. Subscriptions are ref-counted:
|
|
|
189
197
|
| `session.phone.notifications` | `on(handler)`, `onDismissed(handler)`, `stop()`, `hasPermission`, `installedApps()` (needs `READ_NOTIFICATIONS`) |
|
|
190
198
|
| `session.phone.calendar` | `listEvents({startsAt, endsAt, limit?})`, `hasPermission` |
|
|
191
199
|
| `session.phone` | `onBattery(handler)` |
|
|
192
|
-
| `session.settings` | `get(key)`, `getAll(keys?)`, `set(key, value)`, `onChange(handler)`; needs `PLATFORM_SETTINGS
|
|
200
|
+
| `session.settings` | `get(key)`, `getAll(keys?)`, `set(key, value)`, `onChange(handler)`; needs `PLATFORM_SETTINGS` except for the reading settings; see [settings reference](../../../sdk/docs/settings.md) |
|
|
193
201
|
| `session.storage` | `get(key)`, `set(key, value)`, `delete(key)`, `keys()`, `has(key)`, `getAll()`, `setMultiple(values)`, `clear()`, `flush()`; strings only, scoped to `(userId, packageName)` |
|
|
194
202
|
| `session.blob` | `set(key, data, opts?)`, `get(key)`, `stat(key)`, `has(key)`, `keys()`, `list()`, `setFromUrl(key, url, opts?)`, `importFile(opts?)`, `createWriteStream(key, opts?)`, `createReadStream(key)`, `bytes(key)`, `usage()`, `delete(key)`, `clear()`, `share(key)`; phone-local binary storage, chunked writes/reads |
|
|
195
203
|
| `session.stream` | `startStream(opts?)`, `stop(streamId?)`; managed (default, returns `hlsUrl`/`dashUrl`/`webrtcUrl` and optional `destinations` fan-out) or `direct` (publish straight to your own ingest URL, no playback URLs); `opts.ingest` selects `"srt"` (default), `"whip"`, or `"rtmp"`; video config fields are `width`, `height`, `bitrate`, `fps` |
|
package/dist/host/index.d.ts
CHANGED
package/dist/host/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/host/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAC,WAAW,EAAE,KAAK,aAAa,EAAC,MAAM,UAAU,CAAA;AACxD,OAAO,EACL,yBAAyB,EACzB,yBAAyB,EACzB,KAAK,0BAA0B,EAC/B,KAAK,eAAe,EACpB,KAAK,kBAAkB,EACvB,KAAK,eAAe,GACrB,MAAM,kBAAkB,CAAA;AAGzB,cAAc,sBAAsB,CAAA;AACpC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,oBAAoB,CAAA;AAClC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,sBAAsB,CAAA;AACpC,cAAc,gBAAgB,CAAA;AAC9B,cAAc,mBAAmB,CAAA;AACjC,cAAc,kBAAkB,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/host/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAC,WAAW,EAAE,KAAK,aAAa,EAAC,MAAM,UAAU,CAAA;AACxD,OAAO,EACL,yBAAyB,EACzB,yBAAyB,EACzB,KAAK,0BAA0B,EAC/B,KAAK,eAAe,EACpB,KAAK,kBAAkB,EACvB,KAAK,eAAe,GACrB,MAAM,kBAAkB,CAAA;AAGzB,cAAc,sBAAsB,CAAA;AACpC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,oBAAoB,CAAA;AAClC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,sBAAsB,CAAA;AACpC,cAAc,gBAAgB,CAAA;AAC9B,cAAc,mBAAmB,CAAA;AACjC,cAAc,kBAAkB,CAAA;AAChC,cAAc,gBAAgB,CAAA"}
|
package/dist/host/index.js
CHANGED
package/dist/host/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/host/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAC,WAAW,EAAqB,MAAM,UAAU,CAAA;AACxD,OAAO,EACL,yBAAyB,EACzB,yBAAyB,GAK1B,MAAM,kBAAkB,CAAA;AAEzB,0FAA0F;AAC1F,cAAc,sBAAsB,CAAA;AACpC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,oBAAoB,CAAA;AAClC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,sBAAsB,CAAA;AACpC,cAAc,gBAAgB,CAAA;AAC9B,cAAc,mBAAmB,CAAA;AACjC,cAAc,kBAAkB,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/host/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAC,WAAW,EAAqB,MAAM,UAAU,CAAA;AACxD,OAAO,EACL,yBAAyB,EACzB,yBAAyB,GAK1B,MAAM,kBAAkB,CAAA;AAEzB,0FAA0F;AAC1F,cAAc,sBAAsB,CAAA;AACpC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,oBAAoB,CAAA;AAClC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,sBAAsB,CAAA;AACpC,cAAc,gBAAgB,CAAA;AAC9B,cAAc,mBAAmB,CAAA;AACjC,cAAc,kBAAkB,CAAA;AAChC,cAAc,gBAAgB,CAAA"}
|
|
@@ -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
|
|
@@ -14,6 +18,19 @@
|
|
|
14
18
|
export type SettingsBridgeAccess = "read" | "write";
|
|
15
19
|
/** Stored settings the bridge serves, by key, with what a permitted app may do to each. */
|
|
16
20
|
export declare const SETTINGS_BRIDGE_KEYS: Readonly<Record<string, SettingsBridgeAccess>>;
|
|
21
|
+
export declare const READING_WPM: {
|
|
22
|
+
readonly min: 100;
|
|
23
|
+
readonly max: 400;
|
|
24
|
+
readonly step: 20;
|
|
25
|
+
readonly default: 220;
|
|
26
|
+
};
|
|
27
|
+
export type ReadingHighlight = "filled" | "brackets" | "dim";
|
|
28
|
+
export type ReadingGlassesSpeed = "keep" | "this_read";
|
|
29
|
+
export type ReadingAppSpeed = number | "off";
|
|
30
|
+
export declare const READING_APP_SPEEDS = "reading_app_speeds";
|
|
31
|
+
export declare const READING_APP_SPEED = "reading_app_speed";
|
|
32
|
+
export declare const OPEN_SETTINGS_KEYS: Readonly<Record<string, SettingsBridgeAccess>>;
|
|
33
|
+
export declare function isOpenSettingsKey(key: unknown): boolean;
|
|
17
34
|
/** A stored key's default, as a fresh copy; undefined for a key the bridge does not store. */
|
|
18
35
|
export declare function settingsBridgeDefault(key: string): unknown;
|
|
19
36
|
/**
|
|
@@ -25,16 +42,20 @@ export declare function settingsBridgeDefault(key: string): unknown;
|
|
|
25
42
|
export declare const DERIVED_SETTINGS_KEYS: readonly ["phone_active", "foreground_app_on_screen", "controllers"];
|
|
26
43
|
export type DerivedSettingsKey = (typeof DERIVED_SETTINGS_KEYS)[number];
|
|
27
44
|
export declare function isDerivedSettingsKey(key: string): key is DerivedSettingsKey;
|
|
28
|
-
/** What a permitted app may do with `key`, or null when the bridge does not serve it. */
|
|
29
|
-
export declare function settingsBridgeAccess(key: string): SettingsBridgeAccess | null;
|
|
30
|
-
/** Every key the bridge serves, stored then derived. */
|
|
31
|
-
export declare function allSettingsBridgeKeys(): string[];
|
|
32
45
|
/**
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
46
|
+
* What an app may do with `key`, or null when the bridge does not serve it
|
|
47
|
+
* to that app. `platform` is whether the app holds PLATFORM_SETTINGS (or is
|
|
48
|
+
* a system app); without it only the open keys are served.
|
|
49
|
+
*/
|
|
50
|
+
export declare function settingsBridgeAccess(key: string, platform?: boolean): SettingsBridgeAccess | null;
|
|
51
|
+
export declare function allSettingsBridgeKeys(platform?: boolean): string[];
|
|
52
|
+
/**
|
|
53
|
+
* The keys a SETTINGS_GET asks for: everything the app may read when
|
|
54
|
+
* `requested` is absent, else the known ones among the requested strings
|
|
55
|
+
* (unknown keys are left out, never rejected).
|
|
36
56
|
*/
|
|
37
|
-
export declare function selectSettingsBridgeKeys(requested: unknown): string[];
|
|
57
|
+
export declare function selectSettingsBridgeKeys(requested: unknown, platform?: boolean): string[];
|
|
58
|
+
export declare function settingsRequestNeedsPermission(kind: "get" | "set", payload: Record<string, unknown>): boolean;
|
|
38
59
|
export type SettingsSetValidation = {
|
|
39
60
|
ok: true;
|
|
40
61
|
key: string;
|
|
@@ -46,4 +67,6 @@ export type SettingsSetValidation = {
|
|
|
46
67
|
};
|
|
47
68
|
/** A SETTINGS_SET payload: a writable key and a JSON value (undefined is not a value). */
|
|
48
69
|
export declare function validateSettingsSet(payload: Record<string, unknown>): SettingsSetValidation;
|
|
70
|
+
export declare function readingAppSpeedFor(speeds: unknown, packageName: string): ReadingAppSpeed | null;
|
|
71
|
+
export declare function isReadingWpm(value: unknown): value is number;
|
|
49
72
|
//# sourceMappingURL=settingsBridge.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"settingsBridge.d.ts","sourceRoot":"","sources":["../../src/host/settingsBridge.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"settingsBridge.d.ts","sourceRoot":"","sources":["../../src/host/settingsBridge.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,MAAM,MAAM,oBAAoB,GAAG,MAAM,GAAG,OAAO,CAAA;AAEnD,2FAA2F;AAC3F,eAAO,MAAM,oBAAoB,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,oBAAoB,CAAC,CAsB/E,CAAA;AAED,eAAO,MAAM,WAAW;;;;;CAAwD,CAAA;AAChF,MAAM,MAAM,gBAAgB,GAAG,QAAQ,GAAG,UAAU,GAAG,KAAK,CAAA;AAC5D,MAAM,MAAM,mBAAmB,GAAG,MAAM,GAAG,WAAW,CAAA;AACtD,MAAM,MAAM,eAAe,GAAG,MAAM,GAAG,KAAK,CAAA;AAC5C,eAAO,MAAM,kBAAkB,uBAAuB,CAAA;AACtD,eAAO,MAAM,iBAAiB,sBAAsB,CAAA;AAEpD,eAAO,MAAM,kBAAkB,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,oBAAoB,CAAC,CAO7E,CAAA;AAED,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAEvD;AA4BD,8FAA8F;AAC9F,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAG1D;AAED;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'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
|
|
@@ -35,8 +39,28 @@ export const SETTINGS_BRIDGE_KEYS = {
|
|
|
35
39
|
// Apps the glasses reported posting notifications; the engine records it.
|
|
36
40
|
notification_seen_apps: "read",
|
|
37
41
|
};
|
|
42
|
+
export const READING_WPM = { min: 100, max: 400, step: 20, default: 220 };
|
|
43
|
+
export const READING_APP_SPEEDS = "reading_app_speeds";
|
|
44
|
+
export const READING_APP_SPEED = "reading_app_speed";
|
|
45
|
+
export const OPEN_SETTINGS_KEYS = {
|
|
46
|
+
reading_wpm: "write",
|
|
47
|
+
reading_auto_start: "read",
|
|
48
|
+
reading_pause_paragraphs: "read",
|
|
49
|
+
reading_glasses_speed: "read",
|
|
50
|
+
reading_highlight: "read",
|
|
51
|
+
reading_app_speed: "read",
|
|
52
|
+
};
|
|
53
|
+
export function isOpenSettingsKey(key) {
|
|
54
|
+
return typeof key === "string" && Object.prototype.hasOwnProperty.call(OPEN_SETTINGS_KEYS, key);
|
|
55
|
+
}
|
|
38
56
|
// What each stored key holds until someone writes it; the Glassly App's settings store reads these.
|
|
39
57
|
const SETTINGS_BRIDGE_DEFAULTS = {
|
|
58
|
+
reading_wpm: READING_WPM.default,
|
|
59
|
+
reading_auto_start: true,
|
|
60
|
+
reading_pause_paragraphs: true,
|
|
61
|
+
reading_glasses_speed: "keep",
|
|
62
|
+
reading_highlight: "filled",
|
|
63
|
+
reading_app_speeds: {},
|
|
40
64
|
custom_dashboard_enabled: true,
|
|
41
65
|
head_up_angle: 45,
|
|
42
66
|
dashboard_depth: 2,
|
|
@@ -69,27 +93,41 @@ export const DERIVED_SETTINGS_KEYS = ["phone_active", "foreground_app_on_screen"
|
|
|
69
93
|
export function isDerivedSettingsKey(key) {
|
|
70
94
|
return DERIVED_SETTINGS_KEYS.includes(key);
|
|
71
95
|
}
|
|
72
|
-
/**
|
|
73
|
-
|
|
96
|
+
/**
|
|
97
|
+
* What an app may do with `key`, or null when the bridge does not serve it
|
|
98
|
+
* to that app. `platform` is whether the app holds PLATFORM_SETTINGS (or is
|
|
99
|
+
* a system app); without it only the open keys are served.
|
|
100
|
+
*/
|
|
101
|
+
export function settingsBridgeAccess(key, platform = true) {
|
|
102
|
+
if (isOpenSettingsKey(key))
|
|
103
|
+
return OPEN_SETTINGS_KEYS[key];
|
|
104
|
+
if (!platform)
|
|
105
|
+
return null;
|
|
74
106
|
if (isDerivedSettingsKey(key))
|
|
75
107
|
return "read";
|
|
76
108
|
return SETTINGS_BRIDGE_KEYS[key] ?? null;
|
|
77
109
|
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
110
|
+
export function allSettingsBridgeKeys(platform = true) {
|
|
111
|
+
if (!platform)
|
|
112
|
+
return Object.keys(OPEN_SETTINGS_KEYS);
|
|
113
|
+
return [...Object.keys(SETTINGS_BRIDGE_KEYS), ...Object.keys(OPEN_SETTINGS_KEYS), ...DERIVED_SETTINGS_KEYS];
|
|
81
114
|
}
|
|
82
115
|
/**
|
|
83
|
-
* The keys a SETTINGS_GET asks for: everything
|
|
84
|
-
* else the known ones among the requested strings
|
|
85
|
-
* out, never rejected).
|
|
116
|
+
* The keys a SETTINGS_GET asks for: everything the app may read when
|
|
117
|
+
* `requested` is absent, else the known ones among the requested strings
|
|
118
|
+
* (unknown keys are left out, never rejected).
|
|
86
119
|
*/
|
|
87
|
-
export function selectSettingsBridgeKeys(requested) {
|
|
120
|
+
export function selectSettingsBridgeKeys(requested, platform = true) {
|
|
88
121
|
if (requested === undefined || requested === null)
|
|
89
|
-
return allSettingsBridgeKeys();
|
|
122
|
+
return allSettingsBridgeKeys(platform);
|
|
90
123
|
if (!Array.isArray(requested))
|
|
91
124
|
return [];
|
|
92
|
-
return requested.filter((key) => typeof key === "string" && settingsBridgeAccess(key) !== null);
|
|
125
|
+
return requested.filter((key) => typeof key === "string" && settingsBridgeAccess(key, platform) !== null);
|
|
126
|
+
}
|
|
127
|
+
export function settingsRequestNeedsPermission(kind, payload) {
|
|
128
|
+
if (kind === "set")
|
|
129
|
+
return !isOpenSettingsKey(payload.key);
|
|
130
|
+
return Array.isArray(payload.keys) && payload.keys.some((key) => !isOpenSettingsKey(key));
|
|
93
131
|
}
|
|
94
132
|
/** A SETTINGS_SET payload: a writable key and a JSON value (undefined is not a value). */
|
|
95
133
|
export function validateSettingsSet(payload) {
|
|
@@ -105,6 +143,20 @@ export function validateSettingsSet(payload) {
|
|
|
105
143
|
if (!("value" in payload) || payload.value === undefined) {
|
|
106
144
|
return { ok: false, code: "INVALID_ARGUMENT", message: "settings.set requires a value" };
|
|
107
145
|
}
|
|
146
|
+
if (key === "reading_wpm" && !isReadingWpm(payload.value)) {
|
|
147
|
+
return {
|
|
148
|
+
ok: false,
|
|
149
|
+
code: "INVALID_ARGUMENT",
|
|
150
|
+
message: `reading_wpm is a whole number from ${READING_WPM.min} to ${READING_WPM.max}`,
|
|
151
|
+
};
|
|
152
|
+
}
|
|
108
153
|
return { ok: true, key, value: payload.value };
|
|
109
154
|
}
|
|
155
|
+
export function readingAppSpeedFor(speeds, packageName) {
|
|
156
|
+
const own = speeds && typeof speeds === "object" ? speeds[packageName] : undefined;
|
|
157
|
+
return own === "off" || isReadingWpm(own) ? own : null;
|
|
158
|
+
}
|
|
159
|
+
export function isReadingWpm(value) {
|
|
160
|
+
return Number.isInteger(value) && value >= READING_WPM.min && value <= READING_WPM.max;
|
|
161
|
+
}
|
|
110
162
|
//# sourceMappingURL=settingsBridge.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"settingsBridge.js","sourceRoot":"","sources":["../../src/host/settingsBridge.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"settingsBridge.js","sourceRoot":"","sources":["../../src/host/settingsBridge.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAIH,2FAA2F;AAC3F,MAAM,CAAC,MAAM,oBAAoB,GAAmD;IAClF,4DAA4D;IAC5D,wBAAwB,EAAE,MAAM;IAChC,aAAa,EAAE,OAAO;IACtB,4EAA4E;IAC5E,eAAe,EAAE,OAAO;IACxB,gBAAgB,EAAE,OAAO;IACzB,+DAA+D;IAC/D,UAAU,EAAE,OAAO;IACnB,eAAe,EAAE,OAAO;IACxB,wDAAwD;IACxD,aAAa,EAAE,OAAO;IACtB,SAAS,EAAE,OAAO;IAClB,qBAAqB,EAAE,OAAO;IAC9B,oBAAoB,EAAE,OAAO;IAC7B,2BAA2B,EAAE,OAAO;IACpC,2BAA2B,EAAE,OAAO;IACpC,8BAA8B,EAAE,OAAO;IACvC,iCAAiC,EAAE,OAAO;IAC1C,uBAAuB,EAAE,OAAO;IAChC,0EAA0E;IAC1E,sBAAsB,EAAE,MAAM;CAC/B,CAAA;AAED,MAAM,CAAC,MAAM,WAAW,GAAG,EAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,EAAE,EAAE,OAAO,EAAE,GAAG,EAAU,CAAA;AAIhF,MAAM,CAAC,MAAM,kBAAkB,GAAG,oBAAoB,CAAA;AACtD,MAAM,CAAC,MAAM,iBAAiB,GAAG,mBAAmB,CAAA;AAEpD,MAAM,CAAC,MAAM,kBAAkB,GAAmD;IAChF,WAAW,EAAE,OAAO;IACpB,kBAAkB,EAAE,MAAM;IAC1B,wBAAwB,EAAE,MAAM;IAChC,qBAAqB,EAAE,MAAM;IAC7B,iBAAiB,EAAE,MAAM;IACzB,iBAAiB,EAAE,MAAM;CAC1B,CAAA;AAED,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AI,EAAE,kBAAkB;YACxB,OAAO,EAAE,sCAAsC,WAAW,CAAC,GAAG,OAAO,WAAW,CAAC,GAAG,EAAE;SACvF,CAAA;IACH,CAAC;IACD,OAAO,EAAC,EAAE,EAAE,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAC,CAAA;AAC9C,CAAC;AAED,MAAM,UAAU,kBAAkB,CAAC,MAAe,EAAE,WAAmB;IACrE,MAAM,GAAG,GAAG,MAAM,IAAI,OAAO,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAE,MAAkC,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,SAAS,CAAA;IAC/G,OAAO,GAAG,KAAK,KAAK,IAAI,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAA;AACxD,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,KAAc;IACzC,OAAO,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,IAAK,KAAgB,IAAI,WAAW,CAAC,GAAG,IAAK,KAAgB,IAAI,WAAW,CAAC,GAAG,CAAA;AAChH,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/** Convert display-oriented text into plain words before TTS synthesis. */
|
|
2
|
+
export declare function sanitizeTtsText(text: string): string;
|
|
3
|
+
/** Prepare an already-trimmed sentence list while preserving the exact-text opt-out. */
|
|
4
|
+
export declare function prepareTtsSentences(sentences: string[], enableSanitization?: boolean): string[];
|
|
5
|
+
//# sourceMappingURL=ttsSanitizer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ttsSanitizer.d.ts","sourceRoot":"","sources":["../../src/host/ttsSanitizer.ts"],"names":[],"mappings":"AAQA,2EAA2E;AAC3E,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAmCpD;AAED,wFAAwF;AACxF,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,MAAM,EAAE,EAAE,kBAAkB,UAAO,GAAG,MAAM,EAAE,CAkB5F"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
const HTML_ENTITIES = {
|
|
2
|
+
"&": "&",
|
|
3
|
+
"<": "<",
|
|
4
|
+
">": ">",
|
|
5
|
+
""": '"',
|
|
6
|
+
"'": "'",
|
|
7
|
+
};
|
|
8
|
+
/** Convert display-oriented text into plain words before TTS synthesis. */
|
|
9
|
+
export function sanitizeTtsText(text) {
|
|
10
|
+
let speech = text.replace(/&(amp|lt|gt|quot|#39);/gi, (entity) => HTML_ENTITIES[entity.toLowerCase()] ?? entity);
|
|
11
|
+
speech = speech
|
|
12
|
+
.replace(/<say-as\b[^>]*>(.*?)<\/say-as>/gis, "$1")
|
|
13
|
+
.replace(/<\/?[a-z][a-z0-9-]*(?:\s[^<>]*?)?\s*\/?>/gi, " ")
|
|
14
|
+
.replace(/\[([^\]]+)]\([^)]+\)/g, "$1")
|
|
15
|
+
.replace(/`([^`]*)`/g, "$1")
|
|
16
|
+
.replace(/(-?\d+(?:[.,]\d+)?)\s*(?:°\s*f\b|℉)/gi, "$1 degrees Fahrenheit")
|
|
17
|
+
.replace(/(-?\d+(?:[.,]\d+)?)\s*(?:°\s*c\b|℃)/gi, "$1 degrees Celsius")
|
|
18
|
+
.replace(/(-?\d+(?:[.,]\d+)?)\s*°/g, "$1 degrees")
|
|
19
|
+
.replace(/<=/g, " less than or equal to ")
|
|
20
|
+
.replace(/>=/g, " greater than or equal to ")
|
|
21
|
+
.replace(/</g, " less than ")
|
|
22
|
+
.replace(/>/g, " greater than ")
|
|
23
|
+
.replace(/[[\]{}()]/g, " ")
|
|
24
|
+
.replace(/(degrees Fahrenheit)\s+(-?\d+(?:[.,]\d+)? degrees Celsius)\b/gi, "$1 or $2")
|
|
25
|
+
.replace(/(degrees Celsius)\s+(-?\d+(?:[.,]\d+)? degrees Fahrenheit)\b/gi, "$1 or $2")
|
|
26
|
+
.replace(/&/g, " and ")
|
|
27
|
+
.replace(/\+/g, " plus ")
|
|
28
|
+
.replace(/=/g, " equals ")
|
|
29
|
+
.replace(/#/g, " hash ")
|
|
30
|
+
.replace(/@/g, " at ")
|
|
31
|
+
.replace(/%/g, " percent ")
|
|
32
|
+
.replace(/\\/g, " backslash ")
|
|
33
|
+
.replace(/\//g, (slash, offset, source) => {
|
|
34
|
+
const numericSeparator = /\d/.test(source[offset - 1] ?? "") && /\d/.test(source[offset + 1] ?? "");
|
|
35
|
+
return numericSeparator ? slash : " slash ";
|
|
36
|
+
})
|
|
37
|
+
.replace(/\*/g, " star ");
|
|
38
|
+
return speech
|
|
39
|
+
.replace(/\s+([,.;:!?])/g, "$1")
|
|
40
|
+
.replace(/\s+/g, " ")
|
|
41
|
+
.trim();
|
|
42
|
+
}
|
|
43
|
+
/** Prepare an already-trimmed sentence list while preserving the exact-text opt-out. */
|
|
44
|
+
export function prepareTtsSentences(sentences, enableSanitization = true) {
|
|
45
|
+
if (!enableSanitization)
|
|
46
|
+
return sentences;
|
|
47
|
+
const sanitized = sentences.map((sentence) => sanitizeTtsText(sentence)).filter(Boolean);
|
|
48
|
+
return sanitized.map((sentence, index) => {
|
|
49
|
+
const previous = sanitized[index - 1];
|
|
50
|
+
if (!previous)
|
|
51
|
+
return sentence;
|
|
52
|
+
const followsFahrenheit = /degrees Fahrenheit[,.;:!?]?$/i.test(previous);
|
|
53
|
+
const followsCelsius = /degrees Celsius[,.;:!?]?$/i.test(previous);
|
|
54
|
+
const startsWithFahrenheit = /^-?\d+(?:[.,]\d+)? degrees Fahrenheit\b/i.test(sentence);
|
|
55
|
+
const startsWithCelsius = /^-?\d+(?:[.,]\d+)? degrees Celsius\b/i.test(sentence);
|
|
56
|
+
return (followsFahrenheit && startsWithCelsius) || (followsCelsius && startsWithFahrenheit)
|
|
57
|
+
? `or ${sentence}`
|
|
58
|
+
: sentence;
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=ttsSanitizer.js.map
|
|
@@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AAiB,GAAG,+BAA+B,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;QACxE,MAAM,cAAc,GAAG,4BAA4B,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;QAClE,MAAM,oBAAoB,GAAG,0CAA0C,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;QACtF,MAAM,iBAAiB,GAAG,uCAAuC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;QAEhF,OAAO,CAAC,iBAAiB,IAAI,iBAAiB,CAAC,IAAI,CAAC,cAAc,IAAI,oBAAoB,CAAC;YACzF,CAAC,CAAC,MAAM,QAAQ,EAAE;YAClB,CAAC,CAAC,QAAQ,CAAA;IACd,CAAC,CAAC,CAAA;AACJ,CAAC"}
|
package/dist/modules/cloud.d.ts
CHANGED
|
@@ -11,6 +11,7 @@ export type CloudClientConnectionStatus = "connected" | "connecting" | "reconnec
|
|
|
11
11
|
export type CloudClientAudioTransport = "udp" | "ws" | "offline" | "none";
|
|
12
12
|
/** Metered cloud features the account's plan can run out of. */
|
|
13
13
|
export type CloudQuotaFeature = "transcription";
|
|
14
|
+
export type CloudSpeechFeature = "transcription" | "translation";
|
|
14
15
|
export interface CloudClientStatus {
|
|
15
16
|
status: CloudClientConnectionStatus;
|
|
16
17
|
audioTransport: CloudClientAudioTransport;
|
|
@@ -20,6 +21,7 @@ export interface CloudClientStatus {
|
|
|
20
21
|
* declined. Empty on hosts that predate the field.
|
|
21
22
|
*/
|
|
22
23
|
quotaBlocked: CloudQuotaFeature[];
|
|
24
|
+
speechFailed: CloudSpeechFeature[];
|
|
23
25
|
}
|
|
24
26
|
export declare const CLOUD_STATUS_STREAM = "_cloud_status";
|
|
25
27
|
export declare class CloudModule {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cloud.d.ts","sourceRoot":"","sources":["../../src/modules/cloud.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,OAAO,EAAC,cAAc,EAAC,MAAM,YAAY,CA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cAAc,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO;IAInD,wEAAwE;IACxE,IAAI,SAAS,IAAI,OAAO,CAEvB;IAED,sEAAsE;IACtE,WAAW,IAAI,OAAO;IAItB;;;OAGG;IACH,eAAe,CAAC,OAAO,EAAE,CAAC,MAAM,EAAE,iBAAiB,KAAK,IAAI,GAAG,aAAa;CAO7E"}
|
package/dist/modules/cloud.js
CHANGED
|
@@ -11,8 +11,16 @@ const DEFAULT_STATUS = {
|
|
|
11
11
|
status: "disconnected",
|
|
12
12
|
audioTransport: "none",
|
|
13
13
|
quotaBlocked: [],
|
|
14
|
+
speechFailed: [],
|
|
14
15
|
};
|
|
15
16
|
const QUOTA_FEATURES = ["transcription"];
|
|
17
|
+
const SPEECH_FEATURES = ["transcription", "translation"];
|
|
18
|
+
function knownFeatures(raw, known) {
|
|
19
|
+
return Array.isArray(raw) ? raw.filter((f) => known.includes(f)) : [];
|
|
20
|
+
}
|
|
21
|
+
function sameList(a, b) {
|
|
22
|
+
return a.length === b.length && a.every((f, i) => f === b[i]);
|
|
23
|
+
}
|
|
16
24
|
function normalizeCloudStatus(data) {
|
|
17
25
|
if (!data || typeof data !== "object")
|
|
18
26
|
return null;
|
|
@@ -28,16 +36,18 @@ function normalizeCloudStatus(data) {
|
|
|
28
36
|
audioTransport !== "none") {
|
|
29
37
|
return null;
|
|
30
38
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
39
|
+
return {
|
|
40
|
+
status,
|
|
41
|
+
audioTransport,
|
|
42
|
+
quotaBlocked: knownFeatures(raw.quotaBlocked, QUOTA_FEATURES),
|
|
43
|
+
speechFailed: knownFeatures(raw.speechFailed, SPEECH_FEATURES),
|
|
44
|
+
};
|
|
35
45
|
}
|
|
36
46
|
function sameStatus(a, b) {
|
|
37
47
|
return (a.status === b.status &&
|
|
38
48
|
a.audioTransport === b.audioTransport &&
|
|
39
|
-
a.quotaBlocked
|
|
40
|
-
a.
|
|
49
|
+
sameList(a.quotaBlocked, b.quotaBlocked) &&
|
|
50
|
+
sameList(a.speechFailed, b.speechFailed));
|
|
41
51
|
}
|
|
42
52
|
export class CloudModule {
|
|
43
53
|
constructor(session) {
|
|
@@ -56,7 +66,7 @@ export class CloudModule {
|
|
|
56
66
|
}
|
|
57
67
|
/** Latest status snapshot pushed by the phone runtime. */
|
|
58
68
|
get status() {
|
|
59
|
-
return { ...this.current, quotaBlocked: [...this.current.quotaBlocked] };
|
|
69
|
+
return { ...this.current, quotaBlocked: [...this.current.quotaBlocked], speechFailed: [...this.current.speechFailed] };
|
|
60
70
|
}
|
|
61
71
|
/** Whether the plan quota is refusing `feature` right now. */
|
|
62
72
|
isQuotaBlocked(feature) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cloud.js","sourceRoot":"","sources":["../../src/modules/cloud.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAC,YAAY,EAAC,MAAM,eAAe,CAAA;
|
|
1
|
+
{"version":3,"file":"cloud.js","sourceRoot":"","sources":["../../src/modules/cloud.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAC,YAAY,EAAC,MAAM,eAAe,CAAA;AA2B1C,MAAM,CAAC,MAAM,mBAAmB,GAAG,eAAe,CAAA;AAElD,MAAM,cAAc,GAAsB;IACxC,MAAM,EAAE,cAAc;IACtB,cAAc,EAAE,MAAM;IACtB,YAAY,EAAE,EAAE;IAChB,YAAY,EAAE,EAAE;CACjB,CAAA;AAED,MAAM,cAAc,GAAiC,CAAC,eAAe,CAAC,CAAA;AACtE,MAAM,eAAe,GAAkC,CAAC,eAAe,EAAE,aAAa,CAAC,CAAA;AAEvF,SAAS,aAAa,CAAmB,GAAY,EAAE,KAAmB;IACxE,OAAO,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,EAAU,EAAE,CAAC,KAAK,C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vB,CAAC;IAED;;;OAGG;IACH,eAAe,CAAC,OAA4C;QAC1D,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;QACpB,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAA;QAClC,OAAO,GAAG,EAAE;YACV,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAA;QACrC,CAAC,CAAA;IACH,CAAC;CACF"}
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @fileoverview SettingsModule — `session.settings`, the engine's settings
|
|
3
3
|
* store behind an allowlist. Needs the PLATFORM_SETTINGS manifest
|
|
4
|
-
* permission
|
|
4
|
+
* permission, except for the wearer's reading settings (`reading_wpm` and
|
|
5
|
+
* the other `reading_*` keys), which every miniapp may read and follow, and
|
|
6
|
+
* whose speed it may set. Without it, other keys reject with
|
|
7
|
+
* PERMISSION_NOT_DECLARED.
|
|
5
8
|
* A dashboard miniapp is the usual consumer: it reads and edits the
|
|
6
9
|
* notification and glasses-menu keys the phone's settings screens used to,
|
|
7
10
|
* so firmware sync and the host's notification policy keep one source of
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"settings.d.ts","sourceRoot":"","sources":["../../src/modules/settings.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"settings.d.ts","sourceRoot":"","sources":["../../src/modules/settings.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAGH,OAAO,EAAC,cAAc,EAAC,MAAM,YAAY,CAAA;AACzC,OAAO,KAAK,EAAC,aAAa,EAAC,MAAM,UAAU,CAAA;AAE3C,sDAAsD;AACtD,MAAM,WAAW,iBAAiB;IAChC,kFAAkF;IAClF,EAAE,EAAE,MAAM,CAAA;IACV,oDAAoD;IACpD,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,EAAE,MAAM,CAAA;IACZ,sCAAsC;IACtC,SAAS,EAAE,OAAO,CAAA;IAClB,kCAAkC;IAClC,OAAO,EAAE;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,OAAO,CAAA;KAAC,CAAA;IAC3C,+FAA+F;IAC/F,OAAO,EAAE,OAAO,CAAA;CACjB;AAED,MAAM,WAAW,cAAc;IAC7B,GAAG,EAAE,MAAM,CAAA;IACX,KAAK,EAAE,OAAO,CAAA;CACf;AAED,qBAAa,cAAc;IACb,OAAO,CAAC,QAAQ,CAAC,OAAO;gBAAP,OAAO,EAAE,cAAc;IAEpD,0EAA0E;IAC1E,IAAI,aAAa,IAAI,OAAO,CAE3B;IAED,sEAAsE;IAChE,GAAG,CAAC,CAAC,GAAG,OAAO,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC;IAK3D;;;;OAIG;IACG,MAAM,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAQ/D;;;;OAIG;IACG,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IAIrD;;;;OAIG;IACH,QAAQ,CAAC,OAAO,EAAE,CAAC,MAAM,EAAE,cAAc,KAAK,IAAI,GAAG,aAAa;CAGnE"}
|
package/dist/modules/settings.js
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @fileoverview SettingsModule — `session.settings`, the engine's settings
|
|
3
3
|
* store behind an allowlist. Needs the PLATFORM_SETTINGS manifest
|
|
4
|
-
* permission
|
|
4
|
+
* permission, except for the wearer's reading settings (`reading_wpm` and
|
|
5
|
+
* the other `reading_*` keys), which every miniapp may read and follow, and
|
|
6
|
+
* whose speed it may set. Without it, other keys reject with
|
|
7
|
+
* PERMISSION_NOT_DECLARED.
|
|
5
8
|
* A dashboard miniapp is the usual consumer: it reads and edits the
|
|
6
9
|
* notification and glasses-menu keys the phone's settings screens used to,
|
|
7
10
|
* so firmware sync and the host's notification policy keep one source of
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"settings.js","sourceRoot":"","sources":["../../src/modules/settings.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"settings.js","sourceRoot":"","sources":["../../src/modules/settings.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAAC,kBAAkB,EAAE,iBAAiB,EAAC,MAAM,aAAa,CAAA;AAwBjE,MAAM,OAAO,cAAc;IACzB,YAA6B,OAAuB;QAAvB,YAAO,GAAP,OAAO,CAAgB;IAAG,CAAC;IAExD,0EAA0E;IAC1E,IAAI,aAAa;QACf,OAAO,IAAI,CAAC,OAAO,CAAC,sBAAsB,CAAC,mBAAmB,CAAC,CAAA;IACjE,CAAC;IAED,sEAAsE;IACtE,KAAK,CAAC,GAAG,CAAc,GAAW;QAChC,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,CAAA;QACvC,OAAO,MAAM,CAAC,GAAG,CAAkB,CAAA;IACrC,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,MAAM,CAAC,IAAe;QAC1B,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,WAAW,CAAqC;YAChF,IAAI,EAAE,kBAAkB,CAAC,YAAY;YACrC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,EAAC,IAAI,EAAC,CAAC,CAAC,CAAC,EAAE,CAAC;SACxB,CAAC,CAAA;QACF,OAAO,MAAM,EAAE,MAAM,IAAI,EAAE,CAAA;IAC7B,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,GAAG,CAAC,GAAW,EAAE,KAAc;QACnC,MAAM,IAAI,CAAC,OAAO,CAAC,WAAW,CAAO,EAAC,IAAI,EAAE,kBAAkB,CAAC,YAAY,EAAE,GAAG,EAAE,KAAK,EAAC,CAAC,CAAA;IAC3F,CAAC;IAED;;;;OAIG;IACH,QAAQ,CAAC,OAAyC;QAChD,OAAO,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,iBAAiB,CAAC,gBAAgB,EAAE,OAAkC,CAAC,CAAA;IACxG,CAAC;CACF"}
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Reader: a miniapp hands it a title, sections of text and its end-screen
|
|
3
|
+
* actions, and the glasses read the text to the wearer line by line at their
|
|
4
|
+
* reading speed. Built only on session.display, session.input and
|
|
5
|
+
* session.settings, so it runs on any Glassly App; one that predates the
|
|
6
|
+
* reading settings reads at 220 wpm and keeps a glasses speed change for the
|
|
7
|
+
* rest of the session.
|
|
8
|
+
*
|
|
9
|
+
* Gestures (map A, as Teleprompter): tap pauses and resumes, and at an end
|
|
10
|
+
* screen runs its tap action; swipe down / up step a line while reading and
|
|
11
|
+
* change the speed by 20 wpm while paused (dial and scroll steps count as
|
|
12
|
+
* swipes); hold runs the app's hold action; double tap, or a Neural Band's
|
|
13
|
+
* swipe left, leaves the Reader.
|
|
14
|
+
*/
|
|
15
|
+
import type { RenderElement } from "../modules/display";
|
|
16
|
+
import { type ReaderSection } from "./document";
|
|
17
|
+
export interface ReaderOptions {
|
|
18
|
+
title: string;
|
|
19
|
+
details?: string;
|
|
20
|
+
sections: ReaderSection[];
|
|
21
|
+
hold?: {
|
|
22
|
+
action: string;
|
|
23
|
+
label: string;
|
|
24
|
+
};
|
|
25
|
+
leaveLabel?: string;
|
|
26
|
+
start?: {
|
|
27
|
+
part?: number;
|
|
28
|
+
percent?: number;
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
export type ReaderEvent = {
|
|
32
|
+
type: "action";
|
|
33
|
+
action: string;
|
|
34
|
+
} | {
|
|
35
|
+
type: "progress";
|
|
36
|
+
part: number;
|
|
37
|
+
section: number;
|
|
38
|
+
percent: number;
|
|
39
|
+
} | {
|
|
40
|
+
type: "closed";
|
|
41
|
+
reason: "double_tap" | "swipe_left" | "app";
|
|
42
|
+
};
|
|
43
|
+
export interface ReaderDeps {
|
|
44
|
+
later: (fn: () => void, ms: number) => () => void;
|
|
45
|
+
now: () => number;
|
|
46
|
+
}
|
|
47
|
+
export interface ReaderSession {
|
|
48
|
+
packageName: string;
|
|
49
|
+
capabilities: {
|
|
50
|
+
modelName?: unknown;
|
|
51
|
+
display?: object | null;
|
|
52
|
+
} | null;
|
|
53
|
+
display: {
|
|
54
|
+
render: (elements: RenderElement[]) => Promise<unknown>;
|
|
55
|
+
};
|
|
56
|
+
input: {
|
|
57
|
+
onTouch: (handler: (data: {
|
|
58
|
+
kind: string;
|
|
59
|
+
}) => void) => () => void;
|
|
60
|
+
setClaimedGestures: (gestures: string[], options?: {
|
|
61
|
+
scope?: string;
|
|
62
|
+
}) => Promise<void>;
|
|
63
|
+
};
|
|
64
|
+
settings: {
|
|
65
|
+
getAll: (keys?: string[]) => Promise<Record<string, unknown>>;
|
|
66
|
+
set: (key: string, value: unknown) => Promise<void>;
|
|
67
|
+
onChange: (handler: (change: {
|
|
68
|
+
key: string;
|
|
69
|
+
value: unknown;
|
|
70
|
+
}) => void) => () => void;
|
|
71
|
+
};
|
|
72
|
+
onCapabilitiesChange?: (handler: (capabilities: unknown) => void) => () => void;
|
|
73
|
+
onPause?: (handler: (reason: unknown) => void) => () => void;
|
|
74
|
+
paused?: boolean;
|
|
75
|
+
ready?: boolean;
|
|
76
|
+
on?: (event: "ready", handler: () => void) => () => void;
|
|
77
|
+
}
|
|
78
|
+
export declare const READER_WPM: {
|
|
79
|
+
readonly min: 100;
|
|
80
|
+
readonly max: 400;
|
|
81
|
+
readonly step: 20;
|
|
82
|
+
readonly default: 220;
|
|
83
|
+
};
|
|
84
|
+
export declare function openReader(session: ReaderSession, options: ReaderOptions, deps?: Partial<ReaderDeps>): Reader;
|
|
85
|
+
export declare class Reader {
|
|
86
|
+
private readonly session;
|
|
87
|
+
private readonly deps;
|
|
88
|
+
private options;
|
|
89
|
+
private prefs;
|
|
90
|
+
private bridged;
|
|
91
|
+
private readWpm;
|
|
92
|
+
private profile;
|
|
93
|
+
private measurer;
|
|
94
|
+
private wrapper;
|
|
95
|
+
private layout;
|
|
96
|
+
private doc;
|
|
97
|
+
private wrapWidth;
|
|
98
|
+
private docProfile;
|
|
99
|
+
private phase;
|
|
100
|
+
private line;
|
|
101
|
+
private part;
|
|
102
|
+
private toastText;
|
|
103
|
+
private readOnWhenReady;
|
|
104
|
+
private readMs;
|
|
105
|
+
private readingSince;
|
|
106
|
+
private lastFrame;
|
|
107
|
+
private isOpenNow;
|
|
108
|
+
private handlers;
|
|
109
|
+
private cancelClock;
|
|
110
|
+
private cancelToast;
|
|
111
|
+
private unsubs;
|
|
112
|
+
constructor(session: ReaderSession, options: ReaderOptions, deps: ReaderDeps);
|
|
113
|
+
get isOpen(): boolean;
|
|
114
|
+
get wpm(): number;
|
|
115
|
+
onEvent(handler: (event: ReaderEvent) => void): () => void;
|
|
116
|
+
open(): void;
|
|
117
|
+
close(): void;
|
|
118
|
+
/** Change the text or the hold action while open, keeping the place: e.g. comments arriving after the post. */
|
|
119
|
+
update(next: Partial<Omit<ReaderOptions, "start">>): void;
|
|
120
|
+
/** Show a brief message for 2 s, e.g. "★ Saved\nopens in Reddit on your phone". */
|
|
121
|
+
toast(text: string, ms?: number): void;
|
|
122
|
+
private emit;
|
|
123
|
+
private manual;
|
|
124
|
+
private speed;
|
|
125
|
+
private loadPreferences;
|
|
126
|
+
private apply;
|
|
127
|
+
private relayout;
|
|
128
|
+
private firstLine;
|
|
129
|
+
private autoStart;
|
|
130
|
+
private startReading;
|
|
131
|
+
private markReading;
|
|
132
|
+
private schedule;
|
|
133
|
+
private advance;
|
|
134
|
+
private step;
|
|
135
|
+
private enterStop;
|
|
136
|
+
/** Read on into the next part, from its first line. */
|
|
137
|
+
private continueReading;
|
|
138
|
+
private progress;
|
|
139
|
+
private pauseForAway;
|
|
140
|
+
private changeSpeed;
|
|
141
|
+
private gesture;
|
|
142
|
+
private finish;
|
|
143
|
+
private statusTitle;
|
|
144
|
+
private frame;
|
|
145
|
+
private render;
|
|
146
|
+
}
|
|
147
|
+
//# sourceMappingURL=Reader.d.ts.map
|