prepare for multiple apps

This commit is contained in:
Fabian Freund
2026-04-06 12:23:11 +02:00
parent bd1600e8dc
commit 5afc323f04
904 changed files with 29 additions and 29 deletions
@@ -0,0 +1,61 @@
/*
* Copyright (c) 2024-2026 Fabian Freund.
*
* This file is part of WebLibre
* (see https://weblibre.eu).
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import 'package:drift/drift.dart';
import 'package:weblibre/data/database/extensions/database_table_size.dart';
import 'package:weblibre/features/user/data/database/daos/cache.drift.dart';
import 'package:weblibre/features/user/data/database/database.dart';
import 'package:weblibre/features/user/data/database/definitions.drift.dart';
@DriftAccessor()
class CacheDao extends DatabaseAccessor<UserDatabase> with $CacheDaoMixin {
CacheDao(super.attachedDatabase);
SingleSelectable<double> getIconCacheSize() {
return db.tableSize(db.iconCache);
}
Future<int> clearIconCache() {
return db.iconCache.deleteAll();
}
SingleOrNullSelectable<Uint8List?> getCachedIcon(String origin) {
final query = selectOnly(db.iconCache)
..addColumns([db.iconCache.iconData])
..where(db.iconCache.origin.equals(origin));
return query.map((row) => row.read(db.iconCache.iconData));
}
Future<int> cacheIcon(String origin, Uint8List bytes) {
return db.iconCache.insertOne(
IconCacheCompanion.insert(
origin: origin,
iconData: bytes,
fetchDate: DateTime.now(),
),
onConflict: DoUpdate(
(old) => IconCacheCompanion(
iconData: Value(bytes),
fetchDate: Value(DateTime.now()),
),
),
);
}
}
@@ -0,0 +1,13 @@
// dart format width=80
// ignore_for_file: type=lint
import 'package:drift/drift.dart' as i0;
import 'package:weblibre/features/user/data/database/database.dart' as i1;
mixin $CacheDaoMixin on i0.DatabaseAccessor<i1.UserDatabase> {
CacheDaoManager get managers => CacheDaoManager(this);
}
class CacheDaoManager {
final $CacheDaoMixin _db;
CacheDaoManager(this._db);
}
@@ -0,0 +1,45 @@
/*
* Copyright (c) 2024-2026 Fabian Freund.
*
* This file is part of WebLibre
* (see https://weblibre.eu).
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import 'package:drift/drift.dart';
import 'package:weblibre/features/user/data/database/database.dart';
import 'package:weblibre/features/user/data/database/definitions.drift.dart';
@DriftAccessor()
class OnboardingDao extends DatabaseAccessor<UserDatabase> {
OnboardingDao(super.attachedDatabase);
SingleOrNullSelectable<int?> getLastRevision() {
final maxRevision = db.onboarding.revision.max();
final query = selectOnly(db.onboarding)..addColumns([maxRevision]);
return query.map((row) => row.read(maxRevision));
}
Future<void> pushRevision(int revision, DateTime completionDate) {
return db.onboarding.insertOne(
OnboardingCompanion.insert(
revision: revision,
completionDate: completionDate,
),
mode: InsertMode.insertOrReplace,
);
}
}
@@ -0,0 +1,13 @@
// dart format width=80
// ignore_for_file: type=lint
import 'package:drift/drift.dart' as i0;
import 'package:weblibre/features/user/data/database/database.dart' as i1;
mixin $OnboardingDaoMixin on i0.DatabaseAccessor<i1.UserDatabase> {
OnboardingDaoManager get managers => OnboardingDaoManager(this);
}
class OnboardingDaoManager {
final $OnboardingDaoMixin _db;
OnboardingDaoManager(this._db);
}
@@ -0,0 +1,62 @@
/*
* Copyright (c) 2024-2026 Fabian Freund.
*
* This file is part of WebLibre
* (see https://weblibre.eu).
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import 'dart:convert';
import 'package:drift/drift.dart';
import 'package:nullability/nullability.dart';
import 'package:weblibre/features/user/data/database/daos/setting.drift.dart';
import 'package:weblibre/features/user/data/database/database.dart';
import 'package:weblibre/features/user/data/database/definitions.drift.dart';
@DriftAccessor()
class SettingDao extends DatabaseAccessor<UserDatabase> with $SettingDaoMixin {
SettingDao(super.attachedDatabase);
Future<int> updateSetting(String key, String? partitionKey, Object? value) {
final normalizedValue = (value is Iterable) ? jsonEncode(value) : value;
final driftvalue = normalizedValue.mapNotNull(
(normalizedValue) => DriftAny(normalizedValue),
);
return db.setting.insertOne(
SettingCompanion.insert(
key: key,
partitionKey: Value(partitionKey),
value: Value(driftvalue),
),
onConflict: DoUpdate(
(old) => SettingCompanion(
partitionKey: Value(partitionKey),
value: Value(driftvalue),
),
),
);
}
Selectable<MapEntry<String, DriftAny?>> getAllSettingsOfPartitionKey(
String? partitionKey,
) {
final query = db.setting.select()
..where((r) => r.partitionKey.equalsNullable(partitionKey));
return query.map((row) => MapEntry(row.key, row.value));
}
}
@@ -0,0 +1,13 @@
// dart format width=80
// ignore_for_file: type=lint
import 'package:drift/drift.dart' as i0;
import 'package:weblibre/features/user/data/database/database.dart' as i1;
mixin $SettingDaoMixin on i0.DatabaseAccessor<i1.UserDatabase> {
SettingDaoManager get managers => SettingDaoManager(this);
}
class SettingDaoManager {
final $SettingDaoMixin _db;
SettingDaoManager(this._db);
}
@@ -0,0 +1,134 @@
/*
* Copyright (c) 2024-2026 Fabian Freund.
*
* This file is part of WebLibre
* (see https://weblibre.eu).
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import 'package:drift/drift.dart';
import 'package:weblibre/features/user/data/database/daos/toolbar_button_config.drift.dart';
import 'package:weblibre/features/user/data/database/database.dart';
import 'package:weblibre/features/user/data/database/definitions.drift.dart';
@DriftAccessor()
class ToolbarButtonConfigDao extends DatabaseAccessor<UserDatabase>
with $ToolbarButtonConfigDaoMixin {
ToolbarButtonConfigDao(super.attachedDatabase);
Selectable<ToolbarButtonConfig> selectAll() =>
db.toolbarButtonConfigs.select()
..orderBy([(t) => OrderingTerm.asc(t.orderKey)]);
Stream<List<ToolbarButtonConfig>> watchAll() => selectAll().watch();
Future<List<ToolbarButtonConfig>> getAll() => selectAll().get();
Future<void> upsert(ToolbarButtonConfig config) =>
into(db.toolbarButtonConfigs).insertOnConflictUpdate(config);
Future<void> assignOrderKey(String buttonId, {required String orderKey}) =>
(update(db.toolbarButtonConfigs)
..where((t) => t.buttonId.equals(buttonId)))
.write(ToolbarButtonConfigsCompanion(orderKey: Value(orderKey)));
Future<void> assignVisibility(String buttonId, {required bool visible}) =>
(update(db.toolbarButtonConfigs)
..where((t) => t.buttonId.equals(buttonId)))
.write(ToolbarButtonConfigsCompanion(isVisible: Value(visible)));
Future<void> assignFallback(String buttonId, String? fallbackId) =>
(update(db.toolbarButtonConfigs)
..where((t) => t.buttonId.equals(buttonId)))
.write(ToolbarButtonConfigsCompanion(fallbackId: Value(fallbackId)));
Future<void> replaceAll(List<ToolbarButtonConfig> configs) =>
transaction(() async {
await delete(db.toolbarButtonConfigs).go();
await _insertWithDeferredFallbacks(configs);
});
Future<void> seedMissing(
List<({String buttonId, bool defaultVisible, String? defaultFallback})>
defaults,
) async {
final existing = await getAll();
final existingIds = {for (final r in existing) r.buttonId};
final missing = defaults
.where((d) => !existingIds.contains(d.buttonId))
.toList();
if (missing.isEmpty) return;
await transaction(() async {
final inserted = <ToolbarButtonConfig>[];
for (final def in missing) {
final orderKey = await generateTrailingOrderKey().getSingle();
inserted.add(
ToolbarButtonConfig(
buttonId: def.buttonId,
orderKey: orderKey,
isVisible: def.defaultVisible,
fallbackId: def.defaultFallback,
),
);
await into(db.toolbarButtonConfigs).insert(
ToolbarButtonConfig(
buttonId: def.buttonId,
orderKey: orderKey,
isVisible: def.defaultVisible,
),
);
}
await _assignFallbacks(inserted);
});
}
SingleSelectable<String> generateLeadingOrderKey({int bucket = 0}) =>
db.definitionsDrift.toolbarLeadingOrderKey(bucket: bucket);
SingleSelectable<String> generateTrailingOrderKey({int bucket = 0}) =>
db.definitionsDrift.toolbarTrailingOrderKey(bucket: bucket);
SingleOrNullSelectable<String> generateOrderKeyAfterButtonId(
String buttonId,
) => db.definitionsDrift.toolbarOrderKeyAfterButton(buttonId: buttonId);
SingleSelectable<String> generateOrderKeyBeforeButtonId(String buttonId) =>
db.definitionsDrift.toolbarOrderKeyBeforeButton(buttonId: buttonId);
Future<void> _insertWithDeferredFallbacks(
List<ToolbarButtonConfig> configs,
) async {
for (final config in configs) {
await into(db.toolbarButtonConfigs).insert(
ToolbarButtonConfig(
buttonId: config.buttonId,
orderKey: config.orderKey,
isVisible: config.isVisible,
),
);
}
await _assignFallbacks(configs);
}
Future<void> _assignFallbacks(List<ToolbarButtonConfig> configs) async {
for (final config in configs) {
if (config.fallbackId == null) continue;
await assignFallback(config.buttonId, config.fallbackId);
}
}
}
@@ -0,0 +1,14 @@
// dart format width=80
// ignore_for_file: type=lint
import 'package:drift/drift.dart' as i0;
import 'package:weblibre/features/user/data/database/database.dart' as i1;
mixin $ToolbarButtonConfigDaoMixin on i0.DatabaseAccessor<i1.UserDatabase> {
ToolbarButtonConfigDaoManager get managers =>
ToolbarButtonConfigDaoManager(this);
}
class ToolbarButtonConfigDaoManager {
final $ToolbarButtonConfigDaoMixin _db;
ToolbarButtonConfigDaoManager(this._db);
}
@@ -0,0 +1,92 @@
/*
* Copyright (c) 2024-2026 Fabian Freund.
*
* This file is part of WebLibre
* (see https://weblibre.eu).
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import 'package:drift/drift.dart';
import 'package:drift/internal/versioned_schema.dart';
import 'package:drift_dev/api/migrations_native.dart';
import 'package:flutter/foundation.dart';
import 'package:weblibre/features/user/data/database/daos/cache.dart';
import 'package:weblibre/features/user/data/database/daos/onboarding.dart';
import 'package:weblibre/features/user/data/database/daos/setting.dart';
import 'package:weblibre/features/user/data/database/daos/toolbar_button_config.dart';
import 'package:weblibre/features/user/data/database/database.drift.dart';
import 'package:weblibre/features/user/data/database/database.steps.dart';
@DriftDatabase(
include: {'definitions.drift'},
daos: [SettingDao, CacheDao, OnboardingDao, ToolbarButtonConfigDao],
)
class UserDatabase extends $UserDatabase {
@override
final int schemaVersion = 3;
@override
MigrationStrategy get migration => MigrationStrategy(
beforeOpen: (details) async {
if (kDebugMode) {
// This check pulls in a fair amount of code that's not needed
// anywhere else, so we recommend only doing it in debug builds.
await validateDatabaseSchema();
}
await customStatement('PRAGMA foreign_keys = ON;');
await onAfterOpen?.call(this);
},
onUpgrade: (m, from, to) async {
// Following the advice from https://drift.simonbinder.eu/Migrations/api/#general-tips
await customStatement('PRAGMA foreign_keys = OFF');
await transaction(
() => VersionedSchema.runMigrationSteps(
migrator: m,
from: from,
to: to,
steps: _upgrade,
),
);
if (kDebugMode) {
final wrongForeignKeys = await customSelect(
'PRAGMA foreign_key_check',
).get();
assert(
wrongForeignKeys.isEmpty,
'${wrongForeignKeys.map((e) => e.data)}',
);
}
await customStatement('PRAGMA foreign_keys = ON');
},
);
UserDatabase(super.e, {this.onAfterOpen});
final Future<void> Function(UserDatabase db)? onAfterOpen;
static final _upgrade = migrationSteps(
from1To2: (m, schema) async {
await m.createTable(schema.riverpod);
},
from2To3: (m, schema) async {
await m.createTable(schema.toolbarButtonConfigs);
await m.createIndex(schema.idxToolbarOrderKey);
},
);
}
@@ -0,0 +1,108 @@
// dart format width=80
// ignore_for_file: type=lint
import 'package:drift/drift.dart' as i0;
import 'package:weblibre/features/user/data/database/definitions.drift.dart'
as i1;
import 'package:weblibre/features/user/data/database/daos/setting.dart' as i2;
import 'package:weblibre/features/user/data/database/database.dart' as i3;
import 'package:weblibre/features/user/data/database/daos/cache.dart' as i4;
import 'package:weblibre/features/user/data/database/daos/onboarding.dart'
as i5;
import 'package:weblibre/features/user/data/database/daos/toolbar_button_config.dart'
as i6;
import 'package:drift/internal/modular.dart' as i7;
import 'package:sqlite3/common.dart' as i8;
abstract class $UserDatabase extends i0.GeneratedDatabase {
$UserDatabase(i0.QueryExecutor e) : super(e);
$UserDatabaseManager get managers => $UserDatabaseManager(this);
late final i1.Setting setting = i1.Setting(this);
late final i1.IconCache iconCache = i1.IconCache(this);
late final i1.Onboarding onboarding = i1.Onboarding(this);
late final i1.Riverpod riverpod = i1.Riverpod(this);
late final i1.ToolbarButtonConfigs toolbarButtonConfigs =
i1.ToolbarButtonConfigs(this);
late final i2.SettingDao settingDao = i2.SettingDao(this as i3.UserDatabase);
late final i4.CacheDao cacheDao = i4.CacheDao(this as i3.UserDatabase);
late final i5.OnboardingDao onboardingDao = i5.OnboardingDao(
this as i3.UserDatabase,
);
late final i6.ToolbarButtonConfigDao toolbarButtonConfigDao =
i6.ToolbarButtonConfigDao(this as i3.UserDatabase);
i1.DefinitionsDrift get definitionsDrift => i7.ReadDatabaseContainer(
this,
).accessor<i1.DefinitionsDrift>(i1.DefinitionsDrift.new);
@override
Iterable<i0.TableInfo<i0.Table, Object?>> get allTables =>
allSchemaEntities.whereType<i0.TableInfo<i0.Table, Object?>>();
@override
List<i0.DatabaseSchemaEntity> get allSchemaEntities => [
setting,
iconCache,
onboarding,
riverpod,
toolbarButtonConfigs,
i1.idxToolbarOrderKey,
];
}
class $UserDatabaseManager {
final $UserDatabase _db;
$UserDatabaseManager(this._db);
i1.$SettingTableManager get setting =>
i1.$SettingTableManager(_db, _db.setting);
i1.$IconCacheTableManager get iconCache =>
i1.$IconCacheTableManager(_db, _db.iconCache);
i1.$OnboardingTableManager get onboarding =>
i1.$OnboardingTableManager(_db, _db.onboarding);
i1.$RiverpodTableManager get riverpod =>
i1.$RiverpodTableManager(_db, _db.riverpod);
i1.$ToolbarButtonConfigsTableManager get toolbarButtonConfigs =>
i1.$ToolbarButtonConfigsTableManager(_db, _db.toolbarButtonConfigs);
}
extension DefineFunctions on i8.CommonDatabase {
void defineFunctions({
required String Function(int, String?) lexoRankNext,
required String Function(int, String?) lexoRankPrevious,
required String Function(String?, String?) lexoRankReorderAfter,
required String Function(String?, String?) lexoRankReorderBefore,
}) {
createFunction(
functionName: 'lexo_rank_next',
argumentCount: const i8.AllowedArgumentCount(2),
function: (args) {
final arg0 = args[0] as int;
final arg1 = args[1] as String?;
return lexoRankNext(arg0, arg1);
},
);
createFunction(
functionName: 'lexo_rank_previous',
argumentCount: const i8.AllowedArgumentCount(2),
function: (args) {
final arg0 = args[0] as int;
final arg1 = args[1] as String?;
return lexoRankPrevious(arg0, arg1);
},
);
createFunction(
functionName: 'lexo_rank_reorder_after',
argumentCount: const i8.AllowedArgumentCount(2),
function: (args) {
final arg0 = args[0] as String?;
final arg1 = args[1] as String?;
return lexoRankReorderAfter(arg0, arg1);
},
);
createFunction(
functionName: 'lexo_rank_reorder_before',
argumentCount: const i8.AllowedArgumentCount(2),
function: (args) {
final arg0 = args[0] as String?;
final arg1 = args[1] as String?;
return lexoRankReorderBefore(arg0, arg1);
},
);
}
}
@@ -0,0 +1,341 @@
// dart format width=80
import 'package:drift/internal/versioned_schema.dart' as i0;
import 'package:drift/drift.dart' as i1;
import 'dart:typed_data' as i2;
import 'package:drift/drift.dart'; // GENERATED BY drift_dev, DO NOT MODIFY.
// ignore_for_file: type=lint,unused_import
//
final class Schema2 extends i0.VersionedSchema {
Schema2({required super.database}) : super(version: 2);
@override
late final List<i1.DatabaseSchemaEntity> entities = [
setting,
iconCache,
onboarding,
riverpod,
];
late final Shape0 setting = Shape0(
source: i0.VersionedTable(
entityName: 'setting',
withoutRowId: false,
isStrict: true,
tableConstraints: [],
columns: [_column_0, _column_1, _column_2],
attachedDatabase: database,
),
alias: null,
);
late final Shape1 iconCache = Shape1(
source: i0.VersionedTable(
entityName: 'icon_cache',
withoutRowId: false,
isStrict: false,
tableConstraints: [],
columns: [_column_3, _column_4, _column_5],
attachedDatabase: database,
),
alias: null,
);
late final Shape2 onboarding = Shape2(
source: i0.VersionedTable(
entityName: 'onboarding',
withoutRowId: false,
isStrict: false,
tableConstraints: [],
columns: [_column_6, _column_7],
attachedDatabase: database,
),
alias: null,
);
late final Shape3 riverpod = Shape3(
source: i0.VersionedTable(
entityName: 'riverpod',
withoutRowId: true,
isStrict: false,
tableConstraints: [],
columns: [_column_0, _column_8, _column_9, _column_10],
attachedDatabase: database,
),
alias: null,
);
}
class Shape0 extends i0.VersionedTable {
Shape0({required super.source, required super.alias}) : super.aliased();
i1.GeneratedColumn<String> get key =>
columnsByName['key']! as i1.GeneratedColumn<String>;
i1.GeneratedColumn<String> get partitionKey =>
columnsByName['partition_key']! as i1.GeneratedColumn<String>;
i1.GeneratedColumn<i1.DriftAny> get value =>
columnsByName['value']! as i1.GeneratedColumn<i1.DriftAny>;
}
i1.GeneratedColumn<String> _column_0(String aliasedName) =>
i1.GeneratedColumn<String>(
'key',
aliasedName,
false,
type: i1.DriftSqlType.string,
$customConstraints: 'PRIMARY KEY NOT NULL',
);
i1.GeneratedColumn<String> _column_1(String aliasedName) =>
i1.GeneratedColumn<String>(
'partition_key',
aliasedName,
true,
type: i1.DriftSqlType.string,
$customConstraints: '',
);
i1.GeneratedColumn<i1.DriftAny> _column_2(String aliasedName) =>
i1.GeneratedColumn<i1.DriftAny>(
'value',
aliasedName,
true,
type: i1.DriftSqlType.any,
$customConstraints: '',
);
class Shape1 extends i0.VersionedTable {
Shape1({required super.source, required super.alias}) : super.aliased();
i1.GeneratedColumn<String> get origin =>
columnsByName['origin']! as i1.GeneratedColumn<String>;
i1.GeneratedColumn<i2.Uint8List> get iconData =>
columnsByName['icon_data']! as i1.GeneratedColumn<i2.Uint8List>;
i1.GeneratedColumn<int> get fetchDate =>
columnsByName['fetch_date']! as i1.GeneratedColumn<int>;
}
i1.GeneratedColumn<String> _column_3(String aliasedName) =>
i1.GeneratedColumn<String>(
'origin',
aliasedName,
false,
type: i1.DriftSqlType.string,
$customConstraints: 'PRIMARY KEY NOT NULL',
);
i1.GeneratedColumn<i2.Uint8List> _column_4(String aliasedName) =>
i1.GeneratedColumn<i2.Uint8List>(
'icon_data',
aliasedName,
false,
type: i1.DriftSqlType.blob,
$customConstraints: 'NOT NULL',
);
i1.GeneratedColumn<int> _column_5(String aliasedName) =>
i1.GeneratedColumn<int>(
'fetch_date',
aliasedName,
false,
type: i1.DriftSqlType.int,
$customConstraints: 'NOT NULL',
);
class Shape2 extends i0.VersionedTable {
Shape2({required super.source, required super.alias}) : super.aliased();
i1.GeneratedColumn<int> get revision =>
columnsByName['revision']! as i1.GeneratedColumn<int>;
i1.GeneratedColumn<int> get completionDate =>
columnsByName['completion_date']! as i1.GeneratedColumn<int>;
}
i1.GeneratedColumn<int> _column_6(String aliasedName) =>
i1.GeneratedColumn<int>(
'revision',
aliasedName,
false,
type: i1.DriftSqlType.int,
$customConstraints: 'NOT NULL',
);
i1.GeneratedColumn<int> _column_7(String aliasedName) =>
i1.GeneratedColumn<int>(
'completion_date',
aliasedName,
false,
type: i1.DriftSqlType.int,
$customConstraints: 'NOT NULL',
);
class Shape3 extends i0.VersionedTable {
Shape3({required super.source, required super.alias}) : super.aliased();
i1.GeneratedColumn<String> get key =>
columnsByName['key']! as i1.GeneratedColumn<String>;
i1.GeneratedColumn<String> get json =>
columnsByName['json']! as i1.GeneratedColumn<String>;
i1.GeneratedColumn<int> get expireAt =>
columnsByName['expireAt']! as i1.GeneratedColumn<int>;
i1.GeneratedColumn<String> get destroyKey =>
columnsByName['destroyKey']! as i1.GeneratedColumn<String>;
}
i1.GeneratedColumn<String> _column_8(String aliasedName) =>
i1.GeneratedColumn<String>(
'json',
aliasedName,
false,
type: i1.DriftSqlType.string,
$customConstraints: 'NOT NULL',
);
i1.GeneratedColumn<int> _column_9(String aliasedName) =>
i1.GeneratedColumn<int>(
'expireAt',
aliasedName,
true,
type: i1.DriftSqlType.int,
$customConstraints: '',
);
i1.GeneratedColumn<String> _column_10(String aliasedName) =>
i1.GeneratedColumn<String>(
'destroyKey',
aliasedName,
true,
type: i1.DriftSqlType.string,
$customConstraints: '',
);
final class Schema3 extends i0.VersionedSchema {
Schema3({required super.database}) : super(version: 3);
@override
late final List<i1.DatabaseSchemaEntity> entities = [
setting,
iconCache,
onboarding,
riverpod,
toolbarButtonConfigs,
idxToolbarOrderKey,
];
late final Shape0 setting = Shape0(
source: i0.VersionedTable(
entityName: 'setting',
withoutRowId: false,
isStrict: true,
tableConstraints: [],
columns: [_column_0, _column_1, _column_2],
attachedDatabase: database,
),
alias: null,
);
late final Shape1 iconCache = Shape1(
source: i0.VersionedTable(
entityName: 'icon_cache',
withoutRowId: false,
isStrict: false,
tableConstraints: [],
columns: [_column_3, _column_4, _column_5],
attachedDatabase: database,
),
alias: null,
);
late final Shape2 onboarding = Shape2(
source: i0.VersionedTable(
entityName: 'onboarding',
withoutRowId: false,
isStrict: false,
tableConstraints: [],
columns: [_column_6, _column_7],
attachedDatabase: database,
),
alias: null,
);
late final Shape3 riverpod = Shape3(
source: i0.VersionedTable(
entityName: 'riverpod',
withoutRowId: true,
isStrict: false,
tableConstraints: [],
columns: [_column_0, _column_8, _column_9, _column_10],
attachedDatabase: database,
),
alias: null,
);
late final Shape4 toolbarButtonConfigs = Shape4(
source: i0.VersionedTable(
entityName: 'toolbar_button_configs',
withoutRowId: false,
isStrict: false,
tableConstraints: [],
columns: [_column_11, _column_12, _column_13, _column_14],
attachedDatabase: database,
),
alias: null,
);
final i1.Index idxToolbarOrderKey = i1.Index(
'idx_toolbar_order_key',
'CREATE INDEX idx_toolbar_order_key ON toolbar_button_configs (order_key)',
);
}
class Shape4 extends i0.VersionedTable {
Shape4({required super.source, required super.alias}) : super.aliased();
i1.GeneratedColumn<String> get buttonId =>
columnsByName['button_id']! as i1.GeneratedColumn<String>;
i1.GeneratedColumn<String> get orderKey =>
columnsByName['order_key']! as i1.GeneratedColumn<String>;
i1.GeneratedColumn<int> get isVisible =>
columnsByName['is_visible']! as i1.GeneratedColumn<int>;
i1.GeneratedColumn<String> get fallbackId =>
columnsByName['fallback_id']! as i1.GeneratedColumn<String>;
}
i1.GeneratedColumn<String> _column_11(String aliasedName) =>
i1.GeneratedColumn<String>(
'button_id',
aliasedName,
false,
type: i1.DriftSqlType.string,
$customConstraints: 'NOT NULL PRIMARY KEY',
);
i1.GeneratedColumn<String> _column_12(String aliasedName) =>
i1.GeneratedColumn<String>(
'order_key',
aliasedName,
false,
type: i1.DriftSqlType.string,
$customConstraints: 'NOT NULL',
);
i1.GeneratedColumn<int> _column_13(String aliasedName) =>
i1.GeneratedColumn<int>(
'is_visible',
aliasedName,
false,
type: i1.DriftSqlType.int,
$customConstraints: 'NOT NULL DEFAULT TRUE',
defaultValue: const i1.CustomExpression('TRUE'),
);
i1.GeneratedColumn<String> _column_14(String aliasedName) =>
i1.GeneratedColumn<String>(
'fallback_id',
aliasedName,
true,
type: i1.DriftSqlType.string,
$customConstraints:
'REFERENCES toolbar_button_configs(button_id)ON DELETE SET NULL',
);
i0.MigrationStepWithVersion migrationSteps({
required Future<void> Function(i1.Migrator m, Schema2 schema) from1To2,
required Future<void> Function(i1.Migrator m, Schema3 schema) from2To3,
}) {
return (currentVersion, database) async {
switch (currentVersion) {
case 1:
final schema = Schema2(database: database);
final migrator = i1.Migrator(database, schema);
await from1To2(migrator, schema);
return 2;
case 2:
final schema = Schema3(database: database);
final migrator = i1.Migrator(database, schema);
await from2To3(migrator, schema);
return 3;
default:
throw ArgumentError.value('Unknown migration from $currentVersion');
}
};
}
i1.OnUpgrade stepByStep({
required Future<void> Function(i1.Migrator m, Schema2 schema) from1To2,
required Future<void> Function(i1.Migrator m, Schema3 schema) from2To3,
}) => i0.VersionedSchema.stepByStepHelper(
step: migrationSteps(from1To2: from1To2, from2To3: from2To3),
);
@@ -0,0 +1,87 @@
CREATE TABLE setting (
"key" TEXT PRIMARY KEY NOT NULL,
partition_key TEXT,
"value" ANY
) STRICT;
CREATE TABLE icon_cache (
origin TEXT PRIMARY KEY NOT NULL,
icon_data BLOB NOT NULL,
fetch_date DATETIME NOT NULL
);
CREATE TABLE onboarding (
revision INTEGER NOT NULL,
completion_date DATETIME NOT NULL
);
CREATE TABLE riverpod (
"key" TEXT PRIMARY KEY NOT NULL,
json TEXT NOT NULL,
expireAt DATETIME,
destroyKey TEXT
) WITHOUT ROWID;
CREATE TABLE toolbar_button_configs (
button_id TEXT NOT NULL PRIMARY KEY,
order_key TEXT NOT NULL,
is_visible BOOLEAN NOT NULL DEFAULT TRUE,
fallback_id TEXT REFERENCES toolbar_button_configs(button_id) ON DELETE SET NULL
);
CREATE INDEX idx_toolbar_order_key ON toolbar_button_configs(order_key);
toolbarLeadingOrderKey(:bucket AS INTEGER):
SELECT lexo_rank_previous(
:bucket,
(
SELECT order_key
FROM toolbar_button_configs
ORDER BY order_key
LIMIT 1
)
);
toolbarTrailingOrderKey(:bucket AS INTEGER):
SELECT lexo_rank_next(
:bucket,
(
SELECT order_key
FROM toolbar_button_configs
ORDER BY order_key DESC
LIMIT 1
)
);
toolbarOrderKeyAfterButton(:button_id AS TEXT):
WITH ordered_table AS (
SELECT
button_id,
order_key,
LEAD(order_key) OVER (ORDER BY order_key) AS next_order_key
FROM toolbar_button_configs
)
SELECT lexo_rank_reorder_after(order_key, next_order_key)
FROM ordered_table
WHERE button_id = :button_id;
toolbarOrderKeyBeforeButton(:button_id AS TEXT):
WITH ordered_table AS (
SELECT
button_id,
order_key,
LAG(order_key) OVER (ORDER BY order_key) AS prev_order_key
FROM toolbar_button_configs
)
SELECT lexo_rank_reorder_before(order_key, prev_order_key)
FROM ordered_table
WHERE button_id = :button_id;
evictCacheEntries:
DELETE FROM icon_cache
WHERE rowid IN (
SELECT rowid
FROM icon_cache
ORDER BY fetch_date DESC
LIMIT -1 OFFSET :limit
);
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,76 @@
/*
* Copyright (c) 2024-2026 Fabian Freund.
*
* This file is part of WebLibre
* (see https://weblibre.eu).
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import 'dart:async';
import 'package:drift/drift.dart';
import 'package:nullability/nullability.dart';
import 'package:riverpod/experimental/persist.dart';
import 'package:weblibre/features/user/data/database/database.dart';
import 'package:weblibre/features/user/data/database/definitions.drift.dart';
final class RiverpodStorage extends Storage<String, String> {
final UserDatabase _db;
RiverpodStorage(this._db);
@override
Future<void> delete(String key) {
return _db.riverpod.deleteWhere((x) => x.key.equals(key));
}
@override
Future<void> deleteOutOfDate() {
return _db.riverpod.deleteWhere(
(x) => x.expireAt.isSmallerThanValue(DateTime.now()),
);
}
@override
Future<PersistedData<String>?> read(String key) async {
final query = _db.riverpod.select()..where((x) => x.key.equals(key));
final data = await query.getSingleOrNull();
return data.mapNotNull(
(data) => PersistedData(
data.json,
destroyKey: data.destroyKey,
expireAt: data.expireAt,
),
);
}
@override
Future<void> write(String key, String value, StorageOptions options) {
return _db.riverpod.insertOne(
RiverpodCompanion.insert(
key: key,
json: value,
destroyKey: Value(options.destroyKey),
expireAt: Value(
options.cacheTime.duration.mapNotNull(
(duration) => DateTime.now().add(duration),
),
),
),
mode: InsertMode.insertOrReplace,
);
}
}
@@ -0,0 +1,70 @@
/*
* Copyright (c) 2024-2026 Fabian Freund.
*
* This file is part of WebLibre
* (see https://weblibre.eu).
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import 'package:copy_with_extension/copy_with_extension.dart';
import 'package:fast_equatable/fast_equatable.dart';
import 'package:json_annotation/json_annotation.dart';
part 'auth_settings.g.dart';
enum AutoLockMode { background, timeout }
@CopyWith()
@JsonSerializable()
class AuthSettings with FastEquatable {
final bool authenticationRequired;
final AutoLockMode autoLockMode;
final Duration timeout;
AuthSettings({
required this.authenticationRequired,
required this.autoLockMode,
required this.timeout,
});
AuthSettings.withDefaults({
bool? authenticationRequired,
AutoLockMode? autoLockMode,
Duration? timeout,
}) : this(
authenticationRequired: authenticationRequired ?? false,
autoLockMode: autoLockMode ?? AutoLockMode.background,
timeout: timeout ?? const Duration(minutes: 5),
);
AuthSettings withBackgroundLock() {
return copyWith(autoLockMode: AutoLockMode.background);
}
AuthSettings withTimeoutLock(Duration value) {
return copyWith(autoLockMode: AutoLockMode.timeout, timeout: value);
}
factory AuthSettings.fromJson(Map<String, dynamic> json) =>
_$AuthSettingsFromJson(json);
Map<String, dynamic> toJson() => _$AuthSettingsToJson(this);
@override
List<Object?> get hashParameters => [
authenticationRequired,
autoLockMode,
timeout,
];
}
@@ -0,0 +1,108 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'auth_settings.dart';
// **************************************************************************
// CopyWithGenerator
// **************************************************************************
abstract class _$AuthSettingsCWProxy {
AuthSettings authenticationRequired(bool authenticationRequired);
AuthSettings autoLockMode(AutoLockMode autoLockMode);
AuthSettings timeout(Duration timeout);
/// Creates a new instance with the provided field values.
/// Passing `null` to a nullable field nullifies it, while `null` for a non-nullable field is ignored. To update a single field use `AuthSettings(...).copyWith.fieldName(value)`.
///
/// Example:
/// ```dart
/// AuthSettings(...).copyWith(id: 12, name: "My name")
/// ```
AuthSettings call({
bool authenticationRequired,
AutoLockMode autoLockMode,
Duration timeout,
});
}
/// Callable proxy for `copyWith` functionality.
/// Use as `instanceOfAuthSettings.copyWith(...)` or call `instanceOfAuthSettings.copyWith.fieldName(value)` for a single field.
class _$AuthSettingsCWProxyImpl implements _$AuthSettingsCWProxy {
const _$AuthSettingsCWProxyImpl(this._value);
final AuthSettings _value;
@override
AuthSettings authenticationRequired(bool authenticationRequired) =>
call(authenticationRequired: authenticationRequired);
@override
AuthSettings autoLockMode(AutoLockMode autoLockMode) =>
call(autoLockMode: autoLockMode);
@override
AuthSettings timeout(Duration timeout) => call(timeout: timeout);
@override
/// Creates a new instance with the provided field values.
/// Passing `null` to a nullable field nullifies it, while `null` for a non-nullable field is ignored. To update a single field use `AuthSettings(...).copyWith.fieldName(value)`.
///
/// Example:
/// ```dart
/// AuthSettings(...).copyWith(id: 12, name: "My name")
/// ```
AuthSettings call({
Object? authenticationRequired = const $CopyWithPlaceholder(),
Object? autoLockMode = const $CopyWithPlaceholder(),
Object? timeout = const $CopyWithPlaceholder(),
}) {
return AuthSettings(
authenticationRequired:
authenticationRequired == const $CopyWithPlaceholder() ||
authenticationRequired == null
? _value.authenticationRequired
// ignore: cast_nullable_to_non_nullable
: authenticationRequired as bool,
autoLockMode:
autoLockMode == const $CopyWithPlaceholder() || autoLockMode == null
? _value.autoLockMode
// ignore: cast_nullable_to_non_nullable
: autoLockMode as AutoLockMode,
timeout: timeout == const $CopyWithPlaceholder() || timeout == null
? _value.timeout
// ignore: cast_nullable_to_non_nullable
: timeout as Duration,
);
}
}
extension $AuthSettingsCopyWith on AuthSettings {
/// Returns a callable class used to build a new instance with modified fields.
/// Example: `instanceOfAuthSettings.copyWith(...)` or `instanceOfAuthSettings.copyWith.fieldName(...)`.
// ignore: library_private_types_in_public_api
_$AuthSettingsCWProxy get copyWith => _$AuthSettingsCWProxyImpl(this);
}
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
AuthSettings _$AuthSettingsFromJson(Map<String, dynamic> json) => AuthSettings(
authenticationRequired: json['authenticationRequired'] as bool,
autoLockMode: $enumDecode(_$AutoLockModeEnumMap, json['autoLockMode']),
timeout: Duration(microseconds: (json['timeout'] as num).toInt()),
);
Map<String, dynamic> _$AuthSettingsToJson(AuthSettings instance) =>
<String, dynamic>{
'authenticationRequired': instance.authenticationRequired,
'autoLockMode': _$AutoLockModeEnumMap[instance.autoLockMode]!,
'timeout': instance.timeout.inMicroseconds,
};
const _$AutoLockModeEnumMap = {
AutoLockMode.background: 'background',
AutoLockMode.timeout: 'timeout',
};
@@ -0,0 +1,390 @@
/*
* Copyright (c) 2024-2026 Fabian Freund.
*
* This file is part of WebLibre
* (see https://weblibre.eu).
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import 'dart:convert';
import 'package:copy_with_extension/copy_with_extension.dart';
import 'package:fast_equatable/fast_equatable.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_mozilla_components/flutter_mozilla_components.dart';
import 'package:json_annotation/json_annotation.dart';
import 'package:nullability/nullability.dart';
import 'package:weblibre/features/user/domain/entities/fingerprint_overrides.dart';
part 'engine_settings.g.dart';
enum BuiltInDohProviders {
quad9('Quad9', 'https://dns.quad9.net/dns-query'),
mullvad('Mullvad', 'https://dns.mullvad.net/dns-query'),
adguard('AdGuard', 'https://dns.adguard-dns.com/dns-query'),
ffmuc('Freifunk München', 'https://doh.ffmuc.net/dns-query');
final String name;
final String url;
static bool isBuiltin(String url) =>
BuiltInDohProviders.values.any((provider) => provider.url == url);
const BuiltInDohProviders(this.name, this.url);
}
@CopyWith()
@JsonSerializable(includeIfNull: true, constructor: 'withDefaults')
class EngineSettings extends GeckoEngineSettings with FastEquatable {
@override
bool get javascriptEnabled => super.javascriptEnabled!;
@override
TrackingProtectionPolicy get trackingProtectionPolicy =>
super.trackingProtectionPolicy!;
@override
HttpsOnlyMode get httpsOnlyMode => super.httpsOnlyMode!;
@override
ColorScheme get preferredColorScheme => super.preferredColorScheme!;
@override
bool get globalPrivacyControlEnabled => super.globalPrivacyControlEnabled!;
@override
CookieBannerHandlingMode get cookieBannerHandlingMode =>
super.cookieBannerHandlingMode!;
@override
CookieBannerHandlingMode get cookieBannerHandlingModePrivateBrowsing =>
super.cookieBannerHandlingModePrivateBrowsing!;
@override
bool get cookieBannerHandlingGlobalRules =>
super.cookieBannerHandlingGlobalRules!;
@override
bool get cookieBannerHandlingGlobalRulesSubFrames =>
super.cookieBannerHandlingGlobalRulesSubFrames!;
@override
WebContentIsolationStrategy get webContentIsolationStrategy =>
super.webContentIsolationStrategy!;
@override
bool get enterpriseRootsEnabled => super.enterpriseRootsEnabled!;
@override
List<String> get locales => super.locales!;
// Custom Tracking Protection overrides
@override
bool get blockCookies => super.blockCookies!;
@override
CustomCookiePolicy get customCookiePolicy => super.customCookiePolicy!;
@override
bool get blockTrackingContent => super.blockTrackingContent!;
@override
TrackingScope get trackingContentScope => super.trackingContentScope!;
@override
bool get blockCryptominers => super.blockCryptominers!;
@override
bool get blockFingerprinters => super.blockFingerprinters!;
@override
bool get blockRedirectTrackers => super.blockRedirectTrackers!;
@override
bool get blockSuspectedFingerprinters => super.blockSuspectedFingerprinters!;
@override
TrackingScope get suspectedFingerprintersScope =>
super.suspectedFingerprintersScope!;
@override
bool get allowListBaseline => super.allowListBaseline!;
@override
bool get allowListConvenience => super.allowListConvenience!;
// Web Content Settings
@override
bool get webFontsEnabled => super.webFontsEnabled!;
@override
bool get automaticFontSizeAdjustment => super.automaticFontSizeAdjustment!;
@override
double get fontSizeFactor => super.fontSizeFactor!;
@override
bool get fontInflationEnabled => super.fontInflationEnabled!;
@override
bool get inputAutoZoomEnabled => super.inputAutoZoomEnabled!;
// Process Isolation Settings (require app restart)
@override
bool get fissionEnabled => super.fissionEnabled!;
@override
bool get isolatedProcessEnabled => super.isolatedProcessEnabled!;
@override
bool get appZygoteProcessEnabled => super.appZygoteProcessEnabled!;
@override
bool get extensionsWebAPIEnabled => super.extensionsWebAPIEnabled!;
final QueryParameterStripping queryParameterStripping;
final BounceTrackingProtectionMode bounceTrackingProtectionMode;
@JsonKey(fromJson: _addonCollectionFromJson, toJson: _addonCollectionToJson)
final AddonCollection? addonCollection;
final DohSettingsMode dohSettingsMode;
final String dohProviderUrl;
final String dohDefaultProviderUrl;
final List<String> dohExceptionsList;
@override
@JsonKey(includeFromJson: false, includeToJson: false)
DohSettings get dohSettings => DohSettings(
dohSettingsMode: dohSettingsMode,
dohProviderUrl: dohProviderUrl,
dohDefaultProviderUrl: dohDefaultProviderUrl,
dohExceptionsList: dohExceptionsList,
);
@override
@JsonKey(includeFromJson: false, includeToJson: false)
ContentBlocking get contentBlocking => ContentBlocking(
queryParameterStripping: queryParameterStripping,
queryParameterStrippingAllowList: '',
queryParameterStrippingStripList:
'__hsfp __hssc __hstc __s _bhlid _branch_match_id _branch_referrer _gl _hsenc _kx _openstat at_recipient_id at_recipient_list bbeml bsft_clkid bsft_uid dclid et_rid fb_action_ids fb_comment_id fbclid gbraid gclid guce_referrer guce_referrer_sig hsCtaTracking igshid irclickid mc_eid mkt_tok ml_subscriber ml_subscriber_hash msclkid mtm_cid oft_c oft_ck oft_d oft_id oft_ids oft_k oft_lk oft_sk oly_anon_id oly_enc_id pk_cid rb_clickid s_cid sc_customer sc_eh sc_uid sms_click sms_source sms_uph srsltid ss_email_id syclid ttclid twclid unicorn_click_id vero_conv vero_id vgo_ee wbraid wickedid yclid ymclid ysclid',
bounceTrackingProtectionMode: bounceTrackingProtectionMode,
);
final bool enablePdfJs;
EngineSettings({
required super.javascriptEnabled,
required super.trackingProtectionPolicy,
required super.httpsOnlyMode,
required super.globalPrivacyControlEnabled,
required super.preferredColorScheme,
required super.cookieBannerHandlingMode,
required super.cookieBannerHandlingModePrivateBrowsing,
required super.cookieBannerHandlingGlobalRules,
required super.cookieBannerHandlingGlobalRulesSubFrames,
required super.webContentIsolationStrategy,
required super.userAgent,
required super.enterpriseRootsEnabled,
required this.queryParameterStripping,
required this.bounceTrackingProtectionMode,
required this.addonCollection,
required this.dohSettingsMode,
required this.dohProviderUrl,
required this.dohDefaultProviderUrl,
required this.dohExceptionsList,
required super.fingerprintingProtectionOverrides,
required this.enablePdfJs,
required super.locales,
required super.blockCookies,
required super.customCookiePolicy,
required super.blockTrackingContent,
required super.trackingContentScope,
required super.blockCryptominers,
required super.blockFingerprinters,
required super.blockRedirectTrackers,
required super.blockSuspectedFingerprinters,
required super.suspectedFingerprintersScope,
required super.allowListBaseline,
required super.allowListConvenience,
required super.webFontsEnabled,
required super.automaticFontSizeAdjustment,
required super.fontSizeFactor,
required super.fontInflationEnabled,
required super.displayDensityOverride,
required super.screenWidthOverride,
required super.screenHeightOverride,
required super.inputAutoZoomEnabled,
required super.fissionEnabled,
required super.isolatedProcessEnabled,
required super.appZygoteProcessEnabled,
required super.extensionsWebAPIEnabled,
required super.lnaBlocking,
required super.lnaBlockTrackers,
required super.lnaEnabled,
});
EngineSettings.withDefaults({
bool? javascriptEnabled,
TrackingProtectionPolicy? trackingProtectionPolicy,
HttpsOnlyMode? httpsOnlyMode,
bool? globalPrivacyControlEnabled,
ColorScheme? preferredColorScheme,
CookieBannerHandlingMode? cookieBannerHandlingMode,
CookieBannerHandlingMode? cookieBannerHandlingModePrivateBrowsing,
bool? cookieBannerHandlingGlobalRules,
bool? cookieBannerHandlingGlobalRulesSubFrames,
WebContentIsolationStrategy? webContentIsolationStrategy,
QueryParameterStripping? queryParameterStripping,
BounceTrackingProtectionMode? bounceTrackingProtectionMode,
super.userAgent,
bool? enterpriseRootsEnabled,
this.addonCollection,
DohSettingsMode? dohSettingsMode,
String? dohProviderUrl,
String? dohDefaultProviderUrl,
List<String>? dohExceptionsList,
String? fingerprintingProtectionOverrides,
bool? enablePdfJs,
List<String>? locales,
bool? blockCookies,
CustomCookiePolicy? customCookiePolicy,
bool? blockTrackingContent,
TrackingScope? trackingContentScope,
bool? blockCryptominers,
bool? blockFingerprinters,
bool? blockRedirectTrackers,
bool? blockSuspectedFingerprinters,
TrackingScope? suspectedFingerprintersScope,
bool? allowListBaseline,
bool? allowListConvenience,
bool? webFontsEnabled,
bool? automaticFontSizeAdjustment,
double? fontSizeFactor,
bool? fontInflationEnabled,
super.displayDensityOverride,
super.screenWidthOverride,
super.screenHeightOverride,
bool? inputAutoZoomEnabled,
bool? fissionEnabled,
bool? isolatedProcessEnabled,
bool? appZygoteProcessEnabled,
bool? extensionsWebAPIEnabled,
super.lnaBlocking,
bool? lnaBlockTrackers,
bool? lnaEnabled,
}) : queryParameterStripping =
queryParameterStripping ?? QueryParameterStripping.enabled,
bounceTrackingProtectionMode =
bounceTrackingProtectionMode ?? BounceTrackingProtectionMode.enabled,
dohSettingsMode = dohSettingsMode ?? DohSettingsMode.increased,
dohProviderUrl = dohProviderUrl ?? BuiltInDohProviders.quad9.url,
dohDefaultProviderUrl =
dohDefaultProviderUrl ?? BuiltInDohProviders.quad9.url,
dohExceptionsList = dohExceptionsList ?? [],
enablePdfJs = enablePdfJs ?? true,
super(
javascriptEnabled: javascriptEnabled ?? true,
trackingProtectionPolicy:
trackingProtectionPolicy ?? TrackingProtectionPolicy.strict,
httpsOnlyMode: httpsOnlyMode ?? HttpsOnlyMode.enabled,
globalPrivacyControlEnabled: globalPrivacyControlEnabled ?? true,
preferredColorScheme: preferredColorScheme ?? ColorScheme.system,
cookieBannerHandlingMode:
cookieBannerHandlingMode ?? CookieBannerHandlingMode.rejectAll,
cookieBannerHandlingModePrivateBrowsing:
cookieBannerHandlingModePrivateBrowsing ??
CookieBannerHandlingMode.rejectAll,
cookieBannerHandlingGlobalRules:
cookieBannerHandlingGlobalRules ?? true,
cookieBannerHandlingGlobalRulesSubFrames:
cookieBannerHandlingGlobalRulesSubFrames ?? true,
webContentIsolationStrategy:
webContentIsolationStrategy ??
WebContentIsolationStrategy.isolateHighValue,
enterpriseRootsEnabled: enterpriseRootsEnabled ?? false,
fingerprintingProtectionOverrides:
fingerprintingProtectionOverrides ??
FingerprintOverrides.defaults().toString(),
locales:
locales ??
WidgetsBinding.instance.platformDispatcher.locales
.map((x) => x.toLanguageTag())
.toList(),
blockCookies: blockCookies ?? true,
customCookiePolicy:
customCookiePolicy ?? CustomCookiePolicy.totalProtection,
blockTrackingContent: blockTrackingContent ?? true,
trackingContentScope: trackingContentScope ?? TrackingScope.all,
blockCryptominers: blockCryptominers ?? true,
blockFingerprinters: blockFingerprinters ?? true,
blockRedirectTrackers: blockRedirectTrackers ?? true,
blockSuspectedFingerprinters: blockSuspectedFingerprinters ?? true,
suspectedFingerprintersScope:
suspectedFingerprintersScope ?? TrackingScope.all,
allowListBaseline: allowListBaseline ?? true,
allowListConvenience: allowListConvenience ?? false,
webFontsEnabled: webFontsEnabled ?? true,
automaticFontSizeAdjustment: automaticFontSizeAdjustment ?? true,
fontSizeFactor: fontSizeFactor ?? 1.0,
fontInflationEnabled: fontInflationEnabled ?? false,
inputAutoZoomEnabled: inputAutoZoomEnabled ?? true,
fissionEnabled: fissionEnabled ?? true,
isolatedProcessEnabled: isolatedProcessEnabled ?? false,
appZygoteProcessEnabled: appZygoteProcessEnabled ?? false,
extensionsWebAPIEnabled: extensionsWebAPIEnabled ?? true,
lnaBlockTrackers: lnaBlockTrackers ?? true,
lnaEnabled: lnaEnabled ?? true,
);
static AddonCollection? _addonCollectionFromJson(String? json) =>
json.mapNotNull(
(collection) => AddonCollection.decode(jsonDecode(collection) as List),
);
static String? _addonCollectionToJson(AddonCollection? collection) =>
collection.mapNotNull((collection) => jsonEncode(collection.encode()));
factory EngineSettings.fromJson(Map<String, dynamic> json) =>
_$EngineSettingsFromJson(json);
Map<String, dynamic> toJson() => _$EngineSettingsToJson(this);
@override
List<Object?> get hashParameters => [
javascriptEnabled,
trackingProtectionPolicy,
httpsOnlyMode,
globalPrivacyControlEnabled,
preferredColorScheme,
cookieBannerHandlingMode,
cookieBannerHandlingModePrivateBrowsing,
cookieBannerHandlingGlobalRules,
cookieBannerHandlingGlobalRulesSubFrames,
webContentIsolationStrategy,
userAgent,
enterpriseRootsEnabled,
queryParameterStripping,
bounceTrackingProtectionMode,
addonCollection,
dohSettingsMode,
dohProviderUrl,
dohDefaultProviderUrl,
dohExceptionsList,
fingerprintingProtectionOverrides,
enablePdfJs,
locales,
blockCookies,
customCookiePolicy,
blockTrackingContent,
trackingContentScope,
blockCryptominers,
blockFingerprinters,
blockRedirectTrackers,
blockSuspectedFingerprinters,
suspectedFingerprintersScope,
allowListBaseline,
allowListConvenience,
webFontsEnabled,
automaticFontSizeAdjustment,
fontSizeFactor,
fontInflationEnabled,
displayDensityOverride,
screenWidthOverride,
screenHeightOverride,
inputAutoZoomEnabled,
fissionEnabled,
isolatedProcessEnabled,
appZygoteProcessEnabled,
extensionsWebAPIEnabled,
lnaBlocking,
lnaBlockTrackers,
lnaEnabled,
];
}
@@ -0,0 +1,934 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'engine_settings.dart';
// **************************************************************************
// CopyWithGenerator
// **************************************************************************
abstract class _$EngineSettingsCWProxy {
EngineSettings javascriptEnabled(bool? javascriptEnabled);
EngineSettings trackingProtectionPolicy(
TrackingProtectionPolicy? trackingProtectionPolicy,
);
EngineSettings httpsOnlyMode(HttpsOnlyMode? httpsOnlyMode);
EngineSettings globalPrivacyControlEnabled(bool? globalPrivacyControlEnabled);
EngineSettings preferredColorScheme(ColorScheme? preferredColorScheme);
EngineSettings cookieBannerHandlingMode(
CookieBannerHandlingMode? cookieBannerHandlingMode,
);
EngineSettings cookieBannerHandlingModePrivateBrowsing(
CookieBannerHandlingMode? cookieBannerHandlingModePrivateBrowsing,
);
EngineSettings cookieBannerHandlingGlobalRules(
bool? cookieBannerHandlingGlobalRules,
);
EngineSettings cookieBannerHandlingGlobalRulesSubFrames(
bool? cookieBannerHandlingGlobalRulesSubFrames,
);
EngineSettings webContentIsolationStrategy(
WebContentIsolationStrategy? webContentIsolationStrategy,
);
EngineSettings userAgent(String? userAgent);
EngineSettings enterpriseRootsEnabled(bool? enterpriseRootsEnabled);
EngineSettings queryParameterStripping(
QueryParameterStripping queryParameterStripping,
);
EngineSettings bounceTrackingProtectionMode(
BounceTrackingProtectionMode bounceTrackingProtectionMode,
);
EngineSettings addonCollection(AddonCollection? addonCollection);
EngineSettings dohSettingsMode(DohSettingsMode dohSettingsMode);
EngineSettings dohProviderUrl(String dohProviderUrl);
EngineSettings dohDefaultProviderUrl(String dohDefaultProviderUrl);
EngineSettings dohExceptionsList(List<String> dohExceptionsList);
EngineSettings fingerprintingProtectionOverrides(
String? fingerprintingProtectionOverrides,
);
EngineSettings enablePdfJs(bool enablePdfJs);
EngineSettings locales(List<String>? locales);
EngineSettings blockCookies(bool? blockCookies);
EngineSettings customCookiePolicy(CustomCookiePolicy? customCookiePolicy);
EngineSettings blockTrackingContent(bool? blockTrackingContent);
EngineSettings trackingContentScope(TrackingScope? trackingContentScope);
EngineSettings blockCryptominers(bool? blockCryptominers);
EngineSettings blockFingerprinters(bool? blockFingerprinters);
EngineSettings blockRedirectTrackers(bool? blockRedirectTrackers);
EngineSettings blockSuspectedFingerprinters(
bool? blockSuspectedFingerprinters,
);
EngineSettings suspectedFingerprintersScope(
TrackingScope? suspectedFingerprintersScope,
);
EngineSettings allowListBaseline(bool? allowListBaseline);
EngineSettings allowListConvenience(bool? allowListConvenience);
EngineSettings webFontsEnabled(bool? webFontsEnabled);
EngineSettings automaticFontSizeAdjustment(bool? automaticFontSizeAdjustment);
EngineSettings fontSizeFactor(double? fontSizeFactor);
EngineSettings fontInflationEnabled(bool? fontInflationEnabled);
EngineSettings displayDensityOverride(double? displayDensityOverride);
EngineSettings screenWidthOverride(int? screenWidthOverride);
EngineSettings screenHeightOverride(int? screenHeightOverride);
EngineSettings inputAutoZoomEnabled(bool? inputAutoZoomEnabled);
EngineSettings fissionEnabled(bool? fissionEnabled);
EngineSettings isolatedProcessEnabled(bool? isolatedProcessEnabled);
EngineSettings appZygoteProcessEnabled(bool? appZygoteProcessEnabled);
EngineSettings extensionsWebAPIEnabled(bool? extensionsWebAPIEnabled);
EngineSettings lnaBlocking(bool? lnaBlocking);
EngineSettings lnaBlockTrackers(bool? lnaBlockTrackers);
EngineSettings lnaEnabled(bool? lnaEnabled);
/// Creates a new instance with the provided field values.
/// Passing `null` to a nullable field nullifies it, while `null` for a non-nullable field is ignored. To update a single field use `EngineSettings(...).copyWith.fieldName(value)`.
///
/// Example:
/// ```dart
/// EngineSettings(...).copyWith(id: 12, name: "My name")
/// ```
EngineSettings call({
bool? javascriptEnabled,
TrackingProtectionPolicy? trackingProtectionPolicy,
HttpsOnlyMode? httpsOnlyMode,
bool? globalPrivacyControlEnabled,
ColorScheme? preferredColorScheme,
CookieBannerHandlingMode? cookieBannerHandlingMode,
CookieBannerHandlingMode? cookieBannerHandlingModePrivateBrowsing,
bool? cookieBannerHandlingGlobalRules,
bool? cookieBannerHandlingGlobalRulesSubFrames,
WebContentIsolationStrategy? webContentIsolationStrategy,
String? userAgent,
bool? enterpriseRootsEnabled,
QueryParameterStripping queryParameterStripping,
BounceTrackingProtectionMode bounceTrackingProtectionMode,
AddonCollection? addonCollection,
DohSettingsMode dohSettingsMode,
String dohProviderUrl,
String dohDefaultProviderUrl,
List<String> dohExceptionsList,
String? fingerprintingProtectionOverrides,
bool enablePdfJs,
List<String>? locales,
bool? blockCookies,
CustomCookiePolicy? customCookiePolicy,
bool? blockTrackingContent,
TrackingScope? trackingContentScope,
bool? blockCryptominers,
bool? blockFingerprinters,
bool? blockRedirectTrackers,
bool? blockSuspectedFingerprinters,
TrackingScope? suspectedFingerprintersScope,
bool? allowListBaseline,
bool? allowListConvenience,
bool? webFontsEnabled,
bool? automaticFontSizeAdjustment,
double? fontSizeFactor,
bool? fontInflationEnabled,
double? displayDensityOverride,
int? screenWidthOverride,
int? screenHeightOverride,
bool? inputAutoZoomEnabled,
bool? fissionEnabled,
bool? isolatedProcessEnabled,
bool? appZygoteProcessEnabled,
bool? extensionsWebAPIEnabled,
bool? lnaBlocking,
bool? lnaBlockTrackers,
bool? lnaEnabled,
});
}
/// Callable proxy for `copyWith` functionality.
/// Use as `instanceOfEngineSettings.copyWith(...)` or call `instanceOfEngineSettings.copyWith.fieldName(value)` for a single field.
class _$EngineSettingsCWProxyImpl implements _$EngineSettingsCWProxy {
const _$EngineSettingsCWProxyImpl(this._value);
final EngineSettings _value;
@override
EngineSettings javascriptEnabled(bool? javascriptEnabled) =>
call(javascriptEnabled: javascriptEnabled);
@override
EngineSettings trackingProtectionPolicy(
TrackingProtectionPolicy? trackingProtectionPolicy,
) => call(trackingProtectionPolicy: trackingProtectionPolicy);
@override
EngineSettings httpsOnlyMode(HttpsOnlyMode? httpsOnlyMode) =>
call(httpsOnlyMode: httpsOnlyMode);
@override
EngineSettings globalPrivacyControlEnabled(
bool? globalPrivacyControlEnabled,
) => call(globalPrivacyControlEnabled: globalPrivacyControlEnabled);
@override
EngineSettings preferredColorScheme(ColorScheme? preferredColorScheme) =>
call(preferredColorScheme: preferredColorScheme);
@override
EngineSettings cookieBannerHandlingMode(
CookieBannerHandlingMode? cookieBannerHandlingMode,
) => call(cookieBannerHandlingMode: cookieBannerHandlingMode);
@override
EngineSettings cookieBannerHandlingModePrivateBrowsing(
CookieBannerHandlingMode? cookieBannerHandlingModePrivateBrowsing,
) => call(
cookieBannerHandlingModePrivateBrowsing:
cookieBannerHandlingModePrivateBrowsing,
);
@override
EngineSettings cookieBannerHandlingGlobalRules(
bool? cookieBannerHandlingGlobalRules,
) => call(cookieBannerHandlingGlobalRules: cookieBannerHandlingGlobalRules);
@override
EngineSettings cookieBannerHandlingGlobalRulesSubFrames(
bool? cookieBannerHandlingGlobalRulesSubFrames,
) => call(
cookieBannerHandlingGlobalRulesSubFrames:
cookieBannerHandlingGlobalRulesSubFrames,
);
@override
EngineSettings webContentIsolationStrategy(
WebContentIsolationStrategy? webContentIsolationStrategy,
) => call(webContentIsolationStrategy: webContentIsolationStrategy);
@override
EngineSettings userAgent(String? userAgent) => call(userAgent: userAgent);
@override
EngineSettings enterpriseRootsEnabled(bool? enterpriseRootsEnabled) =>
call(enterpriseRootsEnabled: enterpriseRootsEnabled);
@override
EngineSettings queryParameterStripping(
QueryParameterStripping queryParameterStripping,
) => call(queryParameterStripping: queryParameterStripping);
@override
EngineSettings bounceTrackingProtectionMode(
BounceTrackingProtectionMode bounceTrackingProtectionMode,
) => call(bounceTrackingProtectionMode: bounceTrackingProtectionMode);
@override
EngineSettings addonCollection(AddonCollection? addonCollection) =>
call(addonCollection: addonCollection);
@override
EngineSettings dohSettingsMode(DohSettingsMode dohSettingsMode) =>
call(dohSettingsMode: dohSettingsMode);
@override
EngineSettings dohProviderUrl(String dohProviderUrl) =>
call(dohProviderUrl: dohProviderUrl);
@override
EngineSettings dohDefaultProviderUrl(String dohDefaultProviderUrl) =>
call(dohDefaultProviderUrl: dohDefaultProviderUrl);
@override
EngineSettings dohExceptionsList(List<String> dohExceptionsList) =>
call(dohExceptionsList: dohExceptionsList);
@override
EngineSettings fingerprintingProtectionOverrides(
String? fingerprintingProtectionOverrides,
) => call(
fingerprintingProtectionOverrides: fingerprintingProtectionOverrides,
);
@override
EngineSettings enablePdfJs(bool enablePdfJs) =>
call(enablePdfJs: enablePdfJs);
@override
EngineSettings locales(List<String>? locales) => call(locales: locales);
@override
EngineSettings blockCookies(bool? blockCookies) =>
call(blockCookies: blockCookies);
@override
EngineSettings customCookiePolicy(CustomCookiePolicy? customCookiePolicy) =>
call(customCookiePolicy: customCookiePolicy);
@override
EngineSettings blockTrackingContent(bool? blockTrackingContent) =>
call(blockTrackingContent: blockTrackingContent);
@override
EngineSettings trackingContentScope(TrackingScope? trackingContentScope) =>
call(trackingContentScope: trackingContentScope);
@override
EngineSettings blockCryptominers(bool? blockCryptominers) =>
call(blockCryptominers: blockCryptominers);
@override
EngineSettings blockFingerprinters(bool? blockFingerprinters) =>
call(blockFingerprinters: blockFingerprinters);
@override
EngineSettings blockRedirectTrackers(bool? blockRedirectTrackers) =>
call(blockRedirectTrackers: blockRedirectTrackers);
@override
EngineSettings blockSuspectedFingerprinters(
bool? blockSuspectedFingerprinters,
) => call(blockSuspectedFingerprinters: blockSuspectedFingerprinters);
@override
EngineSettings suspectedFingerprintersScope(
TrackingScope? suspectedFingerprintersScope,
) => call(suspectedFingerprintersScope: suspectedFingerprintersScope);
@override
EngineSettings allowListBaseline(bool? allowListBaseline) =>
call(allowListBaseline: allowListBaseline);
@override
EngineSettings allowListConvenience(bool? allowListConvenience) =>
call(allowListConvenience: allowListConvenience);
@override
EngineSettings webFontsEnabled(bool? webFontsEnabled) =>
call(webFontsEnabled: webFontsEnabled);
@override
EngineSettings automaticFontSizeAdjustment(
bool? automaticFontSizeAdjustment,
) => call(automaticFontSizeAdjustment: automaticFontSizeAdjustment);
@override
EngineSettings fontSizeFactor(double? fontSizeFactor) =>
call(fontSizeFactor: fontSizeFactor);
@override
EngineSettings fontInflationEnabled(bool? fontInflationEnabled) =>
call(fontInflationEnabled: fontInflationEnabled);
@override
EngineSettings displayDensityOverride(double? displayDensityOverride) =>
call(displayDensityOverride: displayDensityOverride);
@override
EngineSettings screenWidthOverride(int? screenWidthOverride) =>
call(screenWidthOverride: screenWidthOverride);
@override
EngineSettings screenHeightOverride(int? screenHeightOverride) =>
call(screenHeightOverride: screenHeightOverride);
@override
EngineSettings inputAutoZoomEnabled(bool? inputAutoZoomEnabled) =>
call(inputAutoZoomEnabled: inputAutoZoomEnabled);
@override
EngineSettings fissionEnabled(bool? fissionEnabled) =>
call(fissionEnabled: fissionEnabled);
@override
EngineSettings isolatedProcessEnabled(bool? isolatedProcessEnabled) =>
call(isolatedProcessEnabled: isolatedProcessEnabled);
@override
EngineSettings appZygoteProcessEnabled(bool? appZygoteProcessEnabled) =>
call(appZygoteProcessEnabled: appZygoteProcessEnabled);
@override
EngineSettings extensionsWebAPIEnabled(bool? extensionsWebAPIEnabled) =>
call(extensionsWebAPIEnabled: extensionsWebAPIEnabled);
@override
EngineSettings lnaBlocking(bool? lnaBlocking) =>
call(lnaBlocking: lnaBlocking);
@override
EngineSettings lnaBlockTrackers(bool? lnaBlockTrackers) =>
call(lnaBlockTrackers: lnaBlockTrackers);
@override
EngineSettings lnaEnabled(bool? lnaEnabled) => call(lnaEnabled: lnaEnabled);
@override
/// Creates a new instance with the provided field values.
/// Passing `null` to a nullable field nullifies it, while `null` for a non-nullable field is ignored. To update a single field use `EngineSettings(...).copyWith.fieldName(value)`.
///
/// Example:
/// ```dart
/// EngineSettings(...).copyWith(id: 12, name: "My name")
/// ```
EngineSettings call({
Object? javascriptEnabled = const $CopyWithPlaceholder(),
Object? trackingProtectionPolicy = const $CopyWithPlaceholder(),
Object? httpsOnlyMode = const $CopyWithPlaceholder(),
Object? globalPrivacyControlEnabled = const $CopyWithPlaceholder(),
Object? preferredColorScheme = const $CopyWithPlaceholder(),
Object? cookieBannerHandlingMode = const $CopyWithPlaceholder(),
Object? cookieBannerHandlingModePrivateBrowsing =
const $CopyWithPlaceholder(),
Object? cookieBannerHandlingGlobalRules = const $CopyWithPlaceholder(),
Object? cookieBannerHandlingGlobalRulesSubFrames =
const $CopyWithPlaceholder(),
Object? webContentIsolationStrategy = const $CopyWithPlaceholder(),
Object? userAgent = const $CopyWithPlaceholder(),
Object? enterpriseRootsEnabled = const $CopyWithPlaceholder(),
Object? queryParameterStripping = const $CopyWithPlaceholder(),
Object? bounceTrackingProtectionMode = const $CopyWithPlaceholder(),
Object? addonCollection = const $CopyWithPlaceholder(),
Object? dohSettingsMode = const $CopyWithPlaceholder(),
Object? dohProviderUrl = const $CopyWithPlaceholder(),
Object? dohDefaultProviderUrl = const $CopyWithPlaceholder(),
Object? dohExceptionsList = const $CopyWithPlaceholder(),
Object? fingerprintingProtectionOverrides = const $CopyWithPlaceholder(),
Object? enablePdfJs = const $CopyWithPlaceholder(),
Object? locales = const $CopyWithPlaceholder(),
Object? blockCookies = const $CopyWithPlaceholder(),
Object? customCookiePolicy = const $CopyWithPlaceholder(),
Object? blockTrackingContent = const $CopyWithPlaceholder(),
Object? trackingContentScope = const $CopyWithPlaceholder(),
Object? blockCryptominers = const $CopyWithPlaceholder(),
Object? blockFingerprinters = const $CopyWithPlaceholder(),
Object? blockRedirectTrackers = const $CopyWithPlaceholder(),
Object? blockSuspectedFingerprinters = const $CopyWithPlaceholder(),
Object? suspectedFingerprintersScope = const $CopyWithPlaceholder(),
Object? allowListBaseline = const $CopyWithPlaceholder(),
Object? allowListConvenience = const $CopyWithPlaceholder(),
Object? webFontsEnabled = const $CopyWithPlaceholder(),
Object? automaticFontSizeAdjustment = const $CopyWithPlaceholder(),
Object? fontSizeFactor = const $CopyWithPlaceholder(),
Object? fontInflationEnabled = const $CopyWithPlaceholder(),
Object? displayDensityOverride = const $CopyWithPlaceholder(),
Object? screenWidthOverride = const $CopyWithPlaceholder(),
Object? screenHeightOverride = const $CopyWithPlaceholder(),
Object? inputAutoZoomEnabled = const $CopyWithPlaceholder(),
Object? fissionEnabled = const $CopyWithPlaceholder(),
Object? isolatedProcessEnabled = const $CopyWithPlaceholder(),
Object? appZygoteProcessEnabled = const $CopyWithPlaceholder(),
Object? extensionsWebAPIEnabled = const $CopyWithPlaceholder(),
Object? lnaBlocking = const $CopyWithPlaceholder(),
Object? lnaBlockTrackers = const $CopyWithPlaceholder(),
Object? lnaEnabled = const $CopyWithPlaceholder(),
}) {
return EngineSettings(
javascriptEnabled: javascriptEnabled == const $CopyWithPlaceholder()
? _value.javascriptEnabled
// ignore: cast_nullable_to_non_nullable
: javascriptEnabled as bool?,
trackingProtectionPolicy:
trackingProtectionPolicy == const $CopyWithPlaceholder()
? _value.trackingProtectionPolicy
// ignore: cast_nullable_to_non_nullable
: trackingProtectionPolicy as TrackingProtectionPolicy?,
httpsOnlyMode: httpsOnlyMode == const $CopyWithPlaceholder()
? _value.httpsOnlyMode
// ignore: cast_nullable_to_non_nullable
: httpsOnlyMode as HttpsOnlyMode?,
globalPrivacyControlEnabled:
globalPrivacyControlEnabled == const $CopyWithPlaceholder()
? _value.globalPrivacyControlEnabled
// ignore: cast_nullable_to_non_nullable
: globalPrivacyControlEnabled as bool?,
preferredColorScheme: preferredColorScheme == const $CopyWithPlaceholder()
? _value.preferredColorScheme
// ignore: cast_nullable_to_non_nullable
: preferredColorScheme as ColorScheme?,
cookieBannerHandlingMode:
cookieBannerHandlingMode == const $CopyWithPlaceholder()
? _value.cookieBannerHandlingMode
// ignore: cast_nullable_to_non_nullable
: cookieBannerHandlingMode as CookieBannerHandlingMode?,
cookieBannerHandlingModePrivateBrowsing:
cookieBannerHandlingModePrivateBrowsing ==
const $CopyWithPlaceholder()
? _value.cookieBannerHandlingModePrivateBrowsing
// ignore: cast_nullable_to_non_nullable
: cookieBannerHandlingModePrivateBrowsing
as CookieBannerHandlingMode?,
cookieBannerHandlingGlobalRules:
cookieBannerHandlingGlobalRules == const $CopyWithPlaceholder()
? _value.cookieBannerHandlingGlobalRules
// ignore: cast_nullable_to_non_nullable
: cookieBannerHandlingGlobalRules as bool?,
cookieBannerHandlingGlobalRulesSubFrames:
cookieBannerHandlingGlobalRulesSubFrames ==
const $CopyWithPlaceholder()
? _value.cookieBannerHandlingGlobalRulesSubFrames
// ignore: cast_nullable_to_non_nullable
: cookieBannerHandlingGlobalRulesSubFrames as bool?,
webContentIsolationStrategy:
webContentIsolationStrategy == const $CopyWithPlaceholder()
? _value.webContentIsolationStrategy
// ignore: cast_nullable_to_non_nullable
: webContentIsolationStrategy as WebContentIsolationStrategy?,
userAgent: userAgent == const $CopyWithPlaceholder()
? _value.userAgent
// ignore: cast_nullable_to_non_nullable
: userAgent as String?,
enterpriseRootsEnabled:
enterpriseRootsEnabled == const $CopyWithPlaceholder()
? _value.enterpriseRootsEnabled
// ignore: cast_nullable_to_non_nullable
: enterpriseRootsEnabled as bool?,
queryParameterStripping:
queryParameterStripping == const $CopyWithPlaceholder() ||
queryParameterStripping == null
? _value.queryParameterStripping
// ignore: cast_nullable_to_non_nullable
: queryParameterStripping as QueryParameterStripping,
bounceTrackingProtectionMode:
bounceTrackingProtectionMode == const $CopyWithPlaceholder() ||
bounceTrackingProtectionMode == null
? _value.bounceTrackingProtectionMode
// ignore: cast_nullable_to_non_nullable
: bounceTrackingProtectionMode as BounceTrackingProtectionMode,
addonCollection: addonCollection == const $CopyWithPlaceholder()
? _value.addonCollection
// ignore: cast_nullable_to_non_nullable
: addonCollection as AddonCollection?,
dohSettingsMode:
dohSettingsMode == const $CopyWithPlaceholder() ||
dohSettingsMode == null
? _value.dohSettingsMode
// ignore: cast_nullable_to_non_nullable
: dohSettingsMode as DohSettingsMode,
dohProviderUrl:
dohProviderUrl == const $CopyWithPlaceholder() ||
dohProviderUrl == null
? _value.dohProviderUrl
// ignore: cast_nullable_to_non_nullable
: dohProviderUrl as String,
dohDefaultProviderUrl:
dohDefaultProviderUrl == const $CopyWithPlaceholder() ||
dohDefaultProviderUrl == null
? _value.dohDefaultProviderUrl
// ignore: cast_nullable_to_non_nullable
: dohDefaultProviderUrl as String,
dohExceptionsList:
dohExceptionsList == const $CopyWithPlaceholder() ||
dohExceptionsList == null
? _value.dohExceptionsList
// ignore: cast_nullable_to_non_nullable
: dohExceptionsList as List<String>,
fingerprintingProtectionOverrides:
fingerprintingProtectionOverrides == const $CopyWithPlaceholder()
? _value.fingerprintingProtectionOverrides
// ignore: cast_nullable_to_non_nullable
: fingerprintingProtectionOverrides as String?,
enablePdfJs:
enablePdfJs == const $CopyWithPlaceholder() || enablePdfJs == null
? _value.enablePdfJs
// ignore: cast_nullable_to_non_nullable
: enablePdfJs as bool,
locales: locales == const $CopyWithPlaceholder()
? _value.locales
// ignore: cast_nullable_to_non_nullable
: locales as List<String>?,
blockCookies: blockCookies == const $CopyWithPlaceholder()
? _value.blockCookies
// ignore: cast_nullable_to_non_nullable
: blockCookies as bool?,
customCookiePolicy: customCookiePolicy == const $CopyWithPlaceholder()
? _value.customCookiePolicy
// ignore: cast_nullable_to_non_nullable
: customCookiePolicy as CustomCookiePolicy?,
blockTrackingContent: blockTrackingContent == const $CopyWithPlaceholder()
? _value.blockTrackingContent
// ignore: cast_nullable_to_non_nullable
: blockTrackingContent as bool?,
trackingContentScope: trackingContentScope == const $CopyWithPlaceholder()
? _value.trackingContentScope
// ignore: cast_nullable_to_non_nullable
: trackingContentScope as TrackingScope?,
blockCryptominers: blockCryptominers == const $CopyWithPlaceholder()
? _value.blockCryptominers
// ignore: cast_nullable_to_non_nullable
: blockCryptominers as bool?,
blockFingerprinters: blockFingerprinters == const $CopyWithPlaceholder()
? _value.blockFingerprinters
// ignore: cast_nullable_to_non_nullable
: blockFingerprinters as bool?,
blockRedirectTrackers:
blockRedirectTrackers == const $CopyWithPlaceholder()
? _value.blockRedirectTrackers
// ignore: cast_nullable_to_non_nullable
: blockRedirectTrackers as bool?,
blockSuspectedFingerprinters:
blockSuspectedFingerprinters == const $CopyWithPlaceholder()
? _value.blockSuspectedFingerprinters
// ignore: cast_nullable_to_non_nullable
: blockSuspectedFingerprinters as bool?,
suspectedFingerprintersScope:
suspectedFingerprintersScope == const $CopyWithPlaceholder()
? _value.suspectedFingerprintersScope
// ignore: cast_nullable_to_non_nullable
: suspectedFingerprintersScope as TrackingScope?,
allowListBaseline: allowListBaseline == const $CopyWithPlaceholder()
? _value.allowListBaseline
// ignore: cast_nullable_to_non_nullable
: allowListBaseline as bool?,
allowListConvenience: allowListConvenience == const $CopyWithPlaceholder()
? _value.allowListConvenience
// ignore: cast_nullable_to_non_nullable
: allowListConvenience as bool?,
webFontsEnabled: webFontsEnabled == const $CopyWithPlaceholder()
? _value.webFontsEnabled
// ignore: cast_nullable_to_non_nullable
: webFontsEnabled as bool?,
automaticFontSizeAdjustment:
automaticFontSizeAdjustment == const $CopyWithPlaceholder()
? _value.automaticFontSizeAdjustment
// ignore: cast_nullable_to_non_nullable
: automaticFontSizeAdjustment as bool?,
fontSizeFactor: fontSizeFactor == const $CopyWithPlaceholder()
? _value.fontSizeFactor
// ignore: cast_nullable_to_non_nullable
: fontSizeFactor as double?,
fontInflationEnabled: fontInflationEnabled == const $CopyWithPlaceholder()
? _value.fontInflationEnabled
// ignore: cast_nullable_to_non_nullable
: fontInflationEnabled as bool?,
displayDensityOverride:
displayDensityOverride == const $CopyWithPlaceholder()
? _value.displayDensityOverride
// ignore: cast_nullable_to_non_nullable
: displayDensityOverride as double?,
screenWidthOverride: screenWidthOverride == const $CopyWithPlaceholder()
? _value.screenWidthOverride
// ignore: cast_nullable_to_non_nullable
: screenWidthOverride as int?,
screenHeightOverride: screenHeightOverride == const $CopyWithPlaceholder()
? _value.screenHeightOverride
// ignore: cast_nullable_to_non_nullable
: screenHeightOverride as int?,
inputAutoZoomEnabled: inputAutoZoomEnabled == const $CopyWithPlaceholder()
? _value.inputAutoZoomEnabled
// ignore: cast_nullable_to_non_nullable
: inputAutoZoomEnabled as bool?,
fissionEnabled: fissionEnabled == const $CopyWithPlaceholder()
? _value.fissionEnabled
// ignore: cast_nullable_to_non_nullable
: fissionEnabled as bool?,
isolatedProcessEnabled:
isolatedProcessEnabled == const $CopyWithPlaceholder()
? _value.isolatedProcessEnabled
// ignore: cast_nullable_to_non_nullable
: isolatedProcessEnabled as bool?,
appZygoteProcessEnabled:
appZygoteProcessEnabled == const $CopyWithPlaceholder()
? _value.appZygoteProcessEnabled
// ignore: cast_nullable_to_non_nullable
: appZygoteProcessEnabled as bool?,
extensionsWebAPIEnabled:
extensionsWebAPIEnabled == const $CopyWithPlaceholder()
? _value.extensionsWebAPIEnabled
// ignore: cast_nullable_to_non_nullable
: extensionsWebAPIEnabled as bool?,
lnaBlocking: lnaBlocking == const $CopyWithPlaceholder()
? _value.lnaBlocking
// ignore: cast_nullable_to_non_nullable
: lnaBlocking as bool?,
lnaBlockTrackers: lnaBlockTrackers == const $CopyWithPlaceholder()
? _value.lnaBlockTrackers
// ignore: cast_nullable_to_non_nullable
: lnaBlockTrackers as bool?,
lnaEnabled: lnaEnabled == const $CopyWithPlaceholder()
? _value.lnaEnabled
// ignore: cast_nullable_to_non_nullable
: lnaEnabled as bool?,
);
}
}
extension $EngineSettingsCopyWith on EngineSettings {
/// Returns a callable class used to build a new instance with modified fields.
/// Example: `instanceOfEngineSettings.copyWith(...)` or `instanceOfEngineSettings.copyWith.fieldName(...)`.
// ignore: library_private_types_in_public_api
_$EngineSettingsCWProxy get copyWith => _$EngineSettingsCWProxyImpl(this);
}
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
EngineSettings _$EngineSettingsFromJson(
Map<String, dynamic> json,
) => EngineSettings.withDefaults(
javascriptEnabled: json['javascriptEnabled'] as bool?,
trackingProtectionPolicy: $enumDecodeNullable(
_$TrackingProtectionPolicyEnumMap,
json['trackingProtectionPolicy'],
),
httpsOnlyMode: $enumDecodeNullable(
_$HttpsOnlyModeEnumMap,
json['httpsOnlyMode'],
),
globalPrivacyControlEnabled: json['globalPrivacyControlEnabled'] as bool?,
preferredColorScheme: $enumDecodeNullable(
_$ColorSchemeEnumMap,
json['preferredColorScheme'],
),
cookieBannerHandlingMode: $enumDecodeNullable(
_$CookieBannerHandlingModeEnumMap,
json['cookieBannerHandlingMode'],
),
cookieBannerHandlingModePrivateBrowsing: $enumDecodeNullable(
_$CookieBannerHandlingModeEnumMap,
json['cookieBannerHandlingModePrivateBrowsing'],
),
cookieBannerHandlingGlobalRules:
json['cookieBannerHandlingGlobalRules'] as bool?,
cookieBannerHandlingGlobalRulesSubFrames:
json['cookieBannerHandlingGlobalRulesSubFrames'] as bool?,
webContentIsolationStrategy: $enumDecodeNullable(
_$WebContentIsolationStrategyEnumMap,
json['webContentIsolationStrategy'],
),
queryParameterStripping: $enumDecodeNullable(
_$QueryParameterStrippingEnumMap,
json['queryParameterStripping'],
),
bounceTrackingProtectionMode: $enumDecodeNullable(
_$BounceTrackingProtectionModeEnumMap,
json['bounceTrackingProtectionMode'],
),
userAgent: json['userAgent'] as String?,
enterpriseRootsEnabled: json['enterpriseRootsEnabled'] as bool?,
addonCollection: EngineSettings._addonCollectionFromJson(
json['addonCollection'] as String?,
),
dohSettingsMode: $enumDecodeNullable(
_$DohSettingsModeEnumMap,
json['dohSettingsMode'],
),
dohProviderUrl: json['dohProviderUrl'] as String?,
dohDefaultProviderUrl: json['dohDefaultProviderUrl'] as String?,
dohExceptionsList: (json['dohExceptionsList'] as List<dynamic>?)
?.map((e) => e as String)
.toList(),
fingerprintingProtectionOverrides:
json['fingerprintingProtectionOverrides'] as String?,
enablePdfJs: json['enablePdfJs'] as bool?,
locales: (json['locales'] as List<dynamic>?)
?.map((e) => e as String)
.toList(),
blockCookies: json['blockCookies'] as bool?,
customCookiePolicy: $enumDecodeNullable(
_$CustomCookiePolicyEnumMap,
json['customCookiePolicy'],
),
blockTrackingContent: json['blockTrackingContent'] as bool?,
trackingContentScope: $enumDecodeNullable(
_$TrackingScopeEnumMap,
json['trackingContentScope'],
),
blockCryptominers: json['blockCryptominers'] as bool?,
blockFingerprinters: json['blockFingerprinters'] as bool?,
blockRedirectTrackers: json['blockRedirectTrackers'] as bool?,
blockSuspectedFingerprinters: json['blockSuspectedFingerprinters'] as bool?,
suspectedFingerprintersScope: $enumDecodeNullable(
_$TrackingScopeEnumMap,
json['suspectedFingerprintersScope'],
),
allowListBaseline: json['allowListBaseline'] as bool?,
allowListConvenience: json['allowListConvenience'] as bool?,
webFontsEnabled: json['webFontsEnabled'] as bool?,
automaticFontSizeAdjustment: json['automaticFontSizeAdjustment'] as bool?,
fontSizeFactor: (json['fontSizeFactor'] as num?)?.toDouble(),
fontInflationEnabled: json['fontInflationEnabled'] as bool?,
displayDensityOverride: (json['displayDensityOverride'] as num?)?.toDouble(),
screenWidthOverride: (json['screenWidthOverride'] as num?)?.toInt(),
screenHeightOverride: (json['screenHeightOverride'] as num?)?.toInt(),
inputAutoZoomEnabled: json['inputAutoZoomEnabled'] as bool?,
fissionEnabled: json['fissionEnabled'] as bool?,
isolatedProcessEnabled: json['isolatedProcessEnabled'] as bool?,
appZygoteProcessEnabled: json['appZygoteProcessEnabled'] as bool?,
extensionsWebAPIEnabled: json['extensionsWebAPIEnabled'] as bool?,
lnaBlocking: json['lnaBlocking'] as bool?,
lnaBlockTrackers: json['lnaBlockTrackers'] as bool?,
lnaEnabled: json['lnaEnabled'] as bool?,
);
Map<String, dynamic> _$EngineSettingsToJson(
EngineSettings instance,
) => <String, dynamic>{
'userAgent': instance.userAgent,
'fingerprintingProtectionOverrides':
instance.fingerprintingProtectionOverrides,
'displayDensityOverride': instance.displayDensityOverride,
'screenWidthOverride': instance.screenWidthOverride,
'screenHeightOverride': instance.screenHeightOverride,
'lnaBlocking': instance.lnaBlocking,
'lnaBlockTrackers': instance.lnaBlockTrackers,
'lnaEnabled': instance.lnaEnabled,
'javascriptEnabled': instance.javascriptEnabled,
'trackingProtectionPolicy':
_$TrackingProtectionPolicyEnumMap[instance.trackingProtectionPolicy]!,
'httpsOnlyMode': _$HttpsOnlyModeEnumMap[instance.httpsOnlyMode]!,
'preferredColorScheme': _$ColorSchemeEnumMap[instance.preferredColorScheme]!,
'globalPrivacyControlEnabled': instance.globalPrivacyControlEnabled,
'cookieBannerHandlingMode':
_$CookieBannerHandlingModeEnumMap[instance.cookieBannerHandlingMode]!,
'cookieBannerHandlingModePrivateBrowsing':
_$CookieBannerHandlingModeEnumMap[instance
.cookieBannerHandlingModePrivateBrowsing]!,
'cookieBannerHandlingGlobalRules': instance.cookieBannerHandlingGlobalRules,
'cookieBannerHandlingGlobalRulesSubFrames':
instance.cookieBannerHandlingGlobalRulesSubFrames,
'webContentIsolationStrategy':
_$WebContentIsolationStrategyEnumMap[instance
.webContentIsolationStrategy]!,
'enterpriseRootsEnabled': instance.enterpriseRootsEnabled,
'locales': instance.locales,
'blockCookies': instance.blockCookies,
'customCookiePolicy':
_$CustomCookiePolicyEnumMap[instance.customCookiePolicy]!,
'blockTrackingContent': instance.blockTrackingContent,
'trackingContentScope':
_$TrackingScopeEnumMap[instance.trackingContentScope]!,
'blockCryptominers': instance.blockCryptominers,
'blockFingerprinters': instance.blockFingerprinters,
'blockRedirectTrackers': instance.blockRedirectTrackers,
'blockSuspectedFingerprinters': instance.blockSuspectedFingerprinters,
'suspectedFingerprintersScope':
_$TrackingScopeEnumMap[instance.suspectedFingerprintersScope]!,
'allowListBaseline': instance.allowListBaseline,
'allowListConvenience': instance.allowListConvenience,
'webFontsEnabled': instance.webFontsEnabled,
'automaticFontSizeAdjustment': instance.automaticFontSizeAdjustment,
'fontSizeFactor': instance.fontSizeFactor,
'fontInflationEnabled': instance.fontInflationEnabled,
'inputAutoZoomEnabled': instance.inputAutoZoomEnabled,
'fissionEnabled': instance.fissionEnabled,
'isolatedProcessEnabled': instance.isolatedProcessEnabled,
'appZygoteProcessEnabled': instance.appZygoteProcessEnabled,
'extensionsWebAPIEnabled': instance.extensionsWebAPIEnabled,
'queryParameterStripping':
_$QueryParameterStrippingEnumMap[instance.queryParameterStripping]!,
'bounceTrackingProtectionMode':
_$BounceTrackingProtectionModeEnumMap[instance
.bounceTrackingProtectionMode]!,
'addonCollection': EngineSettings._addonCollectionToJson(
instance.addonCollection,
),
'dohSettingsMode': _$DohSettingsModeEnumMap[instance.dohSettingsMode]!,
'dohProviderUrl': instance.dohProviderUrl,
'dohDefaultProviderUrl': instance.dohDefaultProviderUrl,
'dohExceptionsList': instance.dohExceptionsList,
'enablePdfJs': instance.enablePdfJs,
};
const _$TrackingProtectionPolicyEnumMap = {
TrackingProtectionPolicy.none: 'none',
TrackingProtectionPolicy.recommended: 'recommended',
TrackingProtectionPolicy.strict: 'strict',
TrackingProtectionPolicy.custom: 'custom',
};
const _$HttpsOnlyModeEnumMap = {
HttpsOnlyMode.disabled: 'disabled',
HttpsOnlyMode.privateOnly: 'privateOnly',
HttpsOnlyMode.enabled: 'enabled',
};
const _$ColorSchemeEnumMap = {
ColorScheme.system: 'system',
ColorScheme.light: 'light',
ColorScheme.dark: 'dark',
};
const _$CookieBannerHandlingModeEnumMap = {
CookieBannerHandlingMode.disabled: 'disabled',
CookieBannerHandlingMode.rejectAll: 'rejectAll',
CookieBannerHandlingMode.rejectOrAcceptAll: 'rejectOrAcceptAll',
};
const _$WebContentIsolationStrategyEnumMap = {
WebContentIsolationStrategy.isolateNothing: 'isolateNothing',
WebContentIsolationStrategy.isolateEverything: 'isolateEverything',
WebContentIsolationStrategy.isolateHighValue: 'isolateHighValue',
};
const _$QueryParameterStrippingEnumMap = {
QueryParameterStripping.disabled: 'disabled',
QueryParameterStripping.privateOnly: 'privateOnly',
QueryParameterStripping.enabled: 'enabled',
};
const _$BounceTrackingProtectionModeEnumMap = {
BounceTrackingProtectionMode.disabled: 'disabled',
BounceTrackingProtectionMode.enabled: 'enabled',
BounceTrackingProtectionMode.enabledStandby: 'enabledStandby',
BounceTrackingProtectionMode.enabledDryRun: 'enabledDryRun',
};
const _$DohSettingsModeEnumMap = {
DohSettingsMode.geckoDefault: 'geckoDefault',
DohSettingsMode.increased: 'increased',
DohSettingsMode.max: 'max',
DohSettingsMode.off: 'off',
};
const _$CustomCookiePolicyEnumMap = {
CustomCookiePolicy.totalProtection: 'totalProtection',
CustomCookiePolicy.crossSiteTrackers: 'crossSiteTrackers',
CustomCookiePolicy.unvisited: 'unvisited',
CustomCookiePolicy.thirdParty: 'thirdParty',
CustomCookiePolicy.allCookies: 'allCookies',
};
const _$TrackingScopeEnumMap = {
TrackingScope.all: 'all',
TrackingScope.privateOnly: 'privateOnly',
};
@@ -0,0 +1,357 @@
/*
* Copyright (c) 2024-2026 Fabian Freund.
*
* This file is part of WebLibre
* (see https://weblibre.eu).
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import 'package:copy_with_extension/copy_with_extension.dart';
import 'package:fast_equatable/fast_equatable.dart';
import 'package:flutter/material.dart';
import 'package:json_annotation/json_annotation.dart';
import 'package:weblibre/core/routing/routes.dart';
import 'package:weblibre/features/bangs/data/models/bang_group.dart';
import 'package:weblibre/features/bangs/data/models/bang_key.dart';
import 'package:weblibre/features/search/domain/entities/abstract/i_search_suggestion_provider.dart';
part 'general_settings.g.dart';
const _fallbackSearchProvider = BangKey(
group: BangGroup.general,
trigger: 'wikipedia',
);
const _fallbackAutocompleteProvider = SearchSuggestionProviders.none;
const defaultUiScaleFactor = 1.0;
const minUiScaleFactor = 0.5;
const maxUiScaleFactor = 1.5;
const uiScaleFactorStep = 0.05;
enum TabBarSwipeAction { switchLastOpened, navigateOrderedTabs }
enum QuickTabSwitcherMode { lastUsedTabs, containerTabs }
enum TabIntentOpenSetting { regular, private, ask }
enum NewTabPosition { first, end }
enum TabBarPosition { top, bottom }
enum TabBarLayout { withTitle, compact }
enum DeleteBrowsingDataType {
tabs('Open tabs'),
history('Browsing history'),
cookies('Cookies and site data', 'Youll be logged out of most sites'),
cache('Cached images and files', 'Frees up storage space'),
permissions('Site permissions'),
downloads('Downloads');
final String title;
final String? description;
const DeleteBrowsingDataType(this.title, [this.description]);
}
@CopyWith()
@JsonSerializable(includeIfNull: true, constructor: 'withDefaults')
class GeneralSettings with FastEquatable {
final ThemeMode themeMode;
final double uiScaleFactor;
final bool disableAnimations;
final bool showModalBarrier;
final bool enableReadability;
final bool enforceReadability;
final Set<DeleteBrowsingDataType>? deleteBrowsingDataOnQuit;
@BangKeyConverter()
final BangKey? defaultSearchProvider;
final SearchSuggestionProviders defaultSearchSuggestionsProvider;
final bool createChildTabsOption;
final bool enableLocalAiFeatures;
final bool showContainerUi;
final bool showIsolatedTabUi;
@JsonKey(name: 'defaultCreateTabType')
final TabType storedDefaultCreateTabType;
final NewTabPosition newTabPosition;
final TabIntentOpenSetting tabIntentOpenSetting;
final bool autoHideTabBar;
final TabBarSwipeAction tabBarSwipeAction;
final Duration historyAutoCleanInterval;
final bool tabViewBottomSheet;
final bool tabBarShowContextualBar;
final bool tabBarShowQuickTabSwitcherBar;
final TabBarPosition tabBarPosition;
final TabBarLayout tabBarLayout;
final QuickTabSwitcherMode quickTabSwitcherMode;
final bool pullToRefreshEnabled;
final bool useExternalDownloadManager;
final bool doubleBackCloseTab;
final Duration unassignedTabsAutoCleanInterval;
final int maxSearchHistoryEntries;
final bool allowClipboardAccess;
final bool tabListShowFavicons;
final bool quickTabSwitcherShowTitles;
final bool quickTabSwitcherShowHistorySuggestions;
final String syncServerOverride;
final String syncTokenServerOverride;
final bool urlCleanerEnabled;
final bool urlCleanerAutoApply;
final bool urlCleanerAllowReferralMarketing;
final String urlCleanerCatalogUrl;
final String urlCleanerHashUrl;
final bool urlCleanerAutoUpdate;
final int? urlCleanerLastCheckEpochMs;
final bool urlCleanerLastUpdateWasAuto;
final TabType smallWebTabType;
final bool tabBarLongPressUrlCopy;
final bool unshortenerEnabled;
final String unshortenerToken;
final bool allowNonManifestPwaInstall;
GeneralSettings({
required this.themeMode,
required this.uiScaleFactor,
required this.disableAnimations,
required this.showModalBarrier,
required this.enableReadability,
required this.enforceReadability,
required this.deleteBrowsingDataOnQuit,
required this.defaultSearchProvider,
required this.defaultSearchSuggestionsProvider,
required this.createChildTabsOption,
required this.enableLocalAiFeatures,
required this.showContainerUi,
required this.showIsolatedTabUi,
required this.storedDefaultCreateTabType,
required this.newTabPosition,
required this.tabIntentOpenSetting,
required this.autoHideTabBar,
required this.tabBarSwipeAction,
required this.historyAutoCleanInterval,
required this.tabViewBottomSheet,
required this.tabBarShowContextualBar,
required this.tabBarShowQuickTabSwitcherBar,
required this.tabBarPosition,
required this.tabBarLayout,
required this.quickTabSwitcherMode,
required this.pullToRefreshEnabled,
required this.useExternalDownloadManager,
required this.doubleBackCloseTab,
required this.unassignedTabsAutoCleanInterval,
required this.maxSearchHistoryEntries,
required this.allowClipboardAccess,
required this.tabListShowFavicons,
required this.quickTabSwitcherShowTitles,
required this.quickTabSwitcherShowHistorySuggestions,
required this.syncServerOverride,
required this.syncTokenServerOverride,
required this.urlCleanerEnabled,
required this.urlCleanerAutoApply,
required this.urlCleanerAllowReferralMarketing,
required this.urlCleanerCatalogUrl,
required this.urlCleanerHashUrl,
required this.urlCleanerAutoUpdate,
required this.urlCleanerLastCheckEpochMs,
required this.urlCleanerLastUpdateWasAuto,
required this.smallWebTabType,
required this.tabBarLongPressUrlCopy,
required this.unshortenerEnabled,
required this.unshortenerToken,
required this.allowNonManifestPwaInstall,
});
GeneralSettings.withDefaults({
ThemeMode? themeMode,
double? uiScaleFactor,
bool? disableAnimations,
bool? showModalBarrier,
bool? enableReadability,
bool? enforceReadability,
this.deleteBrowsingDataOnQuit,
BangKey? defaultSearchProvider,
SearchSuggestionProviders? defaultSearchSuggestionsProvider,
bool? createChildTabsOption,
bool? enableLocalAiFeatures,
bool? showContainerUi,
bool? showIsolatedTabUi,
TabType? storedDefaultCreateTabType,
NewTabPosition? newTabPosition,
TabIntentOpenSetting? tabIntentOpenSetting,
bool? autoHideTabBar,
TabBarSwipeAction? tabBarSwipeAction,
Duration? historyAutoCleanInterval,
bool? tabViewBottomSheet,
bool? tabBarShowContextualBar,
bool? tabBarShowQuickTabSwitcherBar,
TabBarPosition? tabBarPosition,
TabBarLayout? tabBarLayout,
QuickTabSwitcherMode? quickTabSwitcherMode,
bool? pullToRefreshEnabled,
bool? useExternalDownloadManager,
bool? doubleBackCloseTab,
Duration? unassignedTabsAutoCleanInterval,
int? maxSearchHistoryEntries,
bool? allowClipboardAccess,
bool? tabListShowFavicons,
bool? quickTabSwitcherShowTitles,
bool? quickTabSwitcherShowHistorySuggestions,
String? syncServerOverride,
String? syncTokenServerOverride,
bool? urlCleanerEnabled,
bool? urlCleanerAutoApply,
bool? urlCleanerAllowReferralMarketing,
String? urlCleanerCatalogUrl,
String? urlCleanerHashUrl,
bool? urlCleanerAutoUpdate,
this.urlCleanerLastCheckEpochMs,
bool? urlCleanerLastUpdateWasAuto,
TabType? smallWebTabType,
bool? tabBarLongPressUrlCopy,
bool? unshortenerEnabled,
String? unshortenerToken,
bool? allowNonManifestPwaInstall,
}) : themeMode = themeMode ?? ThemeMode.dark,
uiScaleFactor = uiScaleFactor ?? defaultUiScaleFactor,
disableAnimations = disableAnimations ?? false,
showModalBarrier = showModalBarrier ?? true,
enableReadability = enableReadability ?? true,
enforceReadability = enforceReadability ?? false,
defaultSearchProvider = defaultSearchProvider ?? _fallbackSearchProvider,
defaultSearchSuggestionsProvider =
defaultSearchSuggestionsProvider ?? _fallbackAutocompleteProvider,
createChildTabsOption = createChildTabsOption ?? false,
enableLocalAiFeatures = enableLocalAiFeatures ?? true,
showContainerUi = showContainerUi ?? true,
showIsolatedTabUi = showIsolatedTabUi ?? true,
storedDefaultCreateTabType =
storedDefaultCreateTabType ?? TabType.regular,
newTabPosition = newTabPosition ?? NewTabPosition.first,
tabIntentOpenSetting = tabIntentOpenSetting ?? TabIntentOpenSetting.ask,
autoHideTabBar = autoHideTabBar ?? true,
tabBarSwipeAction =
tabBarSwipeAction ?? TabBarSwipeAction.switchLastOpened,
historyAutoCleanInterval =
historyAutoCleanInterval ?? const Duration(days: 90),
tabViewBottomSheet = tabViewBottomSheet ?? false,
tabBarShowContextualBar = tabBarShowContextualBar ?? true,
tabBarShowQuickTabSwitcherBar = tabBarShowQuickTabSwitcherBar ?? true,
tabBarPosition = tabBarPosition ?? TabBarPosition.bottom,
tabBarLayout = tabBarLayout ?? TabBarLayout.compact,
quickTabSwitcherMode =
quickTabSwitcherMode ?? QuickTabSwitcherMode.lastUsedTabs,
pullToRefreshEnabled = pullToRefreshEnabled ?? true,
useExternalDownloadManager = useExternalDownloadManager ?? false,
doubleBackCloseTab = doubleBackCloseTab ?? true,
unassignedTabsAutoCleanInterval =
unassignedTabsAutoCleanInterval ?? Duration.zero,
maxSearchHistoryEntries = maxSearchHistoryEntries ?? 5,
allowClipboardAccess = allowClipboardAccess ?? true,
tabListShowFavicons = tabListShowFavicons ?? false,
quickTabSwitcherShowTitles = quickTabSwitcherShowTitles ?? true,
quickTabSwitcherShowHistorySuggestions =
quickTabSwitcherShowHistorySuggestions ?? true,
syncServerOverride = syncServerOverride ?? '',
syncTokenServerOverride = syncTokenServerOverride ?? '',
urlCleanerEnabled = urlCleanerEnabled ?? true,
urlCleanerAutoApply = urlCleanerAutoApply ?? false,
urlCleanerAllowReferralMarketing =
urlCleanerAllowReferralMarketing ?? false,
urlCleanerCatalogUrl =
urlCleanerCatalogUrl ??
'https://rules2.clearurls.xyz/data.minify.json',
urlCleanerHashUrl =
urlCleanerHashUrl ??
'https://rules2.clearurls.xyz/rules.minify.hash',
urlCleanerAutoUpdate = urlCleanerAutoUpdate ?? false,
urlCleanerLastUpdateWasAuto = urlCleanerLastUpdateWasAuto ?? false,
smallWebTabType = smallWebTabType ?? TabType.private,
tabBarLongPressUrlCopy = tabBarLongPressUrlCopy ?? true,
unshortenerEnabled = unshortenerEnabled ?? false,
unshortenerToken = unshortenerToken ?? '',
allowNonManifestPwaInstall = allowNonManifestPwaInstall ?? false;
factory GeneralSettings.fromJson(Map<String, dynamic> json) =>
_$GeneralSettingsFromJson(json);
Map<String, dynamic> toJson() => _$GeneralSettingsToJson(this);
TabType get effectiveDefaultCreateTabType {
if (!showIsolatedTabUi && storedDefaultCreateTabType == TabType.isolated) {
return TabType.regular;
}
return storedDefaultCreateTabType;
}
QuickTabSwitcherMode effectiveUiQuickTabSwitcherMode() {
if (!showContainerUi &&
quickTabSwitcherMode == QuickTabSwitcherMode.containerTabs) {
return QuickTabSwitcherMode.lastUsedTabs;
}
return quickTabSwitcherMode;
}
@override
List<Object?> get hashParameters => [
themeMode,
uiScaleFactor,
disableAnimations,
showModalBarrier,
enableReadability,
enforceReadability,
deleteBrowsingDataOnQuit,
defaultSearchProvider,
defaultSearchSuggestionsProvider,
createChildTabsOption,
enableLocalAiFeatures,
showContainerUi,
showIsolatedTabUi,
storedDefaultCreateTabType,
newTabPosition,
tabIntentOpenSetting,
autoHideTabBar,
tabBarSwipeAction,
historyAutoCleanInterval,
tabViewBottomSheet,
tabBarShowContextualBar,
tabBarShowQuickTabSwitcherBar,
tabBarPosition,
tabBarLayout,
quickTabSwitcherMode,
pullToRefreshEnabled,
useExternalDownloadManager,
doubleBackCloseTab,
unassignedTabsAutoCleanInterval,
maxSearchHistoryEntries,
allowClipboardAccess,
tabListShowFavicons,
quickTabSwitcherShowTitles,
quickTabSwitcherShowHistorySuggestions,
syncServerOverride,
syncTokenServerOverride,
urlCleanerEnabled,
urlCleanerAutoApply,
urlCleanerAllowReferralMarketing,
urlCleanerCatalogUrl,
urlCleanerHashUrl,
urlCleanerAutoUpdate,
urlCleanerLastCheckEpochMs,
urlCleanerLastUpdateWasAuto,
smallWebTabType,
tabBarLongPressUrlCopy,
unshortenerEnabled,
unshortenerToken,
allowNonManifestPwaInstall,
];
}
@@ -0,0 +1,987 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'general_settings.dart';
// **************************************************************************
// CopyWithGenerator
// **************************************************************************
abstract class _$GeneralSettingsCWProxy {
GeneralSettings themeMode(ThemeMode themeMode);
GeneralSettings uiScaleFactor(double uiScaleFactor);
GeneralSettings disableAnimations(bool disableAnimations);
GeneralSettings showModalBarrier(bool showModalBarrier);
GeneralSettings enableReadability(bool enableReadability);
GeneralSettings enforceReadability(bool enforceReadability);
GeneralSettings deleteBrowsingDataOnQuit(
Set<DeleteBrowsingDataType>? deleteBrowsingDataOnQuit,
);
GeneralSettings defaultSearchProvider(BangKey? defaultSearchProvider);
GeneralSettings defaultSearchSuggestionsProvider(
SearchSuggestionProviders defaultSearchSuggestionsProvider,
);
GeneralSettings createChildTabsOption(bool createChildTabsOption);
GeneralSettings enableLocalAiFeatures(bool enableLocalAiFeatures);
GeneralSettings showContainerUi(bool showContainerUi);
GeneralSettings showIsolatedTabUi(bool showIsolatedTabUi);
GeneralSettings storedDefaultCreateTabType(
TabType storedDefaultCreateTabType,
);
GeneralSettings newTabPosition(NewTabPosition newTabPosition);
GeneralSettings tabIntentOpenSetting(
TabIntentOpenSetting tabIntentOpenSetting,
);
GeneralSettings autoHideTabBar(bool autoHideTabBar);
GeneralSettings tabBarSwipeAction(TabBarSwipeAction tabBarSwipeAction);
GeneralSettings historyAutoCleanInterval(Duration historyAutoCleanInterval);
GeneralSettings tabViewBottomSheet(bool tabViewBottomSheet);
GeneralSettings tabBarShowContextualBar(bool tabBarShowContextualBar);
GeneralSettings tabBarShowQuickTabSwitcherBar(
bool tabBarShowQuickTabSwitcherBar,
);
GeneralSettings tabBarPosition(TabBarPosition tabBarPosition);
GeneralSettings tabBarLayout(TabBarLayout tabBarLayout);
GeneralSettings quickTabSwitcherMode(
QuickTabSwitcherMode quickTabSwitcherMode,
);
GeneralSettings pullToRefreshEnabled(bool pullToRefreshEnabled);
GeneralSettings useExternalDownloadManager(bool useExternalDownloadManager);
GeneralSettings doubleBackCloseTab(bool doubleBackCloseTab);
GeneralSettings unassignedTabsAutoCleanInterval(
Duration unassignedTabsAutoCleanInterval,
);
GeneralSettings maxSearchHistoryEntries(int maxSearchHistoryEntries);
GeneralSettings allowClipboardAccess(bool allowClipboardAccess);
GeneralSettings tabListShowFavicons(bool tabListShowFavicons);
GeneralSettings quickTabSwitcherShowTitles(bool quickTabSwitcherShowTitles);
GeneralSettings quickTabSwitcherShowHistorySuggestions(
bool quickTabSwitcherShowHistorySuggestions,
);
GeneralSettings syncServerOverride(String syncServerOverride);
GeneralSettings syncTokenServerOverride(String syncTokenServerOverride);
GeneralSettings urlCleanerEnabled(bool urlCleanerEnabled);
GeneralSettings urlCleanerAutoApply(bool urlCleanerAutoApply);
GeneralSettings urlCleanerAllowReferralMarketing(
bool urlCleanerAllowReferralMarketing,
);
GeneralSettings urlCleanerCatalogUrl(String urlCleanerCatalogUrl);
GeneralSettings urlCleanerHashUrl(String urlCleanerHashUrl);
GeneralSettings urlCleanerAutoUpdate(bool urlCleanerAutoUpdate);
GeneralSettings urlCleanerLastCheckEpochMs(int? urlCleanerLastCheckEpochMs);
GeneralSettings urlCleanerLastUpdateWasAuto(bool urlCleanerLastUpdateWasAuto);
GeneralSettings smallWebTabType(TabType smallWebTabType);
GeneralSettings tabBarLongPressUrlCopy(bool tabBarLongPressUrlCopy);
GeneralSettings unshortenerEnabled(bool unshortenerEnabled);
GeneralSettings unshortenerToken(String unshortenerToken);
GeneralSettings allowNonManifestPwaInstall(bool allowNonManifestPwaInstall);
/// Creates a new instance with the provided field values.
/// Passing `null` to a nullable field nullifies it, while `null` for a non-nullable field is ignored. To update a single field use `GeneralSettings(...).copyWith.fieldName(value)`.
///
/// Example:
/// ```dart
/// GeneralSettings(...).copyWith(id: 12, name: "My name")
/// ```
GeneralSettings call({
ThemeMode themeMode,
double uiScaleFactor,
bool disableAnimations,
bool showModalBarrier,
bool enableReadability,
bool enforceReadability,
Set<DeleteBrowsingDataType>? deleteBrowsingDataOnQuit,
BangKey? defaultSearchProvider,
SearchSuggestionProviders defaultSearchSuggestionsProvider,
bool createChildTabsOption,
bool enableLocalAiFeatures,
bool showContainerUi,
bool showIsolatedTabUi,
TabType storedDefaultCreateTabType,
NewTabPosition newTabPosition,
TabIntentOpenSetting tabIntentOpenSetting,
bool autoHideTabBar,
TabBarSwipeAction tabBarSwipeAction,
Duration historyAutoCleanInterval,
bool tabViewBottomSheet,
bool tabBarShowContextualBar,
bool tabBarShowQuickTabSwitcherBar,
TabBarPosition tabBarPosition,
TabBarLayout tabBarLayout,
QuickTabSwitcherMode quickTabSwitcherMode,
bool pullToRefreshEnabled,
bool useExternalDownloadManager,
bool doubleBackCloseTab,
Duration unassignedTabsAutoCleanInterval,
int maxSearchHistoryEntries,
bool allowClipboardAccess,
bool tabListShowFavicons,
bool quickTabSwitcherShowTitles,
bool quickTabSwitcherShowHistorySuggestions,
String syncServerOverride,
String syncTokenServerOverride,
bool urlCleanerEnabled,
bool urlCleanerAutoApply,
bool urlCleanerAllowReferralMarketing,
String urlCleanerCatalogUrl,
String urlCleanerHashUrl,
bool urlCleanerAutoUpdate,
int? urlCleanerLastCheckEpochMs,
bool urlCleanerLastUpdateWasAuto,
TabType smallWebTabType,
bool tabBarLongPressUrlCopy,
bool unshortenerEnabled,
String unshortenerToken,
bool allowNonManifestPwaInstall,
});
}
/// Callable proxy for `copyWith` functionality.
/// Use as `instanceOfGeneralSettings.copyWith(...)` or call `instanceOfGeneralSettings.copyWith.fieldName(value)` for a single field.
class _$GeneralSettingsCWProxyImpl implements _$GeneralSettingsCWProxy {
const _$GeneralSettingsCWProxyImpl(this._value);
final GeneralSettings _value;
@override
GeneralSettings themeMode(ThemeMode themeMode) => call(themeMode: themeMode);
@override
GeneralSettings uiScaleFactor(double uiScaleFactor) =>
call(uiScaleFactor: uiScaleFactor);
@override
GeneralSettings disableAnimations(bool disableAnimations) =>
call(disableAnimations: disableAnimations);
@override
GeneralSettings showModalBarrier(bool showModalBarrier) =>
call(showModalBarrier: showModalBarrier);
@override
GeneralSettings enableReadability(bool enableReadability) =>
call(enableReadability: enableReadability);
@override
GeneralSettings enforceReadability(bool enforceReadability) =>
call(enforceReadability: enforceReadability);
@override
GeneralSettings deleteBrowsingDataOnQuit(
Set<DeleteBrowsingDataType>? deleteBrowsingDataOnQuit,
) => call(deleteBrowsingDataOnQuit: deleteBrowsingDataOnQuit);
@override
GeneralSettings defaultSearchProvider(BangKey? defaultSearchProvider) =>
call(defaultSearchProvider: defaultSearchProvider);
@override
GeneralSettings defaultSearchSuggestionsProvider(
SearchSuggestionProviders defaultSearchSuggestionsProvider,
) => call(defaultSearchSuggestionsProvider: defaultSearchSuggestionsProvider);
@override
GeneralSettings createChildTabsOption(bool createChildTabsOption) =>
call(createChildTabsOption: createChildTabsOption);
@override
GeneralSettings enableLocalAiFeatures(bool enableLocalAiFeatures) =>
call(enableLocalAiFeatures: enableLocalAiFeatures);
@override
GeneralSettings showContainerUi(bool showContainerUi) =>
call(showContainerUi: showContainerUi);
@override
GeneralSettings showIsolatedTabUi(bool showIsolatedTabUi) =>
call(showIsolatedTabUi: showIsolatedTabUi);
@override
GeneralSettings storedDefaultCreateTabType(
TabType storedDefaultCreateTabType,
) => call(storedDefaultCreateTabType: storedDefaultCreateTabType);
@override
GeneralSettings newTabPosition(NewTabPosition newTabPosition) =>
call(newTabPosition: newTabPosition);
@override
GeneralSettings tabIntentOpenSetting(
TabIntentOpenSetting tabIntentOpenSetting,
) => call(tabIntentOpenSetting: tabIntentOpenSetting);
@override
GeneralSettings autoHideTabBar(bool autoHideTabBar) =>
call(autoHideTabBar: autoHideTabBar);
@override
GeneralSettings tabBarSwipeAction(TabBarSwipeAction tabBarSwipeAction) =>
call(tabBarSwipeAction: tabBarSwipeAction);
@override
GeneralSettings historyAutoCleanInterval(Duration historyAutoCleanInterval) =>
call(historyAutoCleanInterval: historyAutoCleanInterval);
@override
GeneralSettings tabViewBottomSheet(bool tabViewBottomSheet) =>
call(tabViewBottomSheet: tabViewBottomSheet);
@override
GeneralSettings tabBarShowContextualBar(bool tabBarShowContextualBar) =>
call(tabBarShowContextualBar: tabBarShowContextualBar);
@override
GeneralSettings tabBarShowQuickTabSwitcherBar(
bool tabBarShowQuickTabSwitcherBar,
) => call(tabBarShowQuickTabSwitcherBar: tabBarShowQuickTabSwitcherBar);
@override
GeneralSettings tabBarPosition(TabBarPosition tabBarPosition) =>
call(tabBarPosition: tabBarPosition);
@override
GeneralSettings tabBarLayout(TabBarLayout tabBarLayout) =>
call(tabBarLayout: tabBarLayout);
@override
GeneralSettings quickTabSwitcherMode(
QuickTabSwitcherMode quickTabSwitcherMode,
) => call(quickTabSwitcherMode: quickTabSwitcherMode);
@override
GeneralSettings pullToRefreshEnabled(bool pullToRefreshEnabled) =>
call(pullToRefreshEnabled: pullToRefreshEnabled);
@override
GeneralSettings useExternalDownloadManager(bool useExternalDownloadManager) =>
call(useExternalDownloadManager: useExternalDownloadManager);
@override
GeneralSettings doubleBackCloseTab(bool doubleBackCloseTab) =>
call(doubleBackCloseTab: doubleBackCloseTab);
@override
GeneralSettings unassignedTabsAutoCleanInterval(
Duration unassignedTabsAutoCleanInterval,
) => call(unassignedTabsAutoCleanInterval: unassignedTabsAutoCleanInterval);
@override
GeneralSettings maxSearchHistoryEntries(int maxSearchHistoryEntries) =>
call(maxSearchHistoryEntries: maxSearchHistoryEntries);
@override
GeneralSettings allowClipboardAccess(bool allowClipboardAccess) =>
call(allowClipboardAccess: allowClipboardAccess);
@override
GeneralSettings tabListShowFavicons(bool tabListShowFavicons) =>
call(tabListShowFavicons: tabListShowFavicons);
@override
GeneralSettings quickTabSwitcherShowTitles(bool quickTabSwitcherShowTitles) =>
call(quickTabSwitcherShowTitles: quickTabSwitcherShowTitles);
@override
GeneralSettings quickTabSwitcherShowHistorySuggestions(
bool quickTabSwitcherShowHistorySuggestions,
) => call(
quickTabSwitcherShowHistorySuggestions:
quickTabSwitcherShowHistorySuggestions,
);
@override
GeneralSettings syncServerOverride(String syncServerOverride) =>
call(syncServerOverride: syncServerOverride);
@override
GeneralSettings syncTokenServerOverride(String syncTokenServerOverride) =>
call(syncTokenServerOverride: syncTokenServerOverride);
@override
GeneralSettings urlCleanerEnabled(bool urlCleanerEnabled) =>
call(urlCleanerEnabled: urlCleanerEnabled);
@override
GeneralSettings urlCleanerAutoApply(bool urlCleanerAutoApply) =>
call(urlCleanerAutoApply: urlCleanerAutoApply);
@override
GeneralSettings urlCleanerAllowReferralMarketing(
bool urlCleanerAllowReferralMarketing,
) => call(urlCleanerAllowReferralMarketing: urlCleanerAllowReferralMarketing);
@override
GeneralSettings urlCleanerCatalogUrl(String urlCleanerCatalogUrl) =>
call(urlCleanerCatalogUrl: urlCleanerCatalogUrl);
@override
GeneralSettings urlCleanerHashUrl(String urlCleanerHashUrl) =>
call(urlCleanerHashUrl: urlCleanerHashUrl);
@override
GeneralSettings urlCleanerAutoUpdate(bool urlCleanerAutoUpdate) =>
call(urlCleanerAutoUpdate: urlCleanerAutoUpdate);
@override
GeneralSettings urlCleanerLastCheckEpochMs(int? urlCleanerLastCheckEpochMs) =>
call(urlCleanerLastCheckEpochMs: urlCleanerLastCheckEpochMs);
@override
GeneralSettings urlCleanerLastUpdateWasAuto(
bool urlCleanerLastUpdateWasAuto,
) => call(urlCleanerLastUpdateWasAuto: urlCleanerLastUpdateWasAuto);
@override
GeneralSettings smallWebTabType(TabType smallWebTabType) =>
call(smallWebTabType: smallWebTabType);
@override
GeneralSettings tabBarLongPressUrlCopy(bool tabBarLongPressUrlCopy) =>
call(tabBarLongPressUrlCopy: tabBarLongPressUrlCopy);
@override
GeneralSettings unshortenerEnabled(bool unshortenerEnabled) =>
call(unshortenerEnabled: unshortenerEnabled);
@override
GeneralSettings unshortenerToken(String unshortenerToken) =>
call(unshortenerToken: unshortenerToken);
@override
GeneralSettings allowNonManifestPwaInstall(bool allowNonManifestPwaInstall) =>
call(allowNonManifestPwaInstall: allowNonManifestPwaInstall);
@override
/// Creates a new instance with the provided field values.
/// Passing `null` to a nullable field nullifies it, while `null` for a non-nullable field is ignored. To update a single field use `GeneralSettings(...).copyWith.fieldName(value)`.
///
/// Example:
/// ```dart
/// GeneralSettings(...).copyWith(id: 12, name: "My name")
/// ```
GeneralSettings call({
Object? themeMode = const $CopyWithPlaceholder(),
Object? uiScaleFactor = const $CopyWithPlaceholder(),
Object? disableAnimations = const $CopyWithPlaceholder(),
Object? showModalBarrier = const $CopyWithPlaceholder(),
Object? enableReadability = const $CopyWithPlaceholder(),
Object? enforceReadability = const $CopyWithPlaceholder(),
Object? deleteBrowsingDataOnQuit = const $CopyWithPlaceholder(),
Object? defaultSearchProvider = const $CopyWithPlaceholder(),
Object? defaultSearchSuggestionsProvider = const $CopyWithPlaceholder(),
Object? createChildTabsOption = const $CopyWithPlaceholder(),
Object? enableLocalAiFeatures = const $CopyWithPlaceholder(),
Object? showContainerUi = const $CopyWithPlaceholder(),
Object? showIsolatedTabUi = const $CopyWithPlaceholder(),
Object? storedDefaultCreateTabType = const $CopyWithPlaceholder(),
Object? newTabPosition = const $CopyWithPlaceholder(),
Object? tabIntentOpenSetting = const $CopyWithPlaceholder(),
Object? autoHideTabBar = const $CopyWithPlaceholder(),
Object? tabBarSwipeAction = const $CopyWithPlaceholder(),
Object? historyAutoCleanInterval = const $CopyWithPlaceholder(),
Object? tabViewBottomSheet = const $CopyWithPlaceholder(),
Object? tabBarShowContextualBar = const $CopyWithPlaceholder(),
Object? tabBarShowQuickTabSwitcherBar = const $CopyWithPlaceholder(),
Object? tabBarPosition = const $CopyWithPlaceholder(),
Object? tabBarLayout = const $CopyWithPlaceholder(),
Object? quickTabSwitcherMode = const $CopyWithPlaceholder(),
Object? pullToRefreshEnabled = const $CopyWithPlaceholder(),
Object? useExternalDownloadManager = const $CopyWithPlaceholder(),
Object? doubleBackCloseTab = const $CopyWithPlaceholder(),
Object? unassignedTabsAutoCleanInterval = const $CopyWithPlaceholder(),
Object? maxSearchHistoryEntries = const $CopyWithPlaceholder(),
Object? allowClipboardAccess = const $CopyWithPlaceholder(),
Object? tabListShowFavicons = const $CopyWithPlaceholder(),
Object? quickTabSwitcherShowTitles = const $CopyWithPlaceholder(),
Object? quickTabSwitcherShowHistorySuggestions =
const $CopyWithPlaceholder(),
Object? syncServerOverride = const $CopyWithPlaceholder(),
Object? syncTokenServerOverride = const $CopyWithPlaceholder(),
Object? urlCleanerEnabled = const $CopyWithPlaceholder(),
Object? urlCleanerAutoApply = const $CopyWithPlaceholder(),
Object? urlCleanerAllowReferralMarketing = const $CopyWithPlaceholder(),
Object? urlCleanerCatalogUrl = const $CopyWithPlaceholder(),
Object? urlCleanerHashUrl = const $CopyWithPlaceholder(),
Object? urlCleanerAutoUpdate = const $CopyWithPlaceholder(),
Object? urlCleanerLastCheckEpochMs = const $CopyWithPlaceholder(),
Object? urlCleanerLastUpdateWasAuto = const $CopyWithPlaceholder(),
Object? smallWebTabType = const $CopyWithPlaceholder(),
Object? tabBarLongPressUrlCopy = const $CopyWithPlaceholder(),
Object? unshortenerEnabled = const $CopyWithPlaceholder(),
Object? unshortenerToken = const $CopyWithPlaceholder(),
Object? allowNonManifestPwaInstall = const $CopyWithPlaceholder(),
}) {
return GeneralSettings(
themeMode: themeMode == const $CopyWithPlaceholder() || themeMode == null
? _value.themeMode
// ignore: cast_nullable_to_non_nullable
: themeMode as ThemeMode,
uiScaleFactor:
uiScaleFactor == const $CopyWithPlaceholder() || uiScaleFactor == null
? _value.uiScaleFactor
// ignore: cast_nullable_to_non_nullable
: uiScaleFactor as double,
disableAnimations:
disableAnimations == const $CopyWithPlaceholder() ||
disableAnimations == null
? _value.disableAnimations
// ignore: cast_nullable_to_non_nullable
: disableAnimations as bool,
showModalBarrier:
showModalBarrier == const $CopyWithPlaceholder() ||
showModalBarrier == null
? _value.showModalBarrier
// ignore: cast_nullable_to_non_nullable
: showModalBarrier as bool,
enableReadability:
enableReadability == const $CopyWithPlaceholder() ||
enableReadability == null
? _value.enableReadability
// ignore: cast_nullable_to_non_nullable
: enableReadability as bool,
enforceReadability:
enforceReadability == const $CopyWithPlaceholder() ||
enforceReadability == null
? _value.enforceReadability
// ignore: cast_nullable_to_non_nullable
: enforceReadability as bool,
deleteBrowsingDataOnQuit:
deleteBrowsingDataOnQuit == const $CopyWithPlaceholder()
? _value.deleteBrowsingDataOnQuit
// ignore: cast_nullable_to_non_nullable
: deleteBrowsingDataOnQuit as Set<DeleteBrowsingDataType>?,
defaultSearchProvider:
defaultSearchProvider == const $CopyWithPlaceholder()
? _value.defaultSearchProvider
// ignore: cast_nullable_to_non_nullable
: defaultSearchProvider as BangKey?,
defaultSearchSuggestionsProvider:
defaultSearchSuggestionsProvider == const $CopyWithPlaceholder() ||
defaultSearchSuggestionsProvider == null
? _value.defaultSearchSuggestionsProvider
// ignore: cast_nullable_to_non_nullable
: defaultSearchSuggestionsProvider as SearchSuggestionProviders,
createChildTabsOption:
createChildTabsOption == const $CopyWithPlaceholder() ||
createChildTabsOption == null
? _value.createChildTabsOption
// ignore: cast_nullable_to_non_nullable
: createChildTabsOption as bool,
enableLocalAiFeatures:
enableLocalAiFeatures == const $CopyWithPlaceholder() ||
enableLocalAiFeatures == null
? _value.enableLocalAiFeatures
// ignore: cast_nullable_to_non_nullable
: enableLocalAiFeatures as bool,
showContainerUi:
showContainerUi == const $CopyWithPlaceholder() ||
showContainerUi == null
? _value.showContainerUi
// ignore: cast_nullable_to_non_nullable
: showContainerUi as bool,
showIsolatedTabUi:
showIsolatedTabUi == const $CopyWithPlaceholder() ||
showIsolatedTabUi == null
? _value.showIsolatedTabUi
// ignore: cast_nullable_to_non_nullable
: showIsolatedTabUi as bool,
storedDefaultCreateTabType:
storedDefaultCreateTabType == const $CopyWithPlaceholder() ||
storedDefaultCreateTabType == null
? _value.storedDefaultCreateTabType
// ignore: cast_nullable_to_non_nullable
: storedDefaultCreateTabType as TabType,
newTabPosition:
newTabPosition == const $CopyWithPlaceholder() ||
newTabPosition == null
? _value.newTabPosition
// ignore: cast_nullable_to_non_nullable
: newTabPosition as NewTabPosition,
tabIntentOpenSetting:
tabIntentOpenSetting == const $CopyWithPlaceholder() ||
tabIntentOpenSetting == null
? _value.tabIntentOpenSetting
// ignore: cast_nullable_to_non_nullable
: tabIntentOpenSetting as TabIntentOpenSetting,
autoHideTabBar:
autoHideTabBar == const $CopyWithPlaceholder() ||
autoHideTabBar == null
? _value.autoHideTabBar
// ignore: cast_nullable_to_non_nullable
: autoHideTabBar as bool,
tabBarSwipeAction:
tabBarSwipeAction == const $CopyWithPlaceholder() ||
tabBarSwipeAction == null
? _value.tabBarSwipeAction
// ignore: cast_nullable_to_non_nullable
: tabBarSwipeAction as TabBarSwipeAction,
historyAutoCleanInterval:
historyAutoCleanInterval == const $CopyWithPlaceholder() ||
historyAutoCleanInterval == null
? _value.historyAutoCleanInterval
// ignore: cast_nullable_to_non_nullable
: historyAutoCleanInterval as Duration,
tabViewBottomSheet:
tabViewBottomSheet == const $CopyWithPlaceholder() ||
tabViewBottomSheet == null
? _value.tabViewBottomSheet
// ignore: cast_nullable_to_non_nullable
: tabViewBottomSheet as bool,
tabBarShowContextualBar:
tabBarShowContextualBar == const $CopyWithPlaceholder() ||
tabBarShowContextualBar == null
? _value.tabBarShowContextualBar
// ignore: cast_nullable_to_non_nullable
: tabBarShowContextualBar as bool,
tabBarShowQuickTabSwitcherBar:
tabBarShowQuickTabSwitcherBar == const $CopyWithPlaceholder() ||
tabBarShowQuickTabSwitcherBar == null
? _value.tabBarShowQuickTabSwitcherBar
// ignore: cast_nullable_to_non_nullable
: tabBarShowQuickTabSwitcherBar as bool,
tabBarPosition:
tabBarPosition == const $CopyWithPlaceholder() ||
tabBarPosition == null
? _value.tabBarPosition
// ignore: cast_nullable_to_non_nullable
: tabBarPosition as TabBarPosition,
tabBarLayout:
tabBarLayout == const $CopyWithPlaceholder() || tabBarLayout == null
? _value.tabBarLayout
// ignore: cast_nullable_to_non_nullable
: tabBarLayout as TabBarLayout,
quickTabSwitcherMode:
quickTabSwitcherMode == const $CopyWithPlaceholder() ||
quickTabSwitcherMode == null
? _value.quickTabSwitcherMode
// ignore: cast_nullable_to_non_nullable
: quickTabSwitcherMode as QuickTabSwitcherMode,
pullToRefreshEnabled:
pullToRefreshEnabled == const $CopyWithPlaceholder() ||
pullToRefreshEnabled == null
? _value.pullToRefreshEnabled
// ignore: cast_nullable_to_non_nullable
: pullToRefreshEnabled as bool,
useExternalDownloadManager:
useExternalDownloadManager == const $CopyWithPlaceholder() ||
useExternalDownloadManager == null
? _value.useExternalDownloadManager
// ignore: cast_nullable_to_non_nullable
: useExternalDownloadManager as bool,
doubleBackCloseTab:
doubleBackCloseTab == const $CopyWithPlaceholder() ||
doubleBackCloseTab == null
? _value.doubleBackCloseTab
// ignore: cast_nullable_to_non_nullable
: doubleBackCloseTab as bool,
unassignedTabsAutoCleanInterval:
unassignedTabsAutoCleanInterval == const $CopyWithPlaceholder() ||
unassignedTabsAutoCleanInterval == null
? _value.unassignedTabsAutoCleanInterval
// ignore: cast_nullable_to_non_nullable
: unassignedTabsAutoCleanInterval as Duration,
maxSearchHistoryEntries:
maxSearchHistoryEntries == const $CopyWithPlaceholder() ||
maxSearchHistoryEntries == null
? _value.maxSearchHistoryEntries
// ignore: cast_nullable_to_non_nullable
: maxSearchHistoryEntries as int,
allowClipboardAccess:
allowClipboardAccess == const $CopyWithPlaceholder() ||
allowClipboardAccess == null
? _value.allowClipboardAccess
// ignore: cast_nullable_to_non_nullable
: allowClipboardAccess as bool,
tabListShowFavicons:
tabListShowFavicons == const $CopyWithPlaceholder() ||
tabListShowFavicons == null
? _value.tabListShowFavicons
// ignore: cast_nullable_to_non_nullable
: tabListShowFavicons as bool,
quickTabSwitcherShowTitles:
quickTabSwitcherShowTitles == const $CopyWithPlaceholder() ||
quickTabSwitcherShowTitles == null
? _value.quickTabSwitcherShowTitles
// ignore: cast_nullable_to_non_nullable
: quickTabSwitcherShowTitles as bool,
quickTabSwitcherShowHistorySuggestions:
quickTabSwitcherShowHistorySuggestions ==
const $CopyWithPlaceholder() ||
quickTabSwitcherShowHistorySuggestions == null
? _value.quickTabSwitcherShowHistorySuggestions
// ignore: cast_nullable_to_non_nullable
: quickTabSwitcherShowHistorySuggestions as bool,
syncServerOverride:
syncServerOverride == const $CopyWithPlaceholder() ||
syncServerOverride == null
? _value.syncServerOverride
// ignore: cast_nullable_to_non_nullable
: syncServerOverride as String,
syncTokenServerOverride:
syncTokenServerOverride == const $CopyWithPlaceholder() ||
syncTokenServerOverride == null
? _value.syncTokenServerOverride
// ignore: cast_nullable_to_non_nullable
: syncTokenServerOverride as String,
urlCleanerEnabled:
urlCleanerEnabled == const $CopyWithPlaceholder() ||
urlCleanerEnabled == null
? _value.urlCleanerEnabled
// ignore: cast_nullable_to_non_nullable
: urlCleanerEnabled as bool,
urlCleanerAutoApply:
urlCleanerAutoApply == const $CopyWithPlaceholder() ||
urlCleanerAutoApply == null
? _value.urlCleanerAutoApply
// ignore: cast_nullable_to_non_nullable
: urlCleanerAutoApply as bool,
urlCleanerAllowReferralMarketing:
urlCleanerAllowReferralMarketing == const $CopyWithPlaceholder() ||
urlCleanerAllowReferralMarketing == null
? _value.urlCleanerAllowReferralMarketing
// ignore: cast_nullable_to_non_nullable
: urlCleanerAllowReferralMarketing as bool,
urlCleanerCatalogUrl:
urlCleanerCatalogUrl == const $CopyWithPlaceholder() ||
urlCleanerCatalogUrl == null
? _value.urlCleanerCatalogUrl
// ignore: cast_nullable_to_non_nullable
: urlCleanerCatalogUrl as String,
urlCleanerHashUrl:
urlCleanerHashUrl == const $CopyWithPlaceholder() ||
urlCleanerHashUrl == null
? _value.urlCleanerHashUrl
// ignore: cast_nullable_to_non_nullable
: urlCleanerHashUrl as String,
urlCleanerAutoUpdate:
urlCleanerAutoUpdate == const $CopyWithPlaceholder() ||
urlCleanerAutoUpdate == null
? _value.urlCleanerAutoUpdate
// ignore: cast_nullable_to_non_nullable
: urlCleanerAutoUpdate as bool,
urlCleanerLastCheckEpochMs:
urlCleanerLastCheckEpochMs == const $CopyWithPlaceholder()
? _value.urlCleanerLastCheckEpochMs
// ignore: cast_nullable_to_non_nullable
: urlCleanerLastCheckEpochMs as int?,
urlCleanerLastUpdateWasAuto:
urlCleanerLastUpdateWasAuto == const $CopyWithPlaceholder() ||
urlCleanerLastUpdateWasAuto == null
? _value.urlCleanerLastUpdateWasAuto
// ignore: cast_nullable_to_non_nullable
: urlCleanerLastUpdateWasAuto as bool,
smallWebTabType:
smallWebTabType == const $CopyWithPlaceholder() ||
smallWebTabType == null
? _value.smallWebTabType
// ignore: cast_nullable_to_non_nullable
: smallWebTabType as TabType,
tabBarLongPressUrlCopy:
tabBarLongPressUrlCopy == const $CopyWithPlaceholder() ||
tabBarLongPressUrlCopy == null
? _value.tabBarLongPressUrlCopy
// ignore: cast_nullable_to_non_nullable
: tabBarLongPressUrlCopy as bool,
unshortenerEnabled:
unshortenerEnabled == const $CopyWithPlaceholder() ||
unshortenerEnabled == null
? _value.unshortenerEnabled
// ignore: cast_nullable_to_non_nullable
: unshortenerEnabled as bool,
unshortenerToken:
unshortenerToken == const $CopyWithPlaceholder() ||
unshortenerToken == null
? _value.unshortenerToken
// ignore: cast_nullable_to_non_nullable
: unshortenerToken as String,
allowNonManifestPwaInstall:
allowNonManifestPwaInstall == const $CopyWithPlaceholder() ||
allowNonManifestPwaInstall == null
? _value.allowNonManifestPwaInstall
// ignore: cast_nullable_to_non_nullable
: allowNonManifestPwaInstall as bool,
);
}
}
extension $GeneralSettingsCopyWith on GeneralSettings {
/// Returns a callable class used to build a new instance with modified fields.
/// Example: `instanceOfGeneralSettings.copyWith(...)` or `instanceOfGeneralSettings.copyWith.fieldName(...)`.
// ignore: library_private_types_in_public_api
_$GeneralSettingsCWProxy get copyWith => _$GeneralSettingsCWProxyImpl(this);
}
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
GeneralSettings _$GeneralSettingsFromJson(
Map<String, dynamic> json,
) => GeneralSettings.withDefaults(
themeMode: $enumDecodeNullable(_$ThemeModeEnumMap, json['themeMode']),
uiScaleFactor: (json['uiScaleFactor'] as num?)?.toDouble(),
disableAnimations: json['disableAnimations'] as bool?,
showModalBarrier: json['showModalBarrier'] as bool?,
enableReadability: json['enableReadability'] as bool?,
enforceReadability: json['enforceReadability'] as bool?,
deleteBrowsingDataOnQuit: (json['deleteBrowsingDataOnQuit'] as List<dynamic>?)
?.map((e) => $enumDecode(_$DeleteBrowsingDataTypeEnumMap, e))
.toSet(),
defaultSearchProvider: const BangKeyConverter().fromJson(
json['defaultSearchProvider'] as String?,
),
defaultSearchSuggestionsProvider: $enumDecodeNullable(
_$SearchSuggestionProvidersEnumMap,
json['defaultSearchSuggestionsProvider'],
),
createChildTabsOption: json['createChildTabsOption'] as bool?,
enableLocalAiFeatures: json['enableLocalAiFeatures'] as bool?,
showContainerUi: json['showContainerUi'] as bool?,
showIsolatedTabUi: json['showIsolatedTabUi'] as bool?,
storedDefaultCreateTabType: $enumDecodeNullable(
_$TabTypeEnumMap,
json['defaultCreateTabType'],
),
newTabPosition: $enumDecodeNullable(
_$NewTabPositionEnumMap,
json['newTabPosition'],
),
tabIntentOpenSetting: $enumDecodeNullable(
_$TabIntentOpenSettingEnumMap,
json['tabIntentOpenSetting'],
),
autoHideTabBar: json['autoHideTabBar'] as bool?,
tabBarSwipeAction: $enumDecodeNullable(
_$TabBarSwipeActionEnumMap,
json['tabBarSwipeAction'],
),
historyAutoCleanInterval: json['historyAutoCleanInterval'] == null
? null
: Duration(
microseconds: (json['historyAutoCleanInterval'] as num).toInt(),
),
tabViewBottomSheet: json['tabViewBottomSheet'] as bool?,
tabBarShowContextualBar: json['tabBarShowContextualBar'] as bool?,
tabBarShowQuickTabSwitcherBar: json['tabBarShowQuickTabSwitcherBar'] as bool?,
tabBarPosition: $enumDecodeNullable(
_$TabBarPositionEnumMap,
json['tabBarPosition'],
),
tabBarLayout: $enumDecodeNullable(
_$TabBarLayoutEnumMap,
json['tabBarLayout'],
),
quickTabSwitcherMode: $enumDecodeNullable(
_$QuickTabSwitcherModeEnumMap,
json['quickTabSwitcherMode'],
),
pullToRefreshEnabled: json['pullToRefreshEnabled'] as bool?,
useExternalDownloadManager: json['useExternalDownloadManager'] as bool?,
doubleBackCloseTab: json['doubleBackCloseTab'] as bool?,
unassignedTabsAutoCleanInterval:
json['unassignedTabsAutoCleanInterval'] == null
? null
: Duration(
microseconds: (json['unassignedTabsAutoCleanInterval'] as num)
.toInt(),
),
maxSearchHistoryEntries: (json['maxSearchHistoryEntries'] as num?)?.toInt(),
allowClipboardAccess: json['allowClipboardAccess'] as bool?,
tabListShowFavicons: json['tabListShowFavicons'] as bool?,
quickTabSwitcherShowTitles: json['quickTabSwitcherShowTitles'] as bool?,
quickTabSwitcherShowHistorySuggestions:
json['quickTabSwitcherShowHistorySuggestions'] as bool?,
syncServerOverride: json['syncServerOverride'] as String?,
syncTokenServerOverride: json['syncTokenServerOverride'] as String?,
urlCleanerEnabled: json['urlCleanerEnabled'] as bool?,
urlCleanerAutoApply: json['urlCleanerAutoApply'] as bool?,
urlCleanerAllowReferralMarketing:
json['urlCleanerAllowReferralMarketing'] as bool?,
urlCleanerCatalogUrl: json['urlCleanerCatalogUrl'] as String?,
urlCleanerHashUrl: json['urlCleanerHashUrl'] as String?,
urlCleanerAutoUpdate: json['urlCleanerAutoUpdate'] as bool?,
urlCleanerLastCheckEpochMs: (json['urlCleanerLastCheckEpochMs'] as num?)
?.toInt(),
urlCleanerLastUpdateWasAuto: json['urlCleanerLastUpdateWasAuto'] as bool?,
smallWebTabType: $enumDecodeNullable(
_$TabTypeEnumMap,
json['smallWebTabType'],
),
tabBarLongPressUrlCopy: json['tabBarLongPressUrlCopy'] as bool?,
unshortenerEnabled: json['unshortenerEnabled'] as bool?,
unshortenerToken: json['unshortenerToken'] as String?,
allowNonManifestPwaInstall: json['allowNonManifestPwaInstall'] as bool?,
);
Map<String, dynamic> _$GeneralSettingsToJson(
GeneralSettings instance,
) => <String, dynamic>{
'themeMode': _$ThemeModeEnumMap[instance.themeMode]!,
'uiScaleFactor': instance.uiScaleFactor,
'disableAnimations': instance.disableAnimations,
'showModalBarrier': instance.showModalBarrier,
'enableReadability': instance.enableReadability,
'enforceReadability': instance.enforceReadability,
'deleteBrowsingDataOnQuit': instance.deleteBrowsingDataOnQuit
?.map((e) => _$DeleteBrowsingDataTypeEnumMap[e]!)
.toList(),
'defaultSearchProvider': const BangKeyConverter().toJson(
instance.defaultSearchProvider,
),
'defaultSearchSuggestionsProvider':
_$SearchSuggestionProvidersEnumMap[instance
.defaultSearchSuggestionsProvider]!,
'createChildTabsOption': instance.createChildTabsOption,
'enableLocalAiFeatures': instance.enableLocalAiFeatures,
'showContainerUi': instance.showContainerUi,
'showIsolatedTabUi': instance.showIsolatedTabUi,
'defaultCreateTabType':
_$TabTypeEnumMap[instance.storedDefaultCreateTabType]!,
'newTabPosition': _$NewTabPositionEnumMap[instance.newTabPosition]!,
'tabIntentOpenSetting':
_$TabIntentOpenSettingEnumMap[instance.tabIntentOpenSetting]!,
'autoHideTabBar': instance.autoHideTabBar,
'tabBarSwipeAction': _$TabBarSwipeActionEnumMap[instance.tabBarSwipeAction]!,
'historyAutoCleanInterval': instance.historyAutoCleanInterval.inMicroseconds,
'tabViewBottomSheet': instance.tabViewBottomSheet,
'tabBarShowContextualBar': instance.tabBarShowContextualBar,
'tabBarShowQuickTabSwitcherBar': instance.tabBarShowQuickTabSwitcherBar,
'tabBarPosition': _$TabBarPositionEnumMap[instance.tabBarPosition]!,
'tabBarLayout': _$TabBarLayoutEnumMap[instance.tabBarLayout]!,
'quickTabSwitcherMode':
_$QuickTabSwitcherModeEnumMap[instance.quickTabSwitcherMode]!,
'pullToRefreshEnabled': instance.pullToRefreshEnabled,
'useExternalDownloadManager': instance.useExternalDownloadManager,
'doubleBackCloseTab': instance.doubleBackCloseTab,
'unassignedTabsAutoCleanInterval':
instance.unassignedTabsAutoCleanInterval.inMicroseconds,
'maxSearchHistoryEntries': instance.maxSearchHistoryEntries,
'allowClipboardAccess': instance.allowClipboardAccess,
'tabListShowFavicons': instance.tabListShowFavicons,
'quickTabSwitcherShowTitles': instance.quickTabSwitcherShowTitles,
'quickTabSwitcherShowHistorySuggestions':
instance.quickTabSwitcherShowHistorySuggestions,
'syncServerOverride': instance.syncServerOverride,
'syncTokenServerOverride': instance.syncTokenServerOverride,
'urlCleanerEnabled': instance.urlCleanerEnabled,
'urlCleanerAutoApply': instance.urlCleanerAutoApply,
'urlCleanerAllowReferralMarketing': instance.urlCleanerAllowReferralMarketing,
'urlCleanerCatalogUrl': instance.urlCleanerCatalogUrl,
'urlCleanerHashUrl': instance.urlCleanerHashUrl,
'urlCleanerAutoUpdate': instance.urlCleanerAutoUpdate,
'urlCleanerLastCheckEpochMs': instance.urlCleanerLastCheckEpochMs,
'urlCleanerLastUpdateWasAuto': instance.urlCleanerLastUpdateWasAuto,
'smallWebTabType': _$TabTypeEnumMap[instance.smallWebTabType]!,
'tabBarLongPressUrlCopy': instance.tabBarLongPressUrlCopy,
'unshortenerEnabled': instance.unshortenerEnabled,
'unshortenerToken': instance.unshortenerToken,
'allowNonManifestPwaInstall': instance.allowNonManifestPwaInstall,
};
const _$ThemeModeEnumMap = {
ThemeMode.system: 'system',
ThemeMode.light: 'light',
ThemeMode.dark: 'dark',
};
const _$DeleteBrowsingDataTypeEnumMap = {
DeleteBrowsingDataType.tabs: 'tabs',
DeleteBrowsingDataType.history: 'history',
DeleteBrowsingDataType.cookies: 'cookies',
DeleteBrowsingDataType.cache: 'cache',
DeleteBrowsingDataType.permissions: 'permissions',
DeleteBrowsingDataType.downloads: 'downloads',
};
const _$SearchSuggestionProvidersEnumMap = {
SearchSuggestionProviders.none: 'none',
SearchSuggestionProviders.brave: 'brave',
SearchSuggestionProviders.ddg: 'ddg',
SearchSuggestionProviders.kagi: 'kagi',
SearchSuggestionProviders.qwant: 'qwant',
};
const _$TabTypeEnumMap = {
TabType.regular: 'regular',
TabType.private: 'private',
TabType.child: 'child',
TabType.isolated: 'isolated',
};
const _$NewTabPositionEnumMap = {
NewTabPosition.first: 'first',
NewTabPosition.end: 'end',
};
const _$TabIntentOpenSettingEnumMap = {
TabIntentOpenSetting.regular: 'regular',
TabIntentOpenSetting.private: 'private',
TabIntentOpenSetting.ask: 'ask',
};
const _$TabBarSwipeActionEnumMap = {
TabBarSwipeAction.switchLastOpened: 'switchLastOpened',
TabBarSwipeAction.navigateOrderedTabs: 'navigateOrderedTabs',
};
const _$TabBarPositionEnumMap = {
TabBarPosition.top: 'top',
TabBarPosition.bottom: 'bottom',
};
const _$TabBarLayoutEnumMap = {
TabBarLayout.withTitle: 'withTitle',
TabBarLayout.compact: 'compact',
};
const _$QuickTabSwitcherModeEnumMap = {
QuickTabSwitcherMode.lastUsedTabs: 'lastUsedTabs',
QuickTabSwitcherMode.containerTabs: 'containerTabs',
};
@@ -0,0 +1,46 @@
/*
* Copyright (c) 2024-2026 Fabian Freund.
*
* This file is part of WebLibre
* (see https://weblibre.eu).
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import 'package:fast_equatable/fast_equatable.dart';
import 'package:json_annotation/json_annotation.dart';
part 'rfp_target.g.dart';
@JsonSerializable()
class RFPTarget with FastEquatable {
final String name;
final int id;
final String? description;
final List<String> keywords;
RFPTarget({
required this.name,
required this.id,
this.description,
required this.keywords,
});
factory RFPTarget.fromJson(Map<String, dynamic> json) =>
_$RFPTargetFromJson(json);
Map<String, dynamic> toJson() => _$RFPTargetToJson(this);
@override
List<Object?> get hashParameters => [name, id, description, keywords];
}
@@ -0,0 +1,23 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'rfp_target.dart';
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
RFPTarget _$RFPTargetFromJson(Map<String, dynamic> json) => RFPTarget(
name: json['name'] as String,
id: (json['id'] as num).toInt(),
description: json['description'] as String?,
keywords: (json['keywords'] as List<dynamic>)
.map((e) => e as String)
.toList(),
);
Map<String, dynamic> _$RFPTargetToJson(RFPTarget instance) => <String, dynamic>{
'name': instance.name,
'id': instance.id,
'description': instance.description,
'keywords': instance.keywords,
};
@@ -0,0 +1,81 @@
/*
* Copyright (c) 2024-2026 Fabian Freund.
*
* This file is part of WebLibre
* (see https://weblibre.eu).
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import 'package:copy_with_extension/copy_with_extension.dart';
import 'package:fast_equatable/fast_equatable.dart';
import 'package:json_annotation/json_annotation.dart';
part 'tor_settings.g.dart';
enum TorConnectionConfig { auto, direct, obfs4, snowflake }
enum TorRegularTabProxyMode { container, all }
@CopyWith()
@JsonSerializable(includeIfNull: true, constructor: 'withDefaults')
class TorSettings with FastEquatable {
final TorRegularTabProxyMode proxyRegularTabsMode;
final bool proxyPrivateTabsTor;
final TorConnectionConfig config;
final bool requireBridge;
final bool fetchRemoteBridges;
final String? entryNodeCountry;
final String? exitNodeCountry;
TorSettings({
required this.proxyRegularTabsMode,
required this.proxyPrivateTabsTor,
required this.config,
required this.requireBridge,
required this.fetchRemoteBridges,
required this.entryNodeCountry,
required this.exitNodeCountry,
});
TorSettings.withDefaults({
TorRegularTabProxyMode? proxyRegularTabsMode,
bool? proxyPrivateTabsTor,
TorConnectionConfig? config,
bool? requireBridge,
bool? fetchRemoteBridges,
this.entryNodeCountry,
this.exitNodeCountry,
}) : proxyRegularTabsMode =
proxyRegularTabsMode ?? TorRegularTabProxyMode.container,
proxyPrivateTabsTor = proxyPrivateTabsTor ?? false,
config = config ?? TorConnectionConfig.auto,
requireBridge = requireBridge ?? false,
fetchRemoteBridges = fetchRemoteBridges ?? true;
factory TorSettings.fromJson(Map<String, dynamic> json) =>
_$TorSettingsFromJson(json);
Map<String, dynamic> toJson() => _$TorSettingsToJson(this);
@override
List<Object?> get hashParameters => [
proxyRegularTabsMode,
proxyPrivateTabsTor,
config,
requireBridge,
fetchRemoteBridges,
entryNodeCountry,
exitNodeCountry,
];
}
@@ -0,0 +1,181 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'tor_settings.dart';
// **************************************************************************
// CopyWithGenerator
// **************************************************************************
abstract class _$TorSettingsCWProxy {
TorSettings proxyRegularTabsMode(TorRegularTabProxyMode proxyRegularTabsMode);
TorSettings proxyPrivateTabsTor(bool proxyPrivateTabsTor);
TorSettings config(TorConnectionConfig config);
TorSettings requireBridge(bool requireBridge);
TorSettings fetchRemoteBridges(bool fetchRemoteBridges);
TorSettings entryNodeCountry(String? entryNodeCountry);
TorSettings exitNodeCountry(String? exitNodeCountry);
/// Creates a new instance with the provided field values.
/// Passing `null` to a nullable field nullifies it, while `null` for a non-nullable field is ignored. To update a single field use `TorSettings(...).copyWith.fieldName(value)`.
///
/// Example:
/// ```dart
/// TorSettings(...).copyWith(id: 12, name: "My name")
/// ```
TorSettings call({
TorRegularTabProxyMode proxyRegularTabsMode,
bool proxyPrivateTabsTor,
TorConnectionConfig config,
bool requireBridge,
bool fetchRemoteBridges,
String? entryNodeCountry,
String? exitNodeCountry,
});
}
/// Callable proxy for `copyWith` functionality.
/// Use as `instanceOfTorSettings.copyWith(...)` or call `instanceOfTorSettings.copyWith.fieldName(value)` for a single field.
class _$TorSettingsCWProxyImpl implements _$TorSettingsCWProxy {
const _$TorSettingsCWProxyImpl(this._value);
final TorSettings _value;
@override
TorSettings proxyRegularTabsMode(
TorRegularTabProxyMode proxyRegularTabsMode,
) => call(proxyRegularTabsMode: proxyRegularTabsMode);
@override
TorSettings proxyPrivateTabsTor(bool proxyPrivateTabsTor) =>
call(proxyPrivateTabsTor: proxyPrivateTabsTor);
@override
TorSettings config(TorConnectionConfig config) => call(config: config);
@override
TorSettings requireBridge(bool requireBridge) =>
call(requireBridge: requireBridge);
@override
TorSettings fetchRemoteBridges(bool fetchRemoteBridges) =>
call(fetchRemoteBridges: fetchRemoteBridges);
@override
TorSettings entryNodeCountry(String? entryNodeCountry) =>
call(entryNodeCountry: entryNodeCountry);
@override
TorSettings exitNodeCountry(String? exitNodeCountry) =>
call(exitNodeCountry: exitNodeCountry);
@override
/// Creates a new instance with the provided field values.
/// Passing `null` to a nullable field nullifies it, while `null` for a non-nullable field is ignored. To update a single field use `TorSettings(...).copyWith.fieldName(value)`.
///
/// Example:
/// ```dart
/// TorSettings(...).copyWith(id: 12, name: "My name")
/// ```
TorSettings call({
Object? proxyRegularTabsMode = const $CopyWithPlaceholder(),
Object? proxyPrivateTabsTor = const $CopyWithPlaceholder(),
Object? config = const $CopyWithPlaceholder(),
Object? requireBridge = const $CopyWithPlaceholder(),
Object? fetchRemoteBridges = const $CopyWithPlaceholder(),
Object? entryNodeCountry = const $CopyWithPlaceholder(),
Object? exitNodeCountry = const $CopyWithPlaceholder(),
}) {
return TorSettings(
proxyRegularTabsMode:
proxyRegularTabsMode == const $CopyWithPlaceholder() ||
proxyRegularTabsMode == null
? _value.proxyRegularTabsMode
// ignore: cast_nullable_to_non_nullable
: proxyRegularTabsMode as TorRegularTabProxyMode,
proxyPrivateTabsTor:
proxyPrivateTabsTor == const $CopyWithPlaceholder() ||
proxyPrivateTabsTor == null
? _value.proxyPrivateTabsTor
// ignore: cast_nullable_to_non_nullable
: proxyPrivateTabsTor as bool,
config: config == const $CopyWithPlaceholder() || config == null
? _value.config
// ignore: cast_nullable_to_non_nullable
: config as TorConnectionConfig,
requireBridge:
requireBridge == const $CopyWithPlaceholder() || requireBridge == null
? _value.requireBridge
// ignore: cast_nullable_to_non_nullable
: requireBridge as bool,
fetchRemoteBridges:
fetchRemoteBridges == const $CopyWithPlaceholder() ||
fetchRemoteBridges == null
? _value.fetchRemoteBridges
// ignore: cast_nullable_to_non_nullable
: fetchRemoteBridges as bool,
entryNodeCountry: entryNodeCountry == const $CopyWithPlaceholder()
? _value.entryNodeCountry
// ignore: cast_nullable_to_non_nullable
: entryNodeCountry as String?,
exitNodeCountry: exitNodeCountry == const $CopyWithPlaceholder()
? _value.exitNodeCountry
// ignore: cast_nullable_to_non_nullable
: exitNodeCountry as String?,
);
}
}
extension $TorSettingsCopyWith on TorSettings {
/// Returns a callable class used to build a new instance with modified fields.
/// Example: `instanceOfTorSettings.copyWith(...)` or `instanceOfTorSettings.copyWith.fieldName(...)`.
// ignore: library_private_types_in_public_api
_$TorSettingsCWProxy get copyWith => _$TorSettingsCWProxyImpl(this);
}
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
TorSettings _$TorSettingsFromJson(Map<String, dynamic> json) =>
TorSettings.withDefaults(
proxyRegularTabsMode: $enumDecodeNullable(
_$TorRegularTabProxyModeEnumMap,
json['proxyRegularTabsMode'],
),
proxyPrivateTabsTor: json['proxyPrivateTabsTor'] as bool?,
config: $enumDecodeNullable(_$TorConnectionConfigEnumMap, json['config']),
requireBridge: json['requireBridge'] as bool?,
fetchRemoteBridges: json['fetchRemoteBridges'] as bool?,
entryNodeCountry: json['entryNodeCountry'] as String?,
exitNodeCountry: json['exitNodeCountry'] as String?,
);
Map<String, dynamic> _$TorSettingsToJson(TorSettings instance) =>
<String, dynamic>{
'proxyRegularTabsMode':
_$TorRegularTabProxyModeEnumMap[instance.proxyRegularTabsMode]!,
'proxyPrivateTabsTor': instance.proxyPrivateTabsTor,
'config': _$TorConnectionConfigEnumMap[instance.config]!,
'requireBridge': instance.requireBridge,
'fetchRemoteBridges': instance.fetchRemoteBridges,
'entryNodeCountry': instance.entryNodeCountry,
'exitNodeCountry': instance.exitNodeCountry,
};
const _$TorRegularTabProxyModeEnumMap = {
TorRegularTabProxyMode.container: 'container',
TorRegularTabProxyMode.all: 'all',
};
const _$TorConnectionConfigEnumMap = {
TorConnectionConfig.auto: 'auto',
TorConnectionConfig.direct: 'direct',
TorConnectionConfig.obfs4: 'obfs4',
TorConnectionConfig.snowflake: 'snowflake',
};
@@ -0,0 +1,69 @@
/*
* Copyright (c) 2024-2026 Fabian Freund.
*
* This file is part of WebLibre
* (see https://weblibre.eu).
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import 'dart:io';
import 'package:drift/drift.dart';
import 'package:drift/native.dart';
import 'package:path/path.dart' as p;
import 'package:riverpod/experimental/persist.dart';
import 'package:riverpod_annotation/riverpod_annotation.dart';
import 'package:sqlite3_flutter_libs/sqlite3_flutter_libs.dart';
import 'package:weblibre/core/database_registry.dart';
import 'package:weblibre/core/filesystem.dart';
import 'package:weblibre/data/database/functions/lexo_rank_functions.dart';
import 'package:weblibre/features/user/data/database/database.dart';
import 'package:weblibre/features/user/data/database/riverpod_storage.dart';
part 'providers.g.dart';
@Riverpod(keepAlive: true)
UserDatabase userDatabase(Ref ref) {
final db = UserDatabase(
LazyDatabase(() async {
final file = File(p.join(filesystem.profileDatabasesDir.path, 'user.db'));
// Also work around limitations on old Android versions
if (Platform.isAndroid) {
await applyWorkaroundToOpenSqlite3OnOldAndroidVersions();
}
return NativeDatabase.createInBackground(
file,
setup: (database) {
registerLexorankFunctions(database);
},
);
}),
);
DatabaseRegistry.instance.register('user', db);
ref.onDispose(() async {
await db.close();
});
return db;
}
@Riverpod(keepAlive: true)
Storage<String, String> riverpodDatabaseStorage(Ref ref) {
final db = ref.watch(userDatabaseProvider);
return RiverpodStorage(db);
}
@@ -0,0 +1,99 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'providers.dart';
// **************************************************************************
// RiverpodGenerator
// **************************************************************************
// GENERATED CODE - DO NOT MODIFY BY HAND
// ignore_for_file: type=lint, type=warning
@ProviderFor(userDatabase)
final userDatabaseProvider = UserDatabaseProvider._();
final class UserDatabaseProvider
extends $FunctionalProvider<UserDatabase, UserDatabase, UserDatabase>
with $Provider<UserDatabase> {
UserDatabaseProvider._()
: super(
from: null,
argument: null,
retry: null,
name: r'userDatabaseProvider',
isAutoDispose: false,
dependencies: null,
$allTransitiveDependencies: null,
);
@override
String debugGetCreateSourceHash() => _$userDatabaseHash();
@$internal
@override
$ProviderElement<UserDatabase> $createElement($ProviderPointer pointer) =>
$ProviderElement(pointer);
@override
UserDatabase create(Ref ref) {
return userDatabase(ref);
}
/// {@macro riverpod.override_with_value}
Override overrideWithValue(UserDatabase value) {
return $ProviderOverride(
origin: this,
providerOverride: $SyncValueProvider<UserDatabase>(value),
);
}
}
String _$userDatabaseHash() => r'097505438c098252a322e6d0e49f885d67ebe898';
@ProviderFor(riverpodDatabaseStorage)
final riverpodDatabaseStorageProvider = RiverpodDatabaseStorageProvider._();
final class RiverpodDatabaseStorageProvider
extends
$FunctionalProvider<
Storage<String, String>,
Storage<String, String>,
Storage<String, String>
>
with $Provider<Storage<String, String>> {
RiverpodDatabaseStorageProvider._()
: super(
from: null,
argument: null,
retry: null,
name: r'riverpodDatabaseStorageProvider',
isAutoDispose: false,
dependencies: null,
$allTransitiveDependencies: null,
);
@override
String debugGetCreateSourceHash() => _$riverpodDatabaseStorageHash();
@$internal
@override
$ProviderElement<Storage<String, String>> $createElement(
$ProviderPointer pointer,
) => $ProviderElement(pointer);
@override
Storage<String, String> create(Ref ref) {
return riverpodDatabaseStorage(ref);
}
/// {@macro riverpod.override_with_value}
Override overrideWithValue(Storage<String, String> value) {
return $ProviderOverride(
origin: this,
providerOverride: $SyncValueProvider<Storage<String, String>>(value),
);
}
}
String _$riverpodDatabaseStorageHash() =>
r'e60613538dcb1f9cf48d87c029d8493335a5c3e8';