feat/update library entries, use isolate for async method
This commit is contained in:
parent
792f8059a0
commit
b40cf595b7
25 changed files with 271 additions and 127 deletions
|
|
@ -443,7 +443,7 @@ class MBridge {
|
|||
}
|
||||
} catch (e) {
|
||||
log("Http error: $e");
|
||||
botToast(e.toString());
|
||||
// botToast(e.toString());
|
||||
return "error";
|
||||
}
|
||||
}
|
||||
|
|
@ -636,7 +636,7 @@ class MBridge {
|
|||
} catch (_) {}
|
||||
}
|
||||
}
|
||||
botToast(e.toString());
|
||||
// botToast(e.toString());
|
||||
throw Exception(e);
|
||||
}
|
||||
}
|
||||
|
|
@ -766,12 +766,17 @@ final List<String> _dateFormats = [
|
|||
"MMM dd,yyyy"
|
||||
];
|
||||
|
||||
void botToast(String title) {
|
||||
void botToast(String title,
|
||||
{int second = 10,
|
||||
double? fontSize,
|
||||
double alignX = 0,
|
||||
double alignY = 0.99}) {
|
||||
BotToast.showSimpleNotification(
|
||||
titleStyle: TextStyle(fontSize: fontSize),
|
||||
onlyOne: true,
|
||||
dismissDirections: [DismissDirection.horizontal, DismissDirection.down],
|
||||
align: const Alignment(0, 0.99),
|
||||
duration: const Duration(seconds: 10),
|
||||
align: Alignment(alignX, alignY),
|
||||
duration: Duration(seconds: second),
|
||||
title: title);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -280,5 +280,8 @@
|
|||
"aniskip_requires_info": "AniSkip يتطلب تتبع الأنمي باستخدام MAL أو Anilist للعمل.",
|
||||
"enable_aniskip": "تمكين AniSkip",
|
||||
"enable_auto_skip": "تمكين التخطي التلقائي",
|
||||
"aniskip_button_timeout": "مهلة زر"
|
||||
"aniskip_button_timeout": "مهلة زر",
|
||||
"fullscreen": "شاشة كاملة",
|
||||
"update_library": "تحديث المكتبة",
|
||||
"updating_library": "جاري تحديث المكتبة"
|
||||
}
|
||||
|
|
@ -280,5 +280,8 @@
|
|||
"aniskip_requires_info": "AniSkip erfordert, dass der Anime mit MAL oder Anilist verfolgt wird, um zu funktionieren.",
|
||||
"enable_aniskip": "AniSkip aktivieren",
|
||||
"enable_auto_skip": "Automatisches Überspringen aktivieren",
|
||||
"aniskip_button_timeout": "Timeout für Taste"
|
||||
"aniskip_button_timeout": "Timeout für Taste",
|
||||
"fullscreen": "Vollbild",
|
||||
"update_library": "Bibliothek aktualisieren",
|
||||
"updating_library": "Bibliothek wird aktualisiert"
|
||||
}
|
||||
|
|
@ -283,5 +283,7 @@
|
|||
"aniskip_button_timeout": "Button timeout",
|
||||
"skip_opening": "Skip opening",
|
||||
"skip_ending": "Skip ending",
|
||||
"fullscreen": "Fullscreen"
|
||||
"fullscreen": "Fullscreen",
|
||||
"update_library": "Update library",
|
||||
"updating_library": "Updating library"
|
||||
}
|
||||
|
|
@ -280,5 +280,8 @@
|
|||
"aniskip_requires_info": "AniSkip requiere que el anime esté registrado en MAL o Anilist para funcionar.",
|
||||
"enable_aniskip": "Habilitar AniSkip",
|
||||
"enable_auto_skip": "Habilitar salto automático",
|
||||
"aniskip_button_timeout": "Tiempo de espera del botón"
|
||||
"aniskip_button_timeout": "Tiempo de espera del botón",
|
||||
"fullscreen": "Pantalla completa",
|
||||
"update_library": "Actualizar biblioteca",
|
||||
"updating_library": "Actualizando biblioteca"
|
||||
}
|
||||
|
|
@ -280,5 +280,8 @@
|
|||
"aniskip_requires_info": "AniSkip requiere que el anime esté registrado en MAL o Anilist para funcionar.",
|
||||
"enable_aniskip": "Habilitar AniSkip",
|
||||
"enable_auto_skip": "Habilitar salto automático",
|
||||
"aniskip_button_timeout": "Tiempo de espera del botón"
|
||||
"aniskip_button_timeout": "Tiempo de espera del botón",
|
||||
"fullscreen": "Pantalla completa",
|
||||
"update_library": "Actualizar biblioteca",
|
||||
"updating_library": "Actualizando biblioteca"
|
||||
}
|
||||
|
|
@ -282,5 +282,7 @@
|
|||
"enable_auto_skip": "Activer le saut automatique",
|
||||
"aniskip_button_timeout": "Délai du bouton",
|
||||
"skip_opening": "Passer l'opening",
|
||||
"skip_ending": "Passer l'ending"
|
||||
"skip_ending": "Passer l'ending",
|
||||
"update_library": "Mettre à jour la bibliothèque",
|
||||
"updating_library": "Mise à jour de la bibliothèque"
|
||||
}
|
||||
|
|
@ -280,5 +280,8 @@
|
|||
"aniskip_requires_info": "AniSkip memerlukan informasi anime dilacak dengan MAL atau Anilist untuk berfungsi.",
|
||||
"enable_aniskip": "Aktifkan AniSkip",
|
||||
"enable_auto_skip": "Aktifkan pengabaian otomatis",
|
||||
"aniskip_button_timeout": "Timeout tombol"
|
||||
"aniskip_button_timeout": "Timeout tombol",
|
||||
"fullscreen": "Layar Penuh",
|
||||
"update_library": "Perbarui perpustakaan",
|
||||
"updating_library": "Memperbarui perpustakaan"
|
||||
}
|
||||
|
|
@ -280,5 +280,8 @@
|
|||
"aniskip_requires_info": "AniSkip richiede che l'anime sia tracciato con MAL o Anilist per funzionare.",
|
||||
"enable_aniskip": "Abilita AniSkip",
|
||||
"enable_auto_skip": "Abilita l'auto-skip",
|
||||
"aniskip_button_timeout": "Timeout del pulsante"
|
||||
"aniskip_button_timeout": "Timeout del pulsante",
|
||||
"fullscreen": "Schermo intero",
|
||||
"update_library": "Aggiorna libreria",
|
||||
"updating_library": "Aggiornamento della libreria"
|
||||
}
|
||||
|
|
@ -280,5 +280,8 @@
|
|||
"aniskip_requires_info": "AniSkip requer que o anime seja rastreado com o MAL ou Anilist para funcionar.",
|
||||
"enable_aniskip": "Ativar AniSkip",
|
||||
"enable_auto_skip": "Ativar auto skip",
|
||||
"aniskip_button_timeout": "Tempo limite do botão"
|
||||
"aniskip_button_timeout": "Tempo limite do botão",
|
||||
"fullscreen": "Tela cheia",
|
||||
"update_library": "Atualizar biblioteca",
|
||||
"updating_library": "Atualizando biblioteca"
|
||||
}
|
||||
|
|
@ -280,5 +280,8 @@
|
|||
"aniskip_requires_info": "AniSkip requer que o anime seja rastreado com MAL ou Anilist para funcionar.",
|
||||
"enable_aniskip": "Habilitar AniSkip",
|
||||
"enable_auto_skip": "Habilitar auto skip",
|
||||
"aniskip_button_timeout": "Timeout do botão"
|
||||
"aniskip_button_timeout": "Timeout do botão",
|
||||
"fullscreen": "Tela cheia",
|
||||
"update_library": "Atualizar biblioteca",
|
||||
"updating_library": "Atualizando biblioteca"
|
||||
}
|
||||
|
|
@ -280,5 +280,8 @@
|
|||
"aniskip_requires_info": "AniSkip требует отслеживания аниме с использованием MAL или Anilist для работы.",
|
||||
"enable_aniskip": "Включить AniSkip",
|
||||
"enable_auto_skip": "Включить автоматическое пропускание",
|
||||
"aniskip_button_timeout": "Тайм-аут кнопки"
|
||||
"aniskip_button_timeout": "Тайм-аут кнопки",
|
||||
"fullscreen": "Полноэкранный режим",
|
||||
"update_library": "Обновить библиотеку",
|
||||
"updating_library": "Обновление библиотеки"
|
||||
}
|
||||
|
|
@ -280,5 +280,8 @@
|
|||
"aniskip_requires_info": "AniSkip, çalışması için animenin MAL veya Anilist ile takip edilmesini gerektirir.",
|
||||
"enable_aniskip": "AniSkip'i Etkinleştir",
|
||||
"enable_auto_skip": "Otomatik Atla'yı Etkinleştir",
|
||||
"aniskip_button_timeout": "Düğme Zaman Aşımı"
|
||||
"aniskip_button_timeout": "Düğme Zaman Aşımı",
|
||||
"fullscreen": "Tam ekran",
|
||||
"update_library": "Kütüphaneyi güncelle",
|
||||
"updating_library": "Kütüphaneyi güncelleme"
|
||||
}
|
||||
|
|
@ -282,5 +282,8 @@
|
|||
"enable_auto_skip": "启用自动跳过",
|
||||
"aniskip_button_timeout": "按钮超时",
|
||||
"skip_opening": "跳过开头",
|
||||
"skip_ending": "跳过结尾"
|
||||
"skip_ending": "跳过结尾",
|
||||
"fullscreen": "全屏",
|
||||
"update_library": "更新库",
|
||||
"updating_library": "正在更新库"
|
||||
}
|
||||
|
|
@ -61,7 +61,7 @@ void main(List<String> args) async {
|
|||
}
|
||||
|
||||
/// Initialize date formatting based on available locales.
|
||||
_iniDateFormatting() {
|
||||
iniDateFormatting() {
|
||||
initializeDateFormatting();
|
||||
final supportedLocales = DateFormat.allLocalesWithSymbols();
|
||||
for (var locale in supportedLocales) {
|
||||
|
|
@ -82,7 +82,7 @@ class _MyAppState extends ConsumerState<MyApp> {
|
|||
@override
|
||||
void initState() {
|
||||
// Initialize date formatting upon app start.
|
||||
_iniDateFormatting();
|
||||
iniDateFormatting();
|
||||
super.initState();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,11 +1,13 @@
|
|||
// ignore_for_file: use_build_context_synchronously
|
||||
|
||||
import 'dart:io';
|
||||
import 'package:bot_toast/bot_toast.dart';
|
||||
import 'package:draggable_menu/draggable_menu.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:isar/isar.dart';
|
||||
import 'package:mangayomi/eval/model/m_bridge.dart';
|
||||
import 'package:mangayomi/main.dart';
|
||||
import 'package:mangayomi/models/category.dart';
|
||||
import 'package:mangayomi/models/chapter.dart';
|
||||
|
|
@ -14,6 +16,7 @@ import 'package:mangayomi/models/history.dart';
|
|||
import 'package:mangayomi/models/manga.dart';
|
||||
import 'package:mangayomi/models/settings.dart';
|
||||
import 'package:mangayomi/modules/library/providers/local_archive.dart';
|
||||
import 'package:mangayomi/modules/manga/detail/providers/update_manga_detail_providers.dart';
|
||||
import 'package:mangayomi/modules/more/categories/providers/isar_providers.dart';
|
||||
import 'package:mangayomi/modules/widgets/manga_image_card_widget.dart';
|
||||
import 'package:mangayomi/providers/l10n_providers.dart';
|
||||
|
|
@ -45,6 +48,33 @@ class _LibraryScreenState extends ConsumerState<LibraryScreen>
|
|||
final _textEditingController = TextEditingController();
|
||||
late TabController tabBarController;
|
||||
int _tabIndex = 0;
|
||||
|
||||
Future<void> _updateLibrary(List<Manga> mangaList) async {
|
||||
botToast(context.l10n.updating_library,
|
||||
fontSize: 13, second: 1600, alignY: 0.8);
|
||||
int numbers = 0;
|
||||
try {
|
||||
for (var manga in mangaList) {
|
||||
ref
|
||||
.watch(updateMangaDetailProvider(mangaId: manga.id, isInit: false)
|
||||
.future)
|
||||
.then((value) {
|
||||
numbers++;
|
||||
});
|
||||
}
|
||||
await Future.doWhile(() async {
|
||||
await Future.delayed(const Duration(seconds: 1));
|
||||
if (mangaList.length == numbers) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
});
|
||||
BotToast.cleanAll();
|
||||
} catch (e) {
|
||||
BotToast.cleanAll();
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final settingsStream = ref.watch(getSettingsStreamProvider);
|
||||
|
|
@ -649,25 +679,31 @@ class _LibraryScreenState extends ConsumerState<LibraryScreen>
|
|||
sortType: sortType!);
|
||||
if (entries.isNotEmpty) {
|
||||
final entriesManga = reverse ? entries.reversed.toList() : entries;
|
||||
return displayType == DisplayType.list
|
||||
? LibraryListViewWidget(
|
||||
entriesManga: entriesManga,
|
||||
continueReaderBtn: continueReaderBtn,
|
||||
downloadedChapter: downloadedChapter,
|
||||
language: language,
|
||||
mangaIdsList: mangaIdsList,
|
||||
localSource: localSource,
|
||||
)
|
||||
: LibraryGridViewWidget(
|
||||
entriesManga: entriesManga,
|
||||
isCoverOnlyGrid: !(displayType == DisplayType.compactGrid),
|
||||
isComfortableGrid: displayType == DisplayType.comfortableGrid,
|
||||
continueReaderBtn: continueReaderBtn,
|
||||
downloadedChapter: downloadedChapter,
|
||||
language: language,
|
||||
mangaIdsList: mangaIdsList,
|
||||
localSource: localSource,
|
||||
);
|
||||
return RefreshIndicator(
|
||||
onRefresh: () async {
|
||||
await _updateLibrary(data);
|
||||
},
|
||||
child: displayType == DisplayType.list
|
||||
? LibraryListViewWidget(
|
||||
entriesManga: entriesManga,
|
||||
continueReaderBtn: continueReaderBtn,
|
||||
downloadedChapter: downloadedChapter,
|
||||
language: language,
|
||||
mangaIdsList: mangaIdsList,
|
||||
localSource: localSource,
|
||||
)
|
||||
: LibraryGridViewWidget(
|
||||
entriesManga: entriesManga,
|
||||
isCoverOnlyGrid: !(displayType == DisplayType.compactGrid),
|
||||
isComfortableGrid:
|
||||
displayType == DisplayType.comfortableGrid,
|
||||
continueReaderBtn: continueReaderBtn,
|
||||
downloadedChapter: downloadedChapter,
|
||||
language: language,
|
||||
mangaIdsList: mangaIdsList,
|
||||
localSource: localSource,
|
||||
),
|
||||
);
|
||||
}
|
||||
return Center(child: Text(l10n.empty_library));
|
||||
},
|
||||
|
|
@ -716,25 +752,31 @@ class _LibraryScreenState extends ConsumerState<LibraryScreen>
|
|||
sortType: sortType!);
|
||||
if (entries.isNotEmpty) {
|
||||
final entriesManga = reverse ? entries.reversed.toList() : entries;
|
||||
return displayType == DisplayType.list
|
||||
? LibraryListViewWidget(
|
||||
entriesManga: entriesManga,
|
||||
continueReaderBtn: continueReaderBtn,
|
||||
downloadedChapter: downloadedChapter,
|
||||
language: language,
|
||||
mangaIdsList: mangaIdsList,
|
||||
localSource: localSource,
|
||||
)
|
||||
: LibraryGridViewWidget(
|
||||
entriesManga: entriesManga,
|
||||
isCoverOnlyGrid: !(displayType == DisplayType.compactGrid),
|
||||
isComfortableGrid: displayType == DisplayType.comfortableGrid,
|
||||
continueReaderBtn: continueReaderBtn,
|
||||
downloadedChapter: downloadedChapter,
|
||||
language: language,
|
||||
mangaIdsList: mangaIdsList,
|
||||
localSource: localSource,
|
||||
);
|
||||
return RefreshIndicator(
|
||||
onRefresh: () async {
|
||||
await _updateLibrary(data);
|
||||
},
|
||||
child: displayType == DisplayType.list
|
||||
? LibraryListViewWidget(
|
||||
entriesManga: entriesManga,
|
||||
continueReaderBtn: continueReaderBtn,
|
||||
downloadedChapter: downloadedChapter,
|
||||
language: language,
|
||||
mangaIdsList: mangaIdsList,
|
||||
localSource: localSource,
|
||||
)
|
||||
: LibraryGridViewWidget(
|
||||
entriesManga: entriesManga,
|
||||
isCoverOnlyGrid: !(displayType == DisplayType.compactGrid),
|
||||
isComfortableGrid:
|
||||
displayType == DisplayType.comfortableGrid,
|
||||
continueReaderBtn: continueReaderBtn,
|
||||
downloadedChapter: downloadedChapter,
|
||||
language: language,
|
||||
mangaIdsList: mangaIdsList,
|
||||
localSource: localSource,
|
||||
),
|
||||
);
|
||||
}
|
||||
return Center(child: Text(l10n.empty_library));
|
||||
},
|
||||
|
|
@ -1769,11 +1811,19 @@ class _LibraryScreenState extends ConsumerState<LibraryScreen>
|
|||
PopupMenuButton(itemBuilder: (context) {
|
||||
return [
|
||||
PopupMenuItem<int>(
|
||||
value: 0, child: Text(l10n.open_random_entry)),
|
||||
PopupMenuItem<int>(value: 1, child: Text(l10n.import)),
|
||||
value: 0,
|
||||
child: Text(context.l10n.update_library),
|
||||
),
|
||||
PopupMenuItem<int>(
|
||||
value: 1, child: Text(l10n.open_random_entry)),
|
||||
PopupMenuItem<int>(value: 2, child: Text(l10n.import)),
|
||||
];
|
||||
}, onSelected: (value) {
|
||||
if (value == 0) {
|
||||
manga.whenData((value) {
|
||||
_updateLibrary(value);
|
||||
});
|
||||
} else if (value == 1) {
|
||||
manga.whenData((value) {
|
||||
var randomManga = (value..shuffle()).first;
|
||||
pushToMangaReaderDetail(
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:mangayomi/main.dart';
|
||||
import 'package:mangayomi/messages/generated.dart';
|
||||
import 'package:mangayomi/models/chapter.dart';
|
||||
import 'package:mangayomi/models/settings.dart';
|
||||
import 'package:mangayomi/modules/anime/widgets/desktop.dart';
|
||||
|
|
@ -825,6 +826,8 @@ class _MangaChapterPageGalleryState
|
|||
}
|
||||
|
||||
void _initCurrentIndex() async {
|
||||
await Rinf.finalize();
|
||||
await Rinf.initialize();
|
||||
final readerMode = _readerController.getReaderMode();
|
||||
_uChapDataPreload.addAll(_chapterUrlModel.uChapDataPreload);
|
||||
_readerController.setMangaHistoryUpdate();
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import 'dart:typed_data';
|
|||
import 'package:mangayomi/eval/compiler/compiler.dart';
|
||||
import 'package:mangayomi/eval/model/m_provider.dart';
|
||||
import 'package:mangayomi/main.dart';
|
||||
import 'package:mangayomi/messages/generated.dart';
|
||||
import 'package:mangayomi/models/chapter.dart';
|
||||
import 'package:mangayomi/models/settings.dart';
|
||||
import 'package:mangayomi/modules/manga/archive_reader/providers/archive_reader_providers.dart';
|
||||
|
|
@ -60,6 +61,8 @@ Future<GetChapterPagesModel> getChapterPages(
|
|||
isarPageUrls.first.urls!.isNotEmpty) {
|
||||
pageUrls = isarPageUrls.first.urls!;
|
||||
} else {
|
||||
await Rinf.finalize();
|
||||
await Rinf.initialize();
|
||||
final bytecode =
|
||||
compilerEval(useTestSourceCode ? testSourceCode : source.sourceCode!);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,9 +1,12 @@
|
|||
import 'dart:async';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:mangayomi/eval/model/m_manga.dart';
|
||||
import 'package:mangayomi/eval/compiler/compiler.dart';
|
||||
import 'package:mangayomi/eval/model/m_provider.dart';
|
||||
import 'package:mangayomi/models/source.dart';
|
||||
import 'package:mangayomi/eval/runtime/runtime.dart';
|
||||
import 'package:mangayomi/services/isolate.dart';
|
||||
import 'package:mangayomi/sources/source_test.dart';
|
||||
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||
part 'get_detail.g.dart';
|
||||
|
|
@ -14,17 +17,20 @@ Future<MManga> getDetail(
|
|||
required String url,
|
||||
required Source source,
|
||||
}) async {
|
||||
MManga? mangadetail;
|
||||
final bytecode =
|
||||
compilerEval(useTestSourceCode ? testSourceCode : source.sourceCode!);
|
||||
return await compute<RootIsolateToken, MManga>((token) async {
|
||||
await initInIsolate(token);
|
||||
MManga? mangadetail;
|
||||
final bytecode =
|
||||
compilerEval(useTestSourceCode ? testSourceCode : source.sourceCode!);
|
||||
|
||||
final runtime = runtimeEval(bytecode);
|
||||
final runtime = runtimeEval(bytecode);
|
||||
|
||||
var res = await runtime.executeLib('package:mangayomi/main.dart', 'main');
|
||||
try {
|
||||
mangadetail = await (res as MProvider).getDetail(source.toMSource(), url);
|
||||
} catch (e) {
|
||||
throw Exception(e);
|
||||
}
|
||||
return mangadetail;
|
||||
var res = await runtime.executeLib('package:mangayomi/main.dart', 'main');
|
||||
try {
|
||||
mangadetail = await (res as MProvider).getDetail(source.toMSource(), url);
|
||||
} catch (e) {
|
||||
throw Exception(e);
|
||||
}
|
||||
return mangadetail;
|
||||
}, RootIsolateToken.instance!);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,9 +1,12 @@
|
|||
import 'dart:async';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:mangayomi/eval/model/m_pages.dart';
|
||||
import 'package:mangayomi/eval/compiler/compiler.dart';
|
||||
import 'package:mangayomi/eval/model/m_provider.dart';
|
||||
import 'package:mangayomi/models/source.dart';
|
||||
import 'package:mangayomi/eval/runtime/runtime.dart';
|
||||
import 'package:mangayomi/services/isolate.dart';
|
||||
import 'package:mangayomi/sources/source_test.dart';
|
||||
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||
part 'get_latest_updates.g.dart';
|
||||
|
|
@ -14,20 +17,23 @@ Future<MPages?> getLatestUpdates(
|
|||
required Source source,
|
||||
required int page,
|
||||
}) async {
|
||||
MPages? latestUpdatesManga;
|
||||
return await compute<RootIsolateToken, MPages?>((token) async {
|
||||
await initInIsolate(token);
|
||||
MPages? latestUpdatesManga;
|
||||
|
||||
try {
|
||||
final bytecode =
|
||||
compilerEval(useTestSourceCode ? testSourceCode : source.sourceCode!);
|
||||
try {
|
||||
final bytecode =
|
||||
compilerEval(useTestSourceCode ? testSourceCode : source.sourceCode!);
|
||||
|
||||
final runtime = runtimeEval(bytecode);
|
||||
final runtime = runtimeEval(bytecode);
|
||||
|
||||
var res = await runtime.executeLib('package:mangayomi/main.dart', 'main');
|
||||
latestUpdatesManga =
|
||||
await (res as MProvider).getLatestUpdates(source.toMSource(), page);
|
||||
} catch (e) {
|
||||
throw Exception(e);
|
||||
}
|
||||
var res = await runtime.executeLib('package:mangayomi/main.dart', 'main');
|
||||
latestUpdatesManga =
|
||||
await (res as MProvider).getLatestUpdates(source.toMSource(), page);
|
||||
} catch (e) {
|
||||
throw Exception(e);
|
||||
}
|
||||
|
||||
return latestUpdatesManga;
|
||||
return latestUpdatesManga;
|
||||
}, RootIsolateToken.instance!);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,9 +1,12 @@
|
|||
import 'dart:async';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:mangayomi/eval/model/m_pages.dart';
|
||||
import 'package:mangayomi/eval/compiler/compiler.dart';
|
||||
import 'package:mangayomi/eval/model/m_provider.dart';
|
||||
import 'package:mangayomi/models/source.dart';
|
||||
import 'package:mangayomi/eval/runtime/runtime.dart';
|
||||
import 'package:mangayomi/services/isolate.dart';
|
||||
import 'package:mangayomi/sources/source_test.dart';
|
||||
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||
part 'get_popular.g.dart';
|
||||
|
|
@ -14,20 +17,23 @@ Future<MPages?> getPopular(
|
|||
required Source source,
|
||||
required int page,
|
||||
}) async {
|
||||
MPages? popularManga;
|
||||
return await compute<RootIsolateToken, MPages?>((token) async {
|
||||
await initInIsolate(token);
|
||||
MPages? popularManga;
|
||||
|
||||
try {
|
||||
final bytecode =
|
||||
compilerEval(useTestSourceCode ? testSourceCode : source.sourceCode!);
|
||||
try {
|
||||
final bytecode =
|
||||
compilerEval(useTestSourceCode ? testSourceCode : source.sourceCode!);
|
||||
|
||||
final runtime = runtimeEval(bytecode);
|
||||
final runtime = runtimeEval(bytecode);
|
||||
|
||||
var res = runtime.executeLib('package:mangayomi/main.dart', 'main');
|
||||
popularManga =
|
||||
await (res as MProvider).getPopular(source.toMSource(), page);
|
||||
} catch (e) {
|
||||
throw Exception(e);
|
||||
}
|
||||
var res = runtime.executeLib('package:mangayomi/main.dart', 'main');
|
||||
popularManga =
|
||||
await (res as MProvider).getPopular(source.toMSource(), page);
|
||||
} catch (e) {
|
||||
throw Exception(e);
|
||||
}
|
||||
|
||||
return popularManga;
|
||||
return popularManga;
|
||||
}, RootIsolateToken.instance!);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ import 'dart:async';
|
|||
import 'dart:io';
|
||||
import 'package:mangayomi/eval/model/m_provider.dart';
|
||||
import 'package:mangayomi/eval/compiler/compiler.dart';
|
||||
import 'package:mangayomi/messages/generated.dart';
|
||||
import 'package:mangayomi/models/chapter.dart';
|
||||
import 'package:mangayomi/models/video.dart';
|
||||
import 'package:mangayomi/eval/runtime/runtime.dart';
|
||||
|
|
@ -35,14 +36,15 @@ Future<(List<Video>, bool, String?)> getVideoList(
|
|||
await MTorrentServer().getTorrentPlaylist(episode.url!);
|
||||
return (videos, false, infohash);
|
||||
}
|
||||
await Rinf.finalize();
|
||||
await Rinf.initialize();
|
||||
final bytecode =
|
||||
compilerEval(useTestSourceCode ? testSourceCode : source.sourceCode!);
|
||||
|
||||
final bytecode =
|
||||
compilerEval(useTestSourceCode ? testSourceCode : source.sourceCode!);
|
||||
final runtime = runtimeEval(bytecode);
|
||||
|
||||
final runtime = runtimeEval(bytecode);
|
||||
|
||||
var res = runtime.executeLib('package:mangayomi/main.dart', 'main');
|
||||
final dd =
|
||||
(await (res as MProvider).getVideoList(source.toMSource(), episode.url!));
|
||||
return (dd, false, null);
|
||||
var res = runtime.executeLib('package:mangayomi/main.dart', 'main');
|
||||
final dd = (await (res as MProvider)
|
||||
.getVideoList(source.toMSource(), episode.url!));
|
||||
return (dd, false, null);
|
||||
}
|
||||
|
|
|
|||
14
lib/services/isolate.dart
Normal file
14
lib/services/isolate.dart
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
import 'dart:io';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:mangayomi/main.dart';
|
||||
import 'package:mangayomi/messages/generated.dart';
|
||||
import 'package:mangayomi/providers/storage_provider.dart';
|
||||
|
||||
Future<void> initInIsolate(RootIsolateToken token) async {
|
||||
BackgroundIsolateBinaryMessenger.ensureInitialized(token);
|
||||
await Rinf.initialize();
|
||||
HttpOverrides.global = MyHttpoverrides();
|
||||
isar = await StorageProvider().initDB(null, inspector: kDebugMode);
|
||||
iniDateFormatting();
|
||||
}
|
||||
|
|
@ -1,9 +1,12 @@
|
|||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:mangayomi/eval/model/filter.dart';
|
||||
import 'package:mangayomi/eval/model/m_pages.dart';
|
||||
import 'package:mangayomi/eval/compiler/compiler.dart';
|
||||
import 'package:mangayomi/eval/model/m_provider.dart';
|
||||
import 'package:mangayomi/models/source.dart';
|
||||
import 'package:mangayomi/eval/runtime/runtime.dart';
|
||||
import 'package:mangayomi/services/isolate.dart';
|
||||
import 'package:mangayomi/sources/source_test.dart';
|
||||
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||
part 'search.g.dart';
|
||||
|
|
@ -14,16 +17,19 @@ Future<MPages?> search(SearchRef ref,
|
|||
required String query,
|
||||
required int page,
|
||||
required List<dynamic> filterList}) async {
|
||||
MPages? manga;
|
||||
final bytecode =
|
||||
compilerEval(useTestSourceCode ? testSourceCode : source.sourceCode!);
|
||||
final runtime = runtimeEval(bytecode);
|
||||
var res = runtime.executeLib('package:mangayomi/main.dart', 'main');
|
||||
try {
|
||||
manga = await (res as MProvider)
|
||||
.search(source.toMSource(), query, page, FilterList(filterList));
|
||||
} catch (e) {
|
||||
throw Exception(e);
|
||||
}
|
||||
return manga;
|
||||
return await compute<RootIsolateToken, MPages?>((token) async {
|
||||
await initInIsolate(token);
|
||||
MPages? manga;
|
||||
final bytecode =
|
||||
compilerEval(useTestSourceCode ? testSourceCode : source.sourceCode!);
|
||||
final runtime = runtimeEval(bytecode);
|
||||
var res = runtime.executeLib('package:mangayomi/main.dart', 'main');
|
||||
try {
|
||||
manga = await (res as MProvider)
|
||||
.search(source.toMSource(), query, page, FilterList(filterList));
|
||||
} catch (e) {
|
||||
throw Exception(e);
|
||||
}
|
||||
return manga;
|
||||
}, RootIsolateToken.instance!);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,9 +1,12 @@
|
|||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:mangayomi/eval/model/filter.dart';
|
||||
import 'package:mangayomi/eval/model/m_pages.dart';
|
||||
import 'package:mangayomi/eval/compiler/compiler.dart';
|
||||
import 'package:mangayomi/eval/model/m_provider.dart';
|
||||
import 'package:mangayomi/models/source.dart';
|
||||
import 'package:mangayomi/eval/runtime/runtime.dart';
|
||||
import 'package:mangayomi/services/isolate.dart';
|
||||
import 'package:mangayomi/sources/source_test.dart';
|
||||
|
||||
Future<MPages?> search(
|
||||
|
|
@ -11,16 +14,19 @@ Future<MPages?> search(
|
|||
required String query,
|
||||
required int page,
|
||||
required List<dynamic> filterList}) async {
|
||||
MPages? manga;
|
||||
final bytecode =
|
||||
compilerEval(useTestSourceCode ? testSourceCode : source.sourceCode!);
|
||||
final runtime = runtimeEval(bytecode);
|
||||
var res = runtime.executeLib('package:mangayomi/main.dart', 'main');
|
||||
try {
|
||||
manga = await (res as MProvider)
|
||||
.search(source.toMSource(), query, page, FilterList(filterList));
|
||||
} catch (e) {
|
||||
throw Exception(e);
|
||||
}
|
||||
return manga;
|
||||
return await compute<RootIsolateToken, MPages?>((token) async {
|
||||
await initInIsolate(token);
|
||||
MPages? manga;
|
||||
final bytecode =
|
||||
compilerEval(useTestSourceCode ? testSourceCode : source.sourceCode!);
|
||||
final runtime = runtimeEval(bytecode);
|
||||
var res = runtime.executeLib('package:mangayomi/main.dart', 'main');
|
||||
try {
|
||||
manga = await (res as MProvider)
|
||||
.search(source.toMSource(), query, page, FilterList(filterList));
|
||||
} catch (e) {
|
||||
throw Exception(e);
|
||||
}
|
||||
return manga;
|
||||
}, RootIsolateToken.instance!);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue