Add stats collection and first-run on-glasses onboarding app

This commit is contained in:
James Babcock committed 2026-10-10 17:33:32 -07:00
1 parent 84baee9c76
commit 406cefe0c5
73 files changed
+3906 -98

No files matched your search

+2
View File
@@ -76,6 +76,8 @@ export const ICON_SVGS = {
'<svg viewBox="0 0 24 24" fill="none"><path d="M14 2v6a2 2 0 0 0 .245.96l5.51 10.08A2 2 0 0 1 18 22H6a2 2 0 0 1-1.755-2.96l5.51-10.08A2 2 0 0 0 10 8V2"/><path d="M6.453 15h11.094"/><path d="M8.5 2h7"/></svg>',
wrench:
'<svg viewBox="0 0 24 24" fill="none"><path d="M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z"/></svg>',
sparkles:
'<svg viewBox="0 0 24 24" fill="none"><path d="m12 3-1.912 5.813a2 2 0 0 1-1.275 1.275L3 12l5.813 1.912a2 2 0 0 1 1.275 1.275L12 21l1.912-5.813a2 2 0 0 1 1.275-1.275L21 12l-5.813-1.912a2 2 0 0 1-1.275-1.275L12 3Z"/><path d="M5 3v4"/><path d="M19 17v4"/><path d="M3 5h4"/><path d="M17 19h4"/></svg>',
settings:
'<svg viewBox="0 0 24 24" fill="none"><path d="M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915"/><circle cx="12" cy="12" r="3"/></svg>',
mic:
+8 -2
View File
@@ -6,7 +6,12 @@ declare const interop: any;
const UPNG = require("upng-js");
export function loadPngAsGrayImage(path: string): GrayImage {
/**
* Decode a PNG to grayscale, premultiplied by alpha so transparency reads as
* black. With `invert`, the PNG is dark art on a light or transparent ground
* (e.g. the phone-side logo) and its ink is drawn white instead.
*/
export function loadPngAsGrayImage(path: string, options: { invert?: boolean } = {}): GrayImage {
const file = resolveFile(path);
const raw = file.readSync();
const pngBuffer = toArrayBuffer(raw);
@@ -25,7 +30,8 @@ export function loadPngAsGrayImage(path: string): GrayImage {
const g = rgba[offset + 1] ?? 0;
const b = rgba[offset + 2] ?? 0;
const a = (rgba[offset + 3] ?? 0) / 255;
const gray = Math.round((0.2126 * r + 0.7152 * g + 0.0722 * b) * a);
const luminance = 0.2126 * r + 0.7152 * g + 0.0722 * b;
const gray = Math.round((options.invert ? 255 - luminance : luminance) * a);
image.pixels[y * decoded.width + x] = gray;
}
}
+5
View File
@@ -44,6 +44,11 @@ export type InstalledFont = {
monospace: boolean;
};
/** Whether `fileName` is one of the fonts the app ships, rather than one the user installed. */
export function isPreinstalledFont(fileName: string): boolean {
return (PREINSTALLED_FONT_FILES as readonly string[]).includes(fileName);
}
/** The app-internal fonts directory (created on first use). */
export function installedFontsDir(): string {
return knownFolders.documents().getFolder("fonts").path;
+54
View File
@@ -14,3 +14,57 @@ export function getDashboardLogo(): GrayImage | null {
}
return cachedDashboardLogo;
}
const FULL_LOGO_PATH = "images/faceclaw-logo.png";
let fullLogoSource: GrayImage | null | undefined;
const scaledFullLogos = new Map<number, GrayImage>();
/**
* The full Faceclaw logo (the lobster over the smiley face), white on black,
* scaled to `height` pixels tall for splash screens. The source is the phone
* UI's black-on-transparent PNG, inverted, and area-averaged down so the
* edges stay antialiased.
*/
export function getFullLogo(height: number): GrayImage | null {
const targetHeight = Math.max(1, Math.round(height));
const cached = scaledFullLogos.get(targetHeight);
if (cached) return cached;
if (fullLogoSource === undefined) {
try {
fullLogoSource = loadPngAsGrayImage(FULL_LOGO_PATH, { invert: true });
} catch (error) {
console.warn(`Could not load ${FULL_LOGO_PATH}: ${error}`);
fullLogoSource = null;
}
}
if (!fullLogoSource) return null;
const scale = Math.min(1, targetHeight / fullLogoSource.height);
const scaled = downscaleArea(
fullLogoSource,
Math.max(1, Math.round(fullLogoSource.width * scale)),
Math.max(1, Math.round(fullLogoSource.height * scale)),
);
scaledFullLogos.set(targetHeight, scaled);
return scaled;
}
/** Box-filter downscale: each output pixel averages the source pixels it covers. */
function downscaleArea(source: GrayImage, width: number, height: number): GrayImage {
if (width === source.width && height === source.height) return source;
const output = new GrayImage(width, height, 0);
for (let y = 0; y < height; y++) {
const y0 = Math.floor((y * source.height) / height);
const y1 = Math.max(y0 + 1, Math.floor(((y + 1) * source.height) / height));
for (let x = 0; x < width; x++) {
const x0 = Math.floor((x * source.width) / width);
const x1 = Math.max(x0 + 1, Math.floor(((x + 1) * source.width) / width));
let sum = 0;
for (let sy = y0; sy < y1; sy++) {
const row = sy * source.width;
for (let sx = x0; sx < x1; sx++) sum += source.pixels[row + sx]!;
}
output.pixels[y * width + x] = Math.round(sum / ((y1 - y0) * (x1 - x0)));
}
}
return output;
}