Class SurfaceSerializer
Serializes surface descriptors to the canonical wire format shared by every port: a compact JSON document plus PNG blobs named by content hash. This class is an internal seam between the core API and the platform bridges -- it is public only because ports live in separate artifacts; apps never call it.
The wire format is versioned ("v": 1) and deterministic: node maps preserve build order,
state maps are emitted with sorted keys, timeline entries are sorted ascending by date and
image names derive from a hash of the PNG bytes (identical art always gets the same name).
-
Method Summary
Modifier and TypeMethodDescriptionstatic StringserializeKind(WidgetKind kind) Serializes a widget kind declaration.static StringserializeLiveActivity(LiveActivityDescriptor descriptor, Map<String, Object> state, Map<String, byte[]> imagesOut) Serializes a live activity descriptor together with its initial state.static StringserializeState(Map<String, Object> state) Serializes a state map with sorted keys.static StringserializeTimeline(String kindId, WidgetTimeline timeline, Map<String, byte[]> imagesOut) Serializes a widget timeline.
-
Method Details
-
serializeTimeline
public static String serializeTimeline(String kindId, WidgetTimeline timeline, Map<String, byte[]> imagesOut) Serializes a widget timeline.
Parameters
kindId: the widget kind id the timeline belongs totimeline: the timeline to serializeimagesOut: receives PNG blobs keyed by registered name
Returns
the timeline JSON
-
serializeLiveActivity
public static String serializeLiveActivity(LiveActivityDescriptor descriptor, Map<String, Object> state, Map<String, byte[]> imagesOut) Serializes a live activity descriptor together with its initial state.
Parameters
descriptor: the descriptor to serializestate: the initial state map, may be nullimagesOut: receives PNG blobs keyed by registered name
Returns
the descriptor JSON
-
serializeState
-
serializeKind
Serializes a widget kind declaration.
Parameters
kind: the kind to serialize
Returns
the kind JSON
-