@glassly/engine 0.3.7 → 0.3.8-dev.977
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/README.md +4 -0
- package/build/engine.d.ts +8 -2
- package/build/engine.d.ts.map +1 -1
- package/build/engine.js +7 -4
- package/build/engine.js.map +1 -1
- package/build/facades/backup.d.ts +14 -0
- package/build/facades/backup.d.ts.map +1 -0
- package/build/facades/backup.js +22 -0
- package/build/facades/backup.js.map +1 -0
- package/build/facades/glasses.d.ts +4 -4
- package/build/facades/glasses.d.ts.map +1 -1
- package/build/facades/glasses.js +4 -4
- package/build/facades/glasses.js.map +1 -1
- package/build/generated/releaseMetadata.js +4 -4
- 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/AppRegistry.d.ts +2 -1
- package/build/services/AppRegistry.d.ts.map +1 -1
- package/build/services/AppRegistry.js +38 -8
- package/build/services/AppRegistry.js.map +1 -1
- package/build/services/AppStateBackup.d.ts +98 -0
- package/build/services/AppStateBackup.d.ts.map +1 -0
- package/build/services/AppStateBackup.js +224 -0
- package/build/services/AppStateBackup.js.map +1 -0
- package/build/services/BlobStore.d.ts.map +1 -1
- package/build/services/BlobStore.js +5 -12
- package/build/services/BlobStore.js.map +1 -1
- package/build/services/CloudClientService.d.ts +1 -0
- package/build/services/CloudClientService.d.ts.map +1 -1
- package/build/services/CloudClientService.js +34 -2
- package/build/services/CloudClientService.js.map +1 -1
- package/build/services/DisplayProcessor.d.ts +2 -0
- package/build/services/DisplayProcessor.d.ts.map +1 -1
- package/build/services/DisplayProcessor.js +15 -1
- package/build/services/DisplayProcessor.js.map +1 -1
- package/build/services/GlassesTouchInput.d.ts.map +1 -1
- package/build/services/GlassesTouchInput.js +4 -2
- package/build/services/GlassesTouchInput.js.map +1 -1
- package/build/services/JSCrashloopReportService.d.ts.map +1 -1
- package/build/services/JSCrashloopReportService.js +5 -0
- package/build/services/JSCrashloopReportService.js.map +1 -1
- package/build/services/JSRouter.d.ts +11 -3
- package/build/services/JSRouter.d.ts.map +1 -1
- package/build/services/JSRouter.js +36 -6
- package/build/services/JSRouter.js.map +1 -1
- package/build/services/LocalMiniappRuntime.d.ts +13 -0
- package/build/services/LocalMiniappRuntime.d.ts.map +1 -1
- package/build/services/LocalMiniappRuntime.js +54 -20
- package/build/services/LocalMiniappRuntime.js.map +1 -1
- package/build/services/MiniappEngine.d.ts +9 -0
- package/build/services/MiniappEngine.d.ts.map +1 -1
- package/build/services/MiniappEngine.js +60 -27
- package/build/services/MiniappEngine.js.map +1 -1
- package/build/services/MiniappLauncher.d.ts +2 -0
- package/build/services/MiniappLauncher.d.ts.map +1 -1
- package/build/services/MiniappLauncher.js +6 -0
- package/build/services/MiniappLauncher.js.map +1 -1
- package/build/services/NavigationService.d.ts +1 -0
- package/build/services/NavigationService.d.ts.map +1 -1
- package/build/services/NavigationService.js +20 -6
- package/build/services/NavigationService.js.map +1 -1
- package/build/services/PhoneCalendarService.d.ts.map +1 -1
- package/build/services/PhoneCalendarService.js +8 -0
- package/build/services/PhoneCalendarService.js.map +1 -1
- package/build/services/PhoneNotificationsSync.d.ts.map +1 -1
- package/build/services/PhoneNotificationsSync.js +7 -3
- package/build/services/PhoneNotificationsSync.js.map +1 -1
- package/build/services/SceneRenderer.js +1 -1
- package/build/services/SceneRenderer.js.map +1 -1
- package/build/services/appStateBackupFile.d.ts +32 -0
- package/build/services/appStateBackupFile.d.ts.map +1 -0
- package/build/services/appStateBackupFile.js +135 -0
- package/build/services/appStateBackupFile.js.map +1 -0
- package/build/services/controllers.d.ts.map +1 -1
- package/build/services/controllers.js +11 -3
- package/build/services/controllers.js.map +1 -1
- package/build/services/effectiveCapabilities.js +3 -0
- package/build/services/effectiveCapabilities.js.map +1 -1
- package/build/services/pages/pageEligibility.d.ts.map +1 -1
- package/build/services/pages/pageEligibility.js +8 -1
- package/build/services/pages/pageEligibility.js.map +1 -1
- package/build/services/settingsBridge.d.ts.map +1 -1
- package/build/services/settingsBridge.js +1 -0
- package/build/services/settingsBridge.js.map +1 -1
- package/build/services/{appleWatch/AppleWatchLink.d.ts → watch/WatchLink.d.ts} +8 -7
- package/build/services/watch/WatchLink.d.ts.map +1 -0
- package/build/services/{appleWatch/AppleWatchLink.js → watch/WatchLink.js} +14 -15
- package/build/services/watch/WatchLink.js.map +1 -0
- package/build/stores/apps.d.ts.map +1 -1
- package/build/stores/apps.js +14 -2
- package/build/stores/apps.js.map +1 -1
- package/build/stores/settings.d.ts.map +1 -1
- package/build/stores/settings.js +53 -3
- package/build/stores/settings.js.map +1 -1
- package/build/types/capabilities/even-realities-g1.d.ts.map +1 -1
- package/build/types/capabilities/even-realities-g1.js +3 -0
- package/build/types/capabilities/even-realities-g1.js.map +1 -1
- package/build/types/capabilities/memomind-one.d.ts +3 -0
- package/build/types/capabilities/memomind-one.d.ts.map +1 -0
- package/build/types/capabilities/memomind-one.js +41 -0
- package/build/types/capabilities/memomind-one.js.map +1 -0
- package/build/types/enums.d.ts +6 -2
- package/build/types/enums.d.ts.map +1 -1
- package/build/types/enums.js +4 -0
- package/build/types/enums.js.map +1 -1
- package/build/types/hardware.d.ts +3 -1
- package/build/types/hardware.d.ts.map +1 -1
- package/build/types/hardware.js +3 -1
- package/build/types/hardware.js.map +1 -1
- package/build/utils/display/index.d.ts +2 -1
- package/build/utils/display/index.d.ts.map +1 -1
- package/build/utils/display/index.js +3 -2
- package/build/utils/display/index.js.map +1 -1
- package/build/utils/display/profiles/index.d.ts +2 -1
- package/build/utils/display/profiles/index.d.ts.map +1 -1
- package/build/utils/display/profiles/index.js +3 -2
- package/build/utils/display/profiles/index.js.map +1 -1
- package/build/utils/display/profiles/rayneo-io.d.ts +1 -1
- package/build/utils/display/profiles/rayneo-io.d.ts.map +1 -1
- package/build/utils/display/profiles/rayneo-io.js +1 -1
- package/build/utils/display/profiles/rayneo-io.js.map +1 -1
- package/build/utils/display/scene/index.d.ts +1 -1
- package/build/utils/display/scene/index.d.ts.map +1 -1
- package/build/utils/display/scene/index.js +1 -1
- package/build/utils/display/scene/index.js.map +1 -1
- package/build/utils/display/scene/process.d.ts +6 -0
- package/build/utils/display/scene/process.d.ts.map +1 -1
- package/build/utils/display/scene/process.js +22 -7
- package/build/utils/display/scene/process.js.map +1 -1
- package/build/utils/miniappGlobals.d.ts +13 -17
- package/build/utils/miniappGlobals.d.ts.map +1 -1
- package/build/utils/miniappGlobals.js +24 -56
- package/build/utils/miniappGlobals.js.map +1 -1
- package/package.json +7 -7
- package/src/engine.ts +7 -4
- package/src/facades/backup.ts +28 -0
- package/src/facades/glasses.ts +5 -5
- package/src/generated/releaseMetadata.ts +4 -4
- package/src/index.ts +1 -0
- package/src/services/AppRegistry.ts +36 -9
- package/src/services/AppStateBackup.ts +283 -0
- package/src/services/BlobStore.ts +5 -11
- package/src/services/CloudClientService.ts +35 -4
- package/src/services/DisplayProcessor.ts +20 -8
- package/src/services/GlassesTouchInput.ts +6 -2
- package/src/services/JSCrashloopReportService.ts +5 -0
- package/src/services/JSRouter.ts +37 -6
- package/src/services/LocalMiniappRuntime.ts +55 -20
- package/src/services/MiniappEngine.ts +62 -27
- package/src/services/MiniappLauncher.ts +7 -0
- package/src/services/NavigationService.ts +28 -8
- package/src/services/PhoneCalendarService.ts +7 -0
- package/src/services/PhoneNotificationsSync.ts +8 -3
- package/src/services/SceneRenderer.ts +1 -1
- package/src/services/appStateBackupFile.ts +171 -0
- package/src/services/controllers.ts +12 -3
- package/src/services/effectiveCapabilities.ts +3 -0
- package/src/services/pages/pageEligibility.ts +9 -1
- package/src/services/settingsBridge.ts +1 -0
- package/src/services/{appleWatch/AppleWatchLink.ts → watch/WatchLink.ts} +20 -20
- package/src/stores/apps.ts +13 -2
- package/src/stores/settings.ts +60 -7
- package/src/types/capabilities/even-realities-g1.ts +4 -0
- package/src/types/capabilities/memomind-one.ts +42 -0
- package/src/types/enums.ts +4 -0
- package/src/types/hardware.ts +14 -1
- package/src/utils/display/index.ts +4 -2
- package/src/utils/display/profiles/index.ts +9 -2
- package/src/utils/display/profiles/rayneo-io.ts +6 -1
- package/src/utils/display/scene/index.ts +1 -1
- package/src/utils/display/scene/process.ts +22 -7
- package/src/utils/miniappGlobals.ts +32 -64
- package/build/services/appleWatch/AppleWatchLink.d.ts.map +0 -1
- package/build/services/appleWatch/AppleWatchLink.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"process.js","sourceRoot":"","sources":["../../../../src/utils/display/scene/process.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAC,cAAc,EAAC,MAAM,WAAW,CAAA;AACxC,OAAO,EAAC,YAAY,EAAC,MAAM,0BAA0B,CAAA;AACrD,OAAO,EAAC,WAAW,EAAC,MAAM,wBAAwB,CAAA;AAalD,OAAO,EAAC,eAAe,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,kBAAkB,EAAC,MAAM,SAAS,CAAA;AAQjG,8DAA8D;AAC9D,SAAS,QAAQ,CAAC,EAAqB,EAAE,KAAa;IACpD,OAAO,EAAE,CAAC,EAAE,IAAI,GAAG,EAAE,CAAC,IAAI,IAAI,KAAK,GAAG,CAAA;AACxC,CAAC;AAED,SAAS,QAAQ,CAAC,GAAa,EAAE,KAAa,EAAE,MAAc;IAC5D,MAAM,EAAE,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAA;IACzC,MAAM,EAAE,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAA;IACzC,MAAM,EAAE,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IA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AM;YACZ,GAAG,EAAE,OAAO;YACZ,IAAI,EAAE,WAAW;YACjB,KAAK,EAAE,EAAE,CAAC,KAAK;YACf,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,EAAC,UAAU,EAAC,CAAC,CAAC,CAAC,EAAE,CAAC;YACnC,GAAG,KAAK;YACR,WAAW,EAAE,kBAAkB,CAAC,EAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,WAAW,EAAE,KAAK,EAAE,EAAE,CAAC,KAAK,EAAE,KAAK,EAAC,CAAC;SAC3F,CAAC,CAAA;IACJ,CAAC;IAED,OAAO,EAAC,QAAQ,EAAE,GAAG,EAAE,QAAQ,EAAE,OAAO,EAAC,CAAA;AAC3C,CAAC","sourcesContent":["/**\n * Scene processing — validate → clamp → budget → wrap. Everything here is\n * generic; device variation enters only through the capabilities block and the\n * display profile (data, not code). Spec §5.\n *\n * Never rejects a frame: offending elements are dropped per-element and\n * reported via `dropped` / `degraded` (design doc §3.4.6; spec §4 refines the\n * design doc's image \"reject\" to per-element drop).\n */\n\nimport {compileSvgPath} from \"./svgPath\"\nimport {TextMeasurer} from \"../measurer/TextMeasurer\"\nimport {TextWrapper} from \"../wrapper/TextWrapper\"\nimport type {DisplayProfile} from \"../profiles/types\"\nimport type {DiffableElement} from \"./differ\"\nimport type {\n SceneBox,\n SceneBoxInput,\n SceneDisplayCapabilities,\n SceneElementInput,\n ScenePoint,\n SceneTextStyle,\n SceneTransition,\n SceneTransitionEdge,\n} from \"./types\"\nimport {MAX_SCENE_DEPTH, POINT_SHAPE_ARITY, POINT_SHAPE_TYPES, elementContentHash} from \"./types\"\n\nexport interface ProcessedScene {\n elements: DiffableElement[]\n degraded: boolean\n dropped: string[]\n}\n\n/** Reporting id for an element the app may not have named. */\nfunction reportId(el: SceneElementInput, index: number): string {\n return el.id ?? `${el.type}[${index}]`\n}\n\nfunction clampBox(box: SceneBox, width: number, height: number): SceneBox | null {\n const x1 = Math.max(0, Math.floor(box.x))\n const y1 = Math.max(0, Math.floor(box.y))\n const x2 = Math.min(width, Math.floor(box.x) + Math.max(0, Math.floor(box.w)))\n const y2 = Math.min(height, Math.floor(box.y) + Math.max(0, Math.floor(box.h)))\n if (x2 <= x1 || y2 <= y1) return null\n return {x: x1, y: y1, w: x2 - x1, h: y2 - y1}\n}\n\nconst isFinite = (n: unknown): n is number => typeof n === \"number\" && Number.isFinite(n)\n\n/** Integer points, or null when the count/values are invalid for the type. */\nfunction validPoints(el: SceneElementInput): ScenePoint[] | null {\n const raw = (el as {points?: unknown}).points\n if (!Array.isArray(raw) || !(POINT_SHAPE_ARITY[el.type] ?? []).includes(raw.length)) return null\n const points: ScenePoint[] = []\n for (const p of raw) {\n if (!p || typeof p !== \"object\" || !isFinite((p as ScenePoint).x) || !isFinite((p as ScenePoint).y)) return null\n points.push({x: Math.floor((p as ScenePoint).x), y: Math.floor((p as ScenePoint).y)})\n }\n return points\n}\n\nfunction pointsBox(points: ScenePoint[]): SceneBox {\n const xs = points.map((p) => p.x)\n const ys = points.map((p) => p.y)\n const x = Math.min(...xs)\n const y = Math.min(...ys)\n return {x, y, w: Math.max(...xs) - x + 1, h: Math.max(...ys) - y + 1}\n}\n\nfunction validEdge(e: unknown): SceneTransitionEdge | undefined {\n if (!e || typeof e !== \"object\") return undefined\n const dx = Math.round(Number((e as SceneTransitionEdge).dx ?? 0))\n const dy = Math.round(Number((e as SceneTransitionEdge).dy ?? 0))\n if (!isFinite(dx) || !isFinite(dy) || Math.abs(dx) > 1024 || Math.abs(dy) > 1024) return undefined\n return {dx, dy}\n}\n\nfunction validTransition(t: unknown): SceneTransition | undefined {\n if (!t || typeof t !== \"object\") return undefined\n const {durationMs, easing} = t as SceneTransition\n if (!isFinite(durationMs) || durationMs <= 0) return undefined\n const out: SceneTransition = easing ? {durationMs, easing} : {durationMs}\n const enter = validEdge((t as SceneTransition).enter)\n const exit = validEdge((t as SceneTransition).exit)\n if (enter) out.enter = enter\n if (exit) out.exit = exit\n return out\n}\n\nfunction boxShrunk(orig: SceneBox, clamped: SceneBox): boolean {\n return (\n clamped.x !== Math.floor(orig.x) ||\n clamped.y !== Math.floor(orig.y) ||\n clamped.w !== Math.floor(orig.w) ||\n clamped.h !== Math.floor(orig.h)\n )\n}\n\n/**\n * Line height for box-height→line-count math — ONLY when the profile declares\n * a calibrated `lineHeightPx`. Deriving one from full-canvas numbers proved\n * wrong on hardware (288/8=36px clipped the G2 nav instruction to one line;\n * the real container line height is smaller). Without calibration we return\n * null and the wrap step skips host-side height clipping entirely — text wraps\n * to the box WIDTH and the firmware clips vertically in-box, which is exactly\n * the legacy behavior.\n */\nexport function profileLineHeightPx(profile: DisplayProfile, _canvasHeight: number): number | null {\n return profile.lineHeightPx ?? null\n}\n\n/**\n * Process a raw scene against a device's capabilities + profile. Output is\n * diff-ready (text pre-wrapped, boxes clamped, content hashed) and reflects\n * exactly what will be sent — the diff baseline is post-processed by design\n * (spec §4).\n */\nexport function processScene(\n input: readonly SceneElementInput[],\n caps: SceneDisplayCapabilities,\n profile: DisplayProfile,\n): ProcessedScene {\n const dropped: string[] = []\n let degraded = false\n\n const measurer = new TextMeasurer(profile)\n const wrapper = new TextWrapper(measurer)\n const lineHeight = profileLineHeightPx(profile, caps.height)\n\n // Validate + dedupe explicit ids (first occurrence wins; dupes are dev error).\n const seenIds = new Set<string>()\n const valid: {el: SceneElementInput; index: number; box: SceneBoxInput; points?: ScenePoint[]}[] = []\n input.forEach((raw, index) => {\n if (!raw || typeof raw !== \"object\") {\n dropped.push(reportId(raw ?? ({type: \"text\"} as SceneElementInput), index))\n degraded = true\n return\n }\n let points: ScenePoint[] | undefined\n if (POINT_SHAPE_TYPES.includes(raw.type)) {\n const valid = validPoints(raw)\n if (!valid) {\n dropped.push(reportId(raw, index))\n degraded = true\n return\n }\n points = valid\n raw = {...raw, box: pointsBox(valid)} as SceneElementInput\n }\n if (!raw.box) {\n dropped.push(reportId(raw, index))\n degraded = true\n return\n }\n // Non-finite box numbers (NaN/±Infinity/non-number) would survive the\n // Math.* clamp below and poison the frame all the way to native ints.\n const b = raw.box\n if (![b.x, b.y, b.w, b.h].every(isFinite)) {\n dropped.push(reportId(raw, index))\n degraded = true\n return\n }\n if ((raw.type === \"arc\" || raw.type === \"pie\") && !(isFinite(raw.startDeg) && isFinite(raw.endDeg))) {\n dropped.push(reportId(raw, index))\n degraded = true\n return\n }\n // Leading \"~\" is the differ's synthetic-id namespace — an app id there\n // would never match across frames (re-created every push). Normalize by\n // stripping; the rewrite is deterministic, so diffing stays stable.\n const el = raw.id?.startsWith(\"~\") ? {...raw, id: raw.id.replace(/^~+/, \"\") || undefined} : raw\n if (el.id) {\n const key = `${el.type}:${el.id}`\n if (seenIds.has(key)) {\n dropped.push(reportId(el, index))\n degraded = true\n return\n }\n seenIds.add(key)\n }\n valid.push({el, index, box: el.box as SceneBoxInput, points})\n })\n\n // Clamp + per-type limits, then budget in array order.\n let textBudget = caps.maxTextElements\n let imageBudget = caps.maxImageElements\n const out: DiffableElement[] = []\n let pathEdges = 0\n\n for (const {el, index, box, points} of valid) {\n const transition = validTransition((el as {transition?: unknown}).transition)\n // Leaving elements only exist to tween away; a device that jumps never shows them.\n if (transition?.exit && !caps.animation) continue\n const transform: {rotation?: number; pivot?: ScenePoint} = {}\n if (el.rotation !== undefined || el.pivot !== undefined) {\n const angle = el.rotation ?? 0\n const pivot = el.pivot ?? {x: box.x + box.w / 2, y: box.y + box.h / 2}\n if (\n !isFinite(angle) ||\n Math.abs(angle) > 36000 ||\n !isFinite(pivot.x) ||\n !isFinite(pivot.y) ||\n Math.abs(pivot.x) > 32767 ||\n Math.abs(pivot.y) > 32767 ||\n !caps.rotation ||\n el.type === \"image\" ||\n el.type === \"text\"\n ) {\n dropped.push(reportId(el, index))\n degraded = true\n continue\n }\n transform.rotation = Math.round(angle * 256) / 256\n transform.pivot = {x: Math.round(pivot.x), y: Math.round(pivot.y)}\n if (transition) transition.durationMs = Math.min(65535, transition.durationMs)\n }\n const transformHash =\n transform.rotation === undefined ? undefined : `${transform.rotation}:${transform.pivot?.x}:${transform.pivot?.y}`\n // Depth is a lens disparity, not content: devices without it draw the\n // element flat instead of dropping it. A non-number is still a dev error.\n let depth: number | undefined\n if (el.depth !== undefined) {\n if (!isFinite(el.depth)) {\n dropped.push(reportId(el, index))\n degraded = true\n continue\n }\n const d = Math.max(-MAX_SCENE_DEPTH, Math.min(MAX_SCENE_DEPTH, Math.round(el.depth)))\n if (caps.depth && d !== 0) depth = d\n }\n const plane = depth === undefined ? {} : {depth}\n const clamped = clampBox(box, caps.width, caps.height)\n if (!clamped) {\n dropped.push(reportId(el, index))\n degraded = true\n continue\n }\n const shrunk = boxShrunk(box, clamped)\n if (shrunk) degraded = true\n\n if (el.type === \"svg\") {\n try {\n if (!caps.shapes.includes(\"svg\") || textBudget <= 0 || shrunk)\n throw new Error(\"SVG unavailable or out of bounds\")\n const scale = el.scale ?? 1\n if (\n !isFinite(scale) ||\n scale < 0 ||\n scale > 8 ||\n (el.fillRule !== undefined && el.fillRule !== \"evenodd\" && el.fillRule !== \"nonzero\")\n )\n throw new Error(\"Invalid SVG scale or fill rule\")\n const compiled = compileSvgPath(el.d)\n if (pathEdges + compiled.edges > 4096) throw new Error(\"SVG scene exceeds the edge budget\")\n pathEdges += compiled.edges\n textBudget--\n out.push({\n id: el.id,\n type: \"svg\",\n box: clamped,\n d: el.d,\n path: compiled.commands,\n pathScale: Math.round(scale * 256),\n fillRule: el.fillRule ?? \"nonzero\",\n style: el.style,\n ...transform,\n ...plane,\n ...(transition ? {transition} : {}),\n contentHash: elementContentHash({\n type: \"svg\",\n data: `${el.d}:${scale}:${el.fillRule}:${transformHash}`,\n style: el.style,\n depth,\n }),\n })\n } catch {\n dropped.push(reportId(el, index))\n degraded = true\n }\n continue\n }\n\n if (el.type !== \"text\" && el.type !== \"image\" && el.type !== \"rect\") {\n // Vector shapes: only devices that draw them get them; the device clips\n // point shapes itself, so an off-canvas point is not a drop.\n if (!caps.shapes.includes(el.type) || textBudget <= 0) {\n dropped.push(reportId(el, index))\n degraded = true\n continue\n }\n textBudget--\n const angles = el.type === \"arc\" || el.type === \"pie\" ? {startDeg: el.startDeg, endDeg: el.endDeg} : {}\n out.push({\n id: el.id,\n type: el.type,\n box: clamped,\n style: el.style,\n ...(points ? {points} : {}),\n ...angles,\n ...(transition ? {transition} : {}),\n ...transform,\n ...plane,\n contentHash: elementContentHash({\n type: el.type,\n style: el.style,\n points,\n ...angles,\n data: transformHash,\n depth,\n }),\n })\n continue\n }\n\n if (el.type === \"image\") {\n // Images: a shrunk box can't be honored (we don't crop pixels host-side)\n // and per-image device limits are box-level (the firmware allocates the\n // component from the box). SGCs scale pixels to the box (phone-side\n // scaling — never on glasses).\n if (shrunk) {\n dropped.push(reportId(el, index))\n continue\n }\n if (caps.maxImagePx && (clamped.w > caps.maxImagePx.width || clamped.h > caps.maxImagePx.height)) {\n dropped.push(reportId(el, index))\n degraded = true\n continue\n }\n if (imageBudget <= 0) {\n dropped.push(reportId(el, index))\n degraded = true\n continue\n }\n imageBudget--\n out.push({\n id: el.id,\n type: \"image\",\n box: clamped,\n data: el.data,\n ...(el.style ? {style: el.style} : {}),\n ...(transition ? {transition} : {}),\n ...plane,\n contentHash: elementContentHash({type: \"image\", data: el.data, style: el.style, depth}),\n })\n continue\n }\n\n // text + rect share the text-container budget (design doc §3.4.6).\n if (textBudget <= 0) {\n dropped.push(reportId(el, index))\n degraded = true\n continue\n }\n textBudget--\n\n if (el.type === \"rect\") {\n out.push({\n id: el.id,\n type: \"rect\",\n box: clamped,\n style: el.style,\n ...(transition ? {transition} : {}),\n ...transform,\n ...plane,\n contentHash: elementContentHash({type: \"rect\", style: el.style, data: transformHash, depth}),\n })\n continue\n }\n\n // Text: wrap on the phone into the (clamped) box. The box then carries\n // pre-wrapped text; firmware in-box wrap is a fallback, not the mechanism.\n // Height clipping only applies with a CALIBRATED line height — otherwise\n // the firmware clips vertically in-box (legacy behavior).\n const style: SceneTextStyle = el.style ?? {}\n if (style.font === \"mono\" || style.font === \"builtin\") {\n // Grid text is laid out by the app (cols × rows) and builtin text by the\n // glasses' own font engine; the host's proportional wrap metrics don't\n // apply to either. Pass lines through and let the device clip.\n const monoText = el.text ?? \"\"\n out.push({\n id: el.id,\n type: \"text\",\n box: clamped,\n text: monoText,\n style: el.style,\n ...(transition ? {transition} : {}),\n ...plane,\n contentHash: elementContentHash({type: \"text\", text: monoText, style: el.style, depth}),\n })\n continue\n }\n const maxLines = lineHeight ? Math.max(1, Math.floor(clamped.h / lineHeight)) : profile.maxLines\n const result = wrapper.wrap(el.text ?? \"\", {\n maxWidthPx: clamped.w,\n maxLines,\n ...(style.breakMode ? {breakMode: style.breakMode} : {}),\n })\n let lines = result.lines\n if (result.truncated) {\n degraded = true\n if (style.overflow === \"ellipsis\" && lines.length > 0) {\n // Trim the last line until it fits WITH the ellipsis appended —\n // otherwise the extra glyph can overflow the clamped box width.\n let last = lines[lines.length - 1]\n while (last.length > 0 && !measurer.fitsInWidth(`${last}…`, clamped.w)) {\n last = last.slice(0, -1)\n }\n // A box narrower than the ellipsis glyph itself gets an empty line —\n // never emit a line wider than the clamped box.\n const ellipsized = last.length > 0 || measurer.fitsInWidth(\"…\", clamped.w) ? `${last}…` : \"\"\n lines = [...lines.slice(0, -1), ellipsized]\n }\n }\n const wrappedText = lines.join(\"\\n\")\n out.push({\n id: el.id,\n type: \"text\",\n box: clamped,\n text: wrappedText,\n style: el.style,\n ...(transition ? {transition} : {}),\n ...plane,\n contentHash: elementContentHash({type: \"text\", text: wrappedText, style: el.style, depth}),\n })\n }\n\n return {elements: out, degraded, dropped}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"process.js","sourceRoot":"","sources":["../../../../src/utils/display/scene/process.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAC,cAAc,EAAC,MAAM,WAAW,CAAA;AACxC,OAAO,EAAC,mBAAmB,EAAC,MAAM,8BAA8B,CAAA;AAChE,OAAO,EAAC,YAAY,EAAC,M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;YACf,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,EAAC,UAAU,EAAC,CAAC,CAAC,CAAC,EAAE,CAAC;YACnC,GAAG,KAAK;YACR,WAAW,EAAE,kBAAkB,CAAC,EAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,WAAW,EAAE,KAAK,EAAE,EAAE,CAAC,KAAK,EAAE,KAAK,EAAC,CAAC;SAC3F,CAAC,CAAA;IACJ,CAAC;IAED,OAAO,EAAC,QAAQ,EAAE,GAAG,EAAE,QAAQ,EAAE,OAAO,EAAC,CAAA;AAC3C,CAAC","sourcesContent":["/**\n * Scene processing — validate → clamp → budget → wrap. Everything here is\n * generic; device variation enters only through the capabilities block and the\n * display profile (data, not code). Spec §5.\n *\n * Never rejects a frame: offending elements are dropped per-element and\n * reported via `dropped` / `degraded` (design doc §3.4.6; spec §4 refines the\n * design doc's image \"reject\" to per-element drop).\n */\n\nimport {compileSvgPath} from \"./svgPath\"\nimport {isUnsupportedScript} from \"../measurer/script-detection\"\nimport {TextMeasurer} from \"../measurer/TextMeasurer\"\nimport {TextWrapper} from \"../wrapper/TextWrapper\"\nimport type {DisplayProfile} from \"../profiles/types\"\nimport type {DiffableElement} from \"./differ\"\nimport type {\n SceneBox,\n SceneBoxInput,\n SceneDisplayCapabilities,\n SceneElementInput,\n ScenePoint,\n SceneTextStyle,\n SceneTransition,\n SceneTransitionEdge,\n} from \"./types\"\nimport {MAX_SCENE_DEPTH, POINT_SHAPE_ARITY, POINT_SHAPE_TYPES, elementContentHash} from \"./types\"\n\nexport interface ProcessedScene {\n elements: DiffableElement[]\n degraded: boolean\n dropped: string[]\n}\n\n/** Reporting id for an element the app may not have named. */\nfunction reportId(el: SceneElementInput, index: number): string {\n return el.id ?? `${el.type}[${index}]`\n}\n\nfunction clampBox(box: SceneBox, width: number, height: number): SceneBox | null {\n const x1 = Math.max(0, Math.floor(box.x))\n const y1 = Math.max(0, Math.floor(box.y))\n const x2 = Math.min(width, Math.floor(box.x) + Math.max(0, Math.floor(box.w)))\n const y2 = Math.min(height, Math.floor(box.y) + Math.max(0, Math.floor(box.h)))\n if (x2 <= x1 || y2 <= y1) return null\n return {x: x1, y: y1, w: x2 - x1, h: y2 - y1}\n}\n\nconst isFinite = (n: unknown): n is number => typeof n === \"number\" && Number.isFinite(n)\n\n/**\n * Text the host cannot wrap: a script the measurer has no widths or break\n * rules for (Thai has no spaces between words, for one). It is passed through\n * unwrapped and the device's text engine lays it out in the box.\n */\nexport function wrapsOnDevice(text: string): boolean {\n for (const char of text) {\n if (isUnsupportedScript(char)) return true\n }\n return false\n}\n\n/** Integer points, or null when the count/values are invalid for the type. */\nfunction validPoints(el: SceneElementInput): ScenePoint[] | null {\n const raw = (el as {points?: unknown}).points\n if (!Array.isArray(raw) || !(POINT_SHAPE_ARITY[el.type] ?? []).includes(raw.length)) return null\n const points: ScenePoint[] = []\n for (const p of raw) {\n if (!p || typeof p !== \"object\" || !isFinite((p as ScenePoint).x) || !isFinite((p as ScenePoint).y)) return null\n points.push({x: Math.floor((p as ScenePoint).x), y: Math.floor((p as ScenePoint).y)})\n }\n return points\n}\n\nfunction pointsBox(points: ScenePoint[]): SceneBox {\n const xs = points.map((p) => p.x)\n const ys = points.map((p) => p.y)\n const x = Math.min(...xs)\n const y = Math.min(...ys)\n return {x, y, w: Math.max(...xs) - x + 1, h: Math.max(...ys) - y + 1}\n}\n\nfunction validEdge(e: unknown): SceneTransitionEdge | undefined {\n if (!e || typeof e !== \"object\") return undefined\n const dx = Math.round(Number((e as SceneTransitionEdge).dx ?? 0))\n const dy = Math.round(Number((e as SceneTransitionEdge).dy ?? 0))\n if (!isFinite(dx) || !isFinite(dy) || Math.abs(dx) > 1024 || Math.abs(dy) > 1024) return undefined\n return {dx, dy}\n}\n\nfunction validTransition(t: unknown): SceneTransition | undefined {\n if (!t || typeof t !== \"object\") return undefined\n const {durationMs, easing} = t as SceneTransition\n if (!isFinite(durationMs) || durationMs <= 0) return undefined\n const out: SceneTransition = easing ? {durationMs, easing} : {durationMs}\n const enter = validEdge((t as SceneTransition).enter)\n const exit = validEdge((t as SceneTransition).exit)\n if (enter) out.enter = enter\n if (exit) out.exit = exit\n return out\n}\n\nfunction boxShrunk(orig: SceneBox, clamped: SceneBox): boolean {\n return (\n clamped.x !== Math.floor(orig.x) ||\n clamped.y !== Math.floor(orig.y) ||\n clamped.w !== Math.floor(orig.w) ||\n clamped.h !== Math.floor(orig.h)\n )\n}\n\n/**\n * Line height for box-height→line-count math — ONLY when the profile declares\n * a calibrated `lineHeightPx`. Deriving one from full-canvas numbers proved\n * wrong on hardware (288/8=36px clipped the G2 nav instruction to one line;\n * the real container line height is smaller). Without calibration we return\n * null and the wrap step skips host-side height clipping entirely — text wraps\n * to the box WIDTH and the firmware clips vertically in-box, which is exactly\n * the legacy behavior.\n */\nexport function profileLineHeightPx(profile: DisplayProfile, _canvasHeight: number): number | null {\n return profile.lineHeightPx ?? null\n}\n\n/**\n * Process a raw scene against a device's capabilities + profile. Output is\n * diff-ready (text pre-wrapped, boxes clamped, content hashed) and reflects\n * exactly what will be sent — the diff baseline is post-processed by design\n * (spec §4).\n */\nexport function processScene(\n input: readonly SceneElementInput[],\n caps: SceneDisplayCapabilities,\n profile: DisplayProfile,\n): ProcessedScene {\n const dropped: string[] = []\n let degraded = false\n\n const measurer = new TextMeasurer(profile)\n const wrapper = new TextWrapper(measurer)\n const lineHeight = profileLineHeightPx(profile, caps.height)\n\n // Validate + dedupe explicit ids (first occurrence wins; dupes are dev error).\n const seenIds = new Set<string>()\n const valid: {el: SceneElementInput; index: number; box: SceneBoxInput; points?: ScenePoint[]}[] = []\n input.forEach((raw, index) => {\n if (!raw || typeof raw !== \"object\") {\n dropped.push(reportId(raw ?? ({type: \"text\"} as SceneElementInput), index))\n degraded = true\n return\n }\n let points: ScenePoint[] | undefined\n if (POINT_SHAPE_TYPES.includes(raw.type)) {\n const valid = validPoints(raw)\n if (!valid) {\n dropped.push(reportId(raw, index))\n degraded = true\n return\n }\n points = valid\n raw = {...raw, box: pointsBox(valid)} as SceneElementInput\n }\n if (!raw.box) {\n dropped.push(reportId(raw, index))\n degraded = true\n return\n }\n // Non-finite box numbers (NaN/±Infinity/non-number) would survive the\n // Math.* clamp below and poison the frame all the way to native ints.\n const b = raw.box\n if (![b.x, b.y, b.w, b.h].every(isFinite)) {\n dropped.push(reportId(raw, index))\n degraded = true\n return\n }\n if ((raw.type === \"arc\" || raw.type === \"pie\") && !(isFinite(raw.startDeg) && isFinite(raw.endDeg))) {\n dropped.push(reportId(raw, index))\n degraded = true\n return\n }\n // Leading \"~\" is the differ's synthetic-id namespace — an app id there\n // would never match across frames (re-created every push). Normalize by\n // stripping; the rewrite is deterministic, so diffing stays stable.\n const el = raw.id?.startsWith(\"~\") ? {...raw, id: raw.id.replace(/^~+/, \"\") || undefined} : raw\n if (el.id) {\n const key = `${el.type}:${el.id}`\n if (seenIds.has(key)) {\n dropped.push(reportId(el, index))\n degraded = true\n return\n }\n seenIds.add(key)\n }\n valid.push({el, index, box: el.box as SceneBoxInput, points})\n })\n\n // Clamp + per-type limits, then budget in array order.\n let textBudget = caps.maxTextElements\n let imageBudget = caps.maxImageElements\n const out: DiffableElement[] = []\n let pathEdges = 0\n\n for (const {el, index, box, points} of valid) {\n const transition = validTransition((el as {transition?: unknown}).transition)\n // Leaving elements only exist to tween away; a device that jumps never shows them.\n if (transition?.exit && !caps.animation) continue\n const transform: {rotation?: number; pivot?: ScenePoint} = {}\n if (el.rotation !== undefined || el.pivot !== undefined) {\n const angle = el.rotation ?? 0\n const pivot = el.pivot ?? {x: box.x + box.w / 2, y: box.y + box.h / 2}\n if (\n !isFinite(angle) ||\n Math.abs(angle) > 36000 ||\n !isFinite(pivot.x) ||\n !isFinite(pivot.y) ||\n Math.abs(pivot.x) > 32767 ||\n Math.abs(pivot.y) > 32767 ||\n !caps.rotation ||\n el.type === \"image\" ||\n el.type === \"text\"\n ) {\n dropped.push(reportId(el, index))\n degraded = true\n continue\n }\n transform.rotation = Math.round(angle * 256) / 256\n transform.pivot = {x: Math.round(pivot.x), y: Math.round(pivot.y)}\n if (transition) transition.durationMs = Math.min(65535, transition.durationMs)\n }\n const transformHash =\n transform.rotation === undefined ? undefined : `${transform.rotation}:${transform.pivot?.x}:${transform.pivot?.y}`\n // Depth is a lens disparity, not content: devices without it draw the\n // element flat instead of dropping it. A non-number is still a dev error.\n let depth: number | undefined\n if (el.depth !== undefined) {\n if (!isFinite(el.depth)) {\n dropped.push(reportId(el, index))\n degraded = true\n continue\n }\n const d = Math.max(-MAX_SCENE_DEPTH, Math.min(MAX_SCENE_DEPTH, Math.round(el.depth)))\n if (caps.depth && d !== 0) depth = d\n }\n const plane = depth === undefined ? {} : {depth}\n const clamped = clampBox(box, caps.width, caps.height)\n if (!clamped) {\n dropped.push(reportId(el, index))\n degraded = true\n continue\n }\n const shrunk = boxShrunk(box, clamped)\n if (shrunk) degraded = true\n\n if (el.type === \"svg\") {\n try {\n if (!caps.shapes.includes(\"svg\") || textBudget <= 0 || shrunk)\n throw new Error(\"SVG unavailable or out of bounds\")\n const scale = el.scale ?? 1\n if (\n !isFinite(scale) ||\n scale < 0 ||\n scale > 8 ||\n (el.fillRule !== undefined && el.fillRule !== \"evenodd\" && el.fillRule !== \"nonzero\")\n )\n throw new Error(\"Invalid SVG scale or fill rule\")\n const compiled = compileSvgPath(el.d)\n if (pathEdges + compiled.edges > 4096) throw new Error(\"SVG scene exceeds the edge budget\")\n pathEdges += compiled.edges\n textBudget--\n out.push({\n id: el.id,\n type: \"svg\",\n box: clamped,\n d: el.d,\n path: compiled.commands,\n pathScale: Math.round(scale * 256),\n fillRule: el.fillRule ?? \"nonzero\",\n style: el.style,\n ...transform,\n ...plane,\n ...(transition ? {transition} : {}),\n contentHash: elementContentHash({\n type: \"svg\",\n data: `${el.d}:${scale}:${el.fillRule}:${transformHash}`,\n style: el.style,\n depth,\n }),\n })\n } catch {\n dropped.push(reportId(el, index))\n degraded = true\n }\n continue\n }\n\n if (el.type !== \"text\" && el.type !== \"image\" && el.type !== \"rect\") {\n // Vector shapes: only devices that draw them get them; the device clips\n // point shapes itself, so an off-canvas point is not a drop.\n if (!caps.shapes.includes(el.type) || textBudget <= 0) {\n dropped.push(reportId(el, index))\n degraded = true\n continue\n }\n textBudget--\n const angles = el.type === \"arc\" || el.type === \"pie\" ? {startDeg: el.startDeg, endDeg: el.endDeg} : {}\n out.push({\n id: el.id,\n type: el.type,\n box: clamped,\n style: el.style,\n ...(points ? {points} : {}),\n ...angles,\n ...(transition ? {transition} : {}),\n ...transform,\n ...plane,\n contentHash: elementContentHash({\n type: el.type,\n style: el.style,\n points,\n ...angles,\n data: transformHash,\n depth,\n }),\n })\n continue\n }\n\n if (el.type === \"image\") {\n // Images: a shrunk box can't be honored (we don't crop pixels host-side)\n // and per-image device limits are box-level (the firmware allocates the\n // component from the box). SGCs scale pixels to the box (phone-side\n // scaling — never on glasses).\n if (shrunk) {\n dropped.push(reportId(el, index))\n continue\n }\n if (caps.maxImagePx && (clamped.w > caps.maxImagePx.width || clamped.h > caps.maxImagePx.height)) {\n dropped.push(reportId(el, index))\n degraded = true\n continue\n }\n if (imageBudget <= 0) {\n dropped.push(reportId(el, index))\n degraded = true\n continue\n }\n imageBudget--\n out.push({\n id: el.id,\n type: \"image\",\n box: clamped,\n data: el.data,\n ...(el.style ? {style: el.style} : {}),\n ...(transition ? {transition} : {}),\n ...plane,\n contentHash: elementContentHash({type: \"image\", data: el.data, style: el.style, depth}),\n })\n continue\n }\n\n // text + rect share the text-container budget (design doc §3.4.6).\n if (textBudget <= 0) {\n dropped.push(reportId(el, index))\n degraded = true\n continue\n }\n textBudget--\n\n if (el.type === \"rect\") {\n out.push({\n id: el.id,\n type: \"rect\",\n box: clamped,\n style: el.style,\n ...(transition ? {transition} : {}),\n ...transform,\n ...plane,\n contentHash: elementContentHash({type: \"rect\", style: el.style, data: transformHash, depth}),\n })\n continue\n }\n\n // Text: wrap on the phone into the (clamped) box. The box then carries\n // pre-wrapped text; firmware in-box wrap is a fallback, not the mechanism.\n // Height clipping only applies with a CALIBRATED line height — otherwise\n // the firmware clips vertically in-box (legacy behavior).\n const style: SceneTextStyle = el.style ?? {}\n if (style.font === \"mono\" || style.font === \"builtin\" || wrapsOnDevice(el.text ?? \"\")) {\n // Grid text is laid out by the app (cols × rows), builtin text by the\n // glasses' own font engine and unsupported scripts by the device's text\n // engine; the host's proportional wrap metrics don't apply to any of\n // them. Pass lines through and let the device wrap and clip.\n const monoText = el.text ?? \"\"\n out.push({\n id: el.id,\n type: \"text\",\n box: clamped,\n text: monoText,\n style: el.style,\n ...(transition ? {transition} : {}),\n ...plane,\n contentHash: elementContentHash({type: \"text\", text: monoText, style: el.style, depth}),\n })\n continue\n }\n const maxLines = lineHeight ? Math.max(1, Math.floor(clamped.h / lineHeight)) : profile.maxLines\n const maxWidthPx = Math.max(1, clamped.w - 2 * (profile.textInsetPx ?? 0))\n const result = wrapper.wrap(el.text ?? \"\", {\n maxWidthPx,\n maxLines,\n ...(style.breakMode ? {breakMode: style.breakMode} : {}),\n })\n let lines = result.lines\n if (result.truncated) {\n degraded = true\n if (style.overflow === \"ellipsis\" && lines.length > 0) {\n // Trim the last line until it fits WITH the ellipsis appended —\n // otherwise the extra glyph can overflow the clamped box width.\n let last = lines[lines.length - 1]\n while (last.length > 0 && !measurer.fitsInWidth(`${last}…`, maxWidthPx)) {\n last = last.slice(0, -1)\n }\n // A box narrower than the ellipsis glyph itself gets an empty line —\n // never emit a line wider than the clamped box.\n const ellipsized = last.length > 0 || measurer.fitsInWidth(\"…\", maxWidthPx) ? `${last}…` : \"\"\n lines = [...lines.slice(0, -1), ellipsized]\n }\n }\n const wrappedText = lines.join(\"\\n\")\n out.push({\n id: el.id,\n type: \"text\",\n box: clamped,\n text: wrappedText,\n style: el.style,\n ...(transition ? {transition} : {}),\n ...plane,\n contentHash: elementContentHash({type: \"text\", text: wrappedText, style: el.style, depth}),\n })\n }\n\n return {elements: out, degraded, dropped}\n}\n"]}
|
|
@@ -12,6 +12,11 @@ export interface MiniappSafeArea {
|
|
|
12
12
|
left: number;
|
|
13
13
|
right: number;
|
|
14
14
|
}
|
|
15
|
+
/**
|
|
16
|
+
* The host's capsule menu in the WebView's own coordinate space. `corner`
|
|
17
|
+
* floats over the page's top-right; `rail` sits in the iPhone Duo's status
|
|
18
|
+
* rail, inside the side safe-area inset and clear of the page content.
|
|
19
|
+
*/
|
|
15
20
|
export interface CapsuleMenuRect {
|
|
16
21
|
top: number;
|
|
17
22
|
right: number;
|
|
@@ -19,14 +24,8 @@ export interface CapsuleMenuRect {
|
|
|
19
24
|
left: number;
|
|
20
25
|
width: number;
|
|
21
26
|
height: number;
|
|
27
|
+
placement: "corner" | "rail";
|
|
22
28
|
}
|
|
23
|
-
/**
|
|
24
|
-
* @param topInsetOffset extra top offset to add when the WebView container does
|
|
25
|
-
* NOT already pad by the safe-area inset (i.e. WebView fills edge-to-edge under
|
|
26
|
-
* the status bar). Pass `insets.top` in that case, or 0 when the container
|
|
27
|
-
* already applies top padding.
|
|
28
|
-
*/
|
|
29
|
-
export declare function getCapsuleMenuRect(topInsetOffset?: number): CapsuleMenuRect;
|
|
30
29
|
export type MiniappColorScheme = "light" | "dark";
|
|
31
30
|
export interface BuildMiniappGlobalsOptions {
|
|
32
31
|
packageName?: string;
|
|
@@ -34,21 +33,18 @@ export interface BuildMiniappGlobalsOptions {
|
|
|
34
33
|
miniappLocal?: boolean;
|
|
35
34
|
miniappDeveloperMode?: boolean;
|
|
36
35
|
safeAreaInsets: MiniappSafeArea;
|
|
37
|
-
/**
|
|
38
|
-
|
|
39
|
-
* the status bar). In that case the capsule menu rect needs to shift down by
|
|
40
|
-
* the top inset so its coords match where it's actually drawn on screen.
|
|
41
|
-
*/
|
|
42
|
-
webviewFillsStatusBar?: boolean;
|
|
36
|
+
/** Where the host draws its capsule menu over this WebView. */
|
|
37
|
+
capsuleMenu: CapsuleMenuRect;
|
|
43
38
|
/** Current host color scheme. Miniapps may follow this to match the phone. */
|
|
44
39
|
colorScheme?: MiniappColorScheme;
|
|
45
40
|
}
|
|
46
41
|
/**
|
|
47
|
-
* JS to inject into a running miniapp when the host's safe area
|
|
48
|
-
* iPhone Duo folding
|
|
49
|
-
* CSS variables, then fires
|
|
42
|
+
* JS to inject into a running miniapp when the host's safe area or capsule
|
|
43
|
+
* menu moves (an iPhone Duo folding, or its rail's reserved regions growing):
|
|
44
|
+
* updates window.Glassly and the CSS variables, then fires
|
|
45
|
+
* `glassly:safe-area-change`.
|
|
50
46
|
*/
|
|
51
|
-
export declare function buildSafeAreaUpdateScript(insets: MiniappSafeArea): string;
|
|
47
|
+
export declare function buildSafeAreaUpdateScript(insets: MiniappSafeArea, capsuleMenu: CapsuleMenuRect): string;
|
|
52
48
|
/**
|
|
53
49
|
* Returns the JS string to inject into a miniapp WebView before its content
|
|
54
50
|
* loads. Sets window.Glassly with the standard fields miniapps read:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"miniappGlobals.d.ts","sourceRoot":"","sources":["../../src/utils/miniappGlobals.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,MAAM,WAAW,eAAe;IAC9B,GAAG,EAAE,MAAM,CAAA;IACX,MAAM,EAAE,MAAM,CAAA;IACd,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,MAAM,CAAA;CACd;AAED,MAAM,WAAW,eAAe;IAC9B,GAAG,EAAE,MAAM,CAAA;IACX,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,MAAM,CAAA;IACd,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,MAAM,CAAA;
|
|
1
|
+
{"version":3,"file":"miniappGlobals.d.ts","sourceRoot":"","sources":["../../src/utils/miniappGlobals.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,MAAM,WAAW,eAAe;IAC9B,GAAG,EAAE,MAAM,CAAA;IACX,MAAM,EAAE,MAAM,CAAA;IACd,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,MAAM,CAAA;CACd;AAED;;;;GAIG;AACH,MAAM,WAAW,eAAe;IAC9B,GAAG,EAAE,MAAM,CAAA;IACX,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,MAAM,CAAA;IACd,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,MAAM,CAAA;IACd,SAAS,EAAE,QAAQ,GAAG,MAAM,CAAA;CAC7B;AAED,MAAM,MAAM,kBAAkB,GAAG,OAAO,GAAG,MAAM,CAAA;AAEjD,MAAM,WAAW,0BAA0B;IACzC,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,YAAY,CAAC,EAAE,MAAM,EAAE,CAAA;IACvB,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB,oBAAoB,CAAC,EAAE,OAAO,CAAA;IAC9B,cAAc,EAAE,eAAe,CAAA;IAC/B,+DAA+D;IAC/D,WAAW,EAAE,eAAe,CAAA;IAC5B,8EAA8E;IAC9E,WAAW,CAAC,EAAE,kBAAkB,CAAA;CACjC;AAwBD;;;;;GAKG;AACH,wBAAgB,yBAAyB,CAAC,MAAM,EAAE,eAAe,EAAE,WAAW,EAAE,eAAe,GAAG,MAAM,CAcvG;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,0BAA0B,GAAG,MAAM,CAqJlF"}
|
|
@@ -6,55 +6,42 @@
|
|
|
6
6
|
* this util is the one place that builds the globals so every WebView gets the
|
|
7
7
|
* same API surface.
|
|
8
8
|
*/
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
* - CapsuleButton height ≈ h-7.5 (30px), width ≈ 73px
|
|
15
|
-
* - Positioned at right-2 (8px), top = theme.spacing.s2 (8px) below insets.top
|
|
16
|
-
*/
|
|
17
|
-
const CAPSULE_MENU_HEIGHT = 30;
|
|
18
|
-
const CAPSULE_MENU_WIDTH = 73;
|
|
19
|
-
const CAPSULE_MENU_PADDING = 8;
|
|
20
|
-
/**
|
|
21
|
-
* @param topInsetOffset extra top offset to add when the WebView container does
|
|
22
|
-
* NOT already pad by the safe-area inset (i.e. WebView fills edge-to-edge under
|
|
23
|
-
* the status bar). Pass `insets.top` in that case, or 0 when the container
|
|
24
|
-
* already applies top padding.
|
|
25
|
-
*/
|
|
26
|
-
export function getCapsuleMenuRect(topInsetOffset = 0) {
|
|
27
|
-
const screenWidth = Dimensions.get("window").width;
|
|
28
|
-
const top = topInsetOffset + CAPSULE_MENU_PADDING;
|
|
29
|
-
return {
|
|
30
|
-
top,
|
|
31
|
-
right: CAPSULE_MENU_PADDING,
|
|
32
|
-
bottom: top + CAPSULE_MENU_HEIGHT,
|
|
33
|
-
left: screenWidth - CAPSULE_MENU_PADDING - CAPSULE_MENU_WIDTH,
|
|
34
|
-
width: CAPSULE_MENU_WIDTH,
|
|
35
|
-
height: CAPSULE_MENU_HEIGHT,
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
function safeAreaCssVars(insets) {
|
|
9
|
+
import { Platform } from "react-native";
|
|
10
|
+
// CSS custom properties that mirror the safe-area and capsule menu data, so
|
|
11
|
+
// miniapp CSS (or Tailwind arbitrary values) can read them without touching
|
|
12
|
+
// JS: e.g. `style="margin-top: var(--glassly-capsule-top)"`.
|
|
13
|
+
function layoutCssVars(insets, capsule) {
|
|
39
14
|
return {
|
|
40
15
|
"--glassly-safe-top": `${insets.top}px`,
|
|
41
16
|
"--glassly-safe-bottom": `${insets.bottom}px`,
|
|
42
17
|
"--glassly-safe-left": `${insets.left}px`,
|
|
43
18
|
"--glassly-safe-right": `${insets.right}px`,
|
|
19
|
+
"--glassly-capsule-top": `${capsule.top}px`,
|
|
20
|
+
"--glassly-capsule-bottom": `${capsule.bottom}px`,
|
|
21
|
+
"--glassly-capsule-left": `${capsule.left}px`,
|
|
22
|
+
"--glassly-capsule-right": `${capsule.right}px`,
|
|
23
|
+
"--glassly-capsule-width": `${capsule.width}px`,
|
|
24
|
+
"--glassly-capsule-height": `${capsule.height}px`,
|
|
25
|
+
"--glassly-capsule-center-y": `${capsule.top + capsule.height / 2}px`,
|
|
26
|
+
// Right-side gutter to reserve so content doesn't slide under the
|
|
27
|
+
// capsule: its width + 16px breathing room, none when it sits in the rail.
|
|
28
|
+
"--glassly-capsule-gutter": `${capsule.placement === "rail" ? 0 : capsule.width + 16}px`,
|
|
44
29
|
};
|
|
45
30
|
}
|
|
46
31
|
/**
|
|
47
|
-
* JS to inject into a running miniapp when the host's safe area
|
|
48
|
-
* iPhone Duo folding
|
|
49
|
-
* CSS variables, then fires
|
|
32
|
+
* JS to inject into a running miniapp when the host's safe area or capsule
|
|
33
|
+
* menu moves (an iPhone Duo folding, or its rail's reserved regions growing):
|
|
34
|
+
* updates window.Glassly and the CSS variables, then fires
|
|
35
|
+
* `glassly:safe-area-change`.
|
|
50
36
|
*/
|
|
51
|
-
export function buildSafeAreaUpdateScript(insets) {
|
|
52
|
-
const sets = Object.entries(
|
|
37
|
+
export function buildSafeAreaUpdateScript(insets, capsuleMenu) {
|
|
38
|
+
const sets = Object.entries(layoutCssVars(insets, capsuleMenu))
|
|
53
39
|
.map(([k, v]) => `document.documentElement.style.setProperty(${JSON.stringify(k)}, ${JSON.stringify(v)});`)
|
|
54
40
|
.join("\n ");
|
|
55
41
|
return `
|
|
56
42
|
window.Glassly = window.Glassly || {};
|
|
57
43
|
window.Glassly.safeAreaInsets = ${JSON.stringify(insets)};
|
|
44
|
+
window.Glassly.capsuleMenu = ${JSON.stringify(capsuleMenu)};
|
|
58
45
|
try {
|
|
59
46
|
${sets}
|
|
60
47
|
} catch (e) { /* ignore */ }
|
|
@@ -75,12 +62,11 @@ export function buildSafeAreaUpdateScript(insets) {
|
|
|
75
62
|
* assign to it before the native bridge wires in.
|
|
76
63
|
*/
|
|
77
64
|
export function buildMiniappGlobalsScript(opts) {
|
|
78
|
-
const capsuleTopOffset = opts.webviewFillsStatusBar ? opts.safeAreaInsets.top : 0;
|
|
79
65
|
const globals = {
|
|
80
66
|
platform: Platform.OS,
|
|
81
67
|
capabilities: opts.capabilities ?? ["share", "open_url", "copy_clipboard", "download"],
|
|
82
68
|
safeAreaInsets: opts.safeAreaInsets,
|
|
83
|
-
capsuleMenu:
|
|
69
|
+
capsuleMenu: opts.capsuleMenu,
|
|
84
70
|
};
|
|
85
71
|
if (opts.packageName)
|
|
86
72
|
globals.packageName = opts.packageName;
|
|
@@ -90,25 +76,7 @@ export function buildMiniappGlobalsScript(opts) {
|
|
|
90
76
|
globals.miniappDeveloperMode = true;
|
|
91
77
|
if (opts.colorScheme)
|
|
92
78
|
globals.colorScheme = opts.colorScheme;
|
|
93
|
-
|
|
94
|
-
// Miniapp CSS (or Tailwind arbitrary values) can read these without
|
|
95
|
-
// touching JS: e.g. `style="margin-top: var(--glassly-capsule-top)"`.
|
|
96
|
-
const capsule = globals.capsuleMenu;
|
|
97
|
-
const insets = opts.safeAreaInsets;
|
|
98
|
-
const capsuleCenter = capsule.top + capsule.height / 2;
|
|
99
|
-
const cssVars = {
|
|
100
|
-
...safeAreaCssVars(insets),
|
|
101
|
-
"--glassly-capsule-top": `${capsule.top}px`,
|
|
102
|
-
"--glassly-capsule-bottom": `${capsule.bottom}px`,
|
|
103
|
-
"--glassly-capsule-left": `${capsule.left}px`,
|
|
104
|
-
"--glassly-capsule-right": `${capsule.right}px`,
|
|
105
|
-
"--glassly-capsule-width": `${capsule.width}px`,
|
|
106
|
-
"--glassly-capsule-height": `${capsule.height}px`,
|
|
107
|
-
"--glassly-capsule-center-y": `${capsuleCenter}px`,
|
|
108
|
-
// Right-side gutter to reserve so content doesn't slide under the
|
|
109
|
-
// capsule: capsule width + 16px breathing room.
|
|
110
|
-
"--glassly-capsule-gutter": `${capsule.width + 16}px`,
|
|
111
|
-
};
|
|
79
|
+
const cssVars = layoutCssVars(opts.safeAreaInsets, opts.capsuleMenu);
|
|
112
80
|
const cssVarsBlock = Object.entries(cssVars)
|
|
113
81
|
.map(([k, v]) => `${k}: ${v};`)
|
|
114
82
|
.join(" ");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"miniappGlobals.js","sourceRoot":"","sources":["../../src/utils/miniappGlobals.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAC,UAAU,EAAE,QAAQ,EAAC,MAAM,cAAc,CAAA;AAkBjD;;;;;;GAMG;AACH,MAAM,mBAAmB,GAAG,EAAE,CAAA;AAC9B,MAAM,kBAAkB,GAAG,EAAE,CAAA;AAC7B,MAAM,oBAAoB,GAAG,CAAC,CAAA;AAE9B;;;;;GAKG;AACH,MAAM,UAAU,kBAAkB,CAAC,cAAc,GAAG,CAAC;IACnD,MAAM,WAAW,GAAG,UAAU,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,KAAK,CAAA;IAClD,MAAM,GAAG,GAAG,cAAc,GAAG,oBAAoB,CAAA;IACjD,OAAO;QACL,GAAG;QACH,KAAK,EAAE,oBAAoB;QAC3B,MAAM,EAAE,GAAG,GAAG,mBAAmB;QACjC,IAAI,EAAE,WAAW,GAAG,oBAAoB,GAAG,kBAAkB;QAC7D,KAAK,EAAE,kBAAkB;QACzB,MAAM,EAAE,mBAAmB;KAC5B,CAAA;AACH,CAAC;AAoBD,SAAS,eAAe,CAAC,MAAuB;IAC9C,OAAO;QACL,oBAAoB,EAAE,GAAG,MAAM,CAAC,GAAG,IAAI;QACvC,uBAAuB,EAAE,GAAG,MAAM,CAAC,MAAM,IAAI;QAC7C,qBAAqB,EAAE,GAAG,MAAM,CAAC,IAAI,IAAI;QACzC,sBAAsB,EAAE,GAAG,MAAM,CAAC,KAAK,IAAI;KAC5C,CAAA;AACH,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,yBAAyB,CAAC,MAAuB;IAC/D,MAAM,IAAI,GAAG,MAAM,CAAC,OAAO,CAAC,eAAe,CAAC,MAAM,C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sB3B,eAAe;;GAElB,CAAA;AACH,CAAC","sourcesContent":["/**\n * miniappGlobals — shared builder for the window.Glassly globals injected\n * into every miniapp WebView.\n *\n * Miniapps run on-device, and LocalMiniappView is the single injection path;\n * this util is the one place that builds the globals so every WebView gets the\n * same API surface.\n */\n\nimport {Dimensions, Platform} from \"react-native\"\n\nexport interface MiniappSafeArea {\n top: number\n bottom: number\n left: number\n right: number\n}\n\nexport interface CapsuleMenuRect {\n top: number\n right: number\n bottom: number\n left: number\n width: number\n height: number\n}\n\n/**\n * The capsule menu bounding rect in the WebView's own coordinate space.\n *\n * Keep in sync with CapsuleMenu.tsx:\n * - CapsuleButton height ≈ h-7.5 (30px), width ≈ 73px\n * - Positioned at right-2 (8px), top = theme.spacing.s2 (8px) below insets.top\n */\nconst CAPSULE_MENU_HEIGHT = 30\nconst CAPSULE_MENU_WIDTH = 73\nconst CAPSULE_MENU_PADDING = 8\n\n/**\n * @param topInsetOffset extra top offset to add when the WebView container does\n * NOT already pad by the safe-area inset (i.e. WebView fills edge-to-edge under\n * the status bar). Pass `insets.top` in that case, or 0 when the container\n * already applies top padding.\n */\nexport function getCapsuleMenuRect(topInsetOffset = 0): CapsuleMenuRect {\n const screenWidth = Dimensions.get(\"window\").width\n const top = topInsetOffset + CAPSULE_MENU_PADDING\n return {\n top,\n right: CAPSULE_MENU_PADDING,\n bottom: top + CAPSULE_MENU_HEIGHT,\n left: screenWidth - CAPSULE_MENU_PADDING - CAPSULE_MENU_WIDTH,\n width: CAPSULE_MENU_WIDTH,\n height: CAPSULE_MENU_HEIGHT,\n }\n}\n\nexport type MiniappColorScheme = \"light\" | \"dark\"\n\nexport interface BuildMiniappGlobalsOptions {\n packageName?: string\n capabilities?: string[]\n miniappLocal?: boolean\n miniappDeveloperMode?: boolean\n safeAreaInsets: MiniappSafeArea\n /**\n * True when the WebView container renders edge-to-edge (no top padding for\n * the status bar). In that case the capsule menu rect needs to shift down by\n * the top inset so its coords match where it's actually drawn on screen.\n */\n webviewFillsStatusBar?: boolean\n /** Current host color scheme. Miniapps may follow this to match the phone. */\n colorScheme?: MiniappColorScheme\n}\n\nfunction safeAreaCssVars(insets: MiniappSafeArea): Record<string, string> {\n return {\n \"--glassly-safe-top\": `${insets.top}px`,\n \"--glassly-safe-bottom\": `${insets.bottom}px`,\n \"--glassly-safe-left\": `${insets.left}px`,\n \"--glassly-safe-right\": `${insets.right}px`,\n }\n}\n\n/**\n * JS to inject into a running miniapp when the host's safe area changes (an\n * iPhone Duo folding moves its status rail): updates window.Glassly and the\n * CSS variables, then fires `glassly:safe-area-change`.\n */\nexport function buildSafeAreaUpdateScript(insets: MiniappSafeArea): string {\n const sets = Object.entries(safeAreaCssVars(insets))\n .map(([k, v]) => `document.documentElement.style.setProperty(${JSON.stringify(k)}, ${JSON.stringify(v)});`)\n .join(\"\\n \")\n return `\n window.Glassly = window.Glassly || {};\n window.Glassly.safeAreaInsets = ${JSON.stringify(insets)};\n try {\n ${sets}\n } catch (e) { /* ignore */ }\n window.dispatchEvent(new Event(\"glassly:safe-area-change\"));\n true;\n `\n}\n\n/**\n * Returns the JS string to inject into a miniapp WebView before its content\n * loads. Sets window.Glassly with the standard fields miniapps read:\n *\n * window.Glassly = {\n * platform, packageName?, capabilities, safeAreaInsets, capsuleMenu,\n * miniappLocal?, miniappDeveloperMode?\n * }\n *\n * Also defines a stub window.receiveNativeMessage so the miniapp can safely\n * assign to it before the native bridge wires in.\n */\nexport function buildMiniappGlobalsScript(opts: BuildMiniappGlobalsOptions): string {\n const capsuleTopOffset = opts.webviewFillsStatusBar ? opts.safeAreaInsets.top : 0\n const globals: Record<string, unknown> = {\n platform: Platform.OS,\n capabilities: opts.capabilities ?? [\"share\", \"open_url\", \"copy_clipboard\", \"download\"],\n safeAreaInsets: opts.safeAreaInsets,\n capsuleMenu: getCapsuleMenuRect(capsuleTopOffset),\n }\n if (opts.packageName) globals.packageName = opts.packageName\n if (opts.miniappLocal) globals.miniappLocal = true\n if (opts.miniappDeveloperMode) globals.miniappDeveloperMode = true\n if (opts.colorScheme) globals.colorScheme = opts.colorScheme\n\n // CSS custom properties that mirror the capsule menu / safe-area data.\n // Miniapp CSS (or Tailwind arbitrary values) can read these without\n // touching JS: e.g. `style=\"margin-top: var(--glassly-capsule-top)\"`.\n const capsule = globals.capsuleMenu as CapsuleMenuRect\n const insets = opts.safeAreaInsets\n const capsuleCenter = capsule.top + capsule.height / 2\n const cssVars: Record<string, string> = {\n ...safeAreaCssVars(insets),\n \"--glassly-capsule-top\": `${capsule.top}px`,\n \"--glassly-capsule-bottom\": `${capsule.bottom}px`,\n \"--glassly-capsule-left\": `${capsule.left}px`,\n \"--glassly-capsule-right\": `${capsule.right}px`,\n \"--glassly-capsule-width\": `${capsule.width}px`,\n \"--glassly-capsule-height\": `${capsule.height}px`,\n \"--glassly-capsule-center-y\": `${capsuleCenter}px`,\n // Right-side gutter to reserve so content doesn't slide under the\n // capsule: capsule width + 16px breathing room.\n \"--glassly-capsule-gutter\": `${capsule.width + 16}px`,\n }\n const cssVarsBlock = Object.entries(cssVars)\n .map(([k, v]) => `${k}: ${v};`)\n .join(\" \")\n\n // Console-tap shim: wrap console.log/warn/error/info/debug so each call\n // also forwards a `dev_log` envelope back to the phone via\n // ReactNativeWebView.postMessage. Dev mode forwards to the laptop's\n // `glassly dev` terminal; non-dev mode falls back to the React\n // Native log stream (Metro / Xcode console / adb logcat) so installed-\n // miniapp errors are still inspectable when there's no laptop sidecar.\n //\n // Also tap window.onerror and window.onunhandledrejection so synchronous\n // throws and unhandled promise rejections surface even when the bundle\n // never gets a chance to call console.error itself.\n const consoleTapBlock = `\n (function() {\n try {\n var levels = [\"log\", \"warn\", \"error\", \"info\", \"debug\"];\n var seen = new WeakSet();\n function safeSerialize(arg) {\n if (arg instanceof Error) return {__error: true, message: arg.message, stack: arg.stack};\n if (arg === null || typeof arg !== \"object\") return arg;\n try {\n return JSON.parse(JSON.stringify(arg, function(k, v) {\n if (v !== null && typeof v === \"object\") {\n if (seen.has(v)) return \"[Circular]\";\n seen.add(v);\n }\n return v;\n }));\n } catch (e) {\n try { return String(arg); } catch (_) { return \"[unserializable]\"; }\n }\n }\n levels.forEach(function(level) {\n var original = console[level];\n if (typeof original !== \"function\") return;\n console[level] = function() {\n try { original.apply(console, arguments); } catch (_) {}\n try {\n var args = Array.prototype.slice.call(arguments).map(safeSerialize);\n if (window.ReactNativeWebView && typeof window.ReactNativeWebView.postMessage === \"function\") {\n window.ReactNativeWebView.postMessage(JSON.stringify({\n payload: {\n type: \"dev_log\",\n level: level,\n args: args,\n packageName: (window.Glassly && window.Glassly.packageName) || null,\n timestamp: Date.now()\n }\n }));\n }\n } catch (_) { /* swallow */ }\n };\n });\n } catch (_) { /* ignore */ }\n\n // Surface synchronous errors and unhandled promise rejections via the\n // same dev_log channel — many bundle-startup crashes never get to call\n // console.error themselves.\n try {\n window.addEventListener(\"error\", function(e) {\n try {\n if (window.ReactNativeWebView && typeof window.ReactNativeWebView.postMessage === \"function\") {\n window.ReactNativeWebView.postMessage(JSON.stringify({\n payload: {\n type: \"dev_log\",\n level: \"error\",\n args: [\"[window.error] \" + (e.message || \"unknown\"), {filename: e.filename, lineno: e.lineno, colno: e.colno, stack: e.error && e.error.stack}],\n packageName: (window.Glassly && window.Glassly.packageName) || null,\n timestamp: Date.now()\n }\n }));\n }\n } catch (_) {}\n });\n window.addEventListener(\"unhandledrejection\", function(e) {\n try {\n if (window.ReactNativeWebView && typeof window.ReactNativeWebView.postMessage === \"function\") {\n var reason = e.reason;\n var serialized = reason instanceof Error\n ? {__error: true, message: reason.message, stack: reason.stack}\n : (typeof reason === \"object\" ? JSON.stringify(reason) : String(reason));\n window.ReactNativeWebView.postMessage(JSON.stringify({\n payload: {\n type: \"dev_log\",\n level: \"error\",\n args: [\"[unhandledrejection]\", serialized],\n packageName: (window.Glassly && window.Glassly.packageName) || null,\n timestamp: Date.now()\n }\n }));\n }\n } catch (_) {}\n });\n } catch (_) {}\n })();\n `\n\n // Lock zoom so miniapps feel like apps, not pages: force a non-scalable\n // viewport meta (overriding whatever the miniapp shipped) and disable\n // double-tap-zoom via CSS. Re-applies on DOMContentLoaded in case the\n // miniapp re-writes <head> during boot.\n return `\n window.Glassly = ${JSON.stringify(globals)};\n window.receiveNativeMessage = window.receiveNativeMessage || function() {};\n (function() {\n try {\n var styleEl = document.createElement(\"style\");\n styleEl.setAttribute(\"data-glassly-injected\", \"1\");\n styleEl.textContent =\n \":root { ${cssVarsBlock} }\" +\n \"html, body { touch-action: manipulation; -ms-content-zooming: none; }\";\n (document.head || document.documentElement).appendChild(styleEl);\n } catch (e) { /* ignore */ }\n\n function lockViewport() {\n try {\n var content = \"width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no, viewport-fit=cover\";\n var existing = document.querySelector('meta[name=\"viewport\"]');\n if (existing) {\n existing.setAttribute(\"content\", content);\n } else {\n var meta = document.createElement(\"meta\");\n meta.setAttribute(\"name\", \"viewport\");\n meta.setAttribute(\"content\", content);\n (document.head || document.documentElement).appendChild(meta);\n }\n } catch (e) { /* ignore */ }\n }\n lockViewport();\n document.addEventListener(\"DOMContentLoaded\", lockViewport);\n })();\n ${consoleTapBlock}\n true;\n `\n}\n"]}
|
|
1
|
+
{"version":3,"file":"miniappGlobals.js","sourceRoot":"","sources":["../../src/utils/miniappGlobals.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAC,QAAQ,EAAC,MAAM,cAAc,CAAA;AAsCrC,4EAA4E;AAC5E,4EAA4E;AAC5E,6DAA6D;AAC7D,SAAS,aAAa,CAAC,MAAuB,EAAE,OAAwB;IACtE,OAAO;QACL,oBAAoB,EAAE,GAAG,MAAM,CAAC,GAAG,IAAI;QACvC,uBAAuB,EAAE,GAAG,MAAM,CAAC,MAAM,IAAI;QAC7C,qBAAqB,EAAE,GAAG,MAAM,CAAC,IAAI,IAAI;QACzC,sBAAsB,EAAE,GAAG,MAAM,CAAC,KAAK,IAAI;QAC3C,uBAAuB,EAA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;AACH,CAAC","sourcesContent":["/**\n * miniappGlobals — shared builder for the window.Glassly globals injected\n * into every miniapp WebView.\n *\n * Miniapps run on-device, and LocalMiniappView is the single injection path;\n * this util is the one place that builds the globals so every WebView gets the\n * same API surface.\n */\n\nimport {Platform} from \"react-native\"\n\nexport interface MiniappSafeArea {\n top: number\n bottom: number\n left: number\n right: number\n}\n\n/**\n * The host's capsule menu in the WebView's own coordinate space. `corner`\n * floats over the page's top-right; `rail` sits in the iPhone Duo's status\n * rail, inside the side safe-area inset and clear of the page content.\n */\nexport interface CapsuleMenuRect {\n top: number\n right: number\n bottom: number\n left: number\n width: number\n height: number\n placement: \"corner\" | \"rail\"\n}\n\nexport type MiniappColorScheme = \"light\" | \"dark\"\n\nexport interface BuildMiniappGlobalsOptions {\n packageName?: string\n capabilities?: string[]\n miniappLocal?: boolean\n miniappDeveloperMode?: boolean\n safeAreaInsets: MiniappSafeArea\n /** Where the host draws its capsule menu over this WebView. */\n capsuleMenu: CapsuleMenuRect\n /** Current host color scheme. Miniapps may follow this to match the phone. */\n colorScheme?: MiniappColorScheme\n}\n\n// CSS custom properties that mirror the safe-area and capsule menu data, so\n// miniapp CSS (or Tailwind arbitrary values) can read them without touching\n// JS: e.g. `style=\"margin-top: var(--glassly-capsule-top)\"`.\nfunction layoutCssVars(insets: MiniappSafeArea, capsule: CapsuleMenuRect): Record<string, string> {\n return {\n \"--glassly-safe-top\": `${insets.top}px`,\n \"--glassly-safe-bottom\": `${insets.bottom}px`,\n \"--glassly-safe-left\": `${insets.left}px`,\n \"--glassly-safe-right\": `${insets.right}px`,\n \"--glassly-capsule-top\": `${capsule.top}px`,\n \"--glassly-capsule-bottom\": `${capsule.bottom}px`,\n \"--glassly-capsule-left\": `${capsule.left}px`,\n \"--glassly-capsule-right\": `${capsule.right}px`,\n \"--glassly-capsule-width\": `${capsule.width}px`,\n \"--glassly-capsule-height\": `${capsule.height}px`,\n \"--glassly-capsule-center-y\": `${capsule.top + capsule.height / 2}px`,\n // Right-side gutter to reserve so content doesn't slide under the\n // capsule: its width + 16px breathing room, none when it sits in the rail.\n \"--glassly-capsule-gutter\": `${capsule.placement === \"rail\" ? 0 : capsule.width + 16}px`,\n }\n}\n\n/**\n * JS to inject into a running miniapp when the host's safe area or capsule\n * menu moves (an iPhone Duo folding, or its rail's reserved regions growing):\n * updates window.Glassly and the CSS variables, then fires\n * `glassly:safe-area-change`.\n */\nexport function buildSafeAreaUpdateScript(insets: MiniappSafeArea, capsuleMenu: CapsuleMenuRect): string {\n const sets = Object.entries(layoutCssVars(insets, capsuleMenu))\n .map(([k, v]) => `document.documentElement.style.setProperty(${JSON.stringify(k)}, ${JSON.stringify(v)});`)\n .join(\"\\n \")\n return `\n window.Glassly = window.Glassly || {};\n window.Glassly.safeAreaInsets = ${JSON.stringify(insets)};\n window.Glassly.capsuleMenu = ${JSON.stringify(capsuleMenu)};\n try {\n ${sets}\n } catch (e) { /* ignore */ }\n window.dispatchEvent(new Event(\"glassly:safe-area-change\"));\n true;\n `\n}\n\n/**\n * Returns the JS string to inject into a miniapp WebView before its content\n * loads. Sets window.Glassly with the standard fields miniapps read:\n *\n * window.Glassly = {\n * platform, packageName?, capabilities, safeAreaInsets, capsuleMenu,\n * miniappLocal?, miniappDeveloperMode?\n * }\n *\n * Also defines a stub window.receiveNativeMessage so the miniapp can safely\n * assign to it before the native bridge wires in.\n */\nexport function buildMiniappGlobalsScript(opts: BuildMiniappGlobalsOptions): string {\n const globals: Record<string, unknown> = {\n platform: Platform.OS,\n capabilities: opts.capabilities ?? [\"share\", \"open_url\", \"copy_clipboard\", \"download\"],\n safeAreaInsets: opts.safeAreaInsets,\n capsuleMenu: opts.capsuleMenu,\n }\n if (opts.packageName) globals.packageName = opts.packageName\n if (opts.miniappLocal) globals.miniappLocal = true\n if (opts.miniappDeveloperMode) globals.miniappDeveloperMode = true\n if (opts.colorScheme) globals.colorScheme = opts.colorScheme\n\n const cssVars = layoutCssVars(opts.safeAreaInsets, opts.capsuleMenu)\n const cssVarsBlock = Object.entries(cssVars)\n .map(([k, v]) => `${k}: ${v};`)\n .join(\" \")\n\n // Console-tap shim: wrap console.log/warn/error/info/debug so each call\n // also forwards a `dev_log` envelope back to the phone via\n // ReactNativeWebView.postMessage. Dev mode forwards to the laptop's\n // `glassly dev` terminal; non-dev mode falls back to the React\n // Native log stream (Metro / Xcode console / adb logcat) so installed-\n // miniapp errors are still inspectable when there's no laptop sidecar.\n //\n // Also tap window.onerror and window.onunhandledrejection so synchronous\n // throws and unhandled promise rejections surface even when the bundle\n // never gets a chance to call console.error itself.\n const consoleTapBlock = `\n (function() {\n try {\n var levels = [\"log\", \"warn\", \"error\", \"info\", \"debug\"];\n var seen = new WeakSet();\n function safeSerialize(arg) {\n if (arg instanceof Error) return {__error: true, message: arg.message, stack: arg.stack};\n if (arg === null || typeof arg !== \"object\") return arg;\n try {\n return JSON.parse(JSON.stringify(arg, function(k, v) {\n if (v !== null && typeof v === \"object\") {\n if (seen.has(v)) return \"[Circular]\";\n seen.add(v);\n }\n return v;\n }));\n } catch (e) {\n try { return String(arg); } catch (_) { return \"[unserializable]\"; }\n }\n }\n levels.forEach(function(level) {\n var original = console[level];\n if (typeof original !== \"function\") return;\n console[level] = function() {\n try { original.apply(console, arguments); } catch (_) {}\n try {\n var args = Array.prototype.slice.call(arguments).map(safeSerialize);\n if (window.ReactNativeWebView && typeof window.ReactNativeWebView.postMessage === \"function\") {\n window.ReactNativeWebView.postMessage(JSON.stringify({\n payload: {\n type: \"dev_log\",\n level: level,\n args: args,\n packageName: (window.Glassly && window.Glassly.packageName) || null,\n timestamp: Date.now()\n }\n }));\n }\n } catch (_) { /* swallow */ }\n };\n });\n } catch (_) { /* ignore */ }\n\n // Surface synchronous errors and unhandled promise rejections via the\n // same dev_log channel — many bundle-startup crashes never get to call\n // console.error themselves.\n try {\n window.addEventListener(\"error\", function(e) {\n try {\n if (window.ReactNativeWebView && typeof window.ReactNativeWebView.postMessage === \"function\") {\n window.ReactNativeWebView.postMessage(JSON.stringify({\n payload: {\n type: \"dev_log\",\n level: \"error\",\n args: [\"[window.error] \" + (e.message || \"unknown\"), {filename: e.filename, lineno: e.lineno, colno: e.colno, stack: e.error && e.error.stack}],\n packageName: (window.Glassly && window.Glassly.packageName) || null,\n timestamp: Date.now()\n }\n }));\n }\n } catch (_) {}\n });\n window.addEventListener(\"unhandledrejection\", function(e) {\n try {\n if (window.ReactNativeWebView && typeof window.ReactNativeWebView.postMessage === \"function\") {\n var reason = e.reason;\n var serialized = reason instanceof Error\n ? {__error: true, message: reason.message, stack: reason.stack}\n : (typeof reason === \"object\" ? JSON.stringify(reason) : String(reason));\n window.ReactNativeWebView.postMessage(JSON.stringify({\n payload: {\n type: \"dev_log\",\n level: \"error\",\n args: [\"[unhandledrejection]\", serialized],\n packageName: (window.Glassly && window.Glassly.packageName) || null,\n timestamp: Date.now()\n }\n }));\n }\n } catch (_) {}\n });\n } catch (_) {}\n })();\n `\n\n // Lock zoom so miniapps feel like apps, not pages: force a non-scalable\n // viewport meta (overriding whatever the miniapp shipped) and disable\n // double-tap-zoom via CSS. Re-applies on DOMContentLoaded in case the\n // miniapp re-writes <head> during boot.\n return `\n window.Glassly = ${JSON.stringify(globals)};\n window.receiveNativeMessage = window.receiveNativeMessage || function() {};\n (function() {\n try {\n var styleEl = document.createElement(\"style\");\n styleEl.setAttribute(\"data-glassly-injected\", \"1\");\n styleEl.textContent =\n \":root { ${cssVarsBlock} }\" +\n \"html, body { touch-action: manipulation; -ms-content-zooming: none; }\";\n (document.head || document.documentElement).appendChild(styleEl);\n } catch (e) { /* ignore */ }\n\n function lockViewport() {\n try {\n var content = \"width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no, viewport-fit=cover\";\n var existing = document.querySelector('meta[name=\"viewport\"]');\n if (existing) {\n existing.setAttribute(\"content\", content);\n } else {\n var meta = document.createElement(\"meta\");\n meta.setAttribute(\"name\", \"viewport\");\n meta.setAttribute(\"content\", content);\n (document.head || document.documentElement).appendChild(meta);\n }\n } catch (e) { /* ignore */ }\n }\n lockViewport();\n document.addEventListener(\"DOMContentLoaded\", lockViewport);\n })();\n ${consoleTapBlock}\n true;\n `\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@glassly/engine",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.8-dev.977",
|
|
4
4
|
"description": "Glassly Engine — miniapp registry, WebView bridge, and miniapp store",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"react-native": "src/index.ts",
|
|
@@ -97,17 +97,17 @@
|
|
|
97
97
|
"registry": "https://registry.npmjs.org/"
|
|
98
98
|
},
|
|
99
99
|
"dependencies": {
|
|
100
|
-
"@glassly/bluetooth-sdk": "0.3.
|
|
101
|
-
"@glassly/cloud-client": "0.3.
|
|
102
|
-
"@glassly/cloud-protocol": "0.3.
|
|
103
|
-
"@glassly/crust": "0.3.
|
|
104
|
-
"@glassly/miniapp": "0.3.
|
|
100
|
+
"@glassly/bluetooth-sdk": "0.3.8-dev.977",
|
|
101
|
+
"@glassly/cloud-client": "0.3.8-dev.977",
|
|
102
|
+
"@glassly/cloud-protocol": "0.3.8-dev.977",
|
|
103
|
+
"@glassly/crust": "0.3.8-dev.977",
|
|
104
|
+
"@glassly/miniapp": "0.3.8-dev.977",
|
|
105
105
|
"buffer": "^6.0.3",
|
|
106
106
|
"events": "^3.3.0",
|
|
107
107
|
"react-native-marked": "8.3.2",
|
|
108
108
|
"semver": "^7.7.4",
|
|
109
109
|
"typesafe-ts": "^1.7.1",
|
|
110
|
-
"@glassly/llm-providers": "0.3.
|
|
110
|
+
"@glassly/llm-providers": "0.3.8-dev.977",
|
|
111
111
|
"@huggingface/jinja": "^0.5.9",
|
|
112
112
|
"jsonrepair": "^3.12.0"
|
|
113
113
|
},
|
package/src/engine.ts
CHANGED
|
@@ -25,7 +25,7 @@ import {startPhoneActivityTracking, stopPhoneActivityTracking} from "./services/
|
|
|
25
25
|
import {startPhoneNotificationsSync, stopPhoneNotificationsSync} from "./services/PhoneNotificationsSync"
|
|
26
26
|
import {startSpeakerIdSync, stopSpeakerIdSync} from "./services/SpeakerIdSync"
|
|
27
27
|
import {startNeuralBandSettingsSync, stopNeuralBandSettingsSync} from "./services/neuralBand/NeuralBandSettingsSync"
|
|
28
|
-
import {
|
|
28
|
+
import {startWatchLink, stopWatchLink} from "./services/watch/WatchLink"
|
|
29
29
|
import {startCaptionsTesterReportService, stopCaptionsTesterReportService} from "./services/CaptionsTesterReportService"
|
|
30
30
|
import {startJSCrashloopReportService, stopJSCrashloopReportService} from "./services/JSCrashloopReportService"
|
|
31
31
|
import {ensureMiniappEngine, stopMiniappEngine} from "./services/MiniappEngine"
|
|
@@ -49,6 +49,7 @@ import {permissions} from "./facades/permissions"
|
|
|
49
49
|
import {notifications} from "./facades/notifications"
|
|
50
50
|
import {maps} from "./facades/maps"
|
|
51
51
|
import {memory} from "./facades/memory"
|
|
52
|
+
import {backup} from "./facades/backup"
|
|
52
53
|
import {speakers} from "./facades/speakers"
|
|
53
54
|
import {providerKeys} from "./facades/providerKeys"
|
|
54
55
|
import {logBuffer} from "./utils/devLogging"
|
|
@@ -146,8 +147,8 @@ export const engine = {
|
|
|
146
147
|
startSpeakerIdSync()
|
|
147
148
|
// Meta Neural Band: push the air mouse and wearing-hand settings to the band on connect.
|
|
148
149
|
startNeuralBandSettingsSync()
|
|
149
|
-
// Apple Watch
|
|
150
|
-
|
|
150
|
+
// Watch remote (Apple Watch on iOS, Wear OS on Android): status and mirror frames out, wrist commands in.
|
|
151
|
+
startWatchLink()
|
|
151
152
|
// Android internal/e2e: laptop captions tester can broadcast a failure intent;
|
|
152
153
|
// engine owns turning that into a Cloud report.
|
|
153
154
|
startCaptionsTesterReportService()
|
|
@@ -192,7 +193,7 @@ export const engine = {
|
|
|
192
193
|
await safely("phone activity tracking", stopPhoneActivityTracking)
|
|
193
194
|
await safely("speaker id sync", stopSpeakerIdSync)
|
|
194
195
|
await safely("neural band settings sync", stopNeuralBandSettingsSync)
|
|
195
|
-
await safely("
|
|
196
|
+
await safely("watch link", stopWatchLink)
|
|
196
197
|
await safely("captions tester report service", stopCaptionsTesterReportService)
|
|
197
198
|
await safely("js crashloop report service", stopJSCrashloopReportService)
|
|
198
199
|
await safely("miniapp engine", stopMiniappEngine)
|
|
@@ -232,6 +233,8 @@ export const engine = {
|
|
|
232
233
|
maps,
|
|
233
234
|
/** Shared user-scoped memory timeline (Settings > Memory + session.memory). */
|
|
234
235
|
memory,
|
|
236
|
+
/** Whole-app backup file: settings, miniapp storage, installed list, memory (Settings > Profile). */
|
|
237
|
+
backup,
|
|
235
238
|
/** Device-local voice profiles for on-device speaker ID (Settings > Speakers). */
|
|
236
239
|
speakers,
|
|
237
240
|
/** AI/voice provider key validation — user-supplied keys (Settings > API Keys). */
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* backup facade — `engine.backup`: the whole-app backup behind Settings >
|
|
3
|
+
* Profile > Backup. One JSON file carries system settings, every miniapp's
|
|
4
|
+
* storage (so their sign-ins survive a logout or reinstall), the installed
|
|
5
|
+
* miniapp list, and the memory timeline.
|
|
6
|
+
*/
|
|
7
|
+
import {AppStateBackupError} from "../services/AppStateBackup"
|
|
8
|
+
import {
|
|
9
|
+
exportAppStateFile,
|
|
10
|
+
importAppStateFile,
|
|
11
|
+
type AppStateExportResult,
|
|
12
|
+
type AppStateRestoreOptions,
|
|
13
|
+
type AppStateRestoreResult,
|
|
14
|
+
} from "../services/appStateBackupFile"
|
|
15
|
+
import {MemoryBackupError} from "../services/MemoryStore"
|
|
16
|
+
|
|
17
|
+
export const backup = {
|
|
18
|
+
/** Share the app state as a JSON backup file. */
|
|
19
|
+
exportFile: (): Promise<AppStateExportResult> => exportAppStateFile(),
|
|
20
|
+
/**
|
|
21
|
+
* Pick a backup file and restore it: backup values overwrite per key, and
|
|
22
|
+
* running miniapps whose storage changed restart after `opts.reinstall` has
|
|
23
|
+
* installed the ones this phone lacks. Resolves null on cancel.
|
|
24
|
+
*/
|
|
25
|
+
importFile: (opts?: AppStateRestoreOptions): Promise<AppStateRestoreResult | null> => importAppStateFile(opts),
|
|
26
|
+
/** True for a file that isn't a backup this build can read. */
|
|
27
|
+
isBackupError: (err: unknown): boolean => err instanceof AppStateBackupError || err instanceof MemoryBackupError,
|
|
28
|
+
}
|
package/src/facades/glasses.ts
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
// standalone build); jest moduleNameMapper + tsconfig both resolve it.
|
|
13
13
|
import BluetoothSdk from "@glassly/bluetooth-sdk/internal"
|
|
14
14
|
import type {
|
|
15
|
-
|
|
15
|
+
WatchAvailability,
|
|
16
16
|
ButtonPressEvent,
|
|
17
17
|
ConnectOptions,
|
|
18
18
|
ControllerStatus,
|
|
@@ -346,10 +346,10 @@ export const glasses = {
|
|
|
346
346
|
setHand: (id: string, hand: "left" | "right"): Promise<void> => BluetoothSdk.neuralBandSetHand(id, hand),
|
|
347
347
|
},
|
|
348
348
|
|
|
349
|
-
// --- Apple Watch (iOS)
|
|
350
|
-
|
|
351
|
-
/** Whether this
|
|
352
|
-
availability: (): Promise<
|
|
349
|
+
// --- watch: an Apple Watch over WatchConnectivity (iOS), a Wear OS watch over the Data Layer (Android) ---
|
|
350
|
+
watch: {
|
|
351
|
+
/** Whether this phone has a paired watch and the Glassly watch app is on it. */
|
|
352
|
+
availability: (): Promise<WatchAvailability> => BluetoothSdk.watchAvailability(),
|
|
353
353
|
},
|
|
354
354
|
|
|
355
355
|
// --- audio (glasses media-volume, own-app playback hint, live mic level) ---
|
|
@@ -11,10 +11,10 @@ export interface EngineReleaseMetadata {
|
|
|
11
11
|
|
|
12
12
|
export const ENGINE_RELEASE_METADATA: Readonly<EngineReleaseMetadata> = Object.freeze({
|
|
13
13
|
"schemaVersion": 1,
|
|
14
|
-
"familyBaseVersion": "0.3.
|
|
15
|
-
"releaseIdentity": "0.3.
|
|
16
|
-
"releaseSetId": "glassly-0.3.
|
|
17
|
-
"sourceCommit": "
|
|
14
|
+
"familyBaseVersion": "0.3.8",
|
|
15
|
+
"releaseIdentity": "0.3.8-dev.977",
|
|
16
|
+
"releaseSetId": "glassly-0.3.8-dev.977",
|
|
17
|
+
"sourceCommit": "cd05a91cc0c7f4f569e59e5b79b0cdfcbc0277db",
|
|
18
18
|
"otaManifestUrl": null,
|
|
19
19
|
"otaManifestSha256": null
|
|
20
20
|
})
|
package/src/index.ts
CHANGED
|
@@ -69,6 +69,7 @@ export {DEFAULT_LOCAL_LLM_MODEL, isLocalLlmModelId} from "./services/LocalLlmMod
|
|
|
69
69
|
// session shapes are canonical in @glassly/miniapp (the session.memory
|
|
70
70
|
// surface); the stats read model is engine-side.
|
|
71
71
|
export type {MemoryStats} from "./services/MemoryStore"
|
|
72
|
+
export type {AppStateExportResult, AppStateRestoreOptions, AppStateRestoreResult} from "./services/appStateBackupFile"
|
|
72
73
|
export type {SpeakerProfile} from "./services/SpeakerProfileStore"
|
|
73
74
|
export type {EnrollOutcome} from "./facades/speakers"
|
|
74
75
|
export {MENTRA_LIVE_SETTING_KEYS, getBluetoothSettingKeysForDevice} from "./stores/bluetoothSettingKeys"
|