@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.
- package/README.md +219 -74
- package/dist/background/index.d.ts +14 -8
- package/dist/background/index.d.ts.map +1 -1
- package/dist/background/index.js +4 -0
- package/dist/background/index.js.map +1 -1
- package/dist/background/register.d.ts +1 -1
- package/dist/background/register.js +1 -1
- package/dist/display/index.d.ts +23 -0
- package/dist/display/index.d.ts.map +1 -0
- package/dist/display/index.js +17 -0
- package/dist/display/index.js.map +1 -0
- package/dist/display/measurer/TextMeasurer.d.ts +160 -0
- package/dist/display/measurer/TextMeasurer.d.ts.map +1 -0
- package/dist/display/measurer/TextMeasurer.js +272 -0
- package/dist/display/measurer/TextMeasurer.js.map +1 -0
- package/dist/display/measurer/index.d.ts +10 -0
- package/dist/display/measurer/index.d.ts.map +1 -0
- package/dist/display/measurer/index.js +11 -0
- package/dist/display/measurer/index.js.map +1 -0
- package/dist/display/measurer/script-detection.d.ts +53 -0
- package/dist/display/measurer/script-detection.d.ts.map +1 -0
- package/dist/display/measurer/script-detection.js +184 -0
- package/dist/display/measurer/script-detection.js.map +1 -0
- package/dist/display/pixelArt.d.ts +22 -0
- package/dist/display/pixelArt.d.ts.map +1 -0
- package/dist/display/pixelArt.js +126 -0
- package/dist/display/pixelArt.js.map +1 -0
- package/dist/display/profiles/g1.d.ts +33 -0
- package/dist/display/profiles/g1.d.ts.map +1 -0
- package/dist/display/profiles/g1.js +214 -0
- package/dist/display/profiles/g1.js.map +1 -0
- package/dist/display/profiles/g2.d.ts +13 -0
- package/dist/display/profiles/g2.d.ts.map +1 -0
- package/dist/display/profiles/g2.js +34 -0
- package/dist/display/profiles/g2.js.map +1 -0
- package/dist/display/profiles/index.d.ts +12 -0
- package/dist/display/profiles/index.d.ts.map +1 -0
- package/dist/display/profiles/index.js +15 -0
- package/dist/display/profiles/index.js.map +1 -0
- package/dist/display/profiles/nex.d.ts +10 -0
- package/dist/display/profiles/nex.d.ts.map +1 -0
- package/dist/display/profiles/nex.js +150 -0
- package/dist/display/profiles/nex.js.map +1 -0
- package/dist/display/profiles/types.d.ts +103 -0
- package/dist/display/profiles/types.d.ts.map +1 -0
- package/dist/display/profiles/types.js +2 -0
- package/dist/display/profiles/types.js.map +1 -0
- package/dist/display/profiles/z100.d.ts +33 -0
- package/dist/display/profiles/z100.d.ts.map +1 -0
- package/dist/display/profiles/z100.js +182 -0
- package/dist/display/profiles/z100.js.map +1 -0
- package/dist/display/scene/types.d.ts +292 -0
- package/dist/display/scene/types.d.ts.map +1 -0
- package/dist/display/scene/types.js +0 -0
- package/dist/display/scene/types.js.map +1 -0
- package/dist/display/wrapper/TextWrapper.d.ts +102 -0
- package/dist/display/wrapper/TextWrapper.d.ts.map +1 -0
- package/dist/display/wrapper/TextWrapper.js +469 -0
- package/dist/display/wrapper/TextWrapper.js.map +1 -0
- package/dist/display/wrapper/index.d.ts +12 -0
- package/dist/display/wrapper/index.d.ts.map +1 -0
- package/dist/display/wrapper/index.js +12 -0
- package/dist/display/wrapper/index.js.map +1 -0
- package/dist/display/wrapper/types.d.ts +75 -0
- package/dist/display/wrapper/types.d.ts.map +1 -0
- package/dist/display/wrapper/types.js +11 -0
- package/dist/display/wrapper/types.js.map +1 -0
- package/dist/globals.d.ts +5 -5
- package/dist/globals.d.ts.map +1 -1
- package/dist/globals.js +1 -1
- package/dist/globals.js.map +1 -1
- package/dist/hardware.d.ts +4 -18
- package/dist/hardware.d.ts.map +1 -1
- package/dist/hardware.js +2 -13
- package/dist/hardware.js.map +1 -1
- package/dist/index.d.ts +16 -10
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/knownApps.d.ts +26 -0
- package/dist/knownApps.d.ts.map +1 -0
- package/dist/knownApps.js +140 -0
- package/dist/knownApps.js.map +1 -0
- package/dist/mirror/canvas.d.ts +22 -0
- package/dist/mirror/canvas.d.ts.map +1 -0
- package/dist/mirror/canvas.js +311 -0
- package/dist/mirror/canvas.js.map +1 -0
- package/dist/mirror/geometry.d.ts +69 -0
- package/dist/mirror/geometry.d.ts.map +1 -0
- package/dist/mirror/geometry.js +75 -0
- package/dist/mirror/geometry.js.map +1 -0
- package/dist/mirror/index.d.ts +3 -0
- package/dist/mirror/index.d.ts.map +1 -0
- package/dist/mirror/index.js +2 -0
- package/dist/mirror/index.js.map +1 -0
- package/dist/mirror/types.d.ts +40 -0
- package/dist/mirror/types.d.ts.map +1 -0
- package/dist/mirror/types.js +2 -0
- package/dist/mirror/types.js.map +1 -0
- package/dist/modules/auth.d.ts +1 -1
- package/dist/modules/auth.d.ts.map +1 -1
- package/dist/modules/auth.js +2 -2
- package/dist/modules/auth.js.map +1 -1
- package/dist/modules/compass.d.ts +47 -0
- package/dist/modules/compass.d.ts.map +1 -0
- package/dist/modules/compass.js +39 -0
- package/dist/modules/compass.js.map +1 -0
- package/dist/modules/display.d.ts +192 -8
- package/dist/modules/display.d.ts.map +1 -1
- package/dist/modules/display.js +40 -3
- package/dist/modules/display.js.map +1 -1
- package/dist/modules/events.d.ts +30 -2
- package/dist/modules/events.d.ts.map +1 -1
- package/dist/modules/events.js.map +1 -1
- package/dist/modules/input.d.ts +40 -1
- package/dist/modules/input.d.ts.map +1 -1
- package/dist/modules/input.js +45 -1
- package/dist/modules/input.js.map +1 -1
- package/dist/modules/latest-render-scheduler.d.ts +19 -0
- package/dist/modules/latest-render-scheduler.d.ts.map +1 -0
- package/dist/modules/latest-render-scheduler.js +54 -0
- package/dist/modules/latest-render-scheduler.js.map +1 -0
- package/dist/modules/lightSensor.d.ts +44 -0
- package/dist/modules/lightSensor.d.ts.map +1 -0
- package/dist/modules/lightSensor.js +33 -0
- package/dist/modules/lightSensor.js.map +1 -0
- package/dist/modules/mic.d.ts +3 -2
- package/dist/modules/mic.d.ts.map +1 -1
- package/dist/modules/mic.js +3 -2
- package/dist/modules/mic.js.map +1 -1
- package/dist/modules/miniapps.d.ts +2 -0
- package/dist/modules/miniapps.d.ts.map +1 -1
- package/dist/modules/miniapps.js.map +1 -1
- package/dist/modules/mirror.d.ts +16 -0
- package/dist/modules/mirror.d.ts.map +1 -0
- package/dist/modules/mirror.js +40 -0
- package/dist/modules/mirror.js.map +1 -0
- package/dist/modules/mono-text-rows.d.ts +20 -0
- package/dist/modules/mono-text-rows.d.ts.map +1 -0
- package/dist/modules/mono-text-rows.js +26 -0
- package/dist/modules/mono-text-rows.js.map +1 -0
- package/dist/modules/navigation.d.ts.map +1 -1
- package/dist/modules/navigation.js +21 -14
- package/dist/modules/navigation.js.map +1 -1
- package/dist/modules/phone.d.ts +26 -1
- package/dist/modules/phone.d.ts.map +1 -1
- package/dist/modules/phone.js +28 -0
- package/dist/modules/phone.js.map +1 -1
- package/dist/modules/settings.d.ts +45 -0
- package/dist/modules/settings.d.ts.map +1 -0
- package/dist/modules/settings.js +54 -0
- package/dist/modules/settings.js.map +1 -0
- package/dist/modules/system.d.ts +21 -0
- package/dist/modules/system.d.ts.map +1 -1
- package/dist/modules/system.js +12 -0
- package/dist/modules/system.js.map +1 -1
- package/dist/modules/transcription.d.ts +3 -2
- package/dist/modules/transcription.d.ts.map +1 -1
- package/dist/modules/transcription.js +3 -2
- package/dist/modules/transcription.js.map +1 -1
- package/dist/protocol.d.ts +65 -5
- package/dist/protocol.d.ts.map +1 -1
- package/dist/protocol.js +66 -5
- package/dist/protocol.js.map +1 -1
- package/dist/react/MirrorCanvas.d.ts +10 -0
- package/dist/react/MirrorCanvas.d.ts.map +1 -0
- package/dist/react/MirrorCanvas.js +23 -0
- package/dist/react/MirrorCanvas.js.map +1 -0
- package/dist/react/index.d.ts +2 -0
- package/dist/react/index.d.ts.map +1 -1
- package/dist/react/index.js +1 -0
- package/dist/react/index.js.map +1 -1
- package/dist/react/useColorScheme.d.ts +2 -3
- package/dist/react/useColorScheme.d.ts.map +1 -1
- package/dist/react/useColorScheme.js +15 -8
- package/dist/react/useColorScheme.js.map +1 -1
- package/dist/react/useRpc.js +2 -2
- package/dist/react/useRpc.js.map +1 -1
- package/dist/react/useSafeArea.d.ts.map +1 -1
- package/dist/react/useSafeArea.js +2 -2
- package/dist/react/useSafeArea.js.map +1 -1
- package/dist/session.d.ts +50 -4
- package/dist/session.d.ts.map +1 -1
- package/dist/session.js +35 -6
- package/dist/session.js.map +1 -1
- package/dist/transport/auto.d.ts +2 -2
- package/dist/transport/auto.js +2 -2
- package/dist/transport/dispatch.d.ts +1 -1
- package/dist/transport/dispatch.js +1 -1
- package/dist/transport/mock.d.ts +4 -4
- package/dist/transport/mock.d.ts.map +1 -1
- package/dist/transport/mock.js +31 -7
- package/dist/transport/mock.js.map +1 -1
- package/dist/ui/index.d.ts +2 -0
- package/dist/ui/index.d.ts.map +1 -1
- package/dist/ui/index.js +1 -0
- package/dist/ui/index.js.map +1 -1
- package/package.json +19 -3
- package/src/background/index.ts +26 -4
- package/src/background/register.ts +1 -1
- package/src/display/index.ts +83 -0
- package/src/display/measurer/TextMeasurer.ts +346 -0
- package/src/display/measurer/index.ts +21 -0
- package/src/display/measurer/script-detection.ts +218 -0
- package/src/display/pixelArt.ts +141 -0
- package/src/display/profiles/g1.ts +237 -0
- package/src/display/profiles/g2.ts +39 -0
- package/src/display/profiles/index.ts +28 -0
- package/src/display/profiles/nex.ts +166 -0
- package/src/display/profiles/types.ts +132 -0
- package/src/display/profiles/z100.ts +198 -0
- package/src/display/scene/types.ts +335 -0
- package/src/display/wrapper/TextWrapper.ts +546 -0
- package/src/display/wrapper/index.ts +15 -0
- package/src/display/wrapper/types.ts +102 -0
- package/src/globals.ts +5 -5
- package/src/hardware.ts +6 -21
- package/src/index.ts +34 -6
- package/src/knownApps.ts +170 -0
- package/src/mirror/canvas.ts +322 -0
- package/src/mirror/geometry.ts +128 -0
- package/src/mirror/index.ts +2 -0
- package/src/mirror/types.ts +38 -0
- package/src/modules/auth.ts +2 -2
- package/src/modules/compass.ts +69 -0
- package/src/modules/display.ts +222 -12
- package/src/modules/events.ts +27 -1
- package/src/modules/input.ts +55 -2
- package/src/modules/latest-render-scheduler.ts +55 -0
- package/src/modules/lightSensor.ts +61 -0
- package/src/modules/mic.ts +3 -2
- package/src/modules/miniapps.ts +2 -0
- package/src/modules/mirror.ts +42 -0
- package/src/modules/mono-text-rows.ts +30 -0
- package/src/modules/navigation.ts +20 -14
- package/src/modules/phone.ts +40 -1
- package/src/modules/settings.ts +64 -0
- package/src/modules/system.ts +30 -1
- package/src/modules/transcription.ts +3 -2
- package/src/protocol.ts +72 -5
- package/src/react/MirrorCanvas.tsx +35 -0
- package/src/react/index.ts +3 -0
- package/src/react/useColorScheme.ts +17 -8
- package/src/react/useRpc.ts +2 -2
- package/src/react/useSafeArea.ts +2 -2
- package/src/session.ts +78 -8
- package/src/transport/auto.ts +2 -2
- package/src/transport/dispatch.ts +1 -1
- package/src/transport/mock.ts +42 -11
- package/src/ui/index.ts +3 -0
- package/dist/modules/heading.d.ts +0 -16
- package/dist/modules/heading.d.ts.map +0 -1
- package/dist/modules/heading.js +0 -20
- package/dist/modules/heading.js.map +0 -1
- package/src/modules/heading.ts +0 -23
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { MiniappSession } from "../session";
|
|
2
|
+
import type { UnsubscribeFn } from "./events";
|
|
3
|
+
export interface CompassOptions {
|
|
4
|
+
/** 50..2000 ms, default 1000. */
|
|
5
|
+
intervalMs?: number;
|
|
6
|
+
/** Heading change threshold, 0..359 degrees, default 5. */
|
|
7
|
+
minChangeDegrees?: number;
|
|
8
|
+
}
|
|
9
|
+
export interface CompassDiagnostics {
|
|
10
|
+
accuracy: 0 | 1 | 2 | 3 | null;
|
|
11
|
+
anomalies: 0 | 1 | 2 | null;
|
|
12
|
+
source: "unknown" | "grv" | "gmrv" | "rv";
|
|
13
|
+
sampleMatched: boolean;
|
|
14
|
+
grvValid: boolean;
|
|
15
|
+
gmrvValid: boolean;
|
|
16
|
+
rvValid: boolean;
|
|
17
|
+
magneticDataFresh: boolean;
|
|
18
|
+
/** Firmware uptime, wraps at 2^32 ms. */
|
|
19
|
+
sampleTimestampMs: number;
|
|
20
|
+
}
|
|
21
|
+
export interface CompassData {
|
|
22
|
+
/** Magnetic heading in degrees, 0 = north, 90 = east. Fused heading, not raw magnetometer XYZ. */
|
|
23
|
+
degrees: number;
|
|
24
|
+
/** Phone reception time, Unix milliseconds. */
|
|
25
|
+
timestamp: number;
|
|
26
|
+
/** Fusion quality; custom firmware only. */
|
|
27
|
+
diagnostics?: CompassDiagnostics;
|
|
28
|
+
}
|
|
29
|
+
export interface CompassCalibrationData {
|
|
30
|
+
status: "start" | "complete";
|
|
31
|
+
}
|
|
32
|
+
export declare class CompassModule {
|
|
33
|
+
private readonly session;
|
|
34
|
+
constructor(session: MiniappSession);
|
|
35
|
+
onUpdate(handler: (data: CompassData) => void): UnsubscribeFn;
|
|
36
|
+
onCalibration(handler: (data: CompassCalibrationData) => void): UnsubscribeFn;
|
|
37
|
+
/**
|
|
38
|
+
* Override the sampling this miniapp asks for. Subscribers already run with
|
|
39
|
+
* firmware defaults; the phone serves every subscriber the smallest interval
|
|
40
|
+
* and smallest change threshold requested across miniapps. Custom firmware only.
|
|
41
|
+
*/
|
|
42
|
+
start(options?: CompassOptions): Promise<void>;
|
|
43
|
+
/** Drop this miniapp's sampling override. Live subscriptions keep the sensor running. */
|
|
44
|
+
stop(): Promise<void>;
|
|
45
|
+
private control;
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=compass.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compass.d.ts","sourceRoot":"","sources":["../../src/modules/compass.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,YAAY,CAAA;AAC9C,OAAO,KAAK,EAAC,aAAa,EAAC,MAAM,UAAU,CAAA;AAE3C,MAAM,WAAW,cAAc;IAC7B,iCAAiC;IACjC,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,2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Subscribing starts the sensor like other glasses streams:
|
|
3
|
+
* on G2 custom firmware the raw compass API runs whenever any miniapp is
|
|
4
|
+
* subscribed; on stock firmware headings only arrive while the glasses' native
|
|
5
|
+
* navigation UI is open. Elsewhere the subscription succeeds and stays silent.
|
|
6
|
+
*/
|
|
7
|
+
import { MiniappRequestType, MiniappStreamType } from "../protocol";
|
|
8
|
+
export class CompassModule {
|
|
9
|
+
constructor(session) {
|
|
10
|
+
this.session = session;
|
|
11
|
+
}
|
|
12
|
+
onUpdate(handler) {
|
|
13
|
+
return this.session._subscribe(MiniappStreamType.GLASSES_COMPASS, handler);
|
|
14
|
+
}
|
|
15
|
+
onCalibration(handler) {
|
|
16
|
+
return this.session._subscribe(MiniappStreamType.COMPASS_CALIBRATION, handler);
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Override the sampling this miniapp asks for. Subscribers already run with
|
|
20
|
+
* firmware defaults; the phone serves every subscriber the smallest interval
|
|
21
|
+
* and smallest change threshold requested across miniapps. Custom firmware only.
|
|
22
|
+
*/
|
|
23
|
+
start(options = {}) {
|
|
24
|
+
return this.control("start", options);
|
|
25
|
+
}
|
|
26
|
+
/** Drop this miniapp's sampling override. Live subscriptions keep the sensor running. */
|
|
27
|
+
stop() {
|
|
28
|
+
return this.control("stop");
|
|
29
|
+
}
|
|
30
|
+
control(operation, options = {}) {
|
|
31
|
+
return this.session.sendRequest({
|
|
32
|
+
type: MiniappRequestType.GLASSES_SENSOR_CONTROL,
|
|
33
|
+
sensor: "compass",
|
|
34
|
+
operation,
|
|
35
|
+
options,
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=compass.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compass.js","sourceRoot":"","sources":["../../src/modules/compass.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAC,kBAAkB,EAAE,iBAAiB,EAAC,MAAM,aAAa,CAAA;AAkCjE,MAAM,OAAO,aAAa;IACxB,YAA6B,OAAuB;QAAvB,YAAO,GAAP,OAAO,CAAgB;IAAG,CAAC;IACxD,QAAQ,CAAC,OAAoC;QAC3C,OAAO,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,iBAAiB,CAAC,eAAe,EAAE,OAAkC,CAAC,CAAA;IACvG,CAAC;IACD,aAAa,CAAC,OAA+C;QAC3D,OAAO,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,iBAAiB,CAAC,mBAAmB,EAAE,OAAkC,CAAC,CAAA;IAC3G,CAAC;IACD;;;;OAIG;IACH,KAAK,CAAC,UAA0B,EAAE;QAChC,OAAO,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;IACvC,CAAC;IACD,yFAAyF;IACzF,IAAI;QACF,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAA;IAC7B,CAAC;IACO,OAAO,CAAC,SAAiB,EAAE,UAA0B,EAAE;QAC7D,OAAO,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC;YAC9B,IAAI,EAAE,kBAAkB,CAAC,sBAAsB;YAC/C,MAAM,EAAE,SAAS;YACjB,SAAS;YACT,OAAO;SACR,CAAC,CAAA;IACJ,CAAC;CACF"}
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
* from bundles packed with older SDKs.
|
|
10
10
|
*/
|
|
11
11
|
import { MiniappSession } from "../session";
|
|
12
|
+
import type { UnsubscribeFn } from "./events";
|
|
12
13
|
export type ViewType = "main" | "dashboard";
|
|
13
14
|
export type DisplayBreakMode = "character" | "character-no-hyphen" | "word" | "strict-word";
|
|
14
15
|
/** Canvas corner a box's `x`/`y` are measured from (insets grow inward). */
|
|
@@ -46,42 +47,192 @@ export interface RenderTextStyle {
|
|
|
46
47
|
* of 1.2 × size, and NOT re-wrapped by the host — lines are taken as given.
|
|
47
48
|
* For grids (terminals, tables). Devices without a phone-side rasterizer
|
|
48
49
|
* (stock G2 firmware) fall back to their own proportional font.
|
|
50
|
+
*
|
|
51
|
+
* "builtin": the glasses draw the text themselves with their built-in 20 px
|
|
52
|
+
* proportional font. On the Glassly CFW G2 the default face is drawn the
|
|
53
|
+
* same way, so text updates are a few bytes each and animate like shapes;
|
|
54
|
+
* lines are clipped to the box and the render window is pinned to the
|
|
55
|
+
* middle depth level. Other devices and stock firmware use the phone's
|
|
56
|
+
* proportional face.
|
|
49
57
|
*/
|
|
50
|
-
font?: "default" | "mono";
|
|
58
|
+
font?: "default" | "mono" | "builtin";
|
|
51
59
|
/** Font size in px for `font: "mono"`. Default 20. */
|
|
52
60
|
fontSize?: number;
|
|
61
|
+
/** Gray level 0..15 (15 = brightest) on devices that draw text themselves. Default 15. */
|
|
62
|
+
color?: number;
|
|
53
63
|
}
|
|
54
64
|
export interface RenderRectStyle {
|
|
55
65
|
border?: number;
|
|
56
66
|
radius?: number;
|
|
67
|
+
/** Solid fill instead of an outline. */
|
|
68
|
+
fill?: boolean;
|
|
69
|
+
/** Gray level 0..15 (15 = brightest). Default 15. */
|
|
70
|
+
color?: number;
|
|
71
|
+
}
|
|
72
|
+
/** Closed shapes (circle, triangle, quad): an outline `border` px wide, or filled. */
|
|
73
|
+
export interface RenderShapeStyle {
|
|
74
|
+
border?: number;
|
|
75
|
+
fill?: boolean;
|
|
76
|
+
/** Gray level 0..15 (15 = brightest). Default 15. */
|
|
77
|
+
color?: number;
|
|
78
|
+
}
|
|
79
|
+
/** Open strokes (line, bezier, arc). */
|
|
80
|
+
export interface RenderStrokeStyle {
|
|
81
|
+
/** Stroke width in px. Default 1. */
|
|
82
|
+
width?: number;
|
|
83
|
+
/** Gray level 0..15 (15 = brightest). Default 15. */
|
|
84
|
+
color?: number;
|
|
85
|
+
}
|
|
86
|
+
/** A point in raw canvas pixels (no anchoring). */
|
|
87
|
+
export interface RenderPoint {
|
|
88
|
+
x: number;
|
|
89
|
+
y: number;
|
|
90
|
+
}
|
|
91
|
+
export type RenderEasing = "linear" | "ease" | "ease-in" | "ease-out" | "ease-in-out";
|
|
92
|
+
/**
|
|
93
|
+
* Animate an element's geometry between renders. When an element with a
|
|
94
|
+
* stable `id` moves, resizes, or changes its points/angles/color, devices
|
|
95
|
+
* with `capabilities.display.animation` tween it on the glasses over
|
|
96
|
+
* `durationMs`; other devices jump. Content changes (new text or image
|
|
97
|
+
* pixels) always switch immediately.
|
|
98
|
+
*/
|
|
99
|
+
export interface RenderTransition {
|
|
100
|
+
durationMs: number;
|
|
101
|
+
/** Default "ease". */
|
|
102
|
+
easing?: RenderEasing;
|
|
57
103
|
}
|
|
58
104
|
/**
|
|
59
105
|
* One element of a rendered scene. `id` is optional but recommended for
|
|
60
106
|
* anything that updates over time: elements with a stable id update in place on
|
|
61
107
|
* the glasses (no flicker); the host matches unnamed elements by geometry.
|
|
108
|
+
*
|
|
109
|
+
* Shapes beyond `rect` need `capabilities.display.shapes` to list the type;
|
|
110
|
+
* a device without it drops the element (reported via `dropped`). Circles,
|
|
111
|
+
* arcs and pies are inscribed in their box (radius = half the shorter side;
|
|
112
|
+
* angles in degrees, 0 = right, increasing clockwise). Point shapes take
|
|
113
|
+
* raw canvas coordinates and are clipped by the device; `bezier` is
|
|
114
|
+
* quadratic with 3 points or cubic with 4.
|
|
62
115
|
*/
|
|
63
|
-
export type RenderElement = {
|
|
116
|
+
export type RenderElement = ({
|
|
64
117
|
type: "text";
|
|
65
118
|
id?: string;
|
|
66
119
|
box: RenderBox;
|
|
67
120
|
text: string;
|
|
68
121
|
style?: RenderTextStyle;
|
|
122
|
+
transition?: RenderTransition;
|
|
69
123
|
} | {
|
|
70
124
|
type: "image";
|
|
71
125
|
id?: string;
|
|
72
126
|
box: RenderBox;
|
|
73
127
|
data: string;
|
|
128
|
+
transition?: RenderTransition;
|
|
74
129
|
} | {
|
|
75
130
|
type: "rect";
|
|
76
131
|
id?: string;
|
|
77
132
|
box: RenderBox;
|
|
78
133
|
style?: RenderRectStyle;
|
|
134
|
+
transition?: RenderTransition;
|
|
135
|
+
} | {
|
|
136
|
+
type: "circle";
|
|
137
|
+
id?: string;
|
|
138
|
+
box: RenderBox;
|
|
139
|
+
style?: RenderShapeStyle;
|
|
140
|
+
transition?: RenderTransition;
|
|
141
|
+
} | {
|
|
142
|
+
type: "arc";
|
|
143
|
+
id?: string;
|
|
144
|
+
box: RenderBox;
|
|
145
|
+
startDeg: number;
|
|
146
|
+
endDeg: number;
|
|
147
|
+
style?: RenderStrokeStyle;
|
|
148
|
+
transition?: RenderTransition;
|
|
149
|
+
} | {
|
|
150
|
+
type: "pie";
|
|
151
|
+
id?: string;
|
|
152
|
+
box: RenderBox;
|
|
153
|
+
startDeg: number;
|
|
154
|
+
endDeg: number;
|
|
155
|
+
style?: {
|
|
156
|
+
color?: number;
|
|
157
|
+
};
|
|
158
|
+
transition?: RenderTransition;
|
|
159
|
+
} | {
|
|
160
|
+
type: "line";
|
|
161
|
+
id?: string;
|
|
162
|
+
points: [RenderPoint, RenderPoint];
|
|
163
|
+
style?: RenderStrokeStyle;
|
|
164
|
+
transition?: RenderTransition;
|
|
165
|
+
} | {
|
|
166
|
+
type: "triangle";
|
|
167
|
+
id?: string;
|
|
168
|
+
points: [RenderPoint, RenderPoint, RenderPoint];
|
|
169
|
+
style?: RenderShapeStyle;
|
|
170
|
+
transition?: RenderTransition;
|
|
171
|
+
} | {
|
|
172
|
+
type: "quad";
|
|
173
|
+
id?: string;
|
|
174
|
+
points: [RenderPoint, RenderPoint, RenderPoint, RenderPoint];
|
|
175
|
+
style?: RenderShapeStyle;
|
|
176
|
+
transition?: RenderTransition;
|
|
177
|
+
} | {
|
|
178
|
+
type: "bezier";
|
|
179
|
+
id?: string;
|
|
180
|
+
points: [RenderPoint, RenderPoint, RenderPoint] | [RenderPoint, RenderPoint, RenderPoint, RenderPoint];
|
|
181
|
+
style?: RenderStrokeStyle;
|
|
182
|
+
transition?: RenderTransition;
|
|
183
|
+
} | {
|
|
184
|
+
type: "svg";
|
|
185
|
+
id?: string;
|
|
186
|
+
box: RenderBox;
|
|
187
|
+
d: string;
|
|
188
|
+
scale?: number;
|
|
189
|
+
fillRule?: "nonzero" | "evenodd";
|
|
190
|
+
style?: {
|
|
191
|
+
color?: number;
|
|
192
|
+
};
|
|
193
|
+
transition?: RenderTransition;
|
|
194
|
+
}) & {
|
|
195
|
+
/** Clockwise degrees, unwrapped (0 to 360 makes a full turn). Geometric shapes and SVG only. */
|
|
196
|
+
rotation?: number;
|
|
197
|
+
/** Fixed pivot in canvas pixels; defaults to the target box center. */
|
|
198
|
+
pivot?: RenderPoint;
|
|
199
|
+
/**
|
|
200
|
+
* Stereo depth in canvas pixels, -16..16: positive floats the element in
|
|
201
|
+
* front of the rest of the frame, negative sinks it behind. Devices with
|
|
202
|
+
* `capabilities.display.depth` shift it by `depth` px on the left lens and
|
|
203
|
+
* `-depth` px on the right; others draw it flat. Elements paint in array
|
|
204
|
+
* order, so a card that should sit on top goes last AND at a positive depth.
|
|
205
|
+
* A depth change with a `transition` glides toward or away from the viewer.
|
|
206
|
+
*/
|
|
207
|
+
depth?: number;
|
|
79
208
|
};
|
|
80
209
|
export interface RenderOptions {
|
|
81
210
|
view?: ViewType;
|
|
82
211
|
/** Auto-clear after this many ms (same semantics as legacy display options). */
|
|
83
212
|
durationMs?: number;
|
|
84
213
|
}
|
|
214
|
+
/**
|
|
215
|
+
* "shown" = the requested view is showing (already showing counts).
|
|
216
|
+
* "unsupported" = the host refused: the glasses cannot show the dashboard
|
|
217
|
+
* view right now, or this app is not the designated dashboard app.
|
|
218
|
+
*/
|
|
219
|
+
export interface ShowViewResult {
|
|
220
|
+
status: "shown" | "unsupported";
|
|
221
|
+
reason?: string;
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* Why the showing view changed. "shown" and "hidden" answer this app's own
|
|
225
|
+
* showView calls; "replaced" means another overlay app took the view;
|
|
226
|
+
* "ineligible" means the glasses stopped being able to show the dashboard
|
|
227
|
+
* view (disconnected, dashboard turned off); "app_stopped" is implied when
|
|
228
|
+
* the app itself stops and never arrives as an event.
|
|
229
|
+
*/
|
|
230
|
+
export type DisplayViewChangeReason = "shown" | "hidden" | "replaced" | "ineligible" | "app_stopped";
|
|
231
|
+
export interface DisplayViewChange {
|
|
232
|
+
/** The view now showing. */
|
|
233
|
+
view: ViewType;
|
|
234
|
+
reason: DisplayViewChangeReason;
|
|
235
|
+
}
|
|
85
236
|
/** Turn-by-turn card fields — pre-formatted display strings, rendered verbatim by the device. */
|
|
86
237
|
export interface NativeNavInfo {
|
|
87
238
|
/** Firmware direction-icon index, 0…35. */
|
|
@@ -107,10 +258,12 @@ export interface NativeNavResult {
|
|
|
107
258
|
reason?: string;
|
|
108
259
|
}
|
|
109
260
|
/**
|
|
110
|
-
* Outcome of a render request
|
|
111
|
-
*
|
|
112
|
-
*
|
|
113
|
-
*
|
|
261
|
+
* Outcome of a render request. "displayed" = the host accepted the frame;
|
|
262
|
+
* on scene devices it resolves once the glasses have the frame and its
|
|
263
|
+
* transitions have finished playing (`presented`), or once the host knows
|
|
264
|
+
* the frame won't show right now (`presented: false`, `reason` says why —
|
|
265
|
+
* dashboard covering the view, screen off, nav UI up, glasses busy).
|
|
266
|
+
* "blocked" = another app owns the display (or the request failed).
|
|
114
267
|
*/
|
|
115
268
|
export interface RenderResult {
|
|
116
269
|
status: "displayed" | "blocked";
|
|
@@ -118,6 +271,13 @@ export interface RenderResult {
|
|
|
118
271
|
degraded?: boolean;
|
|
119
272
|
/** Ids of elements the host dropped (budget/bounds/device limits) — dropped is never silent. */
|
|
120
273
|
dropped?: string[];
|
|
274
|
+
/**
|
|
275
|
+
* The glasses showed this frame's content before the promise resolved.
|
|
276
|
+
* Absent on legacy/degrade paths, where "displayed" still just means sent.
|
|
277
|
+
*/
|
|
278
|
+
presented?: boolean;
|
|
279
|
+
/** A newer render() from this app landed before this one was reported; its content is on screen. */
|
|
280
|
+
superseded?: boolean;
|
|
121
281
|
reason?: string;
|
|
122
282
|
}
|
|
123
283
|
export declare class DisplayManager {
|
|
@@ -137,18 +297,42 @@ export declare class DisplayManager {
|
|
|
137
297
|
* over-budget elements are dropped tail-first; both are reported via the
|
|
138
298
|
* result, never silently.
|
|
139
299
|
*
|
|
140
|
-
* Awaiting is OPT-IN — a plain fire-and-forget call is fine.
|
|
141
|
-
* promise
|
|
300
|
+
* Awaiting is OPT-IN — a plain fire-and-forget call is fine. Awaited, the
|
|
301
|
+
* promise resolves once the glasses have the frame and any transitions it
|
|
302
|
+
* started have finished (see `RenderResult.presented`), so `await` in a
|
|
303
|
+
* loop paces you at the real display rate. Frames that arrive faster than
|
|
304
|
+
* the host sends them are folded into the next one; each still resolves
|
|
305
|
+
* when its content is on screen. The returned promise never rejects.
|
|
142
306
|
*
|
|
143
307
|
* @example
|
|
144
308
|
* const result = await session.display.render([
|
|
145
309
|
* {type: "text", id: "stats", box: {x: 12, y: 9, w: 200, h: 28}, text: "863 m 11 min"},
|
|
146
310
|
* {type: "image", id: "map", box: {x: 335, y: 14, w: 150, h: 150}, data: mapPng},
|
|
147
311
|
* {type: "rect", box: {x: 0, y: 0, w: 500, h: 220}, style: {radius: 4}},
|
|
312
|
+
* // Re-render with a new box and the ball glides there over 300 ms on animating devices.
|
|
313
|
+
* {type: "circle", id: "ball", box: {x: 40, y: 100, w: 30, h: 30}, style: {fill: true},
|
|
314
|
+
* transition: {durationMs: 300, easing: "ease-in-out"}},
|
|
148
315
|
* ])
|
|
149
316
|
* if (result.degraded) console.warn("dropped:", result.dropped)
|
|
150
317
|
*/
|
|
151
318
|
render(elements: RenderElement[], options?: RenderOptions): Promise<RenderResult>;
|
|
319
|
+
/**
|
|
320
|
+
* Ask the host to show a view. `"dashboard"` takes the overlay slot above
|
|
321
|
+
* the main content: frames rendered with `{view: "dashboard"}` reach the
|
|
322
|
+
* glasses while it shows. Claim the gestures you handle there with
|
|
323
|
+
* `session.input.setClaimedGestures`. `"main"` releases the slot; the
|
|
324
|
+
* retained main content replays. Both are idempotent. Only running apps
|
|
325
|
+
* whose manifest `type` is `"system_dashboard"` may show the dashboard
|
|
326
|
+
* view, and only while `capabilities.display.views` lists it; the most
|
|
327
|
+
* recent of them to ask holds it and the previous one hears "replaced".
|
|
328
|
+
*/
|
|
329
|
+
showView(view: ViewType): Promise<ShowViewResult>;
|
|
330
|
+
/**
|
|
331
|
+
* The showing view changed: the host granted the dashboard view, this app
|
|
332
|
+
* released it, another overlay app took it, or the glasses stopped being
|
|
333
|
+
* able to show it. Fires only for system_dashboard apps.
|
|
334
|
+
*/
|
|
335
|
+
onViewChange(handler: (change: DisplayViewChange) => void): UnsubscribeFn;
|
|
152
336
|
/** Update the native nav UI's turn-by-turn card. */
|
|
153
337
|
sendNativeNavInfo(info: NativeNavInfo): Promise<NativeNavResult>;
|
|
154
338
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"display.d.ts","sourceRoot":"","sources":["../../src/modules/display.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,EAAC,cAAc,EAAC,MAAM,YAAY,CAAA;
|
|
1
|
+
{"version":3,"file":"display.d.ts","sourceRoot":"","sources":["../../src/modules/display.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,EAAC,cAAc,EAAC,MAAM,YAAY,CAAA;AACzC,OAAO,KAAK,EAAC,aAAa,EAAC,MAAM,UAAU,CAAA;AAE3C,MAAM,MAAM,QAAQ,GAAG,MAAM,GAAG,WAAW,CAAA;AAE3C,MAAM,MAAM,gBAAgB,GAAG,WAAW,GAAG,qBAAqB,GAAG,MAAM,GAAG,aAAa,CAAA;AAM3F,4EAA4E;AAC5E,MAAM,MAAM,YAAY,GAAG,UAAU,GAAG,WAAW,GAAG,aAAa,GAAG,cAAc,CAAA;AAEpF;;;;;;;;;;GAUG;AACH,MAAM,WAAW,SAAS;IACxB,CAAC,EAAE,MAAM,CAAA;IACT,CAAC,EAAE,MAAM,CAAA;IACT,CAAC,EAAE,MAAM,CAAA;IACT,CAAC,EAAE,MAAM,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,aAAa;CAWtB"}
|
package/dist/modules/display.js
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* called them; hosts still accept the historical `miniapp_display` wire shape
|
|
9
9
|
* from bundles packed with older SDKs.
|
|
10
10
|
*/
|
|
11
|
-
import { MiniappRequestType } from "../protocol";
|
|
11
|
+
import { MiniappRequestType, MiniappStreamType } from "../protocol";
|
|
12
12
|
export class DisplayManager {
|
|
13
13
|
constructor(session) {
|
|
14
14
|
this.session = session;
|
|
@@ -27,14 +27,21 @@ export class DisplayManager {
|
|
|
27
27
|
* over-budget elements are dropped tail-first; both are reported via the
|
|
28
28
|
* result, never silently.
|
|
29
29
|
*
|
|
30
|
-
* Awaiting is OPT-IN — a plain fire-and-forget call is fine.
|
|
31
|
-
* promise
|
|
30
|
+
* Awaiting is OPT-IN — a plain fire-and-forget call is fine. Awaited, the
|
|
31
|
+
* promise resolves once the glasses have the frame and any transitions it
|
|
32
|
+
* started have finished (see `RenderResult.presented`), so `await` in a
|
|
33
|
+
* loop paces you at the real display rate. Frames that arrive faster than
|
|
34
|
+
* the host sends them are folded into the next one; each still resolves
|
|
35
|
+
* when its content is on screen. The returned promise never rejects.
|
|
32
36
|
*
|
|
33
37
|
* @example
|
|
34
38
|
* const result = await session.display.render([
|
|
35
39
|
* {type: "text", id: "stats", box: {x: 12, y: 9, w: 200, h: 28}, text: "863 m 11 min"},
|
|
36
40
|
* {type: "image", id: "map", box: {x: 335, y: 14, w: 150, h: 150}, data: mapPng},
|
|
37
41
|
* {type: "rect", box: {x: 0, y: 0, w: 500, h: 220}, style: {radius: 4}},
|
|
42
|
+
* // Re-render with a new box and the ball glides there over 300 ms on animating devices.
|
|
43
|
+
* {type: "circle", id: "ball", box: {x: 40, y: 100, w: 30, h: 30}, style: {fill: true},
|
|
44
|
+
* transition: {durationMs: 300, easing: "ease-in-out"}},
|
|
38
45
|
* ])
|
|
39
46
|
* if (result.degraded) console.warn("dropped:", result.dropped)
|
|
40
47
|
*/
|
|
@@ -53,6 +60,36 @@ export class DisplayManager {
|
|
|
53
60
|
: String(err),
|
|
54
61
|
}));
|
|
55
62
|
}
|
|
63
|
+
/**
|
|
64
|
+
* Ask the host to show a view. `"dashboard"` takes the overlay slot above
|
|
65
|
+
* the main content: frames rendered with `{view: "dashboard"}` reach the
|
|
66
|
+
* glasses while it shows. Claim the gestures you handle there with
|
|
67
|
+
* `session.input.setClaimedGestures`. `"main"` releases the slot; the
|
|
68
|
+
* retained main content replays. Both are idempotent. Only running apps
|
|
69
|
+
* whose manifest `type` is `"system_dashboard"` may show the dashboard
|
|
70
|
+
* view, and only while `capabilities.display.views` lists it; the most
|
|
71
|
+
* recent of them to ask holds it and the previous one hears "replaced".
|
|
72
|
+
*/
|
|
73
|
+
showView(view) {
|
|
74
|
+
return this.session.sendRequest({ type: MiniappRequestType.SHOW_VIEW, view }).catch((err) => ({
|
|
75
|
+
status: "unsupported",
|
|
76
|
+
reason: typeof err === "object" && err !== null && "message" in err
|
|
77
|
+
? String(err.message)
|
|
78
|
+
: String(err),
|
|
79
|
+
}));
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* The showing view changed: the host granted the dashboard view, this app
|
|
83
|
+
* released it, another overlay app took it, or the glasses stopped being
|
|
84
|
+
* able to show it. Fires only for system_dashboard apps.
|
|
85
|
+
*/
|
|
86
|
+
onViewChange(handler) {
|
|
87
|
+
return this.session._subscribe(MiniappStreamType.DISPLAY_VIEW, (data) => {
|
|
88
|
+
const event = data;
|
|
89
|
+
if (event?.kind === "change")
|
|
90
|
+
handler({ view: event.view, reason: event.reason });
|
|
91
|
+
});
|
|
92
|
+
}
|
|
56
93
|
/** Update the native nav UI's turn-by-turn card. */
|
|
57
94
|
sendNativeNavInfo(info) {
|
|
58
95
|
return this.sendNativeNav({ action: "info", info });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"display.js","sourceRoot":"","sources":["../../src/modules/display.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;A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;YAC9B,MAAM,EACJ,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,KAAK,IAAI,IAAI,SAAS,IAAI,GAAG;gBACzD,CAAC,CAAC,MAAM,CAAE,GAA0B,CAAC,OAAO,CAAC;gBAC7C,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC;SAClB,CAAC,CAAC,CAAA;IACP,CAAC;CACF"}
|
package/dist/modules/events.d.ts
CHANGED
|
@@ -88,7 +88,7 @@ export interface LocationData {
|
|
|
88
88
|
correlationId?: string;
|
|
89
89
|
}
|
|
90
90
|
export interface HeadingData {
|
|
91
|
-
/**
|
|
91
|
+
/** Phone compass heading in degrees, 0 = north, 90 = east. */
|
|
92
92
|
degrees: number;
|
|
93
93
|
}
|
|
94
94
|
export interface BatteryData {
|
|
@@ -137,8 +137,36 @@ export interface TouchData {
|
|
|
137
137
|
* The gesture: single_tap, double_tap, triple_tap, long_press, swipe_up, or
|
|
138
138
|
* swipe_down — plus the raw press edges tap_start (finger down) and tap_end
|
|
139
139
|
* (finger up), which bracket every gesture on hardware that reports them.
|
|
140
|
+
* tap_then_hold is the G2 2.2.9 tap-then-hold (Menu) gesture. touch_down is
|
|
141
|
+
* the R1 ring's finger-down, forwarded by the Glassly CFW (GLASSLYCFW/37 on
|
|
142
|
+
* G2 2.3.0.24); only the ring produces it, the temples report tap_start.
|
|
140
143
|
*/
|
|
141
|
-
kind: "single_tap" | "double_tap" | "triple_tap" | "long_press" | "swipe_up" | "swipe_down" | "tap_start" | "tap_end" | string;
|
|
144
|
+
kind: "single_tap" | "double_tap" | "triple_tap" | "long_press" | "swipe_up" | "swipe_down" | "tap_start" | "tap_end" | "tap_then_hold" | "touch_down" | string;
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* One key transition from a physical keyboard paired to the glasses (G2
|
|
148
|
+
* Glassly CFW revision 39+). Shapes follow the DOM: `key` is the logical key
|
|
149
|
+
* under the host's layout (US for now: "a", "A", "Enter", "ArrowUp", "F5",
|
|
150
|
+
* "AudioVolumeUp", …), `code` the physical key ("KeyA", "Digit1", "Space",
|
|
151
|
+
* "ControlLeft", …). `text` is the printable character a plain press types
|
|
152
|
+
* (down and repeat only, absent for Ctrl/Alt/Meta chords and named keys).
|
|
153
|
+
* `repeat` marks the host's synthesized auto-repeat while a key stays held;
|
|
154
|
+
* every gap in the link releases held keys with matching `up` events.
|
|
155
|
+
*/
|
|
156
|
+
export interface KeyboardEventData {
|
|
157
|
+
phase: "down" | "up";
|
|
158
|
+
key: string;
|
|
159
|
+
code: string;
|
|
160
|
+
modifiers: {
|
|
161
|
+
shift: boolean;
|
|
162
|
+
ctrl: boolean;
|
|
163
|
+
alt: boolean;
|
|
164
|
+
meta: boolean;
|
|
165
|
+
};
|
|
166
|
+
text?: string;
|
|
167
|
+
repeat: boolean;
|
|
168
|
+
/** Phone receipt time, unix ms. */
|
|
169
|
+
timestamp: number;
|
|
142
170
|
}
|
|
143
171
|
export interface AudioChunkData {
|
|
144
172
|
/** PCM or LC3, base64-encoded. Format depends on phone's mic mode. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../src/modules/events.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAKH,OAAO,EAAC,cAAc,EAAC,MAAM,YAAY,CAAA;AAEzC,MAAM,MAAM,aAAa,GAAG,MAAM,IAAI,CAAA;AAEtC,yEAAyE;AACzE,MAAM,MAAM,uBAAuB,GAAG,SAAS,GAAG,YAAY,GAAG,KAAK,CAAA;AAOtE,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,OAAO,CAAA;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB;;;;;OAKG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB;;;;;OAKG;IACH,MAAM,CAAC,EAAE,OAAO,CAAA;CACjB;AAED,MAAM,WAAW,eAAe;IA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AAA;YAChE,IAAI,cAAc,KAAK,CAAC;gBAAE,OAAO,MAAM,CAAA;YAEvC,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;YACjD,OAAO;gBACL,MAAM;gBACN,UAAU,EAAE,IAAI;gBAChB,GAAG,CAAC,SAAS,GAAG,cAAc,CAAC,CAAC,CAAC,EAAC,YAAY,EAAE,IAAI,EAAC,CAAC,CAAC,CAAC,EAAE,CAAC;aAC5D,CAAA;QACH,CAAC,CAAC,CAAA;QACF,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC;YACvB,IAAI,EAAE,kBAAkB,CAAC,SAAS;YAClC,aAAa;SACd,CAAC,CAAA;IACJ,CAAC;CACF"}
|
package/dist/modules/input.d.ts
CHANGED
|
@@ -15,11 +15,50 @@
|
|
|
15
15
|
* the phone runtime fans out alongside the bare `touch_event` stream.
|
|
16
16
|
*/
|
|
17
17
|
import { MiniappSession } from "../session";
|
|
18
|
-
import type { ButtonPressData, TouchData, UnsubscribeFn } from "./events";
|
|
18
|
+
import type { ButtonPressData, KeyboardEventData, TouchData, UnsubscribeFn } from "./events";
|
|
19
|
+
export interface GestureClaimChange {
|
|
20
|
+
gesture: string;
|
|
21
|
+
/** True when this app now holds the gesture, false when another app took it. */
|
|
22
|
+
held: boolean;
|
|
23
|
+
}
|
|
19
24
|
export declare class InputModule {
|
|
20
25
|
private readonly session;
|
|
21
26
|
constructor(session: MiniappSession);
|
|
27
|
+
/**
|
|
28
|
+
* Declare the gestures this miniapp is handling itself, replacing any
|
|
29
|
+
* previous claim set in the selected scope. Claims stack: the most recent app to claim a gesture
|
|
30
|
+
* holds it and receives it alone through `onTouch`, and the host skips its
|
|
31
|
+
* own default for it (a double tap otherwise leaves the visible miniapp or
|
|
32
|
+
* opens the glasses' dashboard). When the holder releases the gesture, or
|
|
33
|
+
* stops, the previous claimer holds it again; `onClaimChange` reports both
|
|
34
|
+
* sides of every handoff.
|
|
35
|
+
*
|
|
36
|
+
* Pass `[]` to release that scope. Omit `scope` for the default registration.
|
|
37
|
+
* Separate scopes preserve persistent shortcuts while a temporary page claims
|
|
38
|
+
* input: releasing the page scope restores the previous receiver without
|
|
39
|
+
* re-registering the shortcuts. All scopes are cleared automatically when
|
|
40
|
+
* the miniapp stops. One exception stands above the claims: an unclaimed
|
|
41
|
+
* double tap on a miniapp whose frame is visibly on the glasses leaves that
|
|
42
|
+
* app, so claim `double_tap` yourself while you are on screen if you use it.
|
|
43
|
+
*
|
|
44
|
+
* session.input.setClaimedGestures(["double_tap"]) // in-app back gesture
|
|
45
|
+
* session.input.setClaimedGestures([]) // hand it back
|
|
46
|
+
*/
|
|
47
|
+
setClaimedGestures(gestures: string[], options?: {
|
|
48
|
+
scope?: string;
|
|
49
|
+
}): Promise<void>;
|
|
50
|
+
/** This app gained or lost a gesture it claimed (another app claimed it, or released it back). */
|
|
51
|
+
onClaimChange(handler: (change: GestureClaimChange) => void): UnsubscribeFn;
|
|
22
52
|
onButtonPress(handler: (data: ButtonPressData) => void): UnsubscribeFn;
|
|
53
|
+
/**
|
|
54
|
+
* Subscribe to a physical keyboard paired to the glasses (G2 Glassly CFW
|
|
55
|
+
* revision 39+; nothing arrives on other hardware). Every subscriber
|
|
56
|
+
* receives every key, like button presses: check `phase`, use `text` to
|
|
57
|
+
* type printable characters and `key`/`modifiers` for commands.
|
|
58
|
+
*
|
|
59
|
+
* session.input.onKey((e) => { if (e.phase === "down" && e.text) type(e.text) })
|
|
60
|
+
*/
|
|
61
|
+
onKey(handler: (data: KeyboardEventData) => void): UnsubscribeFn;
|
|
23
62
|
/**
|
|
24
63
|
* Subscribe to touch events.
|
|
25
64
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"input.d.ts","sourceRoot":"","sources":["../../src/modules/input.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAGH,OAAO,EAAC,cAAc,EAAC,MAAM,YAAY,CAA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