resolve method
Future<PublishLayout>
resolve(
- PublishLayout layout, {
- String projectId = '',
- ThemeTokens? theme,
layout with each managed instance on the version its channel offers
project projectId now, built with the instance's customization and
theme (the project's tokens); an instance stays on its snapshot when
nothing newer applies or anything fails.
Implementation
Future<PublishLayout> resolve(PublishLayout layout, {String projectId = '', ThemeTokens? theme}) async {
final instances = managedInstancesOf(layout.document).toList();
if (instances.isEmpty) return layout;
var document = layout.document;
var variables = layout.variables;
for (final top in instances) {
try {
final link = top.component!;
final master = await _master(link.id);
if (master == null) continue;
final target = managedUpdateTarget(link, master, projectId: projectId, sdkVersion: sdkVersion);
if (target == null) continue;
final version = await _version(link.id, target);
if (version == null) continue;
final current = document[top.id];
if (current == null) continue;
final build = buildManagedInstance(
version: version,
topId: top.id,
ref: current.component!.managed!,
layout: current.layout,
theme: theme,
catalog: document.catalog,
);
document = replaceManagedInstance(document, top.id, build);
variables = _declare(variables, _canvasOf(document, top.id), build.variables);
} catch (e) {
onError?.call(top.id, e);
}
}
return layout.copyWith(document: document, variables: variables);
}