Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ app.*.map.json
/android/app/profile
/android/app/release
/rust/target/
/packages/p4k_upgrader/target/
/rust/artifacts/
/artifacts/
/lib/generated/l10n_temp.json
Expand Down
3 changes: 2 additions & 1 deletion assets/web_script.js
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,7 @@ async function getRSILauncherToken(channelId) {
window.ipc.postMessage(JSON.stringify({
action: 'webview_rsi_login_success', data: {
'webToken': rsiToken,
'webCookie': document.cookie,
'claims': claimsData,
'authToken': TokenData,
'releaseInfo': releaseDataJson,
Expand All @@ -369,4 +370,4 @@ function SCTShowToast(message) {
document.body.removeChild(m)
}, d * 1000);
}, 3500);
}
}
2 changes: 1 addition & 1 deletion lib/app.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

281 changes: 281 additions & 0 deletions lib/common/rust/api/p4k_upgrader_api.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,281 @@
// 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';

// These functions are ignored because they are not marked as `pub`: `cancelled`, `done`, `error`, `to_upgrader_config`
// These function are ignored because they are on traits that is not defined in current crate (put an empty `#[frb]` on it to unignore): `clone`, `clone`, `clone`, `clone`, `fmt`, `fmt`, `fmt`, `fmt`, `from`

List<String> p4KUpgraderDefaultObjectPathTemplates() => RustLib.instance.api
.crateApiP4KUpgraderApiP4KUpgraderDefaultObjectPathTemplates();

Future<P4kUpgraderEstimateReport> p4KUpgraderEstimate({
required P4kUpgraderConfig config,
}) => RustLib.instance.api.crateApiP4KUpgraderApiP4KUpgraderEstimate(
config: config,
);

Future<void> p4KUpgraderVerify({required P4kUpgraderConfig config}) => RustLib
.instance
.api
.crateApiP4KUpgraderApiP4KUpgraderVerify(config: config);

Future<String> p4KUpgraderUpdate({required P4kUpgraderConfig config}) => RustLib
.instance
.api
.crateApiP4KUpgraderApiP4KUpgraderUpdate(config: config);

Stream<P4kUpgraderProgressEvent> p4KUpgraderUpdateWithProgress({
required P4kUpgraderConfig config,
}) => RustLib.instance.api.crateApiP4KUpgraderApiP4KUpgraderUpdateWithProgress(
config: config,
);

void p4KUpgraderSetDownloadThreads({required BigInt threads}) => RustLib
.instance
.api
.crateApiP4KUpgraderApiP4KUpgraderSetDownloadThreads(threads: threads);

void p4KUpgraderPause() =>
RustLib.instance.api.crateApiP4KUpgraderApiP4KUpgraderPause();

void p4KUpgraderResume() =>
RustLib.instance.api.crateApiP4KUpgraderApiP4KUpgraderResume();

void p4KUpgraderCancel() =>
RustLib.instance.api.crateApiP4KUpgraderApiP4KUpgraderCancel();

void p4KUpgraderClearManifestCache() =>
RustLib.instance.api.crateApiP4KUpgraderApiP4KUpgraderClearManifestCache();

class P4kUpgraderConfig {
final String manifestSource;
final List<String> mirrorBases;
final List<String> officialBases;
final String p4KBaseUrl;
final String p4KBaseVerificationUrl;
final List<String> objectPathTemplates;
final String requestCookie;
final String rsiToken;
final String cacheDir;
final String gameDir;
final bool updateP4K;
final bool updateLooseFiles;
final bool inplaceUpdateP4K;
final bool fallbackRebuildOnInplaceVerifyFailure;
final bool replaceExistingP4K;
final bool verifyAfterAssemble;
final bool verifyCigStructure;
final BigInt? maxEntries;

const P4kUpgraderConfig({
required this.manifestSource,
required this.mirrorBases,
required this.officialBases,
required this.p4KBaseUrl,
required this.p4KBaseVerificationUrl,
required this.objectPathTemplates,
required this.requestCookie,
required this.rsiToken,
required this.cacheDir,
required this.gameDir,
required this.updateP4K,
required this.updateLooseFiles,
required this.inplaceUpdateP4K,
required this.fallbackRebuildOnInplaceVerifyFailure,
required this.replaceExistingP4K,
required this.verifyAfterAssemble,
required this.verifyCigStructure,
this.maxEntries,
});

@override
int get hashCode =>
manifestSource.hashCode ^
mirrorBases.hashCode ^
officialBases.hashCode ^
p4KBaseUrl.hashCode ^
p4KBaseVerificationUrl.hashCode ^
objectPathTemplates.hashCode ^
requestCookie.hashCode ^
rsiToken.hashCode ^
cacheDir.hashCode ^
gameDir.hashCode ^
updateP4K.hashCode ^
updateLooseFiles.hashCode ^
inplaceUpdateP4K.hashCode ^
fallbackRebuildOnInplaceVerifyFailure.hashCode ^
replaceExistingP4K.hashCode ^
verifyAfterAssemble.hashCode ^
verifyCigStructure.hashCode ^
maxEntries.hashCode;

@override
bool operator ==(Object other) =>
identical(this, other) ||
other is P4kUpgraderConfig &&
runtimeType == other.runtimeType &&
manifestSource == other.manifestSource &&
mirrorBases == other.mirrorBases &&
officialBases == other.officialBases &&
p4KBaseUrl == other.p4KBaseUrl &&
p4KBaseVerificationUrl == other.p4KBaseVerificationUrl &&
objectPathTemplates == other.objectPathTemplates &&
requestCookie == other.requestCookie &&
rsiToken == other.rsiToken &&
cacheDir == other.cacheDir &&
gameDir == other.gameDir &&
updateP4K == other.updateP4K &&
updateLooseFiles == other.updateLooseFiles &&
inplaceUpdateP4K == other.inplaceUpdateP4K &&
fallbackRebuildOnInplaceVerifyFailure ==
other.fallbackRebuildOnInplaceVerifyFailure &&
replaceExistingP4K == other.replaceExistingP4K &&
verifyAfterAssemble == other.verifyAfterAssemble &&
verifyCigStructure == other.verifyCigStructure &&
maxEntries == other.maxEntries;
}

class P4kUpgraderEstimateEntry {
final String name;
final String sha256;
final BigInt compressedSize;

const P4kUpgraderEstimateEntry({
required this.name,
required this.sha256,
required this.compressedSize,
});

@override
int get hashCode => name.hashCode ^ sha256.hashCode ^ compressedSize.hashCode;

@override
bool operator ==(Object other) =>
identical(this, other) ||
other is P4kUpgraderEstimateEntry &&
runtimeType == other.runtimeType &&
name == other.name &&
sha256 == other.sha256 &&
compressedSize == other.compressedSize;
}

class P4kUpgraderEstimateReport {
final BigInt manifestEntries;
final bool baseDownloadRequired;
final BigInt baseDownloadBytes;
final BigInt p4KEntriesRequiringDownload;
final BigInt looseEntriesRequiringDownload;
final BigInt totalEntriesRequiringDownload;
final BigInt payloadDownloadBytes;
final double payloadDownloadGbDecimal;
final double payloadDownloadGib;

/// E: static "full-download" reference value — the manifest's
/// cumulative non-loose compressed_size. Used by the UI for the
/// "总下载大小" display row. NOT diffed against cached bytes; the
/// differential lives in `payload_download_bytes` (unchanged).
final BigInt totalDownloadBytes;
final List<P4kUpgraderEstimateEntry> entries;

const P4kUpgraderEstimateReport({
required this.manifestEntries,
required this.baseDownloadRequired,
required this.baseDownloadBytes,
required this.p4KEntriesRequiringDownload,
required this.looseEntriesRequiringDownload,
required this.totalEntriesRequiringDownload,
required this.payloadDownloadBytes,
required this.payloadDownloadGbDecimal,
required this.payloadDownloadGib,
required this.totalDownloadBytes,
required this.entries,
});

@override
int get hashCode =>
manifestEntries.hashCode ^
baseDownloadRequired.hashCode ^
baseDownloadBytes.hashCode ^
p4KEntriesRequiringDownload.hashCode ^
looseEntriesRequiringDownload.hashCode ^
totalEntriesRequiringDownload.hashCode ^
payloadDownloadBytes.hashCode ^
payloadDownloadGbDecimal.hashCode ^
payloadDownloadGib.hashCode ^
totalDownloadBytes.hashCode ^
entries.hashCode;

@override
bool operator ==(Object other) =>
identical(this, other) ||
other is P4kUpgraderEstimateReport &&
runtimeType == other.runtimeType &&
manifestEntries == other.manifestEntries &&
baseDownloadRequired == other.baseDownloadRequired &&
baseDownloadBytes == other.baseDownloadBytes &&
p4KEntriesRequiringDownload == other.p4KEntriesRequiringDownload &&
looseEntriesRequiringDownload ==
other.looseEntriesRequiringDownload &&
totalEntriesRequiringDownload ==
other.totalEntriesRequiringDownload &&
payloadDownloadBytes == other.payloadDownloadBytes &&
payloadDownloadGbDecimal == other.payloadDownloadGbDecimal &&
payloadDownloadGib == other.payloadDownloadGib &&
totalDownloadBytes == other.totalDownloadBytes &&
entries == other.entries;
}

class P4kUpgraderProgressEvent {
final String phase;
final String name;
final BigInt current;
final BigInt total;
final BigInt downloadedBytes;
final BigInt totalBytes;
final BigInt activeDownloads;
final BigInt threadLimit;
final String message;

const P4kUpgraderProgressEvent({
required this.phase,
required this.name,
required this.current,
required this.total,
required this.downloadedBytes,
required this.totalBytes,
required this.activeDownloads,
required this.threadLimit,
required this.message,
});

@override
int get hashCode =>
phase.hashCode ^
name.hashCode ^
current.hashCode ^
total.hashCode ^
downloadedBytes.hashCode ^
totalBytes.hashCode ^
activeDownloads.hashCode ^
threadLimit.hashCode ^
message.hashCode;

@override
bool operator ==(Object other) =>
identical(this, other) ||
other is P4kUpgraderProgressEvent &&
runtimeType == other.runtimeType &&
phase == other.phase &&
name == other.name &&
current == other.current &&
total == other.total &&
downloadedBytes == other.downloadedBytes &&
totalBytes == other.totalBytes &&
activeDownloads == other.activeDownloads &&
threadLimit == other.threadLimit &&
message == other.message;
}
2 changes: 1 addition & 1 deletion lib/common/rust/api/unp4k_api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import 'package:flutter_rust_bridge/flutter_rust_bridge_for_generated.dart';
import 'package:freezed_annotation/freezed_annotation.dart' hide protected;
part 'unp4k_api.freezed.dart';

// These functions are ignored because they are not marked as `pub`: `build_preview_candidates`, `build_wav_from_pcm`, `collect_dds_part_paths`, `collect_dds_parts`, `compute_dds_mip_sizes`, `compute_waveform_from_pcm`, `compute_waveform_from_wav`, `dcb_record_index_by_path`, `dcb_record_path`, `dcb_record_xml`, `dds_base_path`, `dds_block_bytes_dxgi`, `dds_block_bytes`, `dds_payload_layout`, `decode_dds_image`, `decode_image_for_preview`, `decode_uncompressed_dds`, `ensure_files_loaded`, `estimate_duration_from_wav`, `extract_masked_component`, `has_dds_signature`, `le_u32`, `model_dcb_cache_key`, `normalize_p4k_path`, `normalize_slashes`, `p4k_get_entry`, `reconstruct_dds_stream`, `sanitize_dcb_export_file_name`
// These functions are ignored because they are not marked as `pub`: `build_preview_candidates`, `collect_dds_part_paths`, `collect_dds_parts`, `compute_dds_mip_sizes`, `compute_waveform_from_pcm`, `dcb_record_index_by_path`, `dcb_record_path`, `dcb_record_xml`, `dds_base_path`, `dds_block_bytes_dxgi`, `dds_block_bytes`, `dds_payload_layout`, `decode_dds_image`, `decode_image_for_preview`, `decode_uncompressed_dds`, `ensure_files_loaded`, `extract_masked_component`, `has_dds_signature`, `le_u32`, `model_dcb_cache_key`, `normalize_p4k_path`, `normalize_slashes`, `p4k_get_entry`, `reconstruct_dds_stream`, `sanitize_dcb_export_file_name`
// These function are ignored because they are on traits that is not defined in current crate (put an empty `#[frb]` on it to unignore): `clone`, `fmt`

/// 打开 P4K 文件(仅打开,不读取文件列表)
Expand Down
7 changes: 7 additions & 0 deletions lib/common/rust/api/webview_api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,13 @@ void webviewSetWindowPosition({
WebViewNavigationState webviewGetState({required String id}) =>
RustLib.instance.api.crateApiWebviewApiWebviewGetState(id: id);

/// Get cookies for a URL from the WebView cookie store, including HttpOnly cookies.
String webviewGetCookiesForUrl({required String id, required String url}) =>
RustLib.instance.api.crateApiWebviewApiWebviewGetCookiesForUrl(
id: id,
url: url,
);

/// Check if the WebView is closed
bool webviewIsClosed({required String id}) =>
RustLib.instance.api.crateApiWebviewApiWebviewIsClosed(id: id);
Expand Down
Loading