revDocumentScriptOrder function

List<String> revDocumentScriptOrder(
  1. RevDocument document, {
  2. List<RevLibrarySnapshot> libraries = const [],
})

Links libraries, the snapshots the plan's requests named, into document's export, and returns the payload key of every script and shader it writes, a library's behind its snapshot's key, in the order the riv holds them, which is the order to sign them in.

Implementation

List<String> revDocumentScriptOrder(
  RevDocument document, {
  List<RevLibrarySnapshot> libraries = const [],
}) {
  final encoded = encodeRevLibraries(libraries);
  final source = calloc<Uint8>(encoded.length);
  final response = calloc<_RmlExportResponseStruct>();
  try {
    source.asTypedList(encoded.length).setAll(0, encoded);
    final ok = _revDocumentScriptOrder(
      Pointer.fromAddress(document.address),
      source,
      encoded.length,
      response,
    );
    if (!ok || response.ref.data == nullptr) {
      return const [];
    }
    return decodeRevScriptOrder(
      Uint8List.fromList(response.ref.data.asTypedList(response.ref.size)),
    );
  } finally {
    _freeRmlExport(response);
    calloc.free(response);
    calloc.free(source);
  }
}