@glassly/engine 0.3.8-beta.984 → 0.3.8-dev.1002
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/engine.d.ts +2 -0
- package/build/engine.d.ts.map +1 -1
- package/build/facades/ai.d.ts +3 -0
- package/build/facades/ai.d.ts.map +1 -1
- package/build/facades/ai.js +3 -0
- package/build/facades/ai.js.map +1 -1
- package/build/generated/releaseMetadata.js +3 -3
- package/build/generated/releaseMetadata.js.map +1 -1
- package/build/index.d.ts +1 -0
- package/build/index.d.ts.map +1 -1
- package/build/index.js.map +1 -1
- package/build/services/LocalDisplayManager.d.ts +0 -2
- package/build/services/LocalDisplayManager.d.ts.map +1 -1
- package/build/services/LocalDisplayManager.js +5 -6
- package/build/services/LocalDisplayManager.js.map +1 -1
- package/build/services/LocalMiniappRuntime.d.ts +0 -6
- package/build/services/LocalMiniappRuntime.d.ts.map +1 -1
- package/build/services/LocalMiniappRuntime.js +5 -23
- package/build/services/LocalMiniappRuntime.js.map +1 -1
- package/build/services/LocalSttFallbackCoordinator.d.ts.map +1 -1
- package/build/services/LocalSttFallbackCoordinator.js +2 -0
- package/build/services/LocalSttFallbackCoordinator.js.map +1 -1
- package/build/services/LocalTranslationService.d.ts +2 -0
- package/build/services/LocalTranslationService.d.ts.map +1 -1
- package/build/services/LocalTranslationService.js +22 -0
- package/build/services/LocalTranslationService.js.map +1 -1
- package/build/services/OfflineActivity.d.ts +54 -0
- package/build/services/OfflineActivity.d.ts.map +1 -0
- package/build/services/OfflineActivity.js +86 -0
- package/build/services/OfflineActivity.js.map +1 -0
- package/build/services/STTModelManager.d.ts +1 -0
- package/build/services/STTModelManager.d.ts.map +1 -1
- package/build/services/STTModelManager.js +6 -0
- package/build/services/STTModelManager.js.map +1 -1
- package/build/services/SceneRenderer.d.ts +0 -8
- package/build/services/SceneRenderer.d.ts.map +1 -1
- package/build/services/SceneRenderer.js +0 -28
- package/build/services/SceneRenderer.js.map +1 -1
- package/build/services/controllers.d.ts.map +1 -1
- package/build/services/controllers.js +1 -0
- package/build/services/controllers.js.map +1 -1
- package/build/services/effectiveCapabilities.js +3 -1
- package/build/services/effectiveCapabilities.js.map +1 -1
- package/build/stores/appVisibility.d.ts.map +1 -1
- package/build/stores/appVisibility.js +0 -1
- package/build/stores/appVisibility.js.map +1 -1
- package/build/stores/settings.d.ts.map +1 -1
- package/build/stores/settings.js +7 -0
- package/build/stores/settings.js.map +1 -1
- package/build/types/capabilities/memomind-one.d.ts.map +1 -1
- package/build/types/capabilities/memomind-one.js +1 -0
- package/build/types/capabilities/memomind-one.js.map +1 -1
- package/build/types/capabilities/rayneo-io.d.ts.map +1 -1
- package/build/types/capabilities/rayneo-io.js +3 -2
- package/build/types/capabilities/rayneo-io.js.map +1 -1
- package/build/types/enums.d.ts +2 -1
- package/build/types/enums.d.ts.map +1 -1
- package/build/types/enums.js +1 -0
- package/build/types/enums.js.map +1 -1
- package/package.json +7 -7
- package/src/facades/ai.ts +4 -0
- package/src/generated/releaseMetadata.ts +3 -3
- package/src/index.ts +8 -0
- package/src/services/LocalDisplayManager.ts +5 -7
- package/src/services/LocalMiniappRuntime.ts +4 -24
- package/src/services/LocalSttFallbackCoordinator.ts +4 -0
- package/src/services/LocalTranslationService.ts +20 -0
- package/src/services/OfflineActivity.ts +131 -0
- package/src/services/STTModelManager.ts +6 -0
- package/src/services/SceneRenderer.ts +0 -28
- package/src/services/controllers.ts +1 -0
- package/src/services/effectiveCapabilities.ts +3 -1
- package/src/stores/appVisibility.ts +0 -1
- package/src/stores/settings.ts +7 -0
- package/src/types/capabilities/memomind-one.ts +1 -0
- package/src/types/capabilities/rayneo-io.ts +3 -2
- package/src/types/enums.ts +1 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"STTModelManager.js","sourceRoot":"","sources":["../../src/services/STTModelManager.ts"],"names":[],"mappings":"AAAA,OAAO,YAAY,MAAM,wBAAwB,CAAA;AACjD,OAAO,EAAC,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KAAa;QAC9B,IAAI,KAAK,KAAK,CAAC;YAAE,OAAO,SAAS,CAAA;QACjC,MAAM,CAAC,GAAG,IAAI,CAAA;QACd,MAAM,KAAK,GAAG,CAAC,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAA;QACzC,MAAM,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAA;QACnD,OAAO,UAAU,CAAC,CAAC,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,GAAG,KAAK,CAAC,CAAC,CAAC,CAAA;IACzE,CAAC;CACF;AAED,MAAM,QAAQ,GAAG,eAAe,CAAC,WAAW,EAAE,CAAA;AAC9C,OAAO,EAAC,eAAe,EAAC,CAAA;AACxB,eAAe,QAAQ,CAAA","sourcesContent":["import BluetoothSdk from \"@glassly/bluetooth-sdk\"\nimport {Platform} from \"react-native\"\nimport * as RNFS from \"@dr.pogodin/react-native-fs\"\n\nexport type SttModelType = \"transducer\" | \"ctc\" | \"nemotron\" | \"apple\"\n\nexport interface LanguageInfo {\n code: string\n displayName: string\n size: number\n language: string\n downloaded: boolean\n path?: string\n type: SttModelType\n}\n\nexport interface DownloadProgress {\n jobId: number\n bytesWritten: number\n contentLength: number\n percentage: number\n}\n\nexport interface ExtractionProgress {\n percentage: number\n currentFile?: string\n}\n\nexport interface LanguageConfig {\n code: string\n displayName: string\n fileName: string\n downloadUrl?: string\n size: number\n type: SttModelType\n requiredFiles: string[]\n languageCode: string\n}\n\nconst DEFAULT_LANGUAGE = \"en\"\n\n/**\n * Apple SpeechTranscriber entries are keyed `apple:<bcp47>`; the same string is\n * what native stores as the model path, since the OS owns the assets and there\n * is no directory to point at.\n */\nexport const APPLE_STT_PREFIX = \"apple:\"\n\nexport function isAppleSttCode(code: string): boolean {\n return code.startsWith(APPLE_STT_PREFIX)\n}\n\n/** SpeechTranscriber ships with iOS 26. */\nexport function appleSttSupported(): boolean {\n return Platform.OS === \"ios\" && parseInt(String(Platform.Version), 10) >= 26\n}\n\nclass STTModelManager {\n private static instance: STTModelManager\n private downloadJobId?: number\n private currentLanguage = DEFAULT_LANGUAGE\n private modelReadyListeners = new Set<() => void>()\n private modelBaseUrl = \"https://github.com/k2-fsa/sherpa-onnx/releases/download/asr-models/\"\n /** Apple locales reported by the OS, refreshed on each list load. */\n private appleLanguages: Record<string, LanguageConfig> = {}\n private appleInstalled = new Set<string>()\n private appleRefresh: Promise<void> | null = null\n\n private languages: Record<string, LanguageConfig> = {\n \"en\": {\n code: \"en\",\n displayName: \"English\",\n fileName: \"sherpa-onnx-streaming-zipformer-en-2023-06-21-mobile\",\n size: 349 * 1024 * 1024,\n type: \"transducer\",\n requiredFiles: [\"encoder.onnx\", \"decoder.onnx\", \"joiner.onnx\", \"tokens.txt\"],\n languageCode: \"en-US\",\n },\n \"fr\": {\n code: \"fr\",\n displayName: \"Français\",\n fileName: \"sherpa-onnx-streaming-zipformer-fr-kroko-2025-08-06\",\n size: 57 * 1024 * 1024,\n type: \"transducer\",\n requiredFiles: [\"encoder.onnx\", \"decoder.onnx\", \"joiner.onnx\", \"tokens.txt\"],\n languageCode: \"fr-FR\",\n },\n \"de\": {\n code: \"de\",\n displayName: \"Deutsch\",\n fileName: \"sherpa-onnx-streaming-zipformer-de-kroko-2025-08-06\",\n size: 58 * 1024 * 1024,\n type: \"transducer\",\n requiredFiles: [\"encoder.onnx\", \"decoder.onnx\", \"joiner.onnx\", \"tokens.txt\"],\n languageCode: \"de-DE\",\n },\n \"es\": {\n code: \"es\",\n displayName: \"Español\",\n fileName: \"sherpa-onnx-streaming-zipformer-es-kroko-2025-08-06\",\n size: 124 * 1024 * 1024,\n type: \"transducer\",\n requiredFiles: [\"encoder.onnx\", \"decoder.onnx\", \"joiner.onnx\", \"tokens.txt\"],\n languageCode: \"es-ES\",\n },\n \"zh\": {\n code: \"zh\",\n displayName: \"中文\",\n fileName: \"sherpa-onnx-streaming-zipformer-zh-2025-06-30\",\n size: 150 * 1024 * 1024,\n type: \"transducer\",\n requiredFiles: [\"encoder.onnx\", \"decoder.onnx\", \"joiner.onnx\", \"tokens.txt\"],\n languageCode: \"zh-CN\",\n },\n \"ko\": {\n code: \"ko\",\n displayName: \"한국어\",\n fileName: \"sherpa-onnx-streaming-zipformer-korean-2024-06-16\",\n size: 200 * 1024 * 1024,\n type: \"transducer\",\n requiredFiles: [\"encoder.onnx\", \"decoder.onnx\", \"joiner.onnx\", \"tokens.txt\"],\n languageCode: \"ko-KR\",\n },\n // Alternative English streaming models, kept alongside \"en\" so the three can\n // be compared on-device. Both are newer than the 2023 Zipformer used for\n // \"en\" and are a fraction of its 349 MB.\n //\n // Kroko: same family as the fr/de/es entries above, and the smallest English\n // option here. Ships bare encoder/decoder/joiner .onnx (no int8 variants).\n \"en-kroko\": {\n code: \"en-kroko\",\n displayName: \"English (Kroko, 55 MB)\",\n fileName: \"sherpa-onnx-streaming-zipformer-en-kroko-2025-08-06\",\n size: 55 * 1024 * 1024,\n type: \"transducer\",\n requiredFiles: [\"encoder.onnx\", \"decoder.onnx\", \"joiner.onnx\", \"tokens.txt\"],\n languageCode: \"en-US\",\n },\n // NeMo streaming fast-conformer, 480 ms chunk. Upstream publishes 80/480/1040 ms;\n // 480 ms is the middle latency/accuracy point. Unlike Kroko this ships only\n // int8 weights, so requiredFiles uses the .int8.onnx names — the archive has\n // no bare .onnx files at all.\n //\n // sherpa-onnx loads it through the plain transducer config (type \"transducer\",\n // not \"nemotron\"): the nemotron branch in SherpaOnnxTranscriber exists for the\n // Nemotron models below, which need a different modelType string to decode\n // correctly. This one is a stock NeMo transducer.\n \"en-nemo-fast-conformer\": {\n code: \"en-nemo-fast-conformer\",\n displayName: \"English (NeMo Fast-Conformer 480ms, 101 MB)\",\n fileName: \"sherpa-onnx-nemo-streaming-fast-conformer-transducer-en-480ms-int8\",\n size: 101 * 1024 * 1024,\n type: \"transducer\",\n requiredFiles: [\n \"encoder.int8.onnx\",\n \"decoder.int8.onnx\",\n \"joiner.int8.onnx\",\n \"tokens.txt\",\n ],\n languageCode: \"en-US\",\n },\n // NVIDIA Nemotron streaming ASR. These are model choices rather than plain\n // languages, so they get their own codes and sort after the per-language\n // Zipformers above.\n //\n // Both ship int8 encoder/decoder/joiner — the same file shape as a Zipformer\n // transducer — and are loaded through the identical transducer config;\n // sherpa-onnx dispatches to its NeMo implementation from the ONNX metadata.\n // Requires sherpa-onnx >= 1.13.4 (see the pins in the Android build.gradle\n // and scripts/setup-sherpa-onnx-optional.sh).\n //\n // The 560ms chunk variant is chosen for both: upstream publishes\n // 80/160/320/560/1120ms, trading latency against accuracy, and 560ms is the\n // middle ground that stays usable for live captions. These are ~450 MB\n // downloads — substantially larger than every other model here.\n \"nemotron-en\": {\n code: \"nemotron-en\",\n displayName: \"Nemotron English (high accuracy)\",\n fileName: \"sherpa-onnx-nemotron-speech-streaming-en-0.6b-560ms-int8-2026-04-25\",\n size: 442 * 1024 * 1024,\n type: \"nemotron\",\n requiredFiles: [\"encoder.int8.onnx\", \"decoder.int8.onnx\", \"joiner.int8.onnx\", \"tokens.txt\"],\n languageCode: \"en-US\",\n },\n // Nemotron-3.5 covers 40 language-locales with automatic language detection,\n // so there is no single BCP-47 tag for it. We report en-US as the nominal\n // tag because downstream consumers require one; the model itself is not\n // restricted to English.\n \"nemotron-3.5\": {\n code: \"nemotron-3.5\",\n displayName: \"Nemotron 3.5 Multilingual (40 languages)\",\n fileName: \"sherpa-onnx-nemotron-3.5-asr-streaming-0.6b-560ms-int8-2026-06-11\",\n size: 453 * 1024 * 1024,\n type: \"nemotron\",\n requiredFiles: [\"encoder.int8.onnx\", \"decoder.int8.onnx\", \"joiner.int8.onnx\", \"tokens.txt\"],\n languageCode: \"en-US\",\n },\n }\n\n private constructor() {}\n\n static getInstance(): STTModelManager {\n if (!STTModelManager.instance) {\n STTModelManager.instance = new STTModelManager()\n }\n return STTModelManager.instance\n }\n\n async getCurrentLanguageFromPreferences(): Promise<string> {\n try {\n const path = await BluetoothSdk.getSttModelPath()\n const code = path && path.length > 0 ? this.getLanguageFromPath(path) : \"\"\n if (code && isAppleSttCode(code)) {\n await this.refreshAppleLanguages()\n }\n if (code && this.config(code)) {\n this.currentLanguage = code\n return code\n }\n return \"\"\n } catch (error) {\n console.error(\"Error getting current STT language from preferences:\", error)\n return \"\"\n }\n }\n\n getCurrentLanguage(): string {\n return this.currentLanguage\n }\n\n setCurrentLanguage(code: string): void {\n if (this.config(code)) {\n this.currentLanguage = code\n }\n }\n\n getBcp47ForLanguage(code?: string): string {\n const id = code || this.currentLanguage\n return this.config(id)?.languageCode ?? \"en-US\"\n }\n\n /** Sherpa models first, then whatever Apple locales the last refresh reported. */\n getAvailableLanguages(): LanguageConfig[] {\n return [...Object.values(this.languages), ...Object.values(this.appleLanguages)]\n }\n\n private config(code: string): LanguageConfig | undefined {\n return this.languages[code] ?? this.appleLanguages[code]\n }\n\n /**\n * Re-read the Apple locale list and install states from the OS. A no-op below\n * iOS 26 and on Android, where the Apple section simply never appears.\n */\n async refreshAppleLanguages(): Promise<void> {\n if (!appleSttSupported()) return\n if (this.appleRefresh) return this.appleRefresh\n this.appleRefresh = (async () => {\n try {\n const rows = await BluetoothSdk.getAppleSpeechLocales()\n const next: Record<string, LanguageConfig> = {}\n const installed = new Set<string>()\n for (const row of rows) {\n const code = APPLE_STT_PREFIX + row.code\n next[code] = {\n code,\n displayName: row.name,\n fileName: \"\",\n size: 0,\n type: \"apple\",\n requiredFiles: [],\n languageCode: row.code,\n }\n if (row.status === \"installed\") installed.add(code)\n }\n this.appleLanguages = next\n this.appleInstalled = installed\n } catch (error) {\n console.warn(\"STTModelManager: Apple locale refresh failed:\", error)\n } finally {\n this.appleRefresh = null\n }\n })()\n return this.appleRefresh\n }\n\n getModelDirectory(): string {\n const baseDir = Platform.OS === \"ios\" ? RNFS.DocumentDirectoryPath : RNFS.DocumentDirectoryPath\n return `${baseDir}/stt_models`\n }\n\n getModelPath(code?: string): string {\n const id = code || this.currentLanguage\n if (isAppleSttCode(id)) return id\n return `${this.getModelDirectory()}/${id}`\n }\n\n /** Last path segment is the language code (the on-disk folder name). */\n getLanguageFromPath(path: string): string {\n return path.split(\"/\").pop() || \"\"\n }\n\n async isModelAvailable(code?: string): Promise<boolean> {\n try {\n const id = code || this.currentLanguage\n if (isAppleSttCode(id)) {\n if (!appleSttSupported()) return false\n const status = await BluetoothSdk.getAppleSpeechLocaleStatus(id.slice(APPLE_STT_PREFIX.length))\n const installed = status === \"installed\"\n if (installed) this.appleInstalled.add(id)\n else this.appleInstalled.delete(id)\n return installed\n }\n const language = this.languages[id]\n if (!language) return false\n\n const modelPath = this.getModelPath(id)\n for (const file of language.requiredFiles) {\n const filePath = `${modelPath}/${file}`\n const exists = await RNFS.exists(filePath)\n if (!exists) {\n console.log(`Missing required STT file: ${file} at ${filePath}`)\n return false\n }\n }\n\n return await BluetoothSdk.validateSttModel(modelPath)\n } catch (error) {\n console.error(\"Error checking STT model availability:\", error)\n return false\n }\n }\n\n async getLanguageInfo(code?: string): Promise<LanguageInfo> {\n const id = code || this.currentLanguage\n const language = this.config(id)\n if (!language) {\n throw new Error(`Language ${id} not found`)\n }\n\n const downloaded = await this.isModelAvailable(id)\n const path = downloaded ? this.getModelPath(id) : undefined\n\n return {\n code: id,\n displayName: language.displayName,\n size: language.size,\n language: language.languageCode,\n downloaded,\n path,\n type: language.type,\n }\n }\n\n async getAllLanguageInfo(): Promise<LanguageInfo[]> {\n const infos: LanguageInfo[] = []\n for (const code of Object.keys(this.languages)) {\n infos.push(await this.getLanguageInfo(code))\n }\n // One OS round-trip covers every Apple row's install state.\n await this.refreshAppleLanguages()\n for (const language of Object.values(this.appleLanguages)) {\n const downloaded = this.appleInstalled.has(language.code)\n infos.push({\n code: language.code,\n displayName: language.displayName,\n size: 0,\n language: language.languageCode,\n downloaded,\n path: downloaded ? language.code : undefined,\n type: \"apple\",\n })\n }\n return infos\n }\n\n /** Downloads the Apple locale's assets through the OS, surfacing its progress as a download. */\n private async installAppleModel(\n code: string,\n onProgress?: (progress: DownloadProgress) => void,\n onExtractionProgress?: (progress: ExtractionProgress) => void,\n ): Promise<void> {\n if (!appleSttSupported()) {\n throw new Error(\"Apple on-device speech requires iOS 26\")\n }\n const locale = code.slice(APPLE_STT_PREFIX.length)\n const subscription = BluetoothSdk.addListener(\"apple_speech_install_progress\", (event) => {\n if (event.locale !== locale) return\n onProgress?.({jobId: 0, bytesWritten: 0, contentLength: 0, percentage: event.percentage})\n })\n try {\n const status = await BluetoothSdk.installAppleSpeechLocale(locale)\n if (status !== \"installed\") {\n throw new Error(`Apple speech assets for ${locale} are ${status}`)\n }\n } finally {\n subscription.remove()\n }\n onExtractionProgress?.({percentage: 100})\n this.appleInstalled.add(code)\n if (code === this.currentLanguage) {\n await this.setNativeModelPath(code, locale)\n }\n }\n\n async downloadModel(\n code?: string,\n onProgress?: (progress: DownloadProgress) => void,\n onExtractionProgress?: (progress: ExtractionProgress) => void,\n ): Promise<void> {\n const id = code || this.currentLanguage\n if (isAppleSttCode(id)) {\n return this.installAppleModel(id, onProgress, onExtractionProgress)\n }\n const language = this.languages[id]\n if (!language) {\n throw new Error(`Language ${id} not found`)\n }\n\n const modelUrl = language.downloadUrl ?? `${this.modelBaseUrl}${language.fileName}.tar.bz2`\n const tempPath = `${RNFS.TemporaryDirectoryPath}/${language.fileName}.tar.bz2`\n const modelDir = this.getModelDirectory()\n const finalPath = this.getModelPath(id)\n\n try {\n await RNFS.mkdir(modelDir, {NSURLIsExcludedFromBackupKey: true})\n\n const downloadOptions = {\n fromUrl: modelUrl,\n toFile: tempPath,\n progress: (res: RNFS.DownloadProgressCallbackResultT) => {\n const percentage = Math.round((res.bytesWritten / res.contentLength) * 100)\n onProgress?.({\n jobId: res.jobId,\n bytesWritten: res.bytesWritten,\n contentLength: res.contentLength,\n percentage,\n })\n },\n progressDivider: 10,\n begin: (res: RNFS.DownloadBeginCallbackResultT) => {\n console.log(\"Download started:\", res)\n },\n connectionTimeout: 30000,\n readTimeout: 30000,\n }\n\n const result = await RNFS.downloadFile(downloadOptions)\n this.downloadJobId = result.jobId\n\n const downloadResult = await result.promise\n\n if (downloadResult.statusCode !== 200) {\n throw new Error(`Download failed with status code: ${downloadResult.statusCode}`)\n }\n\n onExtractionProgress?.({percentage: 0})\n\n const subscription = BluetoothSdk.addListener(\"extraction_progress\", (event) => {\n onExtractionProgress?.({percentage: event.percentage})\n })\n\n try {\n const extractionResult = await BluetoothSdk.extractTarBz2(tempPath, finalPath)\n if (!extractionResult) {\n throw new Error(\"Native extraction returned failure status\")\n }\n } catch (extractError) {\n console.error(\"Native extraction failed:\", extractError)\n throw extractError\n } finally {\n subscription.remove()\n }\n\n onExtractionProgress?.({percentage: 100})\n\n await RNFS.unlink(tempPath)\n\n if (id === this.currentLanguage) {\n await this.setNativeModelPath(finalPath, language.languageCode)\n }\n } catch (error) {\n // Best-effort cleanup; never let it mask the original error.\n try {\n if (await RNFS.exists(tempPath)) await RNFS.unlink(tempPath)\n } catch (cleanupError) {\n console.warn(\"STTModelManager: temp cleanup failed:\", cleanupError)\n }\n try {\n if (await RNFS.exists(finalPath)) await RNFS.unlink(finalPath)\n } catch (cleanupError) {\n console.warn(\"STTModelManager: final cleanup failed:\", cleanupError)\n }\n throw error\n }\n }\n\n async cancelDownload(): Promise<void> {\n if (this.downloadJobId !== undefined) {\n await RNFS.stopDownload(this.downloadJobId)\n this.downloadJobId = undefined\n }\n }\n\n async deleteModel(code?: string): Promise<void> {\n const id = code || this.currentLanguage\n if (isAppleSttCode(id)) {\n // The OS owns the assets; only the app's reservation can be dropped.\n this.appleInstalled.delete(id)\n if (appleSttSupported()) {\n await BluetoothSdk.releaseAppleSpeechLocale(id.slice(APPLE_STT_PREFIX.length))\n }\n return\n }\n const modelPath = this.getModelPath(id)\n if (await RNFS.exists(modelPath)) {\n await RNFS.unlink(modelPath)\n }\n }\n\n async activateLanguage(code: string): Promise<void> {\n if (isAppleSttCode(code) && !this.appleLanguages[code]) {\n await this.refreshAppleLanguages()\n }\n const language = this.config(code)\n if (!language) {\n throw new Error(`Language ${code} not found`)\n }\n\n const isAvailable = await this.isModelAvailable(code)\n if (!isAvailable) {\n throw new Error(`Language ${code} model is not downloaded`)\n }\n\n this.currentLanguage = code\n const modelPath = this.getModelPath(code)\n await this.setNativeModelPath(modelPath, language.languageCode)\n }\n\n private async setNativeModelPath(path: string, languageCode: string): Promise<void> {\n await BluetoothSdk.setSttModelDetails(path, languageCode)\n for (const listener of this.modelReadyListeners) {\n try {\n listener()\n } catch (error) {\n console.warn(\"STTModelManager: model-ready listener failed:\", error)\n }\n }\n }\n\n /** Fired after a downloaded/selected model's path has reached native. */\n onModelReady(listener: () => void): () => void {\n this.modelReadyListeners.add(listener)\n return () => this.modelReadyListeners.delete(listener)\n }\n\n async getStorageInfo(): Promise<{free: number; total: number}> {\n const fsInfo = await RNFS.getFSInfo()\n return {\n free: fsInfo.freeSpace,\n total: fsInfo.totalSpace,\n }\n }\n\n formatBytes(bytes: number): string {\n return STTModelManager.formatBytes(bytes)\n }\n\n static formatBytes(bytes: number): string {\n if (bytes === 0) return \"0 Bytes\"\n const k = 1024\n const sizes = [\"Bytes\", \"KB\", \"MB\", \"GB\"]\n const i = Math.floor(Math.log(bytes) / Math.log(k))\n return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + \" \" + sizes[i]\n }\n}\n\nconst instance = STTModelManager.getInstance()\nexport {STTModelManager}\nexport default instance\n"]}
|
|
1
|
+
{"version":3,"file":"STTModelManager.js","sourceRoot":"","sources":["../../src/services/STTModelManager.ts"],"names":[],"mappings":"AAAA,OAAO,YAAY,MAAM,wBAAwB,CAAA;AACjD,OAAO,EAAC,QAAQ,EAAC,MAAM,cAAc,CAAA;AACrC,OAAO,KAAK,IAAI,MAAM,6BAA6B,CAAA;AA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QACrC,OAAO;YACL,IAAI,EAAE,MAAM,CAAC,SAAS;YACtB,KAAK,EAAE,MAAM,CAAC,UAAU;SACzB,CAAA;IACH,CAAC;IAED,WAAW,CAAC,KAAa;QACvB,OAAO,eAAe,CAAC,WAAW,CAAC,KAAK,CAAC,CAAA;IAC3C,CAAC;IAED,MAAM,CAAC,WAAW,CAAC,KAAa;QAC9B,IAAI,KAAK,KAAK,CAAC;YAAE,OAAO,SAAS,CAAA;QACjC,MAAM,CAAC,GAAG,IAAI,CAAA;QACd,MAAM,KAAK,GAAG,CAAC,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAA;QACzC,MAAM,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAA;QACnD,OAAO,UAAU,CAAC,CAAC,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,GAAG,KAAK,CAAC,CAAC,CAAC,CAAA;IACzE,CAAC;CACF;AAED,MAAM,QAAQ,GAAG,eAAe,CAAC,WAAW,EAAE,CAAA;AAC9C,OAAO,EAAC,eAAe,EAAC,CAAA;AACxB,eAAe,QAAQ,CAAA","sourcesContent":["import BluetoothSdk from \"@glassly/bluetooth-sdk\"\nimport {Platform} from \"react-native\"\nimport * as RNFS from \"@dr.pogodin/react-native-fs\"\n\nexport type SttModelType = \"transducer\" | \"ctc\" | \"nemotron\" | \"apple\"\n\nexport interface LanguageInfo {\n code: string\n displayName: string\n size: number\n language: string\n downloaded: boolean\n path?: string\n type: SttModelType\n}\n\nexport interface DownloadProgress {\n jobId: number\n bytesWritten: number\n contentLength: number\n percentage: number\n}\n\nexport interface ExtractionProgress {\n percentage: number\n currentFile?: string\n}\n\nexport interface LanguageConfig {\n code: string\n displayName: string\n fileName: string\n downloadUrl?: string\n size: number\n type: SttModelType\n requiredFiles: string[]\n languageCode: string\n}\n\nconst DEFAULT_LANGUAGE = \"en\"\n\n/**\n * Apple SpeechTranscriber entries are keyed `apple:<bcp47>`; the same string is\n * what native stores as the model path, since the OS owns the assets and there\n * is no directory to point at.\n */\nexport const APPLE_STT_PREFIX = \"apple:\"\n\nexport function isAppleSttCode(code: string): boolean {\n return code.startsWith(APPLE_STT_PREFIX)\n}\n\n/** SpeechTranscriber ships with iOS 26. */\nexport function appleSttSupported(): boolean {\n return Platform.OS === \"ios\" && parseInt(String(Platform.Version), 10) >= 26\n}\n\nclass STTModelManager {\n private static instance: STTModelManager\n private downloadJobId?: number\n private currentLanguage = DEFAULT_LANGUAGE\n private modelReadyListeners = new Set<() => void>()\n private modelBaseUrl = \"https://github.com/k2-fsa/sherpa-onnx/releases/download/asr-models/\"\n /** Apple locales reported by the OS, refreshed on each list load. */\n private appleLanguages: Record<string, LanguageConfig> = {}\n private appleInstalled = new Set<string>()\n private appleRefresh: Promise<void> | null = null\n\n private languages: Record<string, LanguageConfig> = {\n \"en\": {\n code: \"en\",\n displayName: \"English\",\n fileName: \"sherpa-onnx-streaming-zipformer-en-2023-06-21-mobile\",\n size: 349 * 1024 * 1024,\n type: \"transducer\",\n requiredFiles: [\"encoder.onnx\", \"decoder.onnx\", \"joiner.onnx\", \"tokens.txt\"],\n languageCode: \"en-US\",\n },\n \"fr\": {\n code: \"fr\",\n displayName: \"Français\",\n fileName: \"sherpa-onnx-streaming-zipformer-fr-kroko-2025-08-06\",\n size: 57 * 1024 * 1024,\n type: \"transducer\",\n requiredFiles: [\"encoder.onnx\", \"decoder.onnx\", \"joiner.onnx\", \"tokens.txt\"],\n languageCode: \"fr-FR\",\n },\n \"de\": {\n code: \"de\",\n displayName: \"Deutsch\",\n fileName: \"sherpa-onnx-streaming-zipformer-de-kroko-2025-08-06\",\n size: 58 * 1024 * 1024,\n type: \"transducer\",\n requiredFiles: [\"encoder.onnx\", \"decoder.onnx\", \"joiner.onnx\", \"tokens.txt\"],\n languageCode: \"de-DE\",\n },\n \"es\": {\n code: \"es\",\n displayName: \"Español\",\n fileName: \"sherpa-onnx-streaming-zipformer-es-kroko-2025-08-06\",\n size: 124 * 1024 * 1024,\n type: \"transducer\",\n requiredFiles: [\"encoder.onnx\", \"decoder.onnx\", \"joiner.onnx\", \"tokens.txt\"],\n languageCode: \"es-ES\",\n },\n \"zh\": {\n code: \"zh\",\n displayName: \"中文\",\n fileName: \"sherpa-onnx-streaming-zipformer-zh-2025-06-30\",\n size: 150 * 1024 * 1024,\n type: \"transducer\",\n requiredFiles: [\"encoder.onnx\", \"decoder.onnx\", \"joiner.onnx\", \"tokens.txt\"],\n languageCode: \"zh-CN\",\n },\n \"ko\": {\n code: \"ko\",\n displayName: \"한국어\",\n fileName: \"sherpa-onnx-streaming-zipformer-korean-2024-06-16\",\n size: 200 * 1024 * 1024,\n type: \"transducer\",\n requiredFiles: [\"encoder.onnx\", \"decoder.onnx\", \"joiner.onnx\", \"tokens.txt\"],\n languageCode: \"ko-KR\",\n },\n // Alternative English streaming models, kept alongside \"en\" so the three can\n // be compared on-device. Both are newer than the 2023 Zipformer used for\n // \"en\" and are a fraction of its 349 MB.\n //\n // Kroko: same family as the fr/de/es entries above, and the smallest English\n // option here. Ships bare encoder/decoder/joiner .onnx (no int8 variants).\n \"en-kroko\": {\n code: \"en-kroko\",\n displayName: \"English (Kroko, 55 MB)\",\n fileName: \"sherpa-onnx-streaming-zipformer-en-kroko-2025-08-06\",\n size: 55 * 1024 * 1024,\n type: \"transducer\",\n requiredFiles: [\"encoder.onnx\", \"decoder.onnx\", \"joiner.onnx\", \"tokens.txt\"],\n languageCode: \"en-US\",\n },\n // NeMo streaming fast-conformer, 480 ms chunk. Upstream publishes 80/480/1040 ms;\n // 480 ms is the middle latency/accuracy point. Unlike Kroko this ships only\n // int8 weights, so requiredFiles uses the .int8.onnx names — the archive has\n // no bare .onnx files at all.\n //\n // sherpa-onnx loads it through the plain transducer config (type \"transducer\",\n // not \"nemotron\"): the nemotron branch in SherpaOnnxTranscriber exists for the\n // Nemotron models below, which need a different modelType string to decode\n // correctly. This one is a stock NeMo transducer.\n \"en-nemo-fast-conformer\": {\n code: \"en-nemo-fast-conformer\",\n displayName: \"English (NeMo Fast-Conformer 480ms, 101 MB)\",\n fileName: \"sherpa-onnx-nemo-streaming-fast-conformer-transducer-en-480ms-int8\",\n size: 101 * 1024 * 1024,\n type: \"transducer\",\n requiredFiles: [\n \"encoder.int8.onnx\",\n \"decoder.int8.onnx\",\n \"joiner.int8.onnx\",\n \"tokens.txt\",\n ],\n languageCode: \"en-US\",\n },\n // NVIDIA Nemotron streaming ASR. These are model choices rather than plain\n // languages, so they get their own codes and sort after the per-language\n // Zipformers above.\n //\n // Both ship int8 encoder/decoder/joiner — the same file shape as a Zipformer\n // transducer — and are loaded through the identical transducer config;\n // sherpa-onnx dispatches to its NeMo implementation from the ONNX metadata.\n // Requires sherpa-onnx >= 1.13.4 (see the pins in the Android build.gradle\n // and scripts/setup-sherpa-onnx-optional.sh).\n //\n // The 560ms chunk variant is chosen for both: upstream publishes\n // 80/160/320/560/1120ms, trading latency against accuracy, and 560ms is the\n // middle ground that stays usable for live captions. These are ~450 MB\n // downloads — substantially larger than every other model here.\n \"nemotron-en\": {\n code: \"nemotron-en\",\n displayName: \"Nemotron English (high accuracy)\",\n fileName: \"sherpa-onnx-nemotron-speech-streaming-en-0.6b-560ms-int8-2026-04-25\",\n size: 442 * 1024 * 1024,\n type: \"nemotron\",\n requiredFiles: [\"encoder.int8.onnx\", \"decoder.int8.onnx\", \"joiner.int8.onnx\", \"tokens.txt\"],\n languageCode: \"en-US\",\n },\n // Nemotron-3.5 covers 40 language-locales with automatic language detection,\n // so there is no single BCP-47 tag for it. We report en-US as the nominal\n // tag because downstream consumers require one; the model itself is not\n // restricted to English.\n \"nemotron-3.5\": {\n code: \"nemotron-3.5\",\n displayName: \"Nemotron 3.5 Multilingual (40 languages)\",\n fileName: \"sherpa-onnx-nemotron-3.5-asr-streaming-0.6b-560ms-int8-2026-06-11\",\n size: 453 * 1024 * 1024,\n type: \"nemotron\",\n requiredFiles: [\"encoder.int8.onnx\", \"decoder.int8.onnx\", \"joiner.int8.onnx\", \"tokens.txt\"],\n languageCode: \"en-US\",\n },\n }\n\n private constructor() {}\n\n static getInstance(): STTModelManager {\n if (!STTModelManager.instance) {\n STTModelManager.instance = new STTModelManager()\n }\n return STTModelManager.instance\n }\n\n async getCurrentLanguageFromPreferences(): Promise<string> {\n try {\n const path = await BluetoothSdk.getSttModelPath()\n const code = path && path.length > 0 ? this.getLanguageFromPath(path) : \"\"\n if (code && isAppleSttCode(code)) {\n await this.refreshAppleLanguages()\n }\n if (code && this.config(code)) {\n this.currentLanguage = code\n return code\n }\n return \"\"\n } catch (error) {\n console.error(\"Error getting current STT language from preferences:\", error)\n return \"\"\n }\n }\n\n getCurrentLanguage(): string {\n return this.currentLanguage\n }\n\n currentModelLabel(): string {\n const language = this.config(this.currentLanguage)\n if (!language) return this.currentLanguage\n return language.type === \"apple\" ? `Apple · ${language.displayName}` : language.displayName\n }\n\n setCurrentLanguage(code: string): void {\n if (this.config(code)) {\n this.currentLanguage = code\n }\n }\n\n getBcp47ForLanguage(code?: string): string {\n const id = code || this.currentLanguage\n return this.config(id)?.languageCode ?? \"en-US\"\n }\n\n /** Sherpa models first, then whatever Apple locales the last refresh reported. */\n getAvailableLanguages(): LanguageConfig[] {\n return [...Object.values(this.languages), ...Object.values(this.appleLanguages)]\n }\n\n private config(code: string): LanguageConfig | undefined {\n return this.languages[code] ?? this.appleLanguages[code]\n }\n\n /**\n * Re-read the Apple locale list and install states from the OS. A no-op below\n * iOS 26 and on Android, where the Apple section simply never appears.\n */\n async refreshAppleLanguages(): Promise<void> {\n if (!appleSttSupported()) return\n if (this.appleRefresh) return this.appleRefresh\n this.appleRefresh = (async () => {\n try {\n const rows = await BluetoothSdk.getAppleSpeechLocales()\n const next: Record<string, LanguageConfig> = {}\n const installed = new Set<string>()\n for (const row of rows) {\n const code = APPLE_STT_PREFIX + row.code\n next[code] = {\n code,\n displayName: row.name,\n fileName: \"\",\n size: 0,\n type: \"apple\",\n requiredFiles: [],\n languageCode: row.code,\n }\n if (row.status === \"installed\") installed.add(code)\n }\n this.appleLanguages = next\n this.appleInstalled = installed\n } catch (error) {\n console.warn(\"STTModelManager: Apple locale refresh failed:\", error)\n } finally {\n this.appleRefresh = null\n }\n })()\n return this.appleRefresh\n }\n\n getModelDirectory(): string {\n const baseDir = Platform.OS === \"ios\" ? RNFS.DocumentDirectoryPath : RNFS.DocumentDirectoryPath\n return `${baseDir}/stt_models`\n }\n\n getModelPath(code?: string): string {\n const id = code || this.currentLanguage\n if (isAppleSttCode(id)) return id\n return `${this.getModelDirectory()}/${id}`\n }\n\n /** Last path segment is the language code (the on-disk folder name). */\n getLanguageFromPath(path: string): string {\n return path.split(\"/\").pop() || \"\"\n }\n\n async isModelAvailable(code?: string): Promise<boolean> {\n try {\n const id = code || this.currentLanguage\n if (isAppleSttCode(id)) {\n if (!appleSttSupported()) return false\n const status = await BluetoothSdk.getAppleSpeechLocaleStatus(id.slice(APPLE_STT_PREFIX.length))\n const installed = status === \"installed\"\n if (installed) this.appleInstalled.add(id)\n else this.appleInstalled.delete(id)\n return installed\n }\n const language = this.languages[id]\n if (!language) return false\n\n const modelPath = this.getModelPath(id)\n for (const file of language.requiredFiles) {\n const filePath = `${modelPath}/${file}`\n const exists = await RNFS.exists(filePath)\n if (!exists) {\n console.log(`Missing required STT file: ${file} at ${filePath}`)\n return false\n }\n }\n\n return await BluetoothSdk.validateSttModel(modelPath)\n } catch (error) {\n console.error(\"Error checking STT model availability:\", error)\n return false\n }\n }\n\n async getLanguageInfo(code?: string): Promise<LanguageInfo> {\n const id = code || this.currentLanguage\n const language = this.config(id)\n if (!language) {\n throw new Error(`Language ${id} not found`)\n }\n\n const downloaded = await this.isModelAvailable(id)\n const path = downloaded ? this.getModelPath(id) : undefined\n\n return {\n code: id,\n displayName: language.displayName,\n size: language.size,\n language: language.languageCode,\n downloaded,\n path,\n type: language.type,\n }\n }\n\n async getAllLanguageInfo(): Promise<LanguageInfo[]> {\n const infos: LanguageInfo[] = []\n for (const code of Object.keys(this.languages)) {\n infos.push(await this.getLanguageInfo(code))\n }\n // One OS round-trip covers every Apple row's install state.\n await this.refreshAppleLanguages()\n for (const language of Object.values(this.appleLanguages)) {\n const downloaded = this.appleInstalled.has(language.code)\n infos.push({\n code: language.code,\n displayName: language.displayName,\n size: 0,\n language: language.languageCode,\n downloaded,\n path: downloaded ? language.code : undefined,\n type: \"apple\",\n })\n }\n return infos\n }\n\n /** Downloads the Apple locale's assets through the OS, surfacing its progress as a download. */\n private async installAppleModel(\n code: string,\n onProgress?: (progress: DownloadProgress) => void,\n onExtractionProgress?: (progress: ExtractionProgress) => void,\n ): Promise<void> {\n if (!appleSttSupported()) {\n throw new Error(\"Apple on-device speech requires iOS 26\")\n }\n const locale = code.slice(APPLE_STT_PREFIX.length)\n const subscription = BluetoothSdk.addListener(\"apple_speech_install_progress\", (event) => {\n if (event.locale !== locale) return\n onProgress?.({jobId: 0, bytesWritten: 0, contentLength: 0, percentage: event.percentage})\n })\n try {\n const status = await BluetoothSdk.installAppleSpeechLocale(locale)\n if (status !== \"installed\") {\n throw new Error(`Apple speech assets for ${locale} are ${status}`)\n }\n } finally {\n subscription.remove()\n }\n onExtractionProgress?.({percentage: 100})\n this.appleInstalled.add(code)\n if (code === this.currentLanguage) {\n await this.setNativeModelPath(code, locale)\n }\n }\n\n async downloadModel(\n code?: string,\n onProgress?: (progress: DownloadProgress) => void,\n onExtractionProgress?: (progress: ExtractionProgress) => void,\n ): Promise<void> {\n const id = code || this.currentLanguage\n if (isAppleSttCode(id)) {\n return this.installAppleModel(id, onProgress, onExtractionProgress)\n }\n const language = this.languages[id]\n if (!language) {\n throw new Error(`Language ${id} not found`)\n }\n\n const modelUrl = language.downloadUrl ?? `${this.modelBaseUrl}${language.fileName}.tar.bz2`\n const tempPath = `${RNFS.TemporaryDirectoryPath}/${language.fileName}.tar.bz2`\n const modelDir = this.getModelDirectory()\n const finalPath = this.getModelPath(id)\n\n try {\n await RNFS.mkdir(modelDir, {NSURLIsExcludedFromBackupKey: true})\n\n const downloadOptions = {\n fromUrl: modelUrl,\n toFile: tempPath,\n progress: (res: RNFS.DownloadProgressCallbackResultT) => {\n const percentage = Math.round((res.bytesWritten / res.contentLength) * 100)\n onProgress?.({\n jobId: res.jobId,\n bytesWritten: res.bytesWritten,\n contentLength: res.contentLength,\n percentage,\n })\n },\n progressDivider: 10,\n begin: (res: RNFS.DownloadBeginCallbackResultT) => {\n console.log(\"Download started:\", res)\n },\n connectionTimeout: 30000,\n readTimeout: 30000,\n }\n\n const result = await RNFS.downloadFile(downloadOptions)\n this.downloadJobId = result.jobId\n\n const downloadResult = await result.promise\n\n if (downloadResult.statusCode !== 200) {\n throw new Error(`Download failed with status code: ${downloadResult.statusCode}`)\n }\n\n onExtractionProgress?.({percentage: 0})\n\n const subscription = BluetoothSdk.addListener(\"extraction_progress\", (event) => {\n onExtractionProgress?.({percentage: event.percentage})\n })\n\n try {\n const extractionResult = await BluetoothSdk.extractTarBz2(tempPath, finalPath)\n if (!extractionResult) {\n throw new Error(\"Native extraction returned failure status\")\n }\n } catch (extractError) {\n console.error(\"Native extraction failed:\", extractError)\n throw extractError\n } finally {\n subscription.remove()\n }\n\n onExtractionProgress?.({percentage: 100})\n\n await RNFS.unlink(tempPath)\n\n if (id === this.currentLanguage) {\n await this.setNativeModelPath(finalPath, language.languageCode)\n }\n } catch (error) {\n // Best-effort cleanup; never let it mask the original error.\n try {\n if (await RNFS.exists(tempPath)) await RNFS.unlink(tempPath)\n } catch (cleanupError) {\n console.warn(\"STTModelManager: temp cleanup failed:\", cleanupError)\n }\n try {\n if (await RNFS.exists(finalPath)) await RNFS.unlink(finalPath)\n } catch (cleanupError) {\n console.warn(\"STTModelManager: final cleanup failed:\", cleanupError)\n }\n throw error\n }\n }\n\n async cancelDownload(): Promise<void> {\n if (this.downloadJobId !== undefined) {\n await RNFS.stopDownload(this.downloadJobId)\n this.downloadJobId = undefined\n }\n }\n\n async deleteModel(code?: string): Promise<void> {\n const id = code || this.currentLanguage\n if (isAppleSttCode(id)) {\n // The OS owns the assets; only the app's reservation can be dropped.\n this.appleInstalled.delete(id)\n if (appleSttSupported()) {\n await BluetoothSdk.releaseAppleSpeechLocale(id.slice(APPLE_STT_PREFIX.length))\n }\n return\n }\n const modelPath = this.getModelPath(id)\n if (await RNFS.exists(modelPath)) {\n await RNFS.unlink(modelPath)\n }\n }\n\n async activateLanguage(code: string): Promise<void> {\n if (isAppleSttCode(code) && !this.appleLanguages[code]) {\n await this.refreshAppleLanguages()\n }\n const language = this.config(code)\n if (!language) {\n throw new Error(`Language ${code} not found`)\n }\n\n const isAvailable = await this.isModelAvailable(code)\n if (!isAvailable) {\n throw new Error(`Language ${code} model is not downloaded`)\n }\n\n this.currentLanguage = code\n const modelPath = this.getModelPath(code)\n await this.setNativeModelPath(modelPath, language.languageCode)\n }\n\n private async setNativeModelPath(path: string, languageCode: string): Promise<void> {\n await BluetoothSdk.setSttModelDetails(path, languageCode)\n for (const listener of this.modelReadyListeners) {\n try {\n listener()\n } catch (error) {\n console.warn(\"STTModelManager: model-ready listener failed:\", error)\n }\n }\n }\n\n /** Fired after a downloaded/selected model's path has reached native. */\n onModelReady(listener: () => void): () => void {\n this.modelReadyListeners.add(listener)\n return () => this.modelReadyListeners.delete(listener)\n }\n\n async getStorageInfo(): Promise<{free: number; total: number}> {\n const fsInfo = await RNFS.getFSInfo()\n return {\n free: fsInfo.freeSpace,\n total: fsInfo.totalSpace,\n }\n }\n\n formatBytes(bytes: number): string {\n return STTModelManager.formatBytes(bytes)\n }\n\n static formatBytes(bytes: number): string {\n if (bytes === 0) return \"0 Bytes\"\n const k = 1024\n const sizes = [\"Bytes\", \"KB\", \"MB\", \"GB\"]\n const i = Math.floor(Math.log(bytes) / Math.log(k))\n return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + \" \" + sizes[i]\n }\n}\n\nconst instance = STTModelManager.getInstance()\nexport {STTModelManager}\nexport default instance\n"]}
|
|
@@ -77,14 +77,6 @@ declare class SceneRenderer {
|
|
|
77
77
|
* output byte-identical to today).
|
|
78
78
|
*/
|
|
79
79
|
emitScene(appId: string, view: "main" | "dashboard", elements: SceneElementInput[]): SceneEmitResult;
|
|
80
|
-
/**
|
|
81
|
-
* Hand native the frame `elements` would make for (app, view) without
|
|
82
|
-
* showing it or touching the retained scene: drivers with an on-glass asset
|
|
83
|
-
* cache upload its fonts and images while the panel is idle. Every element
|
|
84
|
-
* is "created" and the frame carries seq 0 (no presentation report). Empty
|
|
85
|
-
* elements drop it. False when there is nothing to send it to.
|
|
86
|
-
*/
|
|
87
|
-
prefetchScene(appId: string, view: "main" | "dashboard", elements: SceneElementInput[]): boolean;
|
|
88
80
|
/**
|
|
89
81
|
* Re-emit an app's retained scene (reconnect / arbitration restore). Replay
|
|
90
82
|
* is always create-based — the device rebuilds from scratch (spec §4).
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SceneRenderer.d.ts","sourceRoot":"","sources":["../../src/services/SceneRenderer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAUH,OAAO,EAML,KAAK,YAAY,EAEjB,KAAK,wBAAwB,EAC7B,KAAK,iBAAiB,EAEvB,MAAM,wBAAwB,CAAA;AAI/B,2DAA2D;AAC3D,MAAM,MAAM,YAAY,GAAG;IAAC,UAAU,EAAE,MAAM,CAAC;IAAC,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;CAAC,CAAA;AAEvE,MAAM,MAAM,eAAe;AACzB;;;;;GAKG;AACD;IAAC,IAAI,EAAE,OAAO,CAAC;IAAC,QAAQ,EAAE,OAAO,CAAC;IAAC,OAAO,EAAE,MAAM,EAAE,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,OAAO,C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}
|
|
230
|
-
/**
|
|
231
|
-
* Hand native the frame `elements` would make for (app, view) without
|
|
232
|
-
* showing it or touching the retained scene: drivers with an on-glass asset
|
|
233
|
-
* cache upload its fonts and images while the panel is idle. Every element
|
|
234
|
-
* is "created" and the frame carries seq 0 (no presentation report). Empty
|
|
235
|
-
* elements drop it. False when there is nothing to send it to.
|
|
236
|
-
*/
|
|
237
|
-
prefetchScene(appId, view, elements) {
|
|
238
|
-
const caps = this.currentCapabilities();
|
|
239
|
-
if (!caps?.canPosition)
|
|
240
|
-
return false;
|
|
241
|
-
const processed = processScene(resolveAnchors(elements, caps.width, caps.height), caps, displayProcessor.getSceneProfile());
|
|
242
|
-
let synthetic = 0;
|
|
243
|
-
const { elements: created } = diffScene([], processed.elements, () => `~prefetch${synthetic++}`);
|
|
244
|
-
const frame = {
|
|
245
|
-
appId,
|
|
246
|
-
view,
|
|
247
|
-
sceneEpoch: 0,
|
|
248
|
-
seq: 0,
|
|
249
|
-
elements: created,
|
|
250
|
-
removed: [],
|
|
251
|
-
canvas: { width: caps.width, height: caps.height },
|
|
252
|
-
};
|
|
253
|
-
void Promise.resolve(BluetoothSdk.displayEvent({ view, scene: frame, prefetch: true })).catch((err) => {
|
|
254
|
-
console.error(`${LOG_TAG}: native prefetch failed:`, err);
|
|
255
|
-
});
|
|
256
|
-
return true;
|
|
257
|
-
}
|
|
258
230
|
/**
|
|
259
231
|
* Re-emit an app's retained scene (reconnect / arbitration restore). Replay
|
|
260
232
|
* is always create-based — the device rebuilds from scratch (spec §4).
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SceneRenderer.js","sourceRoot":"","sources":["../../src/services/SceneRenderer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,gBAAgB,MAAM,oBAAoB,CAAA;AACjD,OAAO,YAAY,MAAM,iCAAiC,CAAA;AAC1D,OAAO,EAAC,eAAe,EAAC,MAAM,mBAAmB,CAAA;AACjD,OAAO,EAAC,Q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boundary of the scene display pipeline.\n *\n * LocalDisplayManager owns WHO may draw (arbitration/boot/expiry); this service\n * owns WHAT gets sent for a scene: capabilities lookup, legacy-layout→scene\n * conversion (sugar and old bundles ride the same pipeline), process → diff →\n * SceneFrame emission, retained-scene replay, and the degrade branch for\n * devices that can't position elements.\n *\n * Everything device-specific here is DATA (capability fields, display profile);\n * the code paths are generic. Spec: notes/miniapp-display-render-implementation-spec.md\n */\n\nimport displayProcessor from \"./DisplayProcessor\"\nimport BluetoothSdk from \"@glassly/bluetooth-sdk/internal\"\nimport {useDisplayStore} from \"../stores/display\"\nimport {SETTINGS, useSettingsStore} from \"../stores/settings\"\nimport {useGlassesStore} from \"../stores/glasses\"\nimport {DeviceTypes} from \"../types\"\nimport {getEffectiveCapabilities} from \"./effectiveCapabilities\"\nimport {BgTimer} from \"../utils/timers\"\nimport {\n degradeScene,\n diffScene,\n processScene,\n resolveAnchors,\n SceneStore,\n type FrameElement,\n type SceneBreakMode,\n type SceneDisplayCapabilities,\n type SceneElementInput,\n type SceneFrame,\n} from \"../utils/display/scene\"\n\nconst LOG_TAG = \"SCENE_RENDERER\"\n\n/** Legacy layout shape (matches DisplayPayload.layout). */\nexport type LegacyLayout = {layoutType: string; [key: string]: unknown}\n\nexport type SceneEmitResult =\n /**\n * A SceneFrame was committed. `sent` is false when the frame stayed\n * phone-side (dashboard covering main). `settleMs` is how long the device\n * keeps animating after it has the frame: the longest transition among the\n * elements this frame changed, 0 on devices that jump.\n */\n | {kind: \"scene\"; degraded: boolean; dropped: string[]; seq: number; sent: boolean; settleMs: number}\n /** Degrade path: caller routes this legacy layout through the existing pipeline (null layout ⇒ clear). */\n | {kind: \"legacy\"; layout: LegacyLayout | null; degraded: boolean; dropped: string[]}\n /** No display capabilities on the connected device. */\n | {kind: \"no-display\"}\n\n/** How a frame ended up, as reported by native (or inferred from a later frame's report). */\nexport interface ScenePresentation {\n /** The device had the frame's content (this frame or a later one that folded it in). */\n presented: boolean\n /** A later frame's report settled this one. */\n superseded: boolean\n reason?: string\n}\n\n/** Longest geometry tween (255 frames at ~30 fps); rotation uses a separate millisecond clock. */\nconst MAX_SETTLE_MS = 255 * 33\n\n/** Longest transition among the elements that actually change on the device this frame. */\nfunction settleTimeOf(elements: FrameElement[]): number {\n let ms = 0\n for (const el of elements) {\n // Entering and leaving elements tween too, from or to their offset.\n const edge = el.transition?.exit !== undefined || (el.change === \"created\" && el.transition?.enter !== undefined)\n if (el.change !== \"updated\" && el.change !== \"moved\" && !edge) continue\n const t = el.transition?.durationMs ?? 0\n // Rotation has its own millisecond clock, beyond the geometry frame limit.\n const duration = Math.min(t, el.rotation !== undefined ? 65535 : MAX_SETTLE_MS)\n if (duration > ms) ms = duration\n }\n return ms\n}\n\nclass SceneRenderer {\n private static instance: SceneRenderer | null = null\n private store = new SceneStore()\n private seqCounter = 0\n private pending = new Map<number, {appId: string; resolve: (p: ScenePresentation) => void}>()\n private presentedSub: {remove: () => void} | null = null\n private settledSub: {remove: () => void} | null = null\n private settledListeners = new Set<(seq: number) => void>()\n\n public static getInstance(): SceneRenderer {\n if (!SceneRenderer.instance) {\n SceneRenderer.instance = new SceneRenderer()\n }\n return SceneRenderer.instance\n }\n\n // ===========================================================================\n // Capabilities\n // ===========================================================================\n\n /**\n * Scene capabilities of the currently-selected device, or null when it has no\n * display block. Read on demand — same model source the CONNECT_ACK uses.\n */\n public currentCapabilities(): SceneDisplayCapabilities | null {\n // dev read these via the (since-removed) settings/glassesStatus runtime\n // hooks; engine reads its own stores directly.\n const model =\n (useSettingsStore.getState().getSetting(SETTINGS.default_wearable.key) as string | undefined) ??\n (useGlassesStore.getState().deviceModel as string | undefined)\n const display = getEffectiveCapabilities((model ?? DeviceTypes.NONE) as DeviceTypes)?.display\n if (!display) return null\n return {\n width: display.width ?? display.resolution?.width ?? displayProcessor.getProfile().displayWidthPx,\n height: display.height ?? display.resolution?.height ?? displayProcessor.getProfile().displayHeightPx ?? 288,\n canPosition: display.canPosition === true,\n maxTextElements: display.maxTextElements ?? 6,\n maxImageElements: display.maxImageElements ?? 0,\n maxImagePx: display.maxImagePx,\n shapes: display.shapes ?? [],\n animation: display.animation ?? false,\n rotation: display.rotation ?? false,\n depth: display.depth ?? false,\n intensityLevels: display.intensityLevels ?? 2,\n\n partialUpdate: display.partialUpdate ?? false,\n }\n }\n\n // ===========================================================================\n // Legacy layout → scene conversion (sugar + old bundles on the scene path)\n // ===========================================================================\n\n /**\n * Convert a legacy layout into scene elements for a positioning device.\n * Returns null for layouts that must stay on the legacy path (dashboard_card,\n * clear_view, unknown types). Sugar semantics: full-canvas / split boxes.\n */\n public convertLegacyLayout(layout: LegacyLayout, caps: SceneDisplayCapabilities): SceneElementInput[] | null {\n const W = caps.width\n const H = caps.height\n const breakMode = layout.breakMode as SceneBreakMode | undefined\n\n switch (layout.layoutType) {\n case \"text_wall\":\n return [\n {\n type: \"text\",\n id: \"sugar:wall\",\n box: {x: 0, y: 0, w: W, h: H},\n text: String(layout.text ?? \"\"),\n ...(breakMode ? {style: {breakMode}} : {}),\n },\n ]\n case \"double_text_wall\": {\n const half = Math.floor(W / 2)\n return [\n {\n type: \"text\",\n id: \"sugar:left\",\n box: {x: 0, y: 0, w: half, h: H},\n text: String(layout.topText ?? \"\"),\n ...(breakMode ? {style: {breakMode}} : {}),\n },\n {\n type: \"text\",\n id: \"sugar:right\",\n box: {x: half, y: 0, w: W - half, h: H},\n text: String(layout.bottomText ?? \"\"),\n ...(breakMode ? {style: {breakMode}} : {}),\n },\n ]\n }\n case \"reference_card\": {\n const titleH = Math.max(24, Math.floor(H / 5))\n return [\n {type: \"text\", id: \"sugar:title\", box: {x: 0, y: 0, w: W, h: titleH}, text: String(layout.title ?? \"\")},\n {\n type: \"text\",\n id: \"sugar:body\",\n box: {x: 0, y: titleH, w: W, h: H - titleH},\n text: String(layout.text ?? \"\"),\n ...(breakMode ? {style: {breakMode}} : {}),\n },\n ]\n }\n case \"bitmap_view\": {\n // Dimensionless legacy bitmaps historically landed in the device's\n // default ~200×100 container (G2 seeded 200×100 at 188,44) — NOT the\n // full canvas, which would tile a small image across the whole frame.\n const w = (layout.width as number | undefined) ?? Math.min(200, W)\n const h = (layout.height as number | undefined) ?? Math.min(100, H)\n return [\n {\n type: \"image\",\n id: \"sugar:bmp\",\n box: {\n x: (layout.x as number | undefined) ?? Math.max(0, Math.round((W - w) / 2)),\n y: (layout.y as number | undefined) ?? Math.max(0, Math.round((H - h) / 4)),\n w,\n h,\n },\n data: String(layout.data ?? \"\"),\n },\n ]\n }\n case \"positioned_text\": {\n const border = (layout.borderWidth as number | undefined) ?? 0\n const radius = (layout.borderRadius as number | undefined) ?? 0\n return [\n {\n type: \"text\",\n id: \"sugar:pos\",\n box: {\n x: (layout.x as number | undefined) ?? 0,\n y: (layout.y as number | undefined) ?? 0,\n w: (layout.width as number | undefined) ?? W,\n h: (layout.height as number | undefined) ?? H,\n },\n text: String(layout.text ?? \"\"),\n ...(border || radius ? {style: {border, radius}} : {}),\n },\n ]\n }\n default:\n return null\n }\n }\n\n // ===========================================================================\n // Emit\n // ===========================================================================\n\n /**\n * Process + diff + send a scene for (app, view). On non-positioning devices\n * this returns the degraded legacy layout instead — the caller routes it\n * through the existing DisplayProcessor path (which wraps it, keeping G1/Z100\n * output byte-identical to today).\n */\n public emitScene(appId: string, view: \"main\" | \"dashboard\", elements: SceneElementInput[]): SceneEmitResult {\n const caps = this.currentCapabilities()\n if (!caps) return {kind: \"no-display\"}\n\n // Corner-anchored boxes resolve against the REAL canvas before either\n // branch: processScene clamps concrete coords, and degradeScene's reading\n // order sorts by resolved y (a bottom-anchored y:0 must not sort first).\n elements = resolveAnchors(elements, caps.width, caps.height)\n\n if (!caps.canPosition) {\n const {layout, degraded, dropped} = degradeScene(elements)\n return {kind: \"legacy\", layout, degraded, dropped}\n }\n\n const processed = processScene(elements, caps, displayProcessor.getSceneProfile())\n // A stale baseline means the glasses were cleared since the last commit —\n // diff from empty so everything repaints (the retained frame stays valid\n // as the replay source only).\n const prevFrame = this.store.isBaselineStale(appId, view) ? [] : this.store.lastFrame(appId, view)\n const {elements: diffed, removed} = diffScene(\n prevFrame,\n processed.elements,\n this.store.nextSyntheticId(appId, view),\n )\n const canvas = {width: caps.width, height: caps.height}\n this.store.commit(appId, view, diffed, canvas)\n\n const frame: SceneFrame = {\n appId,\n view,\n sceneEpoch: this.store.currentEpoch(appId, view),\n seq: ++this.seqCounter,\n elements: diffed,\n removed,\n canvas,\n }\n const sent = this.sendFrame(frame)\n return {\n kind: \"scene\",\n degraded: processed.degraded,\n dropped: processed.dropped,\n seq: frame.seq,\n sent,\n settleMs: caps.animation ? settleTimeOf(diffed) : 0,\n }\n }\n\n /**\n * Hand native the frame `elements` would make for (app, view) without\n * showing it or touching the retained scene: drivers with an on-glass asset\n * cache upload its fonts and images while the panel is idle. Every element\n * is \"created\" and the frame carries seq 0 (no presentation report). Empty\n * elements drop it. False when there is nothing to send it to.\n */\n public prefetchScene(appId: string, view: \"main\" | \"dashboard\", elements: SceneElementInput[]): boolean {\n const caps = this.currentCapabilities()\n if (!caps?.canPosition) return false\n const processed = processScene(resolveAnchors(elements, caps.width, caps.height), caps, displayProcessor.getSceneProfile())\n let synthetic = 0\n const {elements: created} = diffScene([], processed.elements, () => `~prefetch${synthetic++}`)\n const frame: SceneFrame = {\n appId,\n view,\n sceneEpoch: 0,\n seq: 0,\n elements: created,\n removed: [],\n canvas: {width: caps.width, height: caps.height},\n }\n void Promise.resolve(BluetoothSdk.displayEvent({view, scene: frame, prefetch: true})).catch((err) => {\n console.error(`${LOG_TAG}: native prefetch failed:`, err)\n })\n return true\n }\n\n /**\n * Re-emit an app's retained scene (reconnect / arbitration restore). Replay\n * is always create-based — the device rebuilds from scratch (spec §4).\n * Returns false when nothing is retained.\n */\n public replayApp(appId: string, view: \"main\" | \"dashboard\"): boolean {\n const frame = this.store.buildReplayFrame(appId, view, ++this.seqCounter)\n if (!frame) return false\n this.sendFrame(frame)\n return true\n }\n\n /** Forget an app's retained scenes (app stop). Frames still in flight will never show. */\n public clearApp(appId: string): void {\n this.store.clear(appId)\n this.settlePending((p) => p.appId === appId, {presented: false, superseded: true, reason: \"cleared\"})\n }\n\n // ===========================================================================\n // Presentation — native reports when the device has a frame\n // ===========================================================================\n\n /**\n * Resolves once native reports frame `seq` on the device, or a later frame\n * that folded it in. Never rejects; `timeoutMs` bounds a frame the device\n * never acknowledges (link stalls, page rebuilding).\n */\n public whenPresented(seq: number, timeoutMs: number, appId: string): Promise<ScenePresentation> {\n this.ensurePresentedListener()\n return new Promise((resolve) => {\n const timer = BgTimer.setTimeout(() => {\n if (this.pending.delete(seq)) resolve({presented: false, superseded: false, reason: \"no presentation report\"})\n }, timeoutMs)\n this.pending.set(seq, {\n appId,\n resolve: (p) => {\n BgTimer.clearTimeout(timer)\n resolve(p)\n },\n })\n })\n }\n\n private ensurePresentedListener(): void {\n if (this.presentedSub) return\n this.presentedSub = BluetoothSdk.addListener(\"scene_frame_presented\", (event) => {\n this.onFramePresented(event.seq, event.appId, event.presented, event.reason)\n })\n }\n\n /**\n * Fires with the host frame number once the glasses report that every\n * animation the frame started has ended (Glassly CFW revision 27+). The\n * device echoes the low 16 bits of the seq; the full number is recovered\n * against the latest frame sent.\n */\n public onSettled(listener: (seq: number) => void): {remove: () => void} {\n this.settledListeners.add(listener)\n if (!this.settledSub) {\n this.settledSub = BluetoothSdk.addListener(\"scene_settled\", (event) => {\n const seq = this.seqCounter - ((this.seqCounter - event.tag) & 0xffff)\n if (seq <= 0) return\n for (const settled of [...this.settledListeners]) settled(seq)\n })\n }\n return {remove: () => this.settledListeners.delete(listener)}\n }\n\n /** A report for `seq` settles it and every earlier frame (folded in by the native pacer). */\n private onFramePresented(seq: number, appId: string, presented: boolean, reason?: string): void {\n this.settlePending(\n (p, s) => s <= seq,\n (p, s) =>\n s === seq\n ? {presented, superseded: false, reason}\n : p.appId === appId\n ? {presented, superseded: true, reason}\n : {presented: false, superseded: true, reason: `superseded by ${appId}`},\n )\n }\n\n private settlePending(\n match: (p: {appId: string}, seq: number) => boolean,\n outcome: ScenePresentation | ((p: {appId: string}, seq: number) => ScenePresentation),\n ): void {\n for (const [seq, p] of [...this.pending]) {\n if (!match(p, seq)) continue\n this.pending.delete(seq)\n p.resolve(typeof outcome === \"function\" ? outcome(p, seq) : outcome)\n }\n }\n\n /**\n * Reset the diff baseline for (app, view) without touching the device.\n * Used when a legacy layout bypasses the scene path (clear_view /\n * dashboard_card / unknown layoutTypes go to native raw): after that, the\n * retained frame no longer matches the glasses, so the next render() must\n * diff from empty — otherwise \"unchanged\" elements would be skipped and\n * never repainted.\n */\n public resetBaseline(appId: string, view: \"main\" | \"dashboard\"): void {\n this.store.commit(appId, view, [])\n }\n\n /**\n * A system-level clear wiped the view (durationMs expiry, unmount fallback,\n * boot-window expiry): mark every app's baseline for that view stale. Unlike\n * resetBaseline this KEEPS the retained frames — they remain the\n * restore-as-replay source; only incremental diffing restarts from empty.\n */\n public markViewStale(view: \"main\" | \"dashboard\"): void {\n this.store.markViewStale(view)\n // Whatever was in flight for the view got wiped with it.\n this.settlePending(() => true, {presented: false, superseded: true, reason: \"cleared\"})\n }\n\n /** Returns false when the frame stayed phone-side (no presentation report will follow). */\n private sendFrame(frame: SceneFrame): boolean {\n // Single native view: only the visible surface's frames go out. Suppressed\n // main frames stay committed; setOverlayOwner(null) replays them.\n const overlayHeld = useDisplayStore.getState().overlayOwner !== null\n if (overlayHeld !== (frame.view === \"dashboard\")) return false\n try {\n // Frames carry the canvas they were laid out against; only a frame from\n // a path that predates the tag falls back to the current capabilities.\n const caps = this.currentCapabilities()\n if (!frame.canvas && caps) frame = {...frame, canvas: {width: caps.width, height: caps.height}}\n // sendDisplayEvent hook -> direct BluetoothSdk.displayEvent (the exact\n // wiring the deleted MantleManager hook provided).\n void Promise.resolve(BluetoothSdk.displayEvent({view: frame.view, scene: frame})).catch((err) => {\n console.error(`${LOG_TAG}: native scene send failed:`, err)\n })\n\n // Keep the phone-side glasses mirror on the same frame as native. Legacy\n // layouts update this store in LocalDisplayManager.sendToNative; scene\n // frames bypass that method, so without an explicit write every\n // positioning device (including G2) leaves the mirror blank/stale.\n useDisplayStore.getState().setDisplayEvent({\n view: frame.view,\n layout: {\n layoutType: \"scene\",\n appId: frame.appId,\n view: frame.view,\n sceneEpoch: frame.sceneEpoch,\n width: frame.canvas?.width,\n height: frame.canvas?.height,\n elements: frame.elements,\n },\n })\n return true\n } catch (err) {\n console.error(`${LOG_TAG}: native scene send failed:`, err)\n return false\n }\n }\n\n // ===========================================================================\n // Test hooks\n // ===========================================================================\n\n public _resetForTest(): void {\n this.store.clearAll()\n this.settlePending(() => true, {presented: false, superseded: false, reason: \"reset\"})\n this.presentedSub?.remove()\n this.presentedSub = null\n this.settledSub?.remove()\n this.settledSub = null\n this.settledListeners.clear()\n this.seqCounter = 0\n }\n\n public _lastFrameForTest(appId: string, view: string): FrameElement[] {\n return this.store.lastFrame(appId, view)\n }\n}\n\nconst sceneRenderer = SceneRenderer.getInstance()\nexport default sceneRenderer\nexport {SceneRenderer}\n"]}
|
|
1
|
+
{"version":3,"file":"SceneRenderer.js","sourceRoot":"","sources":["../../src/services/SceneRenderer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,gBAAgB,MAAM,oBAAoB,CAAA;AACjD,OAAO,YAAY,MAAM,iCAAiC,CAAA;AAC1D,OAAO,EAAC,eAAe,EAAC,MAAM,mBAAmB,CAAA;AACjD,OAAO,EAAC,QAAQ,EAAE,gBAAgB,EAAC,MAAM,oBAAoB,CAAA;AAC7D,OAAO,EAAC,eAAe,EAAC,MAAM,mBAAmB,CAAA;AACjD,OAAO,EAAC,WAAW,EAAC,MAAM,UAAU,CAAA;AACpC,OAAO,EAAC,wBAAwB,EAAC,MAAM,yBAAyB,CAAA;AAChE,OAAO,EAAC,OAAO,EAAC,MAAM,iBAAiB,CAAA;AACvC,OAAO,EACL,YAAY,EACZ,SAAS,EACT,YAAY,EACZ,cAAc,EACd,UAAU,GAMX,MAAM,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;iBACzB;aACF,CAAC,CAAA;YACF,OAAO,IAAI,CAAA;QACb,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,OAAO,CAAC,KAAK,CAAC,GAAG,OAAO,6BAA6B,EAAE,GAAG,CAAC,CAAA;YAC3D,OAAO,KAAK,CAAA;QACd,CAAC;IACH,CAAC;IAED,8EAA8E;IAC9E,aAAa;IACb,8EAA8E;IAEvE,aAAa;QAClB,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAA;QACrB,IAAI,CAAC,aAAa,CAAC,GAAG,EAAE,CAAC,IAAI,EAAE,EAAC,SAAS,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAC,CAAC,CAAA;QACtF,IAAI,CAAC,YAAY,EAAE,MAAM,EAAE,CAAA;QAC3B,IAAI,CAAC,YAAY,GAAG,IAAI,CAAA;QACxB,IAAI,CAAC,UAAU,EAAE,MAAM,EAAE,CAAA;QACzB,IAAI,CAAC,UAAU,GAAG,IAAI,CAAA;QACtB,IAAI,CAAC,gBAAgB,CAAC,KAAK,EAAE,CAAA;QAC7B,IAAI,CAAC,UAAU,GAAG,CAAC,CAAA;IACrB,CAAC;IAEM,iBAAiB,CAAC,KAAa,EAAE,IAAY;QAClD,OAAO,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,KAAK,EAAE,IAAI,CAAC,CAAA;IAC1C,CAAC;;AAGH,MAAM,aAAa,GAAG,aAAa,CAAC,WAAW,EAAE,CAAA;AACjD,eAAe,aAAa,CAAA;AAC5B,OAAO,EAAC,aAAa,EAAC,CAAA","sourcesContent":["/**\n * SceneRenderer — the device-aware boundary of the scene display pipeline.\n *\n * LocalDisplayManager owns WHO may draw (arbitration/boot/expiry); this service\n * owns WHAT gets sent for a scene: capabilities lookup, legacy-layout→scene\n * conversion (sugar and old bundles ride the same pipeline), process → diff →\n * SceneFrame emission, retained-scene replay, and the degrade branch for\n * devices that can't position elements.\n *\n * Everything device-specific here is DATA (capability fields, display profile);\n * the code paths are generic. Spec: notes/miniapp-display-render-implementation-spec.md\n */\n\nimport displayProcessor from \"./DisplayProcessor\"\nimport BluetoothSdk from \"@glassly/bluetooth-sdk/internal\"\nimport {useDisplayStore} from \"../stores/display\"\nimport {SETTINGS, useSettingsStore} from \"../stores/settings\"\nimport {useGlassesStore} from \"../stores/glasses\"\nimport {DeviceTypes} from \"../types\"\nimport {getEffectiveCapabilities} from \"./effectiveCapabilities\"\nimport {BgTimer} from \"../utils/timers\"\nimport {\n degradeScene,\n diffScene,\n processScene,\n resolveAnchors,\n SceneStore,\n type FrameElement,\n type SceneBreakMode,\n type SceneDisplayCapabilities,\n type SceneElementInput,\n type SceneFrame,\n} from \"../utils/display/scene\"\n\nconst LOG_TAG = \"SCENE_RENDERER\"\n\n/** Legacy layout shape (matches DisplayPayload.layout). */\nexport type LegacyLayout = {layoutType: string; [key: string]: unknown}\n\nexport type SceneEmitResult =\n /**\n * A SceneFrame was committed. `sent` is false when the frame stayed\n * phone-side (dashboard covering main). `settleMs` is how long the device\n * keeps animating after it has the frame: the longest transition among the\n * elements this frame changed, 0 on devices that jump.\n */\n | {kind: \"scene\"; degraded: boolean; dropped: string[]; seq: number; sent: boolean; settleMs: number}\n /** Degrade path: caller routes this legacy layout through the existing pipeline (null layout ⇒ clear). */\n | {kind: \"legacy\"; layout: LegacyLayout | null; degraded: boolean; dropped: string[]}\n /** No display capabilities on the connected device. */\n | {kind: \"no-display\"}\n\n/** How a frame ended up, as reported by native (or inferred from a later frame's report). */\nexport interface ScenePresentation {\n /** The device had the frame's content (this frame or a later one that folded it in). */\n presented: boolean\n /** A later frame's report settled this one. */\n superseded: boolean\n reason?: string\n}\n\n/** Longest geometry tween (255 frames at ~30 fps); rotation uses a separate millisecond clock. */\nconst MAX_SETTLE_MS = 255 * 33\n\n/** Longest transition among the elements that actually change on the device this frame. */\nfunction settleTimeOf(elements: FrameElement[]): number {\n let ms = 0\n for (const el of elements) {\n // Entering and leaving elements tween too, from or to their offset.\n const edge = el.transition?.exit !== undefined || (el.change === \"created\" && el.transition?.enter !== undefined)\n if (el.change !== \"updated\" && el.change !== \"moved\" && !edge) continue\n const t = el.transition?.durationMs ?? 0\n // Rotation has its own millisecond clock, beyond the geometry frame limit.\n const duration = Math.min(t, el.rotation !== undefined ? 65535 : MAX_SETTLE_MS)\n if (duration > ms) ms = duration\n }\n return ms\n}\n\nclass SceneRenderer {\n private static instance: SceneRenderer | null = null\n private store = new SceneStore()\n private seqCounter = 0\n private pending = new Map<number, {appId: string; resolve: (p: ScenePresentation) => void}>()\n private presentedSub: {remove: () => void} | null = null\n private settledSub: {remove: () => void} | null = null\n private settledListeners = new Set<(seq: number) => void>()\n\n public static getInstance(): SceneRenderer {\n if (!SceneRenderer.instance) {\n SceneRenderer.instance = new SceneRenderer()\n }\n return SceneRenderer.instance\n }\n\n // ===========================================================================\n // Capabilities\n // ===========================================================================\n\n /**\n * Scene capabilities of the currently-selected device, or null when it has no\n * display block. Read on demand — same model source the CONNECT_ACK uses.\n */\n public currentCapabilities(): SceneDisplayCapabilities | null {\n // dev read these via the (since-removed) settings/glassesStatus runtime\n // hooks; engine reads its own stores directly.\n const model =\n (useSettingsStore.getState().getSetting(SETTINGS.default_wearable.key) as string | undefined) ??\n (useGlassesStore.getState().deviceModel as string | undefined)\n const display = getEffectiveCapabilities((model ?? DeviceTypes.NONE) as DeviceTypes)?.display\n if (!display) return null\n return {\n width: display.width ?? display.resolution?.width ?? displayProcessor.getProfile().displayWidthPx,\n height: display.height ?? display.resolution?.height ?? displayProcessor.getProfile().displayHeightPx ?? 288,\n canPosition: display.canPosition === true,\n maxTextElements: display.maxTextElements ?? 6,\n maxImageElements: display.maxImageElements ?? 0,\n maxImagePx: display.maxImagePx,\n shapes: display.shapes ?? [],\n animation: display.animation ?? false,\n rotation: display.rotation ?? false,\n depth: display.depth ?? false,\n intensityLevels: display.intensityLevels ?? 2,\n\n partialUpdate: display.partialUpdate ?? false,\n }\n }\n\n // ===========================================================================\n // Legacy layout → scene conversion (sugar + old bundles on the scene path)\n // ===========================================================================\n\n /**\n * Convert a legacy layout into scene elements for a positioning device.\n * Returns null for layouts that must stay on the legacy path (dashboard_card,\n * clear_view, unknown types). Sugar semantics: full-canvas / split boxes.\n */\n public convertLegacyLayout(layout: LegacyLayout, caps: SceneDisplayCapabilities): SceneElementInput[] | null {\n const W = caps.width\n const H = caps.height\n const breakMode = layout.breakMode as SceneBreakMode | undefined\n\n switch (layout.layoutType) {\n case \"text_wall\":\n return [\n {\n type: \"text\",\n id: \"sugar:wall\",\n box: {x: 0, y: 0, w: W, h: H},\n text: String(layout.text ?? \"\"),\n ...(breakMode ? {style: {breakMode}} : {}),\n },\n ]\n case \"double_text_wall\": {\n const half = Math.floor(W / 2)\n return [\n {\n type: \"text\",\n id: \"sugar:left\",\n box: {x: 0, y: 0, w: half, h: H},\n text: String(layout.topText ?? \"\"),\n ...(breakMode ? {style: {breakMode}} : {}),\n },\n {\n type: \"text\",\n id: \"sugar:right\",\n box: {x: half, y: 0, w: W - half, h: H},\n text: String(layout.bottomText ?? \"\"),\n ...(breakMode ? {style: {breakMode}} : {}),\n },\n ]\n }\n case \"reference_card\": {\n const titleH = Math.max(24, Math.floor(H / 5))\n return [\n {type: \"text\", id: \"sugar:title\", box: {x: 0, y: 0, w: W, h: titleH}, text: String(layout.title ?? \"\")},\n {\n type: \"text\",\n id: \"sugar:body\",\n box: {x: 0, y: titleH, w: W, h: H - titleH},\n text: String(layout.text ?? \"\"),\n ...(breakMode ? {style: {breakMode}} : {}),\n },\n ]\n }\n case \"bitmap_view\": {\n // Dimensionless legacy bitmaps historically landed in the device's\n // default ~200×100 container (G2 seeded 200×100 at 188,44) — NOT the\n // full canvas, which would tile a small image across the whole frame.\n const w = (layout.width as number | undefined) ?? Math.min(200, W)\n const h = (layout.height as number | undefined) ?? Math.min(100, H)\n return [\n {\n type: \"image\",\n id: \"sugar:bmp\",\n box: {\n x: (layout.x as number | undefined) ?? Math.max(0, Math.round((W - w) / 2)),\n y: (layout.y as number | undefined) ?? Math.max(0, Math.round((H - h) / 4)),\n w,\n h,\n },\n data: String(layout.data ?? \"\"),\n },\n ]\n }\n case \"positioned_text\": {\n const border = (layout.borderWidth as number | undefined) ?? 0\n const radius = (layout.borderRadius as number | undefined) ?? 0\n return [\n {\n type: \"text\",\n id: \"sugar:pos\",\n box: {\n x: (layout.x as number | undefined) ?? 0,\n y: (layout.y as number | undefined) ?? 0,\n w: (layout.width as number | undefined) ?? W,\n h: (layout.height as number | undefined) ?? H,\n },\n text: String(layout.text ?? \"\"),\n ...(border || radius ? {style: {border, radius}} : {}),\n },\n ]\n }\n default:\n return null\n }\n }\n\n // ===========================================================================\n // Emit\n // ===========================================================================\n\n /**\n * Process + diff + send a scene for (app, view). On non-positioning devices\n * this returns the degraded legacy layout instead — the caller routes it\n * through the existing DisplayProcessor path (which wraps it, keeping G1/Z100\n * output byte-identical to today).\n */\n public emitScene(appId: string, view: \"main\" | \"dashboard\", elements: SceneElementInput[]): SceneEmitResult {\n const caps = this.currentCapabilities()\n if (!caps) return {kind: \"no-display\"}\n\n // Corner-anchored boxes resolve against the REAL canvas before either\n // branch: processScene clamps concrete coords, and degradeScene's reading\n // order sorts by resolved y (a bottom-anchored y:0 must not sort first).\n elements = resolveAnchors(elements, caps.width, caps.height)\n\n if (!caps.canPosition) {\n const {layout, degraded, dropped} = degradeScene(elements)\n return {kind: \"legacy\", layout, degraded, dropped}\n }\n\n const processed = processScene(elements, caps, displayProcessor.getSceneProfile())\n // A stale baseline means the glasses were cleared since the last commit —\n // diff from empty so everything repaints (the retained frame stays valid\n // as the replay source only).\n const prevFrame = this.store.isBaselineStale(appId, view) ? [] : this.store.lastFrame(appId, view)\n const {elements: diffed, removed} = diffScene(\n prevFrame,\n processed.elements,\n this.store.nextSyntheticId(appId, view),\n )\n const canvas = {width: caps.width, height: caps.height}\n this.store.commit(appId, view, diffed, canvas)\n\n const frame: SceneFrame = {\n appId,\n view,\n sceneEpoch: this.store.currentEpoch(appId, view),\n seq: ++this.seqCounter,\n elements: diffed,\n removed,\n canvas,\n }\n const sent = this.sendFrame(frame)\n return {\n kind: \"scene\",\n degraded: processed.degraded,\n dropped: processed.dropped,\n seq: frame.seq,\n sent,\n settleMs: caps.animation ? settleTimeOf(diffed) : 0,\n }\n }\n\n /**\n * Re-emit an app's retained scene (reconnect / arbitration restore). Replay\n * is always create-based — the device rebuilds from scratch (spec §4).\n * Returns false when nothing is retained.\n */\n public replayApp(appId: string, view: \"main\" | \"dashboard\"): boolean {\n const frame = this.store.buildReplayFrame(appId, view, ++this.seqCounter)\n if (!frame) return false\n this.sendFrame(frame)\n return true\n }\n\n /** Forget an app's retained scenes (app stop). Frames still in flight will never show. */\n public clearApp(appId: string): void {\n this.store.clear(appId)\n this.settlePending((p) => p.appId === appId, {presented: false, superseded: true, reason: \"cleared\"})\n }\n\n // ===========================================================================\n // Presentation — native reports when the device has a frame\n // ===========================================================================\n\n /**\n * Resolves once native reports frame `seq` on the device, or a later frame\n * that folded it in. Never rejects; `timeoutMs` bounds a frame the device\n * never acknowledges (link stalls, page rebuilding).\n */\n public whenPresented(seq: number, timeoutMs: number, appId: string): Promise<ScenePresentation> {\n this.ensurePresentedListener()\n return new Promise((resolve) => {\n const timer = BgTimer.setTimeout(() => {\n if (this.pending.delete(seq)) resolve({presented: false, superseded: false, reason: \"no presentation report\"})\n }, timeoutMs)\n this.pending.set(seq, {\n appId,\n resolve: (p) => {\n BgTimer.clearTimeout(timer)\n resolve(p)\n },\n })\n })\n }\n\n private ensurePresentedListener(): void {\n if (this.presentedSub) return\n this.presentedSub = BluetoothSdk.addListener(\"scene_frame_presented\", (event) => {\n this.onFramePresented(event.seq, event.appId, event.presented, event.reason)\n })\n }\n\n /**\n * Fires with the host frame number once the glasses report that every\n * animation the frame started has ended (Glassly CFW revision 27+). The\n * device echoes the low 16 bits of the seq; the full number is recovered\n * against the latest frame sent.\n */\n public onSettled(listener: (seq: number) => void): {remove: () => void} {\n this.settledListeners.add(listener)\n if (!this.settledSub) {\n this.settledSub = BluetoothSdk.addListener(\"scene_settled\", (event) => {\n const seq = this.seqCounter - ((this.seqCounter - event.tag) & 0xffff)\n if (seq <= 0) return\n for (const settled of [...this.settledListeners]) settled(seq)\n })\n }\n return {remove: () => this.settledListeners.delete(listener)}\n }\n\n /** A report for `seq` settles it and every earlier frame (folded in by the native pacer). */\n private onFramePresented(seq: number, appId: string, presented: boolean, reason?: string): void {\n this.settlePending(\n (p, s) => s <= seq,\n (p, s) =>\n s === seq\n ? {presented, superseded: false, reason}\n : p.appId === appId\n ? {presented, superseded: true, reason}\n : {presented: false, superseded: true, reason: `superseded by ${appId}`},\n )\n }\n\n private settlePending(\n match: (p: {appId: string}, seq: number) => boolean,\n outcome: ScenePresentation | ((p: {appId: string}, seq: number) => ScenePresentation),\n ): void {\n for (const [seq, p] of [...this.pending]) {\n if (!match(p, seq)) continue\n this.pending.delete(seq)\n p.resolve(typeof outcome === \"function\" ? outcome(p, seq) : outcome)\n }\n }\n\n /**\n * Reset the diff baseline for (app, view) without touching the device.\n * Used when a legacy layout bypasses the scene path (clear_view /\n * dashboard_card / unknown layoutTypes go to native raw): after that, the\n * retained frame no longer matches the glasses, so the next render() must\n * diff from empty — otherwise \"unchanged\" elements would be skipped and\n * never repainted.\n */\n public resetBaseline(appId: string, view: \"main\" | \"dashboard\"): void {\n this.store.commit(appId, view, [])\n }\n\n /**\n * A system-level clear wiped the view (durationMs expiry, unmount fallback,\n * boot-window expiry): mark every app's baseline for that view stale. Unlike\n * resetBaseline this KEEPS the retained frames — they remain the\n * restore-as-replay source; only incremental diffing restarts from empty.\n */\n public markViewStale(view: \"main\" | \"dashboard\"): void {\n this.store.markViewStale(view)\n // Whatever was in flight for the view got wiped with it.\n this.settlePending(() => true, {presented: false, superseded: true, reason: \"cleared\"})\n }\n\n /** Returns false when the frame stayed phone-side (no presentation report will follow). */\n private sendFrame(frame: SceneFrame): boolean {\n // Single native view: only the visible surface's frames go out. Suppressed\n // main frames stay committed; setOverlayOwner(null) replays them.\n const overlayHeld = useDisplayStore.getState().overlayOwner !== null\n if (overlayHeld !== (frame.view === \"dashboard\")) return false\n try {\n // Frames carry the canvas they were laid out against; only a frame from\n // a path that predates the tag falls back to the current capabilities.\n const caps = this.currentCapabilities()\n if (!frame.canvas && caps) frame = {...frame, canvas: {width: caps.width, height: caps.height}}\n // sendDisplayEvent hook -> direct BluetoothSdk.displayEvent (the exact\n // wiring the deleted MantleManager hook provided).\n void Promise.resolve(BluetoothSdk.displayEvent({view: frame.view, scene: frame})).catch((err) => {\n console.error(`${LOG_TAG}: native scene send failed:`, err)\n })\n\n // Keep the phone-side glasses mirror on the same frame as native. Legacy\n // layouts update this store in LocalDisplayManager.sendToNative; scene\n // frames bypass that method, so without an explicit write every\n // positioning device (including G2) leaves the mirror blank/stale.\n useDisplayStore.getState().setDisplayEvent({\n view: frame.view,\n layout: {\n layoutType: \"scene\",\n appId: frame.appId,\n view: frame.view,\n sceneEpoch: frame.sceneEpoch,\n width: frame.canvas?.width,\n height: frame.canvas?.height,\n elements: frame.elements,\n },\n })\n return true\n } catch (err) {\n console.error(`${LOG_TAG}: native scene send failed:`, err)\n return false\n }\n }\n\n // ===========================================================================\n // Test hooks\n // ===========================================================================\n\n public _resetForTest(): void {\n this.store.clearAll()\n this.settlePending(() => true, {presented: false, superseded: false, reason: \"reset\"})\n this.presentedSub?.remove()\n this.presentedSub = null\n this.settledSub?.remove()\n this.settledSub = null\n this.settledListeners.clear()\n this.seqCounter = 0\n }\n\n public _lastFrameForTest(appId: string, view: string): FrameElement[] {\n return this.store.lastFrame(appId, view)\n }\n}\n\nconst sceneRenderer = SceneRenderer.getInstance()\nexport default sceneRenderer\nexport {SceneRenderer}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"controllers.d.ts","sourceRoot":"","sources":["../../src/services/controllers.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAAC,g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INPUT_SURFACES = {
|
|
|
41
41
|
[ControllerTypes.WEAR_OS]: [WATCH_SURFACE],
|
|
42
42
|
[ControllerTypes.GAMEBRICK]: [GAMEBRICK_SURFACE],
|
|
43
43
|
[ControllerTypes.IINE_ANANKE]: [GAMEBRICK_SURFACE],
|
|
44
|
+
[ControllerTypes.ZERO2]: [GAMEBRICK_SURFACE],
|
|
44
45
|
[ControllerTypes.R1]: [],
|
|
45
46
|
};
|
|
46
47
|
/** The input surfaces a connected controller of `model` adds to the glasses'. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"controllers.js","sourceRoot":"","sources":["../../src/services/controllers.ts"],"names":[],"mappings":"AAQA,OAAO,EAAC,eAAe,EAAC,MAAM,gBAAgB,CAAA;AAI9C,wDAAwD;AACxD,MAAM,mBAAmB,GAAiB;IACxC,IAAI,EAAE,SAAS;IACf,MAAM,EAAE;QACN,KAAK;QACL,YAAY;QACZ,YAAY;QACZ,UAAU;QACV,YAAY;QACZ,YAAY;QACZ,aAAa;QACb,SAAS;QACT,WAAW;KACZ;CACF,CAAA;AAED,gHAAgH;AAChH,MAAM,aAAa,GAAiB;IAClC,IAAI,EAAE,SAAS;IACf,MAAM,EAAE;QACN,KAAK;QACL,YAAY;QACZ,YAAY;QACZ,UAAU;QACV,YAAY;QACZ,YAAY;QACZ,aAAa;QACb,SAAS;QACT,WAAW;KACZ;CACF,CAAA;AAED,iHAAiH;AACjH,MAAM,iBAAiB,GAAiB;IACtC,IAAI,EAAE,SAAS;IACf,MAAM,EAAE,CAAC,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,UAAU,EAAE,YAAY,EAAE,YAAY,EAAE,aAAa,CAAC;CACnG,CAAA;AAED,+EAA+E;AAC/E,MAAM,cAAc,GAAsD;IACxE,CAAC,eAAe,CAAC,WAAW,CAAC,EAAE,CAAC,mBAAmB,CAAC;IACpD,CAAC,eAAe,CAAC,WAAW,CAAC,EAAE,CAAC,aAAa,CAAC;IAC9C,CAAC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AAgC,CAAA;QAC1D,IAAI,OAAO,EAAE,KAAK,QAAQ,IAAI,CAAC,EAAE,IAAI,OAAO,KAAK,KAAK,QAAQ;YAAE,SAAQ;QACxE,OAAO,CAAC,IAAI,CAAC,EAAC,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAC,CAAC,CAAA;IACvE,CAAC;IACD,OAAO,OAAO,CAAA;AAChB,CAAC;AAED,6DAA6D;AAC7D,MAAM,UAAU,iBAAiB,CAAC,MAAoC;IACpE,OAAO,MAAM,EAAE,SAAS,KAAK,IAAI,IAAI,MAAM,CAAC,WAAW,KAAK,IAAI,CAAA;AAClE,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,QAAsD;IACrF,OAAO,MAAM,CAAC,MAAM,CAAC,QAAQ,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,iBAAiB,CAAC,CAAA;AAChE,CAAC;AAED,wDAAwD;AACxD,MAAM,UAAU,mBAAmB,CAAC,QAAsD;IACxF,OAAO,gBAAgB,CAAC,QAAQ,CAAC;SAC9B,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,GAAG,MAAM,CAAC,EAAE,IAAI,MAAM,CAAC,KAAK,EAAE,CAAC;SAC/C,IAAI,EAAE;SACN,IAAI,CAAC,GAAG,CAAC,CAAA;AACd,CAAC","sourcesContent":["/**\n * Controller registry read-model: the paired records (the native-authoritative\n * `controllers` setting) and the live driver statuses (glasses status\n * `controllers`), plus what each model adds to the input surfaces. Pure.\n */\nimport type {ControllerStatus, PairedController} from \"@glassly/bluetooth-sdk\"\n\nimport type {ButtonCapabilities} from \"../types\"\nimport {ControllerTypes} from \"../types/enums\"\n\nexport type InputSurface = NonNullable<ButtonCapabilities[\"buttons\"]>[number]\n\n/** The Neural Band's thumb swipes, pinches and dial. */\nconst NEURAL_BAND_SURFACE: InputSurface = {\n type: \"swipe2d\",\n events: [\n \"TAP\",\n \"DOUBLE_TAP\",\n \"PRESS_HOLD\",\n \"SWIPE_UP\",\n \"SWIPE_DOWN\",\n \"SWIPE_LEFT\",\n \"SWIPE_RIGHT\",\n \"DIAL_UP\",\n \"DIAL_DOWN\",\n ],\n}\n\n/** A watch trackpad's taps and four-way swipes, and the crown (Apple) or rotary bezel (Wear OS) as the dial. */\nconst WATCH_SURFACE: InputSurface = {\n type: \"swipe2d\",\n events: [\n \"TAP\",\n \"DOUBLE_TAP\",\n \"PRESS_HOLD\",\n \"SWIPE_UP\",\n \"SWIPE_DOWN\",\n \"SWIPE_LEFT\",\n \"SWIPE_RIGHT\",\n \"DIAL_UP\",\n \"DIAL_DOWN\",\n ],\n}\n\n/** The Gamebrick's D-pad is four absolute swipes; A is the press lifecycle (tap and hold) and B a double tap. */\nconst GAMEBRICK_SURFACE: InputSurface = {\n type: \"swipe2d\",\n events: [\"TAP\", \"DOUBLE_TAP\", \"PRESS_HOLD\", \"SWIPE_UP\", \"SWIPE_DOWN\", \"SWIPE_LEFT\", \"SWIPE_RIGHT\"],\n}\n\n// The R1 swipes up/down like the temples it stands in for, so it adds nothing.\nconst INPUT_SURFACES: Readonly<Record<string, readonly InputSurface[]>> = {\n [ControllerTypes.NEURAL_BAND]: [NEURAL_BAND_SURFACE],\n [ControllerTypes.APPLE_WATCH]: [WATCH_SURFACE],\n [ControllerTypes.WEAR_OS]: [WATCH_SURFACE],\n [ControllerTypes.GAMEBRICK]: [GAMEBRICK_SURFACE],\n [ControllerTypes.IINE_ANANKE]: [GAMEBRICK_SURFACE],\n [ControllerTypes.R1]: [],\n}\n\n/** The input surfaces a connected controller of `model` adds to the glasses'. */\nexport function controllerInputSurfaces(model: string): InputSurface[] {\n return (INPUT_SURFACES[model] ?? []).map((surface) => ({...surface, events: [...surface.events]}))\n}\n\n/** The model swipes in two dimensions. */\nexport function hasInput2d(model: string): boolean {\n return (INPUT_SURFACES[model] ?? []).some((surface) => surface.type === \"swipe2d\")\n}\n\nexport function isControllerModel(model: string | undefined): boolean {\n return model !== undefined && (Object.values(ControllerTypes) as string[]).includes(model)\n}\n\n/** The `controllers` setting as records; malformed entries are dropped. */\nexport function pairedControllersFrom(value: unknown): PairedController[] {\n if (!Array.isArray(value)) return []\n const records: PairedController[] = []\n for (const entry of value) {\n if (!entry || typeof entry !== \"object\") continue\n const {id, model, name} = entry as Record<string, unknown>\n if (typeof id !== \"string\" || !id || typeof model !== \"string\") continue\n records.push({id, model, name: typeof name === \"string\" ? name : id})\n }\n return records\n}\n\n/** Delivering input: link up and the route or claim done. */\nexport function isControllerReady(status: ControllerStatus | undefined): boolean {\n return status?.connected === true && status.fullyBooted === true\n}\n\nexport function readyControllers(statuses: Record<string, ControllerStatus> | undefined): ControllerStatus[] {\n return Object.values(statuses ?? {}).filter(isControllerReady)\n}\n\n/** Change key over the controllers delivering input. */\nexport function readyControllersKey(statuses: Record<string, ControllerStatus> | undefined): string {\n return readyControllers(statuses)\n .map((status) => `${status.id}=${status.model}`)\n .sort()\n .join(\",\")\n}\n"]}
|
|
1
|
+
{"version":3,"file":"controllers.js","sourceRoot":"","sources":["../../src/services/controllers.ts"],"names":[],"mappings":"AAQA,OAAO,EAAC,eAAe,EAAC,MAAM,gBAAgB,CAAA;AAI9C,wDAAwD;AACxD,MAAM,mBAAmB,GAAiB;IACxC,IAAI,EAAE,SAAS;IACf,MAAM,EAAE;QACN,KAAK;QACL,YAAY;QACZ,YAAY;QACZ,UAAU;QACV,YAAY;QACZ,YAAY;QACZ,aAAa;QACb,SAAS;QACT,WAAW;KACZ;CACF,CAAA;AAED,gHAAgH;AAChH,MAAM,aAAa,GAAiB;IAClC,IAAI,EAAE,SAAS;IACf,MAAM,EAAE;QACN,KAAK;QACL,YAAY;QACZ,YAAY;QACZ,UAAU;QACV,YAAY;QACZ,YAAY;QACZ,aAAa;QACb,SAAS;QACT,WAAW;KACZ;CACF,CAAA;AAED,iHAAiH;AACjH,MAAM,iBAAiB,GAAiB;IACtC,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CAAC,GAAG,CAAC,CAAA;AACd,CAAC","sourcesContent":["/**\n * Controller registry read-model: the paired records (the native-authoritative\n * `controllers` setting) and the live driver statuses (glasses status\n * `controllers`), plus what each model adds to the input surfaces. Pure.\n */\nimport type {ControllerStatus, PairedController} from \"@glassly/bluetooth-sdk\"\n\nimport type {ButtonCapabilities} from \"../types\"\nimport {ControllerTypes} from \"../types/enums\"\n\nexport type InputSurface = NonNullable<ButtonCapabilities[\"buttons\"]>[number]\n\n/** The Neural Band's thumb swipes, pinches and dial. */\nconst NEURAL_BAND_SURFACE: InputSurface = {\n type: \"swipe2d\",\n events: [\n \"TAP\",\n \"DOUBLE_TAP\",\n \"PRESS_HOLD\",\n \"SWIPE_UP\",\n \"SWIPE_DOWN\",\n \"SWIPE_LEFT\",\n \"SWIPE_RIGHT\",\n \"DIAL_UP\",\n \"DIAL_DOWN\",\n ],\n}\n\n/** A watch trackpad's taps and four-way swipes, and the crown (Apple) or rotary bezel (Wear OS) as the dial. */\nconst WATCH_SURFACE: InputSurface = {\n type: \"swipe2d\",\n events: [\n \"TAP\",\n \"DOUBLE_TAP\",\n \"PRESS_HOLD\",\n \"SWIPE_UP\",\n \"SWIPE_DOWN\",\n \"SWIPE_LEFT\",\n \"SWIPE_RIGHT\",\n \"DIAL_UP\",\n \"DIAL_DOWN\",\n ],\n}\n\n/** The Gamebrick's D-pad is four absolute swipes; A is the press lifecycle (tap and hold) and B a double tap. */\nconst GAMEBRICK_SURFACE: InputSurface = {\n type: \"swipe2d\",\n events: [\"TAP\", \"DOUBLE_TAP\", \"PRESS_HOLD\", \"SWIPE_UP\", \"SWIPE_DOWN\", \"SWIPE_LEFT\", \"SWIPE_RIGHT\"],\n}\n\n// The R1 swipes up/down like the temples it stands in for, so it adds nothing.\nconst INPUT_SURFACES: Readonly<Record<string, readonly InputSurface[]>> = {\n [ControllerTypes.NEURAL_BAND]: [NEURAL_BAND_SURFACE],\n [ControllerTypes.APPLE_WATCH]: [WATCH_SURFACE],\n [ControllerTypes.WEAR_OS]: [WATCH_SURFACE],\n [ControllerTypes.GAMEBRICK]: [GAMEBRICK_SURFACE],\n [ControllerTypes.IINE_ANANKE]: [GAMEBRICK_SURFACE],\n [ControllerTypes.ZERO2]: [GAMEBRICK_SURFACE],\n [ControllerTypes.R1]: [],\n}\n\n/** The input surfaces a connected controller of `model` adds to the glasses'. */\nexport function controllerInputSurfaces(model: string): InputSurface[] {\n return (INPUT_SURFACES[model] ?? []).map((surface) => ({...surface, events: [...surface.events]}))\n}\n\n/** The model swipes in two dimensions. */\nexport function hasInput2d(model: string): boolean {\n return (INPUT_SURFACES[model] ?? []).some((surface) => surface.type === \"swipe2d\")\n}\n\nexport function isControllerModel(model: string | undefined): boolean {\n return model !== undefined && (Object.values(ControllerTypes) as string[]).includes(model)\n}\n\n/** The `controllers` setting as records; malformed entries are dropped. */\nexport function pairedControllersFrom(value: unknown): PairedController[] {\n if (!Array.isArray(value)) return []\n const records: PairedController[] = []\n for (const entry of value) {\n if (!entry || typeof entry !== \"object\") continue\n const {id, model, name} = entry as Record<string, unknown>\n if (typeof id !== \"string\" || !id || typeof model !== \"string\") continue\n records.push({id, model, name: typeof name === \"string\" ? name : id})\n }\n return records\n}\n\n/** Delivering input: link up and the route or claim done. */\nexport function isControllerReady(status: ControllerStatus | undefined): boolean {\n return status?.connected === true && status.fullyBooted === true\n}\n\nexport function readyControllers(statuses: Record<string, ControllerStatus> | undefined): ControllerStatus[] {\n return Object.values(statuses ?? {}).filter(isControllerReady)\n}\n\n/** Change key over the controllers delivering input. */\nexport function readyControllersKey(statuses: Record<string, ControllerStatus> | undefined): string {\n return readyControllers(statuses)\n .map((status) => `${status.id}=${status.model}`)\n .sort()\n .join(\",\")\n}\n"]}
|
|
@@ -53,6 +53,8 @@ function glassesCapabilities(model) {
|
|
|
53
53
|
// Glassly CFW supports the complete vector contract, including SVG and rotation.
|
|
54
54
|
// Upstream g2flash publishes a raster canvas with sceneVector=false.
|
|
55
55
|
const vector = useGlassesStore.getState().sceneVector === true;
|
|
56
|
+
// Depth is a disparity between the lenses; one panel (MemoMind One) draws every element flat.
|
|
57
|
+
const stereo = (base.display.count ?? 1) >= 2;
|
|
56
58
|
return {
|
|
57
59
|
...(volumeGate ? withVolumeGate(base) : base),
|
|
58
60
|
hasNativeNavigation: resolveNativeNavigation(base.hasNativeNavigation, true, forceNativeNavigationOnCfw()),
|
|
@@ -67,7 +69,7 @@ function glassesCapabilities(model) {
|
|
|
67
69
|
// Vector firmware draws an image as one cached slot, the same as a shape.
|
|
68
70
|
maxImageElements: Math.max(base.display.maxImageElements ?? 0, vector ? CFW_VECTOR_MAX_ELEMENTS : CFW_MAX_IMAGE_ELEMENTS),
|
|
69
71
|
...(vector
|
|
70
|
-
? { shapes: [...ALL_DISPLAY_SHAPES, "svg"], animation: true, rotation: true, depth:
|
|
72
|
+
? { shapes: [...ALL_DISPLAY_SHAPES, "svg"], animation: true, rotation: true, depth: stereo }
|
|
71
73
|
: {}),
|
|
72
74
|
},
|
|
73
75
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"effectiveCapabilities.js","sourceRoot":"","sources":["../../src/services/effectiveCapabilities.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,EAAC,eAAe,EAAC,MAAM,mBAAmB,CAAA;AACjD,OAAO,EAAC,QAAQ,EAAE,gBAAgB,EAAC,MAAM,oBAAoB,CAAA;AAC7D,OAAO,EAAC,kBAAkB,EAAe,oBAAoB,EAAoB,MAAM,UAAU,CAAA;AACjG,OAAO,EAAC,uBAAuB,EAAE,gBAAgB,EAAoB,MAAM,eAAe,CAAA;AAC1F,OAAO,EAAC,uBAAuB,EAAC,MAAM,wBAAwB,CAAA;AAE9D,MAAM,qBAAqB,GAAG,EAAE,CAAA;AAChC,MAAM,sBAAsB,GAAG,EAAE,CAAA;AACjC,MAAM,uBAAuB,GAAG,GAAG,CAAA;AAOnC,MAAM,UAAU,kBAAkB;IAChC,M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E,CAAC,GAAG,OAAO,EAAE,GAAG,KAAK,CAAC;SAChC;KACF,CAAA;AACH,CAAC;AAED,SAAS,cAAc,CAAC,IAAkB;IACxC,OAAO,EAAC,GAAG,IAAI,EAAE,UAAU,EAAE,EAAC,GAAG,CAAC,IAAI,CAAC,UAAU,IAAI,EAAE,CAAC,EAAE,UAAU,EAAE,IAAI,EAAC,EAAC,CAAA;AAC9E,CAAC","sourcesContent":["/**\n * Effective device capabilities — the static model profile plus what the\n * connected firmware reports at runtime. The runtime override is the scene\n * canvas: Glassly CFW on the G2 rasterizes scenes phone-side straight into\n * the 640×480 panel, so the drawable canvas grows past stock's 576×288; on\n * the RayNeo iO it opens a 540×180 page that stock firmware has no\n * equivalent of. Any model whose profile declares `hasCustomFirmware` reads it.\n * Native publishes the canvas into the glasses status (0 = none). Because\n * that path is phone-side rasterization, the stock firmware's container\n * pools (6 text / 4 image) don't bound a CFW frame either — element caps are\n * lifted alongside the canvas, bounded only to keep frames sane. Firmware\n * that draws vector shapes keeps 128 scene slots, so shape-heavy frames\n * (a game board, a chart) get a larger shared text/shape budget.\n *\n * Every connected controller adds its model's input surfaces to\n * `button.buttons` (the Meta Neural Band a `swipe2d` entry), so a miniapp can\n * tell four-way swipes from the temples' and the R1 ring's up/down.\n */\nimport {useGlassesStore} from \"../stores/glasses\"\nimport {SETTINGS, useSettingsStore} from \"../stores/settings\"\nimport {ALL_DISPLAY_SHAPES, DeviceTypes, getModelCapabilities, type Capabilities} from \"../types\"\nimport {controllerInputSurfaces, readyControllers, type InputSurface} from \"./controllers\"\nimport {resolveNativeNavigation} from \"./nativeNavigationGate\"\n\nconst CFW_MAX_TEXT_ELEMENTS = 24\nconst CFW_MAX_IMAGE_ELEMENTS = 16\nconst CFW_VECTOR_MAX_ELEMENTS = 120\n\nexport interface SceneCanvasSize {\n width: number\n height: number\n}\n\nexport function runtimeSceneCanvas(): SceneCanvasSize | null {\n const {sceneCanvasWidth, sceneCanvasHeight} = useGlassesStore.getState()\n if (!sceneCanvasWidth || !sceneCanvasHeight || sceneCanvasWidth <= 0 || sceneCanvasHeight <= 0) return null\n return {width: sceneCanvasWidth, height: sceneCanvasHeight}\n}\n\nfunction forceNativeNavigationOnCfw(): boolean {\n return useSettingsStore.getState().getSetting(SETTINGS.cfw_native_navigation.key) === true\n}\n\n/** The connected firmware gates microphone streaming on volume (G2 Glassly CFW revision 40+). */\nexport function runtimeVolumeGate(): boolean {\n return useGlassesStore.getState().volumeGate === true\n}\n\nexport function getEffectiveCapabilities(model: DeviceTypes): Capabilities {\n return withControllerInput(glassesCapabilities(model))\n}\n\nfunction glassesCapabilities(model: DeviceTypes): Capabilities {\n const base = getModelCapabilities(model)\n // Only models with a Glassly CFW publish a canvas or a volume gate; never\n // let a stale value reshape another model.\n const canvas = base.hasCustomFirmware ? runtimeSceneCanvas() : null\n const volumeGate = base.hasCustomFirmware && base.hasMicrophone && runtimeVolumeGate()\n if (!canvas) return volumeGate ? withVolumeGate(base) : base\n if (!base.display) return volumeGate ? withVolumeGate(base) : base\n // Glassly CFW supports the complete vector contract, including SVG and rotation.\n // Upstream g2flash publishes a raster canvas with sceneVector=false.\n const vector = useGlassesStore.getState().sceneVector === true\n // Depth is a disparity between the lenses; one panel (MemoMind One) draws every element flat.\n const stereo = (base.display.count ?? 1) >= 2\n return {\n ...(volumeGate ? withVolumeGate(base) : base),\n hasNativeNavigation: resolveNativeNavigation(base.hasNativeNavigation, true, forceNativeNavigationOnCfw()),\n display: {\n ...base.display,\n width: canvas.width,\n height: canvas.height,\n // A Glassly CFW that publishes a canvas takes positioned elements, whatever\n // the stock profile says (the G1's stock firmware degrades scenes to text walls).\n canPosition: true,\n maxTextElements: Math.max(\n base.display.maxTextElements ?? 0,\n vector ? CFW_VECTOR_MAX_ELEMENTS : CFW_MAX_TEXT_ELEMENTS,\n ),\n // Vector firmware draws an image as one cached slot, the same as a shape.\n maxImageElements: Math.max(\n base.display.maxImageElements ?? 0,\n vector ? CFW_VECTOR_MAX_ELEMENTS : CFW_MAX_IMAGE_ELEMENTS,\n ),\n ...(vector\n ? {shapes: [...ALL_DISPLAY_SHAPES, \"svg\" as const], animation: true, rotation: true, depth: stereo}\n : {}),\n },\n }\n}\n\nfunction withControllerInput(caps: Capabilities): Capabilities {\n const buttons = caps.button?.buttons ?? []\n const types = new Set(buttons.map((surface) => surface.type))\n const added: InputSurface[] = []\n for (const status of readyControllers(useGlassesStore.getState().controllers)) {\n for (const surface of controllerInputSurfaces(status.model)) {\n if (types.has(surface.type)) continue\n types.add(surface.type)\n added.push(surface)\n }\n }\n if (added.length === 0) return caps\n return {\n ...caps,\n hasButton: true,\n button: {\n ...caps.button,\n count: (caps.button?.count ?? buttons.length) + added.length,\n buttons: [...buttons, ...added],\n },\n }\n}\n\nfunction withVolumeGate(base: Capabilities): Capabilities {\n return {...base, microphone: {...(base.microphone ?? {}), volumeGate: true}}\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"appVisibility.d.ts","sourceRoot":"","sources":["../../src/stores/appVisibility.ts"],"names":[],"mappings":"AAAA,iGAAiG;AACjG,eAAO,MAAM,eAAe,GAAI,KAAK;IAAC,OAAO,EAAE,OAAO,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAC,KAAG,OAC/B,CAAA;AAEzC,+EAA+E;AAC/E,eAAO,MAAM,mBAAmB,GAAI,gBAAgB,OAAO,EAAE,YAAY,OAAO,KAAG,OACrD,CAAA;AAE9B;;;;GAIG;AACH,eAAO,MAAM,uBAAuB,EAAE,WAAW,CAAC,MAAM,CAA2D,CAAA;AAEnH,+EAA+E;AAC/E,eAAO,MAAM,mBAAmB,GAAI,aAAa,MAAM,KAAG,OAAmD,CAAA;AAE7G;;;;;;GAMG;AACH,eAAO,MAAM,kBAAkB,EAAE,WAAW,CAAC,MAAM,
|
|
1
|
+
{"version":3,"file":"appVisibility.d.ts","sourceRoot":"","sources":["../../src/stores/appVisibility.ts"],"names":[],"mappings":"AAAA,iGAAiG;AACjG,eAAO,MAAM,eAAe,GAAI,KAAK;IAAC,OAAO,EAAE,OAAO,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAC,KAAG,OAC/B,CAAA;AAEzC,+EAA+E;AAC/E,eAAO,MAAM,mBAAmB,GAAI,gBAAgB,OAAO,EAAE,YAAY,OAAO,KAAG,OACrD,CAAA;AAE9B;;;;GAIG;AACH,eAAO,MAAM,uBAAuB,EAAE,WAAW,CAAC,MAAM,CAA2D,CAAA;AAEnH,+EAA+E;AAC/E,eAAO,MAAM,mBAAmB,GAAI,aAAa,MAAM,KAAG,OAAmD,CAAA;AAE7G;;;;;;GAMG;AACH,eAAO,MAAM,kBAAkB,EAAE,WAAW,CAAC,MAAM,CAKjD,CAAA;AAEF,iEAAiE;AACjE,eAAO,MAAM,iBAAiB,GAAI,aAAa,MAAM,EAAE,iBAAiB,OAAO,KAAG,OACzB,CAAA;AAEzD;;;;;;GAMG;AACH,eAAO,MAAM,uBAAuB,EAAE,WAAW,CAAC,MAAM,CAAkC,CAAA;AAE1F,uFAAuF;AACvF,eAAO,MAAM,kBAAkB,GAC7B,aAAa,MAAM,EACnB,iBAAiB,OAAO,EACxB,kBAAkB,OAAO,KACxB,OAA4F,CAAA"}
|
|
@@ -22,7 +22,6 @@ export const DEV_TOOLS_PACKAGES = new Set([
|
|
|
22
22
|
"com.glassly.example",
|
|
23
23
|
"com.glassly.tetris",
|
|
24
24
|
"com.glassly.compass",
|
|
25
|
-
"com.glassly.showcase",
|
|
26
25
|
]);
|
|
27
26
|
/** True when the app is dev-only and developer tools are off. */
|
|
28
27
|
export const isGatedByDevTools = (packageName, devToolsEnabled) => !devToolsEnabled && DEV_TOOLS_PACKAGES.has(packageName);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"appVisibility.js","sourceRoot":"","sources":["../../src/stores/appVisibility.ts"],"names":[],"mappings":"AAAA,iGAAiG;AACjG,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,GAAqC,EAA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BAAkB,GAAwB,IAAI,GAAG,CAAC;IAC7D,wBAAwB;IACxB,qBAAqB;IACrB,oBAAoB;IACpB,qBAAqB;CACtB,CAAC,CAAA;AAEF,iEAAiE;AACjE,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,WAAmB,EAAE,eAAwB,EAAW,EAAE,CAC1F,CAAC,eAAe,IAAI,kBAAkB,CAAC,GAAG,CAAC,WAAW,CAAC,CAAA;AAEzD;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAwB,IAAI,GAAG,CAAC,CAAC,mBAAmB,CAAC,CAAC,CAAA;AAE1F,uFAAuF;AACvF,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAChC,WAAmB,EACnB,eAAwB,EACxB,gBAAyB,EAChB,EAAE,CAAC,CAAC,eAAe,IAAI,CAAC,gBAAgB,IAAI,uBAAuB,CAAC,GAAG,CAAC,WAAW,CAAC,CAAA","sourcesContent":["/** Host built-in phone pages and dashboard-type miniapps: never launched from a glasses menu. */\nexport const isSystemMiniapp = (app: {offline: boolean; type: string}): boolean =>\n app.offline || app.type === \"dashboard\"\n\n/** Combine registry-enforced visibility with the user's home-screen choice. */\nexport const resolveHiddenStatus = (registryHidden: boolean, userHidden: boolean): boolean =>\n registryHidden || userHidden\n\n/**\n * Miniapps that start off the primary home screen. They stay listed under\n * \"view all apps\", where \"Add to Home\" saves an explicit choice that wins\n * over this default from then on.\n */\nexport const DEFAULT_HIDDEN_PACKAGES: ReadonlySet<string> = new Set([\"com.glassly.camera\", \"com.glassly.recorder\"])\n\n/** The home-screen visibility of an app the user has never hidden or added. */\nexport const defaultHiddenStatus = (packageName: string): boolean => DEFAULT_HIDDEN_PACKAGES.has(packageName)\n\n/**\n * Miniapps that exist only for developers: the Miniapp Developer launcher and\n * the bundled sample/test miniapps. They are projected into the app store\n * only while the `dev_tools` setting is on; off, they are absent from every\n * launcher surface (home, all apps, glasses menu, AI listing), not merely\n * hidden from the primary home screen.\n */\nexport const DEV_TOOLS_PACKAGES: ReadonlySet<string> = new Set([\n \"com.glassly.miniappdev\",\n \"com.glassly.example\",\n \"com.glassly.tetris\",\n \"com.glassly.compass\",\n])\n\n/** True when the app is dev-only and developer tools are off. */\nexport const isGatedByDevTools = (packageName: string, devToolsEnabled: boolean): boolean =>\n !devToolsEnabled && DEV_TOOLS_PACKAGES.has(packageName)\n\n/**\n * Miniapps that unlock once a real pair of glasses has been paired on this\n * phone (`has_paired_glasses`, latched by PairedGlassesLatch and never\n * cleared, so forgetting the glasses keeps them). Developer tools open them\n * early. Until either, they are absent from every launcher surface like the\n * dev-only set above.\n */\nexport const PAIRED_GLASSES_PACKAGES: ReadonlySet<string> = new Set([\"com.glassly.store\"])\n\n/** True when the app waits on a pairing that hasn't happened and dev tools are off. */\nexport const isGatedUntilPaired = (\n packageName: string,\n devToolsEnabled: boolean,\n hasPairedGlasses: boolean,\n): boolean => !devToolsEnabled && !hasPairedGlasses && PAIRED_GLASSES_PACKAGES.has(packageName)\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"settings.d.ts","sourceRoot":"","sources":["../../src/stores/settings.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,WAAW,EAAwB,MAAM,aAAa,CAAA;AAS9D,OAAO,EAAC,wBAAwB,EAAE,gCAAgC,EAAC,MAAM,wBAAwB,CAAA;AAEjG,MAAM,WAAW,OAAO;IACtB,GAAG,EAAE,MAAM,CAAA;IACX,YAAY,EAAE,MAAM,GAAG,CAAA;IACvB,QAAQ,EAAE,OAAO,CAAA;IACjB,YAAY,EAAE,OAAO,CAAA;IAGrB,OAAO,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,CAAA;IAEjC,QAAQ,CAAC,EAAE,MAAM,GAAG,CAAA;IAEpB,OAAO,EAAE,OAAO,CAAA;IAQhB,mBAAmB,CAAC,EAAE,IAAI,CAAA;IAC1B;;;;;;;;;;;;;;;OAeG;IACH,qBAAqB,CAAC,EAAE,IAAI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AAE,KAAK,CAAC,CAAA;IACzF,cAAc,EAAE,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAAK,WAAW,CAAC,IAAI,EAAE,KAAK,CAAC,CAAA;IAC3E,UAAU,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,GAAG,CAAA;IAEhC,eAAe,EAAE,MAAM,WAAW,CAAC,IAAI,EAAE,KAAK,CAAC,CAAA;IAE/C,oBAAoB,EAAE,MAAM,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IAC/C,uBAAuB,EAAE,MAAM,IAAI,CAAA;CACpC;AAuBD,eAAO,MAAM,gBAAgB;;;;;;;;EAsX5B,CAAA;AAED,eAAO,MAAM,UAAU,GAAI,CAAC,GAAG,GAAG,EAAE,KAAK,MAAM,KAAG,CAAC,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,WAAW,CAAC,IAAI,EAAE,KAAK,CAAC,CAI3F,CAAA"}
|
package/build/stores/settings.js
CHANGED
|
@@ -886,6 +886,13 @@ export const SETTINGS = {
|
|
|
886
886
|
saveOnServer: false,
|
|
887
887
|
persist: true,
|
|
888
888
|
},
|
|
889
|
+
home_offline_card: {
|
|
890
|
+
key: "home_offline_card",
|
|
891
|
+
defaultValue: () => true,
|
|
892
|
+
writable: true,
|
|
893
|
+
saveOnServer: false,
|
|
894
|
+
persist: true,
|
|
895
|
+
},
|
|
889
896
|
// Gesture-dots debug indicator: flash a glyph on the glasses when a touch
|
|
890
897
|
// gesture is received while the display is empty. Works on any
|
|
891
898
|
// scene-capable device, not only CFW. Device-local debug knob, default off.
|