Skip to content
Merged
15 changes: 15 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,16 +75,22 @@ editor/core/
etc2.ts cf 28 (ETC2 RGBA8) block codec
budget.ts what a screen takes in a Watch 3 Pro's RAM (SCREEN_BUDGET)
fit.ts fitForWatch: the file shrunk in RAM before it goes to a watch
compat.ts which watch and firmware a face may go to: widgets (raw bytes), A8, ETC2
raw.ts Face/FaceNode/Resource + TAG + byte primitives
document/ # the document the editor edits
doc.ts Doc/Layer/Screen, meta + condition decoding, fromLegacy/toLegacy
edits.ts pure Doc -> Doc edits: add/remove/move/group/patch
factory.ts the layers the editor creates from scratch, and a blank document
sources.ts data sources: id labels, Sim, idValue, slot/condition helpers
proc.ts the Watch 3 Pro's procedural widgets (0x82 + 0x5c) as layers
support.ts where the open face can go — the editor's note, by compat.ts's rule
pro2.ts the converted copy Export for Watch Pro 2 downloads
render/
render.ts draw a screen from a Doc: per-kind draw functions + group auto-layout
canvas.ts renderer types (Ctx/Point/Size/LayerHit/ImageStore)
arc.ts progress rings: 0x5a/0x5b spec, fill fraction, both draw paths
proc-scene.ts types 4..7's layout, a port of cmf-watch-sdk's wfproc.rs — change them together
proc.ts the simulator's values fed to that layout, and its drawing
pixels.ts asset pixels: decode, resize/adjust, accent tint, previews
screen.ts screen and panel dimensions
overlay.ts editor chrome over a screen: selection boxes, handles, snap guides
Expand All @@ -101,6 +107,15 @@ device/lib/
wp2.ts # what the App Loader stub reports: its release, the loader, the apps by slot
```

Every watchface install ends in `flashFx` (`ble.model`): `fitForWatch`, `assertFlashable`, then
`assertWatchCompat` (`core/format/compat.ts`) on the bytes that go out. The last one reads the raw
file as the firmware's parser does, because a wrong verdict is a boot loop: never move it onto
`parseBin`'s tree, and don't add a way to send a face around it. `PRO2_FACES_STUB` stays null
until a stub release that draws types 4..7 has its number reserved in cmf-watch-sdk and is tried
on a real watch, and a Watch Pro 2 gets no cf 14 until that is seen working on one. A procedural
layer's rules (fixed image count, type 4 doesn't move, no rescale) live in `edits.ts` `procPatch`
and `overlay.ts` `resizable`.

`Face`/`FaceNode` are the file's own shape, not the editor's: `parseBin` produces them,
`fromLegacy` turns them into a `Doc`, `toLegacy` turns one back, and the importers build them
because that is the cheapest target to convert into. Nothing else should touch them — the editor
Expand Down
36 changes: 36 additions & 0 deletions docs/cmf-protocol.md
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,42 @@ undocumented beyond this note. If a face is known (from the real device/app) to
color but the editor doesn't offer/apply it, check `meta[7]` on the specific widget by hand
first — that's the only thing that's mattered so far.

### Watch 3 Pro procedural widgets (0x82 + 0x5c)

A `0x82` widget's first child is its struct (tag 1); a `0x5c` child holds the type as a u16 at +0
and, for type 6, the panel as a u8 at +0x14. Both bodies are leaves: never descend into them.

| type | face | what it draws | images |
| ---- | ---------------- | ------------------------------------------------------------- | --------------------------- |
| 4 | Rainbow Lollipop | the ring under the finger, around the screen's centre | none |
| 5 | Briqbot | clips at 33 ms a frame (0..39, 40..89, 90..158), tap for next | 159 |
| 6 | DataPulse | panel 0 weather, 1 heart rate, 2 SpO2, 3 stress, 4 sleep | 88 for panel 0, 13 for rest |
| 7 | Luminous Beam | percent of the calorie goal, three rotated digits | 10 |

The layout is in `core/render/proc-scene.ts`. Where each type may be installed is in
`core/format/compat.ts`, and it is a boot-loop matter:

- both firmwares compare the u16 against a table ending in `0xffff` with a loop that stops at
`0xff`. A Watch Pro 2 (1.0.0.73) has types 0..3, a Watch 3 Pro (1.0.1.77) 0..7. A type past the
table calls whatever matches further on (8 and `0xffff` fault both in the emulator) or, by
chance, nothing (12). Don't rely on the chance.
- the parser looks the first image up at the widget's fixed offset +0x15 from the struct node's
start, whatever that struct's length. A Pro 2 drops a type 4 that has no list there. A short
struct (18 bytes, no 2 bytes of padding) followed by a condition does have one as far as the
firmware is concerned, and boot-loops it: keep the `0000` tail.

A Watch Pro 2 is also refused any cf 14 (A8) resource, the thumbnail included, until A8 has been
seen on a real one: the emulator stops on faces that use it. Export for Watch Pro 2 re-encodes it as
cf 5.

Sources only a Watch 3 Pro has run 0x8e..0x9d. Known: `0x93` the minutes of last night's sleep,
`0x99` the number of the face's colour theme. A themed layer (meta[7] = 4) takes the theme the
wearer picked, else the palette entry numbered by meta[4]; the two watches' palettes differ (Pro 2
0x101FF59C, ten colours; 3 Pro 0x10235316, seven), and FMC renumbers neither.

Colours in the 3 Pro emulator's frames are no reference for tinted layers: they come out with red
and blue swapped against the palette and the factory thumbnails.

### Hard resource-packing rule

**Every node's `images` array must reference _consecutive_ resource-array indices.**
Expand Down
6 changes: 5 additions & 1 deletion src/lib/modules/device/components/dev-sheet.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@
{#if firmware}
<div class="disclaimer" role="note">
<Icon name="warning" size={20} />
<span>{$t.firmwareRisk}</span>
<span>{$t.firmwareRisk} <span class="rollback">{$t.rollbackRisk}</span></span>
</div>
<label class="accept">
<Checkbox checked={$riskAccepted} onChange={(v) => riskAcceptedSet(v)} />
Expand Down Expand Up @@ -206,6 +206,10 @@
flex: none;
}
}
.rollback {
display: block;
margin-top: 0.5rem;
}
.accept {
display: flex;
align-items: center;
Expand Down
10 changes: 10 additions & 0 deletions src/lib/modules/device/i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ export const t = dict(
fileMeta: (kb: string, time: string) => `${kb} KB, modified ${time}`,
firmwareRisk:
"A firmware image can brick the watch. Battery at 50% or more, on the charger, tab open until it's done.",
rollbackRisk:
"Before installing stock or older firmware, switch to a built-in face and delete Watch 3 Pro faces with animated or data widgets from the watch: older firmware can restart in a loop on them.",
acceptRisk: "I accept the risk",
installingOnWatch: "Installing on the watch",
isOnWatch: (name: string) => `${name} is on the watch.`,
Expand Down Expand Up @@ -196,6 +198,8 @@ export const t = dict(
fileMeta: (kb: string, time: string) => `${kb} КБ, изменён в ${time}`,
firmwareRisk:
"Образ прошивки может превратить часы в кирпич. Заряд от 50%, часы на зарядке, вкладка открыта до конца установки.",
rollbackRisk:
"Перед установкой стоковой или более старой прошивки включите встроенный циферблат и удалите с часов циферблаты Watch 3 Pro с анимацией и виджетами данных: на старой прошивке часы могут зациклиться на перезагрузке.",
acceptRisk: "Я принимаю риск",
installingOnWatch: "Установка на часы",
isOnWatch: (name: string) => `«${name}» уже на часах.`,
Expand Down Expand Up @@ -317,6 +321,8 @@ export const t = dict(
fileMeta: (kb: string, time: string) => `${kb} КБ, змінено о ${time}`,
firmwareRisk:
"Образ прошивки може перетворити годинник на цеглину. Заряд від 50%, годинник на зарядці, вкладка відкрита до кінця встановлення.",
rollbackRisk:
"Перед встановленням стокової або старішої прошивки увімкніть вбудований циферблат і видаліть з годинника циферблати Watch 3 Pro з анімацією та віджетами даних: на старій прошивці годинник може циклічно перезавантажуватися.",
acceptRisk: "Я приймаю ризик",
installingOnWatch: "Встановлення на годинник",
isOnWatch: (name: string) => `«${name}» уже на годиннику.`,
Expand Down Expand Up @@ -438,6 +444,8 @@ export const t = dict(
fileMeta: (kb: string, time: string) => `${kb} KB, modificado a las ${time}`,
firmwareRisk:
"Una imagen de firmware puede dejar el reloj inservible. Batería al 50 % o más, en el cargador y la pestaña abierta hasta que termine.",
rollbackRisk:
"Antes de instalar firmware original o anterior, cambia a una esfera integrada y borra del reloj las esferas del Watch 3 Pro con animaciones o widgets de datos: con un firmware anterior el reloj puede reiniciarse en bucle.",
acceptRisk: "Acepto el riesgo",
installingOnWatch: "Instalando en el reloj",
isOnWatch: (name: string) => `${name} ya está en el reloj.`,
Expand Down Expand Up @@ -558,6 +566,8 @@ export const t = dict(
fileMeta: (kb: string, time: string) => `${kb} KB, ${time} पर बदली गई`,
firmwareRisk:
"फ़र्मवेयर इमेज घड़ी को हमेशा के लिए खराब (ब्रिक) कर सकती है। बैटरी 50% या ज़्यादा हो, घड़ी चार्जर पर हो, और काम पूरा होने तक टैब खुला रहे।",
rollbackRisk:
"स्टॉक या पुराना फ़र्मवेयर इंस्टॉल करने से पहले कोई बिल्ट-इन फ़ेस चुनें और Watch 3 Pro के एनिमेशन या डेटा विजेट वाले फ़ेस घड़ी से हटा दें: पुराने फ़र्मवेयर पर घड़ी बार-बार रीस्टार्ट हो सकती है।",
acceptRisk: "जोखिम मुझे मंज़ूर है",
installingOnWatch: "घड़ी पर इंस्टॉल हो रहा है",
isOnWatch: (name: string) => `${name} घड़ी पर है।`,
Expand Down
Loading
Loading