forked from Blendman974/faceclaw
EvenHub extensions: Fonts, window icons, touch-start events
This commit is contained in:
1 parent
4ee0af86cc
commit
84baee9c76
25 files changed
+1884
-127
No files matched your search
@@ -7,10 +7,12 @@ Faceclaw is an alternative host for EvenHub apps on the Even Realities G2
|
||||
glasses. An app built against the standard
|
||||
[`@evenrealities/even_hub_sdk`](https://www.npmjs.com/package/@evenrealities/even_hub_sdk)
|
||||
runs in Faceclaw unchanged. This package lets the app detect that it is
|
||||
running in Faceclaw and use some extra capabilities there: a taller canvas, the
|
||||
glasses' compass and buzzer, window lifecycle events, voice-assistant tools, and
|
||||
the user's API keys (with their consent). In the stock Even app the extensions
|
||||
are absent, and the app runs as usual.
|
||||
running in Faceclaw and use some extra capabilities there: a taller canvas,
|
||||
choice of fonts, the glasses' compass and buzzer, touch-down events and which device an input came
|
||||
from, dictated or typed text, control of the app's switcher icon and the screen
|
||||
timeout, window lifecycle events, voice-assistant tools, and the user's API keys
|
||||
(with their consent). In the stock Even app the extensions are absent, and the
|
||||
app runs as usual.
|
||||
|
||||
- [API reference](docs/api/README.md)
|
||||
|
||||
@@ -57,11 +59,15 @@ startup. You don't need to wait for the bridge first.
|
||||
## How it works
|
||||
|
||||
Faceclaw injects one global function, `window.getFaceclawExtensions`, into the
|
||||
app's webview. Every extension lives behind it. Faceclaw doesn't modify the
|
||||
standard SDK, other globals, or any built-in prototype, so an app that uses
|
||||
app's webview. Every extension method lives behind it. Faceclaw doesn't modify
|
||||
the standard SDK, other globals, or any built-in prototype, so an app that uses
|
||||
the extensions keeps working in any other host. `getFaceclawExtensions()` in
|
||||
this package checks whether that global exists and calls it.
|
||||
|
||||
The one addition outside that global is data: Faceclaw adds a
|
||||
`faceclawInputSource` field to the raw JSON of stock gesture events, which
|
||||
`getInputSource()` reads. Stock apps ignore it.
|
||||
|
||||
## Checking for features
|
||||
|
||||
New members will be added over time, and an app may run in a Faceclaw build
|
||||
@@ -107,6 +113,18 @@ The [API reference](docs/api/README.md) documents every member in full.
|
||||
| `addCompassListener(fn)` | Turn on the magnetometer and receive headings. |
|
||||
| `createLayout(layout)` / `replaceLayout(layout)` | Build the page on the full 576×452 canvas, with no container limit, and optionally keep content across layouts. |
|
||||
| `setAssistantTools(tools)` | Offer tools to Faceclaw's voice assistant. |
|
||||
| `addTouchDownListener(fn)` | Hear the moment a finger touches the ring or watch, before the gesture is known. |
|
||||
| `addTextInputListener(fn)` | Receive dictated or typed text: the app becomes a "Type Into App" destination. |
|
||||
| `startVoiceInput()` | Open the voice dialog for the app. |
|
||||
| `setWindowIcon(icon)` | Replace the app's switcher icon with a pixel buffer. |
|
||||
| `setAttention(on)` | Show or clear the attention dot on the app's switcher icon. |
|
||||
| `setKeepScreenOn(on)` | Stop the display from sleeping for inactivity while the app is in front. |
|
||||
| `getFonts()` | List the font families available to text and list containers. |
|
||||
| `measureText(text, font)` | Measure text in a font, to size or centre it. |
|
||||
|
||||
The package also exports `getInputSource(event)`, which tells you which device
|
||||
(`ring`, `left-touchpad`, `right-touchpad` or `watch`) produced a stock gesture
|
||||
event.
|
||||
|
||||
### Extended layout
|
||||
|
||||
@@ -121,6 +139,7 @@ classes. The differences:
|
||||
- A container with `preserve: true` keeps the content (text, pixels, or list
|
||||
items and selection) of the same-named container in the previous layout.
|
||||
Without it, the container starts blank.
|
||||
- Text and list containers can use other fonts (see [Fonts](#fonts)).
|
||||
|
||||
```ts
|
||||
import { ImageContainerProperty, TextContainerProperty } from "@evenrealities/even_hub_sdk";
|
||||
@@ -141,6 +160,92 @@ Keep using the stock `updateImageRawData` and `textContainerUpgrade` to update
|
||||
content; they address containers by `containerID`. Once an app has used an
|
||||
extended layout, its window stays at 576×452 for the rest of the session.
|
||||
|
||||
### Fonts
|
||||
|
||||
In an extended layout, text and list containers can set a `font` with a
|
||||
`family`, `size` (in pixels) and `weight`. A `font` on the layout is the
|
||||
default for all of them, and a container's own `font` overrides it field by
|
||||
field. Without either, text is in the stock firmware font, as before.
|
||||
|
||||
```ts
|
||||
await fc.createLayout({
|
||||
font: { family: "Inter", size: 22 },
|
||||
textObject: [
|
||||
{ containerID: 1, containerName: "title", xPosition: 16, yPosition: 12, width: 544, height: 50, content: "Today", font: { size: 40, weight: "bold" } },
|
||||
{ containerID: 2, containerName: "body", xPosition: 16, yPosition: 70, width: 544, height: 360, content: "...", isEventCapture: 1 },
|
||||
],
|
||||
});
|
||||
```
|
||||
|
||||
Faceclaw bundles Roboto, Inter, Montserrat and Roboto Mono (weights 300, 400
|
||||
and 700, any size from 6 to 128) and the bitmap font Terminus (sizes 12 to
|
||||
32, weights 400 and 700). `EvenHub` is the stock font, at 20px only. Users
|
||||
can install more fonts, and `getFonts()` lists everything available. An
|
||||
unknown family falls back to Roboto, and the nearest available weight and
|
||||
(for bitmap fonts) size are used.
|
||||
|
||||
`measureText(text, font)` returns the text's width and line height in a
|
||||
font, so you can size containers or centre text. A list row is the font's
|
||||
line height plus 12 pixels.
|
||||
|
||||
### Input sources and touch-down
|
||||
|
||||
The stock `eventSource` field can't tell the watch from the ring, and scrolls
|
||||
don't carry it at all. Pass the event your `onEvenHubEvent` handler receives
|
||||
to `getInputSource()` to find out which device it came from:
|
||||
|
||||
```ts
|
||||
import { getFaceclawExtensions, getInputSource } from "@faceclaw/evenhub-extensions";
|
||||
|
||||
bridge.onEvenHubEvent((event) => {
|
||||
const source = getInputSource(event); // "ring", "left-touchpad", "right-touchpad", "watch" or null
|
||||
});
|
||||
```
|
||||
|
||||
It returns `null` when the source is unknown (some scrolls), for non-gesture
|
||||
events, and outside Faceclaw.
|
||||
|
||||
A touch-down is the moment a finger lands on the ring or the watch's
|
||||
touchpad, before Faceclaw knows whether it will become a tap, a scroll or a
|
||||
hold. The interpreted gesture still arrives afterwards as the usual stock
|
||||
event. Touch-downs suit games and other latency-sensitive input:
|
||||
|
||||
```ts
|
||||
fc.addTouchDownListener(({ source, timestampMs }) => flap());
|
||||
```
|
||||
|
||||
The glasses' own touchpads don't report touch-down.
|
||||
|
||||
### Text input
|
||||
|
||||
While the app has a text-input listener, Faceclaw offers it as the "Type Into
|
||||
App" destination for its voice dialog, the phone keyboard and the watch. The
|
||||
app can also open the voice dialog itself:
|
||||
|
||||
```ts
|
||||
fc.addTextInputListener(({ text }) => addNote(text));
|
||||
|
||||
// For example, from a "Dictate" item in the app's menu:
|
||||
const opened = await fc.startVoiceInput();
|
||||
```
|
||||
|
||||
### Window icon, attention dot, and screen timeout
|
||||
|
||||
```ts
|
||||
// Draw a 32x32 icon on a canvas, light on black, and use it in the app switcher.
|
||||
fc.setWindowIcon(ctx.getImageData(0, 0, 32, 32));
|
||||
|
||||
// Flag new activity while the app is in the background; clear it when seen.
|
||||
fc.setAttention(true);
|
||||
|
||||
// Keep the display awake while the app is in front (e.g. a teleprompter).
|
||||
fc.setKeepScreenOn(true);
|
||||
```
|
||||
|
||||
`setWindowIcon` takes `{ width, height, data }` with grayscale or RGBA pixels,
|
||||
up to 256×256, so an `ImageData` works as is. Pass `null` to restore the
|
||||
package's icon.
|
||||
|
||||
### Compass
|
||||
|
||||
Each `CompassReading` has several headings, all in degrees clockwise from north:
|
||||
@@ -191,6 +296,18 @@ keys. `requestApiKeyAccess(services)` shows a consent prompt on the glasses and
|
||||
resolves with the keys the user agreed to share. If the user declines, it
|
||||
resolves to `{}`. A grant lasts until the app closes.
|
||||
|
||||
## Stock APIs in Faceclaw
|
||||
|
||||
Faceclaw implements the stock SDK too. Some differences worth knowing:
|
||||
|
||||
- `getDeviceInfo()` and `onDeviceStatusChanged` report the real glasses:
|
||||
their serial number, whether they are connected and worn, the battery level,
|
||||
and whether they are charging. `isInCase` is the same as `isCharging`, since
|
||||
the G2 only charges in its case. Fields Faceclaw doesn't know yet (wear state
|
||||
before the glasses first report it) are left out.
|
||||
- `shutDownPageContainer(1)` returns to the app switcher instead of asking to
|
||||
quit. Use `quit()` to really quit.
|
||||
|
||||
## Stability
|
||||
|
||||
This package is pre-1.0. Until 1.0 the API may still change. After that, changes
|
||||
|
||||
@@ -261,6 +261,168 @@ tool's `handler` runs in the app when the assistant calls it.
|
||||
|
||||
`void`
|
||||
|
||||
##### addTouchDownListener()
|
||||
|
||||
```ts
|
||||
addTouchDownListener(listener): () => void;
|
||||
```
|
||||
|
||||
Receive touch-downs: the moment a finger touches the ring or the watch's
|
||||
touchpad, before Faceclaw knows whether it will become a tap, a scroll or
|
||||
a hold. The interpreted gesture still arrives afterwards as the usual
|
||||
stock event. Use it where latency matters, as in games.
|
||||
|
||||
Touch-downs arrive only while the app's window has input focus. The
|
||||
glasses' own touchpads don't report them.
|
||||
|
||||
###### Parameters
|
||||
|
||||
| Parameter | Type | Description |
|
||||
| ------ | ------ | ------ |
|
||||
| `listener` | (`event`) => `void` | Called on each touch-down. |
|
||||
|
||||
###### Returns
|
||||
|
||||
A function that unsubscribes `listener`.
|
||||
|
||||
() => `void`
|
||||
|
||||
##### addTextInputListener()
|
||||
|
||||
```ts
|
||||
addTextInputListener(listener): () => void;
|
||||
```
|
||||
|
||||
Receive text the user sends to the app. While at least one listener is
|
||||
registered and the app is in the foreground, Faceclaw offers the app as
|
||||
the "Type Into App" destination of its voice dialog, the phone keyboard
|
||||
and the watch.
|
||||
|
||||
###### Parameters
|
||||
|
||||
| Parameter | Type | Description |
|
||||
| ------ | ------ | ------ |
|
||||
| `listener` | (`event`) => `void` | Called with each piece of text. |
|
||||
|
||||
###### Returns
|
||||
|
||||
A function that unsubscribes `listener`.
|
||||
|
||||
() => `void`
|
||||
|
||||
##### startVoiceInput()
|
||||
|
||||
```ts
|
||||
startVoiceInput(): Promise<boolean>;
|
||||
```
|
||||
|
||||
Open Faceclaw's voice dialog for this app. When the user sends the
|
||||
dictation with Type Into App, it arrives at the text-input listeners.
|
||||
|
||||
###### Returns
|
||||
|
||||
`Promise`\<`boolean`\>
|
||||
|
||||
A promise that resolves to true if the dialog is opening, or
|
||||
false if it can't open: there is no text-input listener, the app isn't
|
||||
in the foreground, voice input is unavailable, or another dialog is up.
|
||||
|
||||
##### setWindowIcon()
|
||||
|
||||
```ts
|
||||
setWindowIcon(icon): Promise<void>;
|
||||
```
|
||||
|
||||
Replace the app's icon in the app switcher, or pass `null` to go back to
|
||||
the package's icon. See [WindowIconImage](#windowiconimage) for the format.
|
||||
|
||||
###### Parameters
|
||||
|
||||
| Parameter | Type |
|
||||
| ------ | ------ |
|
||||
| `icon` | [`WindowIconImage`](#windowiconimage) \| `null` |
|
||||
|
||||
###### Returns
|
||||
|
||||
`Promise`\<`void`\>
|
||||
|
||||
A promise that resolves once the icon is set, and rejects if the
|
||||
image is malformed or larger than 256×256.
|
||||
|
||||
##### setAttention()
|
||||
|
||||
```ts
|
||||
setAttention(attention): void;
|
||||
```
|
||||
|
||||
Show or clear the attention dot on the app's switcher icon, for example
|
||||
when something new arrives while the app is in the background. The dot
|
||||
stays until the app clears it or closes.
|
||||
|
||||
###### Parameters
|
||||
|
||||
| Parameter | Type |
|
||||
| ------ | ------ |
|
||||
| `attention` | `boolean` |
|
||||
|
||||
###### Returns
|
||||
|
||||
`void`
|
||||
|
||||
##### setKeepScreenOn()
|
||||
|
||||
```ts
|
||||
setKeepScreenOn(keepOn): void;
|
||||
```
|
||||
|
||||
Stop the glasses display from turning off for inactivity while the app is
|
||||
in the foreground, as a teleprompter or navigation app needs. It has no
|
||||
effect while another window is in front, and the user can still turn the
|
||||
display off. Pass `false` to restore the normal timeout.
|
||||
|
||||
###### Parameters
|
||||
|
||||
| Parameter | Type |
|
||||
| ------ | ------ |
|
||||
| `keepOn` | `boolean` |
|
||||
|
||||
###### Returns
|
||||
|
||||
`void`
|
||||
|
||||
##### getFonts()
|
||||
|
||||
```ts
|
||||
getFonts(): Promise<FaceclawFontFamily[]>;
|
||||
```
|
||||
|
||||
List the font families available for [FaceclawFont.family](#property-family),
|
||||
including any the user has installed.
|
||||
|
||||
###### Returns
|
||||
|
||||
`Promise`\<[`FaceclawFontFamily`](#faceclawfontfamily)[]\>
|
||||
|
||||
##### measureText()
|
||||
|
||||
```ts
|
||||
measureText(text, font?): Promise<TextMeasurement>;
|
||||
```
|
||||
|
||||
Measure text as a container with this font would draw it, for example to
|
||||
size a text container or centre a label.
|
||||
|
||||
###### Parameters
|
||||
|
||||
| Parameter | Type | Description |
|
||||
| ------ | ------ | ------ |
|
||||
| `text` | `string` | The text. Lines split at `\n` are measured separately. |
|
||||
| `font?` | [`FaceclawFont`](#faceclawfont) | The font to measure in. Unlike a container's font, it isn't combined with a layout default. Omit it to measure in the stock font. |
|
||||
|
||||
###### Returns
|
||||
|
||||
`Promise`\<[`TextMeasurement`](#textmeasurement)\>
|
||||
|
||||
***
|
||||
|
||||
### getFaceclawExtensions()
|
||||
@@ -278,7 +440,7 @@ script runs.
|
||||
|
||||
[`FaceclawExtensions`](#faceclawextensions) \| `null`
|
||||
|
||||
## Window lifecycle
|
||||
## Window
|
||||
|
||||
### WindowLifecycleEventType
|
||||
|
||||
@@ -312,51 +474,107 @@ Payload of a [FaceclawExtensions.addWindowLifecycleListener](#addwindowlifecycle
|
||||
| ------ | ------ | ------ |
|
||||
| <a id="property-type"></a> `type` | [`WindowLifecycleEventType`](#windowlifecycleeventtype) | Which transition happened. |
|
||||
|
||||
## API keys
|
||||
***
|
||||
|
||||
### ApiKeyService
|
||||
### WindowIconImage
|
||||
|
||||
```ts
|
||||
type ApiKeyService = "openai" | "anthropic" | "soniox" | "elevenlabs" | "mapbox";
|
||||
```
|
||||
An image for [FaceclawExtensions.setWindowIcon](#setwindowicon). An `ImageData` (from
|
||||
a canvas's `getImageData`) fits this shape and can be passed directly.
|
||||
|
||||
Third-party services whose API keys the user may have configured in Faceclaw.
|
||||
|
||||
## Buzzer
|
||||
|
||||
### BuzzerStep
|
||||
|
||||
One step of a piezo-buzzer tone sequence. The G2 has a single monophonic PWM
|
||||
buzzer, and the firmware plays a sequence's steps back to back on its own timer.
|
||||
|
||||
#### Properties
|
||||
|
||||
| Property | Type | Default value | Description |
|
||||
| ------ | ------ | ------ | ------ |
|
||||
| <a id="property-freq"></a> `freq` | `number` | `undefined` | Tone frequency in Hz. The piezo is loudest around 1–4 kHz and faint below about 150 Hz. |
|
||||
| <a id="property-ms"></a> `ms` | `number` | `undefined` | Step duration in milliseconds (1–65535). |
|
||||
| <a id="property-duty"></a> `duty?` | `number` | `50` | PWM duty cycle, 0–100. Use `duty: 0` for a rest (silence) lasting `ms`. |
|
||||
|
||||
## Compass
|
||||
|
||||
### CompassReading
|
||||
|
||||
A magnetometer heading sample from [FaceclawExtensions.addCompassListener](#addcompasslistener).
|
||||
All headings are in degrees clockwise, in the range [0, 360).
|
||||
|
||||
Prefer `trueHeadingDegrees` when it is present, then `magneticHeadingDegrees`.
|
||||
If `wearerCalibrated` is false, treat both as relative headings, or let the
|
||||
user zero them.
|
||||
Draw it like Faceclaw's own icons: light strokes on black. Brightness is
|
||||
coverage, so black is transparent, and Faceclaw inverts the icon for the
|
||||
selected window. The switcher draws icons at about 32×32; larger images are
|
||||
scaled down to fit, keeping their aspect ratio.
|
||||
|
||||
#### Properties
|
||||
|
||||
| Property | Type | Description |
|
||||
| ------ | ------ | ------ |
|
||||
| <a id="property-headingdegrees"></a> `headingDegrees` | `number` | Raw magnetic heading as reported by the glasses, with no correction for how they sit on the wearer's head. It is kept for apps that zero it themselves. |
|
||||
| <a id="property-magneticheadingdegrees"></a> `magneticHeadingDegrees` | `number` | Magnetic heading corrected by the wearer's calibration offset from Faceclaw's Compass app. Equal to `headingDegrees` until the wearer calibrates. |
|
||||
| <a id="property-wearercalibrated"></a> `wearerCalibrated` | `boolean` | Whether the wearer has calibrated the compass in Faceclaw's Compass app. Only trust `magneticHeadingDegrees` and `trueHeadingDegrees` as absolute headings when this is true. |
|
||||
| <a id="property-declinationdegrees"></a> `declinationDegrees?` | `number` | Local magnetic declination in degrees (east positive), computed from the phone's location and the World Magnetic Model. Absent when Faceclaw has no location fix or no location permission. |
|
||||
| <a id="property-trueheadingdegrees"></a> `trueHeadingDegrees?` | `number` | `magneticHeadingDegrees` plus declination. Absent when `declinationDegrees` is. |
|
||||
| <a id="property-width"></a> `width` | `number` | Width in pixels, 1–256. |
|
||||
| <a id="property-height"></a> `height` | `number` | Height in pixels, 1–256. |
|
||||
| <a id="property-data"></a> `data` | `ArrayLike`\<`number`\> | Pixels in rows from the top left: either `width * height` grayscale values (0–255), or `width * height * 4` RGBA values, which Faceclaw converts to grayscale (luminance times alpha). |
|
||||
|
||||
## Input
|
||||
|
||||
### InputSource
|
||||
|
||||
```ts
|
||||
type InputSource = "ring" | "left-touchpad" | "right-touchpad" | "watch";
|
||||
```
|
||||
|
||||
The device an input came from:
|
||||
|
||||
- `ring`: the Even R1 ring (or the ring pad in Faceclaw's phone app).
|
||||
- `left-touchpad` / `right-touchpad`: the touch areas on the glasses' arms.
|
||||
- `watch`: Faceclaw's Wear OS watch remote (or the watch pad in Faceclaw's
|
||||
phone app).
|
||||
|
||||
***
|
||||
|
||||
### TouchDownEvent
|
||||
|
||||
A touch-down, from [FaceclawExtensions.addTouchDownListener](#addtouchdownlistener).
|
||||
|
||||
#### Properties
|
||||
|
||||
| Property | Type | Description |
|
||||
| ------ | ------ | ------ |
|
||||
| <a id="property-source"></a> `source` | [`InputSource`](#inputsource) | Which device was touched. Currently always `ring` or `watch`: the glasses' touchpads don't report touch-down. |
|
||||
| <a id="property-timestampms"></a> `timestampMs` | `number` | When Faceclaw received the touch, in milliseconds since the epoch (comparable with `Date.now()`). |
|
||||
|
||||
***
|
||||
|
||||
### getInputSource()
|
||||
|
||||
```ts
|
||||
function getInputSource(event): InputSource | null;
|
||||
```
|
||||
|
||||
Which device produced a stock EvenHub gesture event, or `null` if Faceclaw
|
||||
didn't say.
|
||||
|
||||
The stock `eventSource` field only knows the stock devices, so Faceclaw
|
||||
reports the watch there as the ring. Faceclaw adds the real device to the
|
||||
event's raw JSON as `faceclawInputSource`, and this function reads it. Pass
|
||||
the event object your `onEvenHubEvent` handler receives.
|
||||
|
||||
Faceclaw adds the field to clicks, double-clicks, long-presses and their
|
||||
releases, and scrolls, in both `sysEvent` and `listEvent`. It is missing when
|
||||
the glasses don't report a scroll's source, on non-gesture events, and in
|
||||
every other host.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Parameter | Type |
|
||||
| ------ | ------ |
|
||||
| `event` | \| \{ `jsonData?`: `Record`\<`string`, `unknown`\>; \} \| `null` \| `undefined` |
|
||||
|
||||
#### Returns
|
||||
|
||||
[`InputSource`](#inputsource) \| `null`
|
||||
|
||||
#### Example
|
||||
|
||||
```ts
|
||||
bridge.onEvenHubEvent((event) => {
|
||||
if (event.sysEvent && getInputSource(event) === "watch") {
|
||||
// ...
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
## Text input
|
||||
|
||||
### TextInputEvent
|
||||
|
||||
Text sent to the app, from [FaceclawExtensions.addTextInputListener](#addtextinputlistener).
|
||||
|
||||
#### Properties
|
||||
|
||||
| Property | Type | Description |
|
||||
| ------ | ------ | ------ |
|
||||
| <a id="property-text"></a> `text` | `string` | The finished text: a whole dictation, or a typed entry. |
|
||||
| <a id="property-submit"></a> `submit?` | `boolean` | Present when the sender said whether to submit the text (`true`, like pressing Enter after it) or only insert it (`false`). Faceclaw's remote-input tool sets it; dictation and the phone keyboard leave it out. |
|
||||
|
||||
## Extended layout
|
||||
|
||||
@@ -383,8 +601,8 @@ classes can be passed directly. In practice you should set `containerID`,
|
||||
| <a id="property-containername"></a> `containerName?` | `string` | Container name. `preserve` matches containers across layouts by name. |
|
||||
| <a id="property-xposition"></a> `xPosition?` | `number` | Left edge in pixels on the 576×452 canvas. |
|
||||
| <a id="property-yposition"></a> `yPosition?` | `number` | Top edge in pixels on the 576×452 canvas. |
|
||||
| <a id="property-width"></a> `width?` | `number` | Width in pixels. |
|
||||
| <a id="property-height"></a> `height?` | `number` | Height in pixels. |
|
||||
| <a id="property-width-2"></a> `width?` | `number` | Width in pixels. |
|
||||
| <a id="property-height-1"></a> `height?` | `number` | Height in pixels. |
|
||||
| <a id="property-zorderindex"></a> `zOrderIndex?` | `number` | Stacking order: higher values draw on top. |
|
||||
| <a id="property-iseventcapture"></a> `isEventCapture?` | `number` \| `boolean` | When set to `1`/`true`, this container receives the app's tap and scroll events. Exactly one text or list container per layout should capture events. |
|
||||
| <a id="property-preserve"></a> `preserve?` | `boolean` | When true, inherit content (text, image pixels, or list items and selection) from the container of the same kind and `containerName` in the previous layout. Otherwise the container starts blank. |
|
||||
@@ -407,8 +625,8 @@ A text container. The fields match the stock SDK's `TextContainerProperty`, plus
|
||||
| <a id="property-containername-1"></a> `containerName?` | `string` | `undefined` | Container name. `preserve` matches containers across layouts by name. |
|
||||
| <a id="property-xposition-1"></a> `xPosition?` | `number` | `undefined` | Left edge in pixels on the 576×452 canvas. |
|
||||
| <a id="property-yposition-1"></a> `yPosition?` | `number` | `undefined` | Top edge in pixels on the 576×452 canvas. |
|
||||
| <a id="property-width-1"></a> `width?` | `number` | `undefined` | Width in pixels. |
|
||||
| <a id="property-height-1"></a> `height?` | `number` | `undefined` | Height in pixels. |
|
||||
| <a id="property-width-3"></a> `width?` | `number` | `undefined` | Width in pixels. |
|
||||
| <a id="property-height-2"></a> `height?` | `number` | `undefined` | Height in pixels. |
|
||||
| <a id="property-zorderindex-1"></a> `zOrderIndex?` | `number` | `undefined` | Stacking order: higher values draw on top. |
|
||||
| <a id="property-iseventcapture-1"></a> `isEventCapture?` | `number` \| `boolean` | `undefined` | When set to `1`/`true`, this container receives the app's tap and scroll events. Exactly one text or list container per layout should capture events. |
|
||||
| <a id="property-preserve-1"></a> `preserve?` | `boolean` | `undefined` | When true, inherit content (text, image pixels, or list items and selection) from the container of the same kind and `containerName` in the previous layout. Otherwise the container starts blank. |
|
||||
@@ -418,6 +636,7 @@ A text container. The fields match the stock SDK's `TextContainerProperty`, plus
|
||||
| <a id="property-bordercolor"></a> `borderColor?` | `number` | `undefined` | Accepted for compatibility with stock payloads. Faceclaw currently ignores it. |
|
||||
| <a id="property-borderradius"></a> `borderRadius?` | `number` | `undefined` | Border corner radius in pixels. |
|
||||
| <a id="property-paddinglength"></a> `paddingLength?` | `number` | `undefined` | Padding between the border and the text, in pixels. |
|
||||
| <a id="property-font"></a> `font?` | [`FaceclawFont`](#faceclawfont) | `undefined` | The text's font. Its fields override the layout's [FaceclawLayout.font](#property-font-2) one by one. With neither, the text is in the stock firmware font. |
|
||||
|
||||
***
|
||||
|
||||
@@ -469,8 +688,8 @@ A list container. The fields match the stock SDK's `ListContainerProperty`, plus
|
||||
| <a id="property-containername-2"></a> `containerName?` | `string` | Container name. `preserve` matches containers across layouts by name. |
|
||||
| <a id="property-xposition-2"></a> `xPosition?` | `number` | Left edge in pixels on the 576×452 canvas. |
|
||||
| <a id="property-yposition-2"></a> `yPosition?` | `number` | Top edge in pixels on the 576×452 canvas. |
|
||||
| <a id="property-width-2"></a> `width?` | `number` | Width in pixels. |
|
||||
| <a id="property-height-2"></a> `height?` | `number` | Height in pixels. |
|
||||
| <a id="property-width-4"></a> `width?` | `number` | Width in pixels. |
|
||||
| <a id="property-height-3"></a> `height?` | `number` | Height in pixels. |
|
||||
| <a id="property-zorderindex-2"></a> `zOrderIndex?` | `number` | Stacking order: higher values draw on top. |
|
||||
| <a id="property-iseventcapture-2"></a> `isEventCapture?` | `number` \| `boolean` | When set to `1`/`true`, this container receives the app's tap and scroll events. Exactly one text or list container per layout should capture events. |
|
||||
| <a id="property-preserve-2"></a> `preserve?` | `boolean` | When true, inherit content (text, image pixels, or list items and selection) from the container of the same kind and `containerName` in the previous layout. Otherwise the container starts blank. |
|
||||
@@ -479,6 +698,7 @@ A list container. The fields match the stock SDK's `ListContainerProperty`, plus
|
||||
| <a id="property-bordercolor-1"></a> `borderColor?` | `number` | Accepted for compatibility with stock payloads. Faceclaw currently ignores it. |
|
||||
| <a id="property-borderradius-1"></a> `borderRadius?` | `number` | Border corner radius in pixels. |
|
||||
| <a id="property-paddinglength-1"></a> `paddingLength?` | `number` | Padding between the border and the items, in pixels. |
|
||||
| <a id="property-font-1"></a> `font?` | [`FaceclawFont`](#faceclawfont) | The items' font. Its fields override the layout's [FaceclawLayout.font](#property-font-2) one by one. With neither, the items are in the stock firmware font. Each row is the font's line height plus 12 pixels. |
|
||||
|
||||
***
|
||||
|
||||
@@ -512,6 +732,8 @@ classes, with three differences:
|
||||
- Each container may set `preserve: true` to inherit its content from the
|
||||
same-named container in the previous layout.
|
||||
|
||||
Text and list containers can also use other fonts (see [FaceclawFont](#faceclawfont)).
|
||||
|
||||
#### Properties
|
||||
|
||||
| Property | Type | Description |
|
||||
@@ -521,6 +743,110 @@ classes, with three differences:
|
||||
| <a id="property-listobject"></a> `listObject?` | [`FaceclawListContainer`](#faceclawlistcontainer)[] | List containers. |
|
||||
| <a id="property-menuobject"></a> `menuObject?` | [`FaceclawMenu`](#faceclawmenu) | The page's contextual menu. Omit it to clear any previous menu. |
|
||||
| <a id="property-containertotalnum"></a> `containerTotalNum?` | `number` | Accepted for compatibility with stock payloads and ignored: there is no container limit. |
|
||||
| <a id="property-font-2"></a> `font?` | [`FaceclawFont`](#faceclawfont) | The default font for every text and list container in the layout. |
|
||||
|
||||
## Fonts
|
||||
|
||||
### FaceclawFont
|
||||
|
||||
A font for text and list containers in an extended layout, from
|
||||
[FaceclawLayout.font](#property-font-2) and the containers' own `font`. A container
|
||||
that has no font, and whose layout has none, uses the stock firmware font.
|
||||
|
||||
Available families (see [FaceclawExtensions.getFonts](#getfonts)):
|
||||
|
||||
- `Roboto`, `Inter`, `Montserrat` and `Roboto Mono`: bundled TrueType
|
||||
fonts in weights 300, 400 and 700, at any size.
|
||||
- `Terminus`: a monospace bitmap font, in sizes 12, 14, 16, 18, 20, 22, 24,
|
||||
28 and 32, and weights 400 and 700.
|
||||
- `EvenHub`: the stock firmware font, 20px only. Use it to bring back the
|
||||
stock font for one container when the layout sets another.
|
||||
- Any font the user has installed in Faceclaw.
|
||||
|
||||
Text in the stock font wraps exactly as on the stock firmware. Text in
|
||||
other fonts wraps with Faceclaw's own line breaking.
|
||||
|
||||
#### Properties
|
||||
|
||||
| Property | Type | Default value | Description |
|
||||
| ------ | ------ | ------ | ------ |
|
||||
| <a id="property-family"></a> `family?` | `string` | `"Roboto"` | Font family, matched without regard to case, spaces or punctuation. An unknown family falls back to Roboto. |
|
||||
| <a id="property-size"></a> `size?` | `number` | `20` | Size in pixels: the em size, as in CSS `font-size`. A line is somewhat taller; [FaceclawExtensions.measureText](#measuretext) reports its height. 6–128. Bitmap families use their nearest size. |
|
||||
| <a id="property-weight"></a> `weight?` | `number` \| `"normal"` \| `"bold"` | `400` | Weight, 100–900, where `"normal"` is 400 and `"bold"` is 700. The nearest weight the family has is used, as CSS chooses it. |
|
||||
|
||||
***
|
||||
|
||||
### FaceclawFontFamily
|
||||
|
||||
A font family Faceclaw can draw, from [FaceclawExtensions.getFonts](#getfonts).
|
||||
|
||||
#### Properties
|
||||
|
||||
| Property | Type | Description |
|
||||
| ------ | ------ | ------ |
|
||||
| <a id="property-family-1"></a> `family` | `string` | The name to use as [FaceclawFont.family](#property-family). |
|
||||
| <a id="property-weights"></a> `weights` | `number`[] | The weights the family has, lightest first. |
|
||||
| <a id="property-sizes"></a> `sizes?` | `number`[] | For a bitmap family, the sizes it has. Absent for a scalable family, which takes any size. |
|
||||
| <a id="property-monospace"></a> `monospace` | `boolean` | Whether every character has the same width. |
|
||||
|
||||
***
|
||||
|
||||
### TextMeasurement
|
||||
|
||||
The size of some text, from [FaceclawExtensions.measureText](#measuretext).
|
||||
|
||||
#### Properties
|
||||
|
||||
| Property | Type | Description |
|
||||
| ------ | ------ | ------ |
|
||||
| <a id="property-width-1"></a> `width` | `number` | Width in pixels of the widest line (lines are split at `\n`). |
|
||||
| <a id="property-lineheight"></a> `lineHeight` | `number` | Height in pixels of one line. A text container advances by this much per line. |
|
||||
|
||||
## API keys
|
||||
|
||||
### ApiKeyService
|
||||
|
||||
```ts
|
||||
type ApiKeyService = "openai" | "anthropic" | "soniox" | "elevenlabs" | "mapbox";
|
||||
```
|
||||
|
||||
Third-party services whose API keys the user may have configured in Faceclaw.
|
||||
|
||||
## Buzzer
|
||||
|
||||
### BuzzerStep
|
||||
|
||||
One step of a piezo-buzzer tone sequence. The G2 has a single monophonic PWM
|
||||
buzzer, and the firmware plays a sequence's steps back to back on its own timer.
|
||||
|
||||
#### Properties
|
||||
|
||||
| Property | Type | Default value | Description |
|
||||
| ------ | ------ | ------ | ------ |
|
||||
| <a id="property-freq"></a> `freq` | `number` | `undefined` | Tone frequency in Hz. The piezo is loudest around 1–4 kHz and faint below about 150 Hz. |
|
||||
| <a id="property-ms"></a> `ms` | `number` | `undefined` | Step duration in milliseconds (1–65535). |
|
||||
| <a id="property-duty"></a> `duty?` | `number` | `50` | PWM duty cycle, 0–100. Use `duty: 0` for a rest (silence) lasting `ms`. |
|
||||
|
||||
## Compass
|
||||
|
||||
### CompassReading
|
||||
|
||||
A magnetometer heading sample from [FaceclawExtensions.addCompassListener](#addcompasslistener).
|
||||
All headings are in degrees clockwise, in the range [0, 360).
|
||||
|
||||
Prefer `trueHeadingDegrees` when it is present, then `magneticHeadingDegrees`.
|
||||
If `wearerCalibrated` is false, treat both as relative headings, or let the
|
||||
user zero them.
|
||||
|
||||
#### Properties
|
||||
|
||||
| Property | Type | Description |
|
||||
| ------ | ------ | ------ |
|
||||
| <a id="property-headingdegrees"></a> `headingDegrees` | `number` | Raw magnetic heading as reported by the glasses, with no correction for how they sit on the wearer's head. It is kept for apps that zero it themselves. |
|
||||
| <a id="property-magneticheadingdegrees"></a> `magneticHeadingDegrees` | `number` | Magnetic heading corrected by the wearer's calibration offset from Faceclaw's Compass app. Equal to `headingDegrees` until the wearer calibrates. |
|
||||
| <a id="property-wearercalibrated"></a> `wearerCalibrated` | `boolean` | Whether the wearer has calibrated the compass in Faceclaw's Compass app. Only trust `magneticHeadingDegrees` and `trueHeadingDegrees` as absolute headings when this is true. |
|
||||
| <a id="property-declinationdegrees"></a> `declinationDegrees?` | `number` | Local magnetic declination in degrees (east positive), computed from the phone's location and the World Magnetic Model. Absent when Faceclaw has no location fix or no location permission. |
|
||||
| <a id="property-trueheadingdegrees"></a> `trueHeadingDegrees?` | `number` | `magneticHeadingDegrees` plus declination. Absent when `declinationDegrees` is. |
|
||||
|
||||
## Assistant tools
|
||||
|
||||
|
||||
@@ -69,20 +69,121 @@ export interface BuzzerStep {
|
||||
* An app can assume it starts `visible` and `focused` at launch. Events report
|
||||
* changes from there.
|
||||
*
|
||||
* @group Window lifecycle
|
||||
* @group Window
|
||||
*/
|
||||
export type WindowLifecycleEventType = "visible" | "hidden" | "focused" | "blurred";
|
||||
|
||||
/**
|
||||
* Payload of a {@link FaceclawExtensions.addWindowLifecycleListener} callback.
|
||||
*
|
||||
* @group Window lifecycle
|
||||
* @group Window
|
||||
*/
|
||||
export interface WindowLifecycleEvent {
|
||||
/** Which transition happened. */
|
||||
type: WindowLifecycleEventType;
|
||||
}
|
||||
|
||||
/**
|
||||
* An image for {@link FaceclawExtensions.setWindowIcon}. An `ImageData` (from
|
||||
* a canvas's `getImageData`) fits this shape and can be passed directly.
|
||||
*
|
||||
* Draw it like Faceclaw's own icons: light strokes on black. Brightness is
|
||||
* coverage, so black is transparent, and Faceclaw inverts the icon for the
|
||||
* selected window. The switcher draws icons at about 32×32; larger images are
|
||||
* scaled down to fit, keeping their aspect ratio.
|
||||
*
|
||||
* @group Window
|
||||
*/
|
||||
export interface WindowIconImage {
|
||||
/** Width in pixels, 1–256. */
|
||||
width: number;
|
||||
/** Height in pixels, 1–256. */
|
||||
height: number;
|
||||
/**
|
||||
* Pixels in rows from the top left: either `width * height` grayscale
|
||||
* values (0–255), or `width * height * 4` RGBA values, which Faceclaw
|
||||
* converts to grayscale (luminance times alpha).
|
||||
*/
|
||||
data: ArrayLike<number>;
|
||||
}
|
||||
|
||||
// ---- Input ----
|
||||
|
||||
/**
|
||||
* The device an input came from:
|
||||
*
|
||||
* - `ring`: the Even R1 ring (or the ring pad in Faceclaw's phone app).
|
||||
* - `left-touchpad` / `right-touchpad`: the touch areas on the glasses' arms.
|
||||
* - `watch`: Faceclaw's Wear OS watch remote (or the watch pad in Faceclaw's
|
||||
* phone app).
|
||||
*
|
||||
* @group Input
|
||||
*/
|
||||
export type InputSource = "ring" | "left-touchpad" | "right-touchpad" | "watch";
|
||||
|
||||
/**
|
||||
* A touch-down, from {@link FaceclawExtensions.addTouchDownListener}.
|
||||
*
|
||||
* @group Input
|
||||
*/
|
||||
export interface TouchDownEvent {
|
||||
/**
|
||||
* Which device was touched. Currently always `ring` or `watch`: the
|
||||
* glasses' touchpads don't report touch-down.
|
||||
*/
|
||||
source: InputSource;
|
||||
/** When Faceclaw received the touch, in milliseconds since the epoch (comparable with `Date.now()`). */
|
||||
timestampMs: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Which device produced a stock EvenHub gesture event, or `null` if Faceclaw
|
||||
* didn't say.
|
||||
*
|
||||
* The stock `eventSource` field only knows the stock devices, so Faceclaw
|
||||
* reports the watch there as the ring. Faceclaw adds the real device to the
|
||||
* event's raw JSON as `faceclawInputSource`, and this function reads it. Pass
|
||||
* the event object your `onEvenHubEvent` handler receives.
|
||||
*
|
||||
* Faceclaw adds the field to clicks, double-clicks, long-presses and their
|
||||
* releases, and scrolls, in both `sysEvent` and `listEvent`. It is missing when
|
||||
* the glasses don't report a scroll's source, on non-gesture events, and in
|
||||
* every other host.
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* bridge.onEvenHubEvent((event) => {
|
||||
* if (event.sysEvent && getInputSource(event) === "watch") {
|
||||
* // ...
|
||||
* }
|
||||
* });
|
||||
* ```
|
||||
*
|
||||
* @group Input
|
||||
*/
|
||||
export function getInputSource(event: { jsonData?: Record<string, unknown> } | null | undefined): InputSource | null {
|
||||
const value = event?.jsonData?.faceclawInputSource;
|
||||
return value === "ring" || value === "left-touchpad" || value === "right-touchpad" || value === "watch" ? value : null;
|
||||
}
|
||||
|
||||
// ---- Text input ----
|
||||
|
||||
/**
|
||||
* Text sent to the app, from {@link FaceclawExtensions.addTextInputListener}.
|
||||
*
|
||||
* @group Text input
|
||||
*/
|
||||
export interface TextInputEvent {
|
||||
/** The finished text: a whole dictation, or a typed entry. */
|
||||
text: string;
|
||||
/**
|
||||
* Present when the sender said whether to submit the text (`true`, like
|
||||
* pressing Enter after it) or only insert it (`false`). Faceclaw's
|
||||
* remote-input tool sets it; dictation and the phone keyboard leave it out.
|
||||
*/
|
||||
submit?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* A magnetometer heading sample from {@link FaceclawExtensions.addCompassListener}.
|
||||
* All headings are in degrees clockwise, in the range [0, 360).
|
||||
@@ -120,6 +221,78 @@ export interface CompassReading {
|
||||
trueHeadingDegrees?: number;
|
||||
}
|
||||
|
||||
// ---- Fonts ----
|
||||
|
||||
/**
|
||||
* A font for text and list containers in an extended layout, from
|
||||
* {@link FaceclawLayout.font} and the containers' own `font`. A container
|
||||
* that has no font, and whose layout has none, uses the stock firmware font.
|
||||
*
|
||||
* Available families (see {@link FaceclawExtensions.getFonts}):
|
||||
*
|
||||
* - `Roboto`, `Inter`, `Montserrat` and `Roboto Mono`: bundled TrueType
|
||||
* fonts in weights 300, 400 and 700, at any size.
|
||||
* - `Terminus`: a monospace bitmap font, in sizes 12, 14, 16, 18, 20, 22, 24,
|
||||
* 28 and 32, and weights 400 and 700.
|
||||
* - `EvenHub`: the stock firmware font, 20px only. Use it to bring back the
|
||||
* stock font for one container when the layout sets another.
|
||||
* - Any font the user has installed in Faceclaw.
|
||||
*
|
||||
* Text in the stock font wraps exactly as on the stock firmware. Text in
|
||||
* other fonts wraps with Faceclaw's own line breaking.
|
||||
*
|
||||
* @group Fonts
|
||||
*/
|
||||
export interface FaceclawFont {
|
||||
/**
|
||||
* Font family, matched without regard to case, spaces or punctuation. An
|
||||
* unknown family falls back to Roboto.
|
||||
* @defaultValue "Roboto"
|
||||
*/
|
||||
family?: string;
|
||||
/**
|
||||
* Size in pixels: the em size, as in CSS `font-size`. A line is somewhat
|
||||
* taller; {@link FaceclawExtensions.measureText} reports its height. 6–128.
|
||||
* Bitmap families use their nearest size.
|
||||
* @defaultValue 20
|
||||
*/
|
||||
size?: number;
|
||||
/**
|
||||
* Weight, 100–900, where `"normal"` is 400 and `"bold"` is 700. The nearest
|
||||
* weight the family has is used, as CSS chooses it.
|
||||
* @defaultValue 400
|
||||
*/
|
||||
weight?: number | "normal" | "bold";
|
||||
}
|
||||
|
||||
/**
|
||||
* A font family Faceclaw can draw, from {@link FaceclawExtensions.getFonts}.
|
||||
*
|
||||
* @group Fonts
|
||||
*/
|
||||
export interface FaceclawFontFamily {
|
||||
/** The name to use as {@link FaceclawFont.family}. */
|
||||
family: string;
|
||||
/** The weights the family has, lightest first. */
|
||||
weights: number[];
|
||||
/** For a bitmap family, the sizes it has. Absent for a scalable family, which takes any size. */
|
||||
sizes?: number[];
|
||||
/** Whether every character has the same width. */
|
||||
monospace: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* The size of some text, from {@link FaceclawExtensions.measureText}.
|
||||
*
|
||||
* @group Fonts
|
||||
*/
|
||||
export interface TextMeasurement {
|
||||
/** Width in pixels of the widest line (lines are split at `\n`). */
|
||||
width: number;
|
||||
/** Height in pixels of one line. A text container advances by this much per line. */
|
||||
lineHeight: number;
|
||||
}
|
||||
|
||||
// ---- Extended layout (a superset of the stock EvenHub page containers) ----
|
||||
|
||||
/**
|
||||
@@ -185,6 +358,12 @@ export interface FaceclawTextContainer extends FaceclawContainerCommon {
|
||||
borderRadius?: number;
|
||||
/** Padding between the border and the text, in pixels. */
|
||||
paddingLength?: number;
|
||||
/**
|
||||
* The text's font. Its fields override the layout's
|
||||
* {@link FaceclawLayout.font} one by one. With neither, the text is in the
|
||||
* stock firmware font.
|
||||
*/
|
||||
font?: FaceclawFont;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -233,6 +412,13 @@ export interface FaceclawListContainer extends FaceclawContainerCommon {
|
||||
borderRadius?: number;
|
||||
/** Padding between the border and the items, in pixels. */
|
||||
paddingLength?: number;
|
||||
/**
|
||||
* The items' font. Its fields override the layout's
|
||||
* {@link FaceclawLayout.font} one by one. With neither, the items are in
|
||||
* the stock firmware font. Each row is the font's line height plus 12
|
||||
* pixels.
|
||||
*/
|
||||
font?: FaceclawFont;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -262,6 +448,8 @@ export interface FaceclawMenu {
|
||||
* - Each container may set `preserve: true` to inherit its content from the
|
||||
* same-named container in the previous layout.
|
||||
*
|
||||
* Text and list containers can also use other fonts (see {@link FaceclawFont}).
|
||||
*
|
||||
* @group Extended layout
|
||||
*/
|
||||
export interface FaceclawLayout {
|
||||
@@ -275,6 +463,8 @@ export interface FaceclawLayout {
|
||||
menuObject?: FaceclawMenu;
|
||||
/** Accepted for compatibility with stock payloads and ignored: there is no container limit. */
|
||||
containerTotalNum?: number;
|
||||
/** The default font for every text and list container in the layout. */
|
||||
font?: FaceclawFont;
|
||||
}
|
||||
|
||||
// ---- Voice-assistant tools ----
|
||||
@@ -445,6 +635,82 @@ export interface FaceclawExtensions {
|
||||
* @param tools - The tools to offer. Pass `[]` to remove them all.
|
||||
*/
|
||||
setAssistantTools(tools: AssistantTool[]): void;
|
||||
|
||||
/**
|
||||
* Receive touch-downs: the moment a finger touches the ring or the watch's
|
||||
* touchpad, before Faceclaw knows whether it will become a tap, a scroll or
|
||||
* a hold. The interpreted gesture still arrives afterwards as the usual
|
||||
* stock event. Use it where latency matters, as in games.
|
||||
*
|
||||
* Touch-downs arrive only while the app's window has input focus. The
|
||||
* glasses' own touchpads don't report them.
|
||||
*
|
||||
* @param listener - Called on each touch-down.
|
||||
* @returns A function that unsubscribes `listener`.
|
||||
*/
|
||||
addTouchDownListener(listener: (event: TouchDownEvent) => void): () => void;
|
||||
|
||||
/**
|
||||
* Receive text the user sends to the app. While at least one listener is
|
||||
* registered and the app is in the foreground, Faceclaw offers the app as
|
||||
* the "Type Into App" destination of its voice dialog, the phone keyboard
|
||||
* and the watch.
|
||||
*
|
||||
* @param listener - Called with each piece of text.
|
||||
* @returns A function that unsubscribes `listener`.
|
||||
*/
|
||||
addTextInputListener(listener: (event: TextInputEvent) => void): () => void;
|
||||
|
||||
/**
|
||||
* Open Faceclaw's voice dialog for this app. When the user sends the
|
||||
* dictation with Type Into App, it arrives at the text-input listeners.
|
||||
*
|
||||
* @returns A promise that resolves to true if the dialog is opening, or
|
||||
* false if it can't open: there is no text-input listener, the app isn't
|
||||
* in the foreground, voice input is unavailable, or another dialog is up.
|
||||
*/
|
||||
startVoiceInput(): Promise<boolean>;
|
||||
|
||||
/**
|
||||
* Replace the app's icon in the app switcher, or pass `null` to go back to
|
||||
* the package's icon. See {@link WindowIconImage} for the format.
|
||||
*
|
||||
* @returns A promise that resolves once the icon is set, and rejects if the
|
||||
* image is malformed or larger than 256×256.
|
||||
*/
|
||||
setWindowIcon(icon: WindowIconImage | null): Promise<void>;
|
||||
|
||||
/**
|
||||
* Show or clear the attention dot on the app's switcher icon, for example
|
||||
* when something new arrives while the app is in the background. The dot
|
||||
* stays until the app clears it or closes.
|
||||
*/
|
||||
setAttention(attention: boolean): void;
|
||||
|
||||
/**
|
||||
* Stop the glasses display from turning off for inactivity while the app is
|
||||
* in the foreground, as a teleprompter or navigation app needs. It has no
|
||||
* effect while another window is in front, and the user can still turn the
|
||||
* display off. Pass `false` to restore the normal timeout.
|
||||
*/
|
||||
setKeepScreenOn(keepOn: boolean): void;
|
||||
|
||||
/**
|
||||
* List the font families available for {@link FaceclawFont.family},
|
||||
* including any the user has installed.
|
||||
*/
|
||||
getFonts(): Promise<FaceclawFontFamily[]>;
|
||||
|
||||
/**
|
||||
* Measure text as a container with this font would draw it, for example to
|
||||
* size a text container or centre a label.
|
||||
*
|
||||
* @param text - The text. Lines split at `\n` are measured separately.
|
||||
* @param font - The font to measure in. Unlike a container's font, it
|
||||
* isn't combined with a layout default. Omit it to measure in the stock
|
||||
* font.
|
||||
*/
|
||||
measureText(text: string, font?: FaceclawFont): Promise<TextMeasurement>;
|
||||
}
|
||||
|
||||
declare global {
|
||||
|
||||
@@ -10,9 +10,12 @@ import {
|
||||
MenuItemProperty,
|
||||
RebuildPageContainer,
|
||||
TextContainerProperty,
|
||||
type EvenHubEvent,
|
||||
} from "@evenrealities/even_hub_sdk";
|
||||
import { getInputSource } from "../src/index";
|
||||
import type {
|
||||
FaceclawExtensions,
|
||||
InputSource,
|
||||
FaceclawImageContainer,
|
||||
FaceclawLayout,
|
||||
FaceclawListContainer,
|
||||
@@ -62,3 +65,12 @@ void fc.createLayout(fromCreate);
|
||||
void fc.replaceLayout(fromRebuild);
|
||||
void fc.replaceLayout(mixed);
|
||||
void fc.replaceLayout(new RebuildPageContainer({ textObject: [new TextContainerProperty({ containerID: 1 })] }));
|
||||
|
||||
// The stock event the SDK hands onEvenHubEvent carries the source field.
|
||||
declare const stockEvent: EvenHubEvent;
|
||||
const source: InputSource | null = getInputSource(stockEvent);
|
||||
void source;
|
||||
|
||||
// A canvas ImageData is accepted as a window icon.
|
||||
declare const imageData: ImageData;
|
||||
void fc.setWindowIcon(imageData);
|
||||
@@ -18,11 +18,14 @@
|
||||
"treatWarningsAsErrors": true,
|
||||
"groupOrder": [
|
||||
"Entry point",
|
||||
"Window lifecycle",
|
||||
"Window",
|
||||
"Input",
|
||||
"Text input",
|
||||
"Extended layout",
|
||||
"Fonts",
|
||||
"API keys",
|
||||
"Buzzer",
|
||||
"Compass",
|
||||
"Extended layout",
|
||||
"Assistant tools",
|
||||
"Properties",
|
||||
"Methods",
|
||||
|
||||
Reference in new issue
Block a user