twonly-app/lib/core/bridge/webxdc.dart
2026-09-05 01:59:17 +02:00

260 lines
7.4 KiB
Dart

// This file is automatically generated, so please do not edit it.
// @generated by `flutter_rust_bridge`@ 2.12.0.
// ignore_for_file: invalid_use_of_internal_member, unused_import, unnecessary_import
import '../frb_generated.dart';
import 'package:flutter_rust_bridge/flutter_rust_bridge_for_generated.dart';
/// Refreshes the store listing. Metadata only; no bundle is fetched.
Future<void> refreshCatalog() =>
RustLib.instance.api.crateBridgeWebxdcRefreshCatalog();
/// What the in-app store offers, newest version of each app only.
///
/// `languages` is what the UI prefers, most preferred first. Descriptions are
/// cached in every language the catalog carries and picked here, so which
/// language a user reads is never sent anywhere.
Future<List<WebxdcStoreApp>> catalog({required List<String> languages}) =>
RustLib.instance.api.crateBridgeWebxdcCatalog(languages: languages);
/// Places an app into a chat and returns the id of the message that carries it.
Future<String> createInstance({
required String groupId,
required String appId,
required PlatformInt64 version,
}) => RustLib.instance.api.crateBridgeWebxdcCreateInstance(
groupId: groupId,
appId: appId,
version: version,
);
Future<WebxdcInstanceInfo?> instance({required String instanceId}) =>
RustLib.instance.api.crateBridgeWebxdcInstance(instanceId: instanceId);
/// Downloads and verifies the bundle if it is not already on disk, and returns
/// where it landed. Called when the user starts an app, never on message
/// arrival: a message must not be able to make a device fetch anything.
Future<String> prepareBundle({required String instanceId}) =>
RustLib.instance.api.crateBridgeWebxdcPrepareBundle(instanceId: instanceId);
/// Answers one request the webview made for a file inside the bundle.
///
/// The platform shim has already established that the request came from this
/// instance's own origin; everything after that is decided here.
Future<WebxdcResponse> serve({
required String instanceId,
required String requestPath,
}) => RustLib.instance.api.crateBridgeWebxdcServe(
instanceId: instanceId,
requestPath: requestPath,
);
Future<List<WebxdcUpdateEntry>> updatesAfter({
required String instanceId,
required PlatformInt64 serial,
}) => RustLib.instance.api.crateBridgeWebxdcUpdatesAfter(
instanceId: instanceId,
serial: serial,
);
Future<void> sendUpdate({
required String instanceId,
required String payload,
String? info,
String? href,
String? summary,
String? document,
}) => RustLib.instance.api.crateBridgeWebxdcSendUpdate(
instanceId: instanceId,
payload: payload,
info: info,
href: href,
summary: summary,
document: document,
);
/// The address the running app sees for a participant. Stable inside one
/// instance and unrelated to the same user's address in any other.
Future<String> addressFor({
required String instanceId,
required PlatformInt64 userId,
}) => RustLib.instance.api.crateBridgeWebxdcAddressFor(
instanceId: instanceId,
userId: userId,
);
/// Drops an instance and its whole update log, returning the origin whose web
/// storage the platform layer still has to clear. The log is only half the
/// state: an app is free to keep everything in `localStorage`, which no
/// database delete reaches.
Future<String?> deleteInstance({required String instanceId}) => RustLib
.instance
.api
.crateBridgeWebxdcDeleteInstance(instanceId: instanceId);
class WebxdcInstanceInfo {
final String instanceId;
final String groupId;
final String appId;
final PlatformInt64 version;
/// The webview host this instance is served from. Unique per instance, so
/// the browser's own origin model keeps one app's stored data out of reach
/// of every other app.
final String originToken;
final String? summary;
final String? document;
const WebxdcInstanceInfo({
required this.instanceId,
required this.groupId,
required this.appId,
required this.version,
required this.originToken,
this.summary,
this.document,
});
@override
int get hashCode =>
instanceId.hashCode ^
groupId.hashCode ^
appId.hashCode ^
version.hashCode ^
originToken.hashCode ^
summary.hashCode ^
document.hashCode;
@override
bool operator ==(Object other) =>
identical(this, other) ||
other is WebxdcInstanceInfo &&
runtimeType == other.runtimeType &&
instanceId == other.instanceId &&
groupId == other.groupId &&
appId == other.appId &&
version == other.version &&
originToken == other.originToken &&
summary == other.summary &&
document == other.document;
}
class WebxdcResponse {
final int status;
final String mime;
final List<String> headerNames;
final List<String> headerValues;
final Uint8List body;
const WebxdcResponse({
required this.status,
required this.mime,
required this.headerNames,
required this.headerValues,
required this.body,
});
@override
int get hashCode =>
status.hashCode ^
mime.hashCode ^
headerNames.hashCode ^
headerValues.hashCode ^
body.hashCode;
@override
bool operator ==(Object other) =>
identical(this, other) ||
other is WebxdcResponse &&
runtimeType == other.runtimeType &&
status == other.status &&
mime == other.mime &&
headerNames == other.headerNames &&
headerValues == other.headerValues &&
body == other.body;
}
class WebxdcStoreApp {
final String appId;
final PlatformInt64 version;
/// Already in the reader's language, like the description.
final String name;
/// One line about the app, already in the reader's language.
final String? description;
final String? sourceCodeUrl;
final Uint8List? icon;
final PlatformInt64 bundleBytes;
const WebxdcStoreApp({
required this.appId,
required this.version,
required this.name,
this.description,
this.sourceCodeUrl,
this.icon,
required this.bundleBytes,
});
@override
int get hashCode =>
appId.hashCode ^
version.hashCode ^
name.hashCode ^
description.hashCode ^
sourceCodeUrl.hashCode ^
icon.hashCode ^
bundleBytes.hashCode;
@override
bool operator ==(Object other) =>
identical(this, other) ||
other is WebxdcStoreApp &&
runtimeType == other.runtimeType &&
appId == other.appId &&
version == other.version &&
name == other.name &&
description == other.description &&
sourceCodeUrl == other.sourceCodeUrl &&
icon == other.icon &&
bundleBytes == other.bundleBytes;
}
class WebxdcUpdateEntry {
final PlatformInt64 serial;
final String payload;
final String? info;
final String? href;
/// `None` when this device sent it.
final PlatformInt64? senderId;
const WebxdcUpdateEntry({
required this.serial,
required this.payload,
this.info,
this.href,
this.senderId,
});
@override
int get hashCode =>
serial.hashCode ^
payload.hashCode ^
info.hashCode ^
href.hashCode ^
senderId.hashCode;
@override
bool operator ==(Object other) =>
identical(this, other) ||
other is WebxdcUpdateEntry &&
runtimeType == other.runtimeType &&
serial == other.serial &&
payload == other.payload &&
info == other.info &&
href == other.href &&
senderId == other.senderId;
}