refactor code
This commit is contained in:
parent
2f11f495ac
commit
cbd01a3c17
14 changed files with 152 additions and 254 deletions
116
lib/eval/dart/service.dart
Normal file
116
lib/eval/dart/service.dart
Normal file
|
|
@ -0,0 +1,116 @@
|
|||
import 'package:dart_eval/dart_eval_bridge.dart';
|
||||
import 'package:dart_eval/stdlib/core.dart';
|
||||
import 'package:mangayomi/eval/dart/bridge/m_source.dart';
|
||||
import 'package:mangayomi/eval/dart/compiler/compiler.dart';
|
||||
import 'package:mangayomi/eval/dart/model/m_provider.dart';
|
||||
import 'package:mangayomi/eval/dart/runtime/runtime.dart';
|
||||
import 'package:mangayomi/eval/javascript/http.dart';
|
||||
import 'package:mangayomi/eval/dart/model/filter.dart';
|
||||
import 'package:mangayomi/eval/dart/model/m_manga.dart';
|
||||
import 'package:mangayomi/eval/dart/model/m_pages.dart';
|
||||
import 'package:mangayomi/eval/dart/model/source_preference.dart';
|
||||
import 'package:mangayomi/models/source.dart';
|
||||
import 'package:mangayomi/models/video.dart';
|
||||
import 'package:mangayomi/sources/source_test.dart';
|
||||
|
||||
class DartExtensionService {
|
||||
late Source? source;
|
||||
DartExtensionService(this.source);
|
||||
|
||||
MProvider _executeLib() {
|
||||
final bytecode =
|
||||
compilerEval(useTestSourceCode ? testSourceCode : source!.sourceCode!);
|
||||
|
||||
final runtime = runtimeEval(bytecode);
|
||||
|
||||
return runtime.executeLib('package:mangayomi/main.dart', 'main',
|
||||
[$MSource.wrap(source!.toMSource())]) as MProvider;
|
||||
}
|
||||
|
||||
Map<String, String> getHeaders() {
|
||||
Map<String, String> headers = {};
|
||||
try {
|
||||
final bytecode = compilerEval(source!.sourceCode!);
|
||||
final runtime = runtimeEval(bytecode);
|
||||
runtime.args = [$String(source!.baseUrl!)];
|
||||
var res = runtime.executeLib(
|
||||
'package:mangayomi/main.dart',
|
||||
'getHeader',
|
||||
);
|
||||
if (res is $Map) {
|
||||
headers = (res.$reified).toMapStringString!;
|
||||
}
|
||||
return headers;
|
||||
} catch (_) {
|
||||
try {
|
||||
headers = _executeLib().getHeaders(source!.baseUrl!);
|
||||
} catch (_) {
|
||||
return {};
|
||||
}
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
String get sourceBaseUrl {
|
||||
String? baseUrl;
|
||||
try {
|
||||
baseUrl = _executeLib().baseUrl;
|
||||
} catch (e) {
|
||||
baseUrl = source!.baseUrl;
|
||||
}
|
||||
return baseUrl!;
|
||||
}
|
||||
|
||||
bool get supportsLatest {
|
||||
bool? supportsLatest;
|
||||
try {
|
||||
supportsLatest = _executeLib().supportsLatest;
|
||||
} catch (e) {
|
||||
supportsLatest = true;
|
||||
}
|
||||
return supportsLatest;
|
||||
}
|
||||
|
||||
Future<MPages> getPopular(int page) async {
|
||||
return await _executeLib().getPopular(page);
|
||||
}
|
||||
|
||||
Future<MPages> getLatestUpdates(int page) async {
|
||||
return await _executeLib().getLatestUpdates(page);
|
||||
}
|
||||
|
||||
Future<MPages> search(
|
||||
String query, int page, List<dynamic> filterList) async {
|
||||
return await _executeLib().search(query, page, FilterList(filterList));
|
||||
}
|
||||
|
||||
Future<MManga> getDetail(String url) async {
|
||||
return await _executeLib().getDetail(url);
|
||||
}
|
||||
|
||||
Future<List<String>> getPageList(String url) async {
|
||||
return await _executeLib().getPageList(url);
|
||||
}
|
||||
|
||||
Future<List<Video>> getVideoList(String url) async {
|
||||
return await _executeLib().getVideoList(url);
|
||||
}
|
||||
|
||||
List<dynamic> getFilterList() {
|
||||
return _executeLib()
|
||||
.getFilterList()
|
||||
.map((e) => e is $Value ? e.$reified : e)
|
||||
.toList();
|
||||
}
|
||||
|
||||
List<SourcePreference> getSourcePreferences() {
|
||||
try {
|
||||
return _executeLib()
|
||||
.getSourcePreferences()
|
||||
.map((e) => (e is $Value ? e.$reified : e) as SourcePreference)
|
||||
.toList();
|
||||
} catch (_) {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -5,10 +5,7 @@ import 'package:json_view/json_view.dart';
|
|||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:highlight/languages/dart.dart';
|
||||
import 'package:highlight/languages/javascript.dart';
|
||||
import 'package:mangayomi/eval/dart/bridge/m_source.dart';
|
||||
import 'package:mangayomi/eval/dart/compiler/compiler.dart';
|
||||
import 'package:mangayomi/eval/dart/model/m_provider.dart';
|
||||
import 'package:mangayomi/eval/dart/runtime/runtime.dart';
|
||||
import 'package:mangayomi/eval/dart/service.dart';
|
||||
import 'package:mangayomi/eval/javascript/service.dart';
|
||||
import 'package:mangayomi/main.dart';
|
||||
import 'package:mangayomi/models/source.dart';
|
||||
|
|
@ -48,8 +45,8 @@ class _CodeEditorState extends ConsumerState<CodeEditor> {
|
|||
("getLatestUpdates", 1),
|
||||
("search", 2),
|
||||
("getDetail", 3),
|
||||
("getPageList", 4),
|
||||
("getVideoList", 5)
|
||||
if (source!.isManga!) ("getPageList", 4),
|
||||
if (!source!.isManga!) ("getVideoList", 5)
|
||||
];
|
||||
|
||||
int _serviceIndex = 0;
|
||||
|
|
@ -260,18 +257,8 @@ class _CodeEditorState extends ConsumerState<CodeEditor> {
|
|||
} else if (_serviceIndex == 4) {
|
||||
if (source!.sourceCodeLanguage ==
|
||||
SourceCodeLanguage.dart) {
|
||||
final bytecode = compilerEval(
|
||||
source!.sourceCode!);
|
||||
|
||||
final runtime =
|
||||
runtimeEval(bytecode);
|
||||
|
||||
var res = await runtime.executeLib(
|
||||
'package:mangayomi/main.dart',
|
||||
'main', [
|
||||
$MSource.wrap(source!.toMSource())
|
||||
]);
|
||||
result = await (res as MProvider)
|
||||
result = await DartExtensionService(
|
||||
source)
|
||||
.getPageList(_url);
|
||||
} else {
|
||||
result =
|
||||
|
|
@ -282,21 +269,12 @@ class _CodeEditorState extends ConsumerState<CodeEditor> {
|
|||
} else {
|
||||
if (source!.sourceCodeLanguage ==
|
||||
SourceCodeLanguage.dart) {
|
||||
final bytecode = compilerEval(
|
||||
source!.sourceCode!);
|
||||
|
||||
final runtime =
|
||||
runtimeEval(bytecode);
|
||||
|
||||
var res = runtime.executeLib(
|
||||
'package:mangayomi/main.dart',
|
||||
'main', [
|
||||
$MSource.wrap(source!.toMSource())
|
||||
]);
|
||||
result = (await (res as MProvider)
|
||||
.getVideoList(_url))
|
||||
.map((e) => e.toJson())
|
||||
.toList();
|
||||
result =
|
||||
(await DartExtensionService(
|
||||
source)
|
||||
.getVideoList(_url))
|
||||
.map((e) => e.toJson())
|
||||
.toList();
|
||||
} else {
|
||||
result = (await JsExtensionService(
|
||||
source)
|
||||
|
|
|
|||
|
|
@ -1,12 +1,7 @@
|
|||
import 'dart:convert';
|
||||
import 'package:dart_eval/stdlib/core.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:isar/isar.dart';
|
||||
import 'package:mangayomi/eval/dart/bridge/m_source.dart';
|
||||
import 'package:mangayomi/eval/dart/compiler/compiler.dart';
|
||||
import 'package:mangayomi/eval/dart/model/m_provider.dart';
|
||||
import 'package:mangayomi/eval/dart/runtime/runtime.dart';
|
||||
import 'package:mangayomi/eval/javascript/http.dart';
|
||||
import 'package:mangayomi/eval/dart/service.dart';
|
||||
import 'package:mangayomi/eval/javascript/service.dart';
|
||||
import 'package:mangayomi/main.dart';
|
||||
import 'package:mangayomi/models/source.dart';
|
||||
|
|
@ -202,41 +197,12 @@ int compareVersions(String version1, String version2) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
Map<String, String> getHeaders(Source source) {
|
||||
Map<String, String> headers = {};
|
||||
try {
|
||||
final bytecode = compilerEval(source.sourceCode!);
|
||||
final runtime = runtimeEval(bytecode);
|
||||
runtime.args = [$String(source.baseUrl!)];
|
||||
var res = runtime.executeLib(
|
||||
'package:mangayomi/main.dart',
|
||||
'getHeader',
|
||||
);
|
||||
if (res is $Map) {
|
||||
headers = (res.$reified).toMapStringString!;
|
||||
}
|
||||
return headers;
|
||||
} catch (_) {
|
||||
try {
|
||||
final bytecode = compilerEval(source.sourceCode!);
|
||||
final runtime = runtimeEval(bytecode);
|
||||
|
||||
var res = runtime.executeLib('package:mangayomi/main.dart', 'main',
|
||||
[$MSource.wrap(source.toMSource())]);
|
||||
headers = (res as MProvider).getHeaders(source.baseUrl!);
|
||||
} catch (_) {
|
||||
return {};
|
||||
}
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
Map<String, String> getSourceHeaders(Source source) {
|
||||
Map<String, String> headers = {};
|
||||
if (source.sourceCodeLanguage == SourceCodeLanguage.javascript) {
|
||||
headers = JsExtensionService(source).getHeaders(source.baseUrl ?? "");
|
||||
} else {
|
||||
headers = getHeaders(source);
|
||||
headers = DartExtensionService(source).getHeaders();
|
||||
}
|
||||
return headers;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,10 +1,7 @@
|
|||
import 'dart:async';
|
||||
import 'dart:io';
|
||||
import 'dart:typed_data';
|
||||
import 'package:mangayomi/eval/dart/bridge/m_source.dart';
|
||||
import 'package:mangayomi/eval/dart/compiler/compiler.dart';
|
||||
import 'package:mangayomi/eval/dart/service.dart';
|
||||
import 'package:mangayomi/eval/javascript/service.dart';
|
||||
import 'package:mangayomi/eval/dart/model/m_provider.dart';
|
||||
import 'package:mangayomi/main.dart';
|
||||
import 'package:mangayomi/models/chapter.dart';
|
||||
import 'package:mangayomi/models/settings.dart';
|
||||
|
|
@ -12,11 +9,9 @@ import 'package:mangayomi/models/source.dart';
|
|||
import 'package:mangayomi/modules/manga/archive_reader/providers/archive_reader_providers.dart';
|
||||
import 'package:mangayomi/modules/manga/reader/reader_view.dart';
|
||||
import 'package:mangayomi/providers/storage_provider.dart';
|
||||
import 'package:mangayomi/eval/dart/runtime/runtime.dart';
|
||||
import 'package:mangayomi/sources/utils/utils.dart';
|
||||
import 'package:mangayomi/utils/reg_exp_matcher.dart';
|
||||
import 'package:mangayomi/modules/more/providers/incognito_mode_state_provider.dart';
|
||||
import 'package:mangayomi/sources/source_test.dart';
|
||||
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||
part 'get_chapter_pages.g.dart';
|
||||
|
||||
|
|
@ -64,16 +59,8 @@ Future<GetChapterPagesModel> getChapterPages(
|
|||
pageUrls = isarPageUrls.first.urls!;
|
||||
} else {
|
||||
if (source.sourceCodeLanguage == SourceCodeLanguage.dart) {
|
||||
final bytecode = compilerEval(
|
||||
useTestSourceCode ? testSourceCode : source.sourceCode!);
|
||||
|
||||
final runtime = runtimeEval(bytecode);
|
||||
|
||||
var res = await runtime.executeLib('package:mangayomi/main.dart',
|
||||
'main', [$MSource.wrap(source.toMSource())]);
|
||||
pageUrls = (await (res as MProvider).getPageList(chapter.url!));
|
||||
pageUrls = await DartExtensionService(source).getPageList(chapter.url!);
|
||||
} else {
|
||||
|
||||
pageUrls = await JsExtensionService(source).getPageList(chapter.url!);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,12 +1,7 @@
|
|||
import 'dart:async';
|
||||
import 'package:mangayomi/eval/dart/bridge/m_source.dart';
|
||||
import 'package:mangayomi/eval/dart/service.dart';
|
||||
import 'package:mangayomi/eval/javascript/service.dart';
|
||||
import 'package:mangayomi/eval/dart/model/m_manga.dart';
|
||||
import 'package:mangayomi/eval/dart/compiler/compiler.dart';
|
||||
import 'package:mangayomi/eval/dart/model/m_provider.dart';
|
||||
import 'package:mangayomi/models/source.dart';
|
||||
import 'package:mangayomi/eval/dart/runtime/runtime.dart';
|
||||
import 'package:mangayomi/sources/source_test.dart';
|
||||
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||
part 'get_detail.g.dart';
|
||||
|
||||
|
|
@ -18,18 +13,7 @@ Future<MManga> getDetail(
|
|||
}) async {
|
||||
MManga? mangadetail;
|
||||
if (source.sourceCodeLanguage == SourceCodeLanguage.dart) {
|
||||
final bytecode =
|
||||
compilerEval(useTestSourceCode ? testSourceCode : source.sourceCode!);
|
||||
|
||||
final runtime = runtimeEval(bytecode);
|
||||
|
||||
var res = await runtime.executeLib('package:mangayomi/main.dart', 'main',
|
||||
[$MSource.wrap(source.toMSource())]);
|
||||
try {
|
||||
mangadetail = await (res as MProvider).getDetail(url);
|
||||
} catch (e) {
|
||||
throw Exception(e);
|
||||
}
|
||||
mangadetail = await DartExtensionService(source).getDetail(url);
|
||||
} else {
|
||||
mangadetail = await JsExtensionService(source).getDetail(url);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,28 +1,13 @@
|
|||
import 'package:dart_eval/dart_eval_bridge.dart';
|
||||
import 'package:mangayomi/eval/dart/bridge/m_source.dart';
|
||||
import 'package:mangayomi/eval/dart/compiler/compiler.dart';
|
||||
import 'package:mangayomi/eval/dart/service.dart';
|
||||
import 'package:mangayomi/eval/javascript/service.dart';
|
||||
import 'package:mangayomi/eval/dart/model/m_provider.dart';
|
||||
import 'package:mangayomi/models/source.dart';
|
||||
import 'package:mangayomi/eval/dart/runtime/runtime.dart';
|
||||
import 'package:mangayomi/sources/source_test.dart';
|
||||
|
||||
List<dynamic> getFilterList({required Source source}) {
|
||||
List<dynamic> filterList = [];
|
||||
|
||||
try {
|
||||
if (source.sourceCodeLanguage == SourceCodeLanguage.dart) {
|
||||
final bytecode =
|
||||
compilerEval(useTestSourceCode ? testSourceCode : source.sourceCode!);
|
||||
|
||||
final runtime = runtimeEval(bytecode);
|
||||
|
||||
var res = runtime.executeLib('package:mangayomi/main.dart', 'main',
|
||||
[$MSource.wrap(source.toMSource())]);
|
||||
filterList = (res as MProvider)
|
||||
.getFilterList()
|
||||
.map((e) => e is $Value ? e.$reified : e)
|
||||
.toList();
|
||||
filterList = DartExtensionService(source).getFilterList();
|
||||
} else {
|
||||
filterList = (JsExtensionService(source).getFilterList()).filters;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,12 +1,7 @@
|
|||
import 'dart:async';
|
||||
import 'package:mangayomi/eval/dart/bridge/m_source.dart';
|
||||
import 'package:mangayomi/eval/dart/service.dart';
|
||||
import 'package:mangayomi/eval/javascript/service.dart';
|
||||
import 'package:mangayomi/eval/dart/model/m_pages.dart';
|
||||
import 'package:mangayomi/eval/dart/compiler/compiler.dart';
|
||||
import 'package:mangayomi/eval/dart/model/m_provider.dart';
|
||||
import 'package:mangayomi/models/source.dart';
|
||||
import 'package:mangayomi/eval/dart/runtime/runtime.dart';
|
||||
import 'package:mangayomi/sources/source_test.dart';
|
||||
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||
part 'get_latest_updates.g.dart';
|
||||
|
||||
|
|
@ -18,18 +13,8 @@ Future<MPages?> getLatestUpdates(
|
|||
}) async {
|
||||
MPages? latestUpdatesManga;
|
||||
if (source.sourceCodeLanguage == SourceCodeLanguage.dart) {
|
||||
try {
|
||||
final bytecode =
|
||||
compilerEval(useTestSourceCode ? testSourceCode : source.sourceCode!);
|
||||
|
||||
final runtime = runtimeEval(bytecode);
|
||||
|
||||
var res = await runtime.executeLib('package:mangayomi/main.dart', 'main',
|
||||
[$MSource.wrap(source.toMSource())]);
|
||||
latestUpdatesManga = await (res as MProvider).getLatestUpdates(page);
|
||||
} catch (e) {
|
||||
throw Exception(e);
|
||||
}
|
||||
latestUpdatesManga =
|
||||
await DartExtensionService(source).getLatestUpdates(page);
|
||||
} else {
|
||||
latestUpdatesManga =
|
||||
await JsExtensionService(source).getLatestUpdates(page);
|
||||
|
|
|
|||
|
|
@ -1,12 +1,7 @@
|
|||
import 'dart:async';
|
||||
import 'package:mangayomi/eval/dart/bridge/m_source.dart';
|
||||
import 'package:mangayomi/eval/dart/service.dart';
|
||||
import 'package:mangayomi/eval/javascript/service.dart';
|
||||
import 'package:mangayomi/eval/dart/model/m_pages.dart';
|
||||
import 'package:mangayomi/eval/dart/compiler/compiler.dart';
|
||||
import 'package:mangayomi/eval/dart/model/m_provider.dart';
|
||||
import 'package:mangayomi/models/source.dart';
|
||||
import 'package:mangayomi/eval/dart/runtime/runtime.dart';
|
||||
import 'package:mangayomi/sources/source_test.dart';
|
||||
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||
part 'get_popular.g.dart';
|
||||
|
||||
|
|
@ -18,18 +13,7 @@ Future<MPages?> getPopular(
|
|||
}) async {
|
||||
MPages? popularManga;
|
||||
if (source.sourceCodeLanguage == SourceCodeLanguage.dart) {
|
||||
try {
|
||||
final bytecode =
|
||||
compilerEval(useTestSourceCode ? testSourceCode : source.sourceCode!);
|
||||
|
||||
final runtime = runtimeEval(bytecode);
|
||||
|
||||
var res = runtime.executeLib('package:mangayomi/main.dart', 'main',
|
||||
[$MSource.wrap(source.toMSource())]);
|
||||
popularManga = await (res as MProvider).getPopular(page);
|
||||
} catch (e) {
|
||||
throw Exception(e);
|
||||
}
|
||||
popularManga = await DartExtensionService(source).getPopular(page);
|
||||
} else {
|
||||
popularManga = await JsExtensionService(source).getPopular(page);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,9 +1,5 @@
|
|||
import 'package:mangayomi/eval/dart/bridge/m_source.dart';
|
||||
import 'package:mangayomi/eval/dart/compiler/compiler.dart';
|
||||
import 'package:mangayomi/eval/dart/model/m_provider.dart';
|
||||
import 'package:mangayomi/eval/dart/service.dart';
|
||||
import 'package:mangayomi/models/source.dart';
|
||||
import 'package:mangayomi/eval/dart/runtime/runtime.dart';
|
||||
import 'package:mangayomi/sources/source_test.dart';
|
||||
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||
part 'get_source_baseurl.g.dart';
|
||||
|
||||
|
|
@ -11,18 +7,7 @@ part 'get_source_baseurl.g.dart';
|
|||
String sourceBaseUrl(SourceBaseUrlRef ref, {required Source source}) {
|
||||
String? baseUrl;
|
||||
if (source.sourceCodeLanguage == SourceCodeLanguage.dart) {
|
||||
try {
|
||||
final bytecode =
|
||||
compilerEval(useTestSourceCode ? testSourceCode : source.sourceCode!);
|
||||
|
||||
final runtime = runtimeEval(bytecode);
|
||||
|
||||
var res = runtime.executeLib('package:mangayomi/main.dart', 'main',
|
||||
[$MSource.wrap(source.toMSource())]);
|
||||
baseUrl = (res as MProvider).baseUrl;
|
||||
} catch (e) {
|
||||
baseUrl = source.baseUrl;
|
||||
}
|
||||
baseUrl = DartExtensionService(source).sourceBaseUrl;
|
||||
} else {}
|
||||
if (baseUrl == null || baseUrl.isEmpty) {
|
||||
baseUrl = source.baseUrl;
|
||||
|
|
|
|||
|
|
@ -1,30 +1,13 @@
|
|||
import 'package:dart_eval/dart_eval_bridge.dart';
|
||||
import 'package:mangayomi/eval/dart/bridge/m_source.dart';
|
||||
import 'package:mangayomi/eval/dart/compiler/compiler.dart';
|
||||
import 'package:mangayomi/eval/dart/service.dart';
|
||||
import 'package:mangayomi/eval/javascript/service.dart';
|
||||
import 'package:mangayomi/eval/dart/model/m_provider.dart';
|
||||
import 'package:mangayomi/eval/dart/model/source_preference.dart';
|
||||
import 'package:mangayomi/models/source.dart';
|
||||
import 'package:mangayomi/eval/dart/runtime/runtime.dart';
|
||||
|
||||
List<SourcePreference> getSourcePreference({required Source source}) {
|
||||
List<SourcePreference> sourcePreference = [];
|
||||
|
||||
if (source.sourceCodeLanguage == SourceCodeLanguage.dart) {
|
||||
try {
|
||||
final bytecode = compilerEval(source.sourceCode!);
|
||||
|
||||
final runtime = runtimeEval(bytecode);
|
||||
|
||||
var res = runtime.executeLib('package:mangayomi/main.dart', 'main',
|
||||
[$MSource.wrap(source.toMSource())]);
|
||||
sourcePreference = (res as MProvider)
|
||||
.getSourcePreferences()
|
||||
.map((e) => (e is $Value ? e.$reified : e) as SourcePreference)
|
||||
.toList();
|
||||
} catch (_) {
|
||||
return [];
|
||||
}
|
||||
sourcePreference = DartExtensionService(source).getSourcePreferences();
|
||||
} else {
|
||||
sourcePreference = JsExtensionService(source).getSourcePreferences();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,17 +1,13 @@
|
|||
import 'dart:async';
|
||||
import 'dart:io';
|
||||
import 'package:mangayomi/eval/dart/bridge/m_source.dart';
|
||||
import 'package:mangayomi/eval/dart/model/m_provider.dart';
|
||||
import 'package:mangayomi/eval/dart/compiler/compiler.dart';
|
||||
import 'package:mangayomi/eval/dart/service.dart';
|
||||
import 'package:mangayomi/eval/javascript/service.dart';
|
||||
import 'package:mangayomi/models/chapter.dart';
|
||||
import 'package:mangayomi/models/source.dart';
|
||||
import 'package:mangayomi/models/video.dart';
|
||||
import 'package:mangayomi/eval/dart/runtime/runtime.dart';
|
||||
import 'package:mangayomi/providers/storage_provider.dart';
|
||||
import 'package:mangayomi/services/torrent_server.dart';
|
||||
import 'package:mangayomi/sources/utils/utils.dart';
|
||||
import 'package:mangayomi/sources/source_test.dart';
|
||||
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||
part 'get_video_list.g.dart';
|
||||
|
||||
|
|
@ -40,14 +36,7 @@ Future<(List<Video>, bool, String?)> getVideoList(
|
|||
}
|
||||
List<Video> list = [];
|
||||
if (source.sourceCodeLanguage == SourceCodeLanguage.dart) {
|
||||
final bytecode =
|
||||
compilerEval(useTestSourceCode ? testSourceCode : source.sourceCode!);
|
||||
|
||||
final runtime = runtimeEval(bytecode);
|
||||
|
||||
var res = runtime.executeLib('package:mangayomi/main.dart', 'main',
|
||||
[$MSource.wrap(source.toMSource())]);
|
||||
list = (await (res as MProvider).getVideoList(episode.url!));
|
||||
list = await DartExtensionService(source).getVideoList(episode.url!);
|
||||
} else {
|
||||
list = await JsExtensionService(source).getVideoList(episode.url!);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,13 +1,9 @@
|
|||
import 'dart:convert';
|
||||
import 'package:mangayomi/eval/dart/bridge/m_source.dart';
|
||||
import 'package:mangayomi/eval/dart/service.dart';
|
||||
import 'package:mangayomi/eval/javascript/service.dart';
|
||||
import 'package:mangayomi/eval/dart/model/filter.dart';
|
||||
import 'package:mangayomi/eval/dart/model/m_pages.dart';
|
||||
import 'package:mangayomi/eval/dart/compiler/compiler.dart';
|
||||
import 'package:mangayomi/eval/dart/model/m_provider.dart';
|
||||
import 'package:mangayomi/models/source.dart';
|
||||
import 'package:mangayomi/eval/dart/runtime/runtime.dart';
|
||||
import 'package:mangayomi/sources/source_test.dart';
|
||||
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||
part 'search.g.dart';
|
||||
|
||||
|
|
@ -19,17 +15,7 @@ Future<MPages?> search(SearchRef ref,
|
|||
required List<dynamic> filterList}) async {
|
||||
MPages? manga;
|
||||
if (source.sourceCodeLanguage == SourceCodeLanguage.dart) {
|
||||
final bytecode =
|
||||
compilerEval(useTestSourceCode ? testSourceCode : source.sourceCode!);
|
||||
final runtime = runtimeEval(bytecode);
|
||||
var res = runtime.executeLib('package:mangayomi/main.dart', 'main',
|
||||
[$MSource.wrap(source.toMSource())]);
|
||||
try {
|
||||
manga =
|
||||
await (res as MProvider).search(query, page, FilterList(filterList));
|
||||
} catch (e) {
|
||||
throw Exception(e);
|
||||
}
|
||||
manga = await DartExtensionService(source).search(query, page, filterList);
|
||||
} else {
|
||||
manga = await JsExtensionService(source)
|
||||
.search(query, page, jsonEncode(filterValuesListToJson(filterList)));
|
||||
|
|
|
|||
|
|
@ -1,14 +1,9 @@
|
|||
import 'dart:convert';
|
||||
|
||||
import 'package:mangayomi/eval/dart/bridge/m_source.dart';
|
||||
import 'package:mangayomi/eval/dart/service.dart';
|
||||
import 'package:mangayomi/eval/javascript/service.dart';
|
||||
import 'package:mangayomi/eval/dart/model/filter.dart';
|
||||
import 'package:mangayomi/eval/dart/model/m_pages.dart';
|
||||
import 'package:mangayomi/eval/dart/compiler/compiler.dart';
|
||||
import 'package:mangayomi/eval/dart/model/m_provider.dart';
|
||||
import 'package:mangayomi/models/source.dart';
|
||||
import 'package:mangayomi/eval/dart/runtime/runtime.dart';
|
||||
import 'package:mangayomi/sources/source_test.dart';
|
||||
|
||||
Future<MPages?> search(
|
||||
{required Source source,
|
||||
|
|
@ -17,17 +12,7 @@ Future<MPages?> search(
|
|||
required List<dynamic> filterList}) async {
|
||||
MPages? manga;
|
||||
if (source.sourceCodeLanguage == SourceCodeLanguage.dart) {
|
||||
final bytecode =
|
||||
compilerEval(useTestSourceCode ? testSourceCode : source.sourceCode!);
|
||||
final runtime = runtimeEval(bytecode);
|
||||
var res = runtime.executeLib('package:mangayomi/main.dart', 'main',
|
||||
[$MSource.wrap(source.toMSource())]);
|
||||
try {
|
||||
manga =
|
||||
await (res as MProvider).search(query, page, FilterList(filterList));
|
||||
} catch (e) {
|
||||
throw Exception(e);
|
||||
}
|
||||
manga = await DartExtensionService(source).search(query, page, filterList);
|
||||
} else {
|
||||
manga = await JsExtensionService(source)
|
||||
.search(query, page, jsonEncode(filterValuesListToJson(filterList)));
|
||||
|
|
|
|||
|
|
@ -1,9 +1,5 @@
|
|||
import 'package:mangayomi/eval/dart/bridge/m_source.dart';
|
||||
import 'package:mangayomi/eval/dart/compiler/compiler.dart';
|
||||
import 'package:mangayomi/eval/dart/model/m_provider.dart';
|
||||
import 'package:mangayomi/eval/dart/service.dart';
|
||||
import 'package:mangayomi/models/source.dart';
|
||||
import 'package:mangayomi/eval/dart/runtime/runtime.dart';
|
||||
import 'package:mangayomi/sources/source_test.dart';
|
||||
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||
part 'supports_latest.g.dart';
|
||||
|
||||
|
|
@ -11,18 +7,7 @@ part 'supports_latest.g.dart';
|
|||
bool supportsLatest(SupportsLatestRef ref, {required Source source}) {
|
||||
bool? supportsLatest;
|
||||
if (source.sourceCodeLanguage == SourceCodeLanguage.dart) {
|
||||
try {
|
||||
final bytecode =
|
||||
compilerEval(useTestSourceCode ? testSourceCode : source.sourceCode!);
|
||||
|
||||
final runtime = runtimeEval(bytecode);
|
||||
|
||||
var res = runtime.executeLib('package:mangayomi/main.dart', 'main',
|
||||
[$MSource.wrap(source.toMSource())]);
|
||||
supportsLatest = (res as MProvider).supportsLatest;
|
||||
} catch (e) {
|
||||
supportsLatest = true;
|
||||
}
|
||||
supportsLatest = DartExtensionService(source).supportsLatest;
|
||||
} else {
|
||||
supportsLatest = true;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue