@glassly/miniapp 0.4.1-dev.1158 → 0.4.1-dev.1164
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/dist/display/index.d.ts +13 -3
- package/dist/display/index.d.ts.map +1 -1
- package/dist/display/index.js +10 -3
- package/dist/display/index.js.map +1 -1
- package/dist/display/scene/anchor.d.ts +16 -0
- package/dist/display/scene/anchor.d.ts.map +1 -0
- package/dist/display/scene/anchor.js +32 -0
- package/dist/display/scene/anchor.js.map +1 -0
- package/dist/display/scene/degrade.d.ts +25 -0
- package/dist/display/scene/degrade.d.ts.map +1 -0
- package/dist/display/scene/degrade.js +67 -0
- package/dist/display/scene/degrade.js.map +1 -0
- package/dist/display/scene/differ.d.ts +50 -0
- package/dist/display/scene/differ.d.ts.map +1 -0
- package/dist/display/scene/differ.js +129 -0
- package/dist/display/scene/differ.js.map +1 -0
- package/dist/display/scene/process.d.ts +41 -0
- package/dist/display/scene/process.d.ts.map +1 -0
- package/dist/display/scene/process.js +408 -0
- package/dist/display/scene/process.js.map +1 -0
- package/dist/display/scene/store.d.ts +48 -0
- package/dist/display/scene/store.d.ts.map +1 -0
- package/dist/display/scene/store.js +0 -0
- package/dist/display/scene/store.js.map +1 -0
- package/dist/display/scene/svgPath.d.ts +9 -0
- package/dist/display/scene/svgPath.d.ts.map +1 -0
- package/dist/display/scene/svgPath.js +167 -0
- package/dist/display/scene/svgPath.js.map +1 -0
- package/dist/host/index.d.ts +7 -0
- package/dist/host/index.d.ts.map +1 -0
- package/dist/host/index.js +7 -0
- package/dist/host/index.js.map +1 -0
- package/dist/host/uiShim.d.ts +38 -0
- package/dist/host/uiShim.d.ts.map +1 -0
- package/dist/host/uiShim.js +383 -0
- package/dist/host/uiShim.js.map +1 -0
- package/dist/host/webviewGlobals.d.ts +60 -0
- package/dist/host/webviewGlobals.d.ts.map +1 -0
- package/dist/host/webviewGlobals.js +211 -0
- package/dist/host/webviewGlobals.js.map +1 -0
- package/dist/mirror/canvas.d.ts +13 -2
- package/dist/mirror/canvas.d.ts.map +1 -1
- package/dist/mirror/canvas.js +42 -21
- package/dist/mirror/canvas.js.map +1 -1
- package/dist/mirror/index.d.ts +1 -1
- package/dist/mirror/index.d.ts.map +1 -1
- package/dist/mirror/index.js.map +1 -1
- package/dist/ui/index.d.ts +1 -1
- package/dist/ui/index.js +1 -1
- package/package.json +6 -2
- package/src/display/index.ts +14 -3
- package/src/display/scene/anchor.ts +38 -0
- package/src/display/scene/degrade.ts +83 -0
- package/src/display/scene/differ.ts +152 -0
- package/src/display/scene/process.ts +443 -0
- package/src/display/scene/store.ts +0 -0
- package/src/display/scene/svgPath.ts +163 -0
- package/src/host/index.ts +14 -0
- package/src/host/uiShim.ts +389 -0
- package/src/host/webviewGlobals.ts +251 -0
- package/src/mirror/canvas.ts +86 -43
- package/src/mirror/index.ts +1 -1
- package/src/ui/index.ts +1 -1
package/dist/display/index.d.ts
CHANGED
|
@@ -3,9 +3,10 @@
|
|
|
3
3
|
* miniapp needs to lay out a frame the way the host measures it: the glasses'
|
|
4
4
|
* display profiles (glyph widths, line heights), pixel-accurate measurement
|
|
5
5
|
* and wrapping, pixel-art icons as scene images, and the scene element types
|
|
6
|
-
* the host's render pipeline consumes. Pure TypeScript with no host imports
|
|
7
|
-
*
|
|
8
|
-
*
|
|
6
|
+
* the host's render pipeline consumes. Pure TypeScript with no host imports.
|
|
7
|
+
* The host's scene pipeline (`processScene`, `diffScene`, `SceneStore`) lives
|
|
8
|
+
* here too: the Glassly App and the desktop simulator both run it, so a
|
|
9
|
+
* miniapp that wraps text with these modules gets the rows the glasses draw.
|
|
9
10
|
*/
|
|
10
11
|
export type { DisplayProfile, FontMetrics, UniformScriptWidths, FallbackConfig, DisplayConstraints, ScriptType, } from "./profiles";
|
|
11
12
|
export { G1_PROFILE, G1_PROFILE_LEGACY, G1_HYPHEN_WIDTH_PX, G1_SPACE_WIDTH_PX, G2_PROFILE, G2_HYPHEN_WIDTH_PX, G2_SPACE_WIDTH_PX, Z100_PROFILE, Z100_HYPHEN_WIDTH_PX, Z100_SPACE_WIDTH_PX, NEX_PROFILE, NEX_HYPHEN_WIDTH_PX, NEX_SPACE_WIDTH_PX, RAYNEO_IO_PROFILE, RAYNEO_IO_CFW_PROFILE, MEMOMIND_ONE_PROFILE, NIMO_CFW_PROFILE, NIMO_PROFILE, RAYNEO_IO_HYPHEN_WIDTH_PX, RAYNEO_IO_SPACE_WIDTH_PX, } from "./profiles";
|
|
@@ -18,6 +19,15 @@ export { pixelArtElement, pixelArtPng, pixelArtSize, pixelLevel } from "./pixelA
|
|
|
18
19
|
export type { PixelArt } from "./pixelArt";
|
|
19
20
|
export type { FrameElement, SceneAnchor, SceneBox, SceneBoxInput, SceneBreakMode, SceneChange, SceneDisplayCapabilities, SceneElementInput, SceneElementType, SceneFrame, SceneImageStyle, ScenePoint, SceneProcessResult, SceneRectStyle, SceneShapeStyle, SceneStrokeStyle, SceneTextStyle, SceneTransition, SceneTransitionEdge, } from "./scene/types";
|
|
20
21
|
export { boxesEqual, contentHash, elementContentHash, MAX_SCENE_DEPTH, POINT_SHAPE_ARITY, POINT_SHAPE_TYPES, } from "./scene/types";
|
|
22
|
+
export { resolveAnchors } from "./scene/anchor";
|
|
23
|
+
export { diffScene } from "./scene/differ";
|
|
24
|
+
export type { DiffResult, DiffableElement } from "./scene/differ";
|
|
25
|
+
export { degradeScene } from "./scene/degrade";
|
|
26
|
+
export type { DegradedScene } from "./scene/degrade";
|
|
27
|
+
export { processScene, profileLineHeightPx, wrapsOnDevice } from "./scene/process";
|
|
28
|
+
export type { ProcessedScene } from "./scene/process";
|
|
29
|
+
export { SceneStore } from "./scene/store";
|
|
30
|
+
export { compileSvgPath, svgPath } from "./scene/svgPath";
|
|
21
31
|
export { SHAPE_TYPES, enterGeometry, sceneGeometry, geometryEqual, tweenAt, levelOpacity } from "../mirror/geometry";
|
|
22
32
|
export type { MirrorSceneElement, SceneGeometry } from "../mirror/geometry";
|
|
23
33
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/display/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/display/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,YAAY,EACV,cAAc,EACd,WAAW,EACX,mBAAmB,EACnB,cAAc,EACd,kBAAkB,EAClB,UAAU,GACX,MAAM,YAAY,CAAA;AACnB,OAAO,EACL,UAAU,EACV,iBAAiB,EACjB,kBAAkB,EAClB,iBAAiB,EACjB,UAAU,EACV,kBAAkB,EAClB,iBAAiB,EACjB,YAAY,EACZ,oBAAoB,EACpB,mBAAmB,EACnB,WAAW,EACX,mBAAmB,EACnB,kBAAkB,EAClB,iBAAiB,EACjB,qBAAqB,EACrB,oBAAoB,EACpB,gBAAgB,EAChB,YAAY,EACZ,yBAAyB,EACzB,wBAAwB,GACzB,MAAM,YAAY,CAAA;AAEnB,OAAO,EAAC,YAAY,EAAC,MAAM,YAAY,CAAA;AACvC,YAAY,EAAC,eAAe,EAAE,eAAe,EAAC,MAAM,YAAY,CAAA;AAChE,OAAO,EACL,YAAY,EACZ,cAAc,EACd,iBAAiB,EACjB,oBAAoB,EACpB,mBAAmB,EACnB,mBAAmB,EACnB,aAAa,GACd,MAAM,YAAY,CAAA;AAEnB,OAAO,EAAC,WAAW,EAAE,oBAAoB,EAAE,oBAAoB,EAAC,MAAM,WAAW,CAAA;AACjF,YAAY,EAAC,WAAW,EAAE,UAAU,EAAE,WAAW,EAAE,SAAS,EAAE,2BAA2B,EAAC,MAAM,WAAW,CAAA;AAE3G,OAAO,EAAC,eAAe,EAAE,WAAW,EAAE,YAAY,EAAE,UAAU,EAAC,MAAM,YAAY,CAAA;AACjF,YAAY,EAAC,QAAQ,EAAC,MAAM,YAAY,CAAA;AAExC,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,eAAe,CAAA;AACtB,OAAO,EACL,UAAU,EACV,WAAW,EACX,kBAAkB,EAClB,eAAe,EACf,iBAAiB,EACjB,iBAAiB,GAClB,MAAM,eAAe,CAAA;AAEtB,OAAO,EAAC,cAAc,EAAC,MAAM,gBAAgB,CAAA;AAC7C,OAAO,EAAC,SAAS,EAAC,MAAM,gBAAgB,CAAA;AACxC,YAAY,EAAC,UAAU,EAAE,eAAe,EAAC,MAAM,gBAAgB,CAAA;AAC/D,OAAO,EAAC,YAAY,EAAC,MAAM,iBAAiB,CAAA;AAC5C,YAAY,EAAC,aAAa,EAAC,MAAM,iBAAiB,CAAA;AAClD,OAAO,EAAC,YAAY,EAAE,mBAAmB,EAAE,aAAa,EAAC,MAAM,iBAAiB,CAAA;AAChF,YAAY,EAAC,cAAc,EAAC,MAAM,iBAAiB,CAAA;AACnD,OAAO,EAAC,UAAU,EAAC,MAAM,eAAe,CAAA;AACxC,OAAO,EAAC,cAAc,EAAE,OAAO,EAAC,MAAM,iBAAiB,CAAA;AAEvD,OAAO,EAAC,WAAW,EAAE,aAAa,EAAE,aAAa,EAAE,aAAa,EAAE,OAAO,EAAE,YAAY,EAAC,MAAM,oBAAoB,CAAA;AAClH,YAAY,EAAC,kBAAkB,EAAE,aAAa,EAAC,MAAM,oBAAoB,CAAA"}
|
package/dist/display/index.js
CHANGED
|
@@ -3,9 +3,10 @@
|
|
|
3
3
|
* miniapp needs to lay out a frame the way the host measures it: the glasses'
|
|
4
4
|
* display profiles (glyph widths, line heights), pixel-accurate measurement
|
|
5
5
|
* and wrapping, pixel-art icons as scene images, and the scene element types
|
|
6
|
-
* the host's render pipeline consumes. Pure TypeScript with no host imports
|
|
7
|
-
*
|
|
8
|
-
*
|
|
6
|
+
* the host's render pipeline consumes. Pure TypeScript with no host imports.
|
|
7
|
+
* The host's scene pipeline (`processScene`, `diffScene`, `SceneStore`) lives
|
|
8
|
+
* here too: the Glassly App and the desktop simulator both run it, so a
|
|
9
|
+
* miniapp that wraps text with these modules gets the rows the glasses draw.
|
|
9
10
|
*/
|
|
10
11
|
export { G1_PROFILE, G1_PROFILE_LEGACY, G1_HYPHEN_WIDTH_PX, G1_SPACE_WIDTH_PX, G2_PROFILE, G2_HYPHEN_WIDTH_PX, G2_SPACE_WIDTH_PX, Z100_PROFILE, Z100_HYPHEN_WIDTH_PX, Z100_SPACE_WIDTH_PX, NEX_PROFILE, NEX_HYPHEN_WIDTH_PX, NEX_SPACE_WIDTH_PX, RAYNEO_IO_PROFILE, RAYNEO_IO_CFW_PROFILE, MEMOMIND_ONE_PROFILE, NIMO_CFW_PROFILE, NIMO_PROFILE, RAYNEO_IO_HYPHEN_WIDTH_PX, RAYNEO_IO_SPACE_WIDTH_PX, } from "./profiles";
|
|
11
12
|
export { TextMeasurer } from "./measurer";
|
|
@@ -13,5 +14,11 @@ export { detectScript, isCJKCharacter, isKoreanCharacter, isUniformWidthScript,
|
|
|
13
14
|
export { TextWrapper, DEFAULT_WRAP_OPTIONS, normalizeDisplayText } from "./wrapper";
|
|
14
15
|
export { pixelArtElement, pixelArtPng, pixelArtSize, pixelLevel } from "./pixelArt";
|
|
15
16
|
export { boxesEqual, contentHash, elementContentHash, MAX_SCENE_DEPTH, POINT_SHAPE_ARITY, POINT_SHAPE_TYPES, } from "./scene/types";
|
|
17
|
+
export { resolveAnchors } from "./scene/anchor";
|
|
18
|
+
export { diffScene } from "./scene/differ";
|
|
19
|
+
export { degradeScene } from "./scene/degrade";
|
|
20
|
+
export { processScene, profileLineHeightPx, wrapsOnDevice } from "./scene/process";
|
|
21
|
+
export { SceneStore } from "./scene/store";
|
|
22
|
+
export { compileSvgPath, svgPath } from "./scene/svgPath";
|
|
16
23
|
export { SHAPE_TYPES, enterGeometry, sceneGeometry, geometryEqual, tweenAt, levelOpacity } from "../mirror/geometry";
|
|
17
24
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/display/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/display/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAUH,OAAO,EACL,UAAU,EACV,iBAAiB,EACjB,kBAAkB,EAClB,iBAAiB,EACjB,UAAU,EACV,kBAAkB,EAClB,iBAAiB,EACjB,YAAY,EACZ,oBAAoB,EACpB,mBAAmB,EACnB,WAAW,EACX,mBAAmB,EACnB,kBAAkB,EAClB,iBAAiB,EACjB,qBAAqB,EACrB,oBAAoB,EACpB,gBAAgB,EAChB,YAAY,EACZ,yBAAyB,EACzB,wBAAwB,GACzB,MAAM,YAAY,CAAA;AAEnB,OAAO,EAAC,YAAY,EAAC,MAAM,YAAY,CAAA;AAEvC,OAAO,EACL,YAAY,EACZ,cAAc,EACd,iBAAiB,EACjB,oBAAoB,EACpB,mBAAmB,EACnB,mBAAmB,EACnB,aAAa,GACd,MAAM,YAAY,CAAA;AAEnB,OAAO,EAAC,WAAW,EAAE,oBAAoB,EAAE,oBAAoB,EAAC,MAAM,WAAW,CAAA;AAGjF,OAAO,EAAC,eAAe,EAAE,WAAW,EAAE,YAAY,EAAE,UAAU,EAAC,MAAM,YAAY,CAAA;AAwBjF,OAAO,EACL,UAAU,EACV,WAAW,EACX,kBAAkB,EAClB,eAAe,EACf,iBAAiB,EACjB,iBAAiB,GAClB,MAAM,eAAe,CAAA;AAEtB,OAAO,EAAC,cAAc,EAAC,MAAM,gBAAgB,CAAA;AAC7C,OAAO,EAAC,SAAS,EAAC,MAAM,gBAAgB,CAAA;AAExC,OAAO,EAAC,YAAY,EAAC,MAAM,iBAAiB,CAAA;AAE5C,OAAO,EAAC,YAAY,EAAE,mBAAmB,EAAE,aAAa,EAAC,MAAM,iBAAiB,CAAA;AAEhF,OAAO,EAAC,UAAU,EAAC,MAAM,eAAe,CAAA;AACxC,OAAO,EAAC,cAAc,EAAE,OAAO,EAAC,MAAM,iBAAiB,CAAA;AAEvD,OAAO,EAAC,WAAW,EAAE,aAAa,EAAE,aAAa,EAAE,aAAa,EAAE,OAAO,EAAE,YAAY,EAAC,MAAM,oBAAoB,CAAA"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Anchor resolution — turn corner-anchored boxes into plain top-left boxes
|
|
3
|
+
* against the device's real canvas. Runs in emitScene BEFORE the canPosition
|
|
4
|
+
* branch so both processScene (clamping) and degradeScene (reading order)
|
|
5
|
+
* only ever see concrete coordinates.
|
|
6
|
+
*/
|
|
7
|
+
import type { SceneElementInput } from "./types";
|
|
8
|
+
/**
|
|
9
|
+
* Resolve every anchored box in a scene to top-left coordinates on a W×H
|
|
10
|
+
* canvas. Unanchored elements pass through unchanged (same reference — no
|
|
11
|
+
* copy churn on the common path), as do malformed ones so processScene's
|
|
12
|
+
* validation still sees and reports them. Non-finite insets survive the
|
|
13
|
+
* subtraction as non-finite and are dropped by the same validation.
|
|
14
|
+
*/
|
|
15
|
+
export declare function resolveAnchors(input: readonly SceneElementInput[], width: number, height: number): SceneElementInput[];
|
|
16
|
+
//# sourceMappingURL=anchor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"anchor.d.ts","sourceRoot":"","sources":["../../../src/display/scene/anchor.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAA0B,iBAAiB,EAAC,MAAM,SAAS,CAAA;AAcvE;;;;;;GAMG;AACH,wBAAgB,cAAc,CAC5B,KAAK,EAAE,SAAS,iBAAiB,EAAE,EACnC,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,GACb,iBAAiB,EAAE,CAKrB"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Anchor resolution — turn corner-anchored boxes into plain top-left boxes
|
|
3
|
+
* against the device's real canvas. Runs in emitScene BEFORE the canPosition
|
|
4
|
+
* branch so both processScene (clamping) and degradeScene (reading order)
|
|
5
|
+
* only ever see concrete coordinates.
|
|
6
|
+
*/
|
|
7
|
+
function resolveBox(box, width, height) {
|
|
8
|
+
const { anchor, x, y, w, h } = box;
|
|
9
|
+
const right = anchor === "top-right" || anchor === "bottom-right";
|
|
10
|
+
const bottom = anchor === "bottom-left" || anchor === "bottom-right";
|
|
11
|
+
return {
|
|
12
|
+
x: right ? width - x - w : x,
|
|
13
|
+
y: bottom ? height - y - h : y,
|
|
14
|
+
w,
|
|
15
|
+
h,
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Resolve every anchored box in a scene to top-left coordinates on a W×H
|
|
20
|
+
* canvas. Unanchored elements pass through unchanged (same reference — no
|
|
21
|
+
* copy churn on the common path), as do malformed ones so processScene's
|
|
22
|
+
* validation still sees and reports them. Non-finite insets survive the
|
|
23
|
+
* subtraction as non-finite and are dropped by the same validation.
|
|
24
|
+
*/
|
|
25
|
+
export function resolveAnchors(input, width, height) {
|
|
26
|
+
return input.map((el) => {
|
|
27
|
+
if (!el || typeof el !== "object" || !el.box || !el.box.anchor)
|
|
28
|
+
return el;
|
|
29
|
+
return { ...el, box: resolveBox(el.box, width, height) };
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=anchor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"anchor.js","sourceRoot":"","sources":["../../../src/display/scene/anchor.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,SAAS,UAAU,CAAC,GAAkB,EAAE,KAAa,EAAE,MAAc;IACnE,MAAM,EAAC,MAAM,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAC,GAAG,GAAG,CAAA;IAChC,MAAM,KAAK,GAAG,MAAM,KAAK,WAAW,IAAI,MAAM,KAAK,cAAc,CAAA;IACjE,MAAM,MAAM,GAAG,MAAM,KAAK,aAAa,IAAI,MAAM,KAAK,cAAc,CAAA;IACpE,OAAO;QACL,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;QAC5B,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;QAC9B,CAAC;QACD,CAAC;KACF,CAAA;AACH,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,cAAc,CAC5B,KAAmC,EACnC,KAAa,EACb,MAAc;IAEd,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE;QACtB,IAAI,CAAC,EAAE,IAAI,OAAO,EAAE,KAAK,QAAQ,IAAI,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,EAAE,CAAC,GAAG,CAAC,MAAM;YAAE,OAAO,EAAE,CAAA;QACzE,OAAO,EAAC,GAAG,EAAE,EAAE,GAAG,EAAE,UAAU,CAAC,EAAE,CAAC,GAAG,EAAE,KAAK,EAAE,MAAM,CAAC,EAAC,CAAA;IACxD,CAAC,CAAC,CAAA;AACJ,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Degrade — compile a scene for devices that can't position elements
|
|
3
|
+
* (`canPosition: false`: G1, Z100). Output is a LEGACY layout that rides the
|
|
4
|
+
* existing display path — DisplayProcessor wraps it there, exactly as today,
|
|
5
|
+
* which is what keeps sugar byte-identical on old hardware (spec §2/§5:
|
|
6
|
+
* degrade output must be UNWRAPPED; wrapping twice breaks the goldens).
|
|
7
|
+
*
|
|
8
|
+
* Rules (design doc §3.4.8): content-preserving, never-erroring,
|
|
9
|
+
* honestly-reported. Text collapses in reading order (y, then x) joined by
|
|
10
|
+
* blank lines; EXACTLY two text elements sharing a y-range with disjoint
|
|
11
|
+
* x-ranges become a double_text_wall (ColumnComposer path downstream); rects
|
|
12
|
+
* drop silently (decoration); images drop + report.
|
|
13
|
+
*/
|
|
14
|
+
import type { SceneElementInput } from "./types";
|
|
15
|
+
export interface DegradedScene {
|
|
16
|
+
/** Legacy layout for the existing display path, or null for an empty scene (caller clears). */
|
|
17
|
+
layout: {
|
|
18
|
+
layoutType: string;
|
|
19
|
+
[key: string]: unknown;
|
|
20
|
+
} | null;
|
|
21
|
+
degraded: boolean;
|
|
22
|
+
dropped: string[];
|
|
23
|
+
}
|
|
24
|
+
export declare function degradeScene(input: readonly SceneElementInput[]): DegradedScene;
|
|
25
|
+
//# sourceMappingURL=degrade.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"degrade.d.ts","sourceRoot":"","sources":["../../../src/display/scene/degrade.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAC,iBAAiB,EAAC,MAAM,SAAS,CAAA;AAE9C,MAAM,WAAW,aAAa;IAC5B,+FAA+F;IAC/F,MAAM,EAAE;QAAC,UAAU,EAAE,MAAM,CAAC;QAAC,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;KAAC,GAAG,IAAI,CAAA;IAC3D,QAAQ,EAAE,OAAO,CAAA;IACjB,OAAO,EAAE,MAAM,EAAE,CAAA;CAClB;AAYD,wBAAgB,YAAY,CAAC,KAAK,EAAE,SAAS,iBAAiB,EAAE,GAAG,aAAa,CAiD/E"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Degrade — compile a scene for devices that can't position elements
|
|
3
|
+
* (`canPosition: false`: G1, Z100). Output is a LEGACY layout that rides the
|
|
4
|
+
* existing display path — DisplayProcessor wraps it there, exactly as today,
|
|
5
|
+
* which is what keeps sugar byte-identical on old hardware (spec §2/§5:
|
|
6
|
+
* degrade output must be UNWRAPPED; wrapping twice breaks the goldens).
|
|
7
|
+
*
|
|
8
|
+
* Rules (design doc §3.4.8): content-preserving, never-erroring,
|
|
9
|
+
* honestly-reported. Text collapses in reading order (y, then x) joined by
|
|
10
|
+
* blank lines; EXACTLY two text elements sharing a y-range with disjoint
|
|
11
|
+
* x-ranges become a double_text_wall (ColumnComposer path downstream); rects
|
|
12
|
+
* drop silently (decoration); images drop + report.
|
|
13
|
+
*/
|
|
14
|
+
function yOverlap(a, b) {
|
|
15
|
+
return a.box.y < b.box.y + b.box.h && b.box.y < a.box.y + a.box.h;
|
|
16
|
+
}
|
|
17
|
+
function xDisjoint(a, b) {
|
|
18
|
+
return a.box.x + a.box.w <= b.box.x || b.box.x + b.box.w <= a.box.x;
|
|
19
|
+
}
|
|
20
|
+
export function degradeScene(input) {
|
|
21
|
+
const dropped = [];
|
|
22
|
+
let degraded = false;
|
|
23
|
+
const texts = [];
|
|
24
|
+
input.forEach((el, index) => {
|
|
25
|
+
if (el && typeof el === "object" && Array.isArray(el.points)) {
|
|
26
|
+
return; // vector shapes: decoration on a text wall
|
|
27
|
+
}
|
|
28
|
+
if (!el || typeof el !== "object" || !el.box) {
|
|
29
|
+
// Malformed element — report it like the positioning pipeline does
|
|
30
|
+
// instead of silently pretending the render was clean.
|
|
31
|
+
dropped.push(el?.id ?? `element[${index}]`);
|
|
32
|
+
degraded = true;
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
if (el.type === "text") {
|
|
36
|
+
texts.push(el);
|
|
37
|
+
}
|
|
38
|
+
else if (el.type === "image") {
|
|
39
|
+
dropped.push(el.id ?? `image[${index}]`);
|
|
40
|
+
degraded = true;
|
|
41
|
+
}
|
|
42
|
+
// rects and other shapes: silent drop — pure decoration on a text wall.
|
|
43
|
+
});
|
|
44
|
+
if (texts.length === 0) {
|
|
45
|
+
return { layout: null, degraded, dropped };
|
|
46
|
+
}
|
|
47
|
+
// Row exception: exactly 2 columns with clean separation — the shipped
|
|
48
|
+
// double_text_wall mechanism (scope guard: nothing fancier; this is NOT a
|
|
49
|
+
// layout engine).
|
|
50
|
+
if (texts.length === 2 && yOverlap(texts[0], texts[1]) && xDisjoint(texts[0], texts[1])) {
|
|
51
|
+
const [left, right] = texts[0].box.x <= texts[1].box.x ? [texts[0], texts[1]] : [texts[1], texts[0]];
|
|
52
|
+
return {
|
|
53
|
+
layout: { layoutType: "double_text_wall", topText: left.text ?? "", bottomText: right.text ?? "" },
|
|
54
|
+
degraded,
|
|
55
|
+
dropped,
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
// Reading order: y, then x; join with blank lines. Downstream wrap clips
|
|
59
|
+
// overflow per the device profile.
|
|
60
|
+
const ordered = [...texts].sort((a, b) => a.box.y - b.box.y || a.box.x - b.box.x);
|
|
61
|
+
const text = ordered
|
|
62
|
+
.map((t) => t.text ?? "")
|
|
63
|
+
.filter((t) => t.length > 0)
|
|
64
|
+
.join("\n\n");
|
|
65
|
+
return { layout: { layoutType: "text_wall", text }, degraded, dropped };
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=degrade.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"degrade.js","sourceRoot":"","sources":["../../../src/display/scene/degrade.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAaH,SAAS,QAAQ,CAAC,CAAS,EAAE,CAAS;IACpC,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAA;AACnE,CAAC;AAED,SAAS,SAAS,CAAC,CAAS,EAAE,CAAS;IACrC,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,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,EAAE,CAAC;SACxB,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC;SAC3B,IAAI,CAAC,MAAM,CAAC,CAAA;IACf,OAAO,EAAC,MAAM,EAAE,EAAC,UAAU,EAAE,WAAW,EAAE,IAAI,EAAC,EAAE,QAAQ,EAAE,OAAO,EAAC,CAAA;AACrE,CAAC"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Scene differ — matches elements between the last frame sent to the device and
|
|
3
|
+
* the next scene, and classifies each element's change. Pure set arithmetic:
|
|
4
|
+
* nothing in here is device-specific (spec §1).
|
|
5
|
+
*
|
|
6
|
+
* Matching rules (design doc §3.4.1, in order):
|
|
7
|
+
* 1. same explicit `id` + same `type` ⇒ same element
|
|
8
|
+
* 2. no id: same `type` + identical box ⇒ same element
|
|
9
|
+
* 3. no id: same `type`, by order among the still-unmatched
|
|
10
|
+
* 4. anything unmatched in prev ⇒ removed; unmatched in next ⇒ created
|
|
11
|
+
*
|
|
12
|
+
* Matched no-id elements INHERIT the previous element's assigned id so the
|
|
13
|
+
* device-side id⇒firmware-component mapping stays stable; fresh elements get a
|
|
14
|
+
* synthesized id from the caller (SceneStore counter). Synthesized ids are
|
|
15
|
+
* prefixed "~" so they can never collide with app-supplied ids.
|
|
16
|
+
*/
|
|
17
|
+
import type { FrameElement, SceneBox, SceneElementType, ScenePoint, SceneTransition } from "./types";
|
|
18
|
+
/** A processed (clamped/wrapped) element, pre-diff: id optional, no annotation yet. */
|
|
19
|
+
export interface DiffableElement {
|
|
20
|
+
/** SVG path and its checked firmware command stream (Q4 coordinates). */
|
|
21
|
+
d?: string;
|
|
22
|
+
path?: number[];
|
|
23
|
+
pathScale?: number;
|
|
24
|
+
fillRule?: "nonzero" | "evenodd";
|
|
25
|
+
rotation?: number;
|
|
26
|
+
pivot?: ScenePoint;
|
|
27
|
+
depth?: number;
|
|
28
|
+
id?: string;
|
|
29
|
+
type: SceneElementType;
|
|
30
|
+
box: SceneBox;
|
|
31
|
+
text?: string;
|
|
32
|
+
data?: string;
|
|
33
|
+
style?: FrameElement["style"];
|
|
34
|
+
points?: ScenePoint[];
|
|
35
|
+
startDeg?: number;
|
|
36
|
+
endDeg?: number;
|
|
37
|
+
transition?: SceneTransition;
|
|
38
|
+
contentHash: string;
|
|
39
|
+
}
|
|
40
|
+
export interface DiffResult {
|
|
41
|
+
elements: FrameElement[];
|
|
42
|
+
removed: string[];
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Diff `next` against `prev` (the last frame sent for this app/view/device;
|
|
46
|
+
* empty array for a fresh scene). `nextSyntheticId` mints ids for elements the
|
|
47
|
+
* app didn't name — must be stable per (app, view) across calls (SceneStore).
|
|
48
|
+
*/
|
|
49
|
+
export declare function diffScene(prev: readonly FrameElement[], next: readonly DiffableElement[], nextSyntheticId: () => string): DiffResult;
|
|
50
|
+
//# sourceMappingURL=differ.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"differ.d.ts","sourceRoot":"","sources":["../../../src/display/scene/differ.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EAAC,YAAY,EAAE,QAAQ,EAAe,gBAAgB,EAAE,UAAU,EAAE,eAAe,EAAC,MAAM,SAAS,CAAA;AAG/G,uFAAuF;AACvF,MAAM,WAAW,eAAe;IAC9B,yEAAyE;IACzE,CAAC,CAAC,EAAE,MAAM,CAAA;IACV,IAAI,CAAC,EAAE,MAAM,EAAE,CAAA;IACf,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,QAAQ,CAAC,EAAE,SAAS,GAAG,SAAS,CAAA;IAChC,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,KAAK,CAAC,EAAE,UAAU,CAAA;IAClB,KAAK,CAAC,EAAE,MAAM,CAAA;IAEd,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,IAAI,EAAE,gBAAgB,CAAA;IACtB,GAAG,EAAE,QAAQ,CAAA;IACb,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,KAAK,CAAC,EAAE,YAAY,CAAC,OAAO,CAAC,CAAA;IAC7B,MAAM,CAAC,EAAE,UAAU,EAAE,CAAA;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,UAAU,CAAC,EAAE,eAAe,CAAA;IAC5B,WAAW,EAAE,MAAM,CAAA;CACpB;AAED,MAAM,WAAW,UAAU;IACzB,QAAQ,EAAE,YAAY,EAAE,CAAA;IACxB,OAAO,EAAE,MAAM,EAAE,CAAA;CAClB;AAoCD;;;;GAIG;AACH,wBAAgB,SAAS,CACvB,IAAI,EAAE,SAAS,YAAY,EAAE,EAC7B,IAAI,EAAE,SAAS,eAAe,EAAE,EAChC,eAAe,EAAE,MAAM,MAAM,GAC5B,UAAU,CA2DZ"}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Scene differ — matches elements between the last frame sent to the device and
|
|
3
|
+
* the next scene, and classifies each element's change. Pure set arithmetic:
|
|
4
|
+
* nothing in here is device-specific (spec §1).
|
|
5
|
+
*
|
|
6
|
+
* Matching rules (design doc §3.4.1, in order):
|
|
7
|
+
* 1. same explicit `id` + same `type` ⇒ same element
|
|
8
|
+
* 2. no id: same `type` + identical box ⇒ same element
|
|
9
|
+
* 3. no id: same `type`, by order among the still-unmatched
|
|
10
|
+
* 4. anything unmatched in prev ⇒ removed; unmatched in next ⇒ created
|
|
11
|
+
*
|
|
12
|
+
* Matched no-id elements INHERIT the previous element's assigned id so the
|
|
13
|
+
* device-side id⇒firmware-component mapping stays stable; fresh elements get a
|
|
14
|
+
* synthesized id from the caller (SceneStore counter). Synthesized ids are
|
|
15
|
+
* prefixed "~" so they can never collide with app-supplied ids.
|
|
16
|
+
*/
|
|
17
|
+
import { boxesEqual } from "./types";
|
|
18
|
+
function classify(prev, next) {
|
|
19
|
+
if (!boxesEqual(prev.box, next.box))
|
|
20
|
+
return "moved";
|
|
21
|
+
if (prev.contentHash !== next.contentHash)
|
|
22
|
+
return "updated";
|
|
23
|
+
return "unchanged";
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Assemble the annotated FrameElement, OMITTING optional fields that are
|
|
27
|
+
* undefined. A present key with an `undefined` value cannot cross the Expo
|
|
28
|
+
* Android bridge — its `Map<String, Any>` converter rejects it ("Value is
|
|
29
|
+
* undefined, expected an Object"), which surfaces as ERR_UNEXPECTED from
|
|
30
|
+
* displayEvent. (iOS's `[String: Any]` bridge silently drops nils, so the
|
|
31
|
+
* defect was invisible there.) Keeping the keys absent — not undefined —
|
|
32
|
+
* matches the optional-field contract in types.ts.
|
|
33
|
+
*/
|
|
34
|
+
function buildFrameElement(el, id, change) {
|
|
35
|
+
const out = { id, type: el.type, box: el.box, contentHash: el.contentHash, change };
|
|
36
|
+
if (el.text !== undefined)
|
|
37
|
+
out.text = el.text;
|
|
38
|
+
if (el.data !== undefined)
|
|
39
|
+
out.data = el.data;
|
|
40
|
+
if (el.style !== undefined)
|
|
41
|
+
out.style = el.style;
|
|
42
|
+
if (el.points !== undefined)
|
|
43
|
+
out.points = el.points;
|
|
44
|
+
if (el.startDeg !== undefined)
|
|
45
|
+
out.startDeg = el.startDeg;
|
|
46
|
+
if (el.endDeg !== undefined)
|
|
47
|
+
out.endDeg = el.endDeg;
|
|
48
|
+
if (el.transition !== undefined)
|
|
49
|
+
out.transition = el.transition;
|
|
50
|
+
if (el.d !== undefined)
|
|
51
|
+
out.d = el.d;
|
|
52
|
+
if (el.path !== undefined)
|
|
53
|
+
out.path = el.path;
|
|
54
|
+
if (el.pathScale !== undefined)
|
|
55
|
+
out.pathScale = el.pathScale;
|
|
56
|
+
if (el.fillRule !== undefined)
|
|
57
|
+
out.fillRule = el.fillRule;
|
|
58
|
+
if (el.rotation !== undefined)
|
|
59
|
+
out.rotation = el.rotation;
|
|
60
|
+
if (el.pivot !== undefined)
|
|
61
|
+
out.pivot = el.pivot;
|
|
62
|
+
if (el.depth !== undefined)
|
|
63
|
+
out.depth = el.depth;
|
|
64
|
+
return out;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Diff `next` against `prev` (the last frame sent for this app/view/device;
|
|
68
|
+
* empty array for a fresh scene). `nextSyntheticId` mints ids for elements the
|
|
69
|
+
* app didn't name — must be stable per (app, view) across calls (SceneStore).
|
|
70
|
+
*/
|
|
71
|
+
export function diffScene(prev, next, nextSyntheticId) {
|
|
72
|
+
const prevUnmatched = new Set(prev.map((_, i) => i));
|
|
73
|
+
const prevByExplicitId = new Map();
|
|
74
|
+
prev.forEach((el, i) => {
|
|
75
|
+
if (!el.id.startsWith("~"))
|
|
76
|
+
prevByExplicitId.set(`${el.type}:${el.id}`, i);
|
|
77
|
+
});
|
|
78
|
+
// matches[nextIndex] = prevIndex | undefined
|
|
79
|
+
const matches = new Array(next.length).fill(undefined);
|
|
80
|
+
// Pass 1: explicit id + type.
|
|
81
|
+
next.forEach((el, i) => {
|
|
82
|
+
if (!el.id)
|
|
83
|
+
return;
|
|
84
|
+
const j = prevByExplicitId.get(`${el.type}:${el.id}`);
|
|
85
|
+
if (j !== undefined && prevUnmatched.has(j)) {
|
|
86
|
+
matches[i] = j;
|
|
87
|
+
prevUnmatched.delete(j);
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
// Pass 2: no-id elements match a no-id prev element of the same type with an
|
|
91
|
+
// identical box.
|
|
92
|
+
next.forEach((el, i) => {
|
|
93
|
+
if (el.id || matches[i] !== undefined)
|
|
94
|
+
return;
|
|
95
|
+
for (const j of prevUnmatched) {
|
|
96
|
+
const p = prev[j];
|
|
97
|
+
if (p.id.startsWith("~") && p.type === el.type && boxesEqual(p.box, el.box)) {
|
|
98
|
+
matches[i] = j;
|
|
99
|
+
prevUnmatched.delete(j);
|
|
100
|
+
break;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
// Pass 3: remaining no-id elements match remaining no-id prev of the same
|
|
105
|
+
// type in order (k-th unmatched text ↔ k-th unmatched text).
|
|
106
|
+
next.forEach((el, i) => {
|
|
107
|
+
if (el.id || matches[i] !== undefined)
|
|
108
|
+
return;
|
|
109
|
+
for (const j of prevUnmatched) {
|
|
110
|
+
const p = prev[j];
|
|
111
|
+
if (p.id.startsWith("~") && p.type === el.type) {
|
|
112
|
+
matches[i] = j;
|
|
113
|
+
prevUnmatched.delete(j);
|
|
114
|
+
break;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
const elements = next.map((el, i) => {
|
|
119
|
+
const j = matches[i];
|
|
120
|
+
if (j !== undefined) {
|
|
121
|
+
const p = prev[j];
|
|
122
|
+
return buildFrameElement(el, el.id ?? p.id, classify(p, el));
|
|
123
|
+
}
|
|
124
|
+
return buildFrameElement(el, el.id ?? nextSyntheticId(), "created");
|
|
125
|
+
});
|
|
126
|
+
const removed = [...prevUnmatched].map((j) => prev[j].id);
|
|
127
|
+
return { elements, removed };
|
|
128
|
+
}
|
|
129
|
+
//# sourceMappingURL=differ.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"differ.js","sourceRoot":"","sources":["../../../src/display/scene/differ.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAGH,OAAO,EAAC,UAAU,EAAC,MAAM,SAAS,CAAA;AA+BlC,SAAS,QAAQ,CAAC,IAAkB,EAAE,IAAqB;IACzD,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,GAAG,CAAC;QAAE,OAAO,OAAO,CAAA;IACnD,IAAI,IAAI,CAAC,WAAW,KAAK,IAAI,CAAC,WAAW;QAAE,OAAO,SAAS,CAAA;IAC3D,OAAO,WAAW,CAAA;AACpB,CAAC;AAED;;;;;;;;GAQG;AACH,SAAS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,GAAG,CAAC,IAAI,CAAC,CAAC,IAAI,KAAK,EAAE,CAAC,IAAI,EAAE,CAAC;gBAC/C,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAA;gBACd,aAAa,CAAC,MAAM,CAAC,CAAC,CAAC,CAAA;gBACvB,MAAK;YACP,CAAC;QACH,CAAC;IACH,CAAC,CAAC,CAAA;IAEF,MAAM,QAAQ,GAAmB,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,EAAE;QAClD,MAAM,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAA;QACpB,IAAI,CAAC,KAAK,SAAS,EAAE,CAAC;YACpB,MAAM,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAAA;YACjB,OAAO,iBAAiB,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,IAAI,CAAC,CAAC,EAAE,EAAE,QAAQ,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAA;QAC9D,CAAC;QACD,OAAO,iBAAiB,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,IAAI,eAAe,EAAE,EAAE,SAAS,CAAC,CAAA;IACrE,CAAC,CAAC,CAAA;IAEF,MAAM,OAAO,GAAG,CAAC,GAAG,aAAa,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAA;IACzD,OAAO,EAAC,QAAQ,EAAE,OAAO,EAAC,CAAA;AAC5B,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Scene processing — validate → clamp → budget → wrap. Everything here is
|
|
3
|
+
* generic; device variation enters only through the capabilities block and the
|
|
4
|
+
* display profile (data, not code). Spec §5.
|
|
5
|
+
*
|
|
6
|
+
* Never rejects a frame: offending elements are dropped per-element and
|
|
7
|
+
* reported via `dropped` / `degraded` (design doc §3.4.6; spec §4 refines the
|
|
8
|
+
* design doc's image "reject" to per-element drop).
|
|
9
|
+
*/
|
|
10
|
+
import type { DisplayProfile } from "../profiles/types";
|
|
11
|
+
import type { DiffableElement } from "./differ";
|
|
12
|
+
import type { SceneDisplayCapabilities, SceneElementInput } from "./types";
|
|
13
|
+
export interface ProcessedScene {
|
|
14
|
+
elements: DiffableElement[];
|
|
15
|
+
degraded: boolean;
|
|
16
|
+
dropped: string[];
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Text the host cannot wrap: a script the measurer has no widths or break
|
|
20
|
+
* rules for (Thai has no spaces between words, for one). It is passed through
|
|
21
|
+
* unwrapped and the device's text engine lays it out in the box.
|
|
22
|
+
*/
|
|
23
|
+
export declare function wrapsOnDevice(text: string): boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Line height for box-height→line-count math — ONLY when the profile declares
|
|
26
|
+
* a calibrated `lineHeightPx`. Deriving one from full-canvas numbers proved
|
|
27
|
+
* wrong on hardware (288/8=36px clipped the G2 nav instruction to one line;
|
|
28
|
+
* the real container line height is smaller). Without calibration we return
|
|
29
|
+
* null and the wrap step skips host-side height clipping entirely — text wraps
|
|
30
|
+
* to the box WIDTH and the firmware clips vertically in-box, which is exactly
|
|
31
|
+
* the legacy behavior.
|
|
32
|
+
*/
|
|
33
|
+
export declare function profileLineHeightPx(profile: DisplayProfile, _canvasHeight: number): number | null;
|
|
34
|
+
/**
|
|
35
|
+
* Process a raw scene against a device's capabilities + profile. Output is
|
|
36
|
+
* diff-ready (text pre-wrapped, boxes clamped, content hashed) and reflects
|
|
37
|
+
* exactly what will be sent — the diff baseline is post-processed by design
|
|
38
|
+
* (spec §4).
|
|
39
|
+
*/
|
|
40
|
+
export declare function processScene(input: readonly SceneElementInput[], caps: SceneDisplayCapabilities, profile: DisplayProfile): ProcessedScene;
|
|
41
|
+
//# sourceMappingURL=process.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"process.d.ts","sourceRoot":"","sources":["../../../src/display/scene/process.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAMH,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;AAkBD;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAKnD;AAmDD;;;;;;;;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,CAoThB"}
|