usedComponentNames function
Names of the components to keep, per the recorded usages.
Null recordings (the toolchain recorded nothing) keeps everything. So
does a recording that references none of the generated _new externs:
an app that uses no component at all would not depend on this package, so
that pattern means the recording missed the FFI tear-offs — dropping every
component on that evidence would break the app.
Implementation
Set<String> usedComponentNames(
Recordings? recordings,
List<Map<String, Object?>> components,
) {
final all = {for (final c in components) c['name'] as String};
if (recordings == null) return all;
final referenced = {
for (final d in recordings.calls.keys) '${d.library.uri}#${d.name}',
};
final used = {
for (final c in components)
if (referenced.contains('${c['library']}#${c['newExtern']}'))
c['name'] as String,
};
return used.isEmpty ? all : used;
}