refactor: refactor extension services
This commit is contained in:
parent
adbd1529f7
commit
f0cf52813a
74 changed files with 337 additions and 351 deletions
|
|
@ -3,8 +3,8 @@ import 'package:dart_eval/dart_eval_bridge.dart';
|
|||
import 'package:dart_eval/stdlib/core.dart';
|
||||
import 'package:html/dom.dart';
|
||||
import 'package:mangayomi/eval/dart/bridge/element.dart';
|
||||
import 'package:mangayomi/eval/dart/model/document.dart';
|
||||
import 'package:mangayomi/eval/dart/model/element.dart';
|
||||
import 'package:mangayomi/eval/model/document.dart';
|
||||
import 'package:mangayomi/eval/model/element.dart';
|
||||
|
||||
class $MDocument implements MDocument, $Instance {
|
||||
$MDocument.wrap(this.$value) : _superclass = $Object($value);
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import 'package:dart_eval/dart_eval_bridge.dart';
|
||||
import 'package:dart_eval/stdlib/core.dart';
|
||||
import 'package:html/dom.dart';
|
||||
import 'package:mangayomi/eval/dart/model/element.dart';
|
||||
import 'package:mangayomi/eval/model/element.dart';
|
||||
|
||||
class $MElement implements MElement, $Instance {
|
||||
$MElement.wrap(this.$value) : _superclass = $Object($value);
|
||||
|
|
@ -192,48 +192,56 @@ class $MElement implements MElement, $Instance {
|
|||
}
|
||||
|
||||
static const $Function __attr = $Function(_attr);
|
||||
|
||||
static $Value? _attr(final Runtime runtime, final $Value? target, final List<$Value?> args) {
|
||||
final res = (target!.$value as MElement).attr(args[0]?.$value ?? "");
|
||||
return res == null ? const $null() : $String(res);
|
||||
}
|
||||
|
||||
static const $Function __select = $Function(_select);
|
||||
|
||||
static $Value? _select(final Runtime runtime, final $Value? target, final List<$Value?> args) {
|
||||
final res = (target!.$value as MElement).select(args[0]?.$value);
|
||||
return res == null ? const $null() : $List.wrap(res.map((e) => $MElement.wrap(e)).toList());
|
||||
}
|
||||
|
||||
static const $Function __selectFirst = $Function(_selectFirst);
|
||||
|
||||
static $Value? _selectFirst(final Runtime runtime, final $Value? target, final List<$Value?> args) {
|
||||
final res = (target!.$value as MElement).selectFirst(args[0]?.$value);
|
||||
return res == null ? const $null() : $MElement.wrap(res);
|
||||
}
|
||||
|
||||
static const $Function __getElementsByClassName = $Function(_getElementsByClassName);
|
||||
|
||||
static $Value? _getElementsByClassName(final Runtime runtime, final $Value? target, final List<$Value?> args) {
|
||||
final res = (target!.$value as MElement).getElementsByClassName(args[0]?.$value);
|
||||
return res == null ? const $null() : $List.wrap(res.map((e) => $MElement.wrap(e)).toList());
|
||||
}
|
||||
|
||||
static const $Function __getElementsByTagName = $Function(_getElementsByTagName);
|
||||
|
||||
static $Value? _getElementsByTagName(final Runtime runtime, final $Value? target, final List<$Value?> args) {
|
||||
final res = (target!.$value as MElement).getElementsByTagName(args[0]?.$value);
|
||||
return res == null ? const $null() : $List.wrap(res.map((e) => $MElement.wrap(e)).toList());
|
||||
}
|
||||
|
||||
static const $Function __xpath = $Function(_xpath);
|
||||
|
||||
static $Value? _xpath(final Runtime runtime, final $Value? target, final List<$Value?> args) {
|
||||
final res = (target!.$value as MElement).xpath(args[0]?.$value);
|
||||
return res == null ? const $null() : $List.wrap(res.map((e) => $String(e)).toList());
|
||||
}
|
||||
|
||||
static const $Function __xpathFirst = $Function(_xpathFirst);
|
||||
|
||||
static $Value? _xpathFirst(final Runtime runtime, final $Value? target, final List<$Value?> args) {
|
||||
final res = (target!.$value as MElement).xpathFirst(args[0]?.$value);
|
||||
return res == null ? const $null() : $String(res);
|
||||
}
|
||||
|
||||
static const $Function __hasAttr = $Function(_hasAttr);
|
||||
|
||||
static $Value? _hasAttr(final Runtime runtime, final $Value? target, final List<$Value?> args) {
|
||||
final res = (target!.$value as MElement).attr(args[0]?.$value ?? "");
|
||||
return res == null ? const $null() : $String(res);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import 'package:dart_eval/dart_eval_bridge.dart';
|
||||
import 'package:dart_eval/stdlib/core.dart';
|
||||
import 'package:mangayomi/eval/dart/model/filter.dart';
|
||||
import 'package:mangayomi/eval/model/filter.dart';
|
||||
|
||||
class $FilterList implements FilterList, $Instance {
|
||||
$FilterList.wrap(this.$value) : _superclass = $Object($value);
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import 'package:dart_eval/stdlib/core.dart';
|
|||
import 'package:flutter/foundation.dart';
|
||||
import 'package:http_interceptor/http_interceptor.dart';
|
||||
import 'package:mangayomi/eval/dart/bridge/m_source.dart';
|
||||
import 'package:mangayomi/eval/dart/model/m_bridge.dart';
|
||||
import 'package:mangayomi/eval/model/m_bridge.dart';
|
||||
import 'package:mangayomi/services/http/m_client.dart';
|
||||
|
||||
/// dart_eval wrapper for [InterceptedClient]
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import 'package:dart_eval/dart_eval_bridge.dart';
|
||||
import 'package:dart_eval/stdlib/core.dart';
|
||||
import 'package:mangayomi/eval/dart/model/m_chapter.dart';
|
||||
import 'package:mangayomi/eval/model/m_chapter.dart';
|
||||
|
||||
class $MChapter implements MChapter, $Instance {
|
||||
$MChapter.wrap(this.$value) : _superclass = $Object($value);
|
||||
|
|
|
|||
|
|
@ -2,8 +2,8 @@ import 'package:dart_eval/dart_eval_bridge.dart';
|
|||
import 'package:dart_eval/stdlib/core.dart';
|
||||
import 'package:mangayomi/eval/dart/bridge/m_chapter.dart';
|
||||
import 'package:mangayomi/eval/dart/bridge/m_status.dart';
|
||||
import 'package:mangayomi/eval/dart/model/m_chapter.dart';
|
||||
import 'package:mangayomi/eval/dart/model/m_manga.dart';
|
||||
import 'package:mangayomi/eval/model/m_chapter.dart';
|
||||
import 'package:mangayomi/eval/model/m_manga.dart';
|
||||
import 'package:mangayomi/models/manga.dart';
|
||||
import 'package:mangayomi/utils/extensions/string_extensions.dart';
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
import 'package:dart_eval/dart_eval_bridge.dart';
|
||||
import 'package:dart_eval/stdlib/core.dart';
|
||||
import 'package:mangayomi/eval/dart/bridge/m_manga.dart';
|
||||
import 'package:mangayomi/eval/dart/model/m_manga.dart';
|
||||
import 'package:mangayomi/eval/dart/model/m_pages.dart';
|
||||
import 'package:mangayomi/eval/model/m_manga.dart';
|
||||
import 'package:mangayomi/eval/model/m_pages.dart';
|
||||
|
||||
class $MPages implements MPages, $Instance {
|
||||
$MPages.wrap(this.$value) : _superclass = $Object($value);
|
||||
|
|
|
|||
|
|
@ -9,11 +9,11 @@ import 'package:mangayomi/eval/dart/bridge/m_pages.dart';
|
|||
import 'package:mangayomi/eval/dart/bridge/m_status.dart';
|
||||
import 'package:mangayomi/eval/dart/bridge/m_track.dart';
|
||||
import 'package:mangayomi/eval/dart/bridge/m_video.dart';
|
||||
import 'package:mangayomi/eval/dart/model/filter.dart';
|
||||
import 'package:mangayomi/eval/dart/model/m_bridge.dart';
|
||||
import 'package:mangayomi/eval/dart/model/m_pages.dart';
|
||||
import 'package:mangayomi/eval/dart/model/m_manga.dart';
|
||||
import 'package:mangayomi/eval/dart/model/m_provider.dart';
|
||||
import 'package:mangayomi/eval/model/filter.dart';
|
||||
import 'package:mangayomi/eval/model/m_bridge.dart';
|
||||
import 'package:mangayomi/eval/model/m_manga.dart';
|
||||
import 'package:mangayomi/eval/model/m_pages.dart';
|
||||
import 'package:mangayomi/eval/model/m_provider.dart';
|
||||
import 'package:mangayomi/eval/javascript/http.dart';
|
||||
import 'package:mangayomi/models/video.dart';
|
||||
import 'package:mangayomi/modules/browse/extension/providers/extension_preferences_providers.dart';
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import 'package:dart_eval/dart_eval_bridge.dart';
|
||||
import 'package:dart_eval/stdlib/core.dart';
|
||||
import 'package:mangayomi/eval/dart/model/m_source.dart';
|
||||
import 'package:mangayomi/eval/model/m_source.dart';
|
||||
|
||||
class $MSource implements MSource, $Instance {
|
||||
$MSource.wrap(this.$value) : _superclass = $Object($value);
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import 'package:dart_eval/dart_eval_bridge.dart';
|
||||
import 'package:dart_eval/stdlib/core.dart';
|
||||
import 'package:isar/isar.dart';
|
||||
import 'package:mangayomi/eval/dart/model/source_preference.dart';
|
||||
import 'package:mangayomi/eval/model/source_preference.dart';
|
||||
|
||||
class $CheckBoxPreference implements SourcePreference, $Instance {
|
||||
$CheckBoxPreference.wrap(this.$value) : _superclass = $Object($value);
|
||||
|
|
|
|||
|
|
@ -2,35 +2,40 @@ 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/model/filter.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/eval/model/m_manga.dart';
|
||||
import 'package:mangayomi/eval/model/m_pages.dart';
|
||||
import 'package:mangayomi/eval/model/m_provider.dart';
|
||||
import 'package:mangayomi/eval/model/source_preference.dart';
|
||||
import 'package:mangayomi/models/page.dart';
|
||||
import 'package:mangayomi/models/source.dart';
|
||||
import 'package:mangayomi/models/video.dart';
|
||||
|
||||
class DartExtensionService {
|
||||
late Source? source;
|
||||
import '../interface.dart';
|
||||
|
||||
class DartExtensionService implements ExtensionService {
|
||||
@override
|
||||
late Source source;
|
||||
|
||||
DartExtensionService(this.source);
|
||||
|
||||
MProvider _executeLib() {
|
||||
final bytecode = compilerEval(source!.sourceCode!);
|
||||
final bytecode = compilerEval(source.sourceCode!);
|
||||
|
||||
final runtime = runtimeEval(bytecode);
|
||||
|
||||
return runtime.executeLib('package:mangayomi/main.dart', 'main', [$MSource.wrap(source!.toMSource())]) as MProvider;
|
||||
return runtime.executeLib('package:mangayomi/main.dart', 'main', [$MSource.wrap(source.toMSource())]) as MProvider;
|
||||
}
|
||||
|
||||
@override
|
||||
Map<String, String> getHeaders() {
|
||||
Map<String, String> headers = {};
|
||||
try {
|
||||
final bytecode = compilerEval(source!.sourceCode!);
|
||||
final bytecode = compilerEval(source.sourceCode!);
|
||||
final runtime = runtimeEval(bytecode);
|
||||
runtime.args = [$String(source!.baseUrl!)];
|
||||
runtime.args = [$String(source.baseUrl!)];
|
||||
var res = runtime.executeLib(
|
||||
'package:mangayomi/main.dart',
|
||||
'getHeader',
|
||||
|
|
@ -52,16 +57,19 @@ class DartExtensionService {
|
|||
return headers;
|
||||
}
|
||||
|
||||
@override
|
||||
String get sourceBaseUrl {
|
||||
String? baseUrl;
|
||||
try {
|
||||
baseUrl = _executeLib().baseUrl;
|
||||
} catch (e) {
|
||||
baseUrl = source!.baseUrl;
|
||||
} catch (_) {
|
||||
//
|
||||
}
|
||||
return baseUrl!;
|
||||
|
||||
return baseUrl == null || baseUrl.isEmpty ? source.baseUrl! : baseUrl;
|
||||
}
|
||||
|
||||
@override
|
||||
bool get supportsLatest {
|
||||
bool? supportsLatest;
|
||||
try {
|
||||
|
|
@ -72,36 +80,44 @@ class DartExtensionService {
|
|||
return supportsLatest;
|
||||
}
|
||||
|
||||
@override
|
||||
Future<MPages> getPopular(int page) async {
|
||||
return await _executeLib().getPopular(page);
|
||||
}
|
||||
|
||||
@override
|
||||
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));
|
||||
@override
|
||||
Future<MPages> search(String query, int page, List<dynamic> filters) async {
|
||||
return await _executeLib().search(query, page, FilterList(filters));
|
||||
}
|
||||
|
||||
@override
|
||||
Future<MManga> getDetail(String url) async {
|
||||
return await _executeLib().getDetail(url);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<List<PageUrl>> getPageList(String url) async {
|
||||
return (await _executeLib().getPageList(url))
|
||||
.map((e) => e is String ? PageUrl(e.toString().trim()) : PageUrl.fromJson((e as Map).toMapStringDynamic!))
|
||||
.toList();
|
||||
}
|
||||
|
||||
@override
|
||||
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();
|
||||
@override
|
||||
FilterList getFilterList() {
|
||||
return FilterList(_executeLib().getFilterList().map((e) => e is $Value ? e.$reified : e).toList());
|
||||
}
|
||||
|
||||
@override
|
||||
List<SourcePreference> getSourcePreferences() {
|
||||
try {
|
||||
return _executeLib()
|
||||
|
|
|
|||
35
lib/eval/interface.dart
Normal file
35
lib/eval/interface.dart
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
import 'package:mangayomi/models/page.dart';
|
||||
import 'package:mangayomi/models/source.dart';
|
||||
import 'package:mangayomi/models/video.dart';
|
||||
|
||||
import 'model/filter.dart';
|
||||
import 'model/m_manga.dart';
|
||||
import 'model/m_pages.dart';
|
||||
import 'model/source_preference.dart';
|
||||
|
||||
abstract interface class ExtensionService {
|
||||
late Source source;
|
||||
|
||||
ExtensionService(this.source);
|
||||
|
||||
String get sourceBaseUrl;
|
||||
bool get supportsLatest;
|
||||
|
||||
Map<String, String> getHeaders();
|
||||
|
||||
Future<MPages> getPopular(int page);
|
||||
|
||||
Future<MPages> getLatestUpdates(int page);
|
||||
|
||||
Future<MPages> search(String query, int page, List<dynamic> filters);
|
||||
|
||||
Future<MManga> getDetail(String url);
|
||||
|
||||
Future<List<PageUrl>> getPageList(String url);
|
||||
|
||||
Future<List<Video>> getVideoList(String url);
|
||||
|
||||
FilterList getFilterList();
|
||||
|
||||
List<SourcePreference> getSourcePreferences();
|
||||
}
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
import 'dart:convert';
|
||||
import 'package:flutter_qjs/flutter_qjs.dart';
|
||||
import 'package:mangayomi/eval/dart/model/m_bridge.dart';
|
||||
import 'package:mangayomi/eval/model/m_bridge.dart';
|
||||
import 'package:mangayomi/eval/javascript/http.dart';
|
||||
import 'package:mangayomi/models/video.dart';
|
||||
|
||||
|
|
|
|||
|
|
@ -1,21 +1,26 @@
|
|||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter_qjs/flutter_qjs.dart';
|
||||
import 'package:mangayomi/eval/javascript/dom_selector.dart';
|
||||
import 'package:mangayomi/eval/javascript/extractors.dart';
|
||||
import 'package:mangayomi/eval/javascript/http.dart';
|
||||
import 'package:mangayomi/eval/javascript/preferences.dart';
|
||||
import 'package:mangayomi/eval/javascript/utils.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/eval/model/filter.dart';
|
||||
import 'package:mangayomi/eval/model/m_manga.dart';
|
||||
import 'package:mangayomi/eval/model/m_pages.dart';
|
||||
import 'package:mangayomi/eval/model/source_preference.dart';
|
||||
import 'package:mangayomi/models/page.dart';
|
||||
import 'package:mangayomi/models/source.dart';
|
||||
import 'package:mangayomi/models/video.dart';
|
||||
|
||||
class JsExtensionService {
|
||||
import '../interface.dart';
|
||||
|
||||
class JsExtensionService implements ExtensionService {
|
||||
late JavascriptRuntime runtime;
|
||||
late Source? source;
|
||||
@override
|
||||
late Source source;
|
||||
|
||||
JsExtensionService(this.source);
|
||||
|
||||
void _init() {
|
||||
|
|
@ -29,7 +34,7 @@ class JsExtensionService {
|
|||
runtime.evaluate('''
|
||||
class MProvider {
|
||||
get source() {
|
||||
return JSON.parse('${jsonEncode(source!.toMSource().toJson())}');
|
||||
return JSON.parse('${jsonEncode(source.toMSource().toJson())}');
|
||||
}
|
||||
get supportsLatest() {
|
||||
throw new Error("supportsLatest not implemented");
|
||||
|
|
@ -66,83 +71,57 @@ async function jsonStringify(fn) {
|
|||
return JSON.stringify(await fn());
|
||||
}
|
||||
''');
|
||||
runtime.evaluate('''${source!.sourceCode}
|
||||
runtime.evaluate('''${source.sourceCode}
|
||||
var extention = new DefaultExtension();
|
||||
''');
|
||||
}
|
||||
|
||||
Map<String, String> getHeaders(String url) {
|
||||
_init();
|
||||
try {
|
||||
final res = runtime.evaluate('JSON.stringify(extention.getHeaders(`$url`))').stringResult;
|
||||
|
||||
return (jsonDecode(res) as Map).toMapStringString!;
|
||||
} catch (_) {
|
||||
return {};
|
||||
}
|
||||
@override
|
||||
Map<String, String> getHeaders() {
|
||||
return _extensionCall<Map>('getHeaders(`${source.baseUrl ?? ''}`)', {}).toMapStringString!;
|
||||
}
|
||||
|
||||
@override
|
||||
bool get supportsLatest {
|
||||
_init();
|
||||
try {
|
||||
return jsonDecode(runtime.evaluate('JSON.stringify(extention.supportsLatest)').stringResult) as bool;
|
||||
} catch (e) {
|
||||
return true;
|
||||
}
|
||||
return _extensionCall<bool>('supportsLatest', true);
|
||||
}
|
||||
|
||||
@override
|
||||
String get sourceBaseUrl {
|
||||
return source.baseUrl!;
|
||||
}
|
||||
|
||||
@override
|
||||
Future<MPages> getPopular(int page) async {
|
||||
_init();
|
||||
final res =
|
||||
(await runtime.handlePromise(await runtime.evaluateAsync('jsonStringify(() => extention.getPopular($page))')))
|
||||
.stringResult;
|
||||
|
||||
return MPages.fromJson(jsonDecode(res));
|
||||
return MPages.fromJson(await _extensionCallAsync('getPopular($page)', {}));
|
||||
}
|
||||
|
||||
@override
|
||||
Future<MPages> getLatestUpdates(int page) async {
|
||||
_init();
|
||||
final res = (await runtime
|
||||
.handlePromise(await runtime.evaluateAsync('jsonStringify(() => extention.getLatestUpdates($page))')))
|
||||
.stringResult;
|
||||
|
||||
return MPages.fromJson(jsonDecode(res));
|
||||
return MPages.fromJson(await _extensionCallAsync('getLatestUpdates($page)', {}));
|
||||
}
|
||||
|
||||
Future<MPages> search(String query, int page, String filters) async {
|
||||
_init();
|
||||
final res = (await runtime.handlePromise(
|
||||
await runtime.evaluateAsync('jsonStringify(() => extention.search("$query",$page,$filters))')))
|
||||
.stringResult;
|
||||
|
||||
return MPages.fromJson(jsonDecode(res));
|
||||
@override
|
||||
Future<MPages> search(String query, int page, List<dynamic> filters) async {
|
||||
return MPages.fromJson(
|
||||
await _extensionCallAsync('search("$query",$page,${jsonEncode(filterValuesListToJson(filters))})', {}));
|
||||
}
|
||||
|
||||
@override
|
||||
Future<MManga> getDetail(String url) async {
|
||||
_init();
|
||||
final res =
|
||||
(await runtime.handlePromise(await runtime.evaluateAsync('jsonStringify(() => extention.getDetail(`$url`))')))
|
||||
.stringResult;
|
||||
return MManga.fromJson(jsonDecode(res));
|
||||
return MManga.fromJson(await _extensionCallAsync('getDetail(`$url`)', {}));
|
||||
}
|
||||
|
||||
@override
|
||||
Future<List<PageUrl>> getPageList(String url) async {
|
||||
_init();
|
||||
final res =
|
||||
(await runtime.handlePromise(await runtime.evaluateAsync('jsonStringify(() => extention.getPageList(`$url`))')))
|
||||
.stringResult;
|
||||
return (jsonDecode(res) as List)
|
||||
.map((e) => e is String ? PageUrl(e.toString().trim()) : PageUrl.fromJson((e as Map).toMapStringDynamic!))
|
||||
return (await _extensionCallAsync<List>('getPageList(`$url`)', []))
|
||||
.map((e) => e is String ? PageUrl(e.trim()) : PageUrl.fromJson((e as Map).toMapStringDynamic!))
|
||||
.toList();
|
||||
}
|
||||
|
||||
@override
|
||||
Future<List<Video>> getVideoList(String url) async {
|
||||
_init();
|
||||
final res = (await runtime
|
||||
.handlePromise(await runtime.evaluateAsync('jsonStringify(() => extention.getVideoList(`$url`))')))
|
||||
.stringResult;
|
||||
|
||||
return (jsonDecode(res) as List)
|
||||
return (await _extensionCallAsync<List>('getVideoList(`$url`)', []))
|
||||
.where((element) => element['url'] != null && element['originalUrl'] != null)
|
||||
.map((e) => Video.fromJson(e))
|
||||
.toList()
|
||||
|
|
@ -150,23 +129,48 @@ var extention = new DefaultExtension();
|
|||
.toList();
|
||||
}
|
||||
|
||||
dynamic getFilterList() {
|
||||
@override
|
||||
FilterList getFilterList() {
|
||||
return FilterList(fromJsonFilterValuesToList(_extensionCall('getFilterList()', [])));
|
||||
}
|
||||
|
||||
@override
|
||||
List<SourcePreference> getSourcePreferences() {
|
||||
return _extensionCall('getSourcePreferences()', [])
|
||||
.map((e) => SourcePreference.fromJson(e)..sourceId = source.id)
|
||||
.toList();
|
||||
}
|
||||
|
||||
|
||||
T _extensionCall<T>(String call, T def) {
|
||||
_init();
|
||||
|
||||
try {
|
||||
final res = runtime.evaluate('JSON.stringify(extention.getFilterList())').stringResult;
|
||||
return FilterList(fromJsonFilterValuestoList(jsonDecode(res)));
|
||||
final res = runtime.evaluate('JSON.stringify(extention.`$call`)');
|
||||
|
||||
return jsonDecode(res.stringResult) as T;
|
||||
} catch (_) {
|
||||
return [];
|
||||
if (def != null) {
|
||||
return def;
|
||||
}
|
||||
|
||||
rethrow;
|
||||
}
|
||||
}
|
||||
|
||||
List<SourcePreference> getSourcePreferences() {
|
||||
Future<T> _extensionCallAsync<T>(String call, T def) async {
|
||||
_init();
|
||||
|
||||
try {
|
||||
final res = runtime.evaluate('JSON.stringify(extention.getSourcePreferences())').stringResult;
|
||||
return (jsonDecode(res) as List).map((e) => SourcePreference.fromJson(e)..sourceId = source!.id).toList();
|
||||
final promised = await runtime.handlePromise(await runtime.evaluateAsync('jsonStringify(() => extention.$call)'));
|
||||
|
||||
return jsonDecode(promised.stringResult) as T;
|
||||
} catch (_) {
|
||||
return [];
|
||||
if (def != null) {
|
||||
return def;
|
||||
}
|
||||
|
||||
rethrow;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import 'package:flutter_qjs/flutter_qjs.dart';
|
||||
import 'package:js_packer/js_packer.dart';
|
||||
import 'package:mangayomi/eval/dart/model/m_bridge.dart';
|
||||
import 'package:mangayomi/eval/model/m_bridge.dart';
|
||||
import 'package:mangayomi/utils/cryptoaes/js_unpacker.dart';
|
||||
import 'package:mangayomi/utils/log/log.dart';
|
||||
|
||||
|
|
|
|||
12
lib/eval/lib.dart
Normal file
12
lib/eval/lib.dart
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
import 'package:mangayomi/eval/interface.dart';
|
||||
import 'package:mangayomi/models/source.dart';
|
||||
|
||||
import 'dart/service.dart';
|
||||
import 'javascript/service.dart';
|
||||
|
||||
ExtensionService getExtensionService(Source source) {
|
||||
return switch (source.sourceCodeLanguage) {
|
||||
SourceCodeLanguage.dart => DartExtensionService(source),
|
||||
SourceCodeLanguage.javascript => JsExtensionService(source),
|
||||
};
|
||||
}
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
import 'package:html/dom.dart';
|
||||
import 'package:mangayomi/eval/dart/model/element.dart';
|
||||
import 'package:mangayomi/eval/model/element.dart';
|
||||
import 'package:mangayomi/utils/extensions/dom_extensions.dart';
|
||||
|
||||
class MDocument {
|
||||
|
|
@ -4,7 +4,7 @@ class FilterList {
|
|||
List<dynamic> filters;
|
||||
FilterList(this.filters);
|
||||
factory FilterList.fromJson(Map<String, dynamic> json) {
|
||||
return FilterList(fromJsonFilterValuestoList(json['filters']));
|
||||
return FilterList(fromJsonFilterValuesToList(json['filters']));
|
||||
}
|
||||
Map<String, dynamic> toJson() => {'filters': filterValuesListToJson(filters)};
|
||||
}
|
||||
|
|
@ -19,7 +19,7 @@ class SelectFilter {
|
|||
SelectFilter(this.type, this.name, this.state, this.values, this.typeName);
|
||||
factory SelectFilter.fromJson(Map<String, dynamic> json) {
|
||||
return SelectFilter(
|
||||
json['type'], json['name'], json['state'] ?? 0, fromJsonFilterValuestoList(json['values']), json['type_name']);
|
||||
json['type'], json['name'], json['state'] ?? 0, fromJsonFilterValuesToList(json['values']), json['type_name']);
|
||||
}
|
||||
Map<String, dynamic> toJson() => {
|
||||
'type': type,
|
||||
|
|
@ -89,7 +89,7 @@ class SortFilter {
|
|||
json['type'],
|
||||
json['name'],
|
||||
json['state'] == null ? SortState(0, false, "") : SortState.fromJson(json['state']),
|
||||
fromJsonFilterValuestoList(json['values']),
|
||||
fromJsonFilterValuesToList(json['values']),
|
||||
json['type_name']);
|
||||
}
|
||||
Map<String, dynamic> toJson() => {
|
||||
|
|
@ -136,7 +136,7 @@ class GroupFilter {
|
|||
|
||||
GroupFilter(this.type, this.name, this.state, this.typeName);
|
||||
factory GroupFilter.fromJson(Map<String, dynamic> json) {
|
||||
return GroupFilter(json['type'], json['name'], fromJsonFilterValuestoList(json['state']), json['type_name']);
|
||||
return GroupFilter(json['type'], json['name'], fromJsonFilterValuesToList(json['state']), json['type_name']);
|
||||
}
|
||||
Map<String, dynamic> toJson() =>
|
||||
{'type': type, 'name': name, 'state': filterValuesListToJson(state), 'type_name': "GroupFilter"};
|
||||
|
|
@ -157,31 +157,27 @@ class CheckBoxFilter {
|
|||
{'type': type, 'name': name, 'value': value, 'state': state, 'type_name': "CheckBox"};
|
||||
}
|
||||
|
||||
List<dynamic> fromJsonFilterValuestoList(List list) {
|
||||
return list.map((e) {
|
||||
final map = (e as Map).toMapStringDynamic!;
|
||||
if (map['type_name'] == 'TriState') {
|
||||
return TriStateFilter.fromJson(map.toMapStringDynamic!);
|
||||
} else if (map['type_name'] == 'CheckBox') {
|
||||
return CheckBoxFilter.fromJson(map.toMapStringDynamic!);
|
||||
} else if (map['type_name'] == 'SelectOption') {
|
||||
return SelectFilterOption.fromJson(map.toMapStringDynamic!);
|
||||
} else if (map['type_name'] == 'SelectFilter') {
|
||||
return SelectFilter.fromJson(map.toMapStringDynamic!);
|
||||
} else if (map['type_name'] == 'SeparatorFilter') {
|
||||
return SeparatorFilter.fromJson(map.toMapStringDynamic!);
|
||||
} else if (map['type_name'] == 'HeaderFilter') {
|
||||
return HeaderFilter.fromJson(map.toMapStringDynamic!);
|
||||
} else if (map['type_name'] == 'TextFilter') {
|
||||
return TextFilter.fromJson(map.toMapStringDynamic!);
|
||||
} else if (map['type_name'] == 'SortFilter') {
|
||||
return SortFilter.fromJson(map.toMapStringDynamic!);
|
||||
} else if (map['type_name'] == 'SortState') {
|
||||
return SortState.fromJson(map.toMapStringDynamic!);
|
||||
} else if (map['type_name'] == 'GroupFilter') {
|
||||
return GroupFilter.fromJson(map.toMapStringDynamic!);
|
||||
}
|
||||
}).toList();
|
||||
List<dynamic> fromJsonFilterValuesToList(List list) {
|
||||
return list
|
||||
.map((e) {
|
||||
final map = (e as Map).toMapStringDynamic!;
|
||||
|
||||
return switch (map['type_name']) {
|
||||
'TriState' => TriStateFilter.fromJson(map.toMapStringDynamic!),
|
||||
'CheckBox' => CheckBoxFilter.fromJson(map.toMapStringDynamic!),
|
||||
'SelectOption' => SelectFilterOption.fromJson(map.toMapStringDynamic!),
|
||||
'SelectFilter' => SelectFilter.fromJson(map.toMapStringDynamic!),
|
||||
'SeparatorFilter' => SeparatorFilter.fromJson(map.toMapStringDynamic!),
|
||||
'HeaderFilter' => HeaderFilter.fromJson(map.toMapStringDynamic!),
|
||||
'TextFilter' => TextFilter.fromJson(map.toMapStringDynamic!),
|
||||
'SortFilter' => SortFilter.fromJson(map.toMapStringDynamic!),
|
||||
'SortState' => SortState.fromJson(map.toMapStringDynamic!),
|
||||
'GroupFilter' => GroupFilter.fromJson(map.toMapStringDynamic!),
|
||||
_ => null,
|
||||
};
|
||||
})
|
||||
.where((filter) => filter != null)
|
||||
.toList();
|
||||
}
|
||||
|
||||
List<Map<String, dynamic>?> filterValuesListToJson(List<dynamic> values) {
|
||||
|
|
@ -9,7 +9,7 @@ import 'package:intl/date_symbol_data_local.dart';
|
|||
import 'package:intl/intl.dart';
|
||||
import 'package:js_packer/js_packer.dart';
|
||||
import 'package:json_path/json_path.dart';
|
||||
import 'package:mangayomi/eval/dart/model/document.dart';
|
||||
import 'package:mangayomi/eval/model/document.dart';
|
||||
import 'package:mangayomi/eval/javascript/http.dart';
|
||||
import 'package:mangayomi/models/manga.dart';
|
||||
import 'package:mangayomi/router/router.dart';
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
import 'package:mangayomi/eval/dart/model/m_chapter.dart';
|
||||
import 'package:mangayomi/eval/model/m_chapter.dart';
|
||||
import 'package:mangayomi/models/manga.dart';
|
||||
import 'package:mangayomi/utils/extensions/string_extensions.dart';
|
||||
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
import 'package:mangayomi/eval/dart/model/m_manga.dart';
|
||||
import 'package:mangayomi/eval/model/m_manga.dart';
|
||||
|
||||
class MPages {
|
||||
List<MManga> list;
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
import 'package:mangayomi/eval/dart/model/filter.dart';
|
||||
import 'package:mangayomi/eval/dart/model/m_pages.dart';
|
||||
import 'package:mangayomi/eval/dart/model/m_manga.dart';
|
||||
import 'package:mangayomi/eval/model/filter.dart';
|
||||
import 'package:mangayomi/eval/model/m_manga.dart';
|
||||
import 'package:mangayomi/eval/model/m_pages.dart';
|
||||
import 'package:mangayomi/models/video.dart';
|
||||
|
||||
abstract class MProvider {
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
import 'package:isar/isar.dart';
|
||||
import 'package:mangayomi/eval/dart/model/m_source.dart';
|
||||
import 'package:mangayomi/eval/model/m_source.dart';
|
||||
part 'source.g.dart';
|
||||
|
||||
@collection
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_code_editor/flutter_code_editor.dart';
|
||||
import 'package:flutter_highlight/themes/atom-one-dark.dart';
|
||||
import 'package:highlight/highlight.dart';
|
||||
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/service.dart';
|
||||
import 'package:mangayomi/eval/javascript/service.dart';
|
||||
import 'package:mangayomi/eval/lib.dart';
|
||||
import 'package:mangayomi/main.dart';
|
||||
import 'package:mangayomi/models/source.dart';
|
||||
import 'package:mangayomi/modules/manga/home/widget/filter_widget.dart';
|
||||
|
|
@ -27,16 +27,20 @@ class CodeEditor extends ConsumerStatefulWidget {
|
|||
ConsumerState<CodeEditor> createState() => _CodeEditorState();
|
||||
}
|
||||
|
||||
Mode getSourceMode(Source? source) {
|
||||
return switch (source?.sourceCodeLanguage) {
|
||||
SourceCodeLanguage.dart => dart,
|
||||
SourceCodeLanguage.javascript => javascript,
|
||||
_ => dart,
|
||||
};
|
||||
}
|
||||
|
||||
class _CodeEditorState extends ConsumerState<CodeEditor> {
|
||||
dynamic result;
|
||||
late final source = widget.sourceId == null ? null : isar.sources.getSync(widget.sourceId!);
|
||||
late final controller = CodeController(
|
||||
text: source?.sourceCode ?? "",
|
||||
language: source == null
|
||||
? dart
|
||||
: source!.sourceCodeLanguage == SourceCodeLanguage.dart
|
||||
? dart
|
||||
: javascript,
|
||||
language: getSourceMode(source),
|
||||
namedSectionParser: const BracketsStartEndNamedSectionParser());
|
||||
|
||||
List<(String, int)> _getServices(BuildContext context) => [
|
||||
|
|
@ -224,6 +228,8 @@ class _CodeEditorState extends ConsumerState<CodeEditor> {
|
|||
_errorText = "";
|
||||
});
|
||||
if (source != null) {
|
||||
final service = getExtensionService(source!);
|
||||
|
||||
try {
|
||||
if (_serviceIndex == 0) {
|
||||
final getManga =
|
||||
|
|
@ -243,26 +249,15 @@ class _CodeEditorState extends ConsumerState<CodeEditor> {
|
|||
await ref.watch(getDetailProvider(source: source!, url: _url).future);
|
||||
result = getManga.toJson();
|
||||
} else if (_serviceIndex == 4) {
|
||||
if (source!.sourceCodeLanguage == SourceCodeLanguage.dart) {
|
||||
result = (await DartExtensionService(source).getPageList(_url))
|
||||
result = {
|
||||
"pages": (await service.getPageList(_url))
|
||||
.map((e) => e.toJson())
|
||||
.toList();
|
||||
} else {
|
||||
result = (await JsExtensionService(source).getPageList(_url))
|
||||
.map((e) => e.toJson())
|
||||
.toList();
|
||||
}
|
||||
result = {"pages": result};
|
||||
.toList(),
|
||||
};
|
||||
} else {
|
||||
if (source!.sourceCodeLanguage == SourceCodeLanguage.dart) {
|
||||
result = (await DartExtensionService(source).getVideoList(_url))
|
||||
.map((e) => e.toJson())
|
||||
.toList();
|
||||
} else {
|
||||
result = (await JsExtensionService(source).getVideoList(_url))
|
||||
.map((e) => e.toJson())
|
||||
.toList();
|
||||
}
|
||||
result = (await service.getVideoList(_url))
|
||||
.map((e) => e.toJson())
|
||||
.toList();
|
||||
}
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
|
|
|
|||
|
|
@ -2,8 +2,8 @@ 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/dart/model/m_bridge.dart';
|
||||
import 'package:mangayomi/eval/dart/model/source_preference.dart';
|
||||
import 'package:mangayomi/eval/model/m_bridge.dart';
|
||||
import 'package:mangayomi/eval/model/source_preference.dart';
|
||||
import 'package:mangayomi/main.dart';
|
||||
import 'package:mangayomi/models/source.dart';
|
||||
import 'package:mangayomi/modules/browse/extension/providers/extension_preferences_providers.dart';
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import 'package:isar/isar.dart';
|
||||
import 'package:mangayomi/eval/dart/model/source_preference.dart';
|
||||
import 'package:mangayomi/eval/model/source_preference.dart';
|
||||
import 'package:mangayomi/main.dart';
|
||||
import 'package:mangayomi/models/source.dart';
|
||||
import 'package:mangayomi/services/get_source_preference.dart';
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:mangayomi/eval/dart/model/m_bridge.dart';
|
||||
import 'package:mangayomi/eval/model/m_bridge.dart';
|
||||
import 'package:mangayomi/main.dart';
|
||||
import 'package:mangayomi/models/source.dart';
|
||||
import 'package:mangayomi/providers/l10n_providers.dart';
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:mangayomi/eval/dart/model/source_preference.dart';
|
||||
import 'package:mangayomi/eval/model/source_preference.dart';
|
||||
import 'package:mangayomi/models/source.dart';
|
||||
import 'package:mangayomi/modules/browse/extension/providers/extension_preferences_providers.dart';
|
||||
import 'package:mangayomi/modules/manga/detail/widgets/chapter_filter_list_tile_widget.dart';
|
||||
|
|
|
|||
|
|
@ -2,8 +2,8 @@ import 'dart:typed_data';
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:isar/isar.dart';
|
||||
import 'package:mangayomi/eval/dart/model/m_manga.dart';
|
||||
import 'package:mangayomi/eval/dart/model/m_pages.dart';
|
||||
import 'package:mangayomi/eval/model/m_manga.dart';
|
||||
import 'package:mangayomi/eval/model/m_pages.dart';
|
||||
import 'package:mangayomi/main.dart';
|
||||
import 'package:mangayomi/models/manga.dart';
|
||||
import 'package:mangayomi/modules/manga/home/manga_home_screen.dart';
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ import 'package:flutter/services.dart';
|
|||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:isar/isar.dart';
|
||||
import 'package:mangayomi/eval/dart/model/m_bridge.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';
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ import 'package:flutter/rendering.dart';
|
|||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:isar/isar.dart';
|
||||
import 'package:mangayomi/eval/dart/model/m_bridge.dart';
|
||||
import 'package:mangayomi/eval/model/m_bridge.dart';
|
||||
import 'package:mangayomi/main.dart';
|
||||
import 'package:mangayomi/models/chapter.dart';
|
||||
import 'package:mangayomi/models/download.dart';
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import 'package:mangayomi/eval/dart/model/m_bridge.dart';
|
||||
import 'package:mangayomi/eval/dart/model/m_manga.dart';
|
||||
import 'package:mangayomi/eval/model/m_bridge.dart';
|
||||
import 'package:mangayomi/eval/model/m_manga.dart';
|
||||
import 'package:mangayomi/main.dart';
|
||||
import 'package:mangayomi/models/chapter.dart';
|
||||
import 'package:mangayomi/models/update.dart';
|
||||
|
|
|
|||
|
|
@ -2,8 +2,8 @@ import 'dart:async';
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:mangayomi/eval/dart/model/m_manga.dart';
|
||||
import 'package:mangayomi/eval/dart/model/m_pages.dart';
|
||||
import 'package:mangayomi/eval/model/m_manga.dart';
|
||||
import 'package:mangayomi/eval/model/m_pages.dart';
|
||||
import 'package:mangayomi/models/settings.dart';
|
||||
import 'package:mangayomi/models/source.dart';
|
||||
import 'package:mangayomi/modules/library/providers/library_state_provider.dart';
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:mangayomi/eval/dart/model/filter.dart';
|
||||
import 'package:mangayomi/eval/model/filter.dart';
|
||||
import 'package:mangayomi/utils/extensions/build_context_extensions.dart';
|
||||
|
||||
class FilterWidget extends StatelessWidget {
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ import 'package:flutter/services.dart';
|
|||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:mangayomi/eval/dart/model/m_bridge.dart';
|
||||
import 'package:mangayomi/eval/model/m_bridge.dart';
|
||||
import 'package:mangayomi/main.dart';
|
||||
import 'package:mangayomi/models/chapter.dart';
|
||||
import 'package:mangayomi/models/manga.dart';
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ import 'dart:io';
|
|||
import 'package:file_picker/file_picker.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:mangayomi/eval/dart/model/m_bridge.dart';
|
||||
import 'package:mangayomi/eval/model/m_bridge.dart';
|
||||
import 'package:mangayomi/modules/manga/detail/widgets/chapter_filter_list_tile_widget.dart';
|
||||
import 'package:mangayomi/modules/more/backup_and_restore/providers/auto_backup.dart';
|
||||
import 'package:mangayomi/modules/more/backup_and_restore/providers/backup.dart';
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import 'package:archive/archive_io.dart';
|
|||
import 'package:bot_toast/bot_toast.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:isar/isar.dart';
|
||||
import 'package:mangayomi/eval/dart/model/source_preference.dart';
|
||||
import 'package:mangayomi/eval/model/source_preference.dart';
|
||||
import 'package:mangayomi/main.dart';
|
||||
import 'package:mangayomi/models/category.dart';
|
||||
import 'package:mangayomi/models/chapter.dart';
|
||||
|
|
|
|||
|
|
@ -3,8 +3,8 @@ import 'package:archive/archive_io.dart';
|
|||
import 'package:bot_toast/bot_toast.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:isar/isar.dart';
|
||||
import 'package:mangayomi/eval/dart/model/m_bridge.dart';
|
||||
import 'package:mangayomi/eval/dart/model/source_preference.dart';
|
||||
import 'package:mangayomi/eval/model/m_bridge.dart';
|
||||
import 'package:mangayomi/eval/model/source_preference.dart';
|
||||
import 'package:mangayomi/main.dart';
|
||||
import 'package:mangayomi/models/category.dart';
|
||||
import 'package:mangayomi/models/chapter.dart';
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|||
import 'package:grouped_list/sliver_grouped_list.dart';
|
||||
|
||||
import 'package:isar/isar.dart';
|
||||
import 'package:mangayomi/eval/dart/model/m_bridge.dart';
|
||||
import 'package:mangayomi/eval/model/m_bridge.dart';
|
||||
import 'package:mangayomi/main.dart';
|
||||
import 'package:mangayomi/models/chapter.dart';
|
||||
import 'package:mangayomi/models/update.dart';
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ 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/dart/model/m_manga.dart';
|
||||
import 'package:mangayomi/eval/model/m_manga.dart';
|
||||
import 'package:mangayomi/main.dart';
|
||||
import 'package:mangayomi/models/manga.dart';
|
||||
import 'package:mangayomi/models/settings.dart';
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
// ignore_for_file: depend_on_referenced_packages
|
||||
import 'dart:io';
|
||||
import 'package:isar/isar.dart';
|
||||
import 'package:mangayomi/eval/dart/model/source_preference.dart';
|
||||
import 'package:mangayomi/eval/model/source_preference.dart';
|
||||
import 'package:mangayomi/main.dart';
|
||||
import 'package:mangayomi/models/category.dart';
|
||||
import 'package:mangayomi/models/changed_items.dart';
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import 'dart:convert';
|
||||
import 'package:html/dom.dart';
|
||||
import 'package:http_interceptor/http_interceptor.dart';
|
||||
import 'package:mangayomi/eval/dart/model/m_bridge.dart';
|
||||
import 'package:mangayomi/eval/model/m_bridge.dart';
|
||||
import 'package:mangayomi/models/video.dart';
|
||||
import 'package:html/parser.dart' as parser;
|
||||
import 'package:mangayomi/services/http/m_client.dart';
|
||||
|
|
|
|||
|
|
@ -1,8 +1,7 @@
|
|||
import 'dart:convert';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:isar/isar.dart';
|
||||
import 'package:mangayomi/eval/dart/service.dart';
|
||||
import 'package:mangayomi/eval/javascript/service.dart';
|
||||
import 'package:mangayomi/eval/lib.dart';
|
||||
import 'package:mangayomi/main.dart';
|
||||
import 'package:mangayomi/models/source.dart';
|
||||
import 'package:mangayomi/modules/more/settings/browse/providers/browse_state_provider.dart';
|
||||
|
|
@ -26,7 +25,7 @@ Future<void> fetchSourcesList(
|
|||
if (id == source.id) {
|
||||
final sourc = isar.sources.getSync(id)!;
|
||||
final req = await http.get(Uri.parse(source.sourceCodeUrl!));
|
||||
final headers = getSourceHeaders(source..sourceCode = req.body);
|
||||
final headers = getExtensionService(source..sourceCode = req.body).getHeaders();
|
||||
isar.writeTxnSync(() {
|
||||
isar.sources.putSync(sourc
|
||||
..headers = jsonEncode(headers)
|
||||
|
|
@ -60,10 +59,10 @@ Future<void> fetchSourcesList(
|
|||
final sourc = isar.sources.getSync(source.id!)!;
|
||||
if (sourc.isAdded!) {
|
||||
if (compareVersions(sourc.version!, source.version!) < 0) {
|
||||
// log("update aivalable auto update");
|
||||
// log("update available auto update");
|
||||
if (ref.watch(autoUpdateExtensionsStateProvider)) {
|
||||
final req = await http.get(Uri.parse(source.sourceCodeUrl!));
|
||||
final headers = getSourceHeaders(source..sourceCode = req.body);
|
||||
final headers = getExtensionService(source..sourceCode = req.body).getHeaders();
|
||||
isar.writeTxnSync(() {
|
||||
isar.sources.putSync(sourc
|
||||
..headers = jsonEncode(headers)
|
||||
|
|
@ -179,13 +178,3 @@ int compareVersions(String version1, String version2) {
|
|||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Map<String, String> getSourceHeaders(Source source) {
|
||||
Map<String, String> headers = {};
|
||||
if (source.sourceCodeLanguage == SourceCodeLanguage.javascript) {
|
||||
headers = JsExtensionService(source).getHeaders(source.baseUrl ?? "");
|
||||
} else {
|
||||
headers = DartExtensionService(source).getHeaders();
|
||||
}
|
||||
return headers;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,14 +1,12 @@
|
|||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
import 'dart:typed_data';
|
||||
import 'package:mangayomi/eval/dart/service.dart';
|
||||
import 'package:mangayomi/eval/lib.dart';
|
||||
import 'package:mangayomi/eval/javascript/http.dart';
|
||||
import 'package:mangayomi/eval/javascript/service.dart';
|
||||
import 'package:mangayomi/main.dart';
|
||||
import 'package:mangayomi/models/chapter.dart';
|
||||
import 'package:mangayomi/models/page.dart';
|
||||
import 'package:mangayomi/models/settings.dart';
|
||||
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';
|
||||
|
|
@ -63,11 +61,7 @@ Future<GetChapterPagesModel> getChapterPages(
|
|||
pageUrls.add(PageUrl(isarPageUrls.first.urls![i], headers: headers));
|
||||
}
|
||||
} else {
|
||||
if (source.sourceCodeLanguage == SourceCodeLanguage.dart) {
|
||||
pageUrls = await DartExtensionService(source).getPageList(chapter.url!);
|
||||
} else {
|
||||
pageUrls = await JsExtensionService(source).getPageList(chapter.url!);
|
||||
}
|
||||
pageUrls = await getExtensionService(source).getPageList(chapter.url!);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ part of 'get_chapter_pages.dart';
|
|||
// RiverpodGenerator
|
||||
// **************************************************************************
|
||||
|
||||
String _$getChapterPagesHash() => r'c806798536b6d4ca5b2a51417f12c648100cfc44';
|
||||
String _$getChapterPagesHash() => r'8a2606a6640046cb006b24516bf88512f3204aca';
|
||||
|
||||
/// Copied from Dart SDK
|
||||
class _SystemHash {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
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/lib.dart';
|
||||
import 'package:mangayomi/eval/model/m_manga.dart';
|
||||
import 'package:mangayomi/models/source.dart';
|
||||
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
|
|
@ -12,11 +11,5 @@ Future<MManga> getDetail(
|
|||
required String url,
|
||||
required Source source,
|
||||
}) async {
|
||||
MManga? mangadetail;
|
||||
if (source.sourceCodeLanguage == SourceCodeLanguage.dart) {
|
||||
mangadetail = await DartExtensionService(source).getDetail(url);
|
||||
} else {
|
||||
mangadetail = await JsExtensionService(source).getDetail(url);
|
||||
}
|
||||
return mangadetail;
|
||||
return getExtensionService(source).getDetail(url);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ part of 'get_detail.dart';
|
|||
// RiverpodGenerator
|
||||
// **************************************************************************
|
||||
|
||||
String _$getDetailHash() => r'c9e268bb19e786b3bb160023f74336b80da65b6c';
|
||||
String _$getDetailHash() => r'84cc79aa0fd35a2d8efa95f75b85978f521c5daa';
|
||||
|
||||
/// Copied from Dart SDK
|
||||
class _SystemHash {
|
||||
|
|
|
|||
|
|
@ -1,19 +1,10 @@
|
|||
import 'package:mangayomi/eval/dart/service.dart';
|
||||
import 'package:mangayomi/eval/javascript/service.dart';
|
||||
import 'package:mangayomi/eval/lib.dart';
|
||||
import 'package:mangayomi/models/source.dart';
|
||||
|
||||
List<dynamic> getFilterList({required Source source}) {
|
||||
List<dynamic> filterList = [];
|
||||
|
||||
try {
|
||||
if (source.sourceCodeLanguage == SourceCodeLanguage.dart) {
|
||||
filterList = DartExtensionService(source).getFilterList();
|
||||
} else {
|
||||
filterList = (JsExtensionService(source).getFilterList()).filters;
|
||||
}
|
||||
return getExtensionService(source).getFilterList().filters;
|
||||
} catch (_) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return filterList;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
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/lib.dart';
|
||||
import 'package:mangayomi/eval/model/m_pages.dart';
|
||||
import 'package:mangayomi/models/source.dart';
|
||||
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
|
|
@ -12,11 +11,5 @@ Future<MPages?> getLatestUpdates(
|
|||
required Source source,
|
||||
required int page,
|
||||
}) async {
|
||||
MPages? latestUpdatesManga;
|
||||
if (source.sourceCodeLanguage == SourceCodeLanguage.dart) {
|
||||
latestUpdatesManga = await DartExtensionService(source).getLatestUpdates(page);
|
||||
} else {
|
||||
latestUpdatesManga = await JsExtensionService(source).getLatestUpdates(page);
|
||||
}
|
||||
return latestUpdatesManga;
|
||||
return getExtensionService(source).getLatestUpdates(page);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ part of 'get_latest_updates.dart';
|
|||
// RiverpodGenerator
|
||||
// **************************************************************************
|
||||
|
||||
String _$getLatestUpdatesHash() => r'ed983c23ad7d8a1af4332230537daede29b9275e';
|
||||
String _$getLatestUpdatesHash() => r'93e1ba376d14006110e9a6c06d191ffd12b1fdfb';
|
||||
|
||||
/// Copied from Dart SDK
|
||||
class _SystemHash {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
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/lib.dart';
|
||||
import 'package:mangayomi/eval/model/m_pages.dart';
|
||||
import 'package:mangayomi/models/source.dart';
|
||||
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
|
|
@ -12,12 +11,5 @@ Future<MPages?> getPopular(
|
|||
required Source source,
|
||||
required int page,
|
||||
}) async {
|
||||
MPages? popularManga;
|
||||
if (source.sourceCodeLanguage == SourceCodeLanguage.dart) {
|
||||
popularManga = await DartExtensionService(source).getPopular(page);
|
||||
} else {
|
||||
popularManga = await JsExtensionService(source).getPopular(page);
|
||||
}
|
||||
|
||||
return popularManga;
|
||||
return getExtensionService(source).getPopular(page);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ part of 'get_popular.dart';
|
|||
// RiverpodGenerator
|
||||
// **************************************************************************
|
||||
|
||||
String _$getPopularHash() => r'2db0191dd013043970cfac2153e22054b0927ad1';
|
||||
String _$getPopularHash() => r'02291ff9c3eba594b2344b853c34b2cea7be491b';
|
||||
|
||||
/// Copied from Dart SDK
|
||||
class _SystemHash {
|
||||
|
|
|
|||
|
|
@ -1,18 +1,11 @@
|
|||
import 'package:mangayomi/eval/dart/service.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:mangayomi/eval/lib.dart';
|
||||
import 'package:mangayomi/models/source.dart';
|
||||
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
|
||||
part 'get_source_baseurl.g.dart';
|
||||
|
||||
@riverpod
|
||||
String sourceBaseUrl(Ref ref, {required Source source}) {
|
||||
String? baseUrl;
|
||||
if (source.sourceCodeLanguage == SourceCodeLanguage.dart) {
|
||||
baseUrl = DartExtensionService(source).sourceBaseUrl;
|
||||
} else {}
|
||||
if (baseUrl == null || baseUrl.isEmpty) {
|
||||
baseUrl = source.baseUrl;
|
||||
}
|
||||
|
||||
return baseUrl!;
|
||||
return getExtensionService(source).sourceBaseUrl;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ part of 'get_source_baseurl.dart';
|
|||
// RiverpodGenerator
|
||||
// **************************************************************************
|
||||
|
||||
String _$sourceBaseUrlHash() => r'853fdcc3b12f567c7570a8569c7832234d2bf7bf';
|
||||
String _$sourceBaseUrlHash() => r'2eaf2f441085cec9e2f035763ef2ec64aa00f838';
|
||||
|
||||
/// Copied from Dart SDK
|
||||
class _SystemHash {
|
||||
|
|
|
|||
|
|
@ -1,16 +1,7 @@
|
|||
import 'package:mangayomi/eval/dart/service.dart';
|
||||
import 'package:mangayomi/eval/javascript/service.dart';
|
||||
import 'package:mangayomi/eval/dart/model/source_preference.dart';
|
||||
import 'package:mangayomi/eval/lib.dart';
|
||||
import 'package:mangayomi/eval/model/source_preference.dart';
|
||||
import 'package:mangayomi/models/source.dart';
|
||||
|
||||
List<SourcePreference> getSourcePreference({required Source source}) {
|
||||
List<SourcePreference> sourcePreference = [];
|
||||
|
||||
if (source.sourceCodeLanguage == SourceCodeLanguage.dart) {
|
||||
sourcePreference = DartExtensionService(source).getSourcePreferences();
|
||||
} else {
|
||||
sourcePreference = JsExtensionService(source).getSourcePreferences();
|
||||
}
|
||||
|
||||
return sourcePreference;
|
||||
return getExtensionService(source).getSourcePreferences();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,9 +1,7 @@
|
|||
import 'dart:async';
|
||||
import 'dart:io';
|
||||
import 'package:mangayomi/eval/dart/service.dart';
|
||||
import 'package:mangayomi/eval/javascript/service.dart';
|
||||
import 'package:mangayomi/eval/lib.dart';
|
||||
import 'package:mangayomi/models/chapter.dart';
|
||||
import 'package:mangayomi/models/source.dart';
|
||||
import 'package:mangayomi/models/video.dart';
|
||||
import 'package:mangayomi/providers/storage_provider.dart';
|
||||
import 'package:mangayomi/services/torrent_server.dart';
|
||||
|
|
@ -34,11 +32,9 @@ Future<(List<Video>, bool, List<String>)> getVideoList(Ref ref, {required Chapte
|
|||
final (videos, infohash) = await MTorrentServer().getTorrentPlaylist(episode.url, episode.archivePath);
|
||||
return (videos, false, [infohash ?? ""]);
|
||||
}
|
||||
if (source?.sourceCodeLanguage == SourceCodeLanguage.dart) {
|
||||
list = await DartExtensionService(source).getVideoList(episode.url!);
|
||||
} else {
|
||||
list = await JsExtensionService(source).getVideoList(episode.url!);
|
||||
}
|
||||
|
||||
list = await getExtensionService(source!).getVideoList(episode.url!);
|
||||
|
||||
for (var v in list) {
|
||||
final (videos, infohash) = await MTorrentServer().getTorrentPlaylist(v.url, episode.archivePath);
|
||||
for (var video in videos) {
|
||||
|
|
@ -51,17 +47,14 @@ Future<(List<Video>, bool, List<String>)> getVideoList(Ref ref, {required Chapte
|
|||
return (torrentList, false, infoHashes);
|
||||
}
|
||||
|
||||
List<Video> list = [];
|
||||
if (source?.sourceCodeLanguage == SourceCodeLanguage.dart) {
|
||||
list = await DartExtensionService(source).getVideoList(episode.url!);
|
||||
} else {
|
||||
list = await JsExtensionService(source).getVideoList(episode.url!);
|
||||
}
|
||||
List<Video> list = await getExtensionService(source!).getVideoList(episode.url!);
|
||||
List<Video> videos = [];
|
||||
|
||||
for (var video in list) {
|
||||
if (!videos.any((element) => element.quality == video.quality)) {
|
||||
videos.add(video);
|
||||
}
|
||||
}
|
||||
|
||||
return (videos, false, infoHashes);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ part of 'get_video_list.dart';
|
|||
// RiverpodGenerator
|
||||
// **************************************************************************
|
||||
|
||||
String _$getVideoListHash() => r'4cea633e8a21ede6dce9903baef0c978f4826def';
|
||||
String _$getVideoListHash() => r'bae6a3cbc064163148577d0646b87a3f16d44da7';
|
||||
|
||||
/// Copied from Dart SDK
|
||||
class _SystemHash {
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
import 'package:http_interceptor/http_interceptor.dart';
|
||||
import 'package:mangayomi/eval/dart/model/m_bridge.dart';
|
||||
import 'package:mangayomi/eval/model/m_bridge.dart';
|
||||
import 'dart:async';
|
||||
import 'dart:io';
|
||||
import 'package:mangayomi/eval/dart/model/m_source.dart';
|
||||
import 'package:mangayomi/eval/model/m_source.dart';
|
||||
import 'package:mangayomi/main.dart';
|
||||
import 'package:flutter_inappwebview/flutter_inappwebview.dart' as flutter_inappwebview;
|
||||
import 'package:mangayomi/models/settings.dart';
|
||||
|
|
|
|||
|
|
@ -1,21 +1,17 @@
|
|||
import 'dart:convert';
|
||||
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/lib.dart';
|
||||
import 'package:mangayomi/eval/model/m_pages.dart';
|
||||
import 'package:mangayomi/models/source.dart';
|
||||
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
part 'search.g.dart';
|
||||
|
||||
@riverpod
|
||||
Future<MPages?> search(Ref ref,
|
||||
{required Source source, required String query, required int page, required List<dynamic> filterList}) async {
|
||||
MPages? manga;
|
||||
if (source.sourceCodeLanguage == SourceCodeLanguage.dart) {
|
||||
manga = await DartExtensionService(source).search(query, page, filterList);
|
||||
} else {
|
||||
manga = await JsExtensionService(source).search(query, page, jsonEncode(filterValuesListToJson(filterList)));
|
||||
}
|
||||
return manga;
|
||||
Future<MPages?> search(
|
||||
Ref ref, {
|
||||
required Source source,
|
||||
required String query,
|
||||
required int page,
|
||||
required List<dynamic> filterList,
|
||||
}) async {
|
||||
return getExtensionService(source).search(query, page, filterList);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ part of 'search.dart';
|
|||
// RiverpodGenerator
|
||||
// **************************************************************************
|
||||
|
||||
String _$searchHash() => r'c0e7eb3604d2a065762e444cff1dfc5b44ae7da4';
|
||||
String _$searchHash() => r'8ef361b28d7a569b9f5babd69eb83efd9d9814d7';
|
||||
|
||||
/// Copied from Dart SDK
|
||||
class _SystemHash {
|
||||
|
|
|
|||
|
|
@ -1,17 +1,12 @@
|
|||
import 'dart:convert';
|
||||
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/lib.dart';
|
||||
import 'package:mangayomi/eval/model/m_pages.dart';
|
||||
import 'package:mangayomi/models/source.dart';
|
||||
|
||||
Future<MPages?> search(
|
||||
{required Source source, required String query, required int page, required List<dynamic> filterList}) async {
|
||||
MPages? manga;
|
||||
if (source.sourceCodeLanguage == SourceCodeLanguage.dart) {
|
||||
manga = await DartExtensionService(source).search(query, page, filterList);
|
||||
} else {
|
||||
manga = await JsExtensionService(source).search(query, page, jsonEncode(filterValuesListToJson(filterList)));
|
||||
}
|
||||
return manga;
|
||||
Future<MPages?> search({
|
||||
required Source source,
|
||||
required String query,
|
||||
required int page,
|
||||
required List<dynamic> filterList,
|
||||
}) async {
|
||||
return getExtensionService(source).search(query, page, filterList);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
import 'package:mangayomi/eval/dart/service.dart';
|
||||
import 'package:mangayomi/eval/javascript/service.dart';
|
||||
import 'package:mangayomi/eval/lib.dart';
|
||||
import 'package:mangayomi/models/source.dart';
|
||||
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
|
|
@ -7,11 +6,5 @@ part 'supports_latest.g.dart';
|
|||
|
||||
@riverpod
|
||||
bool supportsLatest(Ref ref, {required Source source}) {
|
||||
bool? supportsLatest;
|
||||
if (source.sourceCodeLanguage == SourceCodeLanguage.dart) {
|
||||
supportsLatest = DartExtensionService(source).supportsLatest;
|
||||
} else {
|
||||
supportsLatest = JsExtensionService(source).supportsLatest;
|
||||
}
|
||||
return supportsLatest;
|
||||
return getExtensionService(source).supportsLatest;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ part of 'supports_latest.dart';
|
|||
// RiverpodGenerator
|
||||
// **************************************************************************
|
||||
|
||||
String _$supportsLatestHash() => r'7c4e12c2d8ff213789b50a7aceddd4694badc2e1';
|
||||
String _$supportsLatestHash() => r'71f77f99b86f2f597ec728add2483a5623f4984a';
|
||||
|
||||
/// Copied from Dart SDK
|
||||
class _SystemHash {
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import 'package:crypto/crypto.dart';
|
||||
import 'package:isar/isar.dart';
|
||||
import 'package:mangayomi/eval/dart/model/m_bridge.dart';
|
||||
import 'package:mangayomi/eval/dart/model/source_preference.dart';
|
||||
import 'package:mangayomi/eval/model/m_bridge.dart';
|
||||
import 'package:mangayomi/eval/model/source_preference.dart';
|
||||
import 'package:mangayomi/main.dart';
|
||||
import 'package:mangayomi/models/changed_items.dart';
|
||||
import 'package:mangayomi/models/update.dart';
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import 'dart:io';
|
||||
import 'package:flutter_web_auth_2/flutter_web_auth_2.dart';
|
||||
import 'package:mangayomi/eval/dart/model/m_bridge.dart';
|
||||
import 'package:mangayomi/eval/model/m_bridge.dart';
|
||||
import 'package:mangayomi/main.dart';
|
||||
import 'package:mangayomi/models/track.dart';
|
||||
import 'package:mangayomi/models/track_preference.dart';
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import 'dart:developer';
|
||||
import 'package:http_interceptor/http_interceptor.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:mangayomi/eval/dart/model/m_bridge.dart';
|
||||
import 'package:mangayomi/eval/model/m_bridge.dart';
|
||||
import 'package:mangayomi/models/track.dart';
|
||||
import 'package:mangayomi/models/track_preference.dart';
|
||||
import 'dart:convert';
|
||||
|
|
|
|||
|
|
@ -1,23 +1,30 @@
|
|||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:mangayomi/eval/javascript/http.dart';
|
||||
import 'package:mangayomi/services/fetch_sources_list.dart';
|
||||
import 'package:mangayomi/eval/lib.dart';
|
||||
import 'package:mangayomi/services/http/m_client.dart';
|
||||
import 'package:mangayomi/utils/utils.dart';
|
||||
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
|
||||
part 'headers.g.dart';
|
||||
|
||||
@riverpod
|
||||
Map<String, String> headers(Ref ref, {required String source, required String lang}) {
|
||||
final mSource = getSource(lang, source);
|
||||
if (mSource == null) return {};
|
||||
|
||||
Map<String, String> headers = {};
|
||||
if (mSource.headers?.isNotEmpty ?? false) {
|
||||
headers = (jsonDecode(mSource.headers!) as Map).toMapStringString!;
|
||||
|
||||
if (mSource != null) {
|
||||
final fromSource = mSource.headers;
|
||||
|
||||
if (fromSource != null && fromSource.isNotEmpty) {
|
||||
headers.addAll((jsonDecode(fromSource) as Map).toMapStringString!);
|
||||
}
|
||||
|
||||
headers.addAll(getExtensionService(mSource).getHeaders());
|
||||
headers.addAll(MClient.getCookiesPref(mSource.baseUrl!));
|
||||
}
|
||||
headers.addAll(getSourceHeaders(mSource));
|
||||
final cookies = MClient.getCookiesPref(mSource.baseUrl!);
|
||||
headers.addAll(cookies);
|
||||
|
||||
return headers;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ part of 'headers.dart';
|
|||
// RiverpodGenerator
|
||||
// **************************************************************************
|
||||
|
||||
String _$headersHash() => r'05b066bcfad24a9238d4f7cefdabc7aec01d2e26';
|
||||
String _$headersHash() => r'47499544c2d972da6a0c20f41fe3fc46d1d7c1a0';
|
||||
|
||||
/// Copied from Dart SDK
|
||||
class _SystemHash {
|
||||
|
|
|
|||
Loading…
Reference in a new issue