diff --git a/.oxlintrc.json b/.oxlintrc.json new file mode 100644 index 00000000..5f63cfb3 --- /dev/null +++ b/.oxlintrc.json @@ -0,0 +1,85 @@ +{ + // Run via ./lint.sh (or `npm run lint`). Rule docs: + // https://oxc.rs/docs/guide/usage/linter/rules.html + "$schema": "./node_modules/oxlint/configuration_schema.json", + "plugins": ["eslint", "typescript", "unicorn", "oxc", "import", "promise"], + "options": { + // Type-aware rules run through oxlint-tsgolint (typescript-go), which + // reads tsconfig.json with TS7 semantics (no baseUrl, rootDir explicit). + "typeAware": true + }, + "categories": { + "correctness": "warn", + "suspicious": "warn", + "pedantic": "off", + "perf": "off", + "style": "off", + "restriction": "off", + "nursery": "off" + }, + "rules": { + // --- Opted in from non-default categories --- + "eslint/eqeqeq": ["warn", "always", { "null": "ignore" }], + "eslint/no-fallthrough": "warn", + "eslint/no-var": "warn", + "eslint/prefer-const": "warn", + "import/no-duplicates": "warn", + "typescript/no-deprecated": "warn", + "typescript/no-misused-promises": "warn", + // Rethrowing / rejecting with a caught `unknown` is propagation, not a bug. + "typescript/only-throw-error": ["warn", { "allowThrowingUnknown": true }], + "typescript/prefer-promise-reject-errors": ["warn", { "allowThrowingUnknown": true }], + "typescript/restrict-plus-operands": "warn", + "typescript/switch-exhaustiveness-check": [ + "warn", + { "considerDefaultExhaustiveForUnions": true } + ], + + // --- Turned off from the enabled categories --- + // Intentional control-character stripping and ANSI/terminal handling. + "eslint/no-control-regex": "off", + // Private-by-convention `_field` names are common here. + "eslint/no-underscore-dangle": "off", + // Side-effect imports (polyfills, registrations) are deliberate. + "import/no-unassigned-import": "off", + // Fires on `.then()` chains used for side effects. + "promise/always-return": "off", + // Worker onmessage/postMessage are NativeScript workers, not windows. + "unicorn/prefer-add-event-listener": "off", + "unicorn/require-post-message-target-origin": "off", + // In-place sort/reverse on locally owned arrays is fine. + "unicorn/no-array-sort": "off", + "unicorn/no-array-reverse": "off", + // Stylistic: prefers hoisting closures that don't capture anything. + "unicorn/consistent-function-scoping": "off", + // `for (const l of [...listeners])` snapshots before notifying. + "unicorn/no-useless-spread": "off", + // references.d.ts pulls in @nativescript/types this way. + "typescript/triple-slash-reference": "off", + // Mostly `${error}` on unknown catch values, which is fine. + "typescript/restrict-template-expressions": "off", + // Mostly String(x) on unknown-typed parsed JSON. + "typescript/no-base-to-string": "off", + // Flags exhaustive switches that tsc already checks. + "typescript/consistent-return": "off", + // The app is not strictNullChecks, so these misfire on `!` and on + // String()/Number() coercions of Java-bridged values. + "typescript/no-unnecessary-type-assertion": "off", + "typescript/no-unnecessary-type-conversion": "off", + // Too noisy for NativeScript code that casts bridged `any` values. + "typescript/no-unsafe-type-assertion": "off" + }, + // TypeScript only: scripts, tests and vendored web code are plain JS. + "ignorePatterns": [ + "**/*.js", + "**/*.cjs", + "**/*.mjs", + "**/*.jsx", + "node_modules/**", + "platforms/**", + "dist/**", + "faceclaw-extensions/dist/**", + "old/**", + "tmp/**" + ] +} diff --git a/CLAUDE.md b/CLAUDE.md index 7dd039ef..128f6379 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -21,9 +21,10 @@ relevant tools and an Android device ID to install on; do this in build_paths.sh, which is created from build_paths.sh.template and not checked into git. -To lint and typecheck, prefer to use build.sh; if the user asks you to run or +To typecheck, prefer to use build.sh; if the user asks you to run or test the app, use build_and_run.sh and then use `adb logcat` to view the -results. +results. `lint.sh` (`npm run lint`) runs oxlint over the TypeScript, including +type-aware rules; rule selection is in .oxlintrc.json. If you are working on low-level communication bits, consider checking out https://github.com/Commute773/g2-kit-unofficial/ and referring to ble/docs/ diff --git a/app/apps/ai-chat/ai-chat-app.ts b/app/apps/ai-chat/ai-chat-app.ts index 256c90af..83b176e4 100644 --- a/app/apps/ai-chat/ai-chat-app.ts +++ b/app/apps/ai-chat/ai-chat-app.ts @@ -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(); diff --git a/app/apps/blocks/blocks-app.worker.ts b/app/apps/blocks/blocks-app.worker.ts index b17adaf0..fb4ffd3b 100644 --- a/app/apps/blocks/blocks-app.worker.ts +++ b/app/apps/blocks/blocks-app.worker.ts @@ -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); diff --git a/app/apps/calculator/calculator-app.ts b/app/apps/calculator/calculator-app.ts index 53b68053..e71b827a 100644 --- a/app/apps/calculator/calculator-app.ts +++ b/app/apps/calculator/calculator-app.ts @@ -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", diff --git a/app/apps/calculator/math/advanced.ts b/app/apps/calculator/math/advanced.ts index 3ceb5112..fcba203e 100644 --- a/app/apps/calculator/math/advanced.ts +++ b/app/apps/calculator/math/advanced.ts @@ -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, diff --git a/app/apps/calculator/math/number-theory.ts b/app/apps/calculator/math/number-theory.ts index 405b3c42..dd3f83e9 100644 --- a/app/apps/calculator/math/number-theory.ts +++ b/app/apps/calculator/math/number-theory.ts @@ -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 { diff --git a/app/apps/calculator/math/polynomial.ts b/app/apps/calculator/math/polynomial.ts index 404ed4a7..b93e7269 100644 --- a/app/apps/calculator/math/polynomial.ts +++ b/app/apps/calculator/math/polynomial.ts @@ -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++) { diff --git a/app/apps/calculator/math/solver.ts b/app/apps/calculator/math/solver.ts index 385d2a44..1a34afab 100644 --- a/app/apps/calculator/math/solver.ts +++ b/app/apps/calculator/math/solver.ts @@ -19,7 +19,6 @@ import { multiplyExpr, negate, num, - numberValue, relation as relationExpr, spokenRelation, subtractExpr, diff --git a/app/apps/calculator/math/symbolic-integral.ts b/app/apps/calculator/math/symbolic-integral.ts index 6897868f..7d71367f 100644 --- a/app/apps/calculator/math/symbolic-integral.ts +++ b/app/apps/calculator/math/symbolic-integral.ts @@ -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 { diff --git a/app/apps/calculator/math/text-renderer.ts b/app/apps/calculator/math/text-renderer.ts index 04adcb95..57dbad68 100644 --- a/app/apps/calculator/math/text-renderer.ts +++ b/app/apps/calculator/math/text-renderer.ts @@ -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)}`; } } diff --git a/app/apps/calculator/math/trigonometry.ts b/app/apps/calculator/math/trigonometry.ts index 53ba6fe7..82e19ab8 100644 --- a/app/apps/calculator/math/trigonometry.ts +++ b/app/apps/calculator/math/trigonometry.ts @@ -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`; } diff --git a/app/apps/calendar/calendar-app.ts b/app/apps/calendar/calendar-app.ts index 80098e9b..39caf6ff 100644 --- a/app/apps/calendar/calendar-app.ts +++ b/app/apps/calendar/calendar-app.ts @@ -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 | 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", diff --git a/app/apps/compass/compass-app.ts b/app/apps/compass/compass-app.ts index 3c7b9b1c..00e0c818 100644 --- a/app/apps/compass/compass-app.ts +++ b/app/apps/compass/compass-app.ts @@ -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", diff --git a/app/apps/developer/accelerometer-demo.ts b/app/apps/developer/accelerometer-demo.ts index 657e85cf..bdc88c0a 100644 --- a/app/apps/developer/accelerometer-demo.ts +++ b/app/apps/developer/accelerometer-demo.ts @@ -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"; diff --git a/app/apps/developer/buzzer-demo.ts b/app/apps/developer/buzzer-demo.ts index 1772d555..258ace7c 100644 --- a/app/apps/developer/buzzer-demo.ts +++ b/app/apps/developer/buzzer-demo.ts @@ -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 { diff --git a/app/apps/developer/screen-test.ts b/app/apps/developer/screen-test.ts index af3e7491..52cb911f 100644 --- a/app/apps/developer/screen-test.ts +++ b/app/apps/developer/screen-test.ts @@ -64,6 +64,8 @@ export class ScreenTestLayer implements Layer { case "double-click": ctx.stack.pop(); return; + default: + return; } } } diff --git a/app/apps/developer/unicode-test.ts b/app/apps/developer/unicode-test.ts index 35c3ff37..200c86d7 100644 --- a/app/apps/developer/unicode-test.ts +++ b/app/apps/developer/unicode-test.ts @@ -236,6 +236,8 @@ export class UnicodeSampleLayer implements Layer { case "double-click": ctx.stack.pop(); return; + default: + return; } } diff --git a/app/apps/evenhub/even-platform.ts b/app/apps/evenhub/even-platform.ts index bee53a2c..18283f3d 100644 --- a/app/apps/evenhub/even-platform.ts +++ b/app/apps/evenhub/even-platform.ts @@ -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; diff --git a/app/apps/evenhub/permissions.ts b/app/apps/evenhub/permissions.ts index 31c545f0..0eeb0f59 100644 --- a/app/apps/evenhub/permissions.ts +++ b/app/apps/evenhub/permissions.ts @@ -22,7 +22,7 @@ export type EvenHubPermissionName = | "album" | "camera" | "fs" - | string; + | (string & {}); export type EvenHubPermission = { name: EvenHubPermissionName; diff --git a/app/apps/evenhub/session.ts b/app/apps/evenhub/session.ts index 19bb344c..95957c1d 100644 --- a/app/apps/evenhub/session.ts +++ b/app/apps/evenhub/session.ts @@ -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({}); diff --git a/app/apps/evenhub/updates.ts b/app/apps/evenhub/updates.ts index 05139c4c..0a2016aa 100644 --- a/app/apps/evenhub/updates.ts +++ b/app/apps/evenhub/updates.ts @@ -73,7 +73,7 @@ export async function checkForEvenHubUpdates( onProgress?: (done: number, total: number) => void, ): Promise { const installed = getInstalledEvenHubApps(); - const results: EvenHubAppUpdate[] = new Array(installed.length); + const results: EvenHubAppUpdate[] = []; let next = 0; let done = 0; const worker = async () => { diff --git a/app/apps/files/image-viewer.ts b/app/apps/files/image-viewer.ts index 974dae06..a6bf3456 100644 --- a/app/apps/files/image-viewer.ts +++ b/app/apps/files/image-viewer.ts @@ -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"; diff --git a/app/apps/flappy/flappy-app.worker.ts b/app/apps/flappy/flappy-app.worker.ts index bdfb7c7a..27fae1c7 100644 --- a/app/apps/flappy/flappy-app.worker.ts +++ b/app/apps/flappy/flappy-app.worker.ts @@ -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; } } diff --git a/app/apps/freecell/freecell-app.worker.ts b/app/apps/freecell/freecell-app.worker.ts index ae4f2dc0..fb939857 100644 --- a/app/apps/freecell/freecell-app.worker.ts +++ b/app/apps/freecell/freecell-app.worker.ts @@ -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)) { diff --git a/app/apps/glanceboard/glanceboard-app.ts b/app/apps/glanceboard/glanceboard-app.ts index e6bc38f7..f0af566c 100644 --- a/app/apps/glanceboard/glanceboard-app.ts +++ b/app/apps/glanceboard/glanceboard-app.ts @@ -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; } diff --git a/app/apps/glanceboard/widgets/index.ts b/app/apps/glanceboard/widgets/index.ts index 2efd48ab..fa15a5ec 100644 --- a/app/apps/glanceboard/widgets/index.ts +++ b/app/apps/glanceboard/widgets/index.ts @@ -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; } diff --git a/app/apps/glanceboard/widgets/terminal-widget.ts b/app/apps/glanceboard/widgets/terminal-widget.ts index b48b8543..0401cf1c 100644 --- a/app/apps/glanceboard/widgets/terminal-widget.ts +++ b/app/apps/glanceboard/widgets/terminal-widget.ts @@ -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(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(); }); diff --git a/app/apps/launcher/launcher-app.ts b/app/apps/launcher/launcher-app.ts index 28ba2a90..a50ea683 100644 --- a/app/apps/launcher/launcher-app.ts +++ b/app/apps/launcher/launcher-app.ts @@ -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"; diff --git a/app/apps/microphones/mic-control.ts b/app/apps/microphones/mic-control.ts index 49b46251..fbb6a7b6 100644 --- a/app/apps/microphones/mic-control.ts +++ b/app/apps/microphones/mic-control.ts @@ -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 | null = null; private armed = false; diff --git a/app/apps/microphones/mic-session.ts b/app/apps/microphones/mic-session.ts index 5f019ab8..9de1aba3 100644 --- a/app/apps/microphones/mic-session.ts +++ b/app/apps/microphones/mic-session.ts @@ -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(); 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 diff --git a/app/apps/microphones/translate.ts b/app/apps/microphones/translate.ts index 8ddb1a2d..d27bbfa4 100644 --- a/app/apps/microphones/translate.ts +++ b/app/apps/microphones/translate.ts @@ -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(); @@ -59,7 +59,7 @@ export function identifyLanguage(text: string): Promise { }); } -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; diff --git a/app/apps/minesweeper/minesweeper-app.worker.ts b/app/apps/minesweeper/minesweeper-app.worker.ts index ebc22c9f..a4320d83 100644 --- a/app/apps/minesweeper/minesweeper-app.worker.ts +++ b/app/apps/minesweeper/minesweeper-app.worker.ts @@ -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)); diff --git a/app/apps/navigate/navigate-app.worker.ts b/app/apps/navigate/navigate-app.worker.ts index 14cdd830..4bdef4ab 100644 --- a/app/apps/navigate/navigate-app.worker.ts +++ b/app/apps/navigate/navigate-app.worker.ts @@ -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)); diff --git a/app/apps/navigate/route-follower.ts b/app/apps/navigate/route-follower.ts index e40fe8c1..455f83ba 100644 --- a/app/apps/navigate/route-follower.ts +++ b/app/apps/navigate/route-follower.ts @@ -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); diff --git a/app/apps/pinball/pinball-app.worker.ts b/app/apps/pinball/pinball-app.worker.ts index 30df48ed..57c6a5ea 100644 --- a/app/apps/pinball/pinball-app.worker.ts +++ b/app/apps/pinball/pinball-app.worker.ts @@ -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; } } } diff --git a/app/apps/roam/roam-api.ts b/app/apps/roam/roam-api.ts index a42782d5..ef33022b 100644 --- a/app/apps/roam/roam-api.ts +++ b/app/apps/roam/roam-api.ts @@ -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"); diff --git a/app/apps/roam/roam-app.worker.ts b/app/apps/roam/roam-app.worker.ts index 5ec556eb..5575154b 100644 --- a/app/apps/roam/roam-app.worker.ts +++ b/app/apps/roam/roam-app.worker.ts @@ -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)); diff --git a/app/apps/terminal/terminal-app.worker.ts b/app/apps/terminal/terminal-app.worker.ts index 4dfefaf6..d6bb3963 100644 --- a/app/apps/terminal/terminal-app.worker.ts +++ b/app/apps/terminal/terminal-app.worker.ts @@ -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)); diff --git a/app/apps/timer/timer-app.ts b/app/apps/timer/timer-app.ts index af61c195..a08fec9a 100644 --- a/app/apps/timer/timer-app.ts +++ b/app/apps/timer/timer-app.ts @@ -368,6 +368,7 @@ export class TimersLayer implements Layer { else timerEngine.restartTimer(timer.id); return; } + return; } case "new-timer": this.openDial(""); diff --git a/app/apps/transcribe/transcribe.ts b/app/apps/transcribe/transcribe.ts index 4fa5952a..3da56357 100644 --- a/app/apps/transcribe/transcribe.ts +++ b/app/apps/transcribe/transcribe.ts @@ -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); diff --git a/app/apps/weather/weather-app.ts b/app/apps/weather/weather-app.ts index a0efec28..ffe0fba5 100644 --- a/app/apps/weather/weather-app.ts +++ b/app/apps/weather/weather-app.ts @@ -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", diff --git a/app/g2/dashboard-controller.ts b/app/g2/dashboard-controller.ts index d07b9699..b7abb99b 100644 --- a/app/g2/dashboard-controller.ts +++ b/app/g2/dashboard-controller.ts @@ -47,7 +47,7 @@ const MIRROR_TOUCH_GESTURES: Record, 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 { diff --git a/app/g2/even-advertisement.ts b/app/g2/even-advertisement.ts index 342efdf9..84a9c3c0 100644 --- a/app/g2/even-advertisement.ts +++ b/app/g2/even-advertisement.ts @@ -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()); diff --git a/app/g2/firmware-builder.ts b/app/g2/firmware-builder.ts index bff6e2b5..1f5fb156 100644 --- a/app/g2/firmware-builder.ts +++ b/app/g2/firmware-builder.ts @@ -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. diff --git a/app/g2/glance-host.ts b/app/g2/glance-host.ts index 845e4cf8..e92613ad 100644 --- a/app/g2/glance-host.ts +++ b/app/g2/glance-host.ts @@ -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; diff --git a/app/g2/glance-state.ts b/app/g2/glance-state.ts index b8369486..9848d284 100644 --- a/app/g2/glance-state.ts +++ b/app/g2/glance-state.ts @@ -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) { diff --git a/app/g2/ios-preview-controller.ts b/app/g2/ios-preview-controller.ts index 617ca2c6..a0da264f 100644 --- a/app/g2/ios-preview-controller.ts +++ b/app/g2/ios-preview-controller.ts @@ -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 { - 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)) diff --git a/app/graphics/display-list.ts b/app/graphics/display-list.ts index 924f87d7..108f9b27 100644 --- a/app/graphics/display-list.ts +++ b/app/graphics/display-list.ts @@ -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'); diff --git a/app/graphics/draw-expression.ts b/app/graphics/draw-expression.ts index dab4604e..a8c3fa94 100644 --- a/app/graphics/draw-expression.ts +++ b/app/graphics/draw-expression.ts @@ -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); }; diff --git a/app/graphics/glyph-wire.ts b/app/graphics/glyph-wire.ts index 6d05f5b6..5dc9e176 100644 --- a/app/graphics/glyph-wire.ts +++ b/app/graphics/glyph-wire.ts @@ -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); diff --git a/app/graphics/image.ts b/app/graphics/image.ts index 6f3164c8..340fbccf 100644 --- a/app/graphics/image.ts +++ b/app/graphics/image.ts @@ -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) { diff --git a/app/graphics/shell-scene.ts b/app/graphics/shell-scene.ts index a7dcfdf0..640ca5f5 100644 --- a/app/graphics/shell-scene.ts +++ b/app/graphics/shell-scene.ts @@ -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) diff --git a/app/native/anthropic.ts b/app/native/anthropic.ts index 071867cb..8fd1ac0b 100644 --- a/app/native/anthropic.ts +++ b/app/native/anthropic.ts @@ -193,7 +193,7 @@ function finalizeBlocks(blocks: Map): 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; diff --git a/app/native/calendar-permissions.ios.ts b/app/native/calendar-permissions.ios.ts index 5758f457..42aa5cf7 100644 --- a/app/native/calendar-permissions.ios.ts +++ b/app/native/calendar-permissions.ios.ts @@ -24,7 +24,7 @@ async function requestPermission(): Promise { okButtonText: "Open Settings", cancelButtonText: "Cancel", }); - if (open) await Utils.openUrl("app-settings:"); + if (open) Utils.openUrl("app-settings:"); return false; } if (status === "restricted") { diff --git a/app/native/calendar.ios.ts b/app/native/calendar.ios.ts index 4b8b1c88..8c9eec23 100644 --- a/app/native/calendar.ios.ts +++ b/app/native/calendar.ios.ts @@ -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); } }); }); } diff --git a/app/native/faceclaw-communicator.ios.ts b/app/native/faceclaw-communicator.ios.ts index 704a4a66..eef18120 100644 --- a/app/native/faceclaw-communicator.ios.ts +++ b/app/native/faceclaw-communicator.ios.ts @@ -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; diff --git a/app/native/g2mirror-client.ts b/app/native/g2mirror-client.ts index c0b1274d..b93f18c7 100644 --- a/app/native/g2mirror-client.ts +++ b/app/native/g2mirror-client.ts @@ -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; diff --git a/app/native/ios-bluetooth.ts b/app/native/ios-bluetooth.ts index b1016b29..5c523858 100644 --- a/app/native/ios-bluetooth.ts +++ b/app/native/ios-bluetooth.ts @@ -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 { 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() diff --git a/app/native/kotlin-bridge.ts b/app/native/kotlin-bridge.ts index 6b463807..76ec68e4 100644 --- a/app/native/kotlin-bridge.ts +++ b/app/native/kotlin-bridge.ts @@ -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}`); } } diff --git a/app/native/kotlin-platform.android.ts b/app/native/kotlin-platform.android.ts index 3ece2aa1..cb33ffa3 100644 --- a/app/native/kotlin-platform.android.ts +++ b/app/native/kotlin-platform.android.ts @@ -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; diff --git a/app/native/media-browser.ts b/app/native/media-browser.ts index 80bd73b4..7da4d72a 100644 --- a/app/native/media-browser.ts +++ b/app/native/media-browser.ts @@ -30,8 +30,8 @@ type PendingRequest = { * 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>(); private readonly pendingBrowses = new Map>(); diff --git a/app/native/media-controller.ts b/app/native/media-controller.ts index e685a123..e81a98e9 100644 --- a/app/native/media-controller.ts +++ b/app/native/media-controller.ts @@ -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; diff --git a/app/native/nightscout-bridge.ts b/app/native/nightscout-bridge.ts index de0856dc..9271d7c2 100644 --- a/app/native/nightscout-bridge.ts +++ b/app/native/nightscout-bridge.ts @@ -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), diff --git a/app/native/notification-icons.ts b/app/native/notification-icons.ts index 6d5c2665..4ea179dc 100644 --- a/app/native/notification-icons.ts +++ b/app/native/notification-icons.ts @@ -20,7 +20,7 @@ let cachedIcons: GrayImage[] = []; let cachedAtMs = 0; const keyedIconCache = new Map(); 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 { diff --git a/app/native/openai.ts b/app/native/openai.ts index bba3b840..46e2e1f6 100644 --- a/app/native/openai.ts +++ b/app/native/openai.ts @@ -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; diff --git a/app/native/qr-scan.ios.ts b/app/native/qr-scan.ios.ts index bc74376a..748331c7 100644 --- a/app/native/qr-scan.ios.ts +++ b/app/native/qr-scan.ios.ts @@ -14,7 +14,8 @@ export function scanQrCode(): Promise { 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)) } diff --git a/app/native/voice-control.ios.ts b/app/native/voice-control.ios.ts index a1095779..2896e21d 100644 --- a/app/native/voice-control.ios.ts +++ b/app/native/voice-control.ios.ts @@ -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 diff --git a/app/native/voice-control.ts b/app/native/voice-control.ts index f3acadab..cdaedf74 100644 --- a/app/native/voice-control.ts +++ b/app/native/voice-control.ts @@ -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 = ""; diff --git a/app/native/wear-bridge.ts b/app/native/wear-bridge.ts index c11c55ae..a2871218 100644 --- a/app/native/wear-bridge.ts +++ b/app/native/wear-bridge.ts @@ -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(); private readonly connectionListeners = new Set(); 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; diff --git a/app/phone-ui/main-page.ios.ts b/app/phone-ui/main-page.ios.ts index 1646357c..3419dfc0 100644 --- a/app/phone-ui/main-page.ios.ts +++ b/app/phone-ui/main-page.ios.ts @@ -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) => { diff --git a/app/phone-ui/onboarding-flash-view-model.ts b/app/phone-ui/onboarding-flash-view-model.ts index 3249c97c..7c459a7e 100644 --- a/app/phone-ui/onboarding-flash-view-model.ts +++ b/app/phone-ui/onboarding-flash-view-model.ts @@ -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 = () => 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, headline = "Something Went Wrong"): void { this.retryAction = retry; this.status = message; this.setPhase("error"); diff --git a/app/remote/service.ts b/app/remote/service.ts index 2c324229..46c06d97 100644 --- a/app/remote/service.ts +++ b/app/remote/service.ts @@ -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; diff --git a/app/ui/dashboard-settings.ts b/app/ui/dashboard-settings.ts index 01ffac01..8ae9c943 100644 --- a/app/ui/dashboard-settings.ts +++ b/app/ui/dashboard-settings.ts @@ -100,7 +100,8 @@ export abstract class ConfigSetting { } export class ConfigSettingBoolean extends ConfigSetting { - constructor(options: ConfigSettingOptions) { + // Widens ConfigSetting's protected constructor. + public constructor(options: ConfigSettingOptions) { 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( export function textSettingMenuItem( setting: ConfigSettingString, - opts?: SettingsMenuOptions ): MenuItem { return { label: setting.label, diff --git a/app/ui/font-picker.ts b/app/ui/font-picker.ts index ba06b1b6..031fba76 100644 --- a/app/ui/font-picker.ts +++ b/app/ui/font-picker.ts @@ -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"; diff --git a/app/ui/notifications.ts b/app/ui/notifications.ts index e52adfaa..57766945 100644 --- a/app/ui/notifications.ts +++ b/app/ui/notifications.ts @@ -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); }, }), }; diff --git a/app/ui/shell/brightness-picker-layer.ts b/app/ui/shell/brightness-picker-layer.ts index 85926a52..f735b0ab 100644 --- a/app/ui/shell/brightness-picker-layer.ts +++ b/app/ui/shell/brightness-picker-layer.ts @@ -61,6 +61,8 @@ export class BrightnessPickerLayer implements Layer { case "double-click": ctx.stack.pop(); return; + default: + return; } } } diff --git a/app/ui/shell/open-apps-persistence.ts b/app/ui/shell/open-apps-persistence.ts index 8f5cd4d6..fe7cb4de 100644 --- a/app/ui/shell/open-apps-persistence.ts +++ b/app/ui/shell/open-apps-persistence.ts @@ -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); diff --git a/app/ui/shell/shell.ts b/app/ui/shell/shell.ts index 451a5e27..8ce042c8 100644 --- a/app/ui/shell/shell.ts +++ b/app/ui/shell/shell.ts @@ -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 diff --git a/app/ui/shell/tool-debug-layer.ts b/app/ui/shell/tool-debug-layer.ts index debc9d73..6dcdd333 100644 --- a/app/ui/shell/tool-debug-layer.ts +++ b/app/ui/shell/tool-debug-layer.ts @@ -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; } } } diff --git a/app/ui/shell/worker-state.ts b/app/ui/shell/worker-state.ts index e8b7536d..3216aaaa 100644 --- a/app/ui/shell/worker-state.ts +++ b/app/ui/shell/worker-state.ts @@ -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(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(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); }; } diff --git a/app/ui/shell/worker-window.ts b/app/ui/shell/worker-window.ts index 1657644d..3ef4685b 100644 --- a/app/ui/shell/worker-window.ts +++ b/app/ui/shell/worker-window.ts @@ -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) => { diff --git a/faceclaw-extensions/dist/index.d.ts b/faceclaw-extensions/dist/index.d.ts deleted file mode 100644 index 63a80290..00000000 --- a/faceclaw-extensions/dist/index.d.ts +++ /dev/null @@ -1,236 +0,0 @@ -/** - * faceclaw-extensions — type definitions for the Faceclaw extension API. - * - * Faceclaw (https://github.com/…/faceclaw) is an alternative host for EvenHub - * apps that runs them directly on the Even Realities G2 glasses instead of the - * stock Even app. An app built against the standard `@evenrealities/even_hub_sdk` - * runs unchanged. When it happens to be running inside Faceclaw, this package - * lets it detect that and reach a few extra, Faceclaw-only capabilities. - * - * Design contract: - * - The only entry point is the injected global `window.getFaceclawExtensions`. - * It is `(() => FaceclawExtensions) | null` inside Faceclaw and `undefined` - * in the stock Even app (and any other host). Nothing on the standard SDK or - * on built-in prototypes is modified — every Faceclaw capability lives behind - * this one global, so it is always obvious what is an extension and standard - * apps keep working everywhere. - * - New functionality is only ever *added* here; existing members keep their - * behavior, so pinning a version stays backwards-compatible. - * - * Usage: - * ```ts - * import { getFaceclawExtensions } from "faceclaw-extensions"; - * - * const fc = getFaceclawExtensions(); - * if (fc) { - * console.log("Running in", fc.getVersion()); // "Faceclaw/0.4.0" - * fc.addWindowLifecycleListener((e) => { - * if (e.type === "hidden") pauseExpensiveWork(); - * }); - * } - * ``` - */ -/** Third-party API-key services whose keys the user may have configured in Faceclaw. */ -export type ApiKeyService = "openai" | "anthropic" | "soniox" | "elevenlabs" | "mapbox"; -/** - * One step of a piezo-buzzer tone sequence. The G2 has a single monophonic PWM - * buzzer; a sequence plays back-to-back steps on the firmware's own timer. - */ -export interface BuzzerStep { - /** Tone frequency in Hz. The piezo is loudest ~1–4 kHz; faint below ~150 Hz. */ - freq: number; - /** Step duration in milliseconds (1–65535). */ - ms: number; - /** PWM duty cycle, 0–100 (default 50). `duty: 0` is a rest (silence) for `ms`. */ - duty?: number; -} -/** - * Window lifecycle transitions, delivered to - * {@link FaceclawExtensions.addWindowLifecycleListener}: - * - `visible` / `hidden`: the app's glasses window became the shown surface, or - * stopped being it — because the user switched the foreground window or the - * phone screen turned on/off. A hidden app keeps running (Faceclaw keeps its - * webview alive) but nothing it renders reaches the glasses. - * - `focused` / `blurred`: input focus moved onto or off the app's window (e.g. - * the user opened the app switcher). A blurred-but-visible app is still shown - * but no longer receives taps/scrolls. - * - * An app can assume it starts `visible` and `focused` at launch; events report - * changes from there. - */ -export type WindowLifecycleEventType = "visible" | "hidden" | "focused" | "blurred"; -export interface WindowLifecycleEvent { - type: WindowLifecycleEventType; -} -/** - * A magnetometer heading sample from {@link FaceclawExtensions.addCompassListener}. - * All headings are degrees clockwise in [0, 360). - */ -export interface CompassReading { - /** - * Raw magnetic heading as reported by the glasses, with no correction for - * how they sit on the wearer's head. Kept for apps that zero it themselves. - */ - headingDegrees: number; - /** - * Magnetic heading corrected by the wearer's calibration offset from the - * host's Compass app. Equal to `headingDegrees` until they calibrate. - */ - magneticHeadingDegrees: number; - /** - * Whether the wearer has been through the host's compass calibration, i.e. - * whether `magneticHeadingDegrees` and `trueHeadingDegrees` can be trusted - * as absolute rather than relative. - */ - wearerCalibrated: boolean; - /** - * Local magnetic declination (east positive), from the phone's location and - * the World Magnetic Model. Absent when the host has no location. - */ - declinationDegrees?: number; - /** `magneticHeadingDegrees` plus declination. Absent when declination is. */ - trueHeadingDegrees?: number; -} -export interface FaceclawContainerCommon { - containerID: number; - containerName: string; - xPosition: number; - yPosition: number; - width: number; - height: number; - zOrderIndex?: number; - isEventCapture?: 0 | 1 | boolean; - /** Inherit content from the same-named container in the previous layout. */ - preserve?: boolean; -} -export interface FaceclawTextContainer extends FaceclawContainerCommon { - content?: string; - borderWidth?: number; - borderRadius?: number; - paddingLength?: number; -} -/** Image containers may be up to 576x452 in the extended layout. */ -export type FaceclawImageContainer = FaceclawContainerCommon; -export interface FaceclawListContainer extends FaceclawContainerCommon { - itemContainer?: { - itemName?: string[]; - itemWidth?: number; - isItemSelectBorderEn?: 0 | 1 | boolean; - }; -} -export interface FaceclawLayout { - textObject?: FaceclawTextContainer[]; - imageObject?: FaceclawImageContainer[]; - listObject?: FaceclawListContainer[]; -} -/** - * A tool the app contributes to Faceclaw's voice assistant. The assistant sees - * it namespaced by the app's package name (`app..`); `name` - * here is the bare, un-prefixed name. - */ -export interface AssistantTool { - /** Bare tool name (no package prefix), e.g. `"set_color"`. */ - name: string; - /** What the tool does — the assistant reads this to decide when to call it. */ - description: string; - /** JSON Schema for the arguments object the assistant will pass to `handler`. */ - parameters?: object; - /** - * When the tool is callable: `"foreground"` (default) only while the app owns - * the visible window; `"open"` any time the app is running (even backgrounded). - */ - availability?: "open" | "foreground"; - /** - * Invoked when the assistant calls the tool. Return a string (or any - * JSON-serializable value) to report back to the assistant; throw to report an - * error. May be async. - */ - handler: (args: any) => unknown | Promise; -} -/** - * The Faceclaw-only capability surface. Obtained via {@link getFaceclawExtensions}. - * Every method is additive to the standard EvenHub SDK. - */ -export interface FaceclawExtensions { - /** Host version string, e.g. `"Faceclaw/0.4.0"`. */ - getVersion(): string; - /** - * Hand input focus back to Faceclaw's app switcher without closing the app - * (it keeps running in the background). Equivalent to the user double-tapping - * out, but explicit. - */ - returnToAppSwitcher(): void; - /** - * Close this app for real and tear down its window. Unlike the stock - * `shutDownPageContainer(1)` — which Faceclaw interprets as "return to the app - * switcher" so double-tap-to-quit apps stay alive — this always quits. - */ - quit(): void; - /** - * Subscribe to window lifecycle changes (see {@link WindowLifecycleEvent}). - * Returns an unsubscribe function. - */ - addWindowLifecycleListener(listener: (event: WindowLifecycleEvent) => void): () => void; - /** - * List which API-key services the user has configured in Faceclaw. Returns - * only the service names, never the key values — use - * {@link requestApiKeyAccess} to obtain values (with the user's consent). - */ - getConfiguredApiKeys(): Promise; - /** - * Ask the user to share one or more configured API keys with this app. Opens - * a consent prompt on the glasses. Resolves with a map of the granted keys' - * values (only for services that are both requested and configured); services - * the user declines, or that aren't configured, are absent. Resolves with an - * empty object if the user denies. - */ - requestApiKeyAccess(services: ApiKeyService[]): Promise>>; - /** - * Play a tone sequence on the glasses' piezo buzzer. Sequences longer than the - * firmware's per-message cap (48 steps) are split and paced automatically. - * Resolves once every message has been queued. - */ - playBuzzer(steps: BuzzerStep[]): Promise; - /** - * Activate the glasses' magnetometer compass and receive heading samples. - * Returns an unsubscribe function; the sensor stays on while at least one - * listener is registered and the app is the foreground window. - * - * The magnetometer sits inside the right arm, which rests against the - * wearer's head with a slight curl that differs between wearers (and between - * wears), so `headingDegrees` is relative. The host's Compass app lets the - * wearer calibrate that away and adds local declination: prefer - * `trueHeadingDegrees` when present, then `magneticHeadingDegrees`, and check - * `wearerCalibrated` before trusting either as absolute. - */ - addCompassListener(listener: (reading: CompassReading) => void): () => void; - /** - * Build the app's initial page from an extended layout (superset of the stock - * createStartUpPageContainer — full 576x452 canvas, no container-count limit, - * per-container `preserve`). Resolves true on success. - */ - createLayout(layout: FaceclawLayout): Promise; - /** - * Replace the current page with a new extended layout (superset of the stock - * rebuildPageContainer). Containers marked `preserve` inherit their content - * from the same-named container in the outgoing layout. Resolves true on success. - */ - replaceLayout(layout: FaceclawLayout): Promise; - /** - * Declare the app's voice-assistant tools, replacing any previously set. Each - * tool's `handler` runs in the app when the assistant calls it. The assistant - * sees the tools namespaced by the app's package name. Pass `[]` to remove all. - */ - setAssistantTools(tools: AssistantTool[]): void; -} -declare global { - interface Window { - /** Injected by Faceclaw; `undefined` in the stock Even app and other hosts. */ - getFaceclawExtensions?: (() => FaceclawExtensions) | null; - } -} -/** - * Return the Faceclaw extension API if the app is running inside Faceclaw, or - * `null` otherwise (the stock Even app, a browser, etc.). Safe to call anywhere. - */ -export declare function getFaceclawExtensions(): FaceclawExtensions | null; diff --git a/faceclaw-extensions/dist/index.js b/faceclaw-extensions/dist/index.js deleted file mode 100644 index 88c290ac..00000000 --- a/faceclaw-extensions/dist/index.js +++ /dev/null @@ -1,40 +0,0 @@ -/** - * faceclaw-extensions — type definitions for the Faceclaw extension API. - * - * Faceclaw (https://github.com/…/faceclaw) is an alternative host for EvenHub - * apps that runs them directly on the Even Realities G2 glasses instead of the - * stock Even app. An app built against the standard `@evenrealities/even_hub_sdk` - * runs unchanged. When it happens to be running inside Faceclaw, this package - * lets it detect that and reach a few extra, Faceclaw-only capabilities. - * - * Design contract: - * - The only entry point is the injected global `window.getFaceclawExtensions`. - * It is `(() => FaceclawExtensions) | null` inside Faceclaw and `undefined` - * in the stock Even app (and any other host). Nothing on the standard SDK or - * on built-in prototypes is modified — every Faceclaw capability lives behind - * this one global, so it is always obvious what is an extension and standard - * apps keep working everywhere. - * - New functionality is only ever *added* here; existing members keep their - * behavior, so pinning a version stays backwards-compatible. - * - * Usage: - * ```ts - * import { getFaceclawExtensions } from "faceclaw-extensions"; - * - * const fc = getFaceclawExtensions(); - * if (fc) { - * console.log("Running in", fc.getVersion()); // "Faceclaw/0.4.0" - * fc.addWindowLifecycleListener((e) => { - * if (e.type === "hidden") pauseExpensiveWork(); - * }); - * } - * ``` - */ -/** - * Return the Faceclaw extension API if the app is running inside Faceclaw, or - * `null` otherwise (the stock Even app, a browser, etc.). Safe to call anywhere. - */ -export function getFaceclawExtensions() { - const getter = typeof window !== "undefined" ? window.getFaceclawExtensions : null; - return typeof getter === "function" ? getter() : null; -} diff --git a/faceclaw-extensions/src/index.ts b/faceclaw-extensions/src/index.ts index d4706764..5ca31f5c 100644 --- a/faceclaw-extensions/src/index.ts +++ b/faceclaw-extensions/src/index.ts @@ -172,7 +172,7 @@ export interface AssistantTool { * JSON-serializable value) to report back to the assistant; throw to report an * error. May be async. */ - handler: (args: any) => unknown | Promise; + handler: (args: any) => unknown; } /** diff --git a/faceclaw-extensions/tsconfig.json b/faceclaw-extensions/tsconfig.json index a9bd75c7..f695761c 100644 --- a/faceclaw-extensions/tsconfig.json +++ b/faceclaw-extensions/tsconfig.json @@ -4,6 +4,7 @@ "module": "ESNext", "moduleResolution": "bundler", "declaration": true, + "rootDir": "src", "outDir": "dist", "strict": true, "skipLibCheck": true, diff --git a/package-lock.json b/package-lock.json index bb9bf530..10bc16d5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -26,6 +26,8 @@ "@nativescript/ios": "9.0.3", "@nativescript/types": "~9.0.0", "@nativescript/webpack": "~5.0.25", + "oxlint": "^1.85.0", + "oxlint-tsgolint": "^7.0.2003", "typescript": "~5.4.0" } }, @@ -622,6 +624,437 @@ } } }, + "node_modules/@oxlint-tsgolint/darwin-arm64": { + "version": "7.0.2003", + "resolved": "https://registry.npmjs.org/@oxlint-tsgolint/darwin-arm64/-/darwin-arm64-7.0.2003.tgz", + "integrity": "sha512-TgV33rXr6ueXBwvc+0nssUkTBSXHJxv77I8p4RCjDjCnvexHtmoPiudVRDfj3S3puMDdeQdHW6jdUgUPy3nr/w==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ] + }, + "node_modules/@oxlint-tsgolint/darwin-x64": { + "version": "7.0.2003", + "resolved": "https://registry.npmjs.org/@oxlint-tsgolint/darwin-x64/-/darwin-x64-7.0.2003.tgz", + "integrity": "sha512-hY3FMAjIaPDdK3FNxyRXRfHPOFeoBn6dmnLyKZgQ2IbTTD1adXhl6PfCIqHhCPvurigv7nf7mYuWZZ19MmJzmg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ] + }, + "node_modules/@oxlint-tsgolint/linux-arm64": { + "version": "7.0.2003", + "resolved": "https://registry.npmjs.org/@oxlint-tsgolint/linux-arm64/-/linux-arm64-7.0.2003.tgz", + "integrity": "sha512-eAET4JpyfBbg8SO0K74o4R55tEjVC292pIyxGOw2XGf8x/HrPNyxwQ478jMYOM54FIVOHc8sJ6VRHxluy6lucw==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@oxlint-tsgolint/linux-x64": { + "version": "7.0.2003", + "resolved": "https://registry.npmjs.org/@oxlint-tsgolint/linux-x64/-/linux-x64-7.0.2003.tgz", + "integrity": "sha512-GXdyO/XyqDJ3s/llR/oOktLsYNjZtWSQBy0JMc+/0gsNPvTcseKPhn9c6KcFyWmnr6H4vljYALbujonqSzzEGw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@oxlint-tsgolint/win32-arm64": { + "version": "7.0.2003", + "resolved": "https://registry.npmjs.org/@oxlint-tsgolint/win32-arm64/-/win32-arm64-7.0.2003.tgz", + "integrity": "sha512-TWauXnPfet0VgpmrstoAK58eJ4gbuwPUuUTQmYQAzE/RG1CpnxXtrKUJULf6lyerPE4KN3gM+DflIA1hOH+38Q==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/@oxlint-tsgolint/win32-x64": { + "version": "7.0.2003", + "resolved": "https://registry.npmjs.org/@oxlint-tsgolint/win32-x64/-/win32-x64-7.0.2003.tgz", + "integrity": "sha512-DoRmfe7j8VqNlukp8liRVW45GQDhzRccNenjD/pdzelgtffW47pCMd1xbJLkPaPbKnTwID3onn3VZlL7JbebEA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/@oxlint/binding-android-arm-eabi": { + "version": "1.85.0", + "resolved": "https://registry.npmjs.org/@oxlint/binding-android-arm-eabi/-/binding-android-arm-eabi-1.85.0.tgz", + "integrity": "sha512-q2KO/Zso9UT+OMn0NF9ywn4E4t0MI3yxiDhNyhsQ7DyQJrC4FhFE4TXOi4bktFnOWXTMds8qZSbpv2XwRaNOBg==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxlint/binding-android-arm64": { + "version": "1.85.0", + "resolved": "https://registry.npmjs.org/@oxlint/binding-android-arm64/-/binding-android-arm64-1.85.0.tgz", + "integrity": "sha512-SxLN3ALjoT9NNdvpjEevGeHvfzTAFrF0NBYB5tzK7/GtCKMze3j1e/m/X2ozqGj2U9hfGG/dg/OG8vpVK4PiDA==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxlint/binding-darwin-arm64": { + "version": "1.85.0", + "resolved": "https://registry.npmjs.org/@oxlint/binding-darwin-arm64/-/binding-darwin-arm64-1.85.0.tgz", + "integrity": "sha512-Y/Sup/J4f0f9UGsSd/xyCNTeWL+gepO63GBdEDAfue9nBsnk9zMmnIXx1O6b1V8C90vB5nucYNZ0pbMXAp8zJA==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxlint/binding-darwin-x64": { + "version": "1.85.0", + "resolved": "https://registry.npmjs.org/@oxlint/binding-darwin-x64/-/binding-darwin-x64-1.85.0.tgz", + "integrity": "sha512-ApOSNC04ynpDTwvBD+//0wyfODRSbEzvRoKpX8teffmc27z8AockwSNeMXGJXn5KP85eahDgR/2llICWLkzcnw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxlint/binding-freebsd-x64": { + "version": "1.85.0", + "resolved": "https://registry.npmjs.org/@oxlint/binding-freebsd-x64/-/binding-freebsd-x64-1.85.0.tgz", + "integrity": "sha512-bNrVrCOA/kHky3Tu79IXWXe5bhIgLXfUuUEDHlAGOHUk96MkvDZ1ecaQF19rwstrnaqfP1o9nBTqzIr9+ZHkUg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxlint/binding-linux-arm-gnueabihf": { + "version": "1.85.0", + "resolved": "https://registry.npmjs.org/@oxlint/binding-linux-arm-gnueabihf/-/binding-linux-arm-gnueabihf-1.85.0.tgz", + "integrity": "sha512-NUrzOJ1s/EqsVvfn2L/1D8Wro2LPIZUbihL8kOJLh5fEdGEN3rdOGUYq3HwnUIL8sjpoP+4N6RaGrgmMJnaMPw==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxlint/binding-linux-arm-musleabihf": { + "version": "1.85.0", + "resolved": "https://registry.npmjs.org/@oxlint/binding-linux-arm-musleabihf/-/binding-linux-arm-musleabihf-1.85.0.tgz", + "integrity": "sha512-UJXrAT3E/RWkEqXLIs2ehETja1qfgkPb+5gwLIIS+o/6cf+grHvoOXTa5997a/YNQfcJS0DRBTOfZt95cvOI1g==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxlint/binding-linux-arm64-gnu": { + "version": "1.85.0", + "resolved": "https://registry.npmjs.org/@oxlint/binding-linux-arm64-gnu/-/binding-linux-arm64-gnu-1.85.0.tgz", + "integrity": "sha512-lK40QLjI0HxigO7CjDDshEtfYIeiYS0020v5BHFPqN4uuQBQxd2K9LNom2dW15o9F1937quSCRVp4ZsVhdbYdg==", + "cpu": [ + "arm64" + ], + "dev": true, + "libc": [ + "glibc" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxlint/binding-linux-arm64-musl": { + "version": "1.85.0", + "resolved": "https://registry.npmjs.org/@oxlint/binding-linux-arm64-musl/-/binding-linux-arm64-musl-1.85.0.tgz", + "integrity": "sha512-c2zbdBwGKreHXwRx3gWBuFGJxLhxgsg6YlZ+3H+RgRusU/UEV9jNwJ3HGYK+nRo0LvBa7mt6Kj86xoVotUo8cw==", + "cpu": [ + "arm64" + ], + "dev": true, + "libc": [ + "musl" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxlint/binding-linux-ppc64-gnu": { + "version": "1.85.0", + "resolved": "https://registry.npmjs.org/@oxlint/binding-linux-ppc64-gnu/-/binding-linux-ppc64-gnu-1.85.0.tgz", + "integrity": "sha512-tlt/Hy8lZ97/lCPmCgw/B3k/mwh+BzaIPbPkldZEly7TwLmx0xe2CQcaW2g/rR0dOgS9JNGCZsMEqLhUNMGvaw==", + "cpu": [ + "ppc64" + ], + "dev": true, + "libc": [ + "glibc" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxlint/binding-linux-riscv64-gnu": { + "version": "1.85.0", + "resolved": "https://registry.npmjs.org/@oxlint/binding-linux-riscv64-gnu/-/binding-linux-riscv64-gnu-1.85.0.tgz", + "integrity": "sha512-3tNR9Xey82X0zKuY1d8hJ6Rc9gwRDurmqGLnQZa5xqOXy8/YyiqFXjAtugkKLY82obOlpK1eSiDRlgcNPuxtIg==", + "cpu": [ + "riscv64" + ], + "dev": true, + "libc": [ + "glibc" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxlint/binding-linux-riscv64-musl": { + "version": "1.85.0", + "resolved": "https://registry.npmjs.org/@oxlint/binding-linux-riscv64-musl/-/binding-linux-riscv64-musl-1.85.0.tgz", + "integrity": "sha512-wbGRd5PqCcjkJFHhZuZ2OBSUQY9czlQsoA/cQQB9JK/L9mC5MQgGoKAh+xd8QjA5V+0D3j+Qd1lAWn1I8zlelA==", + "cpu": [ + "riscv64" + ], + "dev": true, + "libc": [ + "musl" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxlint/binding-linux-s390x-gnu": { + "version": "1.85.0", + "resolved": "https://registry.npmjs.org/@oxlint/binding-linux-s390x-gnu/-/binding-linux-s390x-gnu-1.85.0.tgz", + "integrity": "sha512-3Sn0kSrE4DPZCWV/8o+n4x3aFZxI9ulMnkYlwCbJ8eUVkwRK2IerohE/A/z3SNbCwoPFOCJmGE5Avrq0rrvdvQ==", + "cpu": [ + "s390x" + ], + "dev": true, + "libc": [ + "glibc" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxlint/binding-linux-x64-gnu": { + "version": "1.85.0", + "resolved": "https://registry.npmjs.org/@oxlint/binding-linux-x64-gnu/-/binding-linux-x64-gnu-1.85.0.tgz", + "integrity": "sha512-JY2pxxYfB62bAGfejljVCqc44etItehPuAyaeSAdMuEMtwNA00ggMnS66lC1oIhos6oOXUkuU6mZ9bpFh3BqWg==", + "cpu": [ + "x64" + ], + "dev": true, + "libc": [ + "glibc" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxlint/binding-linux-x64-musl": { + "version": "1.85.0", + "resolved": "https://registry.npmjs.org/@oxlint/binding-linux-x64-musl/-/binding-linux-x64-musl-1.85.0.tgz", + "integrity": "sha512-5k74vZ6qJBjBHEOlBk9B/iv68Yu0F1Afw/vvT2ar6OGCqEeXLaSjXz2n/IPCbhLG22UoKoYEJTzpYraRdcp6PA==", + "cpu": [ + "x64" + ], + "dev": true, + "libc": [ + "musl" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxlint/binding-openharmony-arm64": { + "version": "1.85.0", + "resolved": "https://registry.npmjs.org/@oxlint/binding-openharmony-arm64/-/binding-openharmony-arm64-1.85.0.tgz", + "integrity": "sha512-GbAl5qt5TCkPLXTaIISZJnugrcBhra6rodcXc9jYt620UtdsTt71NlNmJmm0frxzFpd54x/G+MkitEJA8I/BoA==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openharmony" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxlint/binding-win32-arm64-msvc": { + "version": "1.85.0", + "resolved": "https://registry.npmjs.org/@oxlint/binding-win32-arm64-msvc/-/binding-win32-arm64-msvc-1.85.0.tgz", + "integrity": "sha512-kjmws5MK0et2swk4ND85D7NVQyDHw162i6whtZDLUA/lo6FQyBZDcmMRCMcVZcNrAhIaftVb00x9ChGDOjjNJA==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxlint/binding-win32-ia32-msvc": { + "version": "1.85.0", + "resolved": "https://registry.npmjs.org/@oxlint/binding-win32-ia32-msvc/-/binding-win32-ia32-msvc-1.85.0.tgz", + "integrity": "sha512-eSsIJx9n4yxvOqYTZyPEMyEXRmE60XH7xGAU7i0Qbsn1lf6Za3CWJ9aRd82oSFKXaxhp+sA6/yMJVRIpLpna6A==", + "cpu": [ + "ia32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxlint/binding-win32-x64-msvc": { + "version": "1.85.0", + "resolved": "https://registry.npmjs.org/@oxlint/binding-win32-x64-msvc/-/binding-win32-x64-msvc-1.85.0.tgz", + "integrity": "sha512-pBebIPUpKKhWrhSMWhy8TdAZBewiXnfxmaAGxhzxM1068GagqFaTwgKlU6e+UyJ2sPR+VoHouhXuGJkQjsrDvA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, "node_modules/@parcel/watcher": { "version": "2.5.6", "resolved": "https://registry.npmjs.org/@parcel/watcher/-/watcher-2.5.6.tgz", @@ -3235,6 +3668,73 @@ "opener": "bin/opener-bin.js" } }, + "node_modules/oxlint": { + "version": "1.85.0", + "resolved": "https://registry.npmjs.org/oxlint/-/oxlint-1.85.0.tgz", + "integrity": "sha512-bc26s97nuvPj1ViyPsqmKecVkUWFMEdtayO8MaQ6oiLfs1pj94cQlZZhrh4BPNlr9HQosjhIlwgZKsfcwmcNgg==", + "dev": true, + "license": "MIT", + "bin": { + "oxlint": "bin/oxlint" + }, + "engines": { + "node": "^20.19.0 || >=22.12.0" + }, + "funding": { + "url": "https://github.com/sponsors/oxc-project" + }, + "optionalDependencies": { + "@oxlint/binding-android-arm-eabi": "1.85.0", + "@oxlint/binding-android-arm64": "1.85.0", + "@oxlint/binding-darwin-arm64": "1.85.0", + "@oxlint/binding-darwin-x64": "1.85.0", + "@oxlint/binding-freebsd-x64": "1.85.0", + "@oxlint/binding-linux-arm-gnueabihf": "1.85.0", + "@oxlint/binding-linux-arm-musleabihf": "1.85.0", + "@oxlint/binding-linux-arm64-gnu": "1.85.0", + "@oxlint/binding-linux-arm64-musl": "1.85.0", + "@oxlint/binding-linux-ppc64-gnu": "1.85.0", + "@oxlint/binding-linux-riscv64-gnu": "1.85.0", + "@oxlint/binding-linux-riscv64-musl": "1.85.0", + "@oxlint/binding-linux-s390x-gnu": "1.85.0", + "@oxlint/binding-linux-x64-gnu": "1.85.0", + "@oxlint/binding-linux-x64-musl": "1.85.0", + "@oxlint/binding-openharmony-arm64": "1.85.0", + "@oxlint/binding-win32-arm64-msvc": "1.85.0", + "@oxlint/binding-win32-ia32-msvc": "1.85.0", + "@oxlint/binding-win32-x64-msvc": "1.85.0" + }, + "peerDependencies": { + "oxlint-tsgolint": ">=7.0.2001", + "vite-plus": "*" + }, + "peerDependenciesMeta": { + "oxlint-tsgolint": { + "optional": true + }, + "vite-plus": { + "optional": true + } + } + }, + "node_modules/oxlint-tsgolint": { + "version": "7.0.2003", + "resolved": "https://registry.npmjs.org/oxlint-tsgolint/-/oxlint-tsgolint-7.0.2003.tgz", + "integrity": "sha512-VnK4zlqgmgq/7ZcjzCk/WpN8kKFsYGcB85Io9qT3wL4K8Un3RKmJkp793crNETieMusPMKOA4a+Mw2wbteI6TQ==", + "dev": true, + "license": "MIT", + "bin": { + "tsgolint": "bin/tsgolint.js" + }, + "optionalDependencies": { + "@oxlint-tsgolint/darwin-arm64": "7.0.2003", + "@oxlint-tsgolint/darwin-x64": "7.0.2003", + "@oxlint-tsgolint/linux-arm64": "7.0.2003", + "@oxlint-tsgolint/linux-x64": "7.0.2003", + "@oxlint-tsgolint/win32-arm64": "7.0.2003", + "@oxlint-tsgolint/win32-x64": "7.0.2003" + } + }, "node_modules/p-limit": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-3.1.0.tgz", diff --git a/package.json b/package.json index 96173ab8..bea34dac 100644 --- a/package.json +++ b/package.json @@ -14,6 +14,7 @@ "prepare:ios": "scripts/ios.sh prepare ios", "doctor:ios": "scripts/ios.sh doctor ios", "build": "./build.sh", + "lint": "./lint.sh", "run": "./build_and_run.sh", "release": "scripts/release.sh", "clean": "rm -rf platforms", @@ -39,6 +40,8 @@ "@nativescript/ios": "9.0.3", "@nativescript/types": "~9.0.0", "@nativescript/webpack": "~5.0.25", + "oxlint": "^1.85.0", + "oxlint-tsgolint": "^7.0.2003", "typescript": "~5.4.0" } } diff --git a/tsconfig.json b/tsconfig.json index 4951dbe8..1c920328 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -9,10 +9,9 @@ "noEmitOnError": true, "skipLibCheck": true, "lib": ["ESNext", "dom"], - "baseUrl": ".", "paths": { - "~/*": ["app/*"], - "@/*": ["app/*"] + "~/*": ["./app/*"], + "@/*": ["./app/*"] } }, "include": ["app/**/*"],