decodeCanvasScene function
Decodes current persisted JSON: strict wire checks, decoding, then integrity.
Upgrade historical JSON explicitly first. Malformed wire data throws FormatException; invalid runtime values throw ArgumentError. Error text is diagnostic context, not a stable code, path, or ordering contract.
Implementation
CanvasSceneDocument decodeCanvasScene(Map<String, Object?> json) {
validateSceneV3Json(json);
final payload = Map<String, dynamic>.from(json)..remove('sceneFormatVersion');
final scene = CanvasSceneDocument.fromJson(payload);
requireCanvasSceneIntegrity(scene);
return scene;
}