forked from Blendman974/faceclaw
Introduce oxlint, and fix lint warnings
This commit is contained in:
1 parent
cb6dddd120
commit
06146c2b08
89 files changed
+818
-469
No files matched your search
@@ -108,6 +108,7 @@ class AiChatLayer implements Layer {
|
||||
return;
|
||||
case "long-press-release": this.draft.release(); return;
|
||||
case "double-click": this.draft.cancel(); shell.yieldFocusToSidebar(); return;
|
||||
default: return;
|
||||
}
|
||||
}
|
||||
menuItems(): MenuItem[] {
|
||||
@@ -123,20 +124,20 @@ class AiChatLayer implements Layer {
|
||||
{ label: "Switch session", disabled: () => external || busy(), onSelect: (ctx) => submenu(ctx, "Sessions",
|
||||
[...this.conversations.list()].reverse().map((item) => ({
|
||||
label: `${item.id === record.id ? "✓ " : ""}${this.conversations.title(item)}`,
|
||||
onSelect: (ctx) => { if (this.conversations.select(item.id)) ctx.stack.clearToBase(); },
|
||||
onSelect: (pickCtx) => { if (this.conversations.select(item.id)) pickCtx.stack.clearToBase(); },
|
||||
}))) },
|
||||
{ label: `Model: ${assistantModelLabel(record.model)}`, disabled: () => external || busy(), onSelect: (ctx) => submenu(ctx, "Model",
|
||||
ASSISTANT_MODEL_CHOICES.map((model) => ({
|
||||
label: `${model === record.model ? "✓ " : ""}${assistantModelLabel(model)}`,
|
||||
disabled: () => !this.conversations.available(model, record.reasoning),
|
||||
onSelect: (ctx) => { if (this.conversations.configure(model, record.reasoning)) ctx.stack.clearToBase(); },
|
||||
onSelect: (pickCtx) => { if (this.conversations.configure(model, record.reasoning)) pickCtx.stack.clearToBase(); },
|
||||
}))) },
|
||||
{ label: `Reasoning: ${record.reasoning}`, disabled: () => {
|
||||
const llm = resolveAssistantModel(record.model, { anthropic: anthropicApiKeySetting.get(), openai: openAiApiKeySetting.get() });
|
||||
return external || busy() || !llm?.effort;
|
||||
}, onSelect: (ctx) => submenu(ctx, "Reasoning", (["default", "low", "medium", "high"] as ReasoningLevel[]).map((reasoning) => ({
|
||||
label: `${reasoning === record.reasoning ? "✓ " : ""}${reasoning === "default" ? "Model default" : reasoning}`,
|
||||
onSelect: (ctx) => { if (this.conversations.configure(record.model, reasoning)) ctx.stack.clearToBase(); },
|
||||
onSelect: (pickCtx) => { if (this.conversations.configure(record.model, reasoning)) pickCtx.stack.clearToBase(); },
|
||||
}))) },
|
||||
...(record.session?.isTurnActive() ? [{ label: "Cancel response", onSelect: (ctx: LayerContext) => {
|
||||
record.session?.cancel(); ctx.stack.clearToBase();
|
||||
|
||||
@@ -284,6 +284,11 @@ global.onmessage = (event: { data: WorkerAppMessage }) => {
|
||||
updateTickTimer(window);
|
||||
}
|
||||
break;
|
||||
case "navigation-sensors":
|
||||
case "resize-window":
|
||||
case "text-input":
|
||||
case "tool-call":
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -349,7 +354,7 @@ function handleInput(window: BlocksWindow, event: InputEvent, frameId: number):
|
||||
// An open window menu owns all input (it closes itself via pop); menus are
|
||||
// list UIs, so watch swipes take their standard fallback meanings there.
|
||||
if (window.menu?.isOpen()) {
|
||||
window.menu
|
||||
void window.menu
|
||||
.handleInput(directionalFallback(event))
|
||||
.catch((error) => console.error(`blocks menu input failed: ${error}`))
|
||||
.then(() => renderAndSubmit(window, frameId));
|
||||
@@ -605,7 +610,7 @@ function paintContent(window: BlocksWindow): GrayImage {
|
||||
drawCenteredIn(image, smallFont, BOARD_X, COLS * CELL, BOARD_Y + 150, `${GESTURE_DOUBLE_CLICK} leave`, 150);
|
||||
} else {
|
||||
paintBoard(image, window);
|
||||
if (window.phase === "game-over") paintGameOver(image, window);
|
||||
if (window.phase === "game-over") paintGameOver(image);
|
||||
}
|
||||
paintPanel(image, window);
|
||||
return image;
|
||||
@@ -637,7 +642,7 @@ function drawCell(image: GrayImage, x: number, y: number, shade: number): void {
|
||||
image.fillRect(BOARD_X + x * CELL, BOARD_Y + y * CELL, CELL - 1, CELL - 1, shade);
|
||||
}
|
||||
|
||||
function paintGameOver(image: GrayImage, window: BlocksWindow): void {
|
||||
function paintGameOver(image: GrayImage): void {
|
||||
const boxY = BOARD_Y + 70;
|
||||
image.fillRect(BOARD_X, boxY, COLS * CELL, 100, 0);
|
||||
image.drawRect(BOARD_X + 4, boxY + 4, COLS * CELL - 8, 92, 150);
|
||||
|
||||
@@ -96,8 +96,7 @@ export function createCalculatorAppWindow(options: InProcessAppOptions): InProce
|
||||
},
|
||||
];
|
||||
|
||||
let app: InProcessWindow;
|
||||
app = createInProcessWindow({
|
||||
const app = createInProcessWindow({
|
||||
appId: "calculator",
|
||||
windowId: CALCULATOR_WINDOW_ID,
|
||||
title: "Calculator",
|
||||
|
||||
@@ -24,7 +24,7 @@ import {
|
||||
findDigits,
|
||||
highlightedMatch,
|
||||
} from "./digit-search";
|
||||
import { type MathWorkload, longRunOffer as makeLongRunOffer, type LongRunOffer } from "./workload";
|
||||
import { type MathWorkload } from "./workload";
|
||||
import {
|
||||
binomial,
|
||||
factorizationText,
|
||||
|
||||
@@ -322,7 +322,7 @@ export function digitalRoot(value: number): number {
|
||||
|
||||
export function isPalindrome(value: number): boolean {
|
||||
const text = String(Math.abs(value));
|
||||
return text === [...text].reverse().join("");
|
||||
return text === text.split("").reverse().join("");
|
||||
}
|
||||
|
||||
export function isPerfect(value: number): boolean {
|
||||
|
||||
@@ -123,7 +123,7 @@ export class Polynomial {
|
||||
*/
|
||||
dividingByRoot(root: MathNumber): Polynomial {
|
||||
if (this.degree < 1) return this;
|
||||
const quotient: MathNumber[] = new Array(this.degree).fill(integer(0));
|
||||
const quotient: MathNumber[] = Array.from({ length: this.degree }, () => integer(0));
|
||||
let carry: MathNumber = integer(0);
|
||||
for (let power = this.degree; power >= 1; power--) {
|
||||
const coefficient = add(this.at(power), carry);
|
||||
@@ -235,7 +235,7 @@ function addAt(value: MathNumber, power: number, coefficients: MathNumber[]): vo
|
||||
|
||||
function convolve(lhs: MathNumber[], rhs: MathNumber[]): MathNumber[] {
|
||||
if (lhs.length === 0 || rhs.length === 0) return [integer(0)];
|
||||
const result: MathNumber[] = new Array(lhs.length + rhs.length - 1).fill(integer(0));
|
||||
const result: MathNumber[] = Array.from({ length: lhs.length + rhs.length - 1 }, () => integer(0));
|
||||
for (let i = 0; i < lhs.length; i++) {
|
||||
if (isZero(lhs[i]!)) continue;
|
||||
for (let j = 0; j < rhs.length; j++) {
|
||||
|
||||
@@ -19,7 +19,6 @@ import {
|
||||
multiplyExpr,
|
||||
negate,
|
||||
num,
|
||||
numberValue,
|
||||
relation as relationExpr,
|
||||
spokenRelation,
|
||||
subtractExpr,
|
||||
|
||||
@@ -29,12 +29,12 @@ import {
|
||||
numberEquals,
|
||||
rational,
|
||||
reciprocal,
|
||||
isZero,
|
||||
} from "./math-number";
|
||||
import { simplify } from "./simplifier";
|
||||
import { differentiate, integrateNumeric } from "./derivative";
|
||||
import { evaluateValue } from "./evaluator";
|
||||
import { Polynomial } from "./polynomial";
|
||||
import { isZero } from "./math-number";
|
||||
|
||||
/** Indefinite integral with respect to `variable`, without the constant. */
|
||||
export function integrate(expression: MathExpression, variable: string): MathExpression | null {
|
||||
|
||||
@@ -103,8 +103,7 @@ function render(expression: MathExpression, parentPrecedence: number): string {
|
||||
return wrap(`1/${inner}`, parentPrecedence > PRECEDENCE.product);
|
||||
}
|
||||
const body =
|
||||
`${render(expression.base, PRECEDENCE.power + 1)}` +
|
||||
`^${render(expression.exponent, PRECEDENCE.power + 1)}`;
|
||||
`${render(expression.base, PRECEDENCE.power + 1)}^${render(expression.exponent, PRECEDENCE.power + 1)}`;
|
||||
return wrap(body, parentPrecedence > PRECEDENCE.power);
|
||||
}
|
||||
|
||||
@@ -116,11 +115,7 @@ function render(expression: MathExpression, parentPrecedence: number): string {
|
||||
}
|
||||
|
||||
case "relation":
|
||||
return (
|
||||
`${render(expression.lhs, PRECEDENCE.relation)} ` +
|
||||
`${expression.relation} ` +
|
||||
`${render(expression.rhs, PRECEDENCE.relation)}`
|
||||
);
|
||||
return `${render(expression.lhs, PRECEDENCE.relation)} ${expression.relation} ${render(expression.rhs, PRECEDENCE.relation)}`;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -26,14 +26,14 @@ export type SolutionFamily = {
|
||||
baseExpression: MathExpression | null;
|
||||
};
|
||||
|
||||
export function familyValues(family: SolutionFamily, lower: number, upper: number): number[] {
|
||||
if (family.period <= 0) {
|
||||
return family.base >= lower && family.base <= upper ? [family.base] : [];
|
||||
export function familyValues(solutionFamily: SolutionFamily, lower: number, upper: number): number[] {
|
||||
if (solutionFamily.period <= 0) {
|
||||
return solutionFamily.base >= lower && solutionFamily.base <= upper ? [solutionFamily.base] : [];
|
||||
}
|
||||
const results: number[] = [];
|
||||
let n = Math.floor((lower - family.base) / family.period);
|
||||
let n = Math.floor((lower - solutionFamily.base) / solutionFamily.period);
|
||||
for (;;) {
|
||||
const value = family.base + n * family.period;
|
||||
const value = solutionFamily.base + n * solutionFamily.period;
|
||||
if (value > upper) break;
|
||||
if (value >= lower) results.push(value);
|
||||
n += 1;
|
||||
@@ -42,14 +42,14 @@ export function familyValues(family: SolutionFamily, lower: number, upper: numbe
|
||||
return results;
|
||||
}
|
||||
|
||||
export function familyText(family: SolutionFamily): string {
|
||||
const baseText = family.baseExpression
|
||||
? plain(family.baseExpression)
|
||||
: describeNumber(fromDecimal(family.base));
|
||||
export function familyText(solutionFamily: SolutionFamily): string {
|
||||
const baseText = solutionFamily.baseExpression
|
||||
? plain(solutionFamily.baseExpression)
|
||||
: describeNumber(fromDecimal(solutionFamily.base));
|
||||
// The separator is load-bearing: "2*pi" run straight into the index reads
|
||||
// as "2*pin", a different and nonsensical expression to anyone scanning it
|
||||
// on the lens.
|
||||
const periodText = describePi(family.period);
|
||||
const periodText = describePi(solutionFamily.period);
|
||||
return `${baseText} + ${periodText}·n`;
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,6 @@ export const CALENDAR_SURFACE_ID = "window:calendar";
|
||||
*/
|
||||
export function createCalendarAppWindow(options: InProcessAppOptions): InProcessWindow {
|
||||
let requesting = false;
|
||||
let app: InProcessWindow;
|
||||
let unsubscribe = () => {};
|
||||
let tick: ReturnType<typeof setInterval> | null = null;
|
||||
|
||||
@@ -37,7 +36,7 @@ export function createCalendarAppWindow(options: InProcessAppOptions): InProcess
|
||||
.finally(() => { requesting = false; });
|
||||
};
|
||||
|
||||
app = createInProcessWindow({
|
||||
const app = createInProcessWindow({
|
||||
appId: "calendar",
|
||||
windowId: CALENDAR_WINDOW_ID,
|
||||
title: "Calendar",
|
||||
|
||||
@@ -211,10 +211,9 @@ class CompassLayer implements Layer {
|
||||
}
|
||||
|
||||
export function createCompassAppWindow(options: InProcessAppOptions): InProcessWindow {
|
||||
let app: InProcessWindow;
|
||||
let requestRender = () => {};
|
||||
const layer = new CompassLayer(() => requestRender());
|
||||
app = createInProcessWindow({
|
||||
const app = createInProcessWindow({
|
||||
appId: "compass",
|
||||
windowId: COMPASS_WINDOW_ID,
|
||||
title: "Compass",
|
||||
|
||||
@@ -2,7 +2,7 @@ import { getDefaultMediumFont, getDefaultSmallFont } from "../../graphics/ui-fon
|
||||
import { GrayImage } from "../../graphics/image";
|
||||
import { clamp } from "../../util/numeric-util";
|
||||
import { addImuListener, imuSourceLabel, setImuReportEnabled, type ImuReading } from "../../native/imu";
|
||||
import { GESTURE_DOUBLE_CLICK, type InputEvent } from "../../ui/gestures";
|
||||
import { type InputEvent } from "../../ui/gestures";
|
||||
import { Layer, type LayerContext } from "../../ui/layers";
|
||||
import { shell } from "../../ui/shell/shell";
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { getDefaultSmallFont } from "../../graphics/ui-fonts";
|
||||
import { GrayImage } from "../../graphics/image";
|
||||
import { Layer, type LayerActions, type LayerContext } from "../../ui/layers";
|
||||
import { GESTURE_CLICK, GESTURE_DOUBLE_CLICK, GESTURE_SCROLL, type InputEvent } from "../../ui/gestures";
|
||||
import { GESTURE_CLICK, type InputEvent } from "../../ui/gestures";
|
||||
import { Menu, type MenuDrawArgs } from "../../ui/menu-core";
|
||||
import { centeredTextY, tightRowHeight } from "../../ui/metrics";
|
||||
import {
|
||||
|
||||
@@ -64,6 +64,8 @@ export class ScreenTestLayer implements Layer {
|
||||
case "double-click":
|
||||
ctx.stack.pop();
|
||||
return;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -236,6 +236,8 @@ export class UnicodeSampleLayer implements Layer {
|
||||
case "double-click":
|
||||
ctx.stack.pop();
|
||||
return;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Application } from "@nativescript/core";
|
||||
import { Utils } from "@nativescript/core";
|
||||
|
||||
export function hmacSha256Base64(secret: string, message: string): string {
|
||||
const charset = java.nio.charset.StandardCharsets.UTF_8;
|
||||
@@ -10,7 +10,7 @@ export function hmacSha256Base64(secret: string, message: string): string {
|
||||
}
|
||||
|
||||
export function getPhoneOpenUdid(): string {
|
||||
const resolver = Application.android.context?.getContentResolver();
|
||||
const resolver = Utils.android.getApplicationContext()?.getContentResolver();
|
||||
const id = resolver ? String(android.provider.Settings.Secure.getString(resolver, android.provider.Settings.Secure.ANDROID_ID) ?? "") : "";
|
||||
if (!id) throw new Error("Android did not provide a device ID for EvenHub authentication.");
|
||||
return id;
|
||||
|
||||
@@ -22,7 +22,7 @@ export type EvenHubPermissionName =
|
||||
| "album"
|
||||
| "camera"
|
||||
| "fs"
|
||||
| string;
|
||||
| (string & {});
|
||||
|
||||
export type EvenHubPermission = {
|
||||
name: EvenHubPermissionName;
|
||||
|
||||
@@ -1177,7 +1177,7 @@ export class EvenHubSession implements EvenHubMicClient, EvenHubImuClient, EvenH
|
||||
}
|
||||
return out;
|
||||
};
|
||||
if (requested.length === 0 || requested.every((id) => this.grantedApiKeys.has(id))) {
|
||||
if (requested.every((id) => this.grantedApiKeys.has(id))) {
|
||||
return Promise.resolve(buildGrant());
|
||||
}
|
||||
if (!this.windowHooks) return Promise.resolve({});
|
||||
|
||||
@@ -73,7 +73,7 @@ export async function checkForEvenHubUpdates(
|
||||
onProgress?: (done: number, total: number) => void,
|
||||
): Promise<EvenHubAppUpdate[]> {
|
||||
const installed = getInstalledEvenHubApps();
|
||||
const results: EvenHubAppUpdate[] = new Array(installed.length);
|
||||
const results: EvenHubAppUpdate[] = [];
|
||||
let next = 0;
|
||||
let done = 0;
|
||||
const worker = async () => {
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import { type BdfFont } from "../../graphics/bdffont";
|
||||
import { getDefaultSmallFont } from "../../graphics/ui-fonts";
|
||||
import { truncateText } from "../../graphics/textwrap";
|
||||
import { GrayImage } from "../../graphics/image";
|
||||
|
||||
@@ -287,6 +287,10 @@ global.onmessage = (event: { data: WorkerAppMessage }) => {
|
||||
syncTickTimer(window);
|
||||
}
|
||||
break;
|
||||
case "navigation-sensors":
|
||||
case "text-input":
|
||||
case "tool-call":
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -383,7 +387,7 @@ function handleInput(window: FlappyWindow, event: InputEvent, frameId: number):
|
||||
// An open window menu owns all input (it closes itself via pop); menus are
|
||||
// list UIs, so watch swipes take their standard fallback meanings there.
|
||||
if (window.menu?.isOpen()) {
|
||||
window.menu
|
||||
void window.menu
|
||||
.handleInput(directionalFallback(event))
|
||||
.catch((error) => console.error(`flappy menu input failed: ${error}`))
|
||||
.then(() => renderAndSubmit(window, frameId));
|
||||
@@ -728,6 +732,9 @@ function paintHud(image: GrayImage, window: FlappyWindow): void {
|
||||
`${GESTURE_CLICK} new game ${GESTURE_DOUBLE_CLICK} leave`,
|
||||
]);
|
||||
break;
|
||||
case "playing":
|
||||
case "dying":
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -58,9 +58,6 @@ function rankOf(card: number): number {
|
||||
function isRed(card: number): boolean {
|
||||
return (card & 1) === 1;
|
||||
}
|
||||
function cardLabel(card: number): string {
|
||||
return RANK_CHARS[rankOf(card)]! + SUIT_CHARS[suitOf(card)]!;
|
||||
}
|
||||
|
||||
const CARD_W = 60;
|
||||
const CARD_H = 36;
|
||||
@@ -208,6 +205,13 @@ global.onmessage = (event: { data: WorkerAppMessage }) => {
|
||||
if (window.foreground) renderAndSubmit(window, 0);
|
||||
break;
|
||||
}
|
||||
case "input-focus":
|
||||
case "navigation-sensors":
|
||||
case "resize-window":
|
||||
case "screen":
|
||||
case "text-input":
|
||||
case "tool-call":
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -285,7 +289,7 @@ function handleInput(window: FreecellWindow, event: InputEvent, frameId: number)
|
||||
// An open window menu owns all input (it closes itself via pop); menus are
|
||||
// list UIs, so watch swipes take their standard fallback meanings there.
|
||||
if (window.menu?.isOpen()) {
|
||||
window.menu
|
||||
void window.menu
|
||||
.handleInput(directionalFallback(event))
|
||||
.catch((error) => console.error(`freecell menu input failed: ${error}`))
|
||||
.then(() => renderAndSubmit(window, frameId));
|
||||
@@ -792,7 +796,6 @@ function paintCard(
|
||||
if (selected) image.drawRoundedRect(x + 1, y + 1, CARD_W - 2, CARD_H - 2, 255, 3);
|
||||
const rankText: string = RANK_CHARS[rankOf(card)]!
|
||||
const suitText: string = SUIT_CHARS[suitOf(card)]!;
|
||||
const labelText = rankText + suitText;
|
||||
image.drawText(labelFont, x + 5, y, rankText, 255);
|
||||
image.drawText(suitFont, x + 5 + labelFont.measureText(rankText), y + 3, suitText, 150);
|
||||
if (isRed(card)) {
|
||||
|
||||
@@ -344,7 +344,6 @@ class GlancePreviewLayer implements Layer {
|
||||
export function createGlanceboardAppWindow(options: InProcessAppOptions): InProcessWindow {
|
||||
let previewVisible = false;
|
||||
const heightMode = () => previewVisible && glanceLayoutSetting.get() === "2x3" ? "max" as const : "medium" as const;
|
||||
let unsubscribeSettings: (() => void) | undefined;
|
||||
const app = createInProcessWindow({
|
||||
appId: "glanceboard",
|
||||
windowId: GLANCEBOARD_WINDOW_ID,
|
||||
@@ -367,10 +366,10 @@ export function createGlanceboardAppWindow(options: InProcessAppOptions): InProc
|
||||
removeSurface: options.removeSurface,
|
||||
reconfigureSurface: options.reconfigureSurface,
|
||||
onClosed: () => {
|
||||
unsubscribeSettings?.();
|
||||
unsubscribeSettings();
|
||||
options.onClosed();
|
||||
},
|
||||
});
|
||||
unsubscribeSettings = onAnySettingChanged(() => app.setHeightMode(heightMode()));
|
||||
const unsubscribeSettings = onAnySettingChanged(() => app.setHeightMode(heightMode()));
|
||||
return app;
|
||||
}
|
||||
@@ -16,7 +16,7 @@ export const GLANCE_WIDGETS: readonly GlanceWidgetDefinition[] = [
|
||||
{ id: "music", label: "Music", create: () => new MusicWidget() },
|
||||
];
|
||||
|
||||
export function findGlanceWidget(id: GlanceWidgetId | string): GlanceWidgetDefinition | null {
|
||||
export function findGlanceWidget(id: GlanceWidgetId | (string & {})): GlanceWidgetDefinition | null {
|
||||
return GLANCE_WIDGETS.find((widget) => widget.id === id) ?? null;
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ const BOTTOM_MARGIN = 2;
|
||||
* once the snapshot is in.
|
||||
*/
|
||||
export class TerminalWidget implements GlanceWidget {
|
||||
private snapshot: TerminalSessionsSnapshot | undefined = readWorkerState(TERMINAL_SESSIONS_STATE_KEY);
|
||||
private snapshot = readWorkerState(TERMINAL_SESSIONS_STATE_KEY) as TerminalSessionsSnapshot | undefined;
|
||||
private unsubscribe: (() => void) | null = null;
|
||||
private requestRender: (() => void) | null = null;
|
||||
private phase = 0;
|
||||
@@ -34,9 +34,9 @@ export class TerminalWidget implements GlanceWidget {
|
||||
|
||||
start(requestRender: () => void): void {
|
||||
this.requestRender = requestRender;
|
||||
this.snapshot = readWorkerState(TERMINAL_SESSIONS_STATE_KEY);
|
||||
this.unsubscribe = onWorkerStateChanged<TerminalSessionsSnapshot>(TERMINAL_SESSIONS_STATE_KEY, (snapshot) => {
|
||||
this.snapshot = snapshot;
|
||||
this.snapshot = readWorkerState(TERMINAL_SESSIONS_STATE_KEY) as TerminalSessionsSnapshot | undefined;
|
||||
this.unsubscribe = onWorkerStateChanged(TERMINAL_SESSIONS_STATE_KEY, (snapshot) => {
|
||||
this.snapshot = snapshot as TerminalSessionsSnapshot;
|
||||
this.syncAnimation();
|
||||
requestRender();
|
||||
});
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import { type BdfFont } from "../../graphics/bdffont";
|
||||
import { getDefaultSmallFont } from "../../graphics/ui-fonts";
|
||||
import { truncateText } from "../../graphics/textwrap";
|
||||
import { GrayImage } from "../../graphics/image";
|
||||
|
||||
@@ -57,7 +57,7 @@ export function loadMicConfig(): MicConfig {
|
||||
return {
|
||||
...defaults,
|
||||
...parsed,
|
||||
hostMics: { ...defaults.hostMics, ...(parsed.hostMics ?? {}) },
|
||||
hostMics: { ...defaults.hostMics, ...parsed.hostMics },
|
||||
};
|
||||
} catch {
|
||||
return defaultMicConfig();
|
||||
@@ -72,8 +72,8 @@ class MicArrayController {
|
||||
private readonly statusListeners = new Set<(statuses: MicArrayStatuses) => void>();
|
||||
private statuses: MicArrayStatuses = { left: null, right: null };
|
||||
// The Java listener proxy must stay referenced or it gets GC'd.
|
||||
private statusProxy: any | null = null;
|
||||
private proxyCommunicator: any | null = null;
|
||||
private statusProxy: any = null;
|
||||
private proxyCommunicator: any = null;
|
||||
private leaseTimer: ReturnType<typeof setInterval> | null = null;
|
||||
private armed = false;
|
||||
|
||||
|
||||
@@ -16,7 +16,6 @@ import {
|
||||
type HeadOrientation,
|
||||
} from "./dsp";
|
||||
import { micArrayController, micControlSupported, loadMicConfig, saveMicConfig } from "./mic-control";
|
||||
import type { MicConfig } from "./mic-protocol";
|
||||
import { micModelPath } from "./mic-models";
|
||||
import {
|
||||
MIC_CHANNEL_KEYS,
|
||||
@@ -27,6 +26,7 @@ import {
|
||||
splitConcatenatedPcm16,
|
||||
templeActive,
|
||||
type MicChannelKey,
|
||||
type MicConfig,
|
||||
type MicSide,
|
||||
} from "./mic-protocol";
|
||||
import {
|
||||
@@ -158,8 +158,8 @@ class MicSession {
|
||||
|
||||
// Captions state.
|
||||
private captionLines: CaptionLine[] = [];
|
||||
private captionEngine: any | null = null;
|
||||
private captionListenerProxy: any | null = null;
|
||||
private captionEngine: any = null;
|
||||
private captionListenerProxy: any = null;
|
||||
private captionsActive = false;
|
||||
private engineStartWallMs = 0;
|
||||
private sessionRowId = -1;
|
||||
@@ -168,7 +168,7 @@ class MicSession {
|
||||
private conversationLang = "und";
|
||||
|
||||
// Recording state.
|
||||
private recorder: any | null = null;
|
||||
private recorder: any = null;
|
||||
private recordingPath = "";
|
||||
|
||||
// Stock path subscriptions.
|
||||
@@ -177,7 +177,7 @@ class MicSession {
|
||||
private offCompass: (() => void) | null = null;
|
||||
|
||||
// Extended path.
|
||||
private forwardingProxy: any | null = null;
|
||||
private forwardingProxy: any = null;
|
||||
private temples = new Map<MicSide, TempleAudioPipeline>();
|
||||
private templeAngles: { left: number | null; right: number | null } = { left: null, right: null };
|
||||
private templeSsr: { left: number; right: number } = { left: 0, right: 0 };
|
||||
@@ -193,7 +193,7 @@ class MicSession {
|
||||
private offVoiceActivity: (() => void) | null = null;
|
||||
|
||||
// Phone-side spectral noise suppressor (FaceclawNoiseSuppressor).
|
||||
private suppressor: any | null = null;
|
||||
private suppressor: any = null;
|
||||
private suppressorEngine = "";
|
||||
|
||||
// True between the caption engine's speech-start event and the utterance
|
||||
|
||||
@@ -8,7 +8,7 @@ declare const java: any;
|
||||
* translation to the phone's default language beneath it.
|
||||
*/
|
||||
|
||||
let languageIdentifier: any | null = null;
|
||||
let languageIdentifier: any = null;
|
||||
// Translators are expensive to build (model download on first use); cache by
|
||||
// "src>dst" and keep the proxies referenced so they aren't GC'd mid-flight.
|
||||
const translators = new Map<string, any>();
|
||||
@@ -59,7 +59,7 @@ export function identifyLanguage(text: string): Promise<string> {
|
||||
});
|
||||
}
|
||||
|
||||
function translatorFor(sourceLang: string, targetLang: string): any | null {
|
||||
function translatorFor(sourceLang: string, targetLang: string): any {
|
||||
const key = `${sourceLang}>${targetLang}`;
|
||||
const cached = translators.get(key);
|
||||
if (cached) return cached;
|
||||
|
||||
@@ -250,6 +250,11 @@ global.onmessage = (event: { data: WorkerAppMessage }) => {
|
||||
syncClock(window);
|
||||
}
|
||||
break;
|
||||
case "navigation-sensors":
|
||||
case "resize-window":
|
||||
case "text-input":
|
||||
case "tool-call":
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -350,7 +355,7 @@ function handleInput(window: MinesweeperWindow, event: InputEvent, frameId: numb
|
||||
// An open window menu owns all input (it closes itself via pop); menus are
|
||||
// list UIs, so watch swipes take their standard fallback meanings there.
|
||||
if (window.menu?.isOpen()) {
|
||||
window.menu
|
||||
void window.menu
|
||||
.handleInput(directionalFallback(event))
|
||||
.catch((error) => console.error(`minesweeper menu input failed: ${error}`))
|
||||
.then(() => renderAndSubmit(window, frameId));
|
||||
|
||||
@@ -63,7 +63,16 @@ import {
|
||||
GESTURE_SHORT_THEN_LONG_PRESS,
|
||||
type InputEvent,
|
||||
} from "../../ui/gestures";
|
||||
import { LocationTracker, type TrackedLocation } from "./navigation-sensors";
|
||||
import {
|
||||
addCompassListener,
|
||||
COMPASS_CHANGED,
|
||||
handleNavigationSensorEvent,
|
||||
LocationTracker,
|
||||
magneticDeclinationDegrees,
|
||||
setCompassEnabled,
|
||||
type CompassEvent,
|
||||
type TrackedLocation,
|
||||
} from "./navigation-sensors";
|
||||
import {
|
||||
fetchRoute,
|
||||
fetchStaticMapGray,
|
||||
@@ -75,14 +84,11 @@ import {
|
||||
type RouteProfile,
|
||||
type StaticMapCamera,
|
||||
} from "../../native/mapbox";
|
||||
import { addCompassListener, COMPASS_CHANGED, setCompassEnabled, type CompassEvent } from "./navigation-sensors";
|
||||
import { magneticDeclinationDegrees, handleNavigationSensorEvent } from "./navigation-sensors";
|
||||
import { calibrateHeading, normalizeHeading } from "../compass/calibration";
|
||||
import { bearingDegrees, haversineMeters, RouteFollower, type RouteProgress } from "./route-follower";
|
||||
import { drawManeuverGlyph } from "./maneuver-icons";
|
||||
|
||||
declare const global: any;
|
||||
declare const com: any;
|
||||
|
||||
const MAP_SIZE = 260;
|
||||
const PANEL_X = MAP_SIZE + 10;
|
||||
@@ -376,6 +382,8 @@ global.onmessage = (event: { data: WorkerAppMessage }) => {
|
||||
);
|
||||
break;
|
||||
}
|
||||
case "input-focus":
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -914,7 +922,7 @@ function describeRouteStatus(): string {
|
||||
* display and saved-destination settings (Home, Work, custom named places), and the
|
||||
* recent-destinations preference.
|
||||
*/
|
||||
function windowMenuItems(win: NavWindow): MenuItem[] {
|
||||
function windowMenuItems(): MenuItem[] {
|
||||
const items: MenuItem[] = [];
|
||||
if (phase !== "idle") {
|
||||
items.push({
|
||||
@@ -993,15 +1001,15 @@ function savedDestinationMenuItems(): MenuItem[] {
|
||||
const work = saved.find((d) => d.id === WORK_DESTINATION_ID);
|
||||
items.push(addressMenuItem("Home", HOME_DESTINATION_ID, home?.address ?? ""));
|
||||
items.push(addressMenuItem("Work", WORK_DESTINATION_ID, work?.address ?? ""));
|
||||
for (const destination of saved) {
|
||||
if (destination.builtin) continue;
|
||||
for (const dest of saved) {
|
||||
if (dest.builtin) continue;
|
||||
items.push({
|
||||
label: destination.name,
|
||||
label: dest.name,
|
||||
onSelect: (ctx) => {
|
||||
ctx.stack.push(new WindowMenuLayer(destination.name, customDestinationMenuItems(destination)));
|
||||
ctx.stack.push(new WindowMenuLayer(dest.name, customDestinationMenuItems(dest)));
|
||||
},
|
||||
render: ({ image, x, y, width, height }) => {
|
||||
drawAddressRow(image, x, y, width, destination.name, destination.address, true);
|
||||
drawAddressRow(image, x, y, width, dest.name, dest.address, true);
|
||||
drawSubmenuIndicator(image, smallFont, x - 10, y, width + 20, height, 150);
|
||||
},
|
||||
});
|
||||
@@ -1028,14 +1036,14 @@ function addressMenuItem(label: string, id: string, address: string): MenuItem {
|
||||
};
|
||||
}
|
||||
|
||||
function customDestinationMenuItems(destination: SavedDestination): MenuItem[] {
|
||||
function customDestinationMenuItems(dest: SavedDestination): MenuItem[] {
|
||||
return [
|
||||
{
|
||||
label: "Navigate there",
|
||||
disabled: !destination.address,
|
||||
disabled: !dest.address,
|
||||
onSelect: (ctx) => {
|
||||
closeMenusAnd(ctx, () => {
|
||||
void startNavigationTo({ kind: "query", query: destination.address, label: destination.name }, profile).catch(
|
||||
void startNavigationTo({ kind: "query", query: dest.address, label: dest.name }, profile).catch(
|
||||
() => {},
|
||||
);
|
||||
});
|
||||
@@ -1044,16 +1052,16 @@ function customDestinationMenuItems(destination: SavedDestination): MenuItem[] {
|
||||
{
|
||||
label: "Set address",
|
||||
onSelect: (ctx) => {
|
||||
closeMenusAnd(ctx, () => beginAddressEdit(destination.id, destination.name, destination.address));
|
||||
closeMenusAnd(ctx, () => beginAddressEdit(dest.id, dest.name, dest.address));
|
||||
},
|
||||
},
|
||||
{
|
||||
label: "Rename",
|
||||
onSelect: (ctx) => {
|
||||
closeMenusAnd(ctx, () => {
|
||||
navigateDestinationNameDraftSetting.set(destination.name);
|
||||
beginEdit(navigateDestinationNameDraftSetting, `Rename ${destination.name}`, (name) => {
|
||||
if (name) updateCustomDestination(destination.id, { name });
|
||||
navigateDestinationNameDraftSetting.set(dest.name);
|
||||
beginEdit(navigateDestinationNameDraftSetting, `Rename ${dest.name}`, (name) => {
|
||||
if (name) updateCustomDestination(dest.id, { name });
|
||||
});
|
||||
});
|
||||
},
|
||||
@@ -1062,7 +1070,7 @@ function customDestinationMenuItems(destination: SavedDestination): MenuItem[] {
|
||||
label: "Remove",
|
||||
onSelect: (ctx) => {
|
||||
closeMenusAnd(ctx, () => {
|
||||
removeCustomDestination(destination.id);
|
||||
removeCustomDestination(dest.id);
|
||||
syncIdleList();
|
||||
});
|
||||
},
|
||||
@@ -1195,10 +1203,10 @@ function idleEntries(): IdleEntry[] {
|
||||
run: () => { void startMap(); },
|
||||
}];
|
||||
entries.push(...loadSavedDestinations()
|
||||
.filter((destination) => destination.address)
|
||||
.map((destination): IdleEntry => ({ kind: "saved", destination })));
|
||||
for (const destination of loadRecentDestinations()) {
|
||||
entries.push({ kind: "recent", destination });
|
||||
.filter((dest) => dest.address)
|
||||
.map((dest): IdleEntry => ({ kind: "saved", destination: dest })));
|
||||
for (const dest of loadRecentDestinations()) {
|
||||
entries.push({ kind: "recent", destination: dest });
|
||||
}
|
||||
return entries;
|
||||
}
|
||||
@@ -1250,7 +1258,7 @@ function windowMenu(win: NavWindow): WindowMenu {
|
||||
windowId: win.windowId,
|
||||
post,
|
||||
title: () => win.title,
|
||||
items: () => windowMenuItems(win),
|
||||
items: () => windowMenuItems(),
|
||||
size: { width: win.viewportWidth, height: win.viewportHeight },
|
||||
paintBase: () => paintContent(win),
|
||||
isFocused: () => win.focused,
|
||||
@@ -1261,7 +1269,7 @@ function windowMenu(win: NavWindow): WindowMenu {
|
||||
|
||||
function handleInput(win: NavWindow, event: InputEvent, frameId: number): void {
|
||||
if (win.menu?.isOpen()) {
|
||||
win.menu
|
||||
void win.menu
|
||||
.handleInput(event)
|
||||
.catch((error) => console.error(`navigate menu input failed: ${error}`))
|
||||
.then(() => renderAndSubmit(win, frameId));
|
||||
|
||||
@@ -46,7 +46,7 @@ export class RouteFollower {
|
||||
|
||||
constructor(route: Route) {
|
||||
this.route = route;
|
||||
this.vertexMeters = new Array(route.coordinates.length);
|
||||
this.vertexMeters = Array.from({ length: route.coordinates.length }, () => 0);
|
||||
let along = 0;
|
||||
this.vertexMeters[0] = 0;
|
||||
for (let i = 1; i < route.coordinates.length; i++) {
|
||||
@@ -58,7 +58,7 @@ export class RouteFollower {
|
||||
// Each step's maneuver happens where the previous step's travel ends, so
|
||||
// the maneuver point of step k sits at the sum of steps 0..k-1 distances.
|
||||
// (Slight drift vs the geometry is fine at guidance granularity.)
|
||||
this.stepStartMeters = new Array(route.steps.length);
|
||||
this.stepStartMeters = Array.from({ length: route.steps.length }, () => 0);
|
||||
let stepAlong = 0;
|
||||
for (let i = 0; i < route.steps.length; i++) {
|
||||
this.stepStartMeters[i] = Math.min(stepAlong, this.totalMeters);
|
||||
|
||||
@@ -405,6 +405,11 @@ global.onmessage = (event: { data: WorkerAppMessage }) => {
|
||||
syncTickTimer(window);
|
||||
}
|
||||
break;
|
||||
case "navigation-sensors":
|
||||
case "resize-window":
|
||||
case "text-input":
|
||||
case "tool-call":
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -500,7 +505,7 @@ function handleInput(window: PinballWindow, event: InputEvent, frameId: number):
|
||||
// An open window menu owns all input (it closes itself via pop); menus are
|
||||
// list UIs, so watch swipes take their standard fallback meanings there.
|
||||
if (window.menu?.isOpen()) {
|
||||
window.menu
|
||||
void window.menu
|
||||
.handleInput(directionalFallback(event))
|
||||
.catch((error) => console.error(`pinball menu input failed: ${error}`))
|
||||
.then(() => renderAndSubmit(window, frameId));
|
||||
@@ -744,6 +749,8 @@ function stepFlippers(window: PinballWindow, dt: number): void {
|
||||
flipper.state = "rest";
|
||||
}
|
||||
break;
|
||||
case "rest":
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -121,7 +121,7 @@ async function roamPost(endpoint: "q" | "pull" | "write", body: object): Promise
|
||||
base = API_BASE;
|
||||
continue;
|
||||
}
|
||||
throw new Error(`Roam API request failed: ${(error as Error)?.message ?? error}`);
|
||||
throw new Error(`Roam API request failed: ${(error as Error)?.message ?? error}`, { cause: error });
|
||||
}
|
||||
if (response.status >= 300 && response.status < 400) {
|
||||
const location = response.headers?.get?.("Location") ?? response.headers?.get?.("location");
|
||||
|
||||
@@ -52,7 +52,6 @@ import {
|
||||
} from "./roam-doc";
|
||||
|
||||
declare const global: any;
|
||||
declare const com: any;
|
||||
|
||||
const HEADER_HEIGHT = 30;
|
||||
const BOTTOM_MARGIN = 6;
|
||||
@@ -252,6 +251,10 @@ global.onmessage = (event: { data: WorkerAppMessage }) => {
|
||||
);
|
||||
break;
|
||||
}
|
||||
case "input-focus":
|
||||
case "navigation-sensors":
|
||||
case "resize-window":
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -339,7 +342,7 @@ function windowMenu(win: RoamWindow): WindowMenu {
|
||||
windowId: win.windowId,
|
||||
post,
|
||||
title: () => win.title,
|
||||
items: () => menuItems(win),
|
||||
items: () => menuItems(),
|
||||
size: { width: win.viewportWidth, height: win.viewportHeight },
|
||||
paintBase: () => paintContent(win),
|
||||
isFocused: () => win.focused,
|
||||
@@ -348,7 +351,7 @@ function windowMenu(win: RoamWindow): WindowMenu {
|
||||
return win.menu;
|
||||
}
|
||||
|
||||
function menuItems(win: RoamWindow): MenuItem[] {
|
||||
function menuItems(): MenuItem[] {
|
||||
const items: MenuItem[] = [];
|
||||
const today = todayRef();
|
||||
if (currentRef?.uid !== today.uid) {
|
||||
@@ -415,7 +418,7 @@ function endSettingEdit(): void {
|
||||
|
||||
function handleInput(win: RoamWindow, event: InputEvent, frameId: number): void {
|
||||
if (win.menu?.isOpen()) {
|
||||
win.menu
|
||||
void win.menu
|
||||
.handleInput(event)
|
||||
.catch((error) => console.error(`roam menu input failed: ${error}`))
|
||||
.then(() => renderAndSubmit(win, frameId));
|
||||
|
||||
@@ -39,7 +39,6 @@ import { flattenPlanesWithDraws, planesFingerprint, type Plane } from "../../gra
|
||||
import { prepareFrameDraws } from "../../graphics/glyph-wire";
|
||||
import { getDefaultSmallFont, getTerminalFontConfig } from "../../graphics/ui-fonts";
|
||||
import { layoutHubHeader } from "./hub-header";
|
||||
import { truncateText } from "../../graphics/textwrap";
|
||||
import { TERMINAL_ICON_GLYPHS, type IconActivity } from "../../graphics/icons";
|
||||
import {
|
||||
drawSessionRow,
|
||||
@@ -64,7 +63,6 @@ import type { WorkerAppMessage, WorkerAppReply } from "../../ui/shell/worker-win
|
||||
import type { ToolResult, ToolSpec } from "../../assistant/tool-registry";
|
||||
|
||||
declare const global: any;
|
||||
declare const com: any;
|
||||
|
||||
// Cell geometry comes from the terminal font setting (Settings > Terminal >
|
||||
// Font; the default is Terminus-12's 6x12). Each window derives its grid from
|
||||
@@ -429,6 +427,9 @@ global.onmessage = (event: { data: WorkerAppMessage }) => {
|
||||
);
|
||||
break;
|
||||
}
|
||||
case "input-focus":
|
||||
case "navigation-sensors":
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1092,7 +1093,7 @@ function handleInput(window: TerminalWindow, event: InputEvent, frameId: number)
|
||||
if (window.kind === "view") activeViewId = window.windowId;
|
||||
// An open window menu owns all input (it closes itself via pop).
|
||||
if (window.menu?.isOpen()) {
|
||||
window.menu
|
||||
void window.menu
|
||||
.handleInput(event)
|
||||
.catch((error) => console.error(`terminal menu input failed: ${error}`))
|
||||
.then(() => renderAndSubmit(window, frameId));
|
||||
|
||||
@@ -368,6 +368,7 @@ export class TimersLayer implements Layer {
|
||||
else timerEngine.restartTimer(timer.id);
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
case "new-timer":
|
||||
this.openDial("");
|
||||
|
||||
@@ -43,7 +43,7 @@ export class TranscribeLayer implements Layer {
|
||||
const { width, height } = ctx.stack.getBaseSize();
|
||||
const image = new GrayImage(width, height, 0);
|
||||
const text = this.transcript.text || (this.listening ? "Listening..." : this.detail);
|
||||
const wrapped = wrapTranscribeText((text) => font.measureText(text), text, width - 64);
|
||||
const wrapped = wrapTranscribeText((line) => font.measureText(line), text, width - 64);
|
||||
|
||||
image.drawText(font, 24, 20, "Transcribe", 200);
|
||||
image.drawText(font, 24, 40, this.saveNotice || this.status, 110);
|
||||
|
||||
@@ -16,7 +16,6 @@ export function createWeatherAppWindow(options: InProcessAppOptions): InProcessW
|
||||
let closed = false;
|
||||
let requestingPermission = false;
|
||||
let unsubscribe: (() => void) | null = null;
|
||||
let app: InProcessWindow;
|
||||
|
||||
const requestUpdate = () => {
|
||||
if (closed || requestingPermission) return;
|
||||
@@ -33,7 +32,7 @@ export function createWeatherAppWindow(options: InProcessAppOptions): InProcessW
|
||||
}).catch((error) => { requestingPermission = false; console.warn(`Weather permission: ${error}`); });
|
||||
};
|
||||
|
||||
app = createInProcessWindow({
|
||||
const app = createInProcessWindow({
|
||||
appId: "weather",
|
||||
windowId: WEATHER_WINDOW_ID,
|
||||
title: "Weather",
|
||||
|
||||
@@ -47,7 +47,7 @@ const MIRROR_TOUCH_GESTURES: Record<Exclude<MirrorTouchKind, "tap">, WearRemoteI
|
||||
import { findSoundEffect, playSoundEffect } from "../ui/sound-effects";
|
||||
import { GlanceHost } from "./glance-host";
|
||||
import { type GlanceEvent } from "./glance-state";
|
||||
import { isWelcomeSoundPending, setWelcomeSoundPending } from "../phone-ui/onboarding-state";
|
||||
import { isPreviewOnlyMode, isWelcomeSoundPending, setWelcomeSoundPending } from "../phone-ui/onboarding-state";
|
||||
import { beginRenderPass, endRenderPass } from "../util/render-freshness";
|
||||
import { voiceControlBridge } from "../native/voice-control";
|
||||
import { G2_LENS_HEIGHT, G2_LENS_WIDTH, GrayImage } from "../graphics/image";
|
||||
@@ -92,7 +92,6 @@ import { wearerVerificationOptions } from "../apps/microphones/speakers";
|
||||
import { micSession } from "../apps/microphones/mic-session";
|
||||
import { glassesDisplayLabel } from "./glasses-display-state";
|
||||
import { PreviewDisplayTarget, type DisplayTarget } from "../native/preview-display";
|
||||
import { isPreviewOnlyMode } from "../phone-ui/onboarding-state";
|
||||
|
||||
type ConnectionPhase = "disconnected" | "connecting" | "connected" | "charging" | "disconnecting";
|
||||
|
||||
@@ -186,6 +185,9 @@ function createInitialDisplayPreview(): ImageSource | null {
|
||||
return grayImageToPreviewSource(new GrayImage(G2_LENS_WIDTH, G2_LENS_HEIGHT, 0));
|
||||
}
|
||||
|
||||
/** Echo the controller's appendLog() trace to the console. */
|
||||
const VERBOSE_CONTROLLER_LOG = false;
|
||||
|
||||
function formatTimestamp(date: Date): string {
|
||||
return date.toISOString().slice(11, 23);
|
||||
}
|
||||
@@ -2004,7 +2006,7 @@ class DashboardController {
|
||||
}
|
||||
|
||||
private startContinuousVoiceCapture(): void {
|
||||
this.beginVoiceCapture("continuous");
|
||||
void this.beginVoiceCapture("continuous");
|
||||
}
|
||||
|
||||
private stopContinuousVoiceCapture(): void {
|
||||
@@ -2761,7 +2763,7 @@ class DashboardController {
|
||||
}
|
||||
|
||||
private appendLog(line: string): void {
|
||||
//console.log(`[${formatTimestamp(new Date())}] ${line}`);
|
||||
if (VERBOSE_CONTROLLER_LOG) console.log(`[${formatTimestamp(new Date())}] ${line}`);
|
||||
}
|
||||
|
||||
private setDisplayPreview(preview: ImageSource | null): void {
|
||||
|
||||
@@ -95,7 +95,7 @@ export function g2NameAddressTail(name: string | null | undefined): string | nul
|
||||
* Even's wire order is reversed human order: "AA:BB:CC:DD:EE:FF" ⇄ [FF EE DD CC BB AA].
|
||||
*/
|
||||
export function wireBytesFromHumanReadableAddress(address: string): Uint8Array | null {
|
||||
const cleaned = address.replace(/[:\-]/g, "").trim();
|
||||
const cleaned = address.replace(/[:-]/g, "").trim();
|
||||
if (cleaned.length !== 12 || !/^[0-9a-fA-F]{12}$/.test(cleaned)) return null;
|
||||
const human = hexToBytes(cleaned);
|
||||
return new Uint8Array(Array.from(human).reverse());
|
||||
|
||||
@@ -187,7 +187,7 @@ function persistEvenHubFonts(base: ArrayBuffer): void {
|
||||
writeError = error;
|
||||
},
|
||||
);
|
||||
if (writeError) throw writeError;
|
||||
if (writeError) throw writeError instanceof Error ? writeError : new Error(String(writeError));
|
||||
// A degraded EvenHubFont (built before this extraction existed) is cached
|
||||
// per JS context; drop it so the next render picks up the real fonts
|
||||
// without an app restart.
|
||||
|
||||
@@ -79,7 +79,7 @@ export class GlanceHost {
|
||||
* "Show on head tilt" is off (it then wakes the regular UI). A release
|
||||
* always passes so a hold in progress can end.
|
||||
*/
|
||||
eventForGesture(gesture: "head-tilt" | string): GlanceEvent | null {
|
||||
eventForGesture(gesture: "head-tilt" | (string & {})): GlanceEvent | null {
|
||||
const provider = this.options.getProvider();
|
||||
if (!provider?.isEnabled()) return null;
|
||||
if (gesture === "click" && !provider.showOnTap()) return null;
|
||||
|
||||
@@ -66,7 +66,7 @@ export function reduceGlance(
|
||||
* already handles or ignores while asleep.
|
||||
*/
|
||||
export function glanceEventForGesture(
|
||||
gesture: "click" | "double-click" | "long-press" | "short-then-long-press" | "long-press-release" | "head-tilt" | string,
|
||||
gesture: "click" | "double-click" | "long-press" | "short-then-long-press" | "long-press-release" | "head-tilt" | (string & {}),
|
||||
boardVisible: boolean,
|
||||
): GlanceEvent | null {
|
||||
switch (gesture) {
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
import { startRemoteInput } from "../remote/service"
|
||||
import type { KeyboardInputSession } from '../ui/shell/keyboard-input'
|
||||
import { acceptInput, resetRingInputFilter } from "../ui/input-monitor";
|
||||
import { bindIosNotifications, iosNotificationsChanged, onIosNotificationPopup } from '../native/notification-icons.ios'
|
||||
import { bindIosNotifications, iosNotificationsChanged, onIosNotificationPopup, readActiveNotifications } from '../native/notification-icons.ios'
|
||||
import { shouldShowNotificationOnGlasses } from '../native/notification-sources'
|
||||
import { readActiveNotifications } from '../native/notification-icons.ios'
|
||||
import { launcherEntries } from '../apps/launcher'
|
||||
import { getInstalledEvenHubAppById, installedEvenHubPackageId, uninstallEvenHubPackage } from '../apps/evenhub/installed-apps'
|
||||
import { isInstalledPackagePresent } from '../apps/evenhub/updates'
|
||||
@@ -14,9 +13,8 @@ import { registerWindowTools } from '../assistant/window-tools'
|
||||
import { registerNavigateTools } from '../assistant/navigate-tools'
|
||||
import { registerRoamTools } from '../assistant/roam-tools'
|
||||
import { IosNavigationSensors } from '../native/ios-navigation-sensors'
|
||||
import { Utils } from '@nativescript/core'
|
||||
import { bindCompassSession, receiveCompassEvent } from '../native/compass.ios'
|
||||
import { Dialogs, File, knownFolders, path, type ImageSource } from '@nativescript/core'
|
||||
import { Dialogs, File, knownFolders, path, Utils, type ImageSource } from '@nativescript/core'
|
||||
import { iosVoiceInput } from '../native/ios-voice-input'
|
||||
import { nightscoutBridge } from '../native/nightscout-bridge'
|
||||
import { FaceclawCommunicatorBridge, resolveIosPeripherals, type CommunicatorState, type RawInputEvent } from '../native/faceclaw-communicator.ios'
|
||||
@@ -32,7 +30,6 @@ import { ALL_APPS } from '../apps/all-apps'
|
||||
import type { AppContext, AppDefinition, AppLaunchParams } from '../apps/app-definition'
|
||||
import { WorkerAppHost } from '../ui/shell/worker-window'
|
||||
import { createInProcessWindow, YieldAtRootLayer, type InProcessAppOptions, type InProcessWindow } from '../ui/shell/in-process-window'
|
||||
import { getStringSettingById, nightscoutSiteUrlSetting, nightscoutApiTokenSetting } from '../ui/dashboard-settings'
|
||||
import { readPhoneBatteryState } from '../native/phone-battery'
|
||||
import { iosAppUnavailableReason } from '../apps/ios-availability'
|
||||
import { flattenPlanesWithDraws, planesFingerprint, type Plane } from '../graphics/plane'
|
||||
@@ -44,7 +41,8 @@ import { TextViewerLayer } from '../apps/files/text-viewer'
|
||||
import { shell, rawInputEventToInputEvent, type ShellWindow } from '../ui/shell/shell'
|
||||
import { appViewportRect, SIDEBAR_WIDTH, sidebarStripVisible } from '../ui/shell/geometry'
|
||||
import { DISPLAY_MODE_VALUES, displayModeLabel, displayModeSetting, onAnySettingChanged,
|
||||
previewColorSetting, lockScreenEnabledSetting, getBrightnessPreferences } from '../ui/dashboard-settings'
|
||||
previewColorSetting, lockScreenEnabledSetting, getBrightnessPreferences, getStringSettingById,
|
||||
nightscoutSiteUrlSetting, nightscoutApiTokenSetting } from '../ui/dashboard-settings'
|
||||
import type { PhoneGesture } from '../phone-ui/phone-gestures'
|
||||
import { isWelcomeSoundPending, setWelcomeSoundPending } from '../phone-ui/onboarding-state'
|
||||
import { findSoundEffect, playSoundEffect } from '../ui/sound-effects'
|
||||
@@ -548,10 +546,10 @@ export class IosPreviewController {
|
||||
this.requestShellRender()
|
||||
}
|
||||
async launchApp(id: string, params?: AppLaunchParams): Promise<void> {
|
||||
const app = ALL_APPS.find(app => app.appId === id)
|
||||
const app = ALL_APPS.find(candidate => candidate.appId === id)
|
||||
if (!app) {
|
||||
const installed = getInstalledEvenHubAppById(id)
|
||||
const host = ALL_APPS.find(app => app.appId === 'evenhub')
|
||||
const host = ALL_APPS.find(candidate => candidate.appId === 'evenhub')
|
||||
if (installed && host) {
|
||||
try {
|
||||
if (isInstalledPackagePresent(installed.packageId))
|
||||
|
||||
@@ -121,24 +121,24 @@ export function readDisplayList(bytes: Uint8Array, offset: number, now = Date.no
|
||||
const x = r.i16(), y = r.i16(), width = r.u16(), height = r.u16(), depth = r.u8() << 24 >> 24;
|
||||
const token = r.u32(), elapsed = r.u32(), count = r.u16(); integer(count, 0, 256);
|
||||
const resources: ListImage[] = [];
|
||||
for (let i = 0; i < count; i++) { const width = r.u16(), height = r.u16(); resources.push({ width, height, pixels: r.take(width * height) }); }
|
||||
for (let i = 0; i < count; i++) { const w = r.u16(), h = r.u16(); resources.push({ width: w, height: h, pixels: r.take(w * h) }); }
|
||||
const calls: ListCall[] = [], callCount = r.u16(); integer(callCount, 0, 4096);
|
||||
for (let i = 0; i < callCount; i++) {
|
||||
const header = r.u8(), op = header & ~CLIPPED, depth = r.i16();
|
||||
const header = r.u8(), op = header & ~CLIPPED, callDepth = r.i16();
|
||||
const clip = header & CLIPPED ? { x: r.i16(), y: r.i16(), width: r.u16(), height: r.u16() } : undefined;
|
||||
const common = clip ? { depth, clip } : { depth };
|
||||
const common = clip ? { depth: callDepth, clip } : { depth: callDepth };
|
||||
if (op === DrawOp.ROUNDED_RECT) calls.push({ op, ...common, x: readValue(r), y: readValue(r), width: r.u16(), height: r.u16(), radius: r.u16(), background: r.u8(), border: r.u8() });
|
||||
else if (op === DrawOp.IMAGE) calls.push({ op, ...common, resource: r.u16(), x: r.i16(), y: r.i16(), transparent: (r.u8() & 16) !== 0 });
|
||||
else if (op === DrawOp.RECT_COPY) calls.push({ op, ...common, resource: r.u16(), x: readValue(r), y: readValue(r), width: r.u16(), height: r.u16(), dx: readValue(r), dy: readValue(r) });
|
||||
else if (op === DrawOp.CLEAR) calls.push({ op, ...common, color: r.u8() });
|
||||
else if (op === DrawOp.DRAWS) {
|
||||
const x = readValue(r), y = readValue(r), records = r.u16(), start = r.offset;
|
||||
const drawX = readValue(r), drawY = readValue(r), records = r.u16(), start = r.offset;
|
||||
for (let n = 0; n < records; n++) {
|
||||
const size = RECORD_BYTES[r.bytes[r.offset]!];
|
||||
if (!size) throw new Error('Unsupported display-list draw record');
|
||||
r.take(size);
|
||||
}
|
||||
calls.push({ op, ...common, x, y, count: records, records: r.bytes.slice(start, r.offset) });
|
||||
calls.push({ op, ...common, x: drawX, y: drawY, count: records, records: r.bytes.slice(start, r.offset) });
|
||||
} else throw new Error('Unsupported display-list call');
|
||||
}
|
||||
if (r.offset !== length) throw new Error('Trailing display-list bytes');
|
||||
|
||||
@@ -112,10 +112,10 @@ export function evaluate(value: DrawValue, elapsed: number, presentTime = 0): {
|
||||
if (typeof value === 'number') return { value, pending: false };
|
||||
const reader = new DrawBytes(Uint8Array.from(value.code)), stack: { value: number; float: boolean }[] = [];
|
||||
let pending = false;
|
||||
const push = (value: number, float = false) => {
|
||||
value = float ? Math.fround(value) : value | 0;
|
||||
if (!Number.isFinite(value) || stack.length === 32) throw new Error('Invalid expression stack');
|
||||
stack.push({ value, float });
|
||||
const push = (n: number, float = false) => {
|
||||
n = float ? Math.fround(n) : n | 0;
|
||||
if (!Number.isFinite(n) || stack.length === 32) throw new Error('Invalid expression stack');
|
||||
stack.push({ value: n, float });
|
||||
};
|
||||
const pop = (float: boolean) => { const v = stack.pop(); if (!v || v.float !== float) throw new Error('Expression type mismatch'); return v.value; };
|
||||
const toInt = (v: number) => { if (v < -2147483648 || v >= 2147483648) throw new Error('Invalid integer conversion'); return Math.trunc(v); };
|
||||
|
||||
@@ -192,7 +192,7 @@ export function prepareFrameDraws(draws: readonly DeferredDraw[]): ArrayBuffer |
|
||||
offset = writeGlyphRecord(out, offset, state, placed);
|
||||
} else if (placed.kind === "image") {
|
||||
if (!inRange16(placed.x) || !inRange16(placed.y)) continue;
|
||||
if (placed.presentation) { const bytes = presentations.get(placed)!; new Uint8Array(out.buffer).set(bytes, offset); offset += bytes.length; continue; }
|
||||
if (placed.presentation) { const record = presentations.get(placed)!; new Uint8Array(out.buffer).set(record, offset); offset += record.length; continue; }
|
||||
const id = imageId(placed);
|
||||
if (id === null) continue;
|
||||
offset = writeImageRecord(out, offset, id, placed);
|
||||
|
||||
@@ -288,7 +288,9 @@ export class GrayImage {
|
||||
const dst = this.pixels;
|
||||
// A blit within one image copies pixel by pixel, forwards, as it always has.
|
||||
const bulk = !opts.transparentZero && source !== this;
|
||||
for (let row = rowStart; span > 0 && row < rowEnd; row++) {
|
||||
// No columns in range means no rows to copy.
|
||||
const rowLimit = span > 0 ? rowEnd : rowStart;
|
||||
for (let row = rowStart; row < rowLimit; row++) {
|
||||
const from = (srcY + row) * source.width + srcX + colStart;
|
||||
const to = (destY + row) * this.width + destX + colStart;
|
||||
if (bulk) {
|
||||
|
||||
@@ -30,7 +30,7 @@ export function encodeShellScene(planes: readonly Plane[]): Uint8Array {
|
||||
presentation: { ...d.presentation!, depth: d.presentation!.depth + (plane.depth ?? 0) } }))
|
||||
layers.push({ depth: plane.depth ?? 0, selections, image: cropped.image, x: plane.x + left, y: plane.y + top, key: plane.shellKey!, dim: Math.round((plane.dimUnderneath ?? 1) * 256) })
|
||||
}
|
||||
const result = new Uint8Array(2 + layers.reduce((n, l) => n + 16 + l.image.pixels.length + l.selections.reduce((n, b) => n + b.length, 0), 0))
|
||||
const result = new Uint8Array(2 + layers.reduce((n, l) => n + 16 + l.image.pixels.length + l.selections.reduce((sum, b) => sum + b.length, 0), 0))
|
||||
const view = new DataView(result.buffer); let p = 0
|
||||
const word = (n: number) => { view.setUint16(p, n, true); p += 2 }
|
||||
word(layers.length)
|
||||
|
||||
@@ -193,7 +193,7 @@ function finalizeBlocks(blocks: Map<number, StreamingBlock>): AnthropicContentBl
|
||||
}
|
||||
|
||||
/** Parse one SSE line; returns the JSON payload of a data: line, else null. */
|
||||
function parseSseDataLine(line: string): any | null {
|
||||
function parseSseDataLine(line: string): any {
|
||||
if (!line.startsWith("data:")) return null;
|
||||
const payload = line.slice(5).trim();
|
||||
if (!payload || payload === "[DONE]") return null;
|
||||
|
||||
@@ -24,7 +24,7 @@ async function requestPermission(): Promise<boolean> {
|
||||
okButtonText: "Open Settings",
|
||||
cancelButtonText: "Cancel",
|
||||
});
|
||||
if (open) await Utils.openUrl("app-settings:");
|
||||
if (open) Utils.openUrl("app-settings:");
|
||||
return false;
|
||||
}
|
||||
if (status === "restricted") {
|
||||
|
||||
@@ -97,7 +97,7 @@ export async function readUpcomingEventsAsync(maxEvents = 50, windowMs = DEFAULT
|
||||
try {
|
||||
if (!hasCalendarPermission()) throw new Error("Calendar permission is required.");
|
||||
resolve(parseEvents(json, error, maxEvents, endMs));
|
||||
} catch (error) { reject(error); }
|
||||
} catch (err) { reject(err); }
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -10,7 +10,6 @@ export type { FirmwareInfo };
|
||||
|
||||
// Kotlin/Native facades exported by FaceclawKit (see native/kotlin/shared/src/iosMain/.../ble).
|
||||
declare const FaceclawKitIosGlassesSession: any;
|
||||
declare const FaceclawKitIosProtocolPlatform: any;
|
||||
declare const FaceclawKitFaceclawBleCommunicatorListener: any;
|
||||
declare const FaceclawKitIosAncsListener: any;
|
||||
declare const FaceclawKitIosAudioPacketListener: any;
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { openSocket } from "./socket";
|
||||
import { toUint8Array } from "../util/array-util";
|
||||
|
||||
declare const com: any;
|
||||
declare const android: any;
|
||||
declare const java: any;
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ export class IosBluetooth {
|
||||
this.state = Number(state); this.authorization = Number(authorization)
|
||||
this.emit({ kind: 'state', state: this.state, authorization: this.authorization })
|
||||
},
|
||||
onAdvertisementIdentifierNameManufacturerDataHexRssiConnectable: (identifier: string, name: string, manufacturerData: string, rssi: number, connectable: boolean) => {
|
||||
onAdvertisementIdentifierNameManufacturerDataHexRssiConnectable: (identifier: string, name: string, manufacturerData: string, rssi: number, connectable: boolean | undefined) => {
|
||||
// The Kotlin central already merges split advertisements and bounds its cache.
|
||||
const raw: IosAdvertisement = { identifier: String(identifier), name: String(name ?? ''), manufacturerData: String(manufacturerData ?? ''), rssi: Number(rssi), connectable: connectable !== false }
|
||||
this.emit({ kind: 'advertisement', ...raw })
|
||||
@@ -65,7 +65,7 @@ export class IosBluetooth {
|
||||
ensureReady(): Promise<void> {
|
||||
if (this.state === BLE_STATE_POWERED_ON) return Promise.resolve()
|
||||
return new Promise((resolve, reject) => {
|
||||
const finish = (error?: Error) => { clearTimeout(timer); off(); error ? reject(error) : resolve() }
|
||||
const finish = (error?: Error) => { clearTimeout(timer); off(); if (error) reject(error); else resolve() }
|
||||
const off = this.onEvent(event => {
|
||||
if (event.kind !== 'state') return
|
||||
if (event.state === BLE_STATE_POWERED_ON) finish()
|
||||
|
||||
@@ -33,6 +33,6 @@ export function runKotlinBridgeSmokeTest(): void {
|
||||
console.log("FACECLAW_KOTLIN_BRIDGE_PASS " + JSON.stringify({ platform, thread, reply }));
|
||||
} catch (error) {
|
||||
// Diagnostics must not prevent the rest of the app from launching.
|
||||
console.error("FACECLAW_KOTLIN_BRIDGE_FAIL " + error);
|
||||
console.error(`FACECLAW_KOTLIN_BRIDGE_FAIL ${error}`);
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,8 @@ import type { KotlinBridge } from './kotlin-platform';
|
||||
// Handwritten declarations for the small native surface, checked against the
|
||||
// compiled API. NativeScript runtime metadata is generated from the AAR.
|
||||
declare namespace com.faceclaw.shared {
|
||||
// Used as com.faceclaw.shared.KotlinBridge; oxlint misses qualified references.
|
||||
// oxlint-disable-next-line no-unused-vars
|
||||
class KotlinBridge extends java.lang.Object {
|
||||
constructor();
|
||||
platform(): string;
|
||||
|
||||
@@ -30,8 +30,8 @@ type PendingRequest<T> = {
|
||||
* Holds at most one connection at a time.
|
||||
*/
|
||||
export class FaceclawMediaBrowserBridge {
|
||||
private browser: any | null = null;
|
||||
private listenerProxy: any | null = null;
|
||||
private browser: any = null;
|
||||
private listenerProxy: any = null;
|
||||
private nextRequestId = 1;
|
||||
private readonly pendingConnects = new Map<number, PendingRequest<string>>();
|
||||
private readonly pendingBrowses = new Map<number, PendingRequest<MediaBrowseItem[]>>();
|
||||
|
||||
@@ -59,8 +59,8 @@ const DEFAULT_MEDIA_STATE: MediaControllerState = {
|
||||
|
||||
export class FaceclawMediaControllerBridge {
|
||||
private readonly stateListeners = new Set<(state: MediaControllerState) => void>();
|
||||
private controller: any | null = null;
|
||||
private listenerProxy: any | null = null;
|
||||
private controller: any = null;
|
||||
private listenerProxy: any = null;
|
||||
private state: MediaControllerState = { ...DEFAULT_MEDIA_STATE };
|
||||
private stateUpdatedAtMs = Date.now();
|
||||
private started = false;
|
||||
|
||||
@@ -106,7 +106,6 @@ type NightscoutTreatmentResponse = {
|
||||
|
||||
const NIGHTSCOUT_REFRESH_MS = 60_000;
|
||||
const NIGHTSCOUT_HISTORY_COUNT = 30;
|
||||
const NIGHTSCOUT_GRAPH_WINDOW_MS = 2 * 60 * 60 * 1000;
|
||||
const NIGHTSCOUT_TREATMENT_LOOKBACK_MS = 3 * 60 * 60 * 1000;
|
||||
// The v1 treatments API silently adds `created_at >= now - 4 days` to any
|
||||
// query without an explicit date filter (lib/server/query.js enforceDateFilter),
|
||||
|
||||
@@ -20,7 +20,7 @@ let cachedIcons: GrayImage[] = [];
|
||||
let cachedAtMs = 0;
|
||||
const keyedIconCache = new Map<string, { icon: GrayImage | null; atMs: number }>();
|
||||
const KEYED_ICON_CACHE_MAX = 128;
|
||||
let notificationListenerProxy: any | null = null;
|
||||
let notificationListenerProxy: any = null;
|
||||
const notificationPostedListeners = new Set<(notificationKey: string) => void>();
|
||||
|
||||
function invalidateIconCaches(): void {
|
||||
|
||||
@@ -288,7 +288,7 @@ function extractMessageText(item: any): string {
|
||||
.join("");
|
||||
}
|
||||
|
||||
function parseSseDataLine(line: string): any | null {
|
||||
function parseSseDataLine(line: string): any {
|
||||
if (!line.startsWith("data:")) return null;
|
||||
const payload = line.slice(5).trim();
|
||||
if (!payload || payload === "[DONE]") return null;
|
||||
|
||||
@@ -14,7 +14,8 @@ export function scanQrCode(): Promise<string | null> {
|
||||
if (settled) return
|
||||
settled = true
|
||||
if (activeScanner === scanner) activeScanner = null
|
||||
error ? reject(new Error(String(error))) : resolve(text == null ? null : String(text))
|
||||
if (error) reject(new Error(String(error)))
|
||||
else resolve(text == null ? null : String(text))
|
||||
}
|
||||
try { scanner.startWithCompletion(finish) }
|
||||
catch (error) { finish(null, String(error)) }
|
||||
|
||||
@@ -64,8 +64,8 @@ export class IosVoiceControlBridge {
|
||||
const generation = ++this.generation
|
||||
this.log = log; this.source = 'glasses'; this.session = session; this.packets = 0; this.capturing = true
|
||||
this.completion = new Promise(resolve => { this.resolveCompletion = resolve })
|
||||
const error = String(this.ensureNative().startWithEndpointing(endpointing) ?? '')
|
||||
if (error) { this.stop(); this.setStatus(error); this.emitEnd(); return }
|
||||
const startError = String(this.ensureNative().startWithEndpointing(endpointing) ?? '')
|
||||
if (startError) { this.stop(); this.setStatus(startError); this.emitEnd(); return }
|
||||
try {
|
||||
await session.setMicrophone(true, packet => {
|
||||
if (generation !== this.generation || !this.capturing) return
|
||||
@@ -136,7 +136,7 @@ export class IosVoiceControlBridge {
|
||||
this.log(`Voice audio: ${event.seconds?.toFixed(1)}s, packets=${event.packets}, RMS=${event.rms?.toFixed(4)}, missing=${event.missing}, errors=${event.errors}`)
|
||||
if (this.capturing) this.setStatus(`Listening on ${this.source === 'phone' ? 'phone' : 'glasses'}… ${event.seconds?.toFixed(0)}s`)
|
||||
} else if (event.kind === 'finishing') {
|
||||
this.stopPushToTalk(); this.emitEnd()
|
||||
void this.stopPushToTalk(); this.emitEnd()
|
||||
} else if (event.kind === 'ended') {
|
||||
this.source = null
|
||||
this.capturing = this.finalizing = false
|
||||
|
||||
@@ -102,8 +102,8 @@ export class FaceclawVoiceControlBridge {
|
||||
private readonly speechPauseListeners = new Set<() => void>();
|
||||
private readonly speechPause = new SpeechPauseDetector();
|
||||
private readonly speechEndListeners = new Set<() => void>();
|
||||
private controller: any | null = null;
|
||||
private listenerProxy: any | null = null;
|
||||
private controller: any = null;
|
||||
private listenerProxy: any = null;
|
||||
private status = "Voice control stopped.";
|
||||
private listening = false;
|
||||
private detail = "";
|
||||
|
||||
@@ -54,14 +54,14 @@ type MessageListener = (message: WearMessage) => void;
|
||||
type ConnectionListener = (connection: WearWatchConnection) => void;
|
||||
|
||||
class WearBridge {
|
||||
private java: any | null | undefined = undefined;
|
||||
private java: any = undefined;
|
||||
// The Java-side listener proxy must stay referenced or it gets GC'd.
|
||||
private retainedListenerProxy: any = null;
|
||||
private readonly messageListeners = new Set<MessageListener>();
|
||||
private readonly connectionListeners = new Set<ConnectionListener>();
|
||||
private lastConnection: WearWatchConnection = { reachable: false, watchName: "" };
|
||||
|
||||
private getJava(): any | null {
|
||||
private getJava(): any {
|
||||
if (this.java !== undefined) return this.java;
|
||||
if (!global.isAndroid) {
|
||||
this.java = null;
|
||||
|
||||
@@ -148,7 +148,7 @@ export function createMainPage(): Page {
|
||||
model.set('onPadTouch', touch(watchInput))
|
||||
model.set('onRingPadTouch', touch(ringInput))
|
||||
model.set('onSyntheticMicTap', () => controller.startVoiceInput())
|
||||
model.set('onKeyboardTap', () => { void controller.typeIntoApp() })
|
||||
model.set('onKeyboardTap', () => { controller.typeIntoApp() })
|
||||
mirror.on('touch', touch(mirrorInput))
|
||||
const cancelGestures = () => { watchInput.cancel(); ringInput.cancel(); mirrorInput.cancel() }
|
||||
model.on('propertyChange', (args: PropertyChangeData) => {
|
||||
|
||||
@@ -55,7 +55,7 @@ export class OnboardingFlashViewModel extends Observable {
|
||||
private promptBattery: FlashPromptBattery | null = null;
|
||||
private flasher: FirmwareFlasher | null = null;
|
||||
private flasherUnsubscribers: Array<() => void> = [];
|
||||
private retryAction: () => void = () => this.beginPrompt();
|
||||
private retryAction: () => void | Promise<void> = () => this.beginPrompt();
|
||||
|
||||
constructor(options?: { mode?: FlashMode; fromOnboarding?: boolean; autoStart?: boolean }) {
|
||||
super();
|
||||
@@ -211,7 +211,7 @@ export class OnboardingFlashViewModel extends Observable {
|
||||
this.finish();
|
||||
return;
|
||||
case "error":
|
||||
this.retryAction();
|
||||
void this.retryAction();
|
||||
return;
|
||||
default:
|
||||
return;
|
||||
@@ -569,7 +569,7 @@ export class OnboardingFlashViewModel extends Observable {
|
||||
});
|
||||
}
|
||||
|
||||
private toError(message: string, retry: () => void, headline = "Something Went Wrong"): void {
|
||||
private toError(message: string, retry: () => void | Promise<void>, headline = "Something Went Wrong"): void {
|
||||
this.retryAction = retry;
|
||||
this.status = message;
|
||||
this.setPhase("error");
|
||||
|
||||
@@ -22,6 +22,8 @@ export function startRemoteInput(host: RemoteHost): () => void {
|
||||
if (busy || stopped) return;
|
||||
busy = true;
|
||||
try {
|
||||
// stop() can flip `stopped` while handleRequest is awaited.
|
||||
// oxlint-disable-next-line no-unmodified-loop-condition
|
||||
while (!stopped) {
|
||||
const raw = native.nextRequest();
|
||||
if (!raw) break;
|
||||
|
||||
@@ -100,7 +100,8 @@ export abstract class ConfigSetting<TValue, TId extends string = string> {
|
||||
}
|
||||
|
||||
export class ConfigSettingBoolean<TId extends string = string> extends ConfigSetting<boolean, TId> {
|
||||
constructor(options: ConfigSettingOptions<boolean, TId>) {
|
||||
// Widens ConfigSetting's protected constructor.
|
||||
public constructor(options: ConfigSettingOptions<boolean, TId>) {
|
||||
super(options);
|
||||
}
|
||||
|
||||
@@ -1086,11 +1087,6 @@ export function isNightscoutSettingsConfigured(): boolean {
|
||||
}
|
||||
|
||||
|
||||
function normalizeSystemCardName(name: string | null | undefined): string {
|
||||
const normalized = (name ?? "").replace(/[\x00-\x1f]+/g, " ").replace(/\s+/g, " ").trim();
|
||||
return normalized;
|
||||
}
|
||||
|
||||
function normalizeNightscoutSiteUrl(siteUrl: string | null | undefined): string {
|
||||
return (siteUrl ?? "").replace(/[\x00-\x1f]+/g, "").trim().replace(/\/+$/, "");
|
||||
}
|
||||
@@ -1169,7 +1165,6 @@ export function toggleSettingMenuItem<TId extends string = string>(
|
||||
|
||||
export function textSettingMenuItem<TId extends string = string>(
|
||||
setting: ConfigSettingString<TId>,
|
||||
opts?: SettingsMenuOptions<string>
|
||||
): MenuItem {
|
||||
return {
|
||||
label: setting.label,
|
||||
|
||||
@@ -22,7 +22,7 @@ import {
|
||||
type BitmapFace,
|
||||
type UiFontSelection,
|
||||
} from "../graphics/ui-fonts";
|
||||
import { GESTURE_DOUBLE_CLICK, type InputEvent } from "./gestures";
|
||||
import { type InputEvent } from "./gestures";
|
||||
import { drawRightValueMenuItem, openModalMenu, type MenuItem } from "./menu";
|
||||
import { Menu, type MenuDrawArgs } from "./menu-core";
|
||||
import { LIST_ROW_TEXT_INSET, listRowHeight } from "./metrics";
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
import { clamp } from "~/util/numeric-util";
|
||||
import { formatRelativeTime } from "~/util/date-util";
|
||||
import { getDefaultSmallFont } from "../graphics/ui-fonts";
|
||||
import { truncateText } from "../graphics/textwrap";
|
||||
import { truncateText, wrapText } from "../graphics/textwrap";
|
||||
import { GrayImage, type UiFont } from "../graphics/image";
|
||||
import { wrapText } from "../graphics/textwrap";
|
||||
import { LIST_ROW_TEXT_INSET, lineStep, listRowHeight } from "./metrics";
|
||||
import {
|
||||
ALL_NOTIFICATIONS,
|
||||
@@ -255,7 +254,7 @@ export class SingleNotificationLayer implements Layer {
|
||||
this.close(ctx);
|
||||
} else if (item.kind === "action") {
|
||||
invokeNotificationAction(this.notificationKey, item.action.index);
|
||||
if (!readActiveNotifications(ALL_NOTIFICATIONS).some((item) => item.key === this.notificationKey)) {
|
||||
if (!readActiveNotifications(ALL_NOTIFICATIONS).some((active) => active.key === this.notificationKey)) {
|
||||
this.closeUnavailableNotification(ctx);
|
||||
}
|
||||
} else if (item.kind === "dismiss") {
|
||||
@@ -276,8 +275,8 @@ export class SingleNotificationLayer implements Layer {
|
||||
wrap: true,
|
||||
rowGap: 1,
|
||||
getHeight: () => listRowHeight(getDefaultSmallFont()),
|
||||
draw: ({ image, item, x, y, selected }) => {
|
||||
image.drawText(getDefaultSmallFont(), x + CONFIRM_TEXT_X, y + LIST_ROW_TEXT_INSET, item.label, selected ? 255 : 200);
|
||||
draw: ({ image, item: option, x, y, selected }) => {
|
||||
image.drawText(getDefaultSmallFont(), x + CONFIRM_TEXT_X, y + LIST_ROW_TEXT_INSET, option.label, selected ? 255 : 200);
|
||||
},
|
||||
}),
|
||||
};
|
||||
|
||||
@@ -61,6 +61,8 @@ export class BrightnessPickerLayer implements Layer {
|
||||
case "double-click":
|
||||
ctx.stack.pop();
|
||||
return;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -57,12 +57,12 @@ export function savePersistedOpenApps(state: PersistedOpenApps): void {
|
||||
if (writeTimer !== null) clearTimeout(writeTimer);
|
||||
writeTimer = setTimeout(() => {
|
||||
writeTimer = null;
|
||||
const state = pendingState;
|
||||
const pending = pendingState;
|
||||
pendingState = null;
|
||||
if (!state) return;
|
||||
if (!pending) return;
|
||||
try {
|
||||
File.fromPath(openAppsFilePath()).writeTextSync(
|
||||
JSON.stringify({ version: STATE_VERSION, ...state }),
|
||||
JSON.stringify({ version: STATE_VERSION, ...pending }),
|
||||
);
|
||||
} catch (error) {
|
||||
console.warn("open-apps state write failed", error);
|
||||
|
||||
@@ -1440,7 +1440,6 @@ class Shell {
|
||||
if (!this.screenOn || this.activeVoiceLayer || !this.stack.isAtBase()) return;
|
||||
const foreground = this.foregroundWindow();
|
||||
if (!foreground) return;
|
||||
let layer: ShellOverlayMenuLayer;
|
||||
const items: MenuItem[] = [];
|
||||
if (foreground.closeable) {
|
||||
items.push({
|
||||
@@ -1500,7 +1499,7 @@ class Shell {
|
||||
const footer = foreground.hasAppMenu?.()
|
||||
? (foreground.holdToTalk ? undefined : gestureHints([[GESTURE_SHORT_THEN_LONG_PRESS, "app menu"]]))
|
||||
: undefined;
|
||||
layer = new ShellOverlayMenuLayer(items, footer, () => this.yieldFocusToSidebar());
|
||||
const layer = new ShellOverlayMenuLayer(items, footer, () => this.yieldFocusToSidebar());
|
||||
layer.selectItem(initialSelection);
|
||||
this.stack.push(layer);
|
||||
// Tell the window the system menu opened over it: an app with its own
|
||||
|
||||
@@ -6,7 +6,7 @@ import type { ToolDebugEntry } from "../../assistant/tool-registry";
|
||||
import { InputEvent } from "../gestures";
|
||||
import { Layer, LayerContext, PaintBelow } from "../layers";
|
||||
import { MenuLayer, drawListScrollbar, type MenuItem } from "../menu";
|
||||
import { MIN_WINDOW_HEIGHT, minWindowTop, sidebarWidth, TOP_BAR_HEIGHT } from "./geometry";
|
||||
import { minWindowTop, sidebarWidth, TOP_BAR_HEIGHT } from "./geometry";
|
||||
import { lineStep } from "../metrics";
|
||||
|
||||
/**
|
||||
@@ -153,6 +153,8 @@ class ToolDetailLayer implements Layer {
|
||||
case "double-click":
|
||||
ctx.stack.pop();
|
||||
return;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -20,19 +20,19 @@ export function publishWorkerState(key: string, value: unknown): void {
|
||||
}
|
||||
|
||||
/** The latest published value for `key`, or undefined when nothing was published yet. */
|
||||
export function readWorkerState<T>(key: string): T | undefined {
|
||||
return values.get(key) as T | undefined;
|
||||
export function readWorkerState(key: string): unknown {
|
||||
return values.get(key);
|
||||
}
|
||||
|
||||
/** Subscribe to later publications of `key`; returns the unsubscribe. */
|
||||
export function onWorkerStateChanged<T>(key: string, listener: (value: T) => void): () => void {
|
||||
export function onWorkerStateChanged(key: string, listener: (value: unknown) => void): () => void {
|
||||
let set = listeners.get(key);
|
||||
if (!set) {
|
||||
set = new Set();
|
||||
listeners.set(key, set);
|
||||
}
|
||||
set.add(listener as (value: unknown) => void);
|
||||
set.add(listener);
|
||||
return () => {
|
||||
set!.delete(listener as (value: unknown) => void);
|
||||
set!.delete(listener);
|
||||
};
|
||||
}
|
||||
@@ -400,6 +400,9 @@ export class WorkerAppHost {
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "worker-stopped":
|
||||
// Only meaningful as the reply to shutdown(), handled above.
|
||||
break;
|
||||
}
|
||||
};
|
||||
options.worker.onerror = (error) => {
|
||||
|
||||
Reference in new issue
Block a user