@glassly/engine 0.3.5-beta.734 → 0.3.5-beta.767

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.
Files changed (102) hide show
  1. package/build/engine.d.ts +3 -0
  2. package/build/engine.d.ts.map +1 -1
  3. package/build/engine.js +4 -0
  4. package/build/engine.js.map +1 -1
  5. package/build/facades/glasses.d.ts +5 -1
  6. package/build/facades/glasses.d.ts.map +1 -1
  7. package/build/facades/glasses.js +5 -0
  8. package/build/facades/glasses.js.map +1 -1
  9. package/build/generated/releaseMetadata.js +3 -3
  10. package/build/generated/releaseMetadata.js.map +1 -1
  11. package/build/services/BlobStore.js +3 -3
  12. package/build/services/BlobStore.js.map +1 -1
  13. package/build/services/ForegroundLocationPermission.d.ts +1 -1
  14. package/build/services/ForegroundLocationPermission.d.ts.map +1 -1
  15. package/build/services/ForegroundLocationPermission.js.map +1 -1
  16. package/build/services/GestureDotsService.d.ts.map +1 -1
  17. package/build/services/GestureDotsService.js +2 -1
  18. package/build/services/GestureDotsService.js.map +1 -1
  19. package/build/services/GlassesTouchInput.d.ts +2 -1
  20. package/build/services/GlassesTouchInput.d.ts.map +1 -1
  21. package/build/services/GlassesTouchInput.js +64 -26
  22. package/build/services/GlassesTouchInput.js.map +1 -1
  23. package/build/services/LocalLlmModelManager.d.ts +3 -1
  24. package/build/services/LocalLlmModelManager.d.ts.map +1 -1
  25. package/build/services/LocalLlmModelManager.js +13 -5
  26. package/build/services/LocalLlmModelManager.js.map +1 -1
  27. package/build/services/LocalLlmPrompt.d.ts +10 -9
  28. package/build/services/LocalLlmPrompt.d.ts.map +1 -1
  29. package/build/services/LocalLlmPrompt.js +43 -32
  30. package/build/services/LocalLlmPrompt.js.map +1 -1
  31. package/build/services/LocalLlmProvider.d.ts.map +1 -1
  32. package/build/services/LocalLlmProvider.js +39 -20
  33. package/build/services/LocalLlmProvider.js.map +1 -1
  34. package/build/services/LocalMiniappRuntime.d.ts +19 -4
  35. package/build/services/LocalMiniappRuntime.d.ts.map +1 -1
  36. package/build/services/LocalMiniappRuntime.js +70 -127
  37. package/build/services/LocalMiniappRuntime.js.map +1 -1
  38. package/build/services/SceneRenderer.d.ts.map +1 -1
  39. package/build/services/SceneRenderer.js +3 -1
  40. package/build/services/SceneRenderer.js.map +1 -1
  41. package/build/services/actionInvoke.d.ts +37 -0
  42. package/build/services/actionInvoke.d.ts.map +1 -0
  43. package/build/services/actionInvoke.js +89 -0
  44. package/build/services/actionInvoke.js.map +1 -0
  45. package/build/services/appleWatch/AppleWatchLink.d.ts +42 -0
  46. package/build/services/appleWatch/AppleWatchLink.d.ts.map +1 -0
  47. package/build/services/appleWatch/AppleWatchLink.js +259 -0
  48. package/build/services/appleWatch/AppleWatchLink.js.map +1 -0
  49. package/build/services/controllers.d.ts.map +1 -1
  50. package/build/services/controllers.js +16 -0
  51. package/build/services/controllers.js.map +1 -1
  52. package/build/services/settingsBridge.d.ts +4 -4
  53. package/build/services/settingsBridge.d.ts.map +1 -1
  54. package/build/services/settingsBridge.js +9 -4
  55. package/build/services/settingsBridge.js.map +1 -1
  56. package/build/stores/bluetoothSettingKeys.d.ts +2 -0
  57. package/build/stores/bluetoothSettingKeys.d.ts.map +1 -1
  58. package/build/stores/bluetoothSettingKeys.js +17 -0
  59. package/build/stores/bluetoothSettingKeys.js.map +1 -1
  60. package/build/stores/settings.d.ts.map +1 -1
  61. package/build/stores/settings.js +32 -2
  62. package/build/stores/settings.js.map +1 -1
  63. package/build/types/capabilities/rayneo-io.d.ts.map +1 -1
  64. package/build/types/capabilities/rayneo-io.js +2 -0
  65. package/build/types/capabilities/rayneo-io.js.map +1 -1
  66. package/build/types/enums.d.ts +2 -1
  67. package/build/types/enums.d.ts.map +1 -1
  68. package/build/types/enums.js +1 -0
  69. package/build/types/enums.js.map +1 -1
  70. package/build/utils/display/scene/index.d.ts +1 -1
  71. package/build/utils/display/scene/index.d.ts.map +1 -1
  72. package/build/utils/display/scene/index.js.map +1 -1
  73. package/build/utils/display/scene/process.d.ts.map +1 -1
  74. package/build/utils/display/scene/process.js +20 -1
  75. package/build/utils/display/scene/process.js.map +1 -1
  76. package/build/utils/display/scene/types.d.ts +1 -1
  77. package/build/utils/display/scene/types.d.ts.map +1 -1
  78. package/build/utils/display/scene/types.js.map +1 -1
  79. package/package.json +9 -9
  80. package/src/engine.ts +4 -0
  81. package/src/facades/glasses.ts +7 -0
  82. package/src/generated/releaseMetadata.ts +3 -3
  83. package/src/services/BlobStore.ts +3 -3
  84. package/src/services/ForegroundLocationPermission.ts +1 -1
  85. package/src/services/GestureDotsService.ts +2 -1
  86. package/src/services/GlassesTouchInput.ts +69 -23
  87. package/src/services/LocalLlmModelManager.ts +16 -6
  88. package/src/services/LocalLlmPrompt.ts +56 -37
  89. package/src/services/LocalLlmProvider.ts +49 -22
  90. package/src/services/LocalMiniappRuntime.ts +105 -127
  91. package/src/services/SceneRenderer.ts +3 -1
  92. package/src/services/actionInvoke.ts +105 -0
  93. package/src/services/appleWatch/AppleWatchLink.ts +297 -0
  94. package/src/services/controllers.ts +17 -0
  95. package/src/services/settingsBridge.ts +9 -4
  96. package/src/stores/bluetoothSettingKeys.ts +20 -0
  97. package/src/stores/settings.ts +34 -2
  98. package/src/types/capabilities/rayneo-io.ts +2 -0
  99. package/src/types/enums.ts +1 -0
  100. package/src/utils/display/scene/index.ts +1 -0
  101. package/src/utils/display/scene/process.ts +17 -1
  102. package/src/utils/display/scene/types.ts +1 -0
@@ -1 +1 @@
1
- {"version":3,"file":"process.d.ts","sourceRoot":"","sources":["../../../../src/utils/display/scene/process.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAKH,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,mBAAmB,CAAA;AACrD,OAAO,KAAK,EAAC,eAAe,EAAC,MAAM,UAAU,CAAA;AAC7C,OAAO,KAAK,EAGV,wBAAwB,EACxB,iBAAiB,EAIlB,MAAM,SAAS,CAAA;AAGhB,MAAM,WAAW,cAAc;IAC7B,QAAQ,EAAE,eAAe,EAAE,CAAA;IAC3B,QAAQ,EAAE,OAAO,CAAA;IACjB,OAAO,EAAE,MAAM,EAAE,CAAA;CAClB;AAsDD;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAEjG;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAC1B,KAAK,EAAE,SAAS,iBAAiB,EAAE,EACnC,IAAI,EAAE,wBAAwB,EAC9B,OAAO,EAAE,cAAc,GACtB,cAAc,CAgThB"}
1
+ {"version":3,"file":"process.d.ts","sourceRoot":"","sources":["../../../../src/utils/display/scene/process.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAKH,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,mBAAmB,CAAA;AACrD,OAAO,KAAK,EAAC,eAAe,EAAC,MAAM,UAAU,CAAA;AAC7C,OAAO,KAAK,EAGV,wBAAwB,EACxB,iBAAiB,EAKlB,MAAM,SAAS,CAAA;AAGhB,MAAM,WAAW,cAAc;IAC7B,QAAQ,EAAE,eAAe,EAAE,CAAA;IAC3B,QAAQ,EAAE,OAAO,CAAA;IACjB,OAAO,EAAE,MAAM,EAAE,CAAA;CAClB;AAmED;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAEjG;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAC1B,KAAK,EAAE,SAAS,iBAAiB,EAAE,EACnC,IAAI,EAAE,wBAAwB,EAC9B,OAAO,EAAE,cAAc,GACtB,cAAc,CAkThB"}
@@ -45,13 +45,29 @@ function pointsBox(points) {
45
45
  const y = Math.min(...ys);
46
46
  return { x, y, w: Math.max(...xs) - x + 1, h: Math.max(...ys) - y + 1 };
47
47
  }
48
+ function validEdge(e) {
49
+ if (!e || typeof e !== "object")
50
+ return undefined;
51
+ const dx = Math.round(Number(e.dx ?? 0));
52
+ const dy = Math.round(Number(e.dy ?? 0));
53
+ if (!isFinite(dx) || !isFinite(dy) || Math.abs(dx) > 1024 || Math.abs(dy) > 1024)
54
+ return undefined;
55
+ return { dx, dy };
56
+ }
48
57
  function validTransition(t) {
49
58
  if (!t || typeof t !== "object")
50
59
  return undefined;
51
60
  const { durationMs, easing } = t;
52
61
  if (!isFinite(durationMs) || durationMs <= 0)
53
62
  return undefined;
54
- return easing ? { durationMs, easing } : { durationMs };
63
+ const out = easing ? { durationMs, easing } : { durationMs };
64
+ const enter = validEdge(t.enter);
65
+ const exit = validEdge(t.exit);
66
+ if (enter)
67
+ out.enter = enter;
68
+ if (exit)
69
+ out.exit = exit;
70
+ return out;
55
71
  }
56
72
  function boxShrunk(orig, clamped) {
57
73
  return (clamped.x !== Math.floor(orig.x) ||
@@ -143,6 +159,9 @@ export function processScene(input, caps, profile) {
143
159
  let pathEdges = 0;
144
160
  for (const { el, index, box, points } of valid) {
145
161
  const transition = validTransition(el.transition);
162
+ // Leaving elements only exist to tween away; a device that jumps never shows them.
163
+ if (transition?.exit && !caps.animation)
164
+ continue;
146
165
  const transform = {};
147
166
  if (el.rotation !== undefined || el.pivot !== undefined) {
148
167
  const angle = el.rotation ?? 0;
@@ -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;AAYlD,OAAO,EAAC,eAAe,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,kBAAkB,EAAC,MAAM,SAAS,CAAA;AAQjG,8DAA8D;AAC9D,SAAS,QAAQ,CAAC,EAAqB,EAAE,KAAa;IACpD,OAAO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AC","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} 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 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 return easing ? {durationMs, easing} : {durationMs}\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 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,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,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;IAC9E,MAAM,EAAE,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,GAAG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AAC,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,3 +1,3 @@
1
- export type { FrameElement, SceneAnchor, SceneBox, SceneBoxInput, SceneBreakMode, SceneChange, SceneDisplayCapabilities, SceneElementInput, SceneElementType, SceneFrame, SceneImageStyle, ScenePoint, SceneProcessResult, SceneRectStyle, SceneShapeStyle, SceneStrokeStyle, SceneTextStyle, SceneTransition, } from "@glassly/miniapp/display";
1
+ export type { FrameElement, SceneAnchor, SceneBox, SceneBoxInput, SceneBreakMode, SceneChange, SceneDisplayCapabilities, SceneElementInput, SceneElementType, SceneFrame, SceneImageStyle, ScenePoint, SceneProcessResult, SceneRectStyle, SceneShapeStyle, SceneStrokeStyle, SceneTextStyle, SceneTransition, SceneTransitionEdge, } from "@glassly/miniapp/display";
2
2
  export { boxesEqual, contentHash, elementContentHash, MAX_SCENE_DEPTH, POINT_SHAPE_ARITY, POINT_SHAPE_TYPES, } from "@glassly/miniapp/display";
3
3
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/utils/display/scene/types.ts"],"names":[],"mappings":"AACA,YAAY,EACV,YAAY,EACZ,WAAW,EACX,QAAQ,EACR,aAAa,EACb,cAAc,EACd,WAAW,EACX,wBAAwB,EACxB,iBAAiB,EACjB,gBAAgB,EAChB,UAAU,EACV,eAAe,EACf,UAAU,EACV,kBAAkB,EAClB,cAAc,EACd,eAAe,EACf,gBAAgB,EAChB,cAAc,EACd,eAAe,GAChB,MAAM,0BAA0B,CAAA;AACjC,OAAO,EACL,UAAU,EACV,WAAW,EACX,kBAAkB,EAClB,eAAe,EACf,iBAAiB,EACjB,iBAAiB,GAClB,MAAM,0BAA0B,CAAA"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/utils/display/scene/types.ts"],"names":[],"mappings":"AACA,YAAY,EACV,YAAY,EACZ,WAAW,EACX,QAAQ,EACR,aAAa,EACb,cAAc,EACd,WAAW,EACX,wBAAwB,EACxB,iBAAiB,EACjB,gBAAgB,EAChB,UAAU,EACV,eAAe,EACf,UAAU,EACV,kBAAkB,EAClB,cAAc,EACd,eAAe,EACf,gBAAgB,EAChB,cAAc,EACd,eAAe,EACf,mBAAmB,GACpB,MAAM,0BAA0B,CAAA;AACjC,OAAO,EACL,UAAU,EACV,WAAW,EACX,kBAAkB,EAClB,eAAe,EACf,iBAAiB,EACjB,iBAAiB,GAClB,MAAM,0BAA0B,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/utils/display/scene/types.ts"],"names":[],"mappings":"AAqBA,OAAO,EACL,UAAU,EACV,WAAW,EACX,kBAAkB,EAClB,eAAe,EACf,iBAAiB,EACjB,iBAAiB,GAClB,MAAM,0BAA0B,CAAA","sourcesContent":["// Moved into the SDK (@glassly/miniapp/display) so miniapps lay text out the way the host measures it; this path re-exports it for the engine.\nexport type {\n FrameElement,\n SceneAnchor,\n SceneBox,\n SceneBoxInput,\n SceneBreakMode,\n SceneChange,\n SceneDisplayCapabilities,\n SceneElementInput,\n SceneElementType,\n SceneFrame,\n SceneImageStyle,\n ScenePoint,\n SceneProcessResult,\n SceneRectStyle,\n SceneShapeStyle,\n SceneStrokeStyle,\n SceneTextStyle,\n SceneTransition,\n} from \"@glassly/miniapp/display\"\nexport {\n boxesEqual,\n contentHash,\n elementContentHash,\n MAX_SCENE_DEPTH,\n POINT_SHAPE_ARITY,\n POINT_SHAPE_TYPES,\n} from \"@glassly/miniapp/display\"\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/utils/display/scene/types.ts"],"names":[],"mappings":"AAsBA,OAAO,EACL,UAAU,EACV,WAAW,EACX,kBAAkB,EAClB,eAAe,EACf,iBAAiB,EACjB,iBAAiB,GAClB,MAAM,0BAA0B,CAAA","sourcesContent":["// Moved into the SDK (@glassly/miniapp/display) so miniapps lay text out the way the host measures it; this path re-exports it for the engine.\nexport type {\n FrameElement,\n SceneAnchor,\n SceneBox,\n SceneBoxInput,\n SceneBreakMode,\n SceneChange,\n SceneDisplayCapabilities,\n SceneElementInput,\n SceneElementType,\n SceneFrame,\n SceneImageStyle,\n ScenePoint,\n SceneProcessResult,\n SceneRectStyle,\n SceneShapeStyle,\n SceneStrokeStyle,\n SceneTextStyle,\n SceneTransition,\n SceneTransitionEdge,\n} from \"@glassly/miniapp/display\"\nexport {\n boxesEqual,\n contentHash,\n elementContentHash,\n MAX_SCENE_DEPTH,\n POINT_SHAPE_ARITY,\n POINT_SHAPE_TYPES,\n} from \"@glassly/miniapp/display\"\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@glassly/engine",
3
- "version": "0.3.5-beta.734",
3
+ "version": "0.3.5-beta.767",
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.5-beta.734",
101
- "@glassly/cloud-client": "0.3.5-beta.734",
102
- "@glassly/cloud-protocol": "0.3.5-beta.734",
103
- "@glassly/crust": "0.3.5-beta.734",
104
- "@glassly/miniapp": "0.3.5-beta.734",
100
+ "@glassly/bluetooth-sdk": "0.3.5-beta.767",
101
+ "@glassly/cloud-client": "0.3.5-beta.767",
102
+ "@glassly/cloud-protocol": "0.3.5-beta.767",
103
+ "@glassly/crust": "0.3.5-beta.767",
104
+ "@glassly/miniapp": "0.3.5-beta.767",
105
105
  "buffer": "^6.0.3",
106
106
  "events": "^3.3.0",
107
107
  "react-native-marked": "8.1.1",
108
108
  "semver": "^7.7.4",
109
109
  "typesafe-ts": "^1.7.1",
110
- "@glassly/llm-providers": "0.3.5-beta.734",
110
+ "@glassly/llm-providers": "0.3.5-beta.767",
111
111
  "@huggingface/jinja": "^0.5.9",
112
112
  "jsonrepair": "^3.12.0"
113
113
  },
@@ -115,8 +115,8 @@
115
115
  "@glassly/llm-providers": "workspace:*",
116
116
  "@types/semver": "^7.7.1",
117
117
  "expo-module-scripts": "^56.0.3",
118
- "expo-modules-core": "^57.0.7",
119
- "react-native-nitro-modules": "^0.35.10",
118
+ "expo-modules-core": "^58.0.23",
119
+ "react-native-nitro-modules": "^0.37.1",
120
120
  "typescript": "~5.9.2"
121
121
  },
122
122
  "peerDependencies": {
package/src/engine.ts CHANGED
@@ -24,6 +24,7 @@ import {startPhoneActivityTracking, stopPhoneActivityTracking} from "./services/
24
24
  import {startPhoneNotificationsSync, stopPhoneNotificationsSync} from "./services/PhoneNotificationsSync"
25
25
  import {startSpeakerIdSync, stopSpeakerIdSync} from "./services/SpeakerIdSync"
26
26
  import {startNeuralBandSettingsSync, stopNeuralBandSettingsSync} from "./services/neuralBand/NeuralBandSettingsSync"
27
+ import {startAppleWatchLink, stopAppleWatchLink} from "./services/appleWatch/AppleWatchLink"
27
28
  import {startCaptionsTesterReportService, stopCaptionsTesterReportService} from "./services/CaptionsTesterReportService"
28
29
  import {startJSCrashloopReportService, stopJSCrashloopReportService} from "./services/JSCrashloopReportService"
29
30
  import {ensureMiniappEngine, stopMiniappEngine} from "./services/MiniappEngine"
@@ -137,6 +138,8 @@ export const engine = {
137
138
  startSpeakerIdSync()
138
139
  // Meta Neural Band: push the air mouse and wearing-hand settings to the band on connect.
139
140
  startNeuralBandSettingsSync()
141
+ // Apple Watch remote (iOS): status and mirror frames out, wrist commands in.
142
+ startAppleWatchLink()
140
143
  // Android internal/e2e: laptop captions tester can broadcast a failure intent;
141
144
  // engine owns turning that into a Cloud report.
142
145
  startCaptionsTesterReportService()
@@ -181,6 +184,7 @@ export const engine = {
181
184
  await safely("phone activity tracking", stopPhoneActivityTracking)
182
185
  await safely("speaker id sync", stopSpeakerIdSync)
183
186
  await safely("neural band settings sync", stopNeuralBandSettingsSync)
187
+ await safely("apple watch link", stopAppleWatchLink)
184
188
  await safely("captions tester report service", stopCaptionsTesterReportService)
185
189
  await safely("js crashloop report service", stopJSCrashloopReportService)
186
190
  await safely("miniapp engine", stopMiniappEngine)
@@ -12,6 +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
+ AppleWatchAvailability,
15
16
  ButtonPressEvent,
16
17
  ConnectOptions,
17
18
  ControllerStatus,
@@ -329,6 +330,12 @@ export const glasses = {
329
330
  setHand: (id: string, hand: "left" | "right"): Promise<void> => BluetoothSdk.neuralBandSetHand(id, hand),
330
331
  },
331
332
 
333
+ // --- Apple Watch (iOS): pairs through the Glassly watch app over WatchConnectivity ---
334
+ appleWatch: {
335
+ /** Whether this iPhone has a paired watch and the Glassly watch app is on it. */
336
+ availability: (): Promise<AppleWatchAvailability> => BluetoothSdk.appleWatchAvailability(),
337
+ },
338
+
332
339
  // --- audio (glasses media-volume, own-app playback hint, live mic level) ---
333
340
  audio: {
334
341
  /** Read the glasses' current media volume. */
@@ -12,9 +12,9 @@ export interface EngineReleaseMetadata {
12
12
  export const ENGINE_RELEASE_METADATA: Readonly<EngineReleaseMetadata> = Object.freeze({
13
13
  "schemaVersion": 1,
14
14
  "familyBaseVersion": "0.3.5",
15
- "releaseIdentity": "0.3.5-beta.734",
16
- "releaseSetId": "glassly-0.3.5-beta.734",
17
- "sourceCommit": "404de28f6796419b21eca85befdb5c28ea8c84a4",
15
+ "releaseIdentity": "0.3.5-beta.767",
16
+ "releaseSetId": "glassly-0.3.5-beta.767",
17
+ "sourceCommit": "4878ce3a85c552bd524283b61c14c9fe5b24b582",
18
18
  "otaManifestUrl": null,
19
19
  "otaManifestSha256": null
20
20
  })
@@ -383,7 +383,7 @@ export class BlobStore {
383
383
  return
384
384
  }
385
385
  up.handle.offset = payload.offset
386
- up.handle.writeBytes(bytes)
386
+ up.handle.writeBytesSync(bytes)
387
387
  up.handle.offset = up.bytes // restore append position
388
388
  this.hooks.sendResult(packageName, requestId, true, {bytesWritten: up.bytes})
389
389
  return
@@ -397,7 +397,7 @@ export class BlobStore {
397
397
  return
398
398
  }
399
399
  up.handle.offset = up.bytes
400
- up.handle.writeBytes(bytes)
400
+ up.handle.writeBytesSync(bytes)
401
401
  up.bytes += bytes.length
402
402
  this.hooks.sendResult(packageName, requestId, true, {bytesWritten: up.bytes})
403
403
  } catch (err) {
@@ -633,7 +633,7 @@ export class BlobStore {
633
633
  }
634
634
  try {
635
635
  const want = Math.max(0, Math.min(Number(payload.maxBytes) || 1024 * 1024, reader.remaining))
636
- const bytes = want > 0 ? reader.handle.readBytes(want) : new Uint8Array(0)
636
+ const bytes = want > 0 ? reader.handle.readBytesSync(want) : new Uint8Array(0)
637
637
  reader.remaining -= bytes.length
638
638
  const done = reader.remaining <= 0
639
639
  const base64 = bytes.length
@@ -13,7 +13,7 @@ export interface ForegroundLocationPermissionClient {
13
13
  */
14
14
  export async function resolveForegroundLocationPermission(
15
15
  client: ForegroundLocationPermissionClient,
16
- getAppState: () => string,
16
+ getAppState: () => string | null | undefined,
17
17
  ): Promise<ForegroundLocationPermissionResponse> {
18
18
  const current = await client.getForegroundPermissionsAsync()
19
19
  if (current.status === "granted" || getAppState() !== "active") {
@@ -132,7 +132,8 @@ class GestureDotsService {
132
132
  * `controllerId` keeps two controllers' fingers apart.
133
133
  */
134
134
  noteGesture(gestureName: string, claimed = false, fingerIndex?: number, controllerId?: string): void {
135
- if (!this.started || !this.enabled()) return
135
+ // A ring's scroll steps ride beside their stroke's one swipe, which already flashed.
136
+ if (!this.started || !this.enabled() || gestureName === "scroll_up" || gestureName === "scroll_down") return
136
137
  this.applyGesture(gestureName, claimed, fingerIndex, controllerId)
137
138
  this.trace("input", {gestureName, claimed})
138
139
  }
@@ -5,6 +5,7 @@ import BluetoothSdk from "@glassly/bluetooth-sdk/internal"
5
5
  import {useAppStatusStore} from "../stores/apps"
6
6
  import {useGlassesStore} from "../stores/glasses"
7
7
  import {BgTimer} from "../utils/timers"
8
+ import {hasInput2d} from "./controllers"
8
9
  import dashboardOpenTrace from "./debug/DashboardOpenTrace"
9
10
  import gestureDotsService from "./GestureDotsService"
10
11
  import {isGlassesConnected} from "./GlassesReadiness"
@@ -25,22 +26,59 @@ const miniappExitGesture = new MiniappExitGesture({
25
26
  clearTimeout: (timerId) => BgTimer.clearTimeout(timerId),
26
27
  })
27
28
 
28
- // Raw ring reports include every scroll step, whether the CFW forwards them
29
- // (deviceModel G2) or the ring sends them to the phone itself (deviceModel R1);
30
- // both tag source 2. Rate-limit scroll actions separately from press/release
31
- // recognition, per ring, using native receipt timestamps so a JS backlog does
32
- // not collapse otherwise separate gestures.
33
- const RING_SCROLL_INTERVAL_MS = 100
34
- const lastRingScrollAt = new Map<string, number>()
35
-
36
- function shouldForwardScroll(event: TouchEvent): boolean {
37
- if (event.source !== 2 || (event.gestureName !== "swipe_up" && event.gestureName !== "swipe_down")) return true
38
- const ring = event.controllerId ?? `source:${event.source}`
39
- const last = lastRingScrollAt.get(ring)
29
+ // The ring reports a slide once per step of travel, whether the CFW forwards
30
+ // it (deviceModel G2) or the ring sends it to the phone itself (deviceModel
31
+ // R1); both tag source 2. One press is one swipe: the stroke's first step goes
32
+ // out as swipe_up / swipe_down, and every step, the first included, as
33
+ // scroll_up / scroll_down with its distance and speed for smooth scrolling. A
34
+ // stroke ends at the ring's next touch_down or tap_end, or after
35
+ // RING_STROKE_IDLE_MS without a step when a report was lost. Reversing within
36
+ // a stroke fires no swipe (a finger rolling back at lift-off). Native receipt
37
+ // timestamps keep strokes apart when JS drains a backlog.
38
+ const RING_STROKE_IDLE_MS = 1000
39
+ /** Per ring, when the open stroke's last step arrived. */
40
+ const ringStrokes = new Map<string, number>()
41
+
42
+ function ringKey(event: TouchEvent): string {
43
+ return event.controllerId ?? `source:${event.source}`
44
+ }
45
+
46
+ function isRingSlideStep(event: TouchEvent): boolean {
47
+ return event.source === 2 && (event.gestureName === "swipe_up" || event.gestureName === "swipe_down")
48
+ }
49
+
50
+ function opensRingStroke(event: TouchEvent): boolean {
51
+ const last = ringStrokes.get(ringKey(event))
52
+ ringStrokes.set(ringKey(event), event.timestamp)
40
53
  const elapsed = last === undefined ? null : event.timestamp - last
41
- if (elapsed !== null && elapsed >= 0 && elapsed < RING_SCROLL_INTERVAL_MS) return false
42
- lastRingScrollAt.set(ring, event.timestamp)
43
- return true
54
+ return elapsed === null || elapsed < 0 || elapsed >= RING_STROKE_IDLE_MS
55
+ }
56
+
57
+ function endRingStroke(event: TouchEvent): void {
58
+ if (event.source === 2 && (event.gestureName === "touch_down" || event.gestureName === "tap_end")) {
59
+ ringStrokes.delete(ringKey(event))
60
+ }
61
+ }
62
+
63
+ /** The discrete swipe a stroke opens with: the step's travel belongs to scroll_*. */
64
+ function strokeSwipe(step: TouchEvent): TouchEvent {
65
+ const swipe = {...step}
66
+ delete swipe.distance
67
+ delete swipe.speed
68
+ return swipe
69
+ }
70
+
71
+ /**
72
+ * Miniapps' copy of the touch: `input2d: true` when it came from a controller
73
+ * that swipes in two dimensions (the Neural Band), the field absent otherwise,
74
+ * so a 1D swipe from the temples or the ring stays tellable while a band is
75
+ * connected under the same gesture names.
76
+ */
77
+ function toMiniapps(event: TouchEvent): TouchEvent & {input2d?: true} {
78
+ const id = event.controllerId
79
+ if (id === undefined) return event
80
+ const model = useGlassesStore.getState().controllers?.[id]?.model
81
+ return model !== undefined && hasInput2d(model) ? {...event, input2d: true} : event
44
82
  }
45
83
 
46
84
  /**
@@ -53,9 +91,20 @@ function shouldForwardScroll(event: TouchEvent): boolean {
53
91
  * dashboard's claim is for the screen with no app in it. Head position
54
92
  * (head_up / head_down) is a gesture like any other: the dashboard claims it
55
93
  * while it runs, and an unclaimed head_up on glasses that defer the dashboard
56
- * to the phone opens the native one, as it would with no app at all.
94
+ * to the phone opens the native one, as it would with no app at all. A ring
95
+ * slide step becomes one swipe per stroke plus a scroll step (see above).
57
96
  */
58
97
  export function dispatchTouchEvent(event: TouchEvent): void {
98
+ if (isRingSlideStep(event)) {
99
+ if (opensRingStroke(event)) routeTouchEvent(strokeSwipe(event))
100
+ routeTouchEvent({...event, gestureName: event.gestureName === "swipe_up" ? "scroll_up" : "scroll_down"})
101
+ return
102
+ }
103
+ endRingStroke(event)
104
+ routeTouchEvent(event)
105
+ }
106
+
107
+ function routeTouchEvent(event: TouchEvent): void {
59
108
  const gesture = event.gestureName
60
109
  const claimant = localMiniappRuntime.gestureClaimant(gesture)
61
110
  // The Neural Band's middle finger (index 1) shares the tap names but is left
@@ -87,18 +136,15 @@ export function dispatchTouchEvent(event: TouchEvent): void {
87
136
  }
88
137
  // The press may have started before this app claimed its release edge.
89
138
  gestureDotsService.noteGesture(gesture, true, event.index, event.controllerId)
90
- if (!shouldForwardScroll(event)) return
91
- localMiniappRuntime.forwardEvent("touch_event", event, undefined, claimant)
139
+ localMiniappRuntime.forwardEvent("touch_event", toMiniapps(event), undefined, claimant)
92
140
  return
93
141
  }
94
142
 
95
143
  // Gesture-dots debug indicator (any device, gated by its setting). It
96
- // only paints while the screen is otherwise empty. Process even suppressed
97
- // scroll repeats here so their completion still clears a held dot.
144
+ // only paints while the screen is otherwise empty.
98
145
  gestureDotsService.noteGesture(gesture, false, event.index, event.controllerId)
99
146
 
100
- if (!shouldForwardScroll(event)) return
101
- localMiniappRuntime.forwardEvent("touch_event", event)
147
+ localMiniappRuntime.forwardEvent("touch_event", toMiniapps(event))
102
148
 
103
149
  // Nobody claimed a double tap or a head-up: the glasses' native dashboard.
104
150
  // On eligible Glassly CFW glasses the dashboard miniapp claims both while it
@@ -119,7 +165,7 @@ export function dispatchTouchEvent(event: TouchEvent): void {
119
165
 
120
166
  export function resetTouchInput(): void {
121
167
  miniappExitGesture.reset()
122
- lastRingScrollAt.clear()
168
+ ringStrokes.clear()
123
169
  }
124
170
 
125
171
  /** Phone mirror input uses the same dashboard/miniapp policy as real glasses. */
@@ -24,8 +24,10 @@ export interface LocalLlmModelConfig {
24
24
  id: LocalLlmModelId
25
25
  /** Human label for the Settings dropdown. */
26
26
  label: string
27
- /** Approximate download size in bytes (the .pte dominates). */
27
+ /** Total download size in bytes (the .pte dominates). */
28
28
  sizeBytes: number
29
+ /** Exact size of the published .pte; the availability check compares against it. */
30
+ modelBytes: number
29
31
  /** Rough resident memory while loaded; the Settings copy warns above ~half of device RAM. */
30
32
  ramBytes: number
31
33
  urls: {
@@ -54,8 +56,10 @@ export interface LocalLlmDownloadStatus {
54
56
 
55
57
  // XNNPACK 8da4w exports from software-mansion/react-native-executorch-qwen-3,
56
58
  // pinned to the v0.10.0 release tag that react-native-executorch 0.10.x
57
- // expects. Sizes are the .pte file sizes on the Hub (tokenizer adds ~11 MB).
59
+ // expects. modelBytes are the .pte sizes on the Hub; sizeBytes adds the
60
+ // tokenizer files (~11 MB).
58
61
  const QWEN3_BASE = "https://huggingface.co/software-mansion/react-native-executorch-qwen-3/resolve/v0.10.0"
62
+ const TOKENIZER_BYTES = 11_431_080
59
63
  const MB = 1024 * 1024
60
64
  const GB = 1024 * MB
61
65
 
@@ -63,7 +67,8 @@ const MODELS: Record<LocalLlmModelId, LocalLlmModelConfig> = {
63
67
  "qwen3-0.6b": {
64
68
  id: "qwen3-0.6b",
65
69
  label: "Qwen3 0.6B",
66
- sizeBytes: 517 * MB,
70
+ sizeBytes: 505_686_400 + TOKENIZER_BYTES,
71
+ modelBytes: 505_686_400,
67
72
  ramBytes: 0.9 * GB,
68
73
  urls: {
69
74
  model: `${QWEN3_BASE}/0_6b/xnnpack/qwen_3_0_6b_xnnpack_8da4w.pte`,
@@ -74,7 +79,8 @@ const MODELS: Record<LocalLlmModelId, LocalLlmModelConfig> = {
74
79
  "qwen3-1.7b": {
75
80
  id: "qwen3-1.7b",
76
81
  label: "Qwen3 1.7B",
77
- sizeBytes: 1315 * MB,
82
+ sizeBytes: 1_303_738_496 + TOKENIZER_BYTES,
83
+ modelBytes: 1_303_738_496,
78
84
  ramBytes: 1.8 * GB,
79
85
  urls: {
80
86
  model: `${QWEN3_BASE}/1_7b/xnnpack/qwen_3_1_7b_xnnpack_8da4w.pte`,
@@ -85,7 +91,8 @@ const MODELS: Record<LocalLlmModelId, LocalLlmModelConfig> = {
85
91
  "qwen3-4b": {
86
92
  id: "qwen3-4b",
87
93
  label: "Qwen3 4B",
88
- sizeBytes: 2693 * MB,
94
+ sizeBytes: 2_681_646_976 + TOKENIZER_BYTES,
95
+ modelBytes: 2_681_646_976,
89
96
  ramBytes: 3.4 * GB,
90
97
  urls: {
91
98
  model: `${QWEN3_BASE}/4b/xnnpack/qwen_3_4b_xnnpack_8da4w.pte`,
@@ -161,7 +168,7 @@ class LocalLlmModelManager {
161
168
  // most of the published size. Downloads land in a .part file and are
162
169
  // renamed only once whole, so this only catches external tampering.
163
170
  const stat = await RNFS.stat(paths.model)
164
- return Number(stat.size) >= MODELS[id].sizeBytes * 0.95
171
+ return Number(stat.size) >= MODELS[id].modelBytes * 0.95
165
172
  } catch (error) {
166
173
  console.warn("LOCAL_LLM: availability check failed:", error)
167
174
  return false
@@ -243,6 +250,9 @@ class LocalLlmModelManager {
243
250
  await this.fetchFile(config.urls.model, paths.model, (percent) =>
244
251
  this.setStatus({modelId: id, stage: "downloading", percent}),
245
252
  )
253
+ if (!(await this.isModelAvailable(id))) {
254
+ throw new Error(`downloaded model is smaller than the expected ${config.modelBytes} bytes`)
255
+ }
246
256
  this.setStatus({modelId: id, stage: "complete", percent: 100})
247
257
  for (const listener of this.modelReadyListeners) {
248
258
  try {