From 791701710ebea01ef1de9ebcc44c412a1e4d3d68 Mon Sep 17 00:00:00 2001 From: ZanderCowboy Date: Sat, 5 Oct 2024 22:58:12 +0200 Subject: [PATCH 01/25] widget tests --- .../lib/presentation/drawer/home_drawer.dart | 1 + .../shared/widgets/add_widgets/tab.dart | 3 +- .../shared/widgets/modals/delete_modal.dart | 1 + .../extensions/extensions_getters_test.dart | 39 +++++ .../presentation/drawer/home_drawer_test.dart | 9 + .../widgets/add_widgets/entry_test.dart | 91 ++++++++++ .../shared/widgets/add_widgets/tab_test.dart | 105 +++++++++++ .../widgets/modals/delete_modal_test.dart | 165 ++++++++++++++++++ 8 files changed, 413 insertions(+), 1 deletion(-) create mode 100644 apps/multichoice/test/app/extensions/extensions_getters_test.dart create mode 100644 apps/multichoice/test/presentation/drawer/home_drawer_test.dart create mode 100644 apps/multichoice/test/presentation/shared/widgets/add_widgets/entry_test.dart create mode 100644 apps/multichoice/test/presentation/shared/widgets/add_widgets/tab_test.dart create mode 100644 apps/multichoice/test/presentation/shared/widgets/modals/delete_modal_test.dart diff --git a/apps/multichoice/lib/presentation/drawer/home_drawer.dart b/apps/multichoice/lib/presentation/drawer/home_drawer.dart index 312afa76..62f8e3df 100644 --- a/apps/multichoice/lib/presentation/drawer/home_drawer.dart +++ b/apps/multichoice/lib/presentation/drawer/home_drawer.dart @@ -61,6 +61,7 @@ class HomeDrawer extends StatelessWidget { ListTile( title: const Text('Horizontal/Vertical Layout'), trailing: Switch( + key: const Key('layoutSwitch'), value: context.watch().appLayout, onChanged: (value) { context.read().appLayout = value; diff --git a/apps/multichoice/lib/presentation/shared/widgets/add_widgets/tab.dart b/apps/multichoice/lib/presentation/shared/widgets/add_widgets/tab.dart index 5ed99de2..ce3d1e16 100644 --- a/apps/multichoice/lib/presentation/shared/widgets/add_widgets/tab.dart +++ b/apps/multichoice/lib/presentation/shared/widgets/add_widgets/tab.dart @@ -17,7 +17,7 @@ class AddTabCard extends StatelessWidget { @override Widget build(BuildContext context) { return _BaseCard( - semanticLabel: semanticLabel ?? '', + semanticLabel: semanticLabel ?? 'AddTab', elevation: 5, color: color ?? context.theme.appColors.primaryLight, shape: RoundedRectangleBorder( @@ -26,6 +26,7 @@ class AddTabCard extends StatelessWidget { child: Padding( padding: allPadding6, child: SizedBox( + key: const Key('AddTabSizedBox'), width: width, child: IconButton( iconSize: 36, diff --git a/apps/multichoice/lib/presentation/shared/widgets/modals/delete_modal.dart b/apps/multichoice/lib/presentation/shared/widgets/modals/delete_modal.dart index 28c9e71f..d2f04743 100644 --- a/apps/multichoice/lib/presentation/shared/widgets/modals/delete_modal.dart +++ b/apps/multichoice/lib/presentation/shared/widgets/modals/delete_modal.dart @@ -13,6 +13,7 @@ void deleteModal({ CustomDialog.show( context: context, title: RichText( + key: const Key('DeleteModalTitle'), text: TextSpan( text: 'Delete ', style: DefaultTextStyle.of(context).style.copyWith( diff --git a/apps/multichoice/test/app/extensions/extensions_getters_test.dart b/apps/multichoice/test/app/extensions/extensions_getters_test.dart new file mode 100644 index 00000000..c38c920a --- /dev/null +++ b/apps/multichoice/test/app/extensions/extensions_getters_test.dart @@ -0,0 +1,39 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:multichoice/app/extensions/extension_getters.dart'; + +void main() { + testWidgets('ThemeGetter extension returns the correct ThemeData', + (WidgetTester tester) async { + // Define a widget that uses the extension + final testWidget = MaterialApp( + theme: ThemeData.light(), + home: Builder( + builder: (BuildContext context) { + // Retrieve the ThemeData using the extension + final themeData = context.theme; + + // Create a simple widget to verify the theme + return Scaffold( + appBar: AppBar( + title: Text( + 'Theme Test', + style: TextStyle(color: themeData.primaryColor), + ), + ), + ); + }, + ), + ); + + // Pump the widget into the widget tree + await tester.pumpWidget(testWidget); + + // Retrieve the current ThemeData + final BuildContext context = tester.element(find.byType(Scaffold)); + final currentTheme = Theme.of(context); + + // Verify that the extension returns the correct ThemeData + expect(currentTheme, equals(context.theme)); + }); +} diff --git a/apps/multichoice/test/presentation/drawer/home_drawer_test.dart b/apps/multichoice/test/presentation/drawer/home_drawer_test.dart new file mode 100644 index 00000000..9f88353d --- /dev/null +++ b/apps/multichoice/test/presentation/drawer/home_drawer_test.dart @@ -0,0 +1,9 @@ +import 'package:flutter_test/flutter_test.dart'; + +void main() { + group('test', () { + test('test', () { + expect(1, 1); + }); + }); +} diff --git a/apps/multichoice/test/presentation/shared/widgets/add_widgets/entry_test.dart b/apps/multichoice/test/presentation/shared/widgets/add_widgets/entry_test.dart new file mode 100644 index 00000000..0790611d --- /dev/null +++ b/apps/multichoice/test/presentation/shared/widgets/add_widgets/entry_test.dart @@ -0,0 +1,91 @@ +// import 'package:flutter/material.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:multichoice/presentation/shared/widgets/add_widgets/_base.dart'; + +// Assuming AddEntryCard and _BaseCard are part of your project imports. + +void main() { + testWidgets('AddEntryCard renders correctly and responds to tap', + (WidgetTester tester) async { + // Test values + const EdgeInsetsGeometry testPadding = EdgeInsets.all(10); + const EdgeInsetsGeometry testMargin = EdgeInsets.all(5); + const Color testColor = Colors.blue; + const testSemanticLabel = 'Add Entry'; + + // Track if the button was pressed + var pressed = false; + + // Build the widget tree + await tester.pumpWidget( + MaterialApp( + home: Scaffold( + body: AddEntryCard( + onPressed: () { + pressed = true; + }, + padding: testPadding, + margin: testMargin, + color: testColor, + semanticLabel: testSemanticLabel, + ), + ), + ), + ); + + // Check that the Icon widget is displayed + expect(find.byIcon(Icons.add_outlined), findsOneWidget); + + // Check that the semantic label is applied correctly + expect(find.bySemanticsLabel(testSemanticLabel), findsOneWidget); + + // Verify the padding and margin + final cardWidget = tester.widget(find.byType(Card)); + expect(cardWidget.margin, equals(testMargin)); // Verify margin + + // Verify the color + expect(cardWidget.color, equals(testColor)); + + // Simulate a tap and check if onPressed was called + await tester.tap(find.byType(IconButton)); + await tester.pumpAndSettle(); // Let any animations complete + + // Ensure the onPressed callback was triggered + expect(pressed, isTrue); + }); + + testWidgets('AddEntryCard uses default values when not provided', + (WidgetTester tester) async { + // Track if the button was pressed + var pressed = false; + + // Build the widget tree with only required parameters + await tester.pumpWidget( + MaterialApp( + home: Scaffold( + body: AddEntryCard( + onPressed: () { + pressed = true; + }, + padding: + EdgeInsets.zero, // Custom padding to isolate the margin test + ), + ), + ), + ); + + // Verify default padding and margin + final cardWidget = tester.widget(find.byType(Card)); + expect( + cardWidget.margin, + equals(const EdgeInsets.all(4)), + ); // Default margin for AddEntryCard + + // Tap the button and check if the callback is triggered + await tester.tap(find.byType(IconButton)); + await tester.pumpAndSettle(); + + expect(pressed, isTrue); + }); +} diff --git a/apps/multichoice/test/presentation/shared/widgets/add_widgets/tab_test.dart b/apps/multichoice/test/presentation/shared/widgets/add_widgets/tab_test.dart new file mode 100644 index 00000000..68ccbe18 --- /dev/null +++ b/apps/multichoice/test/presentation/shared/widgets/add_widgets/tab_test.dart @@ -0,0 +1,105 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:multichoice/presentation/shared/widgets/add_widgets/_base.dart'; + +// Assuming AddTabCard is part of your project imports. + +void main() { + testWidgets('AddTabCard renders correctly and responds to tap', + (WidgetTester tester) async { + // Test values + const testWidth = 100.0; + const Color testColor = Colors.blue; + const testSemanticLabel = 'Add Tab'; + + // Track if the button was pressed + var pressed = false; + + // Build the widget tree + await tester.pumpWidget( + MaterialApp( + home: Scaffold( + body: AddTabCard( + onPressed: () { + pressed = true; + }, + width: testWidth, + color: testColor, + semanticLabel: testSemanticLabel, + ), + ), + ), + ); + + // Ensure only one Icon widget is displayed + expect(find.byIcon(Icons.add_outlined), findsOneWidget); + + // Ensure only one widget with the semantic label is found + expect(find.bySemanticsLabel(testSemanticLabel), findsOneWidget); + + // Verify the Card widget color (since _BaseCard is private, we check the Card directly) + final cardWidget = tester.widget(find.byType(Card)); + expect(cardWidget.color, equals(testColor)); + + // debugDumpApp(); + // Verify the width of the SizedBox inside the AddTabCard + final sizedBox = tester.widget( + // find.descendant( + // of: find.byType(Padding), + // matching: find.byType(SizedBox), + // matchRoot: true, + // ), + find.byKey(const Key('AddTabSizedBox')), + ); + + expect(sizedBox.width, equals(testWidth)); + + // Simulate a tap and check if onPressed was called + await tester.tap(find.byType(IconButton)); + await tester.pumpAndSettle(); // Let any animations complete + + // Ensure the onPressed callback was triggered + expect(pressed, isTrue); + }); + + testWidgets('AddTabCard uses default values when not provided', + (WidgetTester tester) async { + // Track if the button was pressed + var pressed = false; + + // Build the widget tree with only required parameters + await tester.pumpWidget( + MaterialApp( + home: Scaffold( + body: AddTabCard( + onPressed: () { + pressed = true; + }, + ), + ), + ), + ); + + // Ensure only one widget with the default semantic label + expect( + find.bySemanticsLabel('AddTab'), + findsOneWidget, + ); // Default label is empty string + + // Verify the Card widget uses the default color + final cardWidget = tester.widget(find.byType(Card)); + expect(cardWidget.color, isNotNull); // Ensure a color is applied + + // Verify the width of the SizedBox inside the AddTabCard (default is null) + final sizedBox = tester.widget( + find.byKey(const Key('AddTabSizedBox')), + ); + expect(sizedBox.width, isNull); // Default width is null + + // Tap the button and check if the callback is triggered + await tester.tap(find.byType(IconButton)); + await tester.pumpAndSettle(); + + expect(pressed, isTrue); + }); +} diff --git a/apps/multichoice/test/presentation/shared/widgets/modals/delete_modal_test.dart b/apps/multichoice/test/presentation/shared/widgets/modals/delete_modal_test.dart new file mode 100644 index 00000000..54e8ec20 --- /dev/null +++ b/apps/multichoice/test/presentation/shared/widgets/modals/delete_modal_test.dart @@ -0,0 +1,165 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:multichoice/presentation/shared/widgets/modals/delete_modal.dart'; + +// Assuming deleteModal is part of your project imports. +// import 'path/to/delete_modal.dart'; + +void main() { + testWidgets('deleteModal displays correctly and handles actions', + (WidgetTester tester) async { + // Track if the onConfirm callback is triggered + var confirmPressed = false; + var cancelPressed = false; + + // Build a test widget tree that includes the deleteModal call + await tester.pumpWidget( + MaterialApp( + home: Scaffold( + body: Builder( + builder: (context) { + return ElevatedButton( + onPressed: () { + deleteModal( + context: context, + title: 'Item', + content: const Text( + 'Are you sure you want to delete this item?', + ), + onConfirm: () { + confirmPressed = true; + Navigator.of(context).pop(); + }, + onCancel: () { + cancelPressed = true; + Navigator.of(context).pop(); + }, + ); + }, + child: const Text('Open Modal'), + ); + }, + ), + ), + ), + ); + + // Open the modal by tapping the button + await tester.tap(find.text('Open Modal')); + await tester.pumpAndSettle(); // Wait for the dialog to appear + + // Verify that the AlertDialog is displayed + expect(find.byType(AlertDialog), findsOneWidget); + + // Use the key to directly find the RichText widget for the modal title + final richTextWidget = + tester.widget(find.byKey(const Key('DeleteModalTitle'))); + + // Extract the TextSpan from the RichText and verify the parts of the title + final textSpan = richTextWidget.text as TextSpan; + expect(textSpan.text, 'Delete '); + expect((textSpan.children![0] as TextSpan).text, 'Item'); + expect((textSpan.children![1] as TextSpan).text, '?'); + + // Verify the content of the modal + expect( + find.text('Are you sure you want to delete this item?'), + findsOneWidget, + ); + + // Verify the Cancel and Delete buttons are present + expect(find.text('Cancel'), findsOneWidget); + expect(find.text('Delete'), findsOneWidget); + + // Tap the Cancel button and verify that the onCancel callback is triggered + await tester.tap(find.text('Cancel')); + await tester.pumpAndSettle(); // Wait for the dialog to close + expect(cancelPressed, isTrue); + + // Reopen the modal for testing the Delete button + await tester.tap(find.text('Open Modal')); + await tester.pumpAndSettle(); + + // Tap the Delete button and verify that the onConfirm callback is triggered + await tester.tap(find.text('Delete')); + await tester.pumpAndSettle(); // Wait for the dialog to close + expect(confirmPressed, isTrue); + }); + + testWidgets('deleteModal displays correctly and handles actions', + (WidgetTester tester) async { + // Track if the onConfirm callback is triggered + var confirmPressed = false; + // ignore: unused_local_variable + const cancelPressed = false; + + // Build a test widget tree that includes the deleteModal call + await tester.pumpWidget( + MaterialApp( + home: Scaffold( + body: Builder( + builder: (context) { + return ElevatedButton( + onPressed: () { + deleteModal( + context: context, + title: 'Item', + content: const Text( + 'Are you sure you want to delete this item?', + ), + onConfirm: () { + confirmPressed = true; + Navigator.of(context).pop(); + }, + ); + }, + child: const Text('Open Modal'), + ); + }, + ), + ), + ), + ); + + // Open the modal by tapping the button + await tester.tap(find.text('Open Modal')); + await tester.pumpAndSettle(); // Wait for the dialog to appear + + // Verify that the AlertDialog is displayed + expect(find.byType(AlertDialog), findsOneWidget); + + // Use the key to directly find the RichText widget for the modal title + final richTextWidget = + tester.widget(find.byKey(const Key('DeleteModalTitle'))); + + // Extract the TextSpan from the RichText and verify the parts of the title + final textSpan = richTextWidget.text as TextSpan; + expect(textSpan.text, 'Delete '); + expect((textSpan.children![0] as TextSpan).text, 'Item'); + expect((textSpan.children![1] as TextSpan).text, '?'); + + // Verify the content of the modal + expect( + find.text('Are you sure you want to delete this item?'), + findsOneWidget, + ); + + // Verify the Cancel and Delete buttons are present + expect(find.text('Cancel'), findsOneWidget); + expect(find.text('Delete'), findsOneWidget); + + // Tap the Cancel button and verify that the onCancel callback is triggered + await tester.tap(find.text('Cancel')); + await tester.pumpAndSettle(); // Wait for the dialog to close + expect(find.text('Open Modal'), findsOneWidget); + + // Reopen the modal for testing the Delete button + await tester.tap(find.text('Open Modal')); + await tester.pumpAndSettle(); + + // Tap the Delete button and verify that the onConfirm callback is triggered + await tester.tap(find.text('Delete')); + await tester.pumpAndSettle(); // Wait for the dialog to close + expect(confirmPressed, isTrue); + }); +} From d996485a06db29539e8733b296442dc8d22ab7eb Mon Sep 17 00:00:00 2001 From: ZanderCowboy Date: Sun, 6 Oct 2024 15:33:59 +0200 Subject: [PATCH 02/25] update Android folder of Multichoice --- apps/multichoice/android/.gitignore | 2 +- apps/multichoice/android/app/build.gradle | 62 ++++++------------- .../android/app/src/main/AndroidManifest.xml | 30 +++++---- .../main/res/drawable/launch_background.xml | 2 +- apps/multichoice/android/build.gradle | 4 +- apps/multichoice/android/gradle.properties | 2 +- .../gradle/wrapper/gradle-wrapper.properties | 2 +- apps/multichoice/android/settings.gradle | 7 +-- 8 files changed, 45 insertions(+), 66 deletions(-) diff --git a/apps/multichoice/android/.gitignore b/apps/multichoice/android/.gitignore index 2c8dacf5..b89889ce 100644 --- a/apps/multichoice/android/.gitignore +++ b/apps/multichoice/android/.gitignore @@ -7,7 +7,7 @@ gradle-wrapper.jar GeneratedPluginRegistrant.java # Remember to never publicly share your keystore. -# See https://flutter.dev/docs/deployment/android#reference-the-keystore-from-the-app +# See https://flutter.dev/to/reference-keystore key.properties **/*.keystore **/*.jks diff --git a/apps/multichoice/android/app/build.gradle b/apps/multichoice/android/app/build.gradle index dde67d8b..b27f7c25 100644 --- a/apps/multichoice/android/app/build.gradle +++ b/apps/multichoice/android/app/build.gradle @@ -1,26 +1,8 @@ plugins { id "com.android.application" id "kotlin-android" + // The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins. id "dev.flutter.flutter-gradle-plugin" - // id 'com.google.gms.google-services' -} - -def localProperties = new Properties() -def localPropertiesFile = rootProject.file('local.properties') -if (localPropertiesFile.exists()) { - localPropertiesFile.withReader('UTF-8') { reader -> - localProperties.load(reader) - } -} - -def flutterVersionCode = localProperties.getProperty('flutter.versionCode') -if (flutterVersionCode == null) { - flutterVersionCode = '1' -} - -def flutterVersionName = localProperties.getProperty('flutter.versionName') -if (flutterVersionName == null) { - flutterVersionName = '1.0' } def keystoreProperties = new Properties() @@ -30,31 +12,27 @@ if (keystorePropertiesFile.exists()) { } android { - namespace "co.za.zanderkotze.multichoice" - compileSdk flutter.compileSdkVersion - ndkVersion flutter.ndkVersion + namespace = "co.za.zanderkotze.multichoice" + compileSdk = flutter.compileSdkVersion + ndkVersion = flutter.ndkVersion compileOptions { - sourceCompatibility JavaVersion.VERSION_1_8 - targetCompatibility JavaVersion.VERSION_1_8 + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 } kotlinOptions { - jvmTarget = '1.8' - } - - sourceSets { - main.java.srcDirs += 'src/main/kotlin' + jvmTarget = JavaVersion.VERSION_1_8 } defaultConfig { - applicationId "co.za.zanderkotze.multichoice" - minSdkVersion flutter.minSdkVersion - targetSdkVersion flutter.targetSdkVersion - versionCode flutterVersionCode.toInteger() - versionName flutterVersionName + applicationId = "co.za.zanderkotze.multichoice" + minSdk = flutter.minSdkVersion + targetSdk = flutter.targetSdkVersion + versionCode = flutter.versionCode + versionName = flutter.versionName ndk { - debugSymbolLevel 'FULL' + debugSymbolLevel = 'FULL' } } @@ -62,25 +40,21 @@ android { release { keyAlias keystoreProperties['keyAlias'] keyPassword keystoreProperties['keyPassword'] - storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null + storeFile file(keystoreProperties['storeFile']) storePassword keystoreProperties['storePassword'] } } + buildTypes { release { - signingConfig signingConfigs.release + signingConfig = signingConfigs.release ndk { - debugSymbolLevel 'FULL' + debugSymbolLevel = 'FULL' } } } } flutter { - source '../..' -} - -dependencies { - // implementation platform('com.google.firebase:firebase-bom:32.7.3') - // implementation 'com.google.firebase:firebase-analytics' + source = "../.." } diff --git a/apps/multichoice/android/app/src/main/AndroidManifest.xml b/apps/multichoice/android/app/src/main/AndroidManifest.xml index 32f20666..71a22eb2 100644 --- a/apps/multichoice/android/app/src/main/AndroidManifest.xml +++ b/apps/multichoice/android/app/src/main/AndroidManifest.xml @@ -1,13 +1,16 @@ - - - - - @@ -15,20 +18,23 @@ the Android process has started. This theme is visible to the user while the Flutter UI initializes. After that, this theme continues to determine the Window background behind the Flutter UI. --> - + - - + diff --git a/apps/multichoice/android/app/src/main/res/drawable/launch_background.xml b/apps/multichoice/android/app/src/main/res/drawable/launch_background.xml index f0bf5d4c..304732f8 100644 --- a/apps/multichoice/android/app/src/main/res/drawable/launch_background.xml +++ b/apps/multichoice/android/app/src/main/res/drawable/launch_background.xml @@ -9,4 +9,4 @@ android:gravity="center" android:src="@mipmap/launch_image" /> --> - \ No newline at end of file + diff --git a/apps/multichoice/android/build.gradle b/apps/multichoice/android/build.gradle index bc157bd1..d2ffbffa 100644 --- a/apps/multichoice/android/build.gradle +++ b/apps/multichoice/android/build.gradle @@ -5,12 +5,12 @@ allprojects { } } -rootProject.buildDir = '../build' +rootProject.buildDir = "../build" subprojects { project.buildDir = "${rootProject.buildDir}/${project.name}" } subprojects { - project.evaluationDependsOn(':app') + project.evaluationDependsOn(":app") } tasks.register("clean", Delete) { diff --git a/apps/multichoice/android/gradle.properties b/apps/multichoice/android/gradle.properties index 598d13fe..25971708 100644 --- a/apps/multichoice/android/gradle.properties +++ b/apps/multichoice/android/gradle.properties @@ -1,3 +1,3 @@ -org.gradle.jvmargs=-Xmx4G +org.gradle.jvmargs=-Xmx4G -XX:MaxMetaspaceSize=2G -XX:+HeapDumpOnOutOfMemoryError android.useAndroidX=true android.enableJetifier=true diff --git a/apps/multichoice/android/gradle/wrapper/gradle-wrapper.properties b/apps/multichoice/android/gradle/wrapper/gradle-wrapper.properties index e1ca574e..7bb2df6b 100644 --- a/apps/multichoice/android/gradle/wrapper/gradle-wrapper.properties +++ b/apps/multichoice/android/gradle/wrapper/gradle-wrapper.properties @@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.3-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-all.zip diff --git a/apps/multichoice/android/settings.gradle b/apps/multichoice/android/settings.gradle index ded70f0f..b9e43bd3 100644 --- a/apps/multichoice/android/settings.gradle +++ b/apps/multichoice/android/settings.gradle @@ -5,10 +5,9 @@ pluginManagement { def flutterSdkPath = properties.getProperty("flutter.sdk") assert flutterSdkPath != null, "flutter.sdk not set in local.properties" return flutterSdkPath - } - settings.ext.flutterSdkPath = flutterSdkPath() + }() - includeBuild("${settings.ext.flutterSdkPath}/packages/flutter_tools/gradle") + includeBuild("$flutterSdkPath/packages/flutter_tools/gradle") repositories { google() @@ -19,7 +18,7 @@ pluginManagement { plugins { id "dev.flutter.flutter-plugin-loader" version "1.0.0" - id "com.android.application" version "7.4.2" apply false + id "com.android.application" version "8.1.0" apply false id "org.jetbrains.kotlin.android" version "1.8.22" apply false } From 288613c184325afc43b9fd525e451e92b42a220e Mon Sep 17 00:00:00 2001 From: ZanderCowboy Date: Sun, 6 Oct 2024 15:59:56 +0200 Subject: [PATCH 03/25] add isar-3.1.0-1 to packages_external --- .../isar-3.1.0-1/.all-contributorsrc | 214 ++ packages_external/isar-3.1.0-1/.gitignore | 74 + packages_external/isar-3.1.0-1/Cargo.toml | 12 + packages_external/isar-3.1.0-1/LICENSE | 202 ++ packages_external/isar-3.1.0-1/README.md | 1 + packages_external/isar-3.1.0-1/TODO.md | 110 + .../isar-3.1.0-1/packages/isar/.gitignore | 1 + .../isar-3.1.0-1/packages/isar/CHANGELOG.md | 431 ++++ .../isar-3.1.0-1/packages/isar/LICENSE | 202 ++ .../isar-3.1.0-1/packages/isar/README.md | 267 ++ .../packages/isar/analysis_options.yaml | 11 + .../packages/isar/example/README.md | 3 + .../isar-3.1.0-1/packages/isar/lib/isar.dart | 49 + .../isar/lib/src/annotations/backlink.dart | 11 + .../isar/lib/src/annotations/collection.dart | 34 + .../isar/lib/src/annotations/embedded.dart | 17 + .../isar/lib/src/annotations/enumerated.dart | 33 + .../isar/lib/src/annotations/ignore.dart | 11 + .../isar/lib/src/annotations/index.dart | 76 + .../isar/lib/src/annotations/name.dart | 13 + .../isar/lib/src/annotations/type.dart | 20 + .../isar/lib/src/common/isar_common.dart | 222 ++ .../lib/src/common/isar_link_base_impl.dart | 108 + .../isar/lib/src/common/isar_link_common.dart | 92 + .../lib/src/common/isar_links_common.dart | 223 ++ .../packages/isar/lib/src/common/schemas.dart | 13 + .../packages/isar/lib/src/isar.dart | 347 +++ .../isar/lib/src/isar_collection.dart | 342 +++ .../packages/isar/lib/src/isar_connect.dart | 263 ++ .../isar/lib/src/isar_connect_api.dart | 215 ++ .../packages/isar/lib/src/isar_error.dart | 23 + .../packages/isar/lib/src/isar_link.dart | 113 + .../packages/isar/lib/src/isar_reader.dart | 88 + .../packages/isar/lib/src/isar_writer.dart | 53 + .../isar/lib/src/native/bindings.dart | 2241 +++++++++++++++++ .../isar/lib/src/native/encode_string.dart | 54 + .../isar/lib/src/native/index_key.dart | 257 ++ .../lib/src/native/isar_collection_impl.dart | 649 +++++ .../isar/lib/src/native/isar_core.dart | 234 ++ .../isar/lib/src/native/isar_impl.dart | 139 + .../isar/lib/src/native/isar_link_impl.dart | 121 + .../isar/lib/src/native/isar_reader_impl.dart | 591 +++++ .../isar/lib/src/native/isar_writer_impl.dart | 284 +++ .../packages/isar/lib/src/native/open.dart | 159 ++ .../isar/lib/src/native/query_build.dart | 1040 ++++++++ .../isar/lib/src/native/query_impl.dart | 261 ++ .../isar/lib/src/native/split_words.dart | 33 + .../packages/isar/lib/src/native/txn.dart | 113 + .../packages/isar/lib/src/query.dart | 204 ++ .../packages/isar/lib/src/query_builder.dart | 403 +++ .../lib/src/query_builder_extensions.dart | 303 +++ .../isar/lib/src/query_components.dart | 597 +++++ .../lib/src/schema/collection_schema.dart | 152 ++ .../isar/lib/src/schema/index_schema.dart | 104 + .../isar/lib/src/schema/link_schema.dart | 64 + .../isar/lib/src/schema/property_schema.dart | 183 ++ .../packages/isar/lib/src/schema/schema.dart | 126 + .../packages/isar/lib/src/web/bindings.dart | 188 ++ .../lib/src/web/isar_collection_impl.dart | 266 ++ .../packages/isar/lib/src/web/isar_impl.dart | 135 + .../isar/lib/src/web/isar_link_impl.dart | 75 + .../isar/lib/src/web/isar_reader_impl.dart | 347 +++ .../packages/isar/lib/src/web/isar_web.dart | 48 + .../isar/lib/src/web/isar_writer_impl.dart | 171 ++ .../packages/isar/lib/src/web/open.dart | 82 + .../isar/lib/src/web/query_build.dart | 375 +++ .../packages/isar/lib/src/web/query_impl.dart | 180 ++ .../isar/lib/src/web/split_words.dart | 5 + .../isar-3.1.0-1/packages/isar/pubspec.yaml | 23 + .../isar/test/isar_reader_writer_test.dart | 287 +++ .../packages/isar/tool/get_version.dart | 6 + .../isar/tool/verify_release_version.dart | 9 + .../packages/isar_flutter_libs/.pubignore | 5 + .../packages/isar_flutter_libs/CHANGELOG.md | 1 + .../packages/isar_flutter_libs/LICENSE | 202 ++ .../packages/isar_flutter_libs/README.md | 1 + .../isar_flutter_libs/android/.gitignore | 8 + .../isar_flutter_libs/android/build.gradle | 36 + .../android/gradle.properties | 3 + .../gradle/wrapper/gradle-wrapper.properties | 6 + .../isar_flutter_libs/android/settings.gradle | 1 + .../android/src/main/AndroidManifest.xml | 3 + .../IsarFlutterLibsPlugin.java | 13 + .../packages/isar_flutter_libs/ios/.gitignore | 38 + .../isar_flutter_libs/ios/Assets/.gitkeep | 0 .../ios/Classes/IsarFlutterLibsPlugin.h | 4 + .../ios/Classes/IsarFlutterLibsPlugin.m | 15 + .../Classes/SwiftIsarFlutterLibsPlugin.swift | 16 + .../isar_flutter_libs/ios/Classes/binding.h | 6 + .../ios/isar_flutter_libs.podspec | 17 + .../lib/isar_flutter_libs.dart | 0 .../isar_flutter_libs/linux/CMakeLists.txt | 25 + .../isar_flutter_libs_plugin.h | 26 + .../linux/isar_flutter_libs_plugin.cc | 70 + .../macos/Classes/IsarFlutterLibsPlugin.swift | 19 + .../macos/isar_flutter_libs.podspec | 17 + .../packages/isar_flutter_libs/pubspec.yaml | 33 + .../isar_flutter_libs/pubspec_overrides.yaml | 3 + .../isar_flutter_libs/windows/.gitignore | 17 + .../isar_flutter_libs/windows/CMakeLists.txt | 24 + .../isar_flutter_libs_plugin.h | 23 + .../windows/isar_flutter_libs_plugin.cpp | 82 + packages_external/isar-3.1.0-1/tool/build.sh | 22 + .../isar-3.1.0-1/tool/build_android.sh | 60 + .../isar-3.1.0-1/tool/build_ios.sh | 15 + .../isar-3.1.0-1/tool/build_linux.sh | 9 + .../isar-3.1.0-1/tool/build_macos.sh | 8 + .../isar-3.1.0-1/tool/build_windows.sh | 9 + .../isar-3.1.0-1/tool/cbindgen.toml | 8 + .../isar-3.1.0-1/tool/download_binaries.sh | 18 + .../isar-3.1.0-1/tool/ffigen.yaml | 27 + .../isar-3.1.0-1/tool/generate_bindings.sh | 13 + .../isar-3.1.0-1/tool/prepare_tests.sh | 6 + 113 files changed, 15312 insertions(+) create mode 100644 packages_external/isar-3.1.0-1/.all-contributorsrc create mode 100644 packages_external/isar-3.1.0-1/.gitignore create mode 100644 packages_external/isar-3.1.0-1/Cargo.toml create mode 100644 packages_external/isar-3.1.0-1/LICENSE create mode 100644 packages_external/isar-3.1.0-1/README.md create mode 100644 packages_external/isar-3.1.0-1/TODO.md create mode 100644 packages_external/isar-3.1.0-1/packages/isar/.gitignore create mode 100644 packages_external/isar-3.1.0-1/packages/isar/CHANGELOG.md create mode 100644 packages_external/isar-3.1.0-1/packages/isar/LICENSE create mode 100644 packages_external/isar-3.1.0-1/packages/isar/README.md create mode 100644 packages_external/isar-3.1.0-1/packages/isar/analysis_options.yaml create mode 100644 packages_external/isar-3.1.0-1/packages/isar/example/README.md create mode 100644 packages_external/isar-3.1.0-1/packages/isar/lib/isar.dart create mode 100644 packages_external/isar-3.1.0-1/packages/isar/lib/src/annotations/backlink.dart create mode 100644 packages_external/isar-3.1.0-1/packages/isar/lib/src/annotations/collection.dart create mode 100644 packages_external/isar-3.1.0-1/packages/isar/lib/src/annotations/embedded.dart create mode 100644 packages_external/isar-3.1.0-1/packages/isar/lib/src/annotations/enumerated.dart create mode 100644 packages_external/isar-3.1.0-1/packages/isar/lib/src/annotations/ignore.dart create mode 100644 packages_external/isar-3.1.0-1/packages/isar/lib/src/annotations/index.dart create mode 100644 packages_external/isar-3.1.0-1/packages/isar/lib/src/annotations/name.dart create mode 100644 packages_external/isar-3.1.0-1/packages/isar/lib/src/annotations/type.dart create mode 100644 packages_external/isar-3.1.0-1/packages/isar/lib/src/common/isar_common.dart create mode 100644 packages_external/isar-3.1.0-1/packages/isar/lib/src/common/isar_link_base_impl.dart create mode 100644 packages_external/isar-3.1.0-1/packages/isar/lib/src/common/isar_link_common.dart create mode 100644 packages_external/isar-3.1.0-1/packages/isar/lib/src/common/isar_links_common.dart create mode 100644 packages_external/isar-3.1.0-1/packages/isar/lib/src/common/schemas.dart create mode 100644 packages_external/isar-3.1.0-1/packages/isar/lib/src/isar.dart create mode 100644 packages_external/isar-3.1.0-1/packages/isar/lib/src/isar_collection.dart create mode 100644 packages_external/isar-3.1.0-1/packages/isar/lib/src/isar_connect.dart create mode 100644 packages_external/isar-3.1.0-1/packages/isar/lib/src/isar_connect_api.dart create mode 100644 packages_external/isar-3.1.0-1/packages/isar/lib/src/isar_error.dart create mode 100644 packages_external/isar-3.1.0-1/packages/isar/lib/src/isar_link.dart create mode 100644 packages_external/isar-3.1.0-1/packages/isar/lib/src/isar_reader.dart create mode 100644 packages_external/isar-3.1.0-1/packages/isar/lib/src/isar_writer.dart create mode 100644 packages_external/isar-3.1.0-1/packages/isar/lib/src/native/bindings.dart create mode 100644 packages_external/isar-3.1.0-1/packages/isar/lib/src/native/encode_string.dart create mode 100644 packages_external/isar-3.1.0-1/packages/isar/lib/src/native/index_key.dart create mode 100644 packages_external/isar-3.1.0-1/packages/isar/lib/src/native/isar_collection_impl.dart create mode 100644 packages_external/isar-3.1.0-1/packages/isar/lib/src/native/isar_core.dart create mode 100644 packages_external/isar-3.1.0-1/packages/isar/lib/src/native/isar_impl.dart create mode 100644 packages_external/isar-3.1.0-1/packages/isar/lib/src/native/isar_link_impl.dart create mode 100644 packages_external/isar-3.1.0-1/packages/isar/lib/src/native/isar_reader_impl.dart create mode 100644 packages_external/isar-3.1.0-1/packages/isar/lib/src/native/isar_writer_impl.dart create mode 100644 packages_external/isar-3.1.0-1/packages/isar/lib/src/native/open.dart create mode 100644 packages_external/isar-3.1.0-1/packages/isar/lib/src/native/query_build.dart create mode 100644 packages_external/isar-3.1.0-1/packages/isar/lib/src/native/query_impl.dart create mode 100644 packages_external/isar-3.1.0-1/packages/isar/lib/src/native/split_words.dart create mode 100644 packages_external/isar-3.1.0-1/packages/isar/lib/src/native/txn.dart create mode 100644 packages_external/isar-3.1.0-1/packages/isar/lib/src/query.dart create mode 100644 packages_external/isar-3.1.0-1/packages/isar/lib/src/query_builder.dart create mode 100644 packages_external/isar-3.1.0-1/packages/isar/lib/src/query_builder_extensions.dart create mode 100644 packages_external/isar-3.1.0-1/packages/isar/lib/src/query_components.dart create mode 100644 packages_external/isar-3.1.0-1/packages/isar/lib/src/schema/collection_schema.dart create mode 100644 packages_external/isar-3.1.0-1/packages/isar/lib/src/schema/index_schema.dart create mode 100644 packages_external/isar-3.1.0-1/packages/isar/lib/src/schema/link_schema.dart create mode 100644 packages_external/isar-3.1.0-1/packages/isar/lib/src/schema/property_schema.dart create mode 100644 packages_external/isar-3.1.0-1/packages/isar/lib/src/schema/schema.dart create mode 100644 packages_external/isar-3.1.0-1/packages/isar/lib/src/web/bindings.dart create mode 100644 packages_external/isar-3.1.0-1/packages/isar/lib/src/web/isar_collection_impl.dart create mode 100644 packages_external/isar-3.1.0-1/packages/isar/lib/src/web/isar_impl.dart create mode 100644 packages_external/isar-3.1.0-1/packages/isar/lib/src/web/isar_link_impl.dart create mode 100644 packages_external/isar-3.1.0-1/packages/isar/lib/src/web/isar_reader_impl.dart create mode 100644 packages_external/isar-3.1.0-1/packages/isar/lib/src/web/isar_web.dart create mode 100644 packages_external/isar-3.1.0-1/packages/isar/lib/src/web/isar_writer_impl.dart create mode 100644 packages_external/isar-3.1.0-1/packages/isar/lib/src/web/open.dart create mode 100644 packages_external/isar-3.1.0-1/packages/isar/lib/src/web/query_build.dart create mode 100644 packages_external/isar-3.1.0-1/packages/isar/lib/src/web/query_impl.dart create mode 100644 packages_external/isar-3.1.0-1/packages/isar/lib/src/web/split_words.dart create mode 100644 packages_external/isar-3.1.0-1/packages/isar/pubspec.yaml create mode 100644 packages_external/isar-3.1.0-1/packages/isar/test/isar_reader_writer_test.dart create mode 100644 packages_external/isar-3.1.0-1/packages/isar/tool/get_version.dart create mode 100644 packages_external/isar-3.1.0-1/packages/isar/tool/verify_release_version.dart create mode 100644 packages_external/isar-3.1.0-1/packages/isar_flutter_libs/.pubignore create mode 100644 packages_external/isar-3.1.0-1/packages/isar_flutter_libs/CHANGELOG.md create mode 100644 packages_external/isar-3.1.0-1/packages/isar_flutter_libs/LICENSE create mode 100644 packages_external/isar-3.1.0-1/packages/isar_flutter_libs/README.md create mode 100644 packages_external/isar-3.1.0-1/packages/isar_flutter_libs/android/.gitignore create mode 100644 packages_external/isar-3.1.0-1/packages/isar_flutter_libs/android/build.gradle create mode 100644 packages_external/isar-3.1.0-1/packages/isar_flutter_libs/android/gradle.properties create mode 100644 packages_external/isar-3.1.0-1/packages/isar_flutter_libs/android/gradle/wrapper/gradle-wrapper.properties create mode 100644 packages_external/isar-3.1.0-1/packages/isar_flutter_libs/android/settings.gradle create mode 100644 packages_external/isar-3.1.0-1/packages/isar_flutter_libs/android/src/main/AndroidManifest.xml create mode 100644 packages_external/isar-3.1.0-1/packages/isar_flutter_libs/android/src/main/java/dev/isar/isar_flutter_libs/IsarFlutterLibsPlugin.java create mode 100644 packages_external/isar-3.1.0-1/packages/isar_flutter_libs/ios/.gitignore create mode 100644 packages_external/isar-3.1.0-1/packages/isar_flutter_libs/ios/Assets/.gitkeep create mode 100644 packages_external/isar-3.1.0-1/packages/isar_flutter_libs/ios/Classes/IsarFlutterLibsPlugin.h create mode 100644 packages_external/isar-3.1.0-1/packages/isar_flutter_libs/ios/Classes/IsarFlutterLibsPlugin.m create mode 100644 packages_external/isar-3.1.0-1/packages/isar_flutter_libs/ios/Classes/SwiftIsarFlutterLibsPlugin.swift create mode 100644 packages_external/isar-3.1.0-1/packages/isar_flutter_libs/ios/Classes/binding.h create mode 100644 packages_external/isar-3.1.0-1/packages/isar_flutter_libs/ios/isar_flutter_libs.podspec create mode 100644 packages_external/isar-3.1.0-1/packages/isar_flutter_libs/lib/isar_flutter_libs.dart create mode 100644 packages_external/isar-3.1.0-1/packages/isar_flutter_libs/linux/CMakeLists.txt create mode 100644 packages_external/isar-3.1.0-1/packages/isar_flutter_libs/linux/include/isar_flutter_libs/isar_flutter_libs_plugin.h create mode 100644 packages_external/isar-3.1.0-1/packages/isar_flutter_libs/linux/isar_flutter_libs_plugin.cc create mode 100644 packages_external/isar-3.1.0-1/packages/isar_flutter_libs/macos/Classes/IsarFlutterLibsPlugin.swift create mode 100644 packages_external/isar-3.1.0-1/packages/isar_flutter_libs/macos/isar_flutter_libs.podspec create mode 100644 packages_external/isar-3.1.0-1/packages/isar_flutter_libs/pubspec.yaml create mode 100644 packages_external/isar-3.1.0-1/packages/isar_flutter_libs/pubspec_overrides.yaml create mode 100644 packages_external/isar-3.1.0-1/packages/isar_flutter_libs/windows/.gitignore create mode 100644 packages_external/isar-3.1.0-1/packages/isar_flutter_libs/windows/CMakeLists.txt create mode 100644 packages_external/isar-3.1.0-1/packages/isar_flutter_libs/windows/include/isar_flutter_libs/isar_flutter_libs_plugin.h create mode 100644 packages_external/isar-3.1.0-1/packages/isar_flutter_libs/windows/isar_flutter_libs_plugin.cpp create mode 100644 packages_external/isar-3.1.0-1/tool/build.sh create mode 100644 packages_external/isar-3.1.0-1/tool/build_android.sh create mode 100644 packages_external/isar-3.1.0-1/tool/build_ios.sh create mode 100644 packages_external/isar-3.1.0-1/tool/build_linux.sh create mode 100644 packages_external/isar-3.1.0-1/tool/build_macos.sh create mode 100644 packages_external/isar-3.1.0-1/tool/build_windows.sh create mode 100644 packages_external/isar-3.1.0-1/tool/cbindgen.toml create mode 100644 packages_external/isar-3.1.0-1/tool/download_binaries.sh create mode 100644 packages_external/isar-3.1.0-1/tool/ffigen.yaml create mode 100644 packages_external/isar-3.1.0-1/tool/generate_bindings.sh create mode 100644 packages_external/isar-3.1.0-1/tool/prepare_tests.sh diff --git a/packages_external/isar-3.1.0-1/.all-contributorsrc b/packages_external/isar-3.1.0-1/.all-contributorsrc new file mode 100644 index 00000000..c75bdc9d --- /dev/null +++ b/packages_external/isar-3.1.0-1/.all-contributorsrc @@ -0,0 +1,214 @@ +{ + "files": [ + "packages/isar/README.md" + ], + "imageSize": 100, + "commit": false, + "contributors": [ + { + "login": "Jtplouffe", + "name": "JT", + "avatar_url": "https://avatars.githubusercontent.com/u/32107801?v=4", + "profile": "https://github.com/Jtplouffe", + "contributions": [ + "test", + "bug" + ] + }, + { + "login": "leisim", + "name": "Simon Leier", + "avatar_url": "https://avatars.githubusercontent.com/u/13610195?v=4", + "profile": "https://www.linkedin.com/in/simon-leier/", + "contributions": [ + "bug", + "code", + "doc", + "test", + "example" + ] + }, + { + "login": "h1376h", + "name": "Hamed H.", + "avatar_url": "https://avatars.githubusercontent.com/u/3498335?v=4", + "profile": "https://github.com/h1376h", + "contributions": [ + "code", + "maintenance" + ] + }, + { + "login": "Viper-Bit", + "name": "Peyman", + "avatar_url": "https://avatars.githubusercontent.com/u/24822764?v=4", + "profile": "https://github.com/Viper-Bit", + "contributions": [ + "bug", + "code" + ] + }, + { + "login": "blendthink", + "name": "blendthink", + "avatar_url": "https://avatars.githubusercontent.com/u/32213113?v=4", + "profile": "https://github.com/blendthink", + "contributions": [ + "maintenance" + ] + }, + { + "login": "Moseco", + "name": "Moseco", + "avatar_url": "https://avatars.githubusercontent.com/u/10720298?v=4", + "profile": "https://github.com/Moseco", + "contributions": [ + "bug" + ] + }, + { + "login": "Frostedfox", + "name": "Frostedfox", + "avatar_url": "https://avatars.githubusercontent.com/u/84601232?v=4", + "profile": "https://github.com/Frostedfox", + "contributions": [ + "doc" + ] + }, + { + "login": "nohli", + "name": "Joachim Nohl", + "avatar_url": "https://avatars.githubusercontent.com/u/43643339?v=4", + "profile": "http://achim.io", + "contributions": [ + "maintenance" + ] + }, + { + "login": "VoidxHoshi", + "name": "LaLucid", + "avatar_url": "https://avatars.githubusercontent.com/u/55886143?v=4", + "profile": "https://github.com/VoidxHoshi", + "contributions": [ + "maintenance" + ] + }, + { + "login": "vothvovo", + "name": "Johnson", + "avatar_url": "https://avatars.githubusercontent.com/u/20894472?v=4", + "profile": "https://github.com/vothvovo", + "contributions": [ + "bug" + ] + }, + { + "login": "ika020202", + "name": "Ura", + "avatar_url": "https://avatars.githubusercontent.com/u/42883378?v=4", + "profile": "https://zenn.dev/urasan", + "contributions": [ + "translation" + ] + }, + { + "login": "mnkeis", + "name": "mnkeis", + "avatar_url": "https://avatars.githubusercontent.com/u/41247357?v=4", + "profile": "https://github.com/mnkeis", + "contributions": [ + "translation" + ] + }, + { + "login": "CarloDotLog", + "name": "Carlo Loguercio", + "avatar_url": "https://avatars.githubusercontent.com/u/13763473?v=4", + "profile": "https://github.com/CarloDotLog", + "contributions": [ + "translation" + ] + }, + { + "login": "hafeezrana", + "name": "Hafeez Rana", + "avatar_url": "https://avatars.githubusercontent.com/u/87476445?v=4", + "profile": "https://g.dev/hafeezrana", + "contributions": [ + "doc" + ] + }, + { + "login": "inkomomutane", + "name": "Nelson Mutane", + "avatar_url": "https://avatars.githubusercontent.com/u/57417802?v=4", + "profile": "https://github.com/inkomomutane", + "contributions": [ + "translation" + ] + }, + { + "login": "lodisy", + "name": "Michael", + "avatar_url": "https://avatars.githubusercontent.com/u/8101584?v=4", + "profile": "https://github.com/lodisy", + "contributions": [ + "translation" + ] + }, + { + "login": "ritksm", + "name": "Jack Rivers", + "avatar_url": "https://avatars.githubusercontent.com/u/111809?v=4", + "profile": "http://blog.jackrivers.me/", + "contributions": [ + "translation" + ] + }, + { + "login": "buraktabn", + "name": "Burak", + "avatar_url": "https://avatars.githubusercontent.com/u/49204989?v=4", + "profile": "http://buraktaban.ca", + "contributions": [ + "bug" + ] + }, + { + "login": "AlexisL61", + "name": "Alexis", + "avatar_url": "https://avatars.githubusercontent.com/u/30233189?v=4", + "profile": "https://github.com/AlexisL61", + "contributions": [ + "bug" + ] + }, + { + "login": "letyletylety", + "name": "Lety", + "avatar_url": "https://avatars.githubusercontent.com/u/16468579?v=4", + "profile": "https://letyarch.blogspot.com/", + "contributions": [ + "doc" + ] + }, + { + "login": "nobkd", + "name": "nobkd", + "avatar_url": "https://avatars.githubusercontent.com/u/44443899?v=4", + "profile": "https://github.com/nobkd", + "contributions": [ + "doc" + ] + } + ], + "contributorTemplate": "\">\" width=\"<%= options.imageSize %>px;\" alt=\"\"/>
<%= contributor.name %>
", + "contributorsPerLine": 7, + "contributorsSortAlphabetically": true, + "projectName": "isar", + "projectOwner": "isar", + "repoType": "github", + "repoHost": "https://github.com", + "skipCi": true, + "commitConvention": "angular" +} diff --git a/packages_external/isar-3.1.0-1/.gitignore b/packages_external/isar-3.1.0-1/.gitignore new file mode 100644 index 00000000..bda0b43a --- /dev/null +++ b/packages_external/isar-3.1.0-1/.gitignore @@ -0,0 +1,74 @@ +# Miscellaneous +*.class +*.lock +*.log +.DS_Store +.vscode/ +.idea + +# Dart related +.dart_tool/ +.flutter-plugins +.flutter-plugins-dependencies +**/generated_plugin_registrant.dart +.packages +.pub-cache/ +.pub/ +build/ + +# Rust related +target/ +*.a +*.so +*.dylib +*.dll +*.zip +*.xcframework/ +isar-dart.h + +# Android related +**/android/**/gradle-wrapper.jar +.gradle/ +**/android/captures/ +**/android/gradlew +**/android/gradlew.bat +**/android/local.properties +**/android/**/GeneratedPluginRegistrant.java + +# iOS/XCode related +**/ios/**/*.mode1v3 +**/ios/**/*.mode2v3 +**/ios/**/*.moved-aside +**/ios/**/*.pbxuser +**/ios/**/*.perspectivev3 +**/ios/**/*sync/ +**/ios/**/.sconsign.dblite +**/ios/**/.tags* +**/ios/**/.vagrant/ +**/ios/**/DerivedData/ +**/ios/**/Icon? +**/ios/**/Pods/ +**/ios/**/.symlinks/ +**/ios/**/profile +**/ios/**/xcuserdata +**/ios/.generated/ +**/ios/Flutter/.last_build_id +**/ios/Flutter/App.framework +**/ios/Flutter/Flutter.framework +**/ios/Flutter/Flutter.podspec +**/ios/Flutter/Generated.xcconfig +**/ios/Flutter/ephemeral +**/ios/Flutter/app.flx +**/ios/Flutter/app.zip +**/ios/Flutter/flutter_assets/ +**/ios/Flutter/flutter_export_environment.sh +**/ios/ServiceDefinitions.json +**/ios/Runner/GeneratedPluginRegistrant.* + +# macOS +**/macos/Flutter/GeneratedPluginRegistrant.swift +**/ephemeral +**/.plugin_symlinks/ + +# Coverage +coverage/ diff --git a/packages_external/isar-3.1.0-1/Cargo.toml b/packages_external/isar-3.1.0-1/Cargo.toml new file mode 100644 index 00000000..df62b1bd --- /dev/null +++ b/packages_external/isar-3.1.0-1/Cargo.toml @@ -0,0 +1,12 @@ +[workspace] +members = [ + "packages/isar_core", + "packages/isar_core_ffi", + "packages/mdbx_sys" +] + +[profile.release] +lto = true +codegen-units = 1 +panic = "abort" +strip = "symbols" \ No newline at end of file diff --git a/packages_external/isar-3.1.0-1/LICENSE b/packages_external/isar-3.1.0-1/LICENSE new file mode 100644 index 00000000..7a4a3ea2 --- /dev/null +++ b/packages_external/isar-3.1.0-1/LICENSE @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. \ No newline at end of file diff --git a/packages_external/isar-3.1.0-1/README.md b/packages_external/isar-3.1.0-1/README.md new file mode 100644 index 00000000..0f4dcb03 --- /dev/null +++ b/packages_external/isar-3.1.0-1/README.md @@ -0,0 +1 @@ +packages/isar/README.md \ No newline at end of file diff --git a/packages_external/isar-3.1.0-1/TODO.md b/packages_external/isar-3.1.0-1/TODO.md new file mode 100644 index 00000000..b89f04e3 --- /dev/null +++ b/packages_external/isar-3.1.0-1/TODO.md @@ -0,0 +1,110 @@ +

Roadmap and TODOs

+ + +# Documentation + +## API Docs + +- [ ] Document all public APIs + +## Schema + +- [x] Update schema migration instructions +- [ ] Document all annotation options + +## CRUD + +- [ ] Document sync operations +- [x] `getAll()`, `putAll`, `deleteAll()` +- [ ] `getBy...()`, `deleteBy...()` + +## Queries + +- [x] Filter groups +- [x] Boolean operators `and()`, `or()`, `not()` +- [x] Offset, limit +- [x] Distinct where clauses +- [x] Different filter operations (`equalTo`, `beginsWith()` etc.) +- [ ] Better explanation for distinct and sorted where clauses +- [ ] Watching queries + +## Indexes + +- [ ] Intro +- [x] What are they +- [ ] Why use them +- [x] How to in isar? + +## Examples + +- [ ] Create minimal example +- [ ] Create complex example with indexes, filter groups etc. +- [ ] More Sample Apps + +## Tutorials + +- [ ] How to write fast queries +- [ ] Build a simple offline first app +- [ ] Advanced queries + + +---- + + +# Isar Dart + +## Features + +- [x] Distinct by +- [x] Offset, Limit +- [x] Sorted by + +## Fixes + +- [x] Provide an option to change collection accessor names + +## Unit tests + +- [x] Download binaries automatically for tests + +### Queries + +- [x] Restructure query tests to make them less verbose +- [x] Define models that can be reused across tests +- [x] Where clauses with string indexes (value, hash, words, case-sensitive) +- [x] Distinct where clauses +- [x] String filter operations + + +---- + + +# Isar Core + +## Features (low priority) + +- [ ] Draft Synchronization +- [x] Relationships + +## Unit tests + +- [ ] Make mdbx unit tests bulletproof +- [x] Migration tests +- [x] Binary format +- [x] CRUD +- [x] Links +- [ ] QueryBuilder +- [ ] WhereClause +- [ ] WhereExecutor +- [x] CollectionMigrator +- [ ] Watchers + + +---- + + +# Isar Web + +- [ ] MVP + + diff --git a/packages_external/isar-3.1.0-1/packages/isar/.gitignore b/packages_external/isar-3.1.0-1/packages/isar/.gitignore new file mode 100644 index 00000000..25361338 --- /dev/null +++ b/packages_external/isar-3.1.0-1/packages/isar/.gitignore @@ -0,0 +1 @@ +*.g.dart \ No newline at end of file diff --git a/packages_external/isar-3.1.0-1/packages/isar/CHANGELOG.md b/packages_external/isar-3.1.0-1/packages/isar/CHANGELOG.md new file mode 100644 index 00000000..c88e534e --- /dev/null +++ b/packages_external/isar-3.1.0-1/packages/isar/CHANGELOG.md @@ -0,0 +1,431 @@ +## 3.1.0+1 + +### Fixes + +- Fixed error building MacOS library + +## 3.1.0 + +### Breaking + +Sorry for this breaking change. Unfortunately, it was necessary to fix stability issues on Android. + +- `directory` is now required for `Isar.open()` and `Isar.openSync()` + +### Fixes + +- Fixed a crash that occasionally occurred when opening Isar +- Fixed a schema migration issue +- Fixed an issue where embedded class renaming didn't work correctly + +### Enhancements + +- Many internal improvements +- Performance improvements + +## 3.0.6 + +### Fixes + +- Add check to verify transactions are used for correct instance +- Add check to verify that async transactions are still active +- Fix upstream issue with opening databases + +## 3.0.5 + +### Enhancements + +- Improved performance for all operations +- Added `maxSizeMiB` option to `Isar.open()` to specify the maximum size of the database file +- Significantly reduced native library size +- With the help of the community, the docs have been translated into a range of languages +- Improved API docs +- Added integration tests for more platforms to ensure high-quality releases +- Support for unicode paths on Windows + +### Fixes + +- Fixed crash while opening Isar +- Fixed crash on older Android devices +- Fixed a native port that was not closed correctly in some cases +- Added swift version to podspec +- Fixed crash on Windows +- Fixed "IndexNotFound" error + +## 3.0.4 + +REDACTED. + +## 3.0.3 + +REDACTED. + +## 3.0.2 + +### Enhancements + +- The Inspector now supports creating objects and importing JSON +- Added Inspector check to make sure Chrome is used + +### Fixes + +- Added support for the latest analyzer +- Fixed native ports that were not closed correctly in some cases +- Added support for Ubuntu 18.04 and older +- Fixed issue with aborting transactions +- Fixed crash when invalid JSON was provided to `importJsonRaw()` +- Added missing `exportJsonSync()` and `exportJsonRawSync()` +- Fixed issue where secondary instance could not be selected in the Inspector + +## 3.0.1 + +### Enhancements + +- Support for arm64 iOS Simulators + +### Fixes + +- Fixed issue where `.anyOf()`, `.allOf()`, and `.oneOf()` could not be negated +- Fixed too low min-iOS version. The minimum supported is 11.0 +- Fixed error during macOS App Store build + +## 3.0.0 + +This release has been a lot of work! Thanks to everyone who contributed and joined the countless discussions. You are really awesome! + +Special thanks to [@Jtplouffe](https://github.com/Jtplouffe) and [@Peyman](https://github.com/Viper-Bit) for their incredible work. + +### Web support + +This version does not support the web target yet. It will be back in the next version. Please continue using 2.5.0 if you need web support. + +### Enhancements + +- Completely new Isar inspector that does not need to be installed anymore +- Extreme performance improvements for almost all operations (up to 50%) +- Support for embedded objects using `@embedded` +- Support for enums using `@enumerated` +- Vastly improved Isar binary format space efficiency resulting in about 20% smaller databases +- Added `id`, `byte`, `short` and `float` typedefs +- `IsarLinks` now support all `Set` methods based on the Isar `Id` of objects +- Added `download` option to `Isar.initializeIsarCore()` to download binaries automatically +- Added `replace` option for indexes +- Added verification for correct Isar binary version +- Added `collection.getSize()` and `collection.getSizeSync()` +- Added `query.anyOf()` and `query.allOf()` query modifiers +- Support for much more complex composite index queries +- Support for logical XOR and the `.oneOf()` query modifier +- Made providing a path optional +- The default Isar name is now `default` and stored in `dir/name.isar` and `dir/name.isar.lock` +- On non-web platforms, `IsarLink` and `IsarLinks` will load automatically +- `.putSync()`, `.putAllSync()` etc. will now save links recursively by default +- Added `isar.getSize()` and `isar.getSizeSync()` +- Added `linksLengthEqualTo()`, `linksIsEmpty()`, `linksIsNotEmpty()`, `linksLengthGreaterThan()`, `linksLengthLessThan()`, `linksLengthBetween()` and `linkIsNull()` filters +- Added `listLengthEqualTo()`, `listIsEmpty()`, `listIsNotEmpty()`, `listLengthGreaterThan()`, `listLengthLessThan()`, `listLengthBetween()` filters +- Added `isNotNull()` filters +- Added `compactOnLaunch` conditions to `Isar.open()` for automatic database compaction +- Added `isar.copyToFile()` which copies a compacted version of the database to a path +- Added check to verify that linked collections schemas are provided for opening an instance +- Apply default values from constructor during deserialization +- Added `isar.verify()` and `col.verify()` methods for checking database integrity in unit tests +- Added missing float and double queries and an `epsilon` parameter + +### Breaking changes + +- Removed `TypeConverter` support in favor of `@embedded` and `@enumerated` +- Removed `@Id()` and `@Size32()` annotations in favor of the `Id` and `short` types +- Changed the `schemas` parameter from named to positional +- The maximum size of objects is now 16MB +- Removed `replaceOnConflict` and `saveLinks` parameter from `collection.put()` and `collection.putAll()` +- Removed `isar` parameter from `Isar.txn()`, `Isar.writeTxn()`, `Isar.txnSync()` and `Isar.writeTxnSync()` +- Removed `query.repeat()` +- Removed `query.sortById()` and `query.distinctById()` +- Fixed `.or()` instead of `.and()` being used implicitly when combining filters +- Renamed multi-entry where clauses from `.yourListAnyEqualTo()` to `.yourListElementEqualTo()` to avoid confusion +- Isar will no longer create the provided directory. Make sure it exists before opening an Isar Instance. +- Changed the default index type for all `List`s to `IndexType.hash` +- Renamed `isar.getCollection()` to `isar.collection()` +- It is no longer allowed to extend or implement another collection +- Unsupported properties will no longer be ignored by default +- Renamed the `initialReturn` parameter to `fireImmediately` +- Renamed `Isar.initializeLibraries()` to `Isar.initializeIsarCore()` + +### Fixes + +There are too many fixes to list them all. + +- A lot of link fixes and a slight behavior change to make them super reliable +- Fixed missing symbols on older Android phones +- Fixed composite queries +- Fixed various generator issues +- Fixed error retrieving the id property in a query +- Fixed missing symbols on 32-bit Android 5 & 6 devices +- Fixed inconsistent `null` handling in json export +- Fixed default directory issue on Android +- Fixed different where clauses returning duplicate results +- Fixed hash index issue where multiple list values resulted in the same hash +- Fixed edge case where creating a new index failed + +## 2.5.0 + +### Enhancements + +- Support for Android x86 (32 bit emulator) and macOS arm64 (Apple Silicon) +- Greatly improved test coverage for sync methods +- `col.clear()` now resets the auto increment counter to `0` +- Significantly reduced Isar Core binary size (about 1.4MB -> 800KB) + +### Minor Breaking + +- Changed `initializeLibraries(Map libraries)` to `initializeLibraries(Map libraries)` +- Changed min Dart SDK to `2.16.0` + +### Fixes + +- Fixed issue with `IsarLink.saveSync()` +- Fixed `id` queries +- Fixed error thrown by `BroadcastChannel` in Firefox +- Fixed Isar Inspector connection issue + +## 2.4.0 + +### Enhancements + +- Support for querying links +- Support for filtering and sorting links +- Added methods to update and count links without loading them +- Added `isLoaded` property to links +- Added methods to count the number of objects in a collection +- Big internal improvements + +### Minor Breaking + +- There are now different kinds of where clauses for dynamic queries +- `isar.getCollection()` no longer requires the name of the collection +- `Isar.instanceNames` now returns a `Set` instead of a `List` + +### Fixes + +- Fixed iOS crash that frequently happened on older devices +- Fixed 32bit issue on Android +- Fixed link issues +- Fixed missing `BroadcastChannel` API for older Safari versions + +## 2.2.1 + +### Enhancements + +- Reduced Isar web code size by 50% +- Made `directory` parameter of `Isar.open()` optional for web +- Made `name` parameter of `Isar.getInstance()` optional +- Added `Isar.defaultName` constant +- Enabled `TypeConverter`s with supertypes +- Added message if `TypeConverter` nullability doesn't match +- Added more tests + +### Fixes + +- Fixed issue with date queries +- Fixed `FilterGroup.not` constructor (thanks for the PR @jtzell) + +## 2.2.0 + +Isar now has full web support 🎉. No changes to your code required, just run it. + +_Web passes all unit tests but is still considered beta for now._ + +### Minor Breaking + +- Added `saveLinks` parameter to `.put()` and `.putAll()` which defaults to `false` +- Changed default `overrideChanges` parameter of `links.load()` to `true` to avoid unintended behavior + +### Enhancements + +- Full web support! +- Improved write performance +- Added `deleteFromDisk` option to `isar.close()` +- Added `.reset()` and `.resetSync()` methods to `IsarLink` and `IsarLinks` +- Improved `links.save()` performance +- Added many tests + +### Fixed + +- Fixed value of `null` dates to be `DateTime.fromMillisecondsSinceEpoch(0)` +- Fixed problem with migration +- Fixed incorrect list values for new properties (`[]` instead of `null`) +- Improved handling of link edge-cases + +## 2.1.4 + +- Removed `path` dependency +- Fixed incorrect return value of `deleteByIndex()` +- Fixed wrong auto increment ids in some cases (thanks @robban112) +- Fixed an issue with `Isar.close()` (thanks @msxenon) +- Fixed `$` escaping in generated code (thanks @jtzell) +- Fixed broken link in pub.dev example page + +## 2.1.0 + +`isar_connect` is now integrated into `isar` + +### Enhancements + +- Added check for outdated generated files +- Added check for changed schema across isolates +- Added `Isar.openSync()` +- Added `col.importJsonRawSync()`, `col.importJsonSync()`, `query.exportJsonRawSync()`, `query.exportJsonSync()` +- Improved performance for queries +- Improved handling of ffi memory +- More tests + +### Fixed + +- Fixed issue where imported json required existing ids +- Fixed issue with transaction handling (thanks @Peng-Qian for the awesome help) +- Fixed issue with `@Ignore` annotation not always working +- Fixed issue with `getByIndex()` not returning correct object id (thanks @jtzell) + +## 2.0.0 + +### Breaking + +- The id for non-final objects is now assigned automatically after `.put()` and `.putSync()` +- `double` and `List` indexes can no longer be at the beginning of a composite index +- `List` indexes can no longer be hashed +- `.greaterThan()`, `.lessThan()` and `.between()` filters and are now excluding for `double` values (`>=` -> `>`) +- Changed the default index type for lists to `IndexType.value` +- `IsarLink` and `IsarLinks` will no longer be initialized by Isar and must not be `nullable` or `late`. +- Dart `2.14` or higher is required + +### Enhancements + +- Added API docs for all public methods +- Added `isar.clear()`, `isar.clearSync()`, `col.clear()` and `col.clearSync()` +- Added `col.filter()` as shortcut for `col.where().filter()` +- Added `include` parameter to `.greaterThan()` and `.lessThan()` filters and where clauses +- Added `includeLower` and `includeUpper` parameters to `.between()` filters and where clauses +- Added `Isar.autoIncrement` to allow non-nullable auto-incrementing ids +- `Isar.close()` now returns whether the last instance was closed +- List values in composite indexes are now of type `IndexType.hash` automatically +- Allowed multiple indexes on the same property +- Removed exported packages from API docs +- Improved generated code +- Improved Isar Core error messages +- Minor performance improvements +- Automatic XCode configuration +- Updated analyzer to `3.0.0` +- More tests + +### Fixed + +- `IsarLink` and `IsarLinks` can now be final +- Fixed multi-entry index queries returning items multiple times in some cases +- Fixed `.anyLessThan()` and `.anyGreaterThan()` issues +- Fixed issues with backlinks +- Fixed issue where query only returned the first `99999` results +- Fixed issue with id where clauses +- Fixed default index type for lists and bytes +- Fixed issue where renaming indexes was not possible +- Fixed issue where wrong index name was used for `.getByX()` and `.deleteByX()` +- Fixed issue where composite indexes did not allow non-hashed Strings as last value +- Fixed issue where `@Ignore()` fields were not ignored + +## 1.0.5 + +### Enhancements + +- Updated dependencies + +### Fixes: + +- Included desktop binaries +- Fixed "Cannot allocate memory" error on older iOS devices +- Fixed stripped binaries for iOS release builds +- Fixed IsarInspector issues (thanks to [RubenBez](https://github.com/RubenBez) and [rizzi37](https://github.com/rizzi37)) + +## 1.0.0+1 + +Added missing binaries + +## 1.0.0 + +Switched from liblmdb to libmdbx for better performance, more stability and many internal improvements. + +### Breaking + +The internal database format has been changed to improve performance. Old databases do not work anymore! + +### Fixes + +- Fix issue with links being removed after object update +- Fix String index problems + +### Enhancements + +- Support `greaterThan`, `lessThan` and `between` queries for String values +- Support for inheritance (enabled by default) +- Support for `final` properties and getters +- Support for `freezed` and other code generators +- Support getting / deleting objects by a key `col.deleteByName('Anne')` +- Support for list indexes (hash an element based) +- Generator now creates individual files instead of one big file +- Allow specifying the collection accessor name +- Unsupported properties are now ignored automatically +- Returns the assigned ids after `.put()` operations (objects are no longer mutated) +- Introduces `replaceOnConflict` option for `.put()` (instead of specifying it for index) +- many more... + +### Internal + +- Improve generated code +- Many new unit tests + +## 0.4.0 + +### Breaking + +- Remove `.where...In()` and `...In()` extension methods +- Split `.watch(lazy: bool)` into `.watch()` and `.watchLazy()` +- Remove `include` option for filters + +### Fixes + +- Generate id for JSON imports that don't have an id +- Enable `sortBy` and `thenBy` generation + +### Enhancements + +- Add `.optional()` and `.repeat()` query modifiers +- Support property queries +- Support query aggregation +- Support dynamic queries (for custom query languages) +- Support multi package configuration with `@ExternalCollection()` +- Add `caseSensitive` option to `.distinctBy()` + +### Internal + +- Change iOS linking +- Improve generated code +- Set up integration tests and improve unit tests +- Use CORE/0.4.0 + +## 0.2.0 + +- Link support +- Many improvements and fixes + +## 0.1.0 + +- Support for links and backlinks + +## 0.0.4 + +- Bugfixes and many improvements + +## 0.0.2 + +Fix dependency issue + +## 0.0.1 + +Initial release diff --git a/packages_external/isar-3.1.0-1/packages/isar/LICENSE b/packages_external/isar-3.1.0-1/packages/isar/LICENSE new file mode 100644 index 00000000..f0d4b836 --- /dev/null +++ b/packages_external/isar-3.1.0-1/packages/isar/LICENSE @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright 2022 Simon Leier + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. \ No newline at end of file diff --git a/packages_external/isar-3.1.0-1/packages/isar/README.md b/packages_external/isar-3.1.0-1/packages/isar/README.md new file mode 100644 index 00000000..2466b448 --- /dev/null +++ b/packages_external/isar-3.1.0-1/packages/isar/README.md @@ -0,0 +1,267 @@ +

+ + + +

Isar Database

+

+ +

+ + + + + + + + + + + + + + + +

+ +

+ Quickstart • + Documentation • + Sample Apps • + Support & Ideas • + Pub.dev +

+ +> #### Isar [ee-zahr]: +> +> 1. River in Bavaria, Germany. +> 2. [Crazy fast](#benchmarks) NoSQL database that is a joy to use. + +## Features + +- 💙 **Made for Flutter**. Easy to use, no config, no boilerplate +- 🚀 **Highly scalable** The sky is the limit (pun intended) +- 🍭 **Feature rich**. Composite & multi-entry indexes, query modifiers, JSON support etc. +- ⏱ **Asynchronous**. Parallel query operations & multi-isolate support by default +- 🦄 **Open source**. Everything is open source and free forever! + +Isar database can do much more (and we are just getting started) + +- 🕵️ **Full-text search**. Make searching fast and fun +- 📱 **Multiplatform**. iOS, Android, Desktop +- 🧪 **ACID semantics**. Rely on database consistency +- 💃 **Static typing**. Compile-time checked and autocompleted queries +- ✨ **Beautiful documentation**. Readable, easy to understand and ever-improving + +Join the [Telegram group](https://t.me/isardb) for discussion and sneak peeks of new versions of the DB. + +If you want to say thank you, star us on GitHub and like us on pub.dev 🙌💙 + +## Quickstart + +Holy smokes you're here! Let's get started on using the coolest Flutter database out there... + +### 1. Add to pubspec.yaml + +```yaml +isar_version: &isar_version 3.1.0 # define the version to be used + +dependencies: + isar: *isar_version + isar_flutter_libs: *isar_version # contains Isar Core + +dev_dependencies: + isar_generator: *isar_version + build_runner: any +``` + +### 2. Annotate a Collection + +```dart +part 'email.g.dart'; + +@collection +class Email { + Id id = Isar.autoIncrement; // you can also use id = null to auto increment + + @Index(type: IndexType.value) + String? title; + + List? recipients; + + @enumerated + Status status = Status.pending; +} + +@embedded +class Recipient { + String? name; + + String? address; +} + +enum Status { + draft, + pending, + sent, +} +``` + +### 3. Open a database instance + +```dart +final dir = await getApplicationDocumentsDirectory(); +final isar = await Isar.open( + [EmailSchema], + directory: dir.path, +); +``` + +### 4. Query the database + +```dart +final emails = await isar.emails.filter() + .titleContains('awesome', caseSensitive: false) + .sortByStatusDesc() + .limit(10) + .findAll(); +``` + +## Isar Database Inspector + +The Isar Inspector allows you to inspect the Isar instances & collections of your app in real-time. You can execute queries, edit properties, switch between instances and sort the data. + + + +To launch the inspector, just run your Isar app in debug mode and open the Inspector link in the logs. + +## CRUD operations + +All basic crud operations are available via the `IsarCollection`. + +```dart +final newEmail = Email()..title = 'Amazing new database'; + +await isar.writeTxn(() { + await isar.emails.put(newEmail); // insert & update +}); + +final existingEmail = await isar.emails.get(newEmail.id!); // get + +await isar.writeTxn(() { + await isar.emails.delete(existingEmail.id!); // delete +}); +``` + +## Database Queries + +Isar database has a powerful query language that allows you to make use of your indexes, filter distinct objects, use complex `and()`, `or()` and `.xor()` groups, query links and sort the results. + +```dart +final importantEmails = isar.emails + .where() + .titleStartsWith('Important') // use index + .limit(10) + .findAll() + +final specificEmails = isar.emails + .filter() + .recipient((q) => q.nameEqualTo('David')) // query embedded objects + .or() + .titleMatches('*university*', caseSensitive: false) // title containing 'university' (case insensitive) + .findAll() +``` + +## Database Watchers + +With Isar database, you can watch collections, objects, or queries. A watcher is notified after a transaction commits successfully and the target actually changes. +Watchers can be lazy and not reload the data or they can be non-lazy and fetch new results in the background. + +```dart +Stream collectionStream = isar.emails.watchLazy(); + +Stream> queryStream = importantEmails.watch(); + +queryStream.listen((newResult) { + // do UI updates +}) +``` + +## Benchmarks + +Benchmarks only give a rough idea of the performance of a database but as you can see, Isar NoSQL database is quite fast 😇 + +| | | +| ---------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------- | +| | | + +If you are interested in more benchmarks or want to check how Isar performs on your device you can run the [benchmarks](https://github.com/isar/isar_benchmark) yourself. + +## Unit tests + +If you want to use Isar database in unit tests or Dart code, call `await Isar.initializeIsarCore(download: true)` before using Isar in your tests. + +Isar NoSQL database will automatically download the correct binary for your platform. You can also pass a `libraries` map to adjust the download location for each platform. + +Make sure to use `flutter test -j 1` to avoid tests running in parallel. This would break the automatic download. + +## Contributors ✨ + +Big thanks go to these wonderful people: + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Alexis

Burak

Carlo Loguercio

Frostedfox

Hafeez Rana

Hamed H.

JT

Jack Rivers

Joachim Nohl

Johnson

LaLucid

Lety

Michael

Moseco

Nelson Mutane

Peyman

Simon Leier

Ura

blendthink

mnkeis

nobkd
+ + + + + + +### License + +``` +Copyright 2022 Simon Leier + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +``` diff --git a/packages_external/isar-3.1.0-1/packages/isar/analysis_options.yaml b/packages_external/isar-3.1.0-1/packages/isar/analysis_options.yaml new file mode 100644 index 00000000..ee7facbd --- /dev/null +++ b/packages_external/isar-3.1.0-1/packages/isar/analysis_options.yaml @@ -0,0 +1,11 @@ +include: package:very_good_analysis/analysis_options.yaml + +analyzer: + exclude: + - "lib/src/native/bindings.dart" + + errors: + cascade_invocations: ignore + avoid_positional_boolean_parameters: ignore + parameter_assignments: ignore + prefer_asserts_with_message: ignore \ No newline at end of file diff --git a/packages_external/isar-3.1.0-1/packages/isar/example/README.md b/packages_external/isar-3.1.0-1/packages/isar/example/README.md new file mode 100644 index 00000000..e43ff5cc --- /dev/null +++ b/packages_external/isar-3.1.0-1/packages/isar/example/README.md @@ -0,0 +1,3 @@ +## The fastest way to get started is by following the [Quickstart Guide](https://isar.dev/tutorials/quickstart.html)! + +Have fun using Isar! \ No newline at end of file diff --git a/packages_external/isar-3.1.0-1/packages/isar/lib/isar.dart b/packages_external/isar-3.1.0-1/packages/isar/lib/isar.dart new file mode 100644 index 00000000..429086e5 --- /dev/null +++ b/packages_external/isar-3.1.0-1/packages/isar/lib/isar.dart @@ -0,0 +1,49 @@ +library isar; + +import 'dart:async'; +import 'dart:convert'; +import 'dart:developer'; +import 'dart:typed_data'; + +import 'package:isar/src/isar_connect_api.dart'; +import 'package:isar/src/native/isar_core.dart' + if (dart.library.html) 'package:isar/src/web/isar_web.dart'; +import 'package:isar/src/native/isar_link_impl.dart' + if (dart.library.html) 'package:isar/src/web/isar_link_impl.dart'; +import 'package:isar/src/native/open.dart' + if (dart.library.html) 'package:isar/src/web/open.dart'; +import 'package:isar/src/native/split_words.dart' + if (dart.library.html) 'package:isar/src/web/split_words.dart'; +import 'package:meta/meta.dart'; +import 'package:meta/meta_meta.dart'; + +part 'src/annotations/backlink.dart'; +part 'src/annotations/collection.dart'; +part 'src/annotations/embedded.dart'; +part 'src/annotations/enumerated.dart'; +part 'src/annotations/ignore.dart'; +part 'src/annotations/index.dart'; +part 'src/annotations/name.dart'; +part 'src/annotations/type.dart'; +part 'src/isar.dart'; +part 'src/isar_collection.dart'; +part 'src/isar_connect.dart'; +part 'src/isar_error.dart'; +part 'src/isar_link.dart'; +part 'src/isar_reader.dart'; +part 'src/isar_writer.dart'; +part 'src/query.dart'; +part 'src/query_builder.dart'; +part 'src/query_builder_extensions.dart'; +part 'src/query_components.dart'; +part 'src/schema/collection_schema.dart'; +part 'src/schema/index_schema.dart'; +part 'src/schema/link_schema.dart'; +part 'src/schema/property_schema.dart'; +part 'src/schema/schema.dart'; + +/// @nodoc +@protected +typedef IsarUint8List = Uint8List; + +const bool _kIsWeb = identical(0, 0.0); diff --git a/packages_external/isar-3.1.0-1/packages/isar/lib/src/annotations/backlink.dart b/packages_external/isar-3.1.0-1/packages/isar/lib/src/annotations/backlink.dart new file mode 100644 index 00000000..54b0ab2b --- /dev/null +++ b/packages_external/isar-3.1.0-1/packages/isar/lib/src/annotations/backlink.dart @@ -0,0 +1,11 @@ +part of isar; + +/// Annotation to create a backlink to an existing link. +@Target({TargetKind.field}) +class Backlink { + /// Annotation to create a backlink to an existing link. + const Backlink({required this.to}); + + /// The Dart name of the target link. + final String to; +} diff --git a/packages_external/isar-3.1.0-1/packages/isar/lib/src/annotations/collection.dart b/packages_external/isar-3.1.0-1/packages/isar/lib/src/annotations/collection.dart new file mode 100644 index 00000000..979efb02 --- /dev/null +++ b/packages_external/isar-3.1.0-1/packages/isar/lib/src/annotations/collection.dart @@ -0,0 +1,34 @@ +part of isar; + +/// Annotation to create an Isar collection. +const collection = Collection(); + +/// Annotation to create an Isar collection. +@Target({TargetKind.classType}) +class Collection { + /// Annotation to create an Isar collection. + const Collection({ + this.inheritance = true, + this.accessor, + this.ignore = const {}, + }); + + /// Should properties and accessors of parent classes and mixins be included? + final bool inheritance; + + /// Allows you to override the default collection accessor. + /// + /// Example: + /// ```dart + /// @Collection(accessor: 'col') + /// class MyCol { + /// Id? id; + /// } + /// + /// // access collection using: isar.col + /// ``` + final String? accessor; + + /// A list of properties or getter names that Isar should ignore. + final Set ignore; +} diff --git a/packages_external/isar-3.1.0-1/packages/isar/lib/src/annotations/embedded.dart b/packages_external/isar-3.1.0-1/packages/isar/lib/src/annotations/embedded.dart new file mode 100644 index 00000000..d8f5ce93 --- /dev/null +++ b/packages_external/isar-3.1.0-1/packages/isar/lib/src/annotations/embedded.dart @@ -0,0 +1,17 @@ +part of isar; + +/// Annotation to nest objects of this type in collections. +const embedded = Embedded(); + +/// Annotation to nest objects of this type in collections. +@Target({TargetKind.classType}) +class Embedded { + /// Annotation to nest objects of this type in collections. + const Embedded({this.inheritance = true, this.ignore = const {}}); + + /// Should properties and accessors of parent classes and mixins be included? + final bool inheritance; + + /// A list of properties or getter names that Isar should ignore. + final Set ignore; +} diff --git a/packages_external/isar-3.1.0-1/packages/isar/lib/src/annotations/enumerated.dart b/packages_external/isar-3.1.0-1/packages/isar/lib/src/annotations/enumerated.dart new file mode 100644 index 00000000..ade7e5fe --- /dev/null +++ b/packages_external/isar-3.1.0-1/packages/isar/lib/src/annotations/enumerated.dart @@ -0,0 +1,33 @@ +part of isar; + +/// Annotation to specify how an enum property should be serialized. +const enumerated = Enumerated(EnumType.ordinal); + +/// Annotation to specify how an enum property should be serialized. +@Target({TargetKind.field, TargetKind.getter}) +class Enumerated { + /// Annotation to specify how an enum property should be serialized. + const Enumerated(this.type, [this.property]); + + /// How the enum property should be serialized. + final EnumType type; + + /// The property to use for the enum values. + final String? property; +} + +/// Enum type for enum values. +enum EnumType { + /// Stores the index of the enum as a byte value. + ordinal, + + /// Stores the index of the enum as a 4-byte value. Use this type if your enum + /// has more than 256 values or needs to be nullable. + ordinal32, + + /// Uses the name of the enum value. + name, + + /// Uses a custom enum value. + value +} diff --git a/packages_external/isar-3.1.0-1/packages/isar/lib/src/annotations/ignore.dart b/packages_external/isar-3.1.0-1/packages/isar/lib/src/annotations/ignore.dart new file mode 100644 index 00000000..181224ef --- /dev/null +++ b/packages_external/isar-3.1.0-1/packages/isar/lib/src/annotations/ignore.dart @@ -0,0 +1,11 @@ +part of isar; + +/// Annotate a property or accessor in an Isar collection to ignore it. +const ignore = Ignore(); + +/// Annotate a property or accessor in an Isar collection to ignore it. +@Target({TargetKind.field, TargetKind.getter}) +class Ignore { + /// Annotate a property or accessor in an Isar collection to ignore it. + const Ignore(); +} diff --git a/packages_external/isar-3.1.0-1/packages/isar/lib/src/annotations/index.dart b/packages_external/isar-3.1.0-1/packages/isar/lib/src/annotations/index.dart new file mode 100644 index 00000000..62546a92 --- /dev/null +++ b/packages_external/isar-3.1.0-1/packages/isar/lib/src/annotations/index.dart @@ -0,0 +1,76 @@ +part of isar; + +/// Specifies how an index is stored in Isar. +enum IndexType { + /// Stores the value as-is in the index. + value, + + /// Strings or Lists can be hashed to reduce the storage required by the + /// index. The disadvantage of hash indexes is that they can't be used for + /// prefix scans (`startsWith()` where clauses). String and list indexes are + /// hashed by default. + hash, + + /// `List` can hash its elements. + hashElements, +} + +/// Annotate properties to build an index. +@Target({TargetKind.field, TargetKind.getter}) +class Index { + /// Annotate properties to build an index. + const Index({ + this.name, + this.composite = const [], + this.unique = false, + this.replace = false, + this.type, + this.caseSensitive, + }); + + /// Name of the index. By default, the names of the properties are + /// concatenated using "_" + final String? name; + + /// Specify up to two other properties to build a composite index. + final List composite; + + /// A unique index ensures the index does not contain any duplicate values. + /// Any attempt to insert or update data into the unique index that causes a + /// duplicate will result in an error. + final bool unique; + + /// If set to `true`, inserting a duplicate unique value will replace the + /// existing object instead of throwing an error. + final bool replace; + + /// Specifies how an index is stored in Isar. + /// + /// Defaults to: + /// - `IndexType.hash` for `String`s and `List`s + /// - `IndexType.value` for all other types + final IndexType? type; + + /// String or `List` indexes can be case sensitive (default) or case + /// insensitive. + final bool? caseSensitive; +} + +/// Another property that is part of the composite index. +class CompositeIndex { + /// Another property that is part of the composite index. + const CompositeIndex( + this.property, { + this.type, + this.caseSensitive, + }); + + /// Dart name of the property. + final String property; + + /// See [Index.type]. + final IndexType? type; + + /// See [Index.caseSensitive]. + final bool? caseSensitive; +} diff --git a/packages_external/isar-3.1.0-1/packages/isar/lib/src/annotations/name.dart b/packages_external/isar-3.1.0-1/packages/isar/lib/src/annotations/name.dart new file mode 100644 index 00000000..a950ac4c --- /dev/null +++ b/packages_external/isar-3.1.0-1/packages/isar/lib/src/annotations/name.dart @@ -0,0 +1,13 @@ +part of isar; + +/// Annotate Isar collections or properties to change their name. +/// +/// Can be used to change the name in Dart independently of Isar. +@Target({TargetKind.classType, TargetKind.field, TargetKind.getter}) +class Name { + /// Annotate Isar collections or properties to change their name. + const Name(this.name); + + /// The name this entity should have in the database. + final String name; +} diff --git a/packages_external/isar-3.1.0-1/packages/isar/lib/src/annotations/type.dart b/packages_external/isar-3.1.0-1/packages/isar/lib/src/annotations/type.dart new file mode 100644 index 00000000..87322651 --- /dev/null +++ b/packages_external/isar-3.1.0-1/packages/isar/lib/src/annotations/type.dart @@ -0,0 +1,20 @@ +// ignore_for_file: camel_case_types + +part of isar; + +/// Type to specify the id property of a collection. +typedef Id = int; + +/// Type to mark an [int] property or List as 8-bit sized. +/// +/// You may only store values between 0 and 255 in such a property. +typedef byte = int; + +/// Type to mark an [int] property or List as 32-bit sized. +/// +/// You may only store values between -2147483648 and 2147483647 in such a +/// property. +typedef short = int; + +/// Type to mark a [double] property or List to have 32-bit precision. +typedef float = double; diff --git a/packages_external/isar-3.1.0-1/packages/isar/lib/src/common/isar_common.dart b/packages_external/isar-3.1.0-1/packages/isar/lib/src/common/isar_common.dart new file mode 100644 index 00000000..ea0873e3 --- /dev/null +++ b/packages_external/isar-3.1.0-1/packages/isar/lib/src/common/isar_common.dart @@ -0,0 +1,222 @@ +// ignore_for_file: invalid_use_of_protected_member + +import 'dart:async'; + +import 'package:isar/isar.dart'; + +const Symbol _zoneTxn = #zoneTxn; + +/// @nodoc +abstract class IsarCommon extends Isar { + /// @nodoc + IsarCommon(super.name); + + final List> _activeAsyncTxns = []; + var _asyncWriteTxnsActive = 0; + + Transaction? _currentTxnSync; + + void _requireNotInTxn() { + if (_currentTxnSync != null || Zone.current[_zoneTxn] != null) { + throw IsarError( + 'Cannot perform this operation from within an active transaction. ' + 'Isar does not support nesting transactions.', + ); + } + } + + /// @nodoc + Future beginTxn(bool write, bool silent); + + Future _beginTxn( + bool write, + bool silent, + Future Function() callback, + ) async { + requireOpen(); + _requireNotInTxn(); + + final completer = Completer(); + _activeAsyncTxns.add(completer.future); + + try { + if (write) { + _asyncWriteTxnsActive++; + } + + final txn = await beginTxn(write, silent); + + final zone = Zone.current.fork( + zoneValues: {_zoneTxn: txn}, + ); + + T result; + try { + result = await zone.run(callback); + await txn.commit(); + } catch (e) { + await txn.abort(); + rethrow; + } finally { + txn.free(); + } + return result; + } finally { + completer.complete(); + _activeAsyncTxns.remove(completer.future); + if (write) { + _asyncWriteTxnsActive--; + } + } + } + + @override + Future txn(Future Function() callback) { + return _beginTxn(false, false, callback); + } + + @override + Future writeTxn(Future Function() callback, {bool silent = false}) { + return _beginTxn(true, silent, callback); + } + + /// @nodoc + Future getTxn( + bool write, + Future Function(T txn) callback, + ) { + final currentTxn = Zone.current[_zoneTxn] as T?; + if (currentTxn != null) { + if (!currentTxn.active) { + throw IsarError('Transaction is not active anymore. Make sure to await ' + 'all your asynchronous code within transactions to prevent it from ' + 'being closed prematurely.'); + } else if (write && !currentTxn.write) { + throw IsarError('Operation cannot be performed within a read ' + 'transaction. Use isar.writeTxn() instead.'); + } else if (currentTxn.isar != this) { + throw IsarError('Transaction does not match Isar instance. ' + 'Make sure to use transactions from the same Isar instance.'); + } + return callback(currentTxn); + } else if (!write) { + return _beginTxn(false, false, () { + return callback(Zone.current[_zoneTxn] as T); + }); + } else { + throw IsarError('Write operations require an explicit transaction. ' + 'Wrap your code in isar.writeTxn()'); + } + } + + /// @nodoc + Transaction beginTxnSync(bool write, bool silent); + + T _beginTxnSync(bool write, bool silent, T Function() callback) { + requireOpen(); + _requireNotInTxn(); + + if (write && _asyncWriteTxnsActive > 0) { + throw IsarError( + 'An async write transaction is already in progress in this isolate. ' + 'You cannot begin a sync write transaction until it is finished. ' + 'Use asynchroneous transactions if you want to queue multiple write ' + 'transactions.', + ); + } + + final txn = beginTxnSync(write, silent); + _currentTxnSync = txn; + + T result; + try { + result = callback(); + txn.commitSync(); + } catch (e) { + txn.abortSync(); + rethrow; + } finally { + _currentTxnSync = null; + txn.free(); + } + + return result; + } + + @override + T txnSync(T Function() callback) { + return _beginTxnSync(false, false, callback); + } + + @override + T writeTxnSync(T Function() callback, {bool silent = false}) { + return _beginTxnSync(true, silent, callback); + } + + /// @nodoc + R getTxnSync( + bool write, + R Function(T txn) callback, + ) { + if (_currentTxnSync != null) { + if (write && !_currentTxnSync!.write) { + throw IsarError( + 'Operation cannot be performed within a read transaction. ' + 'Use isar.writeTxnSync() instead.', + ); + } + return callback(_currentTxnSync! as T); + } else if (!write) { + return _beginTxnSync(false, false, () => callback(_currentTxnSync! as T)); + } else { + throw IsarError('Write operations require an explicit transaction. ' + 'Wrap your code in isar.writeTxnSync()'); + } + } + + @override + Future close({bool deleteFromDisk = false}) async { + requireOpen(); + _requireNotInTxn(); + await Future.wait(_activeAsyncTxns); + await super.close(); + + return performClose(deleteFromDisk); + } + + /// @nodoc + bool performClose(bool deleteFromDisk); +} + +/// @nodoc +abstract class Transaction { + /// @nodoc + Transaction(this.isar, this.sync, this.write); + + /// @nodoc + final Isar isar; + + /// @nodoc + final bool sync; + + /// @nodoc + final bool write; + + /// @nodoc + bool get active; + + /// @nodoc + Future commit(); + + /// @nodoc + void commitSync(); + + /// @nodoc + Future abort(); + + /// @nodoc + void abortSync(); + + /// @nodoc + void free() {} +} diff --git a/packages_external/isar-3.1.0-1/packages/isar/lib/src/common/isar_link_base_impl.dart b/packages_external/isar-3.1.0-1/packages/isar/lib/src/common/isar_link_base_impl.dart new file mode 100644 index 00000000..1a19192d --- /dev/null +++ b/packages_external/isar-3.1.0-1/packages/isar/lib/src/common/isar_link_base_impl.dart @@ -0,0 +1,108 @@ +import 'package:isar/isar.dart'; + +/// @nodoc +abstract class IsarLinkBaseImpl implements IsarLinkBase { + var _initialized = false; + + Id? _objectId; + + /// The isar name of the link + late final String linkName; + + /// The origin collection of the link. For backlinks it is actually the target + /// collection. + late final IsarCollection sourceCollection; + + /// The target collection of the link. For backlinks it is actually the origin + /// collection. + late final IsarCollection targetCollection; + + @override + bool get isAttached => _objectId != null; + + @override + void attach( + IsarCollection sourceCollection, + IsarCollection targetCollection, + String linkName, + Id? objectId, + ) { + if (_initialized) { + if (linkName != this.linkName || + !identical(sourceCollection, this.sourceCollection) || + !identical(targetCollection, this.targetCollection)) { + throw IsarError( + 'Link has been moved! It is not allowed to move ' + 'a link to a different collection.', + ); + } + } else { + _initialized = true; + this.sourceCollection = sourceCollection; + this.targetCollection = targetCollection; + this.linkName = linkName; + } + + _objectId = objectId; + } + + /// Returns the containing object's id or throws an exception if this link has + /// not been attached to an object yet. + Id requireAttached() { + if (_objectId == null) { + throw IsarError( + 'Containing object needs to be managed by Isar to use this method. ' + 'Use collection.put(yourObject) to add it to the database.', + ); + } else { + return _objectId!; + } + } + + /// Returns the id of a linked object. + Id Function(OBJ obj) get getId; + + /// Returns the id of a linked object or throws an exception if the id is + /// `null` or set to `Isar.autoIncrement`. + Id requireGetId(OBJ object) { + final id = getId(object); + if (id != Isar.autoIncrement) { + return id; + } else { + throw IsarError( + 'Object "$object" has no id and can therefore not be linked. ' + 'Make sure to .put() objects before you use them in links.', + ); + } + } + + /// See [IsarLinks.filter]. + QueryBuilder filter() { + final containingId = requireAttached(); + final qb = QueryBuilderInternal( + collection: targetCollection, + whereClauses: [ + LinkWhereClause( + linkCollection: sourceCollection.name, + linkName: linkName, + id: containingId, + ), + ], + ); + return QueryBuilder(qb); + } + + /// See [IsarLinks.update]. + Future update({ + Iterable link = const [], + Iterable unlink = const [], + bool reset = false, + }); + + /// See [IsarLinks.updateSync]. + void updateSync({ + Iterable link = const [], + Iterable unlink = const [], + bool reset = false, + }); +} diff --git a/packages_external/isar-3.1.0-1/packages/isar/lib/src/common/isar_link_common.dart b/packages_external/isar-3.1.0-1/packages/isar/lib/src/common/isar_link_common.dart new file mode 100644 index 00000000..410ccd3b --- /dev/null +++ b/packages_external/isar-3.1.0-1/packages/isar/lib/src/common/isar_link_common.dart @@ -0,0 +1,92 @@ +import 'package:isar/isar.dart'; +import 'package:isar/src/common/isar_link_base_impl.dart'; + +const bool _kIsWeb = identical(0, 0.0); + +/// @nodoc +abstract class IsarLinkCommon extends IsarLinkBaseImpl + with IsarLink { + OBJ? _value; + + @override + bool isChanged = false; + + @override + bool isLoaded = false; + + @override + OBJ? get value { + if (isAttached && !isLoaded && !isChanged && !_kIsWeb) { + loadSync(); + } + return _value; + } + + @override + set value(OBJ? value) { + isChanged |= !identical(_value, value); + _value = value; + isLoaded = true; + } + + @override + Future load() async { + _value = await filter().findFirst(); + isChanged = false; + isLoaded = true; + } + + @override + void loadSync() { + _value = filter().findFirstSync(); + isChanged = false; + isLoaded = true; + } + + @override + Future save() async { + if (!isChanged) { + return; + } + + final object = value; + + await update(link: [if (object != null) object], reset: true); + isChanged = false; + isLoaded = true; + } + + @override + void saveSync() { + if (!isChanged) { + return; + } + + final object = _value; + updateSync(link: [if (object != null) object], reset: true); + + isChanged = false; + isLoaded = true; + } + + @override + Future reset() async { + await update(reset: true); + _value = null; + isChanged = false; + isLoaded = true; + } + + @override + void resetSync() { + updateSync(reset: true); + _value = null; + isChanged = false; + isLoaded = true; + } + + @override + String toString() { + return 'IsarLink($_value)'; + } +} diff --git a/packages_external/isar-3.1.0-1/packages/isar/lib/src/common/isar_links_common.dart b/packages_external/isar-3.1.0-1/packages/isar/lib/src/common/isar_links_common.dart new file mode 100644 index 00000000..98975b76 --- /dev/null +++ b/packages_external/isar-3.1.0-1/packages/isar/lib/src/common/isar_links_common.dart @@ -0,0 +1,223 @@ +import 'dart:collection'; + +import 'package:isar/isar.dart'; +import 'package:isar/src/common/isar_link_base_impl.dart'; + +const bool _kIsWeb = identical(0, 0.0); + +/// @nodoc +abstract class IsarLinksCommon extends IsarLinkBaseImpl + with IsarLinks, SetMixin { + final _objects = {}; + + /// @nodoc + final addedObjects = HashSet.identity(); + + /// @nodoc + final removedObjects = HashSet.identity(); + + @override + bool isLoaded = false; + + @override + bool get isChanged => addedObjects.isNotEmpty || removedObjects.isNotEmpty; + + Map get _loadedObjects { + if (isAttached && !isLoaded && !_kIsWeb) { + loadSync(); + } + return _objects; + } + + @override + void attach( + IsarCollection sourceCollection, + IsarCollection targetCollection, + String linkName, + Id? objectId, + ) { + super.attach(sourceCollection, targetCollection, linkName, objectId); + + _applyAddedRemoved(); + } + + @override + Future load({bool overrideChanges = false}) async { + final objects = await filter().findAll(); + _applyLoaded(objects, overrideChanges); + } + + @override + void loadSync({bool overrideChanges = false}) { + final objects = filter().findAllSync(); + _applyLoaded(objects, overrideChanges); + } + + void _applyLoaded(List objects, bool overrideChanges) { + _objects.clear(); + for (final object in objects) { + final id = getId(object); + if (id != Isar.autoIncrement) { + _objects[id] = object; + } + } + + if (overrideChanges) { + addedObjects.clear(); + removedObjects.clear(); + } else { + _applyAddedRemoved(); + } + + isLoaded = true; + } + + void _applyAddedRemoved() { + for (final object in addedObjects) { + final id = getId(object); + if (id != Isar.autoIncrement) { + _objects[id] = object; + } + } + + for (final object in removedObjects) { + final id = getId(object); + if (id != Isar.autoIncrement) { + _objects.remove(id); + } + } + } + + @override + Future save() async { + if (!isChanged) { + return; + } + + await update(link: addedObjects, unlink: removedObjects); + + addedObjects.clear(); + removedObjects.clear(); + isLoaded = true; + } + + @override + void saveSync() { + if (!isChanged) { + return; + } + + updateSync(link: addedObjects, unlink: removedObjects); + + addedObjects.clear(); + removedObjects.clear(); + isLoaded = true; + } + + @override + Future reset() async { + await update(reset: true); + clear(); + isLoaded = true; + } + + @override + void resetSync() { + updateSync(reset: true); + clear(); + isLoaded = true; + } + + @override + bool add(OBJ value) { + if (isAttached) { + final id = getId(value); + if (id != Isar.autoIncrement) { + if (_objects.containsKey(id)) { + return false; + } + _objects[id] = value; + } + } + + removedObjects.remove(value); + return addedObjects.add(value); + } + + @override + bool contains(Object? element) { + requireAttached(); + + if (element is OBJ) { + final id = getId(element); + if (id != Isar.autoIncrement) { + return _loadedObjects.containsKey(id); + } + } + return false; + } + + @override + Iterator get iterator => _loadedObjects.values.iterator; + + @override + int get length => _loadedObjects.length; + + @override + OBJ? lookup(Object? element) { + requireAttached(); + + if (element is OBJ) { + final id = getId(element); + if (id != Isar.autoIncrement) { + return _loadedObjects[id]; + } + } + return null; + } + + @override + bool remove(Object? value) { + if (value is! OBJ) { + return false; + } + + if (isAttached) { + final id = getId(value); + if (id != Isar.autoIncrement) { + if (isLoaded && !_objects.containsKey(id)) { + return false; + } + _objects.remove(id); + } + } + + addedObjects.remove(value); + return removedObjects.add(value); + } + + @override + Set toSet() { + requireAttached(); + return HashSet( + equals: (o1, o2) => getId(o1) == getId(o2), + // ignore: noop_primitive_operations + hashCode: (o) => getId(o).toInt(), + isValidKey: (o) => o is OBJ && getId(o) != Isar.autoIncrement, + )..addAll(_loadedObjects.values); + } + + @override + void clear() { + _objects.clear(); + addedObjects.clear(); + removedObjects.clear(); + } + + @override + String toString() { + final content = + IterableBase.iterableToFullString(_objects.values, '{', '}'); + return 'IsarLinks($content)'; + } +} diff --git a/packages_external/isar-3.1.0-1/packages/isar/lib/src/common/schemas.dart b/packages_external/isar-3.1.0-1/packages/isar/lib/src/common/schemas.dart new file mode 100644 index 00000000..06085d81 --- /dev/null +++ b/packages_external/isar-3.1.0-1/packages/isar/lib/src/common/schemas.dart @@ -0,0 +1,13 @@ +import 'package:isar/isar.dart'; + +/// @nodoc +List> getSchemas( + List> collectionSchemas, +) { + final schemas = >{}; + for (final collectionSchema in collectionSchemas) { + schemas.add(collectionSchema); + schemas.addAll(collectionSchema.embeddedSchemas.values); + } + return schemas.toList(); +} diff --git a/packages_external/isar-3.1.0-1/packages/isar/lib/src/isar.dart b/packages_external/isar-3.1.0-1/packages/isar/lib/src/isar.dart new file mode 100644 index 00000000..a67ed718 --- /dev/null +++ b/packages_external/isar-3.1.0-1/packages/isar/lib/src/isar.dart @@ -0,0 +1,347 @@ +part of isar; + +/// Callback for a newly opened Isar instance. +typedef IsarOpenCallback = void Function(Isar isar); + +/// Callback for a release Isar instance. +typedef IsarCloseCallback = void Function(String isarName); + +/// An instance of the Isar Database. +abstract class Isar { + /// @nodoc + @protected + Isar(this.name) { + _instances[name] = this; + for (final callback in _openCallbacks) { + callback(this); + } + } + + /// The version of the Isar library. + static const version = '3.1.0+1'; + + /// Smallest valid id. + static const Id minId = isarMinId; + + /// Largest valid id. + static const Id maxId = isarMaxId; + + /// The default Isar instance name. + static const String defaultName = 'default'; + + /// The default max Isar size. + static const int defaultMaxSizeMiB = 1024; + + /// Placeholder for an auto-increment id. + static const Id autoIncrement = isarAutoIncrementId; + + static final Map _instances = {}; + static final Set _openCallbacks = {}; + static final Set _closeCallbacks = {}; + + /// Name of the instance. + final String name; + + /// The directory containing the database file or `null` on the web. + String? get directory; + + /// The full path of the database file is `directory/name.isar` and the lock + /// file `directory/name.isar.lock`. + String? get path => directory != null ? '$directory/$name.isar' : null; + + late final Map> _collections; + late final Map> _collectionsByName; + + bool _isOpen = true; + + static void _checkOpen(String name, List> schemas) { + if (name.isEmpty || name.startsWith('_')) { + throw IsarError('Instance names must not be empty or start with "_".'); + } + if (_instances.containsKey(name)) { + throw IsarError('Instance has already been opened.'); + } + if (schemas.isEmpty) { + throw IsarError('At least one collection needs to be opened.'); + } + + final schemaNames = {}; + for (final schema in schemas) { + if (!schemaNames.add(schema.name)) { + throw IsarError('Duplicate collection ${schema.name}.'); + } + } + for (final schema in schemas) { + final dependencies = schema.links.values.map((e) => e.target); + for (final dependency in dependencies) { + if (!schemaNames.contains(dependency)) { + throw IsarError( + "Collection ${schema.name} depends on $dependency but it's schema " + 'was not provided.', + ); + } + } + } + } + + /// Open a new Isar instance. + static Future open( + List> schemas, { + required String directory, + String name = defaultName, + int maxSizeMiB = Isar.defaultMaxSizeMiB, + bool relaxedDurability = true, + CompactCondition? compactOnLaunch, + bool inspector = true, + }) { + _checkOpen(name, schemas); + + /// Tree shake the inspector for profile and release builds. + assert(() { + if (!_kIsWeb && inspector) { + _IsarConnect.initialize(schemas); + } + return true; + }()); + + return openIsar( + schemas: schemas, + directory: directory, + name: name, + maxSizeMiB: maxSizeMiB, + relaxedDurability: relaxedDurability, + compactOnLaunch: compactOnLaunch, + ); + } + + /// Open a new Isar instance. + static Isar openSync( + List> schemas, { + required String directory, + String name = defaultName, + int maxSizeMiB = Isar.defaultMaxSizeMiB, + bool relaxedDurability = true, + CompactCondition? compactOnLaunch, + bool inspector = true, + }) { + _checkOpen(name, schemas); + + /// Tree shake the inspector for profile and release builds. + assert(() { + if (!_kIsWeb && inspector) { + _IsarConnect.initialize(schemas); + } + return true; + }()); + + return openIsarSync( + schemas: schemas, + directory: directory, + name: name, + maxSizeMiB: maxSizeMiB, + relaxedDurability: relaxedDurability, + compactOnLaunch: compactOnLaunch, + ); + } + + /// Is the instance open? + bool get isOpen => _isOpen; + + /// @nodoc + @protected + void requireOpen() { + if (!isOpen) { + throw IsarError('Isar instance has already been closed'); + } + } + + /// Executes an asynchronous read-only transaction. + Future txn(Future Function() callback); + + /// Executes an asynchronous read-write transaction. + /// + /// If [silent] is `true`, watchers are not notified about changes in this + /// transaction. + Future writeTxn(Future Function() callback, {bool silent = false}); + + /// Executes a synchronous read-only transaction. + T txnSync(T Function() callback); + + /// Executes a synchronous read-write transaction. + /// + /// If [silent] is `true`, watchers are not notified about changes in this + /// transaction. + T writeTxnSync(T Function() callback, {bool silent = false}); + + /// @nodoc + @protected + void attachCollections(Map> collections) { + _collections = collections; + _collectionsByName = { + for (IsarCollection col in collections.values) col.name: col, + }; + } + + /// Get a collection by its type. + /// + /// You should use the generated extension methods instead. + IsarCollection collection() { + requireOpen(); + final collection = _collections[T]; + if (collection == null) { + throw IsarError('Missing ${T.runtimeType}Schema in Isar.open'); + } + return collection as IsarCollection; + } + + /// @nodoc + @protected + IsarCollection? getCollectionByNameInternal(String name) { + return _collectionsByName[name]; + } + + /// Remove all data in this instance and reset the auto increment values. + Future clear() async { + for (final col in _collections.values) { + await col.clear(); + } + } + + /// Remove all data in this instance and reset the auto increment values. + void clearSync() { + for (final col in _collections.values) { + col.clearSync(); + } + } + + /// Returns the size of all the collections in bytes. Not supported on web. + /// + /// This method is extremely fast and independent of the number of objects in + /// the instance. + Future getSize({bool includeIndexes = false, bool includeLinks = false}); + + /// Returns the size of all collections in bytes. Not supported on web. + /// + /// This method is extremely fast and independent of the number of objects in + /// the instance. + int getSizeSync({bool includeIndexes = false, bool includeLinks = false}); + + /// Copy a compacted version of the database to the specified file. + /// + /// If you want to backup your database, you should always use a compacted + /// version. Compacted does not mean compressed. + /// + /// Do not run this method while other transactions are active to avoid + /// unnecessary growth of the database. + Future copyToFile(String targetPath); + + /// Releases an Isar instance. + /// + /// If this is the only isolate that holds a reference to this instance, the + /// Isar instance will be closed. [deleteFromDisk] additionally removes all + /// database files if enabled. + /// + /// Returns whether the instance was actually closed. + Future close({bool deleteFromDisk = false}) { + requireOpen(); + _isOpen = false; + if (identical(_instances[name], this)) { + _instances.remove(name); + } + for (final callback in _closeCallbacks) { + callback(name); + } + return Future.value(false); + } + + /// Verifies the integrity of the database file. + /// + /// Do not use this method in production apps. + @visibleForTesting + @experimental + Future verify(); + + /// A list of all Isar instances opened in the current isolate. + static Set get instanceNames => _instances.keys.toSet(); + + /// Returns an Isar instance opened in the current isolate by its name. If + /// no name is provided, the default instance is returned. + static Isar? getInstance([String name = defaultName]) { + return _instances[name]; + } + + /// Registers a listener that is called whenever an Isar instance is opened. + static void addOpenListener(IsarOpenCallback callback) { + _openCallbacks.add(callback); + } + + /// Removes a previously registered `IsarOpenCallback`. + static void removeOpenListener(IsarOpenCallback callback) { + _openCallbacks.remove(callback); + } + + /// Registers a listener that is called whenever an Isar instance is + /// released. + static void addCloseListener(IsarCloseCallback callback) { + _closeCallbacks.add(callback); + } + + /// Removes a previously registered `IsarOpenCallback`. + static void removeCloseListener(IsarCloseCallback callback) { + _closeCallbacks.remove(callback); + } + + /// Initialize Isar Core manually. You need to provide Isar Core libraries + /// for every platform your app will run on. + /// + /// If [download] is `true`, Isar will attempt to download the correct + /// library and place it in the specified path or the script directory. + /// + /// Be careful if multiple unit tests try to download the library at the + /// same time. Always use `flutter test -j 1` when you rely on auto + /// downloading to ensure that only one test is running at a time. + /// + /// Only use this method for non-Flutter code or unit tests. + static Future initializeIsarCore({ + Map libraries = const {}, + bool download = false, + }) async { + await initializeCoreBinary( + libraries: libraries, + download: download, + ); + } + + /// Split a String into words according to Unicode Annex #29. Only words + /// containing at least one alphanumeric character will be included. + static List splitWords(String input) => isarSplitWords(input); +} + +/// Isar databases can contain unused space that will be reused for later +/// operations. You can specify conditions to trigger manual compaction where +/// the entire database is copied and unused space freed. +/// +/// This operation can only be performed while a database is being opened and +/// should only be used if absolutely necessary. +class CompactCondition { + /// Compaction will happen if all of the specified conditions are true. + const CompactCondition({ + this.minFileSize, + this.minBytes, + this.minRatio, + }) : assert( + minFileSize != null || minBytes != null || minRatio != null, + 'At least one condition needs to be specified.', + ); + + /// The minimum size in bytes of the database file to trigger compaction. It + /// is highly discouraged to trigger compaction solely on this condition. + final int? minFileSize; + + /// The minimum number of bytes that can be freed with compaction. + final int? minBytes; + + /// The minimum compaction ration. For example `2.0` would trigger compaction + /// as soon as the file size can be halved. + final double? minRatio; +} diff --git a/packages_external/isar-3.1.0-1/packages/isar/lib/src/isar_collection.dart b/packages_external/isar-3.1.0-1/packages/isar/lib/src/isar_collection.dart new file mode 100644 index 00000000..2d2b8142 --- /dev/null +++ b/packages_external/isar-3.1.0-1/packages/isar/lib/src/isar_collection.dart @@ -0,0 +1,342 @@ +part of isar; + +/// Normal keys consist of a single object, composite keys multiple. +typedef IndexKey = List; + +/// Use `IsarCollection` instances to find, query, and create new objects of a +/// given type in Isar. +/// +/// You can get an instance of `IsarCollection` by calling `isar.get()` or +/// by using the generated `isar.yourCollections` getter. +abstract class IsarCollection { + /// The corresponding Isar instance. + Isar get isar; + + /// Get the schema of the collection. + CollectionSchema get schema; + + /// The name of the collection. + String get name => schema.name; + + /// {@template col_get} + /// Get a single object by its [id] or `null` if the object does not exist. + /// {@endtemplate} + Future get(Id id) { + return getAll([id]).then((List objects) => objects[0]); + } + + /// {@macro col_get} + OBJ? getSync(Id id) { + return getAllSync([id])[0]; + } + + /// {@template col_get_all} + /// Get a list of objects by their [ids] or `null` if an object does not + /// exist. + /// {@endtemplate} + Future> getAll(List ids); + + /// {@macro col_get_all} + List getAllSync(List ids); + + /// {@template col_get_by_index} + /// Get a single object by the unique index [indexName] and [key]. + /// + /// Returns `null` if the object does not exist. + /// + /// If possible, you should use the generated type-safe methods instead. + /// {@endtemplate} + @experimental + Future getByIndex(String indexName, IndexKey key) { + return getAllByIndex(indexName, [key]) + .then((List objects) => objects[0]); + } + + /// {@macro col_get_by_index} + @experimental + OBJ? getByIndexSync(String indexName, IndexKey key) { + return getAllByIndexSync(indexName, [key])[0]; + } + + /// {@template col_get_all_by_index} + /// Get a list of objects by the unique index [indexName] and [keys]. + /// + /// Returns `null` if the object does not exist. + /// + /// If possible, you should use the generated type-safe methods instead. + /// {@endtemplate} + @experimental + Future> getAllByIndex(String indexName, List keys); + + /// {@macro col_get_all_by_index}' + @experimental + List getAllByIndexSync(String indexName, List keys); + + /// {@template col_put} + /// Insert or update an [object]. Returns the id of the new or updated object. + /// + /// If the object has an non-final id property, it will be set to the assigned + /// id. Otherwise you should use the returned id to update the object. + /// {@endtemplate} + Future put(OBJ object) { + return putAll([object]).then((List ids) => ids[0]); + } + + /// {@macro col_put} + Id putSync(OBJ object, {bool saveLinks = true}) { + return putAllSync([object], saveLinks: saveLinks)[0]; + } + + /// {@template col_put_all} + /// Insert or update a list of [objects]. Returns the list of ids of the new + /// or updated objects. + /// + /// If the objects have an non-final id property, it will be set to the + /// assigned id. Otherwise you should use the returned ids to update the + /// objects. + /// {@endtemplate} + Future> putAll(List objects); + + /// {@macro col_put_all} + List putAllSync(List objects, {bool saveLinks = true}); + + /// {@template col_put_by_index} + /// Insert or update the [object] by the unique index [indexName]. Returns the + /// id of the new or updated object. + /// + /// If there is already an object with the same index key, it will be + /// updated and all links will be preserved. Otherwise a new object will be + /// inserted. + /// + /// If the object has an non-final id property, it will be set to the assigned + /// id. Otherwise you should use the returned id to update the object. + /// + /// If possible, you should use the generated type-safe methods instead. + /// {@endtemplate} + @experimental + Future putByIndex(String indexName, OBJ object) { + return putAllByIndex(indexName, [object]).then((List ids) => ids[0]); + } + + /// {@macro col_put_by_index} + @experimental + Id putByIndexSync(String indexName, OBJ object, {bool saveLinks = true}) { + return putAllByIndexSync(indexName, [object])[0]; + } + + /// {@template col_put_all_by_index} + /// Insert or update a list of [objects] by the unique index [indexName]. + /// Returns the list of ids of the new or updated objects. + /// + /// If there is already an object with the same index key, it will be + /// updated and all links will be preserved. Otherwise a new object will be + /// inserted. + /// + /// If the objects have an non-final id property, it will be set to the + /// assigned id. Otherwise you should use the returned ids to update the + /// objects. + /// + /// If possible, you should use the generated type-safe methods instead. + /// {@endtemplate} + @experimental + Future> putAllByIndex(String indexName, List objects); + + /// {@macro col_put_all_by_index} + @experimental + List putAllByIndexSync( + String indexName, + List objects, { + bool saveLinks = true, + }); + + /// {@template col_delete} + /// Delete a single object by its [id]. + /// + /// Returns whether the object has been deleted. Isar web always returns + /// `true`. + /// {@endtemplate} + Future delete(Id id) { + return deleteAll([id]).then((int count) => count == 1); + } + + /// {@macro col_delete} + bool deleteSync(Id id) { + return deleteAllSync([id]) == 1; + } + + /// {@template col_delete_all} + /// Delete a list of objects by their [ids]. + /// + /// Returns the number of objects that have been deleted. Isar web always + /// returns `ids.length`. + /// {@endtemplate} + Future deleteAll(List ids); + + /// {@macro col_delete_all} + int deleteAllSync(List ids); + + /// {@template col_delete_by_index} + /// Delete a single object by the unique index [indexName] and [key]. + /// + /// Returns whether the object has been deleted. Isar web always returns + /// `true`. + /// {@endtemplate} + @experimental + Future deleteByIndex(String indexName, IndexKey key) { + return deleteAllByIndex(indexName, [key]).then((int count) => count == 1); + } + + /// {@macro col_delete_by_index} + @experimental + bool deleteByIndexSync(String indexName, IndexKey key) { + return deleteAllByIndexSync(indexName, [key]) == 1; + } + + /// {@template col_delete_all_by_index} + /// Delete a list of objects by the unique index [indexName] and [keys]. + /// + /// Returns the number of objects that have been deleted. Isar web always + /// returns `keys.length`. + /// {@endtemplate} + @experimental + Future deleteAllByIndex(String indexName, List keys); + + /// {@macro col_delete_all_by_index} + @experimental + int deleteAllByIndexSync(String indexName, List keys); + + /// {@template col_clear} + /// Remove all data in this collection and reset the auto increment value. + /// {@endtemplate} + Future clear(); + + /// {@macro col_clear} + void clearSync(); + + /// {@template col_import_json_raw} + /// Import a list of json objects encoded as a byte array. + /// + /// The json objects must have the same structure as the objects in this + /// collection. Otherwise an exception will be thrown. + /// {@endtemplate} + Future importJsonRaw(Uint8List jsonBytes); + + /// {@macro col_import_json_raw} + void importJsonRawSync(Uint8List jsonBytes); + + /// {@template col_import_json} + /// Import a list of json objects. + /// + /// The json objects must have the same structure as the objects in this + /// collection. Otherwise an exception will be thrown. + /// {@endtemplate} + Future importJson(List> json); + + /// {@macro col_import_json} + void importJsonSync(List> json); + + /// Start building a query using the [QueryBuilder]. + /// + /// You can use where clauses to only return [distinct] results. If you want + /// to reverse the order, set [sort] to [Sort.desc]. + QueryBuilder where({ + bool distinct = false, + Sort sort = Sort.asc, + }) { + final qb = QueryBuilderInternal( + collection: this, + whereDistinct: distinct, + whereSort: sort, + ); + return QueryBuilder(qb); + } + + /// Start building a query using the [QueryBuilder]. + /// + /// Shortcut if you don't want to use where clauses. + QueryBuilder filter() => where().filter(); + + /// Build a query dynamically for example to build a custom query language. + /// + /// It is highly discouraged to use this method. Only in very special cases + /// should it be used. If you open an issue please always mention that you + /// used this method. + /// + /// The type argument [R] needs to be equal to [OBJ] if no [property] is + /// specified. Otherwise it should be the type of the property. + @experimental + Query buildQuery({ + List whereClauses = const [], + bool whereDistinct = false, + Sort whereSort = Sort.asc, + FilterOperation? filter, + List sortBy = const [], + List distinctBy = const [], + int? offset, + int? limit, + String? property, + }); + + /// {@template col_count} + /// Returns the total number of objects in this collection. + /// + /// For non-web apps, this method is extremely fast and independent of the + /// number of objects in the collection. + /// {@endtemplate} + Future count(); + + /// {@macro col_count} + int countSync(); + + /// {@template col_size} + /// Returns the size of the collection in bytes. Not supported on web. + /// + /// For non-web apps, this method is extremely fast and independent of the + /// number of objects in the collection. + /// {@endtemplate} + Future getSize({bool includeIndexes = false, bool includeLinks = false}); + + /// {@macro col_size} + int getSizeSync({bool includeIndexes = false, bool includeLinks = false}); + + /// Watch the collection for changes. + /// + /// If [fireImmediately] is `true`, an event will be fired immediately. + Stream watchLazy({bool fireImmediately = false}); + + /// Watch the object with [id] for changes. If a change occurs, the new object + /// will be returned in the stream. + /// + /// Objects that don't exist (yet) can also be watched. If [fireImmediately] + /// is `true`, the object will be sent to the consumer immediately. + Stream watchObject(Id id, {bool fireImmediately = false}); + + /// Watch the object with [id] for changes. + /// + /// If [fireImmediately] is `true`, an event will be fired immediately. + Stream watchObjectLazy(Id id, {bool fireImmediately = false}); + + /// Verifies the integrity of the collection and its indexes. + /// + /// Throws an exception if the collection does not contain exactly the + /// provided [objects]. + /// + /// Do not use this method in production apps. + @visibleForTesting + @experimental + Future verify(List objects); + + /// Verifies the integrity of a link. + /// + /// Throws an exception if not exactly [sourceIds] as linked to the + /// [targetIds]. + /// + /// Do not use this method in production apps. + @visibleForTesting + @experimental + Future verifyLink( + String linkName, + List sourceIds, + List targetIds, + ); +} diff --git a/packages_external/isar-3.1.0-1/packages/isar/lib/src/isar_connect.dart b/packages_external/isar-3.1.0-1/packages/isar/lib/src/isar_connect.dart new file mode 100644 index 00000000..b6eee88a --- /dev/null +++ b/packages_external/isar-3.1.0-1/packages/isar/lib/src/isar_connect.dart @@ -0,0 +1,263 @@ +// coverage:ignore-file +// ignore_for_file: avoid_print + +part of isar; + +abstract class _IsarConnect { + static const Map Function(Map _)> _handlers = { + ConnectAction.getSchema: _getSchema, + ConnectAction.listInstances: _listInstances, + ConnectAction.watchInstance: _watchInstance, + ConnectAction.executeQuery: _executeQuery, + ConnectAction.removeQuery: _removeQuery, + ConnectAction.importJson: _importJson, + ConnectAction.exportJson: _exportJson, + ConnectAction.editProperty: _editProperty, + }; + + static List>? _schemas; + + // ignore: cancel_subscriptions + static final _querySubscription = >[]; + static final List> _collectionSubscriptions = + >[]; + + static void initialize(List> schemas) { + if (_schemas != null) { + return; + } + _schemas = schemas; + + Isar.addOpenListener((_) { + postEvent(ConnectEvent.instancesChanged.event, {}); + }); + + Isar.addCloseListener((_) { + postEvent(ConnectEvent.instancesChanged.event, {}); + }); + + for (final handler in _handlers.entries) { + registerExtension(handler.key.method, + (String method, Map parameters) async { + try { + final args = parameters.containsKey('args') + ? jsonDecode(parameters['args']!) as Map + : {}; + final result = {'result': await handler.value(args)}; + return ServiceExtensionResponse.result(jsonEncode(result)); + } catch (e) { + return ServiceExtensionResponse.error( + ServiceExtensionResponse.extensionError, + e.toString(), + ); + } + }); + } + + _printConnection(); + } + + static void _printConnection() { + Service.getInfo().then((ServiceProtocolInfo info) { + final serviceUri = info.serverUri; + if (serviceUri == null) { + return; + } + final port = serviceUri.port; + var path = serviceUri.path; + if (path.endsWith('/')) { + path = path.substring(0, path.length - 1); + } + if (path.endsWith('=')) { + path = path.substring(0, path.length - 1); + } + final url = ' https://inspect.isar.dev/${Isar.version}/#/$port$path '; + String line(String text, String fill) { + final fillCount = url.length - text.length; + final left = List.filled(fillCount ~/ 2, fill); + final right = List.filled(fillCount - left.length, fill); + return left.join() + text + right.join(); + } + + print('╔${line('', '═')}╗'); + print('║${line('ISAR CONNECT STARTED', ' ')}║'); + print('╟${line('', '─')}╢'); + print('║${line('Open the link to connect to the Isar', ' ')}║'); + print('║${line('Inspector while this build is running.', ' ')}║'); + print('╟${line('', '─')}╢'); + print('║$url║'); + print('╚${line('', '═')}╝'); + }); + } + + static Future _getSchema(Map _) async { + return _schemas!.map((e) => e.toJson()).toList(); + } + + static Future _listInstances(Map _) async { + return Isar.instanceNames.toList(); + } + + static Future _watchInstance(Map params) async { + for (final sub in _collectionSubscriptions) { + unawaited(sub.cancel()); + } + + _collectionSubscriptions.clear(); + if (params.isEmpty) { + return true; + } + + final instanceName = params['instance'] as String; + final instance = Isar.getInstance(instanceName)!; + + for (final collection in instance._collections.values) { + final sub = collection.watchLazy(fireImmediately: true).listen((_) { + _sendCollectionInfo(collection); + }); + _collectionSubscriptions.add(sub); + } + + return true; + } + + static void _sendCollectionInfo(IsarCollection collection) { + final count = collection.countSync(); + final size = collection.getSizeSync( + includeIndexes: true, + includeLinks: true, + ); + final collectionInfo = ConnectCollectionInfo( + instance: collection.isar.name, + collection: collection.name, + size: size, + count: count, + ); + postEvent( + ConnectEvent.collectionInfoChanged.event, + collectionInfo.toJson(), + ); + } + + static Future> _executeQuery( + Map params, + ) async { + for (final sub in _querySubscription) { + unawaited(sub.cancel()); + } + _querySubscription.clear(); + + final cQuery = ConnectQuery.fromJson(params); + final instance = Isar.getInstance(cQuery.instance)!; + + final links = + _schemas!.firstWhere((e) => e.name == cQuery.collection).links.values; + + final query = cQuery.toQuery(); + params.remove('limit'); + params.remove('offset'); + final countQuery = ConnectQuery.fromJson(params).toQuery(); + + _querySubscription.add( + query.watchLazy().listen((_) { + postEvent(ConnectEvent.queryChanged.event, {}); + }), + ); + final subscribed = {cQuery.collection}; + for (final link in links) { + if (subscribed.add(link.target)) { + final target = instance.getCollectionByNameInternal(link.target)!; + _querySubscription.add( + target.watchLazy().listen((_) { + postEvent(ConnectEvent.queryChanged.event, {}); + }), + ); + } + } + + final objects = await query.exportJson(); + if (links.isNotEmpty) { + final source = instance.getCollectionByNameInternal(cQuery.collection)!; + for (final object in objects) { + for (final link in links) { + final target = instance.getCollectionByNameInternal(link.target)!; + final links = await target.buildQuery( + whereClauses: [ + LinkWhereClause( + linkCollection: source.name, + linkName: link.name, + id: object[source.schema.idName] as int, + ), + ], + limit: link.single ? 1 : null, + ).exportJson(); + + if (link.single) { + object[link.name] = links.isEmpty ? null : links.first; + } else { + object[link.name] = links; + } + } + } + } + + return { + 'objects': objects, + 'count': await countQuery.count(), + }; + } + + static Future _removeQuery(Map params) async { + final query = ConnectQuery.fromJson(params).toQuery(); + await query.isar.writeTxn(query.deleteAll); + return true; + } + + static Future _importJson(Map params) async { + final instance = Isar.getInstance(params['instance'] as String)!; + final collection = + instance.getCollectionByNameInternal(params['collection'] as String)!; + final objects = (params['objects'] as List).cast>(); + await instance.writeTxn(() async { + await collection.importJson(objects); + }); + } + + static Future> _exportJson(Map params) async { + final query = ConnectQuery.fromJson(params).toQuery(); + return query.exportJson(); + } + + static Future _editProperty(Map params) async { + final cEdit = ConnectEdit.fromJson(params); + final isar = Isar.getInstance(cEdit.instance)!; + final collection = isar.getCollectionByNameInternal(cEdit.collection)!; + final keys = cEdit.path.split('.'); + + final query = collection.buildQuery( + whereClauses: [IdWhereClause.equalTo(value: cEdit.id)], + ); + + final objects = await query.exportJson(); + if (objects.isNotEmpty) { + dynamic object = objects.first; + for (var i = 0; i < keys.length; i++) { + if (i == keys.length - 1 && object is Map) { + object[keys[i]] = cEdit.value; + } else if (object is Map) { + object = object[keys[i]]; + } else if (object is List) { + object = object[int.parse(keys[i])]; + } + } + try { + await isar.writeTxn(() async { + await collection.importJson(objects); + }); + } catch (e) { + print(e); + } + } + } +} diff --git a/packages_external/isar-3.1.0-1/packages/isar/lib/src/isar_connect_api.dart b/packages_external/isar-3.1.0-1/packages/isar/lib/src/isar_connect_api.dart new file mode 100644 index 00000000..4f182876 --- /dev/null +++ b/packages_external/isar-3.1.0-1/packages/isar/lib/src/isar_connect_api.dart @@ -0,0 +1,215 @@ +// coverage:ignore-file +// ignore_for_file: public_member_api_docs + +import 'package:isar/isar.dart'; + +enum ConnectAction { + getSchema('ext.isar.getSchema'), + listInstances('ext.isar.listInstances'), + watchInstance('ext.isar.watchInstance'), + executeQuery('ext.isar.executeQuery'), + removeQuery('ext.isar.removeQuery'), + importJson('ext.isar.importJson'), + exportJson('ext.isar.exportJson'), + editProperty('ext.isar.editProperty'); + + const ConnectAction(this.method); + + final String method; +} + +enum ConnectEvent { + instancesChanged('isar.instancesChanged'), + queryChanged('isar.queryChanged'), + collectionInfoChanged('isar.collectionInfoChanged'); + + const ConnectEvent(this.event); + + final String event; +} + +class ConnectQuery { + ConnectQuery({ + required this.instance, + required this.collection, + this.filter, + this.offset, + this.limit, + this.sortProperty, + this.sortAsc, + }); + + factory ConnectQuery.fromJson(Map json) { + return ConnectQuery( + instance: json['instance'] as String, + collection: json['collection'] as String, + filter: _filterFromJson(json['filter'] as Map?), + offset: json['offset'] as int?, + limit: json['limit'] as int?, + sortProperty: json['sortProperty'] as String?, + sortAsc: json['sortAsc'] as bool?, + ); + } + + final String instance; + final String collection; + final FilterOperation? filter; + final int? offset; + final int? limit; + final String? sortProperty; + final bool? sortAsc; + + Map toJson() { + return { + 'instance': instance, + 'collection': collection, + if (filter != null) 'filter': _filterToJson(filter!), + if (offset != null) 'offset': offset, + if (limit != null) 'limit': limit, + if (sortProperty != null) 'sortProperty': sortProperty, + if (sortAsc != null) 'sortAsc': sortAsc, + }; + } + + static FilterOperation? _filterFromJson(Map? json) { + if (json == null) { + return null; + } + if (json.containsKey('filters')) { + final filters = (json['filters'] as List) + .map((e) => _filterFromJson(e as Map?)!) + .toList(); + return FilterGroup( + type: FilterGroupType.values[json['type'] as int], + filters: filters, + ); + } else { + return FilterCondition( + type: FilterConditionType.values[json['type'] as int], + property: json['property'] as String, + value1: json['value1'], + value2: json['value2'], + include1: json['include1'] as bool, + include2: json['include2'] as bool, + caseSensitive: json['caseSensitive'] as bool, + ); + } + } + + static Map _filterToJson(FilterOperation filter) { + if (filter is FilterCondition) { + return { + 'type': filter.type.index, + 'property': filter.property, + 'value1': filter.value1, + 'value2': filter.value2, + 'include1': filter.include1, + 'include2': filter.include2, + 'caseSensitive': filter.caseSensitive, + }; + } else if (filter is FilterGroup) { + return { + 'type': filter.type.index, + 'filters': filter.filters.map(_filterToJson).toList(), + }; + } else { + throw UnimplementedError(); + } + } + + Query toQuery() { + final isar = Isar.getInstance(instance)!; + // ignore: invalid_use_of_protected_member + final collection = isar.getCollectionByNameInternal(this.collection)!; + WhereClause? whereClause; + var whereSort = Sort.asc; + + SortProperty? sortProperty; + if (this.sortProperty != null) { + if (this.sortProperty == collection.schema.idName) { + whereClause = const IdWhereClause.any(); + whereSort = sortAsc == true ? Sort.asc : Sort.desc; + } else { + sortProperty = SortProperty( + property: this.sortProperty!, + sort: sortAsc == true ? Sort.asc : Sort.desc, + ); + } + } + return collection.buildQuery( + whereClauses: [if (whereClause != null) whereClause], + whereSort: whereSort, + filter: filter, + offset: offset, + limit: limit, + sortBy: [if (sortProperty != null) sortProperty], + ); + } +} + +class ConnectEdit { + ConnectEdit({ + required this.instance, + required this.collection, + required this.id, + required this.path, + required this.value, + }); + + factory ConnectEdit.fromJson(Map json) { + return ConnectEdit( + instance: json['instance'] as String, + collection: json['collection'] as String, + id: json['id'] as Id, + path: json['path'] as String, + value: json['value'], + ); + } + + final String instance; + final String collection; + final Id id; + final String path; + final dynamic value; + + Map toJson() { + return { + 'instance': instance, + 'collection': collection, + 'id': id, + 'path': path, + 'value': value, + }; + } +} + +class ConnectCollectionInfo { + ConnectCollectionInfo({ + required this.instance, + required this.collection, + required this.size, + required this.count, + }); + + factory ConnectCollectionInfo.fromJson(Map json) { + return ConnectCollectionInfo( + instance: json['instance'] as String, + collection: json['collection'] as String, + size: json['size'] as int, + count: json['count'] as int, + ); + } + final String instance; + final String collection; + final int size; + final int count; + + Map toJson() { + return { + 'instance': instance, + 'collection': collection, + 'size': size, + 'count': count, + }; + } +} diff --git a/packages_external/isar-3.1.0-1/packages/isar/lib/src/isar_error.dart b/packages_external/isar-3.1.0-1/packages/isar/lib/src/isar_error.dart new file mode 100644 index 00000000..18f92e1b --- /dev/null +++ b/packages_external/isar-3.1.0-1/packages/isar/lib/src/isar_error.dart @@ -0,0 +1,23 @@ +part of isar; + +/// An error raised by Isar. +class IsarError extends Error { + /// @nodoc + @protected + IsarError(this.message); + + /// The message + final String message; + + @override + String toString() { + return 'IsarError: $message'; + } +} + +/// This error is returned when a unique index constraint is violated. +class IsarUniqueViolationError extends IsarError { + /// @nodoc + @protected + IsarUniqueViolationError() : super('Unique index violated'); +} diff --git a/packages_external/isar-3.1.0-1/packages/isar/lib/src/isar_link.dart b/packages_external/isar-3.1.0-1/packages/isar/lib/src/isar_link.dart new file mode 100644 index 00000000..d5893833 --- /dev/null +++ b/packages_external/isar-3.1.0-1/packages/isar/lib/src/isar_link.dart @@ -0,0 +1,113 @@ +part of isar; + +/// @nodoc +@sealed +abstract class IsarLinkBase { + /// Is the containing object managed by Isar? + bool get isAttached; + + /// Have the contents been changed? If not, `.save()` is a no-op. + bool get isChanged; + + /// Has this link been loaded? + bool get isLoaded; + + /// {@template link_load} + /// Loads the linked object(s) from the database + /// {@endtemplate} + Future load(); + + /// {@macro link_load} + void loadSync(); + + /// {@template link_save} + /// Saves the linked object(s) to the database if there are changes. + /// + /// Also puts new objects into the database that have id set to `null` or + /// `Isar.autoIncrement`. + /// {@endtemplate} + Future save(); + + /// {@macro link_save} + void saveSync(); + + /// {@template link_reset} + /// Unlinks all linked object(s). + /// + /// You can even call this method on links that have not been loaded yet. + /// {@endtemplate} + Future reset(); + + /// {@macro link_reset} + void resetSync(); + + /// @nodoc + @protected + void attach( + IsarCollection sourceCollection, + IsarCollection targetCollection, + String linkName, + Id? objectId, + ); +} + +/// Establishes a 1:1 relationship with the same or another collection. The +/// target collection is specified by the generic type argument. +abstract class IsarLink implements IsarLinkBase { + /// Create an empty, unattached link. Make sure to provide the correct + /// generic argument. + factory IsarLink() => IsarLinkImpl(); + + /// The linked object or `null` if no object is linked. + OBJ? get value; + + /// The linked object or `null` if no object is linked. + set value(OBJ? obj); +} + +/// Establishes a 1:n relationship with the same or another collection. The +/// target collection is specified by the generic type argument. +abstract class IsarLinks implements IsarLinkBase, Set { + /// Create an empty, unattached link. Make sure to provide the correct + /// generic argument. + factory IsarLinks() => IsarLinksImpl(); + + @override + Future load({bool overrideChanges = true}); + + @override + void loadSync({bool overrideChanges = true}); + + /// {@template links_update} + /// Creates and removes the specified links in the database. + /// + /// This operation does not alter the state of the local copy of this link + /// and it can even be used without loading the link. + /// {@endtemplate} + Future update({ + Iterable link = const [], + Iterable unlink = const [], + bool reset = false, + }); + + /// {@macro links_update} + void updateSync({ + Iterable link = const [], + Iterable unlink = const [], + bool reset = false, + }); + + /// Starts a query for linked objects. + QueryBuilder filter(); + + /// {@template links_count} + /// Counts the linked objects in the database. + /// + /// It does not take the local state into account and can even be used + /// without loading the link. + /// {@endtemplate} + Future count() => filter().count(); + + /// {@macro links_count} + int countSync() => filter().countSync(); +} diff --git a/packages_external/isar-3.1.0-1/packages/isar/lib/src/isar_reader.dart b/packages_external/isar-3.1.0-1/packages/isar/lib/src/isar_reader.dart new file mode 100644 index 00000000..1601ed98 --- /dev/null +++ b/packages_external/isar-3.1.0-1/packages/isar/lib/src/isar_reader.dart @@ -0,0 +1,88 @@ +// ignore_for_file: public_member_api_docs + +part of isar; + +/// @nodoc +@protected +abstract class IsarReader { + bool readBool(int offset); + + bool? readBoolOrNull(int offset); + + int readByte(int offset); + + int? readByteOrNull(int offset); + + int readInt(int offset); + + int? readIntOrNull(int offset); + + double readFloat(int offset); + + double? readFloatOrNull(int offset); + + int readLong(int offset); + + int? readLongOrNull(int offset); + + double readDouble(int offset); + + double? readDoubleOrNull(int offset); + + DateTime readDateTime(int offset); + + DateTime? readDateTimeOrNull(int offset); + + String readString(int offset); + + String? readStringOrNull(int offset); + + T? readObjectOrNull( + int offset, + Deserialize deserialize, + Map> allOffsets, + ); + + List? readBoolList(int offset); + + List? readBoolOrNullList(int offset); + + List? readByteList(int offset); + + List? readIntList(int offset); + + List? readIntOrNullList(int offset); + + List? readFloatList(int offset); + + List? readFloatOrNullList(int offset); + + List? readLongList(int offset); + + List? readLongOrNullList(int offset); + + List? readDoubleList(int offset); + + List? readDoubleOrNullList(int offset); + + List? readDateTimeList(int offset); + + List? readDateTimeOrNullList(int offset); + + List? readStringList(int offset); + + List? readStringOrNullList(int offset); + + List? readObjectList( + int offset, + Deserialize deserialize, + Map> allOffsets, + T defaultValue, + ); + + List? readObjectOrNullList( + int offset, + Deserialize deserialize, + Map> allOffsets, + ); +} diff --git a/packages_external/isar-3.1.0-1/packages/isar/lib/src/isar_writer.dart b/packages_external/isar-3.1.0-1/packages/isar/lib/src/isar_writer.dart new file mode 100644 index 00000000..518802a0 --- /dev/null +++ b/packages_external/isar-3.1.0-1/packages/isar/lib/src/isar_writer.dart @@ -0,0 +1,53 @@ +// ignore_for_file: public_member_api_docs + +part of isar; + +/// @nodoc +@protected +abstract class IsarWriter { + void writeBool(int offset, bool? value); + + void writeByte(int offset, int value); + + void writeInt(int offset, int? value); + + void writeFloat(int offset, double? value); + + void writeLong(int offset, int? value); + + void writeDouble(int offset, double? value); + + void writeDateTime(int offset, DateTime? value); + + void writeString(int offset, String? value); + + void writeObject( + int offset, + Map> allOffsets, + Serialize serialize, + T? value, + ); + + void writeByteList(int offset, List? values); + + void writeBoolList(int offset, List? values); + + void writeIntList(int offset, List? values); + + void writeFloatList(int offset, List? values); + + void writeLongList(int offset, List? values); + + void writeDoubleList(int offset, List? values); + + void writeDateTimeList(int offset, List? values); + + void writeStringList(int offset, List? values); + + void writeObjectList( + int offset, + Map> allOffsets, + Serialize serialize, + List? values, + ); +} diff --git a/packages_external/isar-3.1.0-1/packages/isar/lib/src/native/bindings.dart b/packages_external/isar-3.1.0-1/packages/isar/lib/src/native/bindings.dart new file mode 100644 index 00000000..734bc9d1 --- /dev/null +++ b/packages_external/isar-3.1.0-1/packages/isar/lib/src/native/bindings.dart @@ -0,0 +1,2241 @@ +// ignore_for_file: camel_case_types, non_constant_identifier_names + +// AUTO GENERATED FILE, DO NOT EDIT. +// +// Generated by `package:ffigen`. +import 'dart:ffi' as ffi; + +class IsarCoreBindings { + /// Holds the symbol lookup function. + final ffi.Pointer Function(String symbolName) + _lookup; + + /// The symbols are looked up in [dynamicLibrary]. + IsarCoreBindings(ffi.DynamicLibrary dynamicLibrary) + : _lookup = dynamicLibrary.lookup; + + /// The symbols are looked up with [lookup]. + IsarCoreBindings.fromLookup( + ffi.Pointer Function(String symbolName) + lookup) + : _lookup = lookup; + + ffi.Pointer isar_find_word_boundaries( + ffi.Pointer input_bytes, + int length, + ffi.Pointer number_words, + ) { + return _isar_find_word_boundaries( + input_bytes, + length, + number_words, + ); + } + + late final _isar_find_word_boundariesPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer, ffi.Uint32, + ffi.Pointer)>>('isar_find_word_boundaries'); + late final _isar_find_word_boundaries = + _isar_find_word_boundariesPtr.asFunction< + ffi.Pointer Function( + ffi.Pointer, int, ffi.Pointer)>(); + + void isar_free_word_boundaries( + ffi.Pointer boundaries, + int word_count, + ) { + return _isar_free_word_boundaries( + boundaries, + word_count, + ); + } + + late final _isar_free_word_boundariesPtr = _lookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, + ffi.Uint32)>>('isar_free_word_boundaries'); + late final _isar_free_word_boundaries = _isar_free_word_boundariesPtr + .asFunction, int)>(); + + void isar_free_string( + ffi.Pointer string, + ) { + return _isar_free_string( + string, + ); + } + + late final _isar_free_stringPtr = + _lookup)>>( + 'isar_free_string'); + late final _isar_free_string = + _isar_free_stringPtr.asFunction)>(); + + ffi.Pointer isar_get_error( + int err_code, + ) { + return _isar_get_error( + err_code, + ); + } + + late final _isar_get_errorPtr = + _lookup Function(ffi.Int64)>>( + 'isar_get_error'); + late final _isar_get_error = + _isar_get_errorPtr.asFunction Function(int)>(); + + void isar_free_c_object_set( + ffi.Pointer ros, + ) { + return _isar_free_c_object_set( + ros, + ); + } + + late final _isar_free_c_object_setPtr = + _lookup)>>( + 'isar_free_c_object_set'); + late final _isar_free_c_object_set = _isar_free_c_object_setPtr + .asFunction)>(); + + int isar_get( + ffi.Pointer collection, + ffi.Pointer txn, + ffi.Pointer object, + ) { + return _isar_get( + collection, + txn, + object, + ); + } + + late final _isar_getPtr = _lookup< + ffi.NativeFunction< + ffi.Int64 Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer)>>('isar_get'); + late final _isar_get = _isar_getPtr.asFunction< + int Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer)>(); + + int isar_get_by_index( + ffi.Pointer collection, + ffi.Pointer txn, + int index_id, + ffi.Pointer key, + ffi.Pointer object, + ) { + return _isar_get_by_index( + collection, + txn, + index_id, + key, + object, + ); + } + + late final _isar_get_by_indexPtr = _lookup< + ffi.NativeFunction< + ffi.Int64 Function( + ffi.Pointer, + ffi.Pointer, + ffi.Uint64, + ffi.Pointer, + ffi.Pointer)>>('isar_get_by_index'); + late final _isar_get_by_index = _isar_get_by_indexPtr.asFunction< + int Function(ffi.Pointer, ffi.Pointer, int, + ffi.Pointer, ffi.Pointer)>(); + + int isar_get_all( + ffi.Pointer collection, + ffi.Pointer txn, + ffi.Pointer objects, + ) { + return _isar_get_all( + collection, + txn, + objects, + ); + } + + late final _isar_get_allPtr = _lookup< + ffi.NativeFunction< + ffi.Int64 Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer)>>('isar_get_all'); + late final _isar_get_all = _isar_get_allPtr.asFunction< + int Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer)>(); + + int isar_get_all_by_index( + ffi.Pointer collection, + ffi.Pointer txn, + int index_id, + ffi.Pointer> keys, + ffi.Pointer objects, + ) { + return _isar_get_all_by_index( + collection, + txn, + index_id, + keys, + objects, + ); + } + + late final _isar_get_all_by_indexPtr = _lookup< + ffi.NativeFunction< + ffi.Int64 Function( + ffi.Pointer, + ffi.Pointer, + ffi.Uint64, + ffi.Pointer>, + ffi.Pointer)>>('isar_get_all_by_index'); + late final _isar_get_all_by_index = _isar_get_all_by_indexPtr.asFunction< + int Function(ffi.Pointer, ffi.Pointer, int, + ffi.Pointer>, ffi.Pointer)>(); + + int isar_put( + ffi.Pointer collection, + ffi.Pointer txn, + ffi.Pointer object, + ) { + return _isar_put( + collection, + txn, + object, + ); + } + + late final _isar_putPtr = _lookup< + ffi.NativeFunction< + ffi.Int64 Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer)>>('isar_put'); + late final _isar_put = _isar_putPtr.asFunction< + int Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer)>(); + + int isar_put_by_index( + ffi.Pointer collection, + ffi.Pointer txn, + int index_id, + ffi.Pointer object, + ) { + return _isar_put_by_index( + collection, + txn, + index_id, + object, + ); + } + + late final _isar_put_by_indexPtr = _lookup< + ffi.NativeFunction< + ffi.Int64 Function( + ffi.Pointer, + ffi.Pointer, + ffi.Uint64, + ffi.Pointer)>>('isar_put_by_index'); + late final _isar_put_by_index = _isar_put_by_indexPtr.asFunction< + int Function(ffi.Pointer, ffi.Pointer, int, + ffi.Pointer)>(); + + int isar_put_all( + ffi.Pointer collection, + ffi.Pointer txn, + ffi.Pointer objects, + ) { + return _isar_put_all( + collection, + txn, + objects, + ); + } + + late final _isar_put_allPtr = _lookup< + ffi.NativeFunction< + ffi.Int64 Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer)>>('isar_put_all'); + late final _isar_put_all = _isar_put_allPtr.asFunction< + int Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer)>(); + + int isar_put_all_by_index( + ffi.Pointer collection, + ffi.Pointer txn, + int index_id, + ffi.Pointer objects, + ) { + return _isar_put_all_by_index( + collection, + txn, + index_id, + objects, + ); + } + + late final _isar_put_all_by_indexPtr = _lookup< + ffi.NativeFunction< + ffi.Int64 Function( + ffi.Pointer, + ffi.Pointer, + ffi.Uint64, + ffi.Pointer)>>('isar_put_all_by_index'); + late final _isar_put_all_by_index = _isar_put_all_by_indexPtr.asFunction< + int Function(ffi.Pointer, ffi.Pointer, int, + ffi.Pointer)>(); + + int isar_delete( + ffi.Pointer collection, + ffi.Pointer txn, + int id, + ffi.Pointer deleted, + ) { + return _isar_delete( + collection, + txn, + id, + deleted, + ); + } + + late final _isar_deletePtr = _lookup< + ffi.NativeFunction< + ffi.Int64 Function( + ffi.Pointer, + ffi.Pointer, + ffi.Int64, + ffi.Pointer)>>('isar_delete'); + late final _isar_delete = _isar_deletePtr.asFunction< + int Function(ffi.Pointer, ffi.Pointer, int, + ffi.Pointer)>(); + + int isar_delete_by_index( + ffi.Pointer collection, + ffi.Pointer txn, + int index_id, + ffi.Pointer key, + ffi.Pointer deleted, + ) { + return _isar_delete_by_index( + collection, + txn, + index_id, + key, + deleted, + ); + } + + late final _isar_delete_by_indexPtr = _lookup< + ffi.NativeFunction< + ffi.Int64 Function( + ffi.Pointer, + ffi.Pointer, + ffi.Uint64, + ffi.Pointer, + ffi.Pointer)>>('isar_delete_by_index'); + late final _isar_delete_by_index = _isar_delete_by_indexPtr.asFunction< + int Function(ffi.Pointer, ffi.Pointer, int, + ffi.Pointer, ffi.Pointer)>(); + + int isar_delete_all( + ffi.Pointer collection, + ffi.Pointer txn, + ffi.Pointer ids, + int ids_length, + ffi.Pointer count, + ) { + return _isar_delete_all( + collection, + txn, + ids, + ids_length, + count, + ); + } + + late final _isar_delete_allPtr = _lookup< + ffi.NativeFunction< + ffi.Int64 Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Uint32, + ffi.Pointer)>>('isar_delete_all'); + late final _isar_delete_all = _isar_delete_allPtr.asFunction< + int Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer, int, ffi.Pointer)>(); + + int isar_delete_all_by_index( + ffi.Pointer collection, + ffi.Pointer txn, + int index_id, + ffi.Pointer> keys, + int keys_length, + ffi.Pointer count, + ) { + return _isar_delete_all_by_index( + collection, + txn, + index_id, + keys, + keys_length, + count, + ); + } + + late final _isar_delete_all_by_indexPtr = _lookup< + ffi.NativeFunction< + ffi.Int64 Function( + ffi.Pointer, + ffi.Pointer, + ffi.Uint64, + ffi.Pointer>, + ffi.Uint32, + ffi.Pointer)>>('isar_delete_all_by_index'); + late final _isar_delete_all_by_index = + _isar_delete_all_by_indexPtr.asFunction< + int Function( + ffi.Pointer, + ffi.Pointer, + int, + ffi.Pointer>, + int, + ffi.Pointer)>(); + + int isar_clear( + ffi.Pointer collection, + ffi.Pointer txn, + ) { + return _isar_clear( + collection, + txn, + ); + } + + late final _isar_clearPtr = _lookup< + ffi.NativeFunction< + ffi.Int64 Function(ffi.Pointer, + ffi.Pointer)>>('isar_clear'); + late final _isar_clear = _isar_clearPtr.asFunction< + int Function(ffi.Pointer, ffi.Pointer)>(); + + int isar_json_import( + ffi.Pointer collection, + ffi.Pointer txn, + ffi.Pointer id_name, + ffi.Pointer json_bytes, + int json_length, + ) { + return _isar_json_import( + collection, + txn, + id_name, + json_bytes, + json_length, + ); + } + + late final _isar_json_importPtr = _lookup< + ffi.NativeFunction< + ffi.Int64 Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Uint32)>>('isar_json_import'); + late final _isar_json_import = _isar_json_importPtr.asFunction< + int Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer, ffi.Pointer, int)>(); + + int isar_count( + ffi.Pointer collection, + ffi.Pointer txn, + ffi.Pointer count, + ) { + return _isar_count( + collection, + txn, + count, + ); + } + + late final _isar_countPtr = _lookup< + ffi.NativeFunction< + ffi.Int64 Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer)>>('isar_count'); + late final _isar_count = _isar_countPtr.asFunction< + int Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer)>(); + + int isar_get_size( + ffi.Pointer collection, + ffi.Pointer txn, + bool include_indexes, + bool include_links, + ffi.Pointer size, + ) { + return _isar_get_size( + collection, + txn, + include_indexes, + include_links, + size, + ); + } + + late final _isar_get_sizePtr = _lookup< + ffi.NativeFunction< + ffi.Int64 Function( + ffi.Pointer, + ffi.Pointer, + ffi.Bool, + ffi.Bool, + ffi.Pointer)>>('isar_get_size'); + late final _isar_get_size = _isar_get_sizePtr.asFunction< + int Function(ffi.Pointer, ffi.Pointer, bool, + bool, ffi.Pointer)>(); + + int isar_verify( + ffi.Pointer collection, + ffi.Pointer txn, + ffi.Pointer objects, + ) { + return _isar_verify( + collection, + txn, + objects, + ); + } + + late final _isar_verifyPtr = _lookup< + ffi.NativeFunction< + ffi.Int64 Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer)>>('isar_verify'); + late final _isar_verify = _isar_verifyPtr.asFunction< + int Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer)>(); + + void isar_connect_dart_api( + DartPostCObjectFnType ptr, + ) { + return _isar_connect_dart_api( + ptr, + ); + } + + late final _isar_connect_dart_apiPtr = + _lookup>( + 'isar_connect_dart_api'); + late final _isar_connect_dart_api = _isar_connect_dart_apiPtr + .asFunction(); + + void isar_filter_static( + ffi.Pointer> filter, + bool value, + ) { + return _isar_filter_static( + filter, + value, + ); + } + + late final _isar_filter_staticPtr = _lookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer>, + ffi.Bool)>>('isar_filter_static'); + late final _isar_filter_static = _isar_filter_staticPtr + .asFunction>, bool)>(); + + void isar_filter_and_or_xor( + ffi.Pointer> filter, + bool and, + bool exclusive, + ffi.Pointer> conditions, + int length, + ) { + return _isar_filter_and_or_xor( + filter, + and, + exclusive, + conditions, + length, + ); + } + + late final _isar_filter_and_or_xorPtr = _lookup< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer>, + ffi.Bool, + ffi.Bool, + ffi.Pointer>, + ffi.Uint32)>>('isar_filter_and_or_xor'); + late final _isar_filter_and_or_xor = _isar_filter_and_or_xorPtr.asFunction< + void Function(ffi.Pointer>, bool, bool, + ffi.Pointer>, int)>(); + + void isar_filter_not( + ffi.Pointer> filter, + ffi.Pointer condition, + ) { + return _isar_filter_not( + filter, + condition, + ); + } + + late final _isar_filter_notPtr = _lookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer>, + ffi.Pointer)>>('isar_filter_not'); + late final _isar_filter_not = _isar_filter_notPtr.asFunction< + void Function(ffi.Pointer>, ffi.Pointer)>(); + + int isar_filter_object( + ffi.Pointer collection, + ffi.Pointer> filter, + ffi.Pointer condition, + int embedded_col_id, + int property_id, + ) { + return _isar_filter_object( + collection, + filter, + condition, + embedded_col_id, + property_id, + ); + } + + late final _isar_filter_objectPtr = _lookup< + ffi.NativeFunction< + ffi.Int64 Function( + ffi.Pointer, + ffi.Pointer>, + ffi.Pointer, + ffi.Uint64, + ffi.Uint64)>>('isar_filter_object'); + late final _isar_filter_object = _isar_filter_objectPtr.asFunction< + int Function(ffi.Pointer, + ffi.Pointer>, ffi.Pointer, int, int)>(); + + int isar_filter_link( + ffi.Pointer collection, + ffi.Pointer> filter, + ffi.Pointer condition, + int link_id, + ) { + return _isar_filter_link( + collection, + filter, + condition, + link_id, + ); + } + + late final _isar_filter_linkPtr = _lookup< + ffi.NativeFunction< + ffi.Int64 Function( + ffi.Pointer, + ffi.Pointer>, + ffi.Pointer, + ffi.Uint64)>>('isar_filter_link'); + late final _isar_filter_link = _isar_filter_linkPtr.asFunction< + int Function(ffi.Pointer, + ffi.Pointer>, ffi.Pointer, int)>(); + + int isar_filter_link_length( + ffi.Pointer collection, + ffi.Pointer> filter, + int lower, + int upper, + int link_id, + ) { + return _isar_filter_link_length( + collection, + filter, + lower, + upper, + link_id, + ); + } + + late final _isar_filter_link_lengthPtr = _lookup< + ffi.NativeFunction< + ffi.Int64 Function( + ffi.Pointer, + ffi.Pointer>, + ffi.Uint32, + ffi.Uint32, + ffi.Uint64)>>('isar_filter_link_length'); + late final _isar_filter_link_length = _isar_filter_link_lengthPtr.asFunction< + int Function(ffi.Pointer, + ffi.Pointer>, int, int, int)>(); + + int isar_filter_list_length( + ffi.Pointer collection, + ffi.Pointer> filter, + int lower, + int upper, + int embedded_col_id, + int property_id, + ) { + return _isar_filter_list_length( + collection, + filter, + lower, + upper, + embedded_col_id, + property_id, + ); + } + + late final _isar_filter_list_lengthPtr = _lookup< + ffi.NativeFunction< + ffi.Int64 Function( + ffi.Pointer, + ffi.Pointer>, + ffi.Uint32, + ffi.Uint32, + ffi.Uint64, + ffi.Uint64)>>('isar_filter_list_length'); + late final _isar_filter_list_length = _isar_filter_list_lengthPtr.asFunction< + int Function(ffi.Pointer, + ffi.Pointer>, int, int, int, int)>(); + + int isar_filter_null( + ffi.Pointer collection, + ffi.Pointer> filter, + int embedded_col_id, + int property_id, + ) { + return _isar_filter_null( + collection, + filter, + embedded_col_id, + property_id, + ); + } + + late final _isar_filter_nullPtr = _lookup< + ffi.NativeFunction< + ffi.Int64 Function( + ffi.Pointer, + ffi.Pointer>, + ffi.Uint64, + ffi.Uint64)>>('isar_filter_null'); + late final _isar_filter_null = _isar_filter_nullPtr.asFunction< + int Function(ffi.Pointer, + ffi.Pointer>, int, int)>(); + + void isar_filter_id( + ffi.Pointer> filter, + int lower, + bool include_lower, + int upper, + bool include_upper, + ) { + return _isar_filter_id( + filter, + lower, + include_lower, + upper, + include_upper, + ); + } + + late final _isar_filter_idPtr = _lookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer>, ffi.Int64, + ffi.Bool, ffi.Int64, ffi.Bool)>>('isar_filter_id'); + late final _isar_filter_id = _isar_filter_idPtr.asFunction< + void Function(ffi.Pointer>, int, bool, int, bool)>(); + + int isar_filter_long( + ffi.Pointer collection, + ffi.Pointer> filter, + int lower, + bool include_lower, + int upper, + bool include_upper, + int embedded_col_id, + int property_id, + ) { + return _isar_filter_long( + collection, + filter, + lower, + include_lower, + upper, + include_upper, + embedded_col_id, + property_id, + ); + } + + late final _isar_filter_longPtr = _lookup< + ffi.NativeFunction< + ffi.Int64 Function( + ffi.Pointer, + ffi.Pointer>, + ffi.Int64, + ffi.Bool, + ffi.Int64, + ffi.Bool, + ffi.Uint64, + ffi.Uint64)>>('isar_filter_long'); + late final _isar_filter_long = _isar_filter_longPtr.asFunction< + int Function(ffi.Pointer, + ffi.Pointer>, int, bool, int, bool, int, int)>(); + + int isar_filter_double( + ffi.Pointer collection, + ffi.Pointer> filter, + double lower, + double upper, + int embedded_col_id, + int property_id, + ) { + return _isar_filter_double( + collection, + filter, + lower, + upper, + embedded_col_id, + property_id, + ); + } + + late final _isar_filter_doublePtr = _lookup< + ffi.NativeFunction< + ffi.Int64 Function( + ffi.Pointer, + ffi.Pointer>, + ffi.Double, + ffi.Double, + ffi.Uint64, + ffi.Uint64)>>('isar_filter_double'); + late final _isar_filter_double = _isar_filter_doublePtr.asFunction< + int Function(ffi.Pointer, + ffi.Pointer>, double, double, int, int)>(); + + int isar_filter_string( + ffi.Pointer collection, + ffi.Pointer> filter, + ffi.Pointer lower, + bool include_lower, + ffi.Pointer upper, + bool include_upper, + bool case_sensitive, + int embedded_col_id, + int property_id, + ) { + return _isar_filter_string( + collection, + filter, + lower, + include_lower, + upper, + include_upper, + case_sensitive, + embedded_col_id, + property_id, + ); + } + + late final _isar_filter_stringPtr = _lookup< + ffi.NativeFunction< + ffi.Int64 Function( + ffi.Pointer, + ffi.Pointer>, + ffi.Pointer, + ffi.Bool, + ffi.Pointer, + ffi.Bool, + ffi.Bool, + ffi.Uint64, + ffi.Uint64)>>('isar_filter_string'); + late final _isar_filter_string = _isar_filter_stringPtr.asFunction< + int Function( + ffi.Pointer, + ffi.Pointer>, + ffi.Pointer, + bool, + ffi.Pointer, + bool, + bool, + int, + int)>(); + + int isar_filter_string_starts_with( + ffi.Pointer collection, + ffi.Pointer> filter, + ffi.Pointer value, + bool case_sensitive, + int embedded_col_id, + int property_id, + ) { + return _isar_filter_string_starts_with( + collection, + filter, + value, + case_sensitive, + embedded_col_id, + property_id, + ); + } + + late final _isar_filter_string_starts_withPtr = _lookup< + ffi.NativeFunction< + ffi.Int64 Function( + ffi.Pointer, + ffi.Pointer>, + ffi.Pointer, + ffi.Bool, + ffi.Uint64, + ffi.Uint64)>>('isar_filter_string_starts_with'); + late final _isar_filter_string_starts_with = + _isar_filter_string_starts_withPtr.asFunction< + int Function( + ffi.Pointer, + ffi.Pointer>, + ffi.Pointer, + bool, + int, + int)>(); + + int isar_filter_string_ends_with( + ffi.Pointer collection, + ffi.Pointer> filter, + ffi.Pointer value, + bool case_sensitive, + int embedded_col_id, + int property_id, + ) { + return _isar_filter_string_ends_with( + collection, + filter, + value, + case_sensitive, + embedded_col_id, + property_id, + ); + } + + late final _isar_filter_string_ends_withPtr = _lookup< + ffi.NativeFunction< + ffi.Int64 Function( + ffi.Pointer, + ffi.Pointer>, + ffi.Pointer, + ffi.Bool, + ffi.Uint64, + ffi.Uint64)>>('isar_filter_string_ends_with'); + late final _isar_filter_string_ends_with = + _isar_filter_string_ends_withPtr.asFunction< + int Function( + ffi.Pointer, + ffi.Pointer>, + ffi.Pointer, + bool, + int, + int)>(); + + int isar_filter_string_contains( + ffi.Pointer collection, + ffi.Pointer> filter, + ffi.Pointer value, + bool case_sensitive, + int embedded_col_id, + int property_id, + ) { + return _isar_filter_string_contains( + collection, + filter, + value, + case_sensitive, + embedded_col_id, + property_id, + ); + } + + late final _isar_filter_string_containsPtr = _lookup< + ffi.NativeFunction< + ffi.Int64 Function( + ffi.Pointer, + ffi.Pointer>, + ffi.Pointer, + ffi.Bool, + ffi.Uint64, + ffi.Uint64)>>('isar_filter_string_contains'); + late final _isar_filter_string_contains = + _isar_filter_string_containsPtr.asFunction< + int Function( + ffi.Pointer, + ffi.Pointer>, + ffi.Pointer, + bool, + int, + int)>(); + + int isar_filter_string_matches( + ffi.Pointer collection, + ffi.Pointer> filter, + ffi.Pointer value, + bool case_sensitive, + int embedded_col_id, + int property_id, + ) { + return _isar_filter_string_matches( + collection, + filter, + value, + case_sensitive, + embedded_col_id, + property_id, + ); + } + + late final _isar_filter_string_matchesPtr = _lookup< + ffi.NativeFunction< + ffi.Int64 Function( + ffi.Pointer, + ffi.Pointer>, + ffi.Pointer, + ffi.Bool, + ffi.Uint64, + ffi.Uint64)>>('isar_filter_string_matches'); + late final _isar_filter_string_matches = + _isar_filter_string_matchesPtr.asFunction< + int Function( + ffi.Pointer, + ffi.Pointer>, + ffi.Pointer, + bool, + int, + int)>(); + + void isar_key_create( + ffi.Pointer> key, + ) { + return _isar_key_create( + key, + ); + } + + late final _isar_key_createPtr = _lookup< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer>)>>('isar_key_create'); + late final _isar_key_create = _isar_key_createPtr + .asFunction>)>(); + + bool isar_key_increase( + ffi.Pointer key, + ) { + return _isar_key_increase( + key, + ); + } + + late final _isar_key_increasePtr = + _lookup)>>( + 'isar_key_increase'); + late final _isar_key_increase = + _isar_key_increasePtr.asFunction)>(); + + bool isar_key_decrease( + ffi.Pointer key, + ) { + return _isar_key_decrease( + key, + ); + } + + late final _isar_key_decreasePtr = + _lookup)>>( + 'isar_key_decrease'); + late final _isar_key_decrease = + _isar_key_decreasePtr.asFunction)>(); + + void isar_key_add_byte( + ffi.Pointer key, + int value, + ) { + return _isar_key_add_byte( + key, + value, + ); + } + + late final _isar_key_add_bytePtr = _lookup< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, ffi.Uint8)>>('isar_key_add_byte'); + late final _isar_key_add_byte = _isar_key_add_bytePtr + .asFunction, int)>(); + + void isar_key_add_int( + ffi.Pointer key, + int value, + ) { + return _isar_key_add_int( + key, + value, + ); + } + + late final _isar_key_add_intPtr = _lookup< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, ffi.Int32)>>('isar_key_add_int'); + late final _isar_key_add_int = _isar_key_add_intPtr + .asFunction, int)>(); + + void isar_key_add_long( + ffi.Pointer key, + int value, + ) { + return _isar_key_add_long( + key, + value, + ); + } + + late final _isar_key_add_longPtr = _lookup< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, ffi.Int64)>>('isar_key_add_long'); + late final _isar_key_add_long = _isar_key_add_longPtr + .asFunction, int)>(); + + void isar_key_add_float( + ffi.Pointer key, + double value, + ) { + return _isar_key_add_float( + key, + value, + ); + } + + late final _isar_key_add_floatPtr = _lookup< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, ffi.Double)>>('isar_key_add_float'); + late final _isar_key_add_float = _isar_key_add_floatPtr + .asFunction, double)>(); + + void isar_key_add_double( + ffi.Pointer key, + double value, + ) { + return _isar_key_add_double( + key, + value, + ); + } + + late final _isar_key_add_doublePtr = _lookup< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, ffi.Double)>>('isar_key_add_double'); + late final _isar_key_add_double = _isar_key_add_doublePtr + .asFunction, double)>(); + + void isar_key_add_string( + ffi.Pointer key, + ffi.Pointer value, + bool case_sensitive, + ) { + return _isar_key_add_string( + key, + value, + case_sensitive, + ); + } + + late final _isar_key_add_stringPtr = _lookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, ffi.Pointer, + ffi.Bool)>>('isar_key_add_string'); + late final _isar_key_add_string = _isar_key_add_stringPtr.asFunction< + void Function(ffi.Pointer, ffi.Pointer, bool)>(); + + void isar_key_add_string_hash( + ffi.Pointer key, + ffi.Pointer value, + bool case_sensitive, + ) { + return _isar_key_add_string_hash( + key, + value, + case_sensitive, + ); + } + + late final _isar_key_add_string_hashPtr = _lookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, ffi.Pointer, + ffi.Bool)>>('isar_key_add_string_hash'); + late final _isar_key_add_string_hash = + _isar_key_add_string_hashPtr.asFunction< + void Function(ffi.Pointer, ffi.Pointer, bool)>(); + + void isar_key_add_string_list_hash( + ffi.Pointer key, + ffi.Pointer> value, + int length, + bool case_sensitive, + ) { + return _isar_key_add_string_list_hash( + key, + value, + length, + case_sensitive, + ); + } + + late final _isar_key_add_string_list_hashPtr = _lookup< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer>, + ffi.Uint32, + ffi.Bool)>>('isar_key_add_string_list_hash'); + late final _isar_key_add_string_list_hash = + _isar_key_add_string_list_hashPtr.asFunction< + void Function(ffi.Pointer, + ffi.Pointer>, int, bool)>(); + + void isar_key_add_byte_list_hash( + ffi.Pointer key, + ffi.Pointer value, + int length, + ) { + return _isar_key_add_byte_list_hash( + key, + value, + length, + ); + } + + late final _isar_key_add_byte_list_hashPtr = _lookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, ffi.Pointer, + ffi.Uint32)>>('isar_key_add_byte_list_hash'); + late final _isar_key_add_byte_list_hash = + _isar_key_add_byte_list_hashPtr.asFunction< + void Function(ffi.Pointer, ffi.Pointer, int)>(); + + void isar_key_add_int_list_hash( + ffi.Pointer key, + ffi.Pointer value, + int length, + ) { + return _isar_key_add_int_list_hash( + key, + value, + length, + ); + } + + late final _isar_key_add_int_list_hashPtr = _lookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, ffi.Pointer, + ffi.Uint32)>>('isar_key_add_int_list_hash'); + late final _isar_key_add_int_list_hash = + _isar_key_add_int_list_hashPtr.asFunction< + void Function(ffi.Pointer, ffi.Pointer, int)>(); + + void isar_key_add_long_list_hash( + ffi.Pointer key, + ffi.Pointer value, + int length, + ) { + return _isar_key_add_long_list_hash( + key, + value, + length, + ); + } + + late final _isar_key_add_long_list_hashPtr = _lookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, ffi.Pointer, + ffi.Uint32)>>('isar_key_add_long_list_hash'); + late final _isar_key_add_long_list_hash = + _isar_key_add_long_list_hashPtr.asFunction< + void Function(ffi.Pointer, ffi.Pointer, int)>(); + + ffi.Pointer isar_version() { + return _isar_version(); + } + + late final _isar_versionPtr = + _lookup Function()>>( + 'isar_version'); + late final _isar_version = + _isar_versionPtr.asFunction Function()>(); + + int isar_instance_create( + ffi.Pointer> isar, + ffi.Pointer name, + ffi.Pointer path, + ffi.Pointer schema_json, + int max_size_mib, + bool relaxed_durability, + int compact_min_file_size, + int compact_min_bytes, + double compact_min_ratio, + ) { + return _isar_instance_create( + isar, + name, + path, + schema_json, + max_size_mib, + relaxed_durability, + compact_min_file_size, + compact_min_bytes, + compact_min_ratio, + ); + } + + late final _isar_instance_createPtr = _lookup< + ffi.NativeFunction< + ffi.Int64 Function( + ffi.Pointer>, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Int64, + ffi.Bool, + ffi.Uint32, + ffi.Uint32, + ffi.Double)>>('isar_instance_create'); + late final _isar_instance_create = _isar_instance_createPtr.asFunction< + int Function( + ffi.Pointer>, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + int, + bool, + int, + int, + double)>(); + + void isar_instance_create_async( + ffi.Pointer> isar, + ffi.Pointer name, + ffi.Pointer path, + ffi.Pointer schema_json, + int max_size_mib, + bool relaxed_durability, + int compact_min_file_size, + int compact_min_bytes, + double compact_min_ratio, + int port, + ) { + return _isar_instance_create_async( + isar, + name, + path, + schema_json, + max_size_mib, + relaxed_durability, + compact_min_file_size, + compact_min_bytes, + compact_min_ratio, + port, + ); + } + + late final _isar_instance_create_asyncPtr = _lookup< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer>, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Int64, + ffi.Bool, + ffi.Uint32, + ffi.Uint32, + ffi.Double, + DartPort)>>('isar_instance_create_async'); + late final _isar_instance_create_async = + _isar_instance_create_asyncPtr.asFunction< + void Function( + ffi.Pointer>, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + int, + bool, + int, + int, + double, + int)>(); + + bool isar_instance_close( + ffi.Pointer isar, + ) { + return _isar_instance_close( + isar, + ); + } + + late final _isar_instance_closePtr = _lookup< + ffi.NativeFunction)>>( + 'isar_instance_close'); + late final _isar_instance_close = _isar_instance_closePtr + .asFunction)>(); + + bool isar_instance_close_and_delete( + ffi.Pointer isar, + ) { + return _isar_instance_close_and_delete( + isar, + ); + } + + late final _isar_instance_close_and_deletePtr = _lookup< + ffi.NativeFunction)>>( + 'isar_instance_close_and_delete'); + late final _isar_instance_close_and_delete = + _isar_instance_close_and_deletePtr + .asFunction)>(); + + ffi.Pointer isar_instance_get_path( + ffi.Pointer isar, + ) { + return _isar_instance_get_path( + isar, + ); + } + + late final _isar_instance_get_pathPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer)>>('isar_instance_get_path'); + late final _isar_instance_get_path = _isar_instance_get_pathPtr + .asFunction Function(ffi.Pointer)>(); + + int isar_instance_get_collection( + ffi.Pointer isar, + ffi.Pointer> collection, + int collection_id, + ) { + return _isar_instance_get_collection( + isar, + collection, + collection_id, + ); + } + + late final _isar_instance_get_collectionPtr = _lookup< + ffi.NativeFunction< + ffi.Int64 Function( + ffi.Pointer, + ffi.Pointer>, + ffi.Uint64)>>('isar_instance_get_collection'); + late final _isar_instance_get_collection = + _isar_instance_get_collectionPtr.asFunction< + int Function(ffi.Pointer, + ffi.Pointer>, int)>(); + + int isar_instance_get_size( + ffi.Pointer instance, + ffi.Pointer txn, + bool include_indexes, + bool include_links, + ffi.Pointer size, + ) { + return _isar_instance_get_size( + instance, + txn, + include_indexes, + include_links, + size, + ); + } + + late final _isar_instance_get_sizePtr = _lookup< + ffi.NativeFunction< + ffi.Int64 Function( + ffi.Pointer, + ffi.Pointer, + ffi.Bool, + ffi.Bool, + ffi.Pointer)>>('isar_instance_get_size'); + late final _isar_instance_get_size = _isar_instance_get_sizePtr.asFunction< + int Function(ffi.Pointer, ffi.Pointer, bool, + bool, ffi.Pointer)>(); + + void isar_instance_copy_to_file( + ffi.Pointer instance, + ffi.Pointer path, + int port, + ) { + return _isar_instance_copy_to_file( + instance, + path, + port, + ); + } + + late final _isar_instance_copy_to_filePtr = _lookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, ffi.Pointer, + DartPort)>>('isar_instance_copy_to_file'); + late final _isar_instance_copy_to_file = + _isar_instance_copy_to_filePtr.asFunction< + void Function( + ffi.Pointer, ffi.Pointer, int)>(); + + int isar_instance_verify( + ffi.Pointer instance, + ffi.Pointer txn, + ) { + return _isar_instance_verify( + instance, + txn, + ); + } + + late final _isar_instance_verifyPtr = _lookup< + ffi.NativeFunction< + ffi.Int64 Function(ffi.Pointer, + ffi.Pointer)>>('isar_instance_verify'); + late final _isar_instance_verify = _isar_instance_verifyPtr.asFunction< + int Function(ffi.Pointer, ffi.Pointer)>(); + + int isar_get_offsets( + ffi.Pointer collection, + int embedded_col_id, + ffi.Pointer offsets, + ) { + return _isar_get_offsets( + collection, + embedded_col_id, + offsets, + ); + } + + late final _isar_get_offsetsPtr = _lookup< + ffi.NativeFunction< + ffi.Uint32 Function(ffi.Pointer, ffi.Uint64, + ffi.Pointer)>>('isar_get_offsets'); + late final _isar_get_offsets = _isar_get_offsetsPtr.asFunction< + int Function( + ffi.Pointer, int, ffi.Pointer)>(); + + int isar_link( + ffi.Pointer collection, + ffi.Pointer txn, + int link_id, + int id, + int target_id, + ) { + return _isar_link( + collection, + txn, + link_id, + id, + target_id, + ); + } + + late final _isar_linkPtr = _lookup< + ffi.NativeFunction< + ffi.Int64 Function( + ffi.Pointer, + ffi.Pointer, + ffi.Uint64, + ffi.Int64, + ffi.Int64)>>('isar_link'); + late final _isar_link = _isar_linkPtr.asFunction< + int Function(ffi.Pointer, ffi.Pointer, int, + int, int)>(); + + int isar_link_unlink( + ffi.Pointer collection, + ffi.Pointer txn, + int link_id, + int id, + int target_id, + ) { + return _isar_link_unlink( + collection, + txn, + link_id, + id, + target_id, + ); + } + + late final _isar_link_unlinkPtr = _lookup< + ffi.NativeFunction< + ffi.Int64 Function( + ffi.Pointer, + ffi.Pointer, + ffi.Uint64, + ffi.Int64, + ffi.Int64)>>('isar_link_unlink'); + late final _isar_link_unlink = _isar_link_unlinkPtr.asFunction< + int Function(ffi.Pointer, ffi.Pointer, int, + int, int)>(); + + int isar_link_unlink_all( + ffi.Pointer collection, + ffi.Pointer txn, + int link_id, + int id, + ) { + return _isar_link_unlink_all( + collection, + txn, + link_id, + id, + ); + } + + late final _isar_link_unlink_allPtr = _lookup< + ffi.NativeFunction< + ffi.Int64 Function( + ffi.Pointer, + ffi.Pointer, + ffi.Uint64, + ffi.Int64)>>('isar_link_unlink_all'); + late final _isar_link_unlink_all = _isar_link_unlink_allPtr.asFunction< + int Function( + ffi.Pointer, ffi.Pointer, int, int)>(); + + int isar_link_update_all( + ffi.Pointer collection, + ffi.Pointer txn, + int link_id, + int id, + ffi.Pointer ids, + int link_count, + int unlink_count, + bool replace, + ) { + return _isar_link_update_all( + collection, + txn, + link_id, + id, + ids, + link_count, + unlink_count, + replace, + ); + } + + late final _isar_link_update_allPtr = _lookup< + ffi.NativeFunction< + ffi.Int64 Function( + ffi.Pointer, + ffi.Pointer, + ffi.Uint64, + ffi.Int64, + ffi.Pointer, + ffi.Uint32, + ffi.Uint32, + ffi.Bool)>>('isar_link_update_all'); + late final _isar_link_update_all = _isar_link_update_allPtr.asFunction< + int Function(ffi.Pointer, ffi.Pointer, int, + int, ffi.Pointer, int, int, bool)>(); + + int isar_link_verify( + ffi.Pointer collection, + ffi.Pointer txn, + int link_id, + ffi.Pointer ids, + int ids_count, + ) { + return _isar_link_verify( + collection, + txn, + link_id, + ids, + ids_count, + ); + } + + late final _isar_link_verifyPtr = _lookup< + ffi.NativeFunction< + ffi.Int64 Function( + ffi.Pointer, + ffi.Pointer, + ffi.Uint64, + ffi.Pointer, + ffi.Uint32)>>('isar_link_verify'); + late final _isar_link_verify = _isar_link_verifyPtr.asFunction< + int Function(ffi.Pointer, ffi.Pointer, int, + ffi.Pointer, int)>(); + + ffi.Pointer isar_qb_create( + ffi.Pointer collection, + ) { + return _isar_qb_create( + collection, + ); + } + + late final _isar_qb_createPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer)>>('isar_qb_create'); + late final _isar_qb_create = _isar_qb_createPtr.asFunction< + ffi.Pointer Function(ffi.Pointer)>(); + + int isar_qb_add_id_where_clause( + ffi.Pointer builder, + int start_id, + int end_id, + ) { + return _isar_qb_add_id_where_clause( + builder, + start_id, + end_id, + ); + } + + late final _isar_qb_add_id_where_clausePtr = _lookup< + ffi.NativeFunction< + ffi.Int64 Function(ffi.Pointer, ffi.Int64, + ffi.Int64)>>('isar_qb_add_id_where_clause'); + late final _isar_qb_add_id_where_clause = _isar_qb_add_id_where_clausePtr + .asFunction, int, int)>(); + + int isar_qb_add_index_where_clause( + ffi.Pointer builder, + int index_id, + ffi.Pointer lower_key, + ffi.Pointer upper_key, + bool sort_asc, + bool skip_duplicates, + ) { + return _isar_qb_add_index_where_clause( + builder, + index_id, + lower_key, + upper_key, + sort_asc, + skip_duplicates, + ); + } + + late final _isar_qb_add_index_where_clausePtr = _lookup< + ffi.NativeFunction< + ffi.Int64 Function( + ffi.Pointer, + ffi.Uint64, + ffi.Pointer, + ffi.Pointer, + ffi.Bool, + ffi.Bool)>>('isar_qb_add_index_where_clause'); + late final _isar_qb_add_index_where_clause = + _isar_qb_add_index_where_clausePtr.asFunction< + int Function(ffi.Pointer, int, ffi.Pointer, + ffi.Pointer, bool, bool)>(); + + int isar_qb_add_link_where_clause( + ffi.Pointer builder, + ffi.Pointer source_collection, + int link_id, + int id, + ) { + return _isar_qb_add_link_where_clause( + builder, + source_collection, + link_id, + id, + ); + } + + late final _isar_qb_add_link_where_clausePtr = _lookup< + ffi.NativeFunction< + ffi.Int64 Function( + ffi.Pointer, + ffi.Pointer, + ffi.Uint64, + ffi.Int64)>>('isar_qb_add_link_where_clause'); + late final _isar_qb_add_link_where_clause = + _isar_qb_add_link_where_clausePtr.asFunction< + int Function(ffi.Pointer, ffi.Pointer, + int, int)>(); + + void isar_qb_set_filter( + ffi.Pointer builder, + ffi.Pointer filter, + ) { + return _isar_qb_set_filter( + builder, + filter, + ); + } + + late final _isar_qb_set_filterPtr = _lookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, + ffi.Pointer)>>('isar_qb_set_filter'); + late final _isar_qb_set_filter = _isar_qb_set_filterPtr.asFunction< + void Function(ffi.Pointer, ffi.Pointer)>(); + + int isar_qb_add_sort_by( + ffi.Pointer builder, + int property_id, + bool asc, + ) { + return _isar_qb_add_sort_by( + builder, + property_id, + asc, + ); + } + + late final _isar_qb_add_sort_byPtr = _lookup< + ffi.NativeFunction< + ffi.Int64 Function(ffi.Pointer, ffi.Uint64, + ffi.Bool)>>('isar_qb_add_sort_by'); + late final _isar_qb_add_sort_by = _isar_qb_add_sort_byPtr + .asFunction, int, bool)>(); + + int isar_qb_add_distinct_by( + ffi.Pointer builder, + int property_id, + bool case_sensitive, + ) { + return _isar_qb_add_distinct_by( + builder, + property_id, + case_sensitive, + ); + } + + late final _isar_qb_add_distinct_byPtr = _lookup< + ffi.NativeFunction< + ffi.Int64 Function(ffi.Pointer, ffi.Uint64, + ffi.Bool)>>('isar_qb_add_distinct_by'); + late final _isar_qb_add_distinct_by = _isar_qb_add_distinct_byPtr + .asFunction, int, bool)>(); + + void isar_qb_set_offset_limit( + ffi.Pointer builder, + int offset, + int limit, + ) { + return _isar_qb_set_offset_limit( + builder, + offset, + limit, + ); + } + + late final _isar_qb_set_offset_limitPtr = _lookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, ffi.Int64, + ffi.Int64)>>('isar_qb_set_offset_limit'); + late final _isar_qb_set_offset_limit = _isar_qb_set_offset_limitPtr + .asFunction, int, int)>(); + + ffi.Pointer isar_qb_build( + ffi.Pointer builder, + ) { + return _isar_qb_build( + builder, + ); + } + + late final _isar_qb_buildPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer)>>('isar_qb_build'); + late final _isar_qb_build = _isar_qb_buildPtr + .asFunction Function(ffi.Pointer)>(); + + void isar_q_free( + ffi.Pointer query, + ) { + return _isar_q_free( + query, + ); + } + + late final _isar_q_freePtr = + _lookup)>>( + 'isar_q_free'); + late final _isar_q_free = + _isar_q_freePtr.asFunction)>(); + + int isar_q_find( + ffi.Pointer query, + ffi.Pointer txn, + ffi.Pointer result, + int limit, + ) { + return _isar_q_find( + query, + txn, + result, + limit, + ); + } + + late final _isar_q_findPtr = _lookup< + ffi.NativeFunction< + ffi.Int64 Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer, ffi.Uint32)>>('isar_q_find'); + late final _isar_q_find = _isar_q_findPtr.asFunction< + int Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer, int)>(); + + int isar_q_delete( + ffi.Pointer query, + ffi.Pointer collection, + ffi.Pointer txn, + int limit, + ffi.Pointer count, + ) { + return _isar_q_delete( + query, + collection, + txn, + limit, + count, + ); + } + + late final _isar_q_deletePtr = _lookup< + ffi.NativeFunction< + ffi.Int64 Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Uint32, + ffi.Pointer)>>('isar_q_delete'); + late final _isar_q_delete = _isar_q_deletePtr.asFunction< + int Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer, int, ffi.Pointer)>(); + + int isar_q_export_json( + ffi.Pointer query, + ffi.Pointer collection, + ffi.Pointer txn, + ffi.Pointer id_name, + ffi.Pointer> json_bytes, + ffi.Pointer json_length, + ) { + return _isar_q_export_json( + query, + collection, + txn, + id_name, + json_bytes, + json_length, + ); + } + + late final _isar_q_export_jsonPtr = _lookup< + ffi.NativeFunction< + ffi.Int64 Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer>, + ffi.Pointer)>>('isar_q_export_json'); + late final _isar_q_export_json = _isar_q_export_jsonPtr.asFunction< + int Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer>, + ffi.Pointer)>(); + + void isar_free_json( + ffi.Pointer json_bytes, + int json_length, + ) { + return _isar_free_json( + json_bytes, + json_length, + ); + } + + late final _isar_free_jsonPtr = _lookup< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, ffi.Uint32)>>('isar_free_json'); + late final _isar_free_json = _isar_free_jsonPtr + .asFunction, int)>(); + + int isar_q_aggregate( + ffi.Pointer collection, + ffi.Pointer query, + ffi.Pointer txn, + int operation, + int property_id, + ffi.Pointer> result, + ) { + return _isar_q_aggregate( + collection, + query, + txn, + operation, + property_id, + result, + ); + } + + late final _isar_q_aggregatePtr = _lookup< + ffi.NativeFunction< + ffi.Int64 Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Uint8, + ffi.Uint64, + ffi.Pointer>)>>( + 'isar_q_aggregate'); + late final _isar_q_aggregate = _isar_q_aggregatePtr.asFunction< + int Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + int, + int, + ffi.Pointer>)>(); + + int isar_q_aggregate_long_result( + ffi.Pointer result, + ) { + return _isar_q_aggregate_long_result( + result, + ); + } + + late final _isar_q_aggregate_long_resultPtr = _lookup< + ffi.NativeFunction< + ffi.Int64 Function(ffi.Pointer)>>( + 'isar_q_aggregate_long_result'); + late final _isar_q_aggregate_long_result = _isar_q_aggregate_long_resultPtr + .asFunction)>(); + + double isar_q_aggregate_double_result( + ffi.Pointer result, + ) { + return _isar_q_aggregate_double_result( + result, + ); + } + + late final _isar_q_aggregate_double_resultPtr = _lookup< + ffi.NativeFunction< + ffi.Double Function(ffi.Pointer)>>( + 'isar_q_aggregate_double_result'); + late final _isar_q_aggregate_double_result = + _isar_q_aggregate_double_resultPtr + .asFunction)>(); + + int isar_txn_begin( + ffi.Pointer isar, + ffi.Pointer> txn, + bool sync1, + bool write, + bool silent, + int port, + ) { + return _isar_txn_begin( + isar, + txn, + sync1, + write, + silent, + port, + ); + } + + late final _isar_txn_beginPtr = _lookup< + ffi.NativeFunction< + ffi.Int64 Function( + ffi.Pointer, + ffi.Pointer>, + ffi.Bool, + ffi.Bool, + ffi.Bool, + DartPort)>>('isar_txn_begin'); + late final _isar_txn_begin = _isar_txn_beginPtr.asFunction< + int Function(ffi.Pointer, + ffi.Pointer>, bool, bool, bool, int)>(); + + int isar_txn_finish( + ffi.Pointer txn, + bool commit, + ) { + return _isar_txn_finish( + txn, + commit, + ); + } + + late final _isar_txn_finishPtr = _lookup< + ffi.NativeFunction< + ffi.Int64 Function( + ffi.Pointer, ffi.Bool)>>('isar_txn_finish'); + late final _isar_txn_finish = _isar_txn_finishPtr + .asFunction, bool)>(); + + ffi.Pointer isar_watch_collection( + ffi.Pointer isar, + ffi.Pointer collection, + int port, + ) { + return _isar_watch_collection( + isar, + collection, + port, + ); + } + + late final _isar_watch_collectionPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + DartPort)>>('isar_watch_collection'); + late final _isar_watch_collection = _isar_watch_collectionPtr.asFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer, int)>(); + + ffi.Pointer isar_watch_object( + ffi.Pointer isar, + ffi.Pointer collection, + int id, + int port, + ) { + return _isar_watch_object( + isar, + collection, + id, + port, + ); + } + + late final _isar_watch_objectPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Int64, + DartPort)>>('isar_watch_object'); + late final _isar_watch_object = _isar_watch_objectPtr.asFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer, int, int)>(); + + ffi.Pointer isar_watch_query( + ffi.Pointer isar, + ffi.Pointer collection, + ffi.Pointer query, + int port, + ) { + return _isar_watch_query( + isar, + collection, + query, + port, + ); + } + + late final _isar_watch_queryPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + DartPort)>>('isar_watch_query'); + late final _isar_watch_query = _isar_watch_queryPtr.asFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer, int)>(); + + void isar_stop_watching( + ffi.Pointer handle, + ) { + return _isar_stop_watching( + handle, + ); + } + + late final _isar_stop_watchingPtr = + _lookup)>>( + 'isar_stop_watching'); + late final _isar_stop_watching = _isar_stop_watchingPtr + .asFunction)>(); +} + +class CObject extends ffi.Struct { + @ffi.Int64() + external int id; + + external ffi.Pointer buffer; + + @ffi.Uint32() + external int buffer_length; +} + +class CObjectSet extends ffi.Struct { + external ffi.Pointer objects; + + @ffi.Uint32() + external int length; +} + +class CIsarCollection extends ffi.Opaque {} + +class CIsarTxn extends ffi.Opaque {} + +class CIndexKey extends ffi.Opaque {} + +typedef DartPostCObjectFnType = ffi.Pointer< + ffi.NativeFunction)>>; +typedef DartPort = ffi.Int64; + +class CDartCObject extends ffi.Opaque {} + +class CFilter extends ffi.Opaque {} + +class CIsarInstance extends ffi.Opaque {} + +class CQueryBuilder extends ffi.Opaque {} + +class CQuery extends ffi.Opaque {} + +class CAggregationResult extends ffi.Opaque {} + +class CWatchHandle extends ffi.Opaque {} + +const int IsarIndex_MAX_STRING_INDEX_SIZE = 1024; + +const int IsarObject_NULL_BYTE = 0; + +const int IsarObject_NULL_BOOL = 0; + +const int IsarObject_FALSE_BOOL = 1; + +const int IsarObject_TRUE_BOOL = 2; + +const int IsarObject_NULL_INT = -2147483648; + +const int IsarObject_NULL_LONG = -9223372036854775808; + +const int IsarObject_MAX_SIZE = 33554432; + +const int SchemaManager_ISAR_FILE_VERSION = 2; diff --git a/packages_external/isar-3.1.0-1/packages/isar/lib/src/native/encode_string.dart b/packages_external/isar-3.1.0-1/packages/isar/lib/src/native/encode_string.dart new file mode 100644 index 00000000..a21aa545 --- /dev/null +++ b/packages_external/isar-3.1.0-1/packages/isar/lib/src/native/encode_string.dart @@ -0,0 +1,54 @@ +import 'dart:ffi'; +import 'dart:typed_data'; + +const int _oneByteLimit = 0x7f; // 7 bits +const int _twoByteLimit = 0x7ff; // 11 bits +const int _surrogateTagMask = 0xFC00; +const int _surrogateValueMask = 0x3FF; +const int _leadSurrogateMin = 0xD800; + +/// Encodes a Dart String to UTF8, writes it at [offset] into [buffer] and +/// returns the number of written bytes. +/// +/// The buffer needs to have a capacity of at least `offset + str.length * 3`. +int encodeString(String str, Uint8List buffer, int offset) { + final startOffset = offset; + for (var stringIndex = 0; stringIndex < str.length; stringIndex++) { + final codeUnit = str.codeUnitAt(stringIndex); + // ASCII has the same representation in UTF-8 and UTF-16. + if (codeUnit <= _oneByteLimit) { + buffer[offset++] = codeUnit; + } else if ((codeUnit & _surrogateTagMask) == _leadSurrogateMin) { + // combine surrogate pair + final nextCodeUnit = str.codeUnitAt(++stringIndex); + final rune = 0x10000 + ((codeUnit & _surrogateValueMask) << 10) | + (nextCodeUnit & _surrogateValueMask); + // If the rune is encoded with 2 code-units then it must be encoded + // with 4 bytes in UTF-8. + buffer[offset++] = 0xF0 | (rune >> 18); + buffer[offset++] = 0x80 | ((rune >> 12) & 0x3f); + buffer[offset++] = 0x80 | ((rune >> 6) & 0x3f); + buffer[offset++] = 0x80 | (rune & 0x3f); + } else if (codeUnit <= _twoByteLimit) { + buffer[offset++] = 0xC0 | (codeUnit >> 6); + buffer[offset++] = 0x80 | (codeUnit & 0x3f); + } else { + buffer[offset++] = 0xE0 | (codeUnit >> 12); + buffer[offset++] = 0x80 | ((codeUnit >> 6) & 0x3f); + buffer[offset++] = 0x80 | (codeUnit & 0x3f); + } + } + return offset - startOffset; +} + +/// @nodoc +extension CString on String { + /// Create a zero terminated C-String from a Dart String + Pointer toCString(Allocator alloc) { + final bufferPtr = alloc(length * 3 + 1); + final buffer = bufferPtr.asTypedList(length * 3 + 1); + final size = encodeString(this, buffer, 0); + buffer[size] = 0; + return bufferPtr.cast(); + } +} diff --git a/packages_external/isar-3.1.0-1/packages/isar/lib/src/native/index_key.dart b/packages_external/isar-3.1.0-1/packages/isar/lib/src/native/index_key.dart new file mode 100644 index 00000000..04225785 --- /dev/null +++ b/packages_external/isar-3.1.0-1/packages/isar/lib/src/native/index_key.dart @@ -0,0 +1,257 @@ +// ignore_for_file: public_member_api_docs + +import 'dart:ffi'; + +import 'package:ffi/ffi.dart'; +import 'package:isar/isar.dart'; +import 'package:isar/src/native/bindings.dart'; +import 'package:isar/src/native/encode_string.dart'; +import 'package:isar/src/native/isar_core.dart'; +import 'package:isar/src/native/isar_writer_impl.dart'; + +final _keyPtrPtr = malloc>(); + +Pointer buildIndexKey( + CollectionSchema schema, + IndexSchema index, + IndexKey key, +) { + if (key.length > index.properties.length) { + throw IsarError('Invalid number of values for index ${index.name}.'); + } + + IC.isar_key_create(_keyPtrPtr); + final keyPtr = _keyPtrPtr.value; + + for (var i = 0; i < key.length; i++) { + final indexProperty = index.properties[i]; + _addKeyValue( + keyPtr, + key[i], + schema.property(indexProperty.name), + indexProperty.type, + indexProperty.caseSensitive, + ); + } + + return keyPtr; +} + +Pointer buildLowerUnboundedIndexKey() { + IC.isar_key_create(_keyPtrPtr); + return _keyPtrPtr.value; +} + +Pointer buildUpperUnboundedIndexKey() { + IC.isar_key_create(_keyPtrPtr); + final keyPtr = _keyPtrPtr.value; + IC.isar_key_add_long(keyPtr, maxLong); + + return keyPtr; +} + +void _addKeyValue( + Pointer keyPtr, + Object? value, + PropertySchema property, + IndexType type, + bool caseSensitive, +) { + if (property.enumMap != null) { + if (value is Enum) { + value = property.enumMap![value.name]; + } else if (value is List) { + value = value.map((e) { + if (e is Enum) { + return property.enumMap![e.name]; + } else { + return e; + } + }).toList(); + } + } + + final isarType = + type != IndexType.hash ? property.type.scalarType : property.type; + switch (isarType) { + case IsarType.bool: + IC.isar_key_add_byte(keyPtr, (value as bool?).byteValue); + break; + case IsarType.byte: + IC.isar_key_add_byte(keyPtr, (value ?? 0) as int); + break; + case IsarType.int: + IC.isar_key_add_int(keyPtr, (value as int?) ?? nullInt); + break; + case IsarType.float: + IC.isar_key_add_float(keyPtr, (value as double?) ?? nullFloat); + break; + case IsarType.long: + IC.isar_key_add_long(keyPtr, (value as int?) ?? nullLong); + break; + case IsarType.double: + IC.isar_key_add_double(keyPtr, (value as double?) ?? nullDouble); + break; + case IsarType.dateTime: + IC.isar_key_add_long(keyPtr, (value as DateTime?).longValue); + break; + case IsarType.string: + final strPtr = _strToNative(value as String?); + if (type == IndexType.value) { + IC.isar_key_add_string(keyPtr, strPtr, caseSensitive); + } else { + IC.isar_key_add_string_hash(keyPtr, strPtr, caseSensitive); + } + _freeStr(strPtr); + break; + case IsarType.boolList: + if (value == null) { + IC.isar_key_add_byte_list_hash(keyPtr, nullptr, 0); + } else { + value as List; + final boolListPtr = malloc(value.length); + boolListPtr + .asTypedList(value.length) + .setAll(0, value.map((e) => e.byteValue)); + IC.isar_key_add_byte_list_hash(keyPtr, boolListPtr, value.length); + malloc.free(boolListPtr); + } + break; + case IsarType.byteList: + if (value == null) { + IC.isar_key_add_byte_list_hash(keyPtr, nullptr, 0); + } else { + value as List; + final bytesPtr = malloc(value.length); + bytesPtr.asTypedList(value.length).setAll(0, value); + IC.isar_key_add_byte_list_hash(keyPtr, bytesPtr, value.length); + malloc.free(bytesPtr); + } + break; + case IsarType.intList: + if (value == null) { + IC.isar_key_add_int_list_hash(keyPtr, nullptr, 0); + } else { + value as List; + final intListPtr = malloc(value.length); + intListPtr + .asTypedList(value.length) + .setAll(0, value.map((e) => e ?? nullInt)); + IC.isar_key_add_int_list_hash(keyPtr, intListPtr, value.length); + malloc.free(intListPtr); + } + break; + case IsarType.longList: + if (value == null) { + IC.isar_key_add_long_list_hash(keyPtr, nullptr, 0); + } else { + value as List; + final longListPtr = malloc(value.length); + longListPtr + .asTypedList(value.length) + .setAll(0, value.map((e) => e ?? nullLong)); + IC.isar_key_add_long_list_hash(keyPtr, longListPtr, value.length); + malloc.free(longListPtr); + } + break; + case IsarType.dateTimeList: + if (value == null) { + IC.isar_key_add_long_list_hash(keyPtr, nullptr, 0); + } else { + value as List; + final longListPtr = malloc(value.length); + for (var i = 0; i < value.length; i++) { + longListPtr[i] = value[i].longValue; + } + IC.isar_key_add_long_list_hash(keyPtr, longListPtr, value.length); + } + break; + case IsarType.stringList: + if (value == null) { + IC.isar_key_add_string_list_hash(keyPtr, nullptr, 0, false); + } else { + value as List; + final stringListPtr = malloc>(value.length); + for (var i = 0; i < value.length; i++) { + stringListPtr[i] = _strToNative(value[i]); + } + IC.isar_key_add_string_list_hash( + keyPtr, + stringListPtr, + value.length, + caseSensitive, + ); + for (var i = 0; i < value.length; i++) { + _freeStr(stringListPtr[i]); + } + } + break; + case IsarType.object: + case IsarType.floatList: + case IsarType.doubleList: + case IsarType.objectList: + throw IsarError('Unsupported property type.'); + } +} + +Pointer _strToNative(String? str) { + if (str == null) { + return Pointer.fromAddress(0); + } else { + return str.toCString(malloc); + } +} + +void _freeStr(Pointer strPtr) { + if (!strPtr.isNull) { + malloc.free(strPtr); + } +} + +double? adjustFloatBound({ + required double? value, + required bool lowerBound, + required bool include, + required double epsilon, +}) { + value ??= double.nan; + + if (lowerBound) { + if (include) { + if (value.isFinite) { + return value - epsilon; + } + } else { + if (value.isNaN) { + return double.negativeInfinity; + } else if (value == double.negativeInfinity) { + return -double.maxFinite; + } else if (value == double.maxFinite) { + return double.infinity; + } else if (value == double.infinity) { + return null; + } else { + return value + epsilon; + } + } + } else { + if (include) { + if (value.isFinite) { + return value + epsilon; + } + } else { + if (value.isNaN) { + return null; + } else if (value == double.negativeInfinity) { + return double.nan; + } else if (value == -double.maxFinite) { + return double.negativeInfinity; + } else if (value == double.infinity) { + return double.maxFinite; + } else { + return value - epsilon; + } + } + } + return value; +} diff --git a/packages_external/isar-3.1.0-1/packages/isar/lib/src/native/isar_collection_impl.dart b/packages_external/isar-3.1.0-1/packages/isar/lib/src/native/isar_collection_impl.dart new file mode 100644 index 00000000..0551ee37 --- /dev/null +++ b/packages_external/isar-3.1.0-1/packages/isar/lib/src/native/isar_collection_impl.dart @@ -0,0 +1,649 @@ +// ignore_for_file: public_member_api_docs, invalid_use_of_protected_member + +import 'dart:async'; +import 'dart:convert'; +import 'dart:ffi'; +import 'dart:isolate'; +import 'dart:typed_data'; + +import 'package:ffi/ffi.dart'; +import 'package:isar/isar.dart'; +import 'package:isar/src/native/bindings.dart'; +import 'package:isar/src/native/encode_string.dart'; +import 'package:isar/src/native/index_key.dart'; +import 'package:isar/src/native/isar_core.dart'; +import 'package:isar/src/native/isar_impl.dart'; +import 'package:isar/src/native/isar_reader_impl.dart'; +import 'package:isar/src/native/isar_writer_impl.dart'; +import 'package:isar/src/native/query_build.dart'; +import 'package:isar/src/native/txn.dart'; + +class IsarCollectionImpl extends IsarCollection { + IsarCollectionImpl({ + required this.isar, + required this.ptr, + required this.schema, + }); + + @override + final IsarImpl isar; + final Pointer ptr; + + @override + final CollectionSchema schema; + + late final _offsets = isar.offsets[OBJ]!; + late final _staticSize = _offsets.last; + + @pragma('vm:prefer-inline') + OBJ deserializeObject(CObject cObj) { + final buffer = cObj.buffer.asTypedList(cObj.buffer_length); + final reader = IsarReaderImpl(buffer); + final object = schema.deserialize( + cObj.id, + reader, + _offsets, + isar.offsets, + ); + schema.attach(this, cObj.id, object); + return object; + } + + @pragma('vm:prefer-inline') + OBJ? deserializeObjectOrNull(CObject cObj) { + if (!cObj.buffer.isNull) { + return deserializeObject(cObj); + } else { + return null; + } + } + + @pragma('vm:prefer-inline') + List deserializeObjects(CObjectSet objectSet) { + final objects = []; + for (var i = 0; i < objectSet.length; i++) { + final cObjPtr = objectSet.objects.elementAt(i); + final object = deserializeObject(cObjPtr.ref); + objects.add(object); + } + return objects; + } + + @pragma('vm:prefer-inline') + List deserializeObjectsOrNull(CObjectSet objectSet) { + final objects = List.filled(objectSet.length, null); + for (var i = 0; i < objectSet.length; i++) { + final cObj = objectSet.objects.elementAt(i).ref; + if (!cObj.buffer.isNull) { + objects[i] = deserializeObject(cObj); + } + } + return objects; + } + + @pragma('vm:prefer-inline') + Pointer> _getKeysPtr( + String indexName, + List keys, + Allocator alloc, + ) { + final keysPtrPtr = alloc>(keys.length); + for (var i = 0; i < keys.length; i++) { + keysPtrPtr[i] = buildIndexKey(schema, schema.index(indexName), keys[i]); + } + return keysPtrPtr; + } + + List deserializeProperty(CObjectSet objectSet, int? propertyId) { + final values = []; + if (propertyId != null) { + final propertyOffset = _offsets[propertyId]; + for (var i = 0; i < objectSet.length; i++) { + final cObj = objectSet.objects.elementAt(i).ref; + final buffer = cObj.buffer.asTypedList(cObj.buffer_length); + values.add( + schema.deserializeProp( + IsarReaderImpl(buffer), + propertyId, + propertyOffset, + isar.offsets, + ) as T, + ); + } + } else { + for (var i = 0; i < objectSet.length; i++) { + final cObj = objectSet.objects.elementAt(i).ref; + values.add(cObj.id as T); + } + } + return values; + } + + void serializeObjects( + Txn txn, + Pointer objectsPtr, + List objects, + ) { + var maxBufferSize = 0; + for (var i = 0; i < objects.length; i++) { + final object = objects[i]; + maxBufferSize += schema.estimateSize(object, _offsets, isar.offsets); + } + final bufferPtr = txn.alloc(maxBufferSize); + final buffer = bufferPtr.asTypedList(maxBufferSize).buffer; + + var writtenBytes = 0; + for (var i = 0; i < objects.length; i++) { + final objBuffer = buffer.asUint8List(writtenBytes); + final binaryWriter = IsarWriterImpl(objBuffer, _staticSize); + + final object = objects[i]; + schema.serialize( + object, + binaryWriter, + _offsets, + isar.offsets, + ); + final size = binaryWriter.usedBytes; + + final cObj = objectsPtr.elementAt(i).ref; + cObj.id = schema.getId(object); + cObj.buffer = bufferPtr.elementAt(writtenBytes); + cObj.buffer_length = size; + + writtenBytes += size; + } + } + + @override + Future> getAll(List ids) { + return isar.getTxn(false, (Txn txn) async { + final cObjSetPtr = txn.newCObjectSet(ids.length); + final objectsPtr = cObjSetPtr.ref.objects; + for (var i = 0; i < ids.length; i++) { + objectsPtr.elementAt(i).ref.id = ids[i]; + } + IC.isar_get_all(ptr, txn.ptr, cObjSetPtr); + await txn.wait(); + return deserializeObjectsOrNull(cObjSetPtr.ref); + }); + } + + @override + List getAllSync(List ids) { + return isar.getTxnSync(false, (Txn txn) { + final cObjPtr = txn.getCObject(); + final cObj = cObjPtr.ref; + + final objects = List.filled(ids.length, null); + for (var i = 0; i < ids.length; i++) { + cObj.id = ids[i]; + nCall(IC.isar_get(ptr, txn.ptr, cObjPtr)); + objects[i] = deserializeObjectOrNull(cObj); + } + + return objects; + }); + } + + @override + Future> getAllByIndex(String indexName, List keys) { + return isar.getTxn(false, (Txn txn) async { + final cObjSetPtr = txn.newCObjectSet(keys.length); + final keysPtrPtr = _getKeysPtr(indexName, keys, txn.alloc); + IC.isar_get_all_by_index( + ptr, + txn.ptr, + schema.index(indexName).id, + keysPtrPtr, + cObjSetPtr, + ); + await txn.wait(); + return deserializeObjectsOrNull(cObjSetPtr.ref); + }); + } + + @override + List getAllByIndexSync(String indexName, List keys) { + final index = schema.index(indexName); + + return isar.getTxnSync(false, (Txn txn) { + final cObjPtr = txn.getCObject(); + final cObj = cObjPtr.ref; + + final objects = List.filled(keys.length, null); + for (var i = 0; i < keys.length; i++) { + final keyPtr = buildIndexKey(schema, index, keys[i]); + nCall(IC.isar_get_by_index(ptr, txn.ptr, index.id, keyPtr, cObjPtr)); + objects[i] = deserializeObjectOrNull(cObj); + } + + return objects; + }); + } + + @override + int putSync(OBJ object, {bool saveLinks = true}) { + return isar.getTxnSync(true, (Txn txn) { + return putByIndexSyncInternal( + txn: txn, + object: object, + saveLinks: saveLinks, + ); + }); + } + + @override + int putByIndexSync(String indexName, OBJ object, {bool saveLinks = true}) { + return isar.getTxnSync(true, (Txn txn) { + return putByIndexSyncInternal( + txn: txn, + object: object, + indexId: schema.index(indexName).id, + saveLinks: saveLinks, + ); + }); + } + + int putByIndexSyncInternal({ + required Txn txn, + int? indexId, + required OBJ object, + bool saveLinks = true, + }) { + final cObjPtr = txn.getCObject(); + final cObj = cObjPtr.ref; + + final estimatedSize = schema.estimateSize(object, _offsets, isar.offsets); + cObj.buffer = txn.getBuffer(estimatedSize); + final buffer = cObj.buffer.asTypedList(estimatedSize); + + final writer = IsarWriterImpl(buffer, _staticSize); + schema.serialize( + object, + writer, + _offsets, + isar.offsets, + ); + cObj.buffer_length = writer.usedBytes; + + cObj.id = schema.getId(object); + + if (indexId != null) { + nCall(IC.isar_put_by_index(ptr, txn.ptr, indexId, cObjPtr)); + } else { + nCall(IC.isar_put(ptr, txn.ptr, cObjPtr)); + } + + final id = cObj.id; + schema.attach(this, id, object); + + if (saveLinks) { + for (final link in schema.getLinks(object)) { + link.saveSync(); + } + } + + return id; + } + + @override + Future> putAll(List objects) { + return putAllByIndex(null, objects); + } + + @override + List putAllSync(List objects, {bool saveLinks = true}) { + return putAllByIndexSync(null, objects, saveLinks: saveLinks); + } + + @override + Future> putAllByIndex(String? indexName, List objects) { + final indexId = indexName != null ? schema.index(indexName).id : null; + + return isar.getTxn(true, (Txn txn) async { + final cObjSetPtr = txn.newCObjectSet(objects.length); + serializeObjects(txn, cObjSetPtr.ref.objects, objects); + + if (indexId != null) { + IC.isar_put_all_by_index(ptr, txn.ptr, indexId, cObjSetPtr); + } else { + IC.isar_put_all(ptr, txn.ptr, cObjSetPtr); + } + + await txn.wait(); + final cObjectSet = cObjSetPtr.ref; + final ids = List.filled(objects.length, 0); + for (var i = 0; i < objects.length; i++) { + final cObjPtr = cObjectSet.objects.elementAt(i); + final id = cObjPtr.ref.id; + ids[i] = id; + + final object = objects[i]; + schema.attach(this, id, object); + } + return ids; + }); + } + + @override + List putAllByIndexSync( + String? indexName, + List objects, { + bool saveLinks = true, + }) { + final indexId = indexName != null ? schema.index(indexName).id : null; + final ids = List.filled(objects.length, 0); + isar.getTxnSync(true, (Txn txn) { + for (var i = 0; i < objects.length; i++) { + ids[i] = putByIndexSyncInternal( + txn: txn, + object: objects[i], + indexId: indexId, + saveLinks: saveLinks, + ); + } + }); + return ids; + } + + @override + Future deleteAll(List ids) { + return isar.getTxn(true, (Txn txn) async { + final countPtr = txn.alloc(); + final idsPtr = txn.alloc(ids.length); + idsPtr.asTypedList(ids.length).setAll(0, ids); + + IC.isar_delete_all(ptr, txn.ptr, idsPtr, ids.length, countPtr); + await txn.wait(); + + return countPtr.value; + }); + } + + @override + int deleteAllSync(List ids) { + return isar.getTxnSync(true, (Txn txn) { + final deletedPtr = txn.alloc(); + + var counter = 0; + for (var i = 0; i < ids.length; i++) { + nCall(IC.isar_delete(ptr, txn.ptr, ids[i], deletedPtr)); + if (deletedPtr.value) { + counter++; + } + } + return counter; + }); + } + + @override + Future deleteAllByIndex(String indexName, List keys) { + return isar.getTxn(true, (Txn txn) async { + final countPtr = txn.alloc(); + final keysPtrPtr = _getKeysPtr(indexName, keys, txn.alloc); + + IC.isar_delete_all_by_index( + ptr, + txn.ptr, + schema.index(indexName).id, + keysPtrPtr, + keys.length, + countPtr, + ); + await txn.wait(); + + return countPtr.value; + }); + } + + @override + int deleteAllByIndexSync(String indexName, List keys) { + return isar.getTxnSync(true, (Txn txn) { + final countPtr = txn.alloc(); + final keysPtrPtr = _getKeysPtr(indexName, keys, txn.alloc); + + nCall( + IC.isar_delete_all_by_index( + ptr, + txn.ptr, + schema.index(indexName).id, + keysPtrPtr, + keys.length, + countPtr, + ), + ); + return countPtr.value; + }); + } + + @override + Future clear() { + return isar.getTxn(true, (Txn txn) async { + IC.isar_clear(ptr, txn.ptr); + await txn.wait(); + }); + } + + @override + void clearSync() { + isar.getTxnSync(true, (Txn txn) { + nCall(IC.isar_clear(ptr, txn.ptr)); + }); + } + + @override + Future importJson(List> json) { + final bytes = const Utf8Encoder().convert(jsonEncode(json)); + return importJsonRaw(bytes); + } + + @override + Future importJsonRaw(Uint8List jsonBytes) { + return isar.getTxn(true, (Txn txn) async { + final bytesPtr = txn.alloc(jsonBytes.length); + bytesPtr.asTypedList(jsonBytes.length).setAll(0, jsonBytes); + final idNamePtr = schema.idName.toCString(txn.alloc); + + IC.isar_json_import( + ptr, + txn.ptr, + idNamePtr, + bytesPtr, + jsonBytes.length, + ); + await txn.wait(); + }); + } + + @override + void importJsonSync(List> json) { + final bytes = const Utf8Encoder().convert(jsonEncode(json)); + importJsonRawSync(bytes); + } + + @override + void importJsonRawSync(Uint8List jsonBytes) { + return isar.getTxnSync(true, (Txn txn) async { + final bytesPtr = txn.getBuffer(jsonBytes.length); + bytesPtr.asTypedList(jsonBytes.length).setAll(0, jsonBytes); + final idNamePtr = schema.idName.toCString(txn.alloc); + + nCall( + IC.isar_json_import( + ptr, + txn.ptr, + idNamePtr, + bytesPtr, + jsonBytes.length, + ), + ); + }); + } + + @override + Future count() { + return isar.getTxn(false, (Txn txn) async { + final countPtr = txn.alloc(); + IC.isar_count(ptr, txn.ptr, countPtr); + await txn.wait(); + return countPtr.value; + }); + } + + @override + int countSync() { + return isar.getTxnSync(false, (Txn txn) { + final countPtr = txn.alloc(); + nCall(IC.isar_count(ptr, txn.ptr, countPtr)); + return countPtr.value; + }); + } + + @override + Future getSize({ + bool includeIndexes = false, + bool includeLinks = false, + }) { + return isar.getTxn(false, (Txn txn) async { + final sizePtr = txn.alloc(); + IC.isar_get_size(ptr, txn.ptr, includeIndexes, includeLinks, sizePtr); + await txn.wait(); + return sizePtr.value; + }); + } + + @override + int getSizeSync({bool includeIndexes = false, bool includeLinks = false}) { + return isar.getTxnSync(false, (Txn txn) { + final sizePtr = txn.alloc(); + nCall( + IC.isar_get_size( + ptr, + txn.ptr, + includeIndexes, + includeLinks, + sizePtr, + ), + ); + return sizePtr.value; + }); + } + + @override + Stream watchLazy({bool fireImmediately = false}) { + isar.requireOpen(); + final port = ReceivePort(); + final handle = + IC.isar_watch_collection(isar.ptr, ptr, port.sendPort.nativePort); + final controller = StreamController( + onCancel: () { + IC.isar_stop_watching(handle); + port.close(); + }, + ); + + if (fireImmediately) { + controller.add(null); + } + + controller.addStream(port); + return controller.stream; + } + + @override + Stream watchObject(Id id, {bool fireImmediately = false}) { + return watchObjectLazy(id, fireImmediately: fireImmediately) + .asyncMap((event) => get(id)); + } + + @override + Stream watchObjectLazy(Id id, {bool fireImmediately = false}) { + isar.requireOpen(); + final cObjPtr = malloc(); + + final port = ReceivePort(); + final handle = + IC.isar_watch_object(isar.ptr, ptr, id, port.sendPort.nativePort); + malloc.free(cObjPtr); + + final controller = StreamController( + onCancel: () { + IC.isar_stop_watching(handle); + port.close(); + }, + ); + + if (fireImmediately) { + controller.add(null); + } + + controller.addStream(port); + return controller.stream; + } + + @override + Query buildQuery({ + List whereClauses = const [], + bool whereDistinct = false, + Sort whereSort = Sort.asc, + FilterOperation? filter, + List sortBy = const [], + List distinctBy = const [], + int? offset, + int? limit, + String? property, + }) { + isar.requireOpen(); + return buildNativeQuery( + this, + whereClauses, + whereDistinct, + whereSort, + filter, + sortBy, + distinctBy, + offset, + limit, + property, + ); + } + + @override + Future verify(List objects) async { + await isar.verify(); + return isar.getTxn(false, (Txn txn) async { + final cObjSetPtr = txn.newCObjectSet(objects.length); + serializeObjects(txn, cObjSetPtr.ref.objects, objects); + + IC.isar_verify(ptr, txn.ptr, cObjSetPtr); + await txn.wait(); + }); + } + + @override + Future verifyLink( + String linkName, + List sourceIds, + List targetIds, + ) async { + final link = schema.link(linkName); + + return isar.getTxn(false, (Txn txn) async { + final idsPtr = txn.alloc(sourceIds.length + targetIds.length); + for (var i = 0; i < sourceIds.length; i++) { + idsPtr[i * 2] = sourceIds[i]; + idsPtr[i * 2 + 1] = targetIds[i]; + } + + IC.isar_link_verify( + ptr, + txn.ptr, + link.id, + idsPtr, + sourceIds.length + targetIds.length, + ); + await txn.wait(); + }); + } +} diff --git a/packages_external/isar-3.1.0-1/packages/isar/lib/src/native/isar_core.dart b/packages_external/isar-3.1.0-1/packages/isar/lib/src/native/isar_core.dart new file mode 100644 index 00000000..6ca7389a --- /dev/null +++ b/packages_external/isar-3.1.0-1/packages/isar/lib/src/native/isar_core.dart @@ -0,0 +1,234 @@ +// ignore_for_file: public_member_api_docs + +import 'dart:async'; +import 'dart:ffi'; +import 'dart:io'; +import 'dart:isolate'; + +import 'package:ffi/ffi.dart'; +import 'package:isar/isar.dart'; +import 'package:isar/src/native/bindings.dart'; + +const Id isarMinId = -9223372036854775807; + +const Id isarMaxId = 9223372036854775807; + +const Id isarAutoIncrementId = -9223372036854775808; + +typedef IsarAbi = Abi; + +const int minByte = 0; +const int maxByte = 255; +const int minInt = -2147483648; +const int maxInt = 2147483647; +const int minLong = -9223372036854775808; +const int maxLong = 9223372036854775807; +const double minDouble = double.nan; +const double maxDouble = double.infinity; + +const nullByte = IsarObject_NULL_BYTE; +const nullInt = IsarObject_NULL_INT; +const nullLong = IsarObject_NULL_LONG; +const nullFloat = double.nan; +const nullDouble = double.nan; +final nullDate = DateTime.fromMillisecondsSinceEpoch(0); + +const nullBool = IsarObject_NULL_BOOL; +const falseBool = IsarObject_FALSE_BOOL; +const trueBool = IsarObject_TRUE_BOOL; + +const String _githubUrl = 'https://github.com/isar/isar/releases/download'; + +bool _isarInitialized = false; + +// ignore: non_constant_identifier_names +late final IsarCoreBindings IC; + +typedef FinalizerFunction = void Function(Pointer token); +late final Pointer isarClose; +late final Pointer isarQueryFree; + +FutureOr initializeCoreBinary({ + Map libraries = const {}, + bool download = false, +}) { + if (_isarInitialized) { + return null; + } + + String? libraryPath; + if (!Platform.isIOS) { + libraryPath = libraries[Abi.current()] ?? Abi.current().localName; + } + + try { + _initializePath(libraryPath); + } catch (e) { + if (!Platform.isAndroid && !Platform.isIOS) { + final downloadPath = _getLibraryDownloadPath(libraries); + if (download) { + return _downloadIsarCore(downloadPath).then((value) { + _initializePath(downloadPath); + }); + } else { + // try to use the binary at the download path anyway + _initializePath(downloadPath); + } + } else { + throw IsarError( + 'Could not initialize IsarCore library for processor architecture ' + '"${Abi.current()}". If you create a Flutter app, make sure to add ' + 'isar_flutter_libs to your dependencies.\n$e', + ); + } + } +} + +void _initializePath(String? libraryPath) { + late DynamicLibrary dylib; + if (Platform.isIOS) { + dylib = DynamicLibrary.process(); + } else { + dylib = DynamicLibrary.open(libraryPath!); + } + + final bindings = IsarCoreBindings(dylib); + + final coreVersion = bindings.isar_version().cast().toDartString(); + if (coreVersion != Isar.version && coreVersion != 'debug') { + throw IsarError( + 'Incorrect Isar Core version: Required ${Isar.version} found ' + '$coreVersion. Make sure to use the latest isar_flutter_libs. If you ' + 'have a Dart only project, make sure that old Isar Core binaries are ' + 'deleted.', + ); + } + + IC = bindings; + isarClose = dylib.lookup('isar_instance_close'); + isarQueryFree = dylib.lookup('isar_q_free'); + _isarInitialized = true; +} + +String _getLibraryDownloadPath(Map libraries) { + final providedPath = libraries[Abi.current()]; + if (providedPath != null) { + return providedPath; + } else { + final name = Abi.current().localName; + if (Platform.script.path.isEmpty) { + return name; + } + var dir = Platform.script.pathSegments + .sublist(0, Platform.script.pathSegments.length - 1) + .join(Platform.pathSeparator); + if (!Platform.isWindows) { + // Not on windows, add leading platform path separator + dir = '${Platform.pathSeparator}$dir'; + } + return '$dir${Platform.pathSeparator}$name'; + } +} + +Future _downloadIsarCore(String libraryPath) async { + final libraryFile = File(libraryPath); + // ignore: avoid_slow_async_io + if (await libraryFile.exists()) { + return; + } + final remoteName = Abi.current().remoteName; + final uri = Uri.parse('$_githubUrl/${Isar.version}/$remoteName'); + final request = await HttpClient().getUrl(uri); + final response = await request.close(); + if (response.statusCode != 200) { + throw IsarError( + 'Could not download IsarCore library: ${response.reasonPhrase}', + ); + } + await response.pipe(libraryFile.openWrite()); +} + +IsarError? isarErrorFromResult(int result) { + if (result != 0) { + final error = IC.isar_get_error(result); + if (error.address == 0) { + throw IsarError( + 'There was an error but it could not be loaded from IsarCore.', + ); + } + try { + final message = error.cast().toDartString(); + return IsarError(message); + } finally { + IC.isar_free_string(error); + } + } else { + return null; + } +} + +@pragma('vm:prefer-inline') +void nCall(int result) { + final error = isarErrorFromResult(result); + if (error != null) { + throw error; + } +} + +Stream wrapIsarPort(ReceivePort port) { + final portStreamController = StreamController(onCancel: port.close); + port.listen((event) { + if (event == 0) { + portStreamController.add(null); + } else { + final error = isarErrorFromResult(event as int); + portStreamController.addError(error!); + } + }); + return portStreamController.stream; +} + +extension PointerX on Pointer { + @pragma('vm:prefer-inline') + bool get isNull => address == 0; +} + +extension on Abi { + String get localName { + switch (Abi.current()) { + case Abi.androidArm: + case Abi.androidArm64: + case Abi.androidIA32: + case Abi.androidX64: + return 'libisar.so'; + case Abi.macosArm64: + case Abi.macosX64: + return 'libisar.dylib'; + case Abi.linuxX64: + return 'libisar.so'; + case Abi.windowsArm64: + case Abi.windowsX64: + return 'isar.dll'; + default: + throw IsarError( + 'Unsupported processor architecture "${Abi.current()}". ' + 'Please open an issue on GitHub to request it.', + ); + } + } + + String get remoteName { + switch (Abi.current()) { + case Abi.macosArm64: + case Abi.macosX64: + return 'libisar_macos.dylib'; + case Abi.linuxX64: + return 'libisar_linux_x64.so'; + case Abi.windowsArm64: + return 'isar_windows_arm64.dll'; + case Abi.windowsX64: + return 'isar_windows_x64.dll'; + } + throw UnimplementedError(); + } +} diff --git a/packages_external/isar-3.1.0-1/packages/isar/lib/src/native/isar_impl.dart b/packages_external/isar-3.1.0-1/packages/isar/lib/src/native/isar_impl.dart new file mode 100644 index 00000000..c2d47a23 --- /dev/null +++ b/packages_external/isar-3.1.0-1/packages/isar/lib/src/native/isar_impl.dart @@ -0,0 +1,139 @@ +// ignore_for_file: public_member_api_docs + +import 'dart:async'; +import 'dart:ffi'; +import 'dart:isolate'; + +import 'package:ffi/ffi.dart'; +import 'package:isar/src/common/isar_common.dart'; +import 'package:isar/src/native/bindings.dart'; +import 'package:isar/src/native/encode_string.dart'; +import 'package:isar/src/native/isar_core.dart'; +import 'package:isar/src/native/txn.dart'; + +class IsarImpl extends IsarCommon implements Finalizable { + IsarImpl(super.name, this.ptr) { + _finalizer = NativeFinalizer(isarClose); + _finalizer.attach(this, ptr.cast(), detach: this); + } + + final Pointer ptr; + late final NativeFinalizer _finalizer; + + final offsets = >{}; + + final Pointer> _syncTxnPtrPtr = malloc>(); + + String? _directory; + + @override + String get directory { + requireOpen(); + + if (_directory == null) { + final dirPtr = IC.isar_instance_get_path(ptr); + try { + _directory = dirPtr.cast().toDartString(); + } finally { + IC.isar_free_string(dirPtr); + } + } + + return _directory!; + } + + @override + Future beginTxn(bool write, bool silent) async { + final port = ReceivePort(); + final portStream = wrapIsarPort(port); + + final txnPtrPtr = malloc>(); + IC.isar_txn_begin( + ptr, + txnPtrPtr, + false, + write, + silent, + port.sendPort.nativePort, + ); + + final txn = Txn.async(this, txnPtrPtr.value, write, portStream); + await txn.wait(); + return txn; + } + + @override + Transaction beginTxnSync(bool write, bool silent) { + nCall(IC.isar_txn_begin(ptr, _syncTxnPtrPtr, true, write, silent, 0)); + return Txn.sync(this, _syncTxnPtrPtr.value, write); + } + + @override + bool performClose(bool deleteFromDisk) { + _finalizer.detach(this); + if (deleteFromDisk) { + return IC.isar_instance_close_and_delete(ptr); + } else { + return IC.isar_instance_close(ptr); + } + } + + @override + Future getSize({ + bool includeIndexes = false, + bool includeLinks = false, + }) { + return getTxn(false, (Txn txn) async { + final sizePtr = txn.alloc(); + IC.isar_instance_get_size( + ptr, + txn.ptr, + includeIndexes, + includeLinks, + sizePtr, + ); + await txn.wait(); + return sizePtr.value; + }); + } + + @override + int getSizeSync({bool includeIndexes = false, bool includeLinks = false}) { + return getTxnSync(false, (Txn txn) { + final sizePtr = txn.alloc(); + nCall( + IC.isar_instance_get_size( + ptr, + txn.ptr, + includeIndexes, + includeLinks, + sizePtr, + ), + ); + return sizePtr.value; + }); + } + + @override + Future copyToFile(String targetPath) async { + final pathPtr = targetPath.toCString(malloc); + final receivePort = ReceivePort(); + final nativePort = receivePort.sendPort.nativePort; + + try { + final stream = wrapIsarPort(receivePort); + IC.isar_instance_copy_to_file(ptr, pathPtr, nativePort); + await stream.first; + } finally { + malloc.free(pathPtr); + } + } + + @override + Future verify() async { + return getTxn(false, (Txn txn) async { + IC.isar_instance_verify(ptr, txn.ptr); + await txn.wait(); + }); + } +} diff --git a/packages_external/isar-3.1.0-1/packages/isar/lib/src/native/isar_link_impl.dart b/packages_external/isar-3.1.0-1/packages/isar/lib/src/native/isar_link_impl.dart new file mode 100644 index 00000000..3c954c7d --- /dev/null +++ b/packages_external/isar-3.1.0-1/packages/isar/lib/src/native/isar_link_impl.dart @@ -0,0 +1,121 @@ +// ignore_for_file: public_member_api_docs + +import 'dart:ffi'; + +import 'package:isar/isar.dart'; +import 'package:isar/src/common/isar_link_base_impl.dart'; +import 'package:isar/src/common/isar_link_common.dart'; +import 'package:isar/src/common/isar_links_common.dart'; +import 'package:isar/src/native/isar_collection_impl.dart'; +import 'package:isar/src/native/isar_core.dart'; +import 'package:isar/src/native/txn.dart'; + +mixin IsarLinkBaseMixin on IsarLinkBaseImpl { + @override + IsarCollectionImpl get sourceCollection => + super.sourceCollection as IsarCollectionImpl; + + @override + IsarCollectionImpl get targetCollection => + super.targetCollection as IsarCollectionImpl; + + late final int linkId = sourceCollection.schema.link(linkName).id; + + @override + late final getId = targetCollection.schema.getId; + + @override + Future update({ + Iterable link = const [], + Iterable unlink = const [], + bool reset = false, + }) { + final linkList = link.toList(); + final unlinkList = unlink.toList(); + + final containingId = requireAttached(); + return targetCollection.isar.getTxn(true, (Txn txn) { + final count = linkList.length + unlinkList.length; + final idsPtr = txn.alloc(count); + final ids = idsPtr.asTypedList(count); + + for (var i = 0; i < linkList.length; i++) { + ids[i] = requireGetId(linkList[i]); + } + for (var i = 0; i < unlinkList.length; i++) { + ids[linkList.length + i] = requireGetId(unlinkList[i]); + } + + IC.isar_link_update_all( + sourceCollection.ptr, + txn.ptr, + linkId, + containingId, + idsPtr, + linkList.length, + unlinkList.length, + reset, + ); + return txn.wait(); + }); + } + + @override + void updateSync({ + Iterable link = const [], + Iterable unlink = const [], + bool reset = false, + }) { + final containingId = requireAttached(); + targetCollection.isar.getTxnSync(true, (Txn txn) { + if (reset) { + nCall( + IC.isar_link_unlink_all( + sourceCollection.ptr, + txn.ptr, + linkId, + containingId, + ), + ); + } + + for (final object in link) { + var id = getId(object); + if (id == Isar.autoIncrement) { + id = targetCollection.putByIndexSyncInternal( + txn: txn, + object: object, + ); + } + + nCall( + IC.isar_link( + sourceCollection.ptr, + txn.ptr, + linkId, + containingId, + id, + ), + ); + } + for (final object in unlink) { + final unlinkId = requireGetId(object); + nCall( + IC.isar_link_unlink( + sourceCollection.ptr, + txn.ptr, + linkId, + containingId, + unlinkId, + ), + ); + } + }); + } +} + +class IsarLinkImpl extends IsarLinkCommon + with IsarLinkBaseMixin {} + +class IsarLinksImpl extends IsarLinksCommon + with IsarLinkBaseMixin {} diff --git a/packages_external/isar-3.1.0-1/packages/isar/lib/src/native/isar_reader_impl.dart b/packages_external/isar-3.1.0-1/packages/isar/lib/src/native/isar_reader_impl.dart new file mode 100644 index 00000000..96969cb0 --- /dev/null +++ b/packages_external/isar-3.1.0-1/packages/isar/lib/src/native/isar_reader_impl.dart @@ -0,0 +1,591 @@ +// ignore_for_file: public_member_api_docs + +import 'dart:convert'; +import 'dart:typed_data'; + +import 'package:isar/isar.dart'; +import 'package:isar/src/native/isar_core.dart'; +import 'package:meta/meta.dart'; + +/// @nodoc +@protected +class IsarReaderImpl implements IsarReader { + IsarReaderImpl(this._buffer) + : _byteData = ByteData.view(_buffer.buffer, _buffer.offsetInBytes) { + _staticSize = _byteData.getUint16(0, Endian.little); + } + + static const Utf8Decoder utf8Decoder = Utf8Decoder(); + + final Uint8List _buffer; + final ByteData _byteData; + late int _staticSize; + + @pragma('vm:prefer-inline') + bool _readBool(int offset) { + final value = _buffer[offset]; + if (value == trueBool) { + return true; + } else { + return false; + } + } + + @pragma('vm:prefer-inline') + @override + bool readBool(int offset) { + if (offset >= _staticSize) { + return false; + } + return _readBool(offset); + } + + @pragma('vm:prefer-inline') + bool? _readBoolOrNull(int offset) { + final value = _buffer[offset]; + if (value == trueBool) { + return true; + } else if (value == falseBool) { + return false; + } else { + return null; + } + } + + @pragma('vm:prefer-inline') + @override + bool? readBoolOrNull(int offset) { + if (offset >= _staticSize) { + return null; + } + return _readBoolOrNull(offset); + } + + @pragma('vm:prefer-inline') + @override + int readByte(int offset) { + if (offset >= _staticSize) { + return 0; + } + return _buffer[offset]; + } + + @pragma('vm:prefer-inline') + @override + int? readByteOrNull(int offset) { + if (offset >= _staticSize) { + return null; + } + return _buffer[offset]; + } + + @pragma('vm:prefer-inline') + @override + int readInt(int offset) { + if (offset >= _staticSize) { + return nullInt; + } + return _byteData.getInt32(offset, Endian.little); + } + + @pragma('vm:prefer-inline') + int? _readIntOrNull(int offset) { + final value = _byteData.getInt32(offset, Endian.little); + if (value != nullInt) { + return value; + } else { + return null; + } + } + + @pragma('vm:prefer-inline') + @override + int? readIntOrNull(int offset) { + if (offset >= _staticSize) { + return null; + } + return _readIntOrNull(offset); + } + + @pragma('vm:prefer-inline') + @override + double readFloat(int offset) { + if (offset >= _staticSize) { + return nullDouble; + } + return _byteData.getFloat32(offset, Endian.little); + } + + @pragma('vm:prefer-inline') + double? _readFloatOrNull(int offset) { + final value = _byteData.getFloat32(offset, Endian.little); + if (!value.isNaN) { + return value; + } else { + return null; + } + } + + @pragma('vm:prefer-inline') + @override + double? readFloatOrNull(int offset) { + if (offset >= _staticSize) { + return null; + } + return _readFloatOrNull(offset); + } + + @pragma('vm:prefer-inline') + @override + int readLong(int offset) { + if (offset >= _staticSize) { + return nullLong; + } + return _byteData.getInt64(offset, Endian.little); + } + + @pragma('vm:prefer-inline') + int? _readLongOrNull(int offset) { + final value = _byteData.getInt64(offset, Endian.little); + if (value != nullLong) { + return value; + } else { + return null; + } + } + + @pragma('vm:prefer-inline') + @override + int? readLongOrNull(int offset) { + if (offset >= _staticSize) { + return null; + } + return _readLongOrNull(offset); + } + + @pragma('vm:prefer-inline') + @override + double readDouble(int offset) { + if (offset >= _staticSize) { + return nullDouble; + } + return _byteData.getFloat64(offset, Endian.little); + } + + @pragma('vm:prefer-inline') + double? _readDoubleOrNull(int offset) { + final value = _byteData.getFloat64(offset, Endian.little); + if (!value.isNaN) { + return value; + } else { + return null; + } + } + + @pragma('vm:prefer-inline') + @override + double? readDoubleOrNull(int offset) { + if (offset >= _staticSize) { + return null; + } + return _readDoubleOrNull(offset); + } + + @pragma('vm:prefer-inline') + @override + DateTime readDateTime(int offset) { + final time = readLongOrNull(offset); + return time != null + ? DateTime.fromMicrosecondsSinceEpoch(time, isUtc: true).toLocal() + : nullDate; + } + + @pragma('vm:prefer-inline') + @override + DateTime? readDateTimeOrNull(int offset) { + final time = readLongOrNull(offset); + if (time != null) { + return DateTime.fromMicrosecondsSinceEpoch(time, isUtc: true).toLocal(); + } else { + return null; + } + } + + @pragma('vm:prefer-inline') + int _readUint24(int offset) { + return _buffer[offset] | + _buffer[offset + 1] << 8 | + _buffer[offset + 2] << 16; + } + + @pragma('vm:prefer-inline') + @override + String readString(int offset) { + return readStringOrNull(offset) ?? ''; + } + + @pragma('vm:prefer-inline') + @override + String? readStringOrNull(int offset) { + if (offset >= _staticSize) { + return null; + } + + var bytesOffset = _readUint24(offset); + if (bytesOffset == 0) { + return null; + } + + final length = _readUint24(bytesOffset); + bytesOffset += 3; + + return utf8Decoder.convert(_buffer, bytesOffset, bytesOffset + length); + } + + @pragma('vm:prefer-inline') + @override + T? readObjectOrNull( + int offset, + Deserialize deserialize, + Map> allOffsets, + ) { + if (offset >= _staticSize) { + return null; + } + + var bytesOffset = _readUint24(offset); + if (bytesOffset == 0) { + return null; + } + + final length = _readUint24(bytesOffset); + bytesOffset += 3; + + final buffer = + Uint8List.sublistView(_buffer, bytesOffset, bytesOffset + length); + final reader = IsarReaderImpl(buffer); + final offsets = allOffsets[T]!; + return deserialize(0, reader, offsets, allOffsets); + } + + @override + List? readBoolList(int offset) { + if (offset >= _staticSize) { + return null; + } + + var listOffset = _readUint24(offset); + if (listOffset == 0) { + return null; + } + + final length = _readUint24(listOffset); + listOffset += 3; + + final list = List.filled(length, false); + for (var i = 0; i < length; i++) { + list[i] = _readBool(listOffset + i); + } + return list; + } + + @override + List? readBoolOrNullList(int offset) { + if (offset >= _staticSize) { + return null; + } + + var listOffset = _readUint24(offset); + if (listOffset == 0) { + return null; + } + + final length = _readUint24(listOffset); + listOffset += 3; + + final list = List.filled(length, null); + for (var i = 0; i < length; i++) { + list[i] = _readBoolOrNull(listOffset + i); + } + return list; + } + + @override + List? readByteList(int offset) { + if (offset >= _staticSize) { + return null; + } + + var listOffset = _readUint24(offset); + if (listOffset == 0) { + return null; + } + + final length = _readUint24(listOffset); + listOffset += 3; + + return _buffer.sublist(listOffset, listOffset + length); + } + + @override + List? readIntList(int offset) { + if (offset >= _staticSize) { + return null; + } + + var listOffset = _readUint24(offset); + if (listOffset == 0) { + return null; + } + + final length = _readUint24(listOffset); + listOffset += 3; + + final list = Int32List(length); + for (var i = 0; i < length; i++) { + list[i] = _byteData.getInt32(listOffset + i * 4, Endian.little); + } + return list; + } + + @override + List? readIntOrNullList(int offset) { + if (offset >= _staticSize) { + return null; + } + + var listOffset = _readUint24(offset); + if (listOffset == 0) { + return null; + } + + final length = _readUint24(listOffset); + listOffset += 3; + + final list = List.filled(length, null); + for (var i = 0; i < length; i++) { + list[i] = _readIntOrNull(listOffset + i * 4); + } + return list; + } + + @override + List? readFloatList(int offset) { + if (offset >= _staticSize) { + return null; + } + + var listOffset = _readUint24(offset); + if (listOffset == 0) { + return null; + } + + final length = _readUint24(listOffset); + listOffset += 3; + + final list = Float32List(length); + for (var i = 0; i < length; i++) { + list[i] = _byteData.getFloat32(listOffset + i * 4, Endian.little); + } + return list; + } + + @override + List? readFloatOrNullList(int offset) { + if (offset >= _staticSize) { + return null; + } + + var listOffset = _readUint24(offset); + if (listOffset == 0) { + return null; + } + + final length = _readUint24(listOffset); + listOffset += 3; + + final list = List.filled(length, null); + for (var i = 0; i < length; i++) { + list[i] = _readFloatOrNull(listOffset + i * 4); + } + return list; + } + + @override + List? readLongList(int offset) { + if (offset >= _staticSize) { + return null; + } + + var listOffset = _readUint24(offset); + if (listOffset == 0) { + return null; + } + + final length = _readUint24(listOffset); + listOffset += 3; + + final list = Int64List(length); + for (var i = 0; i < length; i++) { + list[i] = _byteData.getInt64(listOffset + i * 8, Endian.little); + } + return list; + } + + @override + List? readLongOrNullList(int offset) { + if (offset >= _staticSize) { + return null; + } + + var listOffset = _readUint24(offset); + if (listOffset == 0) { + return null; + } + + final length = _readUint24(listOffset); + listOffset += 3; + + final list = List.filled(length, null); + for (var i = 0; i < length; i++) { + list[i] = _readLongOrNull(listOffset + i * 8); + } + return list; + } + + @override + List? readDoubleList(int offset) { + if (offset >= _staticSize) { + return null; + } + + var listOffset = _readUint24(offset); + if (listOffset == 0) { + return null; + } + + final length = _readUint24(listOffset); + listOffset += 3; + + final list = Float64List(length); + for (var i = 0; i < length; i++) { + list[i] = _byteData.getFloat64(listOffset + i * 8, Endian.little); + } + return list; + } + + @override + List? readDoubleOrNullList(int offset) { + if (offset >= _staticSize) { + return null; + } + + var listOffset = _readUint24(offset); + if (listOffset == 0) { + return null; + } + + final length = _readUint24(listOffset); + listOffset += 3; + + final list = List.filled(length, null); + for (var i = 0; i < length; i++) { + list[i] = _readDoubleOrNull(listOffset + i * 8); + } + return list; + } + + @override + List? readDateTimeList(int offset) { + return readLongOrNullList(offset)?.map((e) { + if (e != null) { + return DateTime.fromMicrosecondsSinceEpoch(e, isUtc: true).toLocal(); + } else { + return nullDate; + } + }).toList(); + } + + @override + List? readDateTimeOrNullList(int offset) { + return readLongOrNullList(offset)?.map((e) { + if (e != null) { + return DateTime.fromMicrosecondsSinceEpoch(e, isUtc: true).toLocal(); + } + }).toList(); + } + + List? readDynamicList( + int offset, + T nullValue, + T Function(int startOffset, int endOffset) transform, + ) { + if (offset >= _staticSize) { + return null; + } + + var listOffset = _readUint24(offset); + if (listOffset == 0) { + return null; + } + + final length = _readUint24(listOffset); + listOffset += 3; + + final list = List.filled(length, nullValue); + var contentOffset = listOffset + length * 3; + for (var i = 0; i < length; i++) { + final itemSize = _readUint24(listOffset + i * 3); + + if (itemSize != 0) { + list[i] = transform(contentOffset, contentOffset + itemSize - 1); + contentOffset += itemSize - 1; + } + } + + return list; + } + + @override + List? readStringList(int offset) { + return readDynamicList(offset, '', (startOffset, endOffset) { + return utf8Decoder.convert(_buffer, startOffset, endOffset); + }); + } + + @override + List? readStringOrNullList(int offset) { + return readDynamicList(offset, null, (startOffset, endOffset) { + return utf8Decoder.convert(_buffer, startOffset, endOffset); + }); + } + + @override + List? readObjectList( + int offset, + Deserialize deserialize, + Map> allOffsets, + T defaultValue, + ) { + final offsets = allOffsets[T]!; + return readDynamicList(offset, defaultValue, (startOffset, endOffset) { + final buffer = Uint8List.sublistView(_buffer, startOffset, endOffset); + final reader = IsarReaderImpl(buffer); + return deserialize(0, reader, offsets, allOffsets); + }); + } + + @override + List? readObjectOrNullList( + int offset, + Deserialize deserialize, + Map> allOffsets, + ) { + final offsets = allOffsets[T]!; + return readDynamicList(offset, null, (startOffset, endOffset) { + final buffer = Uint8List.sublistView(_buffer, startOffset, endOffset); + final reader = IsarReaderImpl(buffer); + return deserialize(0, reader, offsets, allOffsets); + }); + } +} diff --git a/packages_external/isar-3.1.0-1/packages/isar/lib/src/native/isar_writer_impl.dart b/packages_external/isar-3.1.0-1/packages/isar/lib/src/native/isar_writer_impl.dart new file mode 100644 index 00000000..7509e67d --- /dev/null +++ b/packages_external/isar-3.1.0-1/packages/isar/lib/src/native/isar_writer_impl.dart @@ -0,0 +1,284 @@ +// ignore_for_file: public_member_api_docs, prefer_asserts_with_message, +// avoid_positional_boolean_parameters + +import 'dart:typed_data'; + +import 'package:isar/isar.dart'; +import 'package:isar/src/native/encode_string.dart'; +import 'package:isar/src/native/isar_core.dart'; +import 'package:meta/meta.dart'; + +/// @nodoc +@protected +class IsarWriterImpl implements IsarWriter { + IsarWriterImpl(Uint8List buffer, int staticSize) + : _dynamicOffset = staticSize, + _buffer = buffer, + _byteData = ByteData.view(buffer.buffer, buffer.offsetInBytes) { + _byteData.setUint16(0, staticSize, Endian.little); + + // Required because we don't want to persist uninitialized memory. + for (var i = 2; i < staticSize; i++) { + _buffer[i] = 0; + } + } + + final Uint8List _buffer; + + final ByteData _byteData; + + int _dynamicOffset; + + int get usedBytes => _dynamicOffset; + + @override + @pragma('vm:prefer-inline') + void writeBool(int offset, bool? value) { + _buffer[offset] = value.byteValue; + } + + @override + @pragma('vm:prefer-inline') + void writeByte(int offset, int value) { + assert(value >= minByte && value <= maxByte); + _buffer[offset] = value; + } + + @override + @pragma('vm:prefer-inline') + void writeInt(int offset, int? value) { + value ??= nullInt; + assert(value >= minInt && value <= maxInt); + _byteData.setInt32(offset, value, Endian.little); + } + + @override + @pragma('vm:prefer-inline') + void writeFloat(int offset, double? value) { + _byteData.setFloat32(offset, value ?? double.nan, Endian.little); + } + + @override + @pragma('vm:prefer-inline') + void writeLong(int offset, int? value) { + _byteData.setInt64(offset, value ?? nullLong, Endian.little); + } + + @override + @pragma('vm:prefer-inline') + void writeDouble(int offset, double? value) { + _byteData.setFloat64(offset, value ?? double.nan, Endian.little); + } + + @override + @pragma('vm:prefer-inline') + void writeDateTime(int offset, DateTime? value) { + writeLong(offset, value?.toUtc().microsecondsSinceEpoch); + } + + @pragma('vm:prefer-inline') + void _writeUint24(int offset, int value) { + _buffer[offset] = value; + _buffer[offset + 1] = value >> 8; + _buffer[offset + 2] = value >> 16; + } + + @override + @pragma('vm:prefer-inline') + void writeString(int offset, String? value) { + if (value != null) { + final byteCount = encodeString(value, _buffer, _dynamicOffset + 3); + _writeUint24(offset, _dynamicOffset); + _writeUint24(_dynamicOffset, byteCount); + _dynamicOffset += byteCount + 3; + } else { + _writeUint24(offset, 0); + } + } + + @override + @pragma('vm:prefer-inline') + void writeObject( + int offset, + Map> allOffsets, + Serialize serialize, + T? value, + ) { + if (value != null) { + final buffer = Uint8List.sublistView(_buffer, _dynamicOffset + 3); + final offsets = allOffsets[T]!; + final binaryWriter = IsarWriterImpl(buffer, offsets.last); + serialize(value, binaryWriter, offsets, allOffsets); + final byteCount = binaryWriter.usedBytes; + _writeUint24(offset, _dynamicOffset); + _writeUint24(_dynamicOffset, byteCount); + _dynamicOffset += byteCount + 3; + } else { + _writeUint24(offset, 0); + } + } + + @pragma('vm:prefer-inline') + void _writeListOffset(int offset, int? length) { + if (length == null) { + _writeUint24(offset, 0); + } else { + _writeUint24(offset, _dynamicOffset); + _writeUint24(_dynamicOffset, length); + _dynamicOffset += 3; + } + } + + @override + @pragma('vm:prefer-inline') + void writeByteList(int offset, List? values) { + _writeListOffset(offset, values?.length); + + if (values != null) { + for (var i = 0; i < values.length; i++) { + _buffer[_dynamicOffset++] = values[i]; + } + } + } + + @override + void writeBoolList(int offset, List? values) { + _writeListOffset(offset, values?.length); + + if (values != null) { + for (var i = 0; i < values.length; i++) { + _buffer[_dynamicOffset++] = values[i].byteValue; + } + } + } + + @override + void writeIntList(int offset, List? values) { + _writeListOffset(offset, values?.length); + + if (values != null) { + for (var value in values) { + value ??= nullInt; + assert(value >= minInt && value <= maxInt); + _byteData.setUint32(_dynamicOffset, value, Endian.little); + _dynamicOffset += 4; + } + } + } + + @override + void writeFloatList(int offset, List? values) { + _writeListOffset(offset, values?.length); + + if (values != null) { + for (var i = 0; i < values.length; i++) { + _byteData.setFloat32( + _dynamicOffset, + values[i] ?? nullFloat, + Endian.little, + ); + _dynamicOffset += 4; + } + } + } + + @override + void writeLongList(int offset, List? values) { + _writeListOffset(offset, values?.length); + + if (values != null) { + for (var i = 0; i < values.length; i++) { + _byteData.setInt64( + _dynamicOffset, + values[i] ?? nullLong, + Endian.little, + ); + _dynamicOffset += 8; + } + } + } + + @override + void writeDoubleList(int offset, List? values) { + _writeListOffset(offset, values?.length); + + if (values != null) { + for (var i = 0; i < values.length; i++) { + _byteData.setFloat64( + _dynamicOffset, + values[i] ?? nullDouble, + Endian.little, + ); + _dynamicOffset += 8; + } + } + } + + @override + void writeDateTimeList(int offset, List? values) { + final longList = values?.map((e) => e.longValue).toList(); + writeLongList(offset, longList); + } + + @override + void writeStringList(int offset, List? values) { + _writeListOffset(offset, values?.length); + + if (values != null) { + final offsetListOffset = _dynamicOffset; + _dynamicOffset += values.length * 3; + for (var i = 0; i < values.length; i++) { + final value = values[i]; + if (value != null) { + final byteCount = encodeString(value, _buffer, _dynamicOffset); + _writeUint24(offsetListOffset + i * 3, byteCount + 1); + _dynamicOffset += byteCount; + } else { + _writeUint24(offsetListOffset + i * 3, 0); + } + } + } + } + + @override + void writeObjectList( + int offset, + Map> allOffsets, + Serialize serialize, + List? values, + ) { + _writeListOffset(offset, values?.length); + + if (values != null) { + final offsetListOffset = _dynamicOffset; + _dynamicOffset += values.length * 3; + + final offsets = allOffsets[T]!; + final staticSize = offsets.last; + for (var i = 0; i < values.length; i++) { + final value = values[i]; + if (value != null) { + final buffer = Uint8List.sublistView(_buffer, _dynamicOffset); + final binaryWriter = IsarWriterImpl(buffer, staticSize); + serialize(value, binaryWriter, offsets, allOffsets); + final byteCount = binaryWriter.usedBytes; + _writeUint24(offsetListOffset + i * 3, byteCount + 1); + _dynamicOffset += byteCount; + } else { + _writeUint24(offsetListOffset + i * 3, 0); + } + } + } + } +} + +extension IsarBoolValue on bool? { + @pragma('vm:prefer-inline') + int get byteValue => + this == null ? nullBool : (this == true ? trueBool : falseBool); +} + +extension IsarDateTimeValue on DateTime? { + @pragma('vm:prefer-inline') + int get longValue => this?.toUtc().microsecondsSinceEpoch ?? nullLong; +} diff --git a/packages_external/isar-3.1.0-1/packages/isar/lib/src/native/open.dart b/packages_external/isar-3.1.0-1/packages/isar/lib/src/native/open.dart new file mode 100644 index 00000000..1b169e0c --- /dev/null +++ b/packages_external/isar-3.1.0-1/packages/isar/lib/src/native/open.dart @@ -0,0 +1,159 @@ +// ignore_for_file: public_member_api_docs, invalid_use_of_protected_member + +import 'dart:convert'; +import 'dart:ffi'; +import 'dart:isolate'; + +import 'package:ffi/ffi.dart'; +import 'package:isar/isar.dart'; +import 'package:isar/src/common/schemas.dart'; +import 'package:isar/src/native/bindings.dart'; +import 'package:isar/src/native/encode_string.dart'; +import 'package:isar/src/native/isar_collection_impl.dart'; +import 'package:isar/src/native/isar_core.dart'; +import 'package:isar/src/native/isar_impl.dart'; + +final Pointer> _isarPtrPtr = + malloc>(); + +List _getOffsets( + Pointer colPtr, + int propertiesCount, + int embeddedColId, +) { + final offsetsPtr = malloc(propertiesCount); + final staticSize = IC.isar_get_offsets(colPtr, embeddedColId, offsetsPtr); + final offsets = offsetsPtr.asTypedList(propertiesCount).toList(); + offsets.add(staticSize); + malloc.free(offsetsPtr); + return offsets; +} + +void _initializeInstance( + IsarImpl isar, + List> schemas, +) { + final colPtrPtr = malloc>(); + + final cols = >{}; + for (final schema in schemas) { + nCall(IC.isar_instance_get_collection(isar.ptr, colPtrPtr, schema.id)); + + final offsets = _getOffsets(colPtrPtr.value, schema.properties.length, 0); + + for (final embeddedSchema in schema.embeddedSchemas.values) { + final embeddedType = embeddedSchema.type; + if (!isar.offsets.containsKey(embeddedType)) { + final offsets = _getOffsets( + colPtrPtr.value, + embeddedSchema.properties.length, + embeddedSchema.id, + ); + isar.offsets[embeddedType] = offsets; + } + } + + schema.toCollection(() { + isar.offsets[OBJ] = offsets; + + schema as CollectionSchema; + cols[OBJ] = IsarCollectionImpl( + isar: isar, + ptr: colPtrPtr.value, + schema: schema, + ); + }); + } + + malloc.free(colPtrPtr); + + isar.attachCollections(cols); +} + +Future openIsar({ + required List> schemas, + required String directory, + required String name, + required int maxSizeMiB, + required bool relaxedDurability, + CompactCondition? compactOnLaunch, +}) async { + initializeCoreBinary(); + IC.isar_connect_dart_api(NativeApi.postCObject.cast()); + + return using((Arena alloc) async { + final namePtr = name.toCString(alloc); + final dirPtr = directory.toCString(alloc); + + final schemasJson = getSchemas(schemas).map((e) => e.toJson()); + final schemaStrPtr = jsonEncode(schemasJson.toList()).toCString(alloc); + + final compactMinFileSize = compactOnLaunch?.minFileSize; + final compactMinBytes = compactOnLaunch?.minBytes; + final compactMinRatio = + compactOnLaunch == null ? double.nan : compactOnLaunch.minRatio; + + final receivePort = ReceivePort(); + final nativePort = receivePort.sendPort.nativePort; + final stream = wrapIsarPort(receivePort); + IC.isar_instance_create_async( + _isarPtrPtr, + namePtr, + dirPtr, + schemaStrPtr, + maxSizeMiB, + relaxedDurability, + compactMinFileSize ?? 0, + compactMinBytes ?? 0, + compactMinRatio ?? 0, + nativePort, + ); + await stream.first; + + final isar = IsarImpl(name, _isarPtrPtr.value); + _initializeInstance(isar, schemas); + return isar; + }); +} + +Isar openIsarSync({ + required List> schemas, + required String directory, + required String name, + required int maxSizeMiB, + required bool relaxedDurability, + CompactCondition? compactOnLaunch, +}) { + initializeCoreBinary(); + IC.isar_connect_dart_api(NativeApi.postCObject.cast()); + return using((Arena alloc) { + final namePtr = name.toCString(alloc); + final dirPtr = directory.toCString(alloc); + + final schemasJson = getSchemas(schemas).map((e) => e.toJson()); + final schemaStrPtr = jsonEncode(schemasJson.toList()).toCString(alloc); + + final compactMinFileSize = compactOnLaunch?.minFileSize; + final compactMinBytes = compactOnLaunch?.minBytes; + final compactMinRatio = + compactOnLaunch == null ? double.nan : compactOnLaunch.minRatio; + + nCall( + IC.isar_instance_create( + _isarPtrPtr, + namePtr, + dirPtr, + schemaStrPtr, + maxSizeMiB, + relaxedDurability, + compactMinFileSize ?? 0, + compactMinBytes ?? 0, + compactMinRatio ?? 0, + ), + ); + + final isar = IsarImpl(name, _isarPtrPtr.value); + _initializeInstance(isar, schemas); + return isar; + }); +} diff --git a/packages_external/isar-3.1.0-1/packages/isar/lib/src/native/query_build.dart b/packages_external/isar-3.1.0-1/packages/isar/lib/src/native/query_build.dart new file mode 100644 index 00000000..1e787174 --- /dev/null +++ b/packages_external/isar-3.1.0-1/packages/isar/lib/src/native/query_build.dart @@ -0,0 +1,1040 @@ +// ignore_for_file: invalid_use_of_protected_member, public_member_api_docs + +import 'dart:ffi'; + +import 'package:ffi/ffi.dart'; +import 'package:isar/isar.dart'; +import 'package:isar/src/native/bindings.dart'; +import 'package:isar/src/native/encode_string.dart'; +import 'package:isar/src/native/index_key.dart'; +import 'package:isar/src/native/isar_collection_impl.dart'; +import 'package:isar/src/native/isar_core.dart'; +import 'package:isar/src/native/isar_writer_impl.dart'; +import 'package:isar/src/native/query_impl.dart'; + +final Pointer maxStr = '\u{FFFFF}'.toNativeUtf8().cast(); + +Query buildNativeQuery( + IsarCollectionImpl col, + List whereClauses, + bool whereDistinct, + Sort whereSort, + FilterOperation? filter, + List sortBy, + List distinctBy, + int? offset, + int? limit, + String? property, +) { + final qbPtr = IC.isar_qb_create(col.ptr); + + for (final wc in whereClauses) { + if (wc is IdWhereClause) { + _addIdWhereClause(qbPtr, wc, whereSort); + } else if (wc is IndexWhereClause) { + _addIndexWhereClause( + col.schema, + qbPtr, + wc, + whereDistinct, + whereSort, + ); + } else { + _addLinkWhereClause(col.isar, qbPtr, wc as LinkWhereClause); + } + } + + if (filter != null) { + final alloc = Arena(malloc); + try { + final filterPtr = _buildFilter(col, null, filter, alloc); + if (filterPtr != null) { + IC.isar_qb_set_filter(qbPtr, filterPtr); + } + } finally { + alloc.releaseAll(); + } + } + + for (final sortProperty in sortBy) { + final property = col.schema.property(sortProperty.property); + nCall( + IC.isar_qb_add_sort_by( + qbPtr, + property.id, + sortProperty.sort == Sort.asc, + ), + ); + } + + if (offset != null || limit != null) { + IC.isar_qb_set_offset_limit(qbPtr, offset ?? -1, limit ?? -1); + } + + for (final distinctByProperty in distinctBy) { + final property = col.schema.property(distinctByProperty.property); + nCall( + IC.isar_qb_add_distinct_by( + qbPtr, + property.id, + distinctByProperty.caseSensitive ?? true, + ), + ); + } + + QueryDeserialize deserialize; + int? propertyId; + if (property == null) { + deserialize = (col as IsarCollectionImpl).deserializeObjects; + } else { + propertyId = + property != col.schema.idName ? col.schema.property(property).id : null; + deserialize = + (CObjectSet cObjSet) => col.deserializeProperty(cObjSet, propertyId); + } + + final queryPtr = IC.isar_qb_build(qbPtr); + return QueryImpl(col, queryPtr, deserialize, propertyId); +} + +void _addIdWhereClause( + Pointer qbPtr, + IdWhereClause wc, + Sort sort, +) { + final lower = (wc.lower ?? minLong) + (wc.includeLower ? 0 : 1); + final upper = (wc.upper ?? maxLong) - (wc.includeUpper ? 0 : 1); + nCall( + IC.isar_qb_add_id_where_clause( + qbPtr, + sort == Sort.asc ? lower : upper, + sort == Sort.asc ? upper : lower, + ), + ); +} + +Pointer? _buildLowerIndexBound( + CollectionSchema schema, + IndexSchema index, + IndexWhereClause wc, +) { + if (wc.lower == null) { + return buildLowerUnboundedIndexKey(); + } + + final firstVal = wc.lower!.length == 1 ? wc.lower!.first : null; + if (firstVal is double) { + final adjusted = adjustFloatBound( + value: firstVal, + lowerBound: true, + include: wc.includeLower, + epsilon: wc.epsilon, + ); + if (adjusted == null) { + return null; + } + + return buildIndexKey(schema, index, [adjusted]); + } else { + final lowerPtr = buildIndexKey(schema, index, wc.lower!); + + if (!wc.includeLower) { + if (!IC.isar_key_increase(lowerPtr)) { + return null; + } + } + + return lowerPtr; + } +} + +Pointer? _buildUpperIndexBound( + CollectionSchema schema, + IndexSchema index, + IndexWhereClause wc, +) { + if (wc.upper == null) { + return buildUpperUnboundedIndexKey(); + } + + final firstVal = wc.upper!.length == 1 ? wc.upper!.first : null; + if (firstVal is double) { + final adjusted = adjustFloatBound( + value: firstVal, + lowerBound: false, + include: wc.includeUpper, + epsilon: wc.epsilon, + ); + if (adjusted == null) { + return null; + } else { + return buildIndexKey(schema, index, [adjusted]); + } + } else { + final upperPtr = buildIndexKey(schema, index, wc.upper!); + + if (!wc.includeUpper) { + if (!IC.isar_key_decrease(upperPtr)) { + return null; + } + } + + // Also include composite indexes for upper keys + if (index.properties.length > wc.upper!.length) { + IC.isar_key_add_long(upperPtr, maxLong); + } + + return upperPtr; + } +} + +void _addIndexWhereClause( + CollectionSchema schema, + Pointer qbPtr, + IndexWhereClause wc, + bool distinct, + Sort sort, +) { + final index = schema.index(wc.indexName); + final lowerPtr = _buildLowerIndexBound(schema, index, wc); + final upperPtr = _buildUpperIndexBound(schema, index, wc); + + if (lowerPtr != null && upperPtr != null) { + nCall( + IC.isar_qb_add_index_where_clause( + qbPtr, + schema.index(wc.indexName).id, + lowerPtr, + upperPtr, + sort == Sort.asc, + distinct, + ), + ); + } else { + // this where clause does not match any objects + nCall( + IC.isar_qb_add_id_where_clause( + qbPtr, + Isar.autoIncrement, + Isar.autoIncrement, + ), + ); + } +} + +void _addLinkWhereClause( + Isar isar, + Pointer qbPtr, + LinkWhereClause wc, +) { + final linkCol = isar.getCollectionByNameInternal(wc.linkCollection)!; + linkCol as IsarCollectionImpl; + + final linkId = linkCol.schema.link(wc.linkName).id; + nCall(IC.isar_qb_add_link_where_clause(qbPtr, linkCol.ptr, linkId, wc.id)); +} + +Pointer? _buildFilter( + IsarCollectionImpl col, + Schema? embeddedCol, + FilterOperation filter, + Allocator alloc, +) { + if (filter is FilterGroup) { + return _buildFilterGroup(col, embeddedCol, filter, alloc); + } else if (filter is LinkFilter) { + return _buildLink(col, filter, alloc); + } else if (filter is ObjectFilter) { + return _buildObject(col, embeddedCol, filter, alloc); + } else if (filter is FilterCondition) { + return _buildCondition(col, embeddedCol, filter, alloc); + } else { + return null; + } +} + +Pointer? _buildFilterGroup( + IsarCollectionImpl col, + Schema? embeddedCol, + FilterGroup group, + Allocator alloc, +) { + final builtConditions = group.filters + .map((FilterOperation op) => _buildFilter(col, embeddedCol, op, alloc)) + .where((Pointer? it) => it != null) + .toList(); + + if (builtConditions.isEmpty) { + return null; + } + + final filterPtrPtr = alloc>(); + if (group.type == FilterGroupType.not) { + IC.isar_filter_not( + filterPtrPtr, + builtConditions.first!, + ); + } else if (builtConditions.length == 1) { + return builtConditions[0]; + } else { + final conditionsPtrPtr = alloc>(builtConditions.length); + for (var i = 0; i < builtConditions.length; i++) { + conditionsPtrPtr[i] = builtConditions[i]!; + } + IC.isar_filter_and_or_xor( + filterPtrPtr, + group.type == FilterGroupType.and, + group.type == FilterGroupType.xor, + conditionsPtrPtr, + builtConditions.length, + ); + } + + return filterPtrPtr.value; +} + +Pointer? _buildLink( + IsarCollectionImpl col, + LinkFilter link, + Allocator alloc, +) { + final linkSchema = col.schema.link(link.linkName); + final linkTargetCol = + col.isar.getCollectionByNameInternal(linkSchema.target)!; + final linkId = col.schema.link(link.linkName).id; + + final filterPtrPtr = alloc>(); + + if (link.filter != null) { + final condition = _buildFilter( + linkTargetCol as IsarCollectionImpl, + null, + link.filter!, + alloc, + ); + if (condition == null) { + return null; + } + + nCall( + IC.isar_filter_link( + col.ptr, + filterPtrPtr, + condition, + linkId, + ), + ); + } else { + nCall( + IC.isar_filter_link_length( + col.ptr, + filterPtrPtr, + link.lower!, + link.upper!, + linkId, + ), + ); + } + + return filterPtrPtr.value; +} + +Pointer? _buildObject( + IsarCollectionImpl col, + Schema? embeddedCol, + ObjectFilter objectFilter, + Allocator alloc, +) { + final property = (embeddedCol ?? col.schema).property(objectFilter.property); + + final condition = _buildFilter( + col, + col.schema.embeddedSchemas[property.target], + objectFilter.filter, + alloc, + ); + if (condition == null) { + return null; + } + + final filterPtrPtr = alloc>(); + nCall( + IC.isar_filter_object( + col.ptr, + filterPtrPtr, + condition, + embeddedCol?.id ?? 0, + property.id, + ), + ); + + return filterPtrPtr.value; +} + +Object _prepareValue( + Object? value, + Allocator alloc, + IsarType type, + Map? enumMap, +) { + if (value is bool) { + return value.byteValue; + } else if (value is DateTime) { + return value.longValue; + } else if (value is Enum) { + return _prepareValue(enumMap![value.name], alloc, type, null); + } else if (value is String) { + return value.toCString(alloc); + } else if (value == null) { + switch (type) { + case IsarType.bool: + case IsarType.byte: + case IsarType.boolList: + case IsarType.byteList: + return minByte; + case IsarType.int: + case IsarType.intList: + return minInt; + case IsarType.long: + case IsarType.longList: + case IsarType.dateTime: + case IsarType.dateTimeList: + return minLong; + case IsarType.float: + case IsarType.double: + case IsarType.floatList: + case IsarType.doubleList: + return minDouble; + case IsarType.string: + case IsarType.stringList: + case IsarType.object: + case IsarType.objectList: + return nullptr; + } + } else { + return value; + } +} + +Pointer _buildCondition( + IsarCollectionImpl col, + Schema? embeddedCol, + FilterCondition condition, + Allocator alloc, +) { + final property = condition.property != col.schema.idName + ? (embeddedCol ?? col.schema).property(condition.property) + : null; + + final value1 = _prepareValue( + condition.value1, + alloc, + property?.type ?? IsarType.long, + property?.enumMap, + ); + final value2 = _prepareValue( + condition.value2, + alloc, + property?.type ?? IsarType.long, + property?.enumMap, + ); + final filterPtr = alloc>(); + + switch (condition.type) { + case FilterConditionType.equalTo: + _buildConditionEqual( + colPtr: col.ptr, + filterPtr: filterPtr, + embeddedColId: embeddedCol?.id, + propertyId: property?.id, + val: value1, + caseSensitive: condition.caseSensitive, + epsilon: condition.epsilon, + ); + break; + case FilterConditionType.between: + _buildConditionBetween( + colPtr: col.ptr, + filterPtr: filterPtr, + embeddedColId: embeddedCol?.id, + propertyId: property?.id, + lower: value1, + includeLower: condition.include1, + upper: value2, + includeUpper: condition.include2, + caseSensitive: condition.caseSensitive, + epsilon: condition.epsilon, + ); + break; + case FilterConditionType.lessThan: + _buildConditionLessThan( + colPtr: col.ptr, + filterPtr: filterPtr, + embeddedColId: embeddedCol?.id, + propertyId: property?.id, + val: value1, + include: condition.include1, + caseSensitive: condition.caseSensitive, + epsilon: condition.epsilon, + ); + break; + case FilterConditionType.greaterThan: + _buildConditionGreaterThan( + colPtr: col.ptr, + filterPtr: filterPtr, + embeddedColId: embeddedCol?.id, + propertyId: property?.id, + val: value1, + include: condition.include1, + caseSensitive: condition.caseSensitive, + epsilon: condition.epsilon, + ); + break; + case FilterConditionType.startsWith: + case FilterConditionType.endsWith: + case FilterConditionType.contains: + case FilterConditionType.matches: + _buildConditionStringOp( + colPtr: col.ptr, + filterPtr: filterPtr, + conditionType: condition.type, + embeddedColId: embeddedCol?.id, + propertyId: property?.id, + val: value1, + include: condition.include1, + caseSensitive: condition.caseSensitive, + ); + break; + case FilterConditionType.isNull: + _buildConditionIsNull( + colPtr: col.ptr, + filterPtr: filterPtr, + embeddedColId: embeddedCol?.id, + propertyId: property?.id, + ); + break; + case FilterConditionType.isNotNull: + _buildConditionIsNotNull( + colPtr: col.ptr, + filterPtr: filterPtr, + embeddedColId: embeddedCol?.id, + propertyId: property?.id, + alloc: alloc, + ); + break; + case FilterConditionType.elementIsNull: + _buildConditionElementIsNull( + colPtr: col.ptr, + filterPtr: filterPtr, + embeddedColId: embeddedCol?.id, + propertyId: property?.id, + isObjectList: property?.type == IsarType.objectList, + nullValue: value1, + ); + break; + case FilterConditionType.elementIsNotNull: + _buildConditionElementIsNotNull( + colPtr: col.ptr, + filterPtr: filterPtr, + embeddedColId: embeddedCol?.id, + propertyId: property?.id, + isObjectList: property?.type == IsarType.objectList, + nullValue: value1, + alloc: alloc, + ); + break; + case FilterConditionType.listLength: + _buildListLength( + colPtr: col.ptr, + filterPtr: filterPtr, + embeddedColId: embeddedCol?.id, + propertyId: property?.id, + lower: value1, + upper: value2, + ); + break; + } + + return filterPtr.value; +} + +void _buildConditionIsNull({ + required Pointer colPtr, + required Pointer> filterPtr, + required int? embeddedColId, + required int? propertyId, +}) { + if (propertyId != null) { + nCall( + IC.isar_filter_null( + colPtr, + filterPtr, + embeddedColId ?? 0, + propertyId, + ), + ); + } else { + IC.isar_filter_static(filterPtr, false); + } +} + +void _buildConditionIsNotNull({ + required Pointer colPtr, + required Pointer> filterPtr, + required int? embeddedColId, + required int? propertyId, + required Allocator alloc, +}) { + if (propertyId != null) { + final conditionPtr = alloc>(); + nCall( + IC.isar_filter_null( + colPtr, + conditionPtr, + embeddedColId ?? 0, + propertyId, + ), + ); + IC.isar_filter_not(filterPtr, conditionPtr.value); + } else { + IC.isar_filter_static(filterPtr, true); + } +} + +void _buildConditionElementIsNull({ + required Pointer colPtr, + required Pointer> filterPtr, + required int? embeddedColId, + required int? propertyId, + required bool isObjectList, + required Object nullValue, +}) { + if (isObjectList) { + IC.isar_filter_object( + colPtr, + filterPtr, + nullptr, + embeddedColId ?? 0, + propertyId ?? 0, + ); + } else { + _buildConditionEqual( + colPtr: colPtr, + filterPtr: filterPtr, + embeddedColId: embeddedColId, + propertyId: propertyId, + val: nullValue, + epsilon: 0, + caseSensitive: true, + ); + } +} + +void _buildConditionElementIsNotNull({ + required Pointer colPtr, + required Pointer> filterPtr, + required int? embeddedColId, + required int? propertyId, + required bool isObjectList, + required Object nullValue, + required Allocator alloc, +}) { + if (isObjectList) { + final objFilterPtrPtr = alloc>(); + IC.isar_filter_static(objFilterPtrPtr, true); + IC.isar_filter_object( + colPtr, + filterPtr, + objFilterPtrPtr.value, + embeddedColId ?? 0, + propertyId ?? 0, + ); + } else { + _buildConditionGreaterThan( + colPtr: colPtr, + filterPtr: filterPtr, + embeddedColId: embeddedColId, + propertyId: propertyId, + val: nullValue, + include: false, + epsilon: 0, + caseSensitive: true, + ); + } +} + +void _buildConditionEqual({ + required Pointer colPtr, + required Pointer> filterPtr, + required int? embeddedColId, + required int? propertyId, + required Object val, + required bool caseSensitive, + required double epsilon, +}) { + if (val is int) { + if (propertyId == null) { + IC.isar_filter_id(filterPtr, val, true, val, true); + } else { + nCall( + IC.isar_filter_long( + colPtr, + filterPtr, + val, + true, + val, + true, + embeddedColId ?? 0, + propertyId, + ), + ); + } + } else if (val is double) { + final lower = adjustFloatBound( + value: val, + lowerBound: true, + include: true, + epsilon: epsilon, + ); + final upper = adjustFloatBound( + value: val, + lowerBound: false, + include: true, + epsilon: epsilon, + ); + if (lower == null || upper == null) { + IC.isar_filter_static(filterPtr, false); + } else { + nCall( + IC.isar_filter_double( + colPtr, + filterPtr, + lower, + upper, + embeddedColId ?? 0, + propertyId!, + ), + ); + } + } else if (val is Pointer) { + nCall( + IC.isar_filter_string( + colPtr, + filterPtr, + val, + true, + val, + true, + caseSensitive, + embeddedColId ?? 0, + propertyId!, + ), + ); + } else { + throw IsarError('Unsupported type for condition'); + } +} + +void _buildConditionBetween({ + required Pointer colPtr, + required Pointer> filterPtr, + required int? embeddedColId, + required int? propertyId, + required Object lower, + required bool includeLower, + required Object upper, + required bool includeUpper, + required bool caseSensitive, + required double epsilon, +}) { + if (lower is int && upper is int) { + if (propertyId == null) { + IC.isar_filter_id(filterPtr, lower, includeLower, upper, includeUpper); + } else { + nCall( + IC.isar_filter_long( + colPtr, + filterPtr, + lower, + includeLower, + upper, + includeUpper, + embeddedColId ?? 0, + propertyId, + ), + ); + } + } else if (lower is double && upper is double) { + final adjustedLower = adjustFloatBound( + value: lower, + lowerBound: true, + include: includeLower, + epsilon: epsilon, + ); + final adjustedUpper = adjustFloatBound( + value: upper, + lowerBound: false, + include: includeUpper, + epsilon: epsilon, + ); + if (adjustedLower == null || adjustedUpper == null) { + IC.isar_filter_static(filterPtr, false); + } else { + nCall( + IC.isar_filter_double( + colPtr, + filterPtr, + adjustedLower, + adjustedUpper, + embeddedColId ?? 0, + propertyId!, + ), + ); + } + } else if (lower is Pointer && upper is Pointer) { + nCall( + IC.isar_filter_string( + colPtr, + filterPtr, + lower, + includeLower, + upper, + includeUpper, + caseSensitive, + embeddedColId ?? 0, + propertyId!, + ), + ); + } else { + throw IsarError('Unsupported type for condition'); + } +} + +void _buildConditionLessThan({ + required Pointer colPtr, + required Pointer> filterPtr, + required int? embeddedColId, + required int? propertyId, + required Object val, + required bool include, + required bool caseSensitive, + required double epsilon, +}) { + if (val is int) { + if (propertyId == null) { + IC.isar_filter_id(filterPtr, minLong, true, val, include); + } else { + nCall( + IC.isar_filter_long( + colPtr, + filterPtr, + minLong, + true, + val, + include, + embeddedColId ?? 0, + propertyId, + ), + ); + } + } else if (val is double) { + final upper = adjustFloatBound( + value: val, + lowerBound: false, + include: include, + epsilon: epsilon, + ); + if (upper == null) { + IC.isar_filter_static(filterPtr, false); + } else { + nCall( + IC.isar_filter_double( + colPtr, + filterPtr, + minDouble, + upper, + embeddedColId ?? 0, + propertyId!, + ), + ); + } + } else if (val is Pointer) { + nCall( + IC.isar_filter_string( + colPtr, + filterPtr, + nullptr, + true, + val, + include, + caseSensitive, + embeddedColId ?? 0, + propertyId!, + ), + ); + } else { + throw IsarError('Unsupported type for condition'); + } +} + +void _buildConditionGreaterThan({ + required Pointer colPtr, + required Pointer> filterPtr, + required int? embeddedColId, + required int? propertyId, + required Object val, + required bool include, + required bool caseSensitive, + required double epsilon, +}) { + if (val is int) { + if (propertyId == null) { + IC.isar_filter_id(filterPtr, val, include, maxLong, true); + } else { + nCall( + IC.isar_filter_long( + colPtr, + filterPtr, + val, + include, + maxLong, + true, + embeddedColId ?? 0, + propertyId, + ), + ); + } + } else if (val is double) { + final lower = adjustFloatBound( + value: val, + lowerBound: true, + include: include, + epsilon: epsilon, + ); + if (lower == null) { + IC.isar_filter_static(filterPtr, false); + } else { + nCall( + IC.isar_filter_double( + colPtr, + filterPtr, + lower, + maxDouble, + embeddedColId ?? 0, + propertyId!, + ), + ); + } + } else if (val is Pointer) { + nCall( + IC.isar_filter_string( + colPtr, + filterPtr, + val, + include, + maxStr, + true, + caseSensitive, + embeddedColId ?? 0, + propertyId!, + ), + ); + } else { + throw IsarError('Unsupported type for condition'); + } +} + +void _buildConditionStringOp({ + required Pointer colPtr, + required Pointer> filterPtr, + required FilterConditionType conditionType, + required int? embeddedColId, + required int? propertyId, + required Object val, + required bool include, + required bool caseSensitive, +}) { + if (val is Pointer) { + if (val.isNull) { + throw IsarError('String operation value must not be null'); + } + + // ignore: missing_enum_constant_in_switch + switch (conditionType) { + case FilterConditionType.startsWith: + nCall( + IC.isar_filter_string_starts_with( + colPtr, + filterPtr, + val, + caseSensitive, + embeddedColId ?? 0, + propertyId!, + ), + ); + break; + case FilterConditionType.endsWith: + nCall( + IC.isar_filter_string_ends_with( + colPtr, + filterPtr, + val, + caseSensitive, + embeddedColId ?? 0, + propertyId!, + ), + ); + break; + case FilterConditionType.contains: + nCall( + IC.isar_filter_string_contains( + colPtr, + filterPtr, + val, + caseSensitive, + embeddedColId ?? 0, + propertyId!, + ), + ); + break; + case FilterConditionType.matches: + nCall( + IC.isar_filter_string_matches( + colPtr, + filterPtr, + val, + caseSensitive, + embeddedColId ?? 0, + propertyId!, + ), + ); + break; + } + } else { + throw IsarError('Unsupported type for condition'); + } +} + +void _buildListLength({ + required Pointer colPtr, + required Pointer> filterPtr, + required int? embeddedColId, + required int? propertyId, + required Object? lower, + required Object? upper, +}) { + if (lower is int && upper is int) { + nCall( + IC.isar_filter_list_length( + colPtr, + filterPtr, + lower, + upper, + embeddedColId ?? 0, + propertyId!, + ), + ); + } else { + throw IsarError('Unsupported type for condition'); + } +} diff --git a/packages_external/isar-3.1.0-1/packages/isar/lib/src/native/query_impl.dart b/packages_external/isar-3.1.0-1/packages/isar/lib/src/native/query_impl.dart new file mode 100644 index 00000000..a5d2452f --- /dev/null +++ b/packages_external/isar-3.1.0-1/packages/isar/lib/src/native/query_impl.dart @@ -0,0 +1,261 @@ +// ignore_for_file: public_member_api_docs + +import 'dart:async'; +import 'dart:ffi'; +import 'dart:isolate'; +import 'dart:typed_data'; + +import 'package:isar/isar.dart'; +import 'package:isar/src/native/bindings.dart'; +import 'package:isar/src/native/encode_string.dart'; +import 'package:isar/src/native/isar_collection_impl.dart'; +import 'package:isar/src/native/isar_core.dart'; +import 'package:isar/src/native/txn.dart'; + +typedef QueryDeserialize = List Function(CObjectSet); + +class QueryImpl extends Query implements Finalizable { + QueryImpl(this.col, this.queryPtr, this.deserialize, this.propertyId) { + NativeFinalizer(isarQueryFree).attach(this, queryPtr.cast()); + } + static const int maxLimit = 4294967295; + + final IsarCollectionImpl col; + final Pointer queryPtr; + final QueryDeserialize deserialize; + final int? propertyId; + + @override + Isar get isar => col.isar; + + @override + Future findFirst() { + return findInternal(maxLimit).then((List result) { + if (result.isNotEmpty) { + return result[0]; + } else { + return null; + } + }); + } + + @override + Future> findAll() => findInternal(maxLimit); + + Future> findInternal(int limit) { + return col.isar.getTxn(false, (Txn txn) async { + final resultsPtr = txn.alloc(); + try { + IC.isar_q_find(queryPtr, txn.ptr, resultsPtr, limit); + await txn.wait(); + return deserialize(resultsPtr.ref).cast(); + } finally { + IC.isar_free_c_object_set(resultsPtr); + } + }); + } + + @override + T? findFirstSync() { + final results = findSyncInternal(1); + if (results.isNotEmpty) { + return results[0]; + } else { + return null; + } + } + + @override + List findAllSync() => findSyncInternal(maxLimit); + + List findSyncInternal(int limit) { + return col.isar.getTxnSync(false, (Txn txn) { + final resultsPtr = txn.getCObjectsSet(); + try { + nCall(IC.isar_q_find(queryPtr, txn.ptr, resultsPtr, limit)); + return deserialize(resultsPtr.ref).cast(); + } finally { + IC.isar_free_c_object_set(resultsPtr); + } + }); + } + + @override + Future deleteFirst() => + deleteInternal(1).then((int count) => count == 1); + + @override + Future deleteAll() => deleteInternal(maxLimit); + + Future deleteInternal(int limit) { + return col.isar.getTxn(false, (Txn txn) async { + final countPtr = txn.alloc(); + IC.isar_q_delete(queryPtr, col.ptr, txn.ptr, limit, countPtr); + await txn.wait(); + return countPtr.value; + }); + } + + @override + bool deleteFirstSync() => deleteSyncInternal(1) == 1; + + @override + int deleteAllSync() => deleteSyncInternal(maxLimit); + + int deleteSyncInternal(int limit) { + return col.isar.getTxnSync(false, (Txn txn) { + final countPtr = txn.alloc(); + nCall(IC.isar_q_delete(queryPtr, col.ptr, txn.ptr, limit, countPtr)); + return countPtr.value; + }); + } + + @override + Stream> watch({bool fireImmediately = false}) { + return watchLazy(fireImmediately: fireImmediately) + .asyncMap((event) => findAll()); + } + + @override + Stream watchLazy({bool fireImmediately = false}) { + final port = ReceivePort(); + final handle = IC.isar_watch_query( + col.isar.ptr, + col.ptr, + queryPtr, + port.sendPort.nativePort, + ); + + final controller = StreamController( + onCancel: () { + IC.isar_stop_watching(handle); + port.close(); + }, + ); + + if (fireImmediately) { + controller.add(null); + } + + controller.addStream(port); + return controller.stream; + } + + @override + Future exportJsonRaw(R Function(Uint8List) callback) { + return col.isar.getTxn(false, (Txn txn) async { + final bytesPtrPtr = txn.alloc>(); + final lengthPtr = txn.alloc(); + final idNamePtr = col.schema.idName.toCString(txn.alloc); + + nCall( + IC.isar_q_export_json( + queryPtr, + col.ptr, + txn.ptr, + idNamePtr, + bytesPtrPtr, + lengthPtr, + ), + ); + + try { + await txn.wait(); + final bytes = bytesPtrPtr.value.asTypedList(lengthPtr.value); + return callback(bytes); + } finally { + IC.isar_free_json(bytesPtrPtr.value, lengthPtr.value); + } + }); + } + + @override + R exportJsonRawSync(R Function(Uint8List) callback) { + return col.isar.getTxnSync(false, (Txn txn) { + final bytesPtrPtr = txn.alloc>(); + final lengthPtr = txn.alloc(); + final idNamePtr = col.schema.idName.toCString(txn.alloc); + + try { + nCall( + IC.isar_q_export_json( + queryPtr, + col.ptr, + txn.ptr, + idNamePtr, + bytesPtrPtr, + lengthPtr, + ), + ); + final bytes = bytesPtrPtr.value.asTypedList(lengthPtr.value); + return callback(bytes); + } finally { + IC.isar_free_json(bytesPtrPtr.value, lengthPtr.value); + } + }); + } + + @override + Future aggregate(AggregationOp op) async { + return col.isar.getTxn(false, (Txn txn) async { + final resultPtrPtr = txn.alloc>(); + + IC.isar_q_aggregate( + col.ptr, + queryPtr, + txn.ptr, + op.index, + propertyId ?? 0, + resultPtrPtr, + ); + await txn.wait(); + + return _convertAggregatedResult(resultPtrPtr.value, op); + }); + } + + @override + R? aggregateSync(AggregationOp op) { + return col.isar.getTxnSync(false, (Txn txn) { + final resultPtrPtr = txn.alloc>(); + + nCall( + IC.isar_q_aggregate( + col.ptr, + queryPtr, + txn.ptr, + op.index, + propertyId ?? 0, + resultPtrPtr, + ), + ); + return _convertAggregatedResult(resultPtrPtr.value, op); + }); + } + + R? _convertAggregatedResult( + Pointer resultPtr, + AggregationOp op, + ) { + final nullable = op == AggregationOp.min || op == AggregationOp.max; + if (R == int || R == DateTime) { + final value = IC.isar_q_aggregate_long_result(resultPtr); + if (nullable && value == nullLong) { + return null; + } + if (R == int) { + return value as R; + } else { + return DateTime.fromMicrosecondsSinceEpoch(value, isUtc: true).toLocal() + as R; + } + } else { + final value = IC.isar_q_aggregate_double_result(resultPtr); + if (nullable && value.isNaN) { + return null; + } else { + return value as R; + } + } + } +} diff --git a/packages_external/isar-3.1.0-1/packages/isar/lib/src/native/split_words.dart b/packages_external/isar-3.1.0-1/packages/isar/lib/src/native/split_words.dart new file mode 100644 index 00000000..6a887fb4 --- /dev/null +++ b/packages_external/isar-3.1.0-1/packages/isar/lib/src/native/split_words.dart @@ -0,0 +1,33 @@ +import 'dart:ffi'; + +import 'package:ffi/ffi.dart'; +import 'package:isar/src/native/encode_string.dart'; +import 'package:isar/src/native/isar_core.dart'; +import 'package:isar/src/native/isar_reader_impl.dart'; + +// ignore: public_member_api_docs +List isarSplitWords(String input) { + initializeCoreBinary(); + + final bytesPtr = malloc(input.length * 3); + final bytes = bytesPtr.asTypedList(input.length * 3); + final byteCount = encodeString(input, bytes, 0); + + final wordCountPtr = malloc(); + final boundariesPtr = + IC.isar_find_word_boundaries(bytesPtr.cast(), byteCount, wordCountPtr); + final wordCount = wordCountPtr.value; + final boundaries = boundariesPtr.asTypedList(wordCount * 2); + + final words = []; + for (var i = 0; i < wordCount * 2; i++) { + final wordBytes = bytes.sublist(boundaries[i++], boundaries[i]); + words.add(IsarReaderImpl.utf8Decoder.convert(wordBytes)); + } + + IC.isar_free_word_boundaries(boundariesPtr, wordCount); + malloc.free(bytesPtr); + malloc.free(wordCountPtr); + + return words; +} diff --git a/packages_external/isar-3.1.0-1/packages/isar/lib/src/native/txn.dart b/packages_external/isar-3.1.0-1/packages/isar/lib/src/native/txn.dart new file mode 100644 index 00000000..6017aef4 --- /dev/null +++ b/packages_external/isar-3.1.0-1/packages/isar/lib/src/native/txn.dart @@ -0,0 +1,113 @@ +import 'dart:async'; +import 'dart:collection'; +import 'dart:ffi'; + +import 'package:ffi/ffi.dart'; +import 'package:isar/isar.dart'; +import 'package:isar/src/common/isar_common.dart'; +import 'package:isar/src/native/bindings.dart'; +import 'package:isar/src/native/isar_core.dart'; + +/// @nodoc +class Txn extends Transaction { + /// @nodoc + Txn.sync(Isar isar, this.ptr, bool write) : super(isar, true, write); + + /// @nodoc + Txn.async(Isar isar, this.ptr, bool write, Stream stream) + : super(isar, false, write) { + _completers = Queue(); + _portSubscription = stream.listen( + (_) => _completers.removeFirst().complete(), + onError: (Object e) => _completers.removeFirst().completeError(e), + ); + } + + @override + bool active = true; + + /// An arena allocator that has the same lifetime as this transaction. + final alloc = Arena(malloc); + + /// The pointer to the native transaction. + final Pointer ptr; + Pointer? _cObjPtr; + Pointer? _cObjSetPtr; + + late Pointer _buffer; + int _bufferLen = -1; + + late final Queue> _completers; + late final StreamSubscription? _portSubscription; + + /// Get a shared CObject pointer + Pointer getCObject() { + _cObjPtr ??= alloc(); + return _cObjPtr!; + } + + /// Get a shared CObjectSet pointer + Pointer getCObjectsSet() { + _cObjSetPtr ??= alloc(); + return _cObjSetPtr!; + } + + /// Allocate a new CObjectSet with the given capacity. + Pointer newCObjectSet(int length) { + final cObjSetPtr = alloc(); + cObjSetPtr.ref + ..objects = alloc(length) + ..length = length; + return cObjSetPtr; + } + + /// Get a shared buffer with at least the specified size. + Pointer getBuffer(int size) { + if (_bufferLen < size) { + final allocSize = (size * 1.3).toInt(); + _buffer = alloc(allocSize); + _bufferLen = allocSize; + } + return _buffer; + } + + /// Wait for the latest async operation to complete. + Future wait() { + final completer = Completer(); + _completers.add(completer); + return completer.future; + } + + @override + Future commit() async { + active = false; + IC.isar_txn_finish(ptr, true); + await wait(); + unawaited(_portSubscription!.cancel()); + } + + @override + void commitSync() { + active = false; + nCall(IC.isar_txn_finish(ptr, true)); + } + + @override + Future abort() async { + active = false; + IC.isar_txn_finish(ptr, false); + await wait(); + unawaited(_portSubscription!.cancel()); + } + + @override + void abortSync() { + active = false; + nCall(IC.isar_txn_finish(ptr, false)); + } + + @override + void free() { + alloc.releaseAll(); + } +} diff --git a/packages_external/isar-3.1.0-1/packages/isar/lib/src/query.dart b/packages_external/isar-3.1.0-1/packages/isar/lib/src/query.dart new file mode 100644 index 00000000..89c7bd74 --- /dev/null +++ b/packages_external/isar-3.1.0-1/packages/isar/lib/src/query.dart @@ -0,0 +1,204 @@ +part of isar; + +/// Querying is how you find records that match certain conditions. +abstract class Query { + /// The default precision for floating point number queries. + static const double epsilon = 0.00001; + + /// The corresponding Isar instance. + Isar get isar; + + /// {@template query_find_first} + /// Find the first object that matches this query or `null` if no object + /// matches. + /// {@endtemplate} + Future findFirst(); + + /// {@macro query_find_first} + T? findFirstSync(); + + /// {@template query_find_all} + /// Find all objects that match this query. + /// {@endtemplate} + Future> findAll(); + + /// {@macro query_find_all} + List findAllSync(); + + /// @nodoc + @protected + Future aggregate(AggregationOp op); + + /// @nodoc + @protected + R? aggregateSync(AggregationOp op); + + /// {@template query_count} + /// Count how many objects match this query. + /// + /// This operation is much faster than using `findAll().length`. + /// {@endtemplate} + Future count() => + aggregate(AggregationOp.count).then((int? value) => value!); + + /// {@macro query_count} + int countSync() => aggregateSync(AggregationOp.count)!; + + /// {@template query_is_empty} + /// Returns `true` if there are no objects that match this query. + /// + /// This operation is faster than using `count() == 0`. + /// {@endtemplate} + Future isEmpty() => + aggregate(AggregationOp.isEmpty).then((value) => value == 1); + + /// {@macro query_is_empty} + bool isEmptySync() => aggregateSync(AggregationOp.isEmpty) == 1; + + /// {@template query_is_not_empty} + /// Returns `true` if there are objects that match this query. + /// + /// This operation is faster than using `count() > 0`. + /// {@endtemplate} + Future isNotEmpty() => + aggregate(AggregationOp.isEmpty).then((value) => value == 0); + + /// {@macro query_is_not_empty} + bool isNotEmptySync() => aggregateSync(AggregationOp.isEmpty) == 0; + + /// {@template query_delete_first} + /// Delete the first object that matches this query. Returns whether a object + /// has been deleted. + /// {@endtemplate} + Future deleteFirst(); + + /// {@macro query_delete_first} + bool deleteFirstSync(); + + /// {@template query_delete_all} + /// Delete all objects that match this query. Returns the number of deleted + /// objects. + /// {@endtemplate} + Future deleteAll(); + + /// {@macro query_delete_all} + int deleteAllSync(); + + /// {@template query_watch} + /// Create a watcher that yields the results of this query whenever its + /// results have (potentially) changed. + /// + /// If you don't always use the results, consider using `watchLazy` and rerun + /// the query manually. If [fireImmediately] is `true`, the results will be + /// sent to the consumer immediately. + /// {@endtemplate} + Stream> watch({bool fireImmediately = false}); + + /// {@template query_watch_lazy} + /// Watch the query for changes. If [fireImmediately] is `true`, an event will + /// be fired immediately. + /// {@endtemplate} + Stream watchLazy({bool fireImmediately = false}); + + /// {@template query_export_json_raw} + /// Export the results of this query as json bytes. + /// + /// **IMPORTANT:** Do not leak the bytes outside the callback. If you need to + /// use the bytes outside, create a copy of the `Uint8List`. + /// {@endtemplate} + Future exportJsonRaw(R Function(Uint8List) callback); + + /// {@macro query_export_json_raw} + R exportJsonRawSync(R Function(Uint8List) callback); + + /// {@template query_export_json} + /// Export the results of this query as json. + /// {@endtemplate} + Future>> exportJson() { + return exportJsonRaw((Uint8List bytes) { + final json = jsonDecode(const Utf8Decoder().convert(bytes)) as List; + return json.cast>(); + }); + } + + /// {@macro query_export_json} + List> exportJsonSync() { + return exportJsonRawSync((Uint8List bytes) { + final json = jsonDecode(const Utf8Decoder().convert(bytes)) as List; + return json.cast>(); + }); + } +} + +/// @nodoc +@protected +enum AggregationOp { + /// Finds the smallest value. + min, + + /// Finds the largest value. + max, + + /// Calculates the sum of all values. + sum, + + /// Calculates the average of all values. + average, + + /// Counts all values. + count, + + /// Returns `true` if the query has no results. + isEmpty, +} + +/// Extension for Queries +extension QueryAggregation on Query { + /// {@template aggregation_min} + /// Returns the minimum value of this query. + /// {@endtemplate} + Future min() => aggregate(AggregationOp.min); + + /// {@macro aggregation_min} + T? minSync() => aggregateSync(AggregationOp.min); + + /// {@template aggregation_max} + /// Returns the maximum value of this query. + /// {@endtemplate} + Future max() => aggregate(AggregationOp.max); + + /// {@macro aggregation_max} + T? maxSync() => aggregateSync(AggregationOp.max); + + /// {@template aggregation_average} + /// Returns the average value of this query. + /// {@endtemplate} + Future average() => + aggregate(AggregationOp.average).then((double? value) => value!); + + /// {@macro aggregation_average} + double averageSync() => aggregateSync(AggregationOp.average)!; + + /// {@template aggregation_sum} + /// Returns the sum of all values of this query. + /// {@endtemplate} + Future sum() => aggregate(AggregationOp.sum).then((value) => value!); + + /// {@macro aggregation_sum} + T sumSync() => aggregateSync(AggregationOp.sum)!; +} + +/// Extension for Queries +extension QueryDateAggregation on Query { + /// {@macro aggregation_min} + Future min() => aggregate(AggregationOp.min); + + /// {@macro aggregation_min} + DateTime? minSync() => aggregateSync(AggregationOp.min); + + /// {@macro aggregation_max} + Future max() => aggregate(AggregationOp.max); + + /// {@macro aggregation_max} + DateTime? maxSync() => aggregateSync(AggregationOp.max); +} diff --git a/packages_external/isar-3.1.0-1/packages/isar/lib/src/query_builder.dart b/packages_external/isar-3.1.0-1/packages/isar/lib/src/query_builder.dart new file mode 100644 index 00000000..a29e6d25 --- /dev/null +++ b/packages_external/isar-3.1.0-1/packages/isar/lib/src/query_builder.dart @@ -0,0 +1,403 @@ +part of isar; + +/// @nodoc +@protected +typedef FilterQuery = QueryBuilder + Function(QueryBuilder q); + +/// Query builders are used to create queries in a safe way. +/// +/// Acquire a `QueryBuilder` instance using `collection.where()` or +/// `collection.filter()`. +class QueryBuilder { + /// @nodoc + @protected + const QueryBuilder(this._query); + + final QueryBuilderInternal _query; + + /// @nodoc + @protected + static QueryBuilder apply( + QueryBuilder qb, + QueryBuilderInternal Function(QueryBuilderInternal query) + transform, + ) { + return QueryBuilder(transform(qb._query)); + } +} + +/// @nodoc +@protected +class QueryBuilderInternal { + /// @nodoc + const QueryBuilderInternal({ + this.collection, + this.whereClauses = const [], + this.whereDistinct = false, + this.whereSort = Sort.asc, + this.filter = const FilterGroup.and([]), + this.filterGroupType = FilterGroupType.and, + this.filterNot = false, + this.distinctByProperties = const [], + this.sortByProperties = const [], + this.offset, + this.limit, + this.propertyName, + }); + + /// @nodoc + final IsarCollection? collection; + + /// @nodoc + final List whereClauses; + + /// @nodoc + final bool whereDistinct; + + /// @nodoc + final Sort whereSort; + + /// @nodoc + final FilterGroup filter; + + /// @nodoc + final FilterGroupType filterGroupType; + + /// @nodoc + final bool filterNot; + + /// @nodoc + final List distinctByProperties; + + /// @nodoc + final List sortByProperties; + + /// @nodoc + final int? offset; + + /// @nodoc + final int? limit; + + /// @nodoc + final String? propertyName; + + /// @nodoc + QueryBuilderInternal addFilterCondition(FilterOperation cond) { + if (filterNot) { + cond = FilterGroup.not(cond); + } + + late FilterGroup filterGroup; + + if (filter.type == filterGroupType || filter.filters.length <= 1) { + filterGroup = FilterGroup( + type: filterGroupType, + filters: [...filter.filters, cond], + ); + } else if (filterGroupType == FilterGroupType.and) { + filterGroup = FilterGroup( + type: filter.type, + filters: [ + ...filter.filters.sublist(0, filter.filters.length - 1), + FilterGroup( + type: filterGroupType, + filters: [filter.filters.last, cond], + ), + ], + ); + } else { + filterGroup = FilterGroup( + type: filterGroupType, + filters: [filter, cond], + ); + } + + return copyWith( + filter: filterGroup, + filterGroupType: FilterGroupType.and, + filterNot: false, + ); + } + + /// @nodoc + QueryBuilderInternal addWhereClause(WhereClause where) { + return copyWith(whereClauses: [...whereClauses, where]); + } + + /// @nodoc + QueryBuilderInternal group(FilterQuery q) { + // ignore: prefer_const_constructors + final qb = q(QueryBuilder(QueryBuilderInternal())); + return addFilterCondition(qb._query.filter); + } + + /// @nodoc + QueryBuilderInternal listLength( + String property, + int lower, + bool includeLower, + int upper, + bool includeUpper, + ) { + if (!includeLower) { + lower += 1; + } + if (!includeUpper) { + if (upper == 0) { + lower = 1; + } else { + upper -= 1; + } + } + return addFilterCondition( + FilterCondition.listLength( + property: property, + lower: lower, + upper: upper, + ), + ); + } + + /// @nodoc + QueryBuilderInternal object( + FilterQuery q, + String property, + ) { + // ignore: prefer_const_constructors + final qb = q(QueryBuilder(QueryBuilderInternal())); + return addFilterCondition( + ObjectFilter(filter: qb._query.filter, property: property), + ); + } + + /// @nodoc + QueryBuilderInternal link( + FilterQuery q, + String linkName, + ) { + // ignore: prefer_const_constructors + final qb = q(QueryBuilder(QueryBuilderInternal())); + return addFilterCondition( + LinkFilter(filter: qb._query.filter, linkName: linkName), + ); + } + + /// @nodoc + QueryBuilderInternal linkLength( + String linkName, + int lower, + bool includeLower, + int upper, + bool includeUpper, + ) { + if (!includeLower) { + lower += 1; + } + if (!includeUpper) { + if (upper == 0) { + lower = 1; + } else { + upper -= 1; + } + } + return addFilterCondition( + LinkFilter.length( + lower: lower, + upper: upper, + linkName: linkName, + ), + ); + } + + /// @nodoc + QueryBuilderInternal addSortBy(String propertyName, Sort sort) { + return copyWith( + sortByProperties: [ + ...sortByProperties, + SortProperty(property: propertyName, sort: sort), + ], + ); + } + + /// @nodoc + QueryBuilderInternal addDistinctBy( + String propertyName, { + bool? caseSensitive, + }) { + return copyWith( + distinctByProperties: [ + ...distinctByProperties, + DistinctProperty( + property: propertyName, + caseSensitive: caseSensitive, + ), + ], + ); + } + + /// @nodoc + QueryBuilderInternal addPropertyName(String propertyName) { + return copyWith(propertyName: propertyName); + } + + /// @nodoc + QueryBuilderInternal copyWith({ + List? whereClauses, + FilterGroup? filter, + bool? filterIsGrouped, + FilterGroupType? filterGroupType, + bool? filterNot, + List? parentFilters, + List? distinctByProperties, + List? sortByProperties, + int? offset, + int? limit, + String? propertyName, + }) { + assert(offset == null || offset >= 0, 'Invalid offset'); + assert(limit == null || limit >= 0, 'Invalid limit'); + return QueryBuilderInternal( + collection: collection, + whereClauses: whereClauses ?? List.unmodifiable(this.whereClauses), + whereDistinct: whereDistinct, + whereSort: whereSort, + filter: filter ?? this.filter, + filterGroupType: filterGroupType ?? this.filterGroupType, + filterNot: filterNot ?? this.filterNot, + distinctByProperties: + distinctByProperties ?? List.unmodifiable(this.distinctByProperties), + sortByProperties: + sortByProperties ?? List.unmodifiable(this.sortByProperties), + offset: offset ?? this.offset, + limit: limit ?? this.limit, + propertyName: propertyName ?? this.propertyName, + ); + } + + /// @nodoc + @protected + Query build() { + return collection!.buildQuery( + whereDistinct: whereDistinct, + whereSort: whereSort, + whereClauses: whereClauses, + filter: filter, + sortBy: sortByProperties, + distinctBy: distinctByProperties, + offset: offset, + limit: limit, + property: propertyName, + ); + } +} + +/// @nodoc +/// +/// Right after query starts +@protected +class QWhere + implements + QWhereClause, + QFilter, + QSortBy, + QDistinct, + QOffset, + QLimit, + QQueryProperty {} + +/// @nodoc +/// +/// No more where conditions are allowed +@protected +class QAfterWhere + implements QFilter, QSortBy, QDistinct, QOffset, QLimit, QQueryProperty {} + +/// @nodoc +@protected +class QWhereClause {} + +/// @nodoc +@protected +class QAfterWhereClause + implements + QWhereOr, + QFilter, + QSortBy, + QDistinct, + QOffset, + QLimit, + QQueryProperty {} + +/// @nodoc +@protected +class QWhereOr {} + +/// @nodoc +@protected +class QFilter {} + +/// @nodoc +@protected +class QFilterCondition {} + +/// @nodoc +@protected +class QAfterFilterCondition + implements + QFilterCondition, + QFilterOperator, + QSortBy, + QDistinct, + QOffset, + QLimit, + QQueryProperty {} + +/// @nodoc +@protected +class QFilterOperator {} + +/// @nodoc +@protected +class QAfterFilterOperator implements QFilterCondition {} + +/// @nodoc +@protected +class QSortBy {} + +/// @nodoc +@protected +class QAfterSortBy + implements QSortThenBy, QDistinct, QOffset, QLimit, QQueryProperty {} + +/// @nodoc +@protected +class QSortThenBy {} + +/// @nodoc +@protected +class QDistinct implements QOffset, QLimit, QQueryProperty {} + +/// @nodoc +@protected +class QOffset {} + +/// @nodoc +@protected +class QAfterOffset implements QLimit, QQueryProperty {} + +/// @nodoc +@protected +class QLimit {} + +/// @nodoc +@protected +class QAfterLimit implements QQueryProperty {} + +/// @nodoc +@protected +class QQueryProperty implements QQueryOperations {} + +/// @nodoc +@protected +class QQueryOperations {} diff --git a/packages_external/isar-3.1.0-1/packages/isar/lib/src/query_builder_extensions.dart b/packages_external/isar-3.1.0-1/packages/isar/lib/src/query_builder_extensions.dart new file mode 100644 index 00000000..70be3c05 --- /dev/null +++ b/packages_external/isar-3.1.0-1/packages/isar/lib/src/query_builder_extensions.dart @@ -0,0 +1,303 @@ +part of isar; + +/// Extension for QueryBuilders. +extension QueryWhereOr on QueryBuilder { + /// Union of two where clauses. + QueryBuilder or() { + return QueryBuilder(_query); + } +} + +/// @nodoc +@protected +typedef WhereRepeatModifier = QueryBuilder + Function(QueryBuilder q, E element); + +/// Extension for QueryBuilders. +extension QueryWhere on QueryBuilder { + /// Joins the results of the [modifier] for each item in [items] using logical + /// OR. So an object will be included if it matches at least one of the + /// resulting where clauses. + /// + /// If [items] is empty, this is a no-op. + QueryBuilder anyOf( + Iterable items, + WhereRepeatModifier modifier, + ) { + QueryBuilder? q; + for (final e in items) { + q = modifier(q?.or() ?? QueryBuilder(_query), e); + } + return q ?? QueryBuilder(_query); + } +} + +/// Extension for QueryBuilders. +extension QueryFilters on QueryBuilder { + /// Start using filter conditions. + QueryBuilder filter() { + return QueryBuilder(_query); + } +} + +/// @nodoc +@protected +typedef FilterRepeatModifier + = QueryBuilder Function( + QueryBuilder q, + E element, +); + +/// Extension for QueryBuilders. +extension QueryFilterAndOr on QueryBuilder { + /// Intersection of two filter conditions. + QueryBuilder and() { + return QueryBuilder.apply( + this, + (q) => q.copyWith(filterGroupType: FilterGroupType.and), + ); + } + + /// Union of two filter conditions. + QueryBuilder or() { + return QueryBuilder.apply( + this, + (q) => q.copyWith(filterGroupType: FilterGroupType.or), + ); + } + + /// Logical XOR of two filter conditions. + QueryBuilder xor() { + return QueryBuilder.apply( + this, + (q) => q.copyWith(filterGroupType: FilterGroupType.xor), + ); + } +} + +/// Extension for QueryBuilders. +extension QueryFilterNot on QueryBuilder { + /// Complement the next filter condition or group. + QueryBuilder not() { + return QueryBuilder.apply( + this, + (q) => q.copyWith(filterNot: !q.filterNot), + ); + } + + /// Joins the results of the [modifier] for each item in [items] using logical + /// OR. So an object will be included if it matches at least one of the + /// resulting filters. + /// + /// If [items] is empty, this is a no-op. + QueryBuilder anyOf( + Iterable items, + FilterRepeatModifier modifier, + ) { + return QueryBuilder.apply(this, (query) { + return query.group((q) { + var q2 = QueryBuilder(q._query); + for (final e in items) { + q2 = modifier(q2.or(), e); + } + return q2; + }); + }); + } + + /// Joins the results of the [modifier] for each item in [items] using logical + /// AND. So an object will be included if it matches all of the resulting + /// filters. + /// + /// If [items] is empty, this is a no-op. + QueryBuilder allOf( + Iterable items, + FilterRepeatModifier modifier, + ) { + return QueryBuilder.apply(this, (query) { + return query.group((q) { + var q2 = QueryBuilder(q._query); + for (final e in items) { + q2 = modifier(q2.and(), e); + } + return q2; + }); + }); + } + + /// Joins the results of the [modifier] for each item in [items] using logical + /// XOR. So an object will be included if it matches exactly one of the + /// resulting filters. + /// + /// If [items] is empty, this is a no-op. + QueryBuilder oneOf( + Iterable items, + FilterRepeatModifier modifier, + ) { + QueryBuilder? q; + for (final e in items) { + q = modifier(q?.xor() ?? QueryBuilder(_query), e); + } + return q ?? QueryBuilder(_query); + } +} + +/// Extension for QueryBuilders. +extension QueryFilterNoGroups + on QueryBuilder { + /// Group filter conditions. + QueryBuilder group(FilterQuery q) { + return QueryBuilder.apply(this, (query) => query.group(q)); + } +} + +/// Extension for QueryBuilders. +extension QueryOffset on QueryBuilder { + /// Offset the query results by a static number. + QueryBuilder offset(int offset) { + return QueryBuilder.apply(this, (q) => q.copyWith(offset: offset)); + } +} + +/// Extension for QueryBuilders. +extension QueryLimit on QueryBuilder { + /// Limit the maximum number of query results. + QueryBuilder limit(int limit) { + return QueryBuilder.apply(this, (q) => q.copyWith(limit: limit)); + } +} + +/// @nodoc +@protected +typedef QueryOption = QueryBuilder Function( + QueryBuilder q, +); + +/// Extension for QueryBuilders. +extension QueryModifier on QueryBuilder { + /// Only apply a part of the query if `enabled` is true. + QueryBuilder optional( + bool enabled, + QueryOption option, + ) { + if (enabled) { + return option(this); + } else { + return QueryBuilder(_query); + } + } +} + +/// Extension for QueryBuilders +extension QueryExecute on QueryBuilder { + /// Create a query from this query builder. + Query build() => _query.build(); + + /// {@macro query_find_first} + Future findFirst() => build().findFirst(); + + /// {@macro query_find_first} + R? findFirstSync() => build().findFirstSync(); + + /// {@macro query_find_all} + Future> findAll() => build().findAll(); + + /// {@macro query_find_all} + List findAllSync() => build().findAllSync(); + + /// {@macro query_count} + Future count() => build().count(); + + /// {@macro query_count} + int countSync() => build().countSync(); + + /// {@macro query_is_empty} + Future isEmpty() => build().isEmpty(); + + /// {@macro query_is_empty} + bool isEmptySync() => build().isEmptySync(); + + /// {@macro query_is_not_empty} + Future isNotEmpty() => build().isNotEmpty(); + + /// {@macro query_is_not_empty} + bool isNotEmptySync() => build().isNotEmptySync(); + + /// {@macro query_delete_first} + Future deleteFirst() => build().deleteFirst(); + + /// {@macro query_delete_first} + bool deleteFirstSync() => build().deleteFirstSync(); + + /// {@macro query_delete_all} + Future deleteAll() => build().deleteAll(); + + /// {@macro query_delete_all} + int deleteAllSync() => build().deleteAllSync(); + + /// {@macro query_watch} + Stream> watch({bool fireImmediately = false}) => + build().watch(fireImmediately: fireImmediately); + + /// {@macro query_watch_lazy} + Stream watchLazy({bool fireImmediately = false}) => + build().watchLazy(fireImmediately: fireImmediately); + + /// {@macro query_export_json_raw} + Future exportJsonRaw(T Function(Uint8List) callback) => + build().exportJsonRaw(callback); + + /// {@macro query_export_json_raw} + T exportJsonRawSync(T Function(Uint8List) callback) => + build().exportJsonRawSync(callback); + + /// {@macro query_export_json} + Future>> exportJson() => build().exportJson(); + + /// {@macro query_export_json} + List> exportJsonSync() => build().exportJsonSync(); +} + +/// Extension for QueryBuilders +extension QueryExecuteAggregation + on QueryBuilder { + /// {@macro aggregation_min} + Future min() => build().min(); + + /// {@macro aggregation_min} + T? minSync() => build().minSync(); + + /// {@macro aggregation_max} + Future max() => build().max(); + + /// {@macro aggregation_max} + T? maxSync() => build().maxSync(); + + /// {@macro aggregation_average} + Future average() => build().average(); + + /// {@macro aggregation_average} + double averageSync() => build().averageSync(); + + /// {@macro aggregation_sum} + Future sum() => build().sum(); + + /// {@macro aggregation_sum} + T sumSync() => build().sumSync(); +} + +/// Extension for QueryBuilders +extension QueryExecuteDateAggregation + on QueryBuilder { + /// {@macro aggregation_min} + Future min() => build().min(); + + /// {@macro aggregation_min} + DateTime? minSync() => build().minSync(); + + /// {@macro aggregation_max} + Future max() => build().max(); + + /// {@macro aggregation_max} + DateTime? maxSync() => build().maxSync(); +} diff --git a/packages_external/isar-3.1.0-1/packages/isar/lib/src/query_components.dart b/packages_external/isar-3.1.0-1/packages/isar/lib/src/query_components.dart new file mode 100644 index 00000000..a2bbfdb1 --- /dev/null +++ b/packages_external/isar-3.1.0-1/packages/isar/lib/src/query_components.dart @@ -0,0 +1,597 @@ +part of isar; + +/// A where clause to traverse an Isar index. +abstract class WhereClause { + const WhereClause._(); +} + +/// A where clause traversing the primary index (ids). +class IdWhereClause extends WhereClause { + /// Where clause that matches all ids. Useful to get sorted results. + const IdWhereClause.any() + : lower = null, + upper = null, + includeLower = true, + includeUpper = true, + super._(); + + /// Where clause that matches all id values greater than the given [lower] + /// bound. + const IdWhereClause.greaterThan({ + required Id this.lower, + this.includeLower = true, + }) : upper = null, + includeUpper = true, + super._(); + + /// Where clause that matches all id values less than the given [upper] + /// bound. + const IdWhereClause.lessThan({ + required Id this.upper, + this.includeUpper = true, + }) : lower = null, + includeLower = true, + super._(); + + /// Where clause that matches the id value equal to the given [value]. + const IdWhereClause.equalTo({ + required Id value, + }) : lower = value, + upper = value, + includeLower = true, + includeUpper = true, + super._(); + + /// Where clause that matches all id values between the given [lower] and + /// [upper] bounds. + const IdWhereClause.between({ + this.lower, + this.includeLower = true, + this.upper, + this.includeUpper = true, + }) : super._(); + + /// The lower bound id or `null` for unbounded. + final Id? lower; + + /// Whether the lower bound should be included in the results. + final bool includeLower; + + /// The upper bound id or `null` for unbounded. + final Id? upper; + + /// Whether the upper bound should be included in the results. + final bool includeUpper; +} + +/// A where clause traversing an index. +class IndexWhereClause extends WhereClause { + /// Where clause that matches all index values. Useful to get sorted results. + const IndexWhereClause.any({required this.indexName}) + : lower = null, + upper = null, + includeLower = true, + includeUpper = true, + epsilon = Query.epsilon, + super._(); + + /// Where clause that matches all index values greater than the given [lower] + /// bound. + /// + /// For composite indexes, the first elements of the [lower] list are checked + /// for equality. + const IndexWhereClause.greaterThan({ + required this.indexName, + required IndexKey this.lower, + this.includeLower = true, + this.epsilon = Query.epsilon, + }) : upper = null, + includeUpper = true, + super._(); + + /// Where clause that matches all index values less than the given [upper] + /// bound. + /// + /// For composite indexes, the first elements of the [upper] list are checked + /// for equality. + const IndexWhereClause.lessThan({ + required this.indexName, + required IndexKey this.upper, + this.includeUpper = true, + this.epsilon = Query.epsilon, + }) : lower = null, + includeLower = true, + super._(); + + /// Where clause that matches all index values equal to the given [value]. + const IndexWhereClause.equalTo({ + required this.indexName, + required IndexKey value, + this.epsilon = Query.epsilon, + }) : lower = value, + upper = value, + includeLower = true, + includeUpper = true, + super._(); + + /// Where clause that matches all index values between the given [lower] and + /// [upper] bounds. + /// + /// For composite indexes, the first elements of the [lower] and [upper] lists + /// are checked for equality. + const IndexWhereClause.between({ + required this.indexName, + required IndexKey this.lower, + this.includeLower = true, + required IndexKey this.upper, + this.includeUpper = true, + this.epsilon = Query.epsilon, + }) : super._(); + + /// The Isar name of the index to be used. + final String indexName; + + /// The lower bound of the where clause. + final IndexKey? lower; + + /// Whether the lower bound should be included in the results. Double values + /// are never included. + final bool includeLower; + + /// The upper bound of the where clause. + final IndexKey? upper; + + /// Whether the upper bound should be included in the results. Double values + /// are never included. + final bool includeUpper; + + /// The precision to use for floating point values. + final double epsilon; +} + +/// A where clause traversing objects linked to the specified object. +class LinkWhereClause extends WhereClause { + /// Create a where clause for the specified link. + const LinkWhereClause({ + required this.linkCollection, + required this.linkName, + required this.id, + }) : super._(); + + /// The name of the collection the link originates from. + final String linkCollection; + + /// The isar name of the link to be used. + final String linkName; + + /// The id of the source object. + final Id id; +} + +/// @nodoc +@protected +abstract class FilterOperation { + const FilterOperation._(); +} + +/// The type of dynamic filter conditions. +enum FilterConditionType { + /// Filter checking for equality. + equalTo, + + /// Filter matching values greater than the bound. + greaterThan, + + /// Filter matching values smaller than the bound. + lessThan, + + /// Filter matching values between the bounds. + between, + + /// Filter matching String values starting with the prefix. + startsWith, + + /// Filter matching String values ending with the suffix. + endsWith, + + /// Filter matching String values containing the String. + contains, + + /// Filter matching String values matching the wildcard. + matches, + + /// Filter matching values that are `null`. + isNull, + + /// Filter matching values that are not `null`. + isNotNull, + + /// Filter matching lists that contain `null`. + elementIsNull, + + /// Filter matching lists that contain an element that is not `null`. + elementIsNotNull, + + /// Filter matching the length of a list. + listLength, +} + +/// Create a filter condition dynamically. +class FilterCondition extends FilterOperation { + /// @nodoc + @protected + const FilterCondition({ + required this.type, + required this.property, + this.value1, + this.value2, + required this.include1, + required this.include2, + required this.caseSensitive, + this.epsilon = Query.epsilon, + }) : super._(); + + /// Filters the results to only include objects where the property equals + /// [value]. + /// + /// For lists, at least one of the values in the list has to match. + const FilterCondition.equalTo({ + required this.property, + required Object? value, + this.caseSensitive = true, + this.epsilon = Query.epsilon, + }) : type = FilterConditionType.equalTo, + value1 = value, + include1 = true, + value2 = null, + include2 = false, + super._(); + + /// Filters the results to only include objects where the property is greater + /// than [value]. + /// + /// For lists, at least one of the values in the list has to match. + const FilterCondition.greaterThan({ + required this.property, + required Object? value, + bool include = false, + this.caseSensitive = true, + this.epsilon = Query.epsilon, + }) : type = FilterConditionType.greaterThan, + value1 = value, + include1 = include, + value2 = null, + include2 = false, + super._(); + + /// Filters the results to only include objects where the property is less + /// than [value]. + /// + /// For lists, at least one of the values in the list has to match. + const FilterCondition.lessThan({ + required this.property, + required Object? value, + bool include = false, + this.caseSensitive = true, + this.epsilon = Query.epsilon, + }) : type = FilterConditionType.lessThan, + value1 = value, + include1 = include, + value2 = null, + include2 = false, + super._(); + + /// Filters the results to only include objects where the property is + /// between [lower] and [upper]. + /// + /// For lists, at least one of the values in the list has to match. + const FilterCondition.between({ + required this.property, + Object? lower, + bool includeLower = true, + Object? upper, + bool includeUpper = true, + this.caseSensitive = true, + this.epsilon = Query.epsilon, + }) : value1 = lower, + include1 = includeLower, + value2 = upper, + include2 = includeUpper, + type = FilterConditionType.between, + super._(); + + /// Filters the results to only include objects where the property starts + /// with [value]. + /// + /// For String lists, at least one of the values in the list has to match. + const FilterCondition.startsWith({ + required this.property, + required String value, + this.caseSensitive = true, + }) : type = FilterConditionType.startsWith, + value1 = value, + include1 = true, + value2 = null, + include2 = false, + epsilon = Query.epsilon, + super._(); + + /// Filters the results to only include objects where the property ends with + /// [value]. + /// + /// For String lists, at least one of the values in the list has to match. + const FilterCondition.endsWith({ + required this.property, + required String value, + this.caseSensitive = true, + }) : type = FilterConditionType.endsWith, + value1 = value, + include1 = true, + value2 = null, + include2 = false, + epsilon = Query.epsilon, + super._(); + + /// Filters the results to only include objects where the String property + /// contains [value]. + /// + /// For String lists, at least one of the values in the list has to match. + const FilterCondition.contains({ + required this.property, + required String value, + this.caseSensitive = true, + }) : type = FilterConditionType.contains, + value1 = value, + include1 = true, + value2 = null, + include2 = false, + epsilon = Query.epsilon, + super._(); + + /// Filters the results to only include objects where the property matches + /// the [wildcard]. + /// + /// For String lists, at least one of the values in the list has to match. + const FilterCondition.matches({ + required this.property, + required String wildcard, + this.caseSensitive = true, + }) : type = FilterConditionType.matches, + value1 = wildcard, + include1 = true, + value2 = null, + include2 = false, + epsilon = Query.epsilon, + super._(); + + /// Filters the results to only include objects where the property is null. + const FilterCondition.isNull({ + required this.property, + }) : type = FilterConditionType.isNull, + value1 = null, + include1 = false, + value2 = null, + include2 = false, + caseSensitive = false, + epsilon = Query.epsilon, + super._(); + + /// Filters the results to only include objects where the property is not + /// null. + const FilterCondition.isNotNull({ + required this.property, + }) : type = FilterConditionType.isNotNull, + value1 = null, + include1 = false, + value2 = null, + include2 = false, + caseSensitive = false, + epsilon = Query.epsilon, + super._(); + + /// Filters the results to only include lists that contain `null`. + const FilterCondition.elementIsNull({ + required this.property, + }) : type = FilterConditionType.elementIsNull, + value1 = null, + include1 = false, + value2 = null, + include2 = false, + caseSensitive = false, + epsilon = Query.epsilon, + super._(); + + /// Filters the results to only include lists that do not contain `null`. + const FilterCondition.elementIsNotNull({ + required this.property, + }) : type = FilterConditionType.elementIsNotNull, + value1 = null, + include1 = false, + value2 = null, + include2 = false, + caseSensitive = false, + epsilon = Query.epsilon, + super._(); + + /// Filters the results to only include objects where the length of + /// [property] is between [lower] (included) and [upper] (included). + /// + /// Only list properties are supported. + const FilterCondition.listLength({ + required this.property, + required int lower, + required int upper, + }) : type = FilterConditionType.listLength, + value1 = lower, + include1 = true, + value2 = upper, + include2 = true, + caseSensitive = false, + epsilon = Query.epsilon, + assert(lower >= 0 && upper >= 0, 'List length must be positive.'), + super._(); + + /// Type of the filter condition. + final FilterConditionType type; + + /// Property used for comparisons. + final String property; + + /// Value used for comparisons. Lower bound for `ConditionType.between`. + final Object? value1; + + /// Should `value1` be part of the results. + final bool include1; + + /// Upper bound for `ConditionType.between`. + final Object? value2; + + /// Should `value1` be part of the results. + final bool include2; + + /// Are string operations case sensitive. + final bool caseSensitive; + + /// The precision to use for floating point values. + final double epsilon; +} + +/// The type of filter groups. +enum FilterGroupType { + /// Logical AND. + and, + + /// Logical OR. + or, + + /// Logical XOR. + xor, + + /// Logical NOT. + not, +} + +/// Group one or more filter conditions. +class FilterGroup extends FilterOperation { + /// @nodoc + @protected + FilterGroup({ + required this.type, + required this.filters, + }) : super._(); + + /// Create a logical AND filter group. + /// + /// Matches when all [filters] match. + const FilterGroup.and(this.filters) + : type = FilterGroupType.and, + super._(); + + /// Create a logical OR filter group. + /// + /// Matches when any of the [filters] matches. + const FilterGroup.or(this.filters) + : type = FilterGroupType.or, + super._(); + + /// Create a logical XOR filter group. + /// + /// Matches when exactly one of the [filters] matches. + const FilterGroup.xor(this.filters) + : type = FilterGroupType.xor, + super._(); + + /// Negate a filter. + /// + /// Matches when any of the [filter] doesn't matches. + FilterGroup.not(FilterOperation filter) + : filters = [filter], + type = FilterGroupType.not, + super._(); + + /// Type of this group. + final FilterGroupType type; + + /// The filter(s) to be grouped. + final List filters; +} + +/// Sort order +enum Sort { + /// Ascending sort order. + asc, + + /// Descending sort order. + desc, +} + +/// Property used to sort query results. +class SortProperty { + /// Create a sort property. + const SortProperty({required this.property, required this.sort}); + + /// Isar name of the property used for sorting. + final String property; + + /// Sort order. + final Sort sort; +} + +/// Property used to filter duplicate values. +class DistinctProperty { + /// Create a distinct property. + const DistinctProperty({required this.property, this.caseSensitive}); + + /// Isar name of the property used for sorting. + final String property; + + /// Should Strings be case sensitive? + final bool? caseSensitive; +} + +/// Filter condition based on an embedded object. +class ObjectFilter extends FilterOperation { + /// Create a filter condition based on an embedded object. + const ObjectFilter({ + required this.property, + required this.filter, + }) : super._(); + + /// Property containing the embedded object(s). + final String property; + + /// Filter condition that should be applied + final FilterOperation filter; +} + +/// Filter condition based on a link. +class LinkFilter extends FilterOperation { + /// Create a filter condition based on a link. + const LinkFilter({ + required this.linkName, + required FilterOperation this.filter, + }) : lower = null, + upper = null, + super._(); + + /// Create a filter condition based on the number of linked objects. + const LinkFilter.length({ + required this.linkName, + required int this.lower, + required int this.upper, + }) : filter = null, + assert(lower >= 0 && upper >= 0, 'Link length must be positive.'), + super._(); + + /// Isar name of the link. + final String linkName; + + /// Filter condition that should be applied + final FilterOperation? filter; + + /// The minumum number of linked objects + final int? lower; + + /// The maximum number of linked objects + final int? upper; +} diff --git a/packages_external/isar-3.1.0-1/packages/isar/lib/src/schema/collection_schema.dart b/packages_external/isar-3.1.0-1/packages/isar/lib/src/schema/collection_schema.dart new file mode 100644 index 00000000..24d280a1 --- /dev/null +++ b/packages_external/isar-3.1.0-1/packages/isar/lib/src/schema/collection_schema.dart @@ -0,0 +1,152 @@ +part of isar; + +/// This schema represents a collection. +class CollectionSchema extends Schema { + /// @nodoc + @protected + const CollectionSchema({ + required super.id, + required super.name, + required super.properties, + required super.estimateSize, + required super.serialize, + required super.deserialize, + required super.deserializeProp, + required this.idName, + required this.indexes, + required this.links, + required this.embeddedSchemas, + required this.getId, + required this.getLinks, + required this.attach, + required this.version, + }) : assert( + Isar.version == version, + 'Outdated generated code. Please re-run code ' + 'generation using the latest generator.', + ); + + /// @nodoc + @protected + factory CollectionSchema.fromJson(Map json) { + final collection = Schema.fromJson(json); + return CollectionSchema( + id: collection.id, + name: collection.name, + properties: collection.properties, + idName: json['idName'] as String, + indexes: { + for (final index in json['indexes'] as List) + (index as Map)['name'] as String: + IndexSchema.fromJson(index), + }, + links: { + for (final link in json['links'] as List) + (link as Map)['name'] as String: + LinkSchema.fromJson(link), + }, + embeddedSchemas: { + for (final schema in json['embeddedSchemas'] as List) + (schema as Map)['name'] as String: + Schema.fromJson(schema), + }, + estimateSize: (_, __, ___) => throw UnimplementedError(), + serialize: (_, __, ___, ____) => throw UnimplementedError(), + deserialize: (_, __, ___, ____) => throw UnimplementedError(), + deserializeProp: (_, __, ___, ____) => throw UnimplementedError(), + getId: (_) => throw UnimplementedError(), + getLinks: (_) => throw UnimplementedError(), + attach: (_, __, ___) => throw UnimplementedError(), + version: Isar.version, + ); + } + + /// Name of the id property + final String idName; + + @override + bool get embedded => false; + + /// A map of name -> index pairs + final Map indexes; + + /// A map of name -> link pairs + final Map links; + + /// A map of name -> embedded schema pairs + final Map> embeddedSchemas; + + /// @nodoc + final GetId getId; + + /// @nodoc + final GetLinks getLinks; + + /// @nodoc + final Attach attach; + + /// @nodoc + final String version; + + /// @nodoc + void toCollection(void Function() callback) => callback(); + + /// @nodoc + @pragma('vm:prefer-inline') + IndexSchema index(String indexName) { + final index = indexes[indexName]; + if (index != null) { + return index; + } else { + throw IsarError('Unknown index "$indexName"'); + } + } + + /// @nodoc + @pragma('vm:prefer-inline') + LinkSchema link(String linkName) { + final link = links[linkName]; + if (link != null) { + return link; + } else { + throw IsarError('Unknown link "$linkName"'); + } + } + + /// @nodoc + @protected + @override + Map toJson() { + final json = { + ...super.toJson(), + 'idName': idName, + 'indexes': [ + for (final index in indexes.values) index.toJson(), + ], + 'links': [ + for (final link in links.values) link.toJson(), + ], + }; + + assert(() { + json['embeddedSchemas'] = [ + for (final schema in embeddedSchemas.values) schema.toJson(), + ]; + return true; + }()); + + return json; + } +} + +/// @nodoc +@protected +typedef GetId = Id Function(T object); + +/// @nodoc +@protected +typedef GetLinks = List> Function(T object); + +/// @nodoc +@protected +typedef Attach = void Function(IsarCollection col, Id id, T object); diff --git a/packages_external/isar-3.1.0-1/packages/isar/lib/src/schema/index_schema.dart b/packages_external/isar-3.1.0-1/packages/isar/lib/src/schema/index_schema.dart new file mode 100644 index 00000000..d8ceb8b9 --- /dev/null +++ b/packages_external/isar-3.1.0-1/packages/isar/lib/src/schema/index_schema.dart @@ -0,0 +1,104 @@ +part of isar; + +/// This schema represents an index. +class IndexSchema { + /// @nodoc + @protected + const IndexSchema({ + required this.id, + required this.name, + required this.unique, + required this.replace, + required this.properties, + }); + + /// @nodoc + @protected + factory IndexSchema.fromJson(Map json) { + return IndexSchema( + id: -1, + name: json['name'] as String, + unique: json['unique'] as bool, + replace: json['replace'] as bool, + properties: (json['properties'] as List) + .map((e) => IndexPropertySchema.fromJson(e as Map)) + .toList(), + ); + } + + /// Internal id of this index. + final int id; + + /// Name of this index. + final String name; + + /// Whether duplicates are disallowed in this index. + final bool unique; + + /// Whether duplocates will be replaced or throw an error. + final bool replace; + + /// Composite properties. + final List properties; + + /// @nodoc + @protected + Map toJson() { + final json = { + 'name': name, + 'unique': unique, + 'replace': replace, + 'properties': [ + for (final property in properties) property.toJson(), + ], + }; + + return json; + } +} + +/// This schema represents a composite index property. +class IndexPropertySchema { + /// @nodoc + @protected + const IndexPropertySchema({ + required this.name, + required this.type, + required this.caseSensitive, + }); + + /// @nodoc + @protected + factory IndexPropertySchema.fromJson(Map json) { + return IndexPropertySchema( + name: json['name'] as String, + type: IndexType.values.firstWhere((e) => _typeName[e] == json['type']), + caseSensitive: json['caseSensitive'] as bool, + ); + } + + /// Isar name of the property. + final String name; + + /// Type of index. + final IndexType type; + + /// Whether String properties should be stored with casing. + final bool caseSensitive; + + /// @nodoc + @protected + Map toJson() { + return { + 'name': name, + 'type': _typeName[type], + 'caseSensitive': caseSensitive, + }; + } + + static const _typeName = { + IndexType.value: 'Value', + IndexType.hash: 'Hash', + IndexType.hashElements: 'HashElements', + }; +} diff --git a/packages_external/isar-3.1.0-1/packages/isar/lib/src/schema/link_schema.dart b/packages_external/isar-3.1.0-1/packages/isar/lib/src/schema/link_schema.dart new file mode 100644 index 00000000..046ed645 --- /dev/null +++ b/packages_external/isar-3.1.0-1/packages/isar/lib/src/schema/link_schema.dart @@ -0,0 +1,64 @@ +part of isar; + +/// This schema represents a link to the same or another collection. +class LinkSchema { + /// @nodoc + @protected + const LinkSchema({ + required this.id, + required this.name, + required this.target, + required this.single, + this.linkName, + }); + + /// @nodoc + @protected + factory LinkSchema.fromJson(Map json) { + return LinkSchema( + id: -1, + name: json['name'] as String, + target: json['target'] as String, + single: json['single'] as bool, + linkName: json['linkName'] as String?, + ); + } + + /// Internal id of this link. + final int id; + + /// Name of this link. + final String name; + + /// Isar name of the target collection. + final String target; + + /// Whether this is link can only hold a single target object. + final bool single; + + /// If this is a backlink, [linkName] is the name of the source link in the + /// [target] collection. + final String? linkName; + + /// Whether this link is a backlink. + bool get isBacklink => linkName != null; + + /// @nodoc + @protected + Map toJson() { + final json = { + 'name': name, + 'target': target, + 'single': single, + }; + + assert(() { + if (linkName != null) { + json['linkName'] = linkName; + } + return true; + }()); + + return json; + } +} diff --git a/packages_external/isar-3.1.0-1/packages/isar/lib/src/schema/property_schema.dart b/packages_external/isar-3.1.0-1/packages/isar/lib/src/schema/property_schema.dart new file mode 100644 index 00000000..9f34c13b --- /dev/null +++ b/packages_external/isar-3.1.0-1/packages/isar/lib/src/schema/property_schema.dart @@ -0,0 +1,183 @@ +part of isar; + +/// A single propery of a collection or embedded object. +class PropertySchema { + /// @nodoc + @protected + const PropertySchema({ + required this.id, + required this.name, + required this.type, + this.enumMap, + this.target, + }); + + /// @nodoc + @protected + factory PropertySchema.fromJson(Map json) { + return PropertySchema( + id: -1, + name: json['name'] as String, + type: IsarType.values.firstWhere((e) => e.schemaName == json['type']), + enumMap: json['enumMap'] as Map?, + target: json['target'] as String?, + ); + } + + /// Internal id of this property. + final int id; + + /// Name of the property + final String name; + + /// Isar type of the property + final IsarType type; + + /// Maps enum names to database values + final Map? enumMap; + + /// For embedded objects: Name of the target schema + final String? target; + + /// @nodoc + @protected + Map toJson() { + final json = { + 'name': name, + 'type': type.schemaName, + if (target != null) 'target': target, + }; + + assert(() { + if (enumMap != null) { + json['enumMap'] = enumMap; + } + return true; + }()); + + return json; + } +} + +/// Supported Isar types +enum IsarType { + /// Boolean + bool('Bool'), + + /// 8-bit unsigned integer + byte('Byte'), + + /// 32-bit singed integer + int('Int'), + + /// 32-bit float + float('Float'), + + /// 64-bit singed integer + long('Long'), + + /// 64-bit float + double('Double'), + + /// DateTime + dateTime('DateTime'), + + /// String + string('String'), + + /// Embedded object + object('Object'), + + /// Boolean list + boolList('BoolList'), + + /// 8-bit unsigned integer list + byteList('ByteList'), + + /// 32-bit singed integer list + intList('IntList'), + + /// 32-bit float list + floatList('FloatList'), + + /// 64-bit singed integer list + longList('LongList'), + + /// 64-bit float list + doubleList('DoubleList'), + + /// DateTime list + dateTimeList('DateTimeList'), + + /// String list + stringList('StringList'), + + /// Embedded object list + objectList('ObjectList'); + + /// @nodoc + const IsarType(this.schemaName); + + /// @nodoc + final String schemaName; +} + +/// @nodoc +extension IsarTypeX on IsarType { + /// Whether this type represents a list + bool get isList => index >= IsarType.boolList.index; + + /// @nodoc + IsarType get scalarType { + switch (this) { + case IsarType.boolList: + return IsarType.bool; + case IsarType.byteList: + return IsarType.byte; + case IsarType.intList: + return IsarType.int; + case IsarType.floatList: + return IsarType.float; + case IsarType.longList: + return IsarType.long; + case IsarType.doubleList: + return IsarType.double; + case IsarType.dateTimeList: + return IsarType.dateTime; + case IsarType.stringList: + return IsarType.string; + case IsarType.objectList: + return IsarType.object; + // ignore: no_default_cases + default: + return this; + } + } + + /// @nodoc + IsarType get listType { + switch (this) { + case IsarType.bool: + return IsarType.boolList; + case IsarType.byte: + return IsarType.byteList; + case IsarType.int: + return IsarType.intList; + case IsarType.float: + return IsarType.floatList; + case IsarType.long: + return IsarType.longList; + case IsarType.double: + return IsarType.doubleList; + case IsarType.dateTime: + return IsarType.dateTimeList; + case IsarType.string: + return IsarType.stringList; + case IsarType.object: + return IsarType.objectList; + // ignore: no_default_cases + default: + return this; + } + } +} diff --git a/packages_external/isar-3.1.0-1/packages/isar/lib/src/schema/schema.dart b/packages_external/isar-3.1.0-1/packages/isar/lib/src/schema/schema.dart new file mode 100644 index 00000000..8cdf73a8 --- /dev/null +++ b/packages_external/isar-3.1.0-1/packages/isar/lib/src/schema/schema.dart @@ -0,0 +1,126 @@ +part of isar; + +/// This schema either represents a collection or embedded object. +class Schema { + /// @nodoc + @protected + const Schema({ + required this.id, + required this.name, + required this.properties, + required this.estimateSize, + required this.serialize, + required this.deserialize, + required this.deserializeProp, + }); + + /// @nodoc + @protected + factory Schema.fromJson(Map json) { + return Schema( + id: -1, + name: json['name'] as String, + properties: { + for (final property in json['properties'] as List) + (property as Map)['name'] as String: + PropertySchema.fromJson(property), + }, + estimateSize: (_, __, ___) => throw UnimplementedError(), + serialize: (_, __, ___, ____) => throw UnimplementedError(), + deserialize: (_, __, ___, ____) => throw UnimplementedError(), + deserializeProp: (_, __, ___, ____) => throw UnimplementedError(), + ); + } + + /// Internal id of this collection or embedded object. + final int id; + + /// Name of the collection or embedded object + final String name; + + /// Whether this is an embedded object + bool get embedded => true; + + /// A map of name -> property pairs + final Map properties; + + /// @nodoc + @protected + final EstimateSize estimateSize; + + /// @nodoc + @protected + final Serialize serialize; + + /// @nodoc + @protected + final Deserialize deserialize; + + /// @nodoc + @protected + final DeserializeProp deserializeProp; + + /// Returns a property by its name or throws an error. + @pragma('vm:prefer-inline') + PropertySchema property(String propertyName) { + final property = properties[propertyName]; + if (property != null) { + return property; + } else { + throw IsarError('Unknown property "$propertyName"'); + } + } + + /// @nodoc + @protected + Map toJson() { + final json = { + 'name': name, + 'embedded': embedded, + 'properties': [ + for (final property in properties.values) property.toJson(), + ], + }; + + return json; + } + + /// @nodoc + @protected + Type get type => OBJ; +} + +/// @nodoc +@protected +typedef EstimateSize = int Function( + T object, + List offsets, + Map> allOffsets, +); + +/// @nodoc +@protected +typedef Serialize = void Function( + T object, + IsarWriter writer, + List offsets, + Map> allOffsets, +); + +/// @nodoc +@protected +typedef Deserialize = T Function( + Id id, + IsarReader reader, + List offsets, + Map> allOffsets, +); + +/// @nodoc +@protected +typedef DeserializeProp = dynamic Function( + IsarReader reader, + int propertyId, + int offset, + Map> allOffsets, +); diff --git a/packages_external/isar-3.1.0-1/packages/isar/lib/src/web/bindings.dart b/packages_external/isar-3.1.0-1/packages/isar/lib/src/web/bindings.dart new file mode 100644 index 00000000..d4a1b76b --- /dev/null +++ b/packages_external/isar-3.1.0-1/packages/isar/lib/src/web/bindings.dart @@ -0,0 +1,188 @@ +// ignore_for_file: public_member_api_docs + +import 'dart:indexed_db'; +import 'dart:js'; + +import 'package:isar/isar.dart'; +import 'package:js/js.dart'; +import 'package:js/js_util.dart'; + +@JS('JSON.stringify') +external String stringify(dynamic value); + +@JS('indexedDB.cmp') +external int idbCmp(dynamic value1, dynamic value2); + +@JS('Object.keys') +external List objectKeys(dynamic obj); + +Map jsMapToDart(Object obj) { + final keys = objectKeys(obj); + final map = {}; + for (final key in keys) { + map[key] = getProperty(obj, key); + } + return map; +} + +@JS('Promise') +class Promise {} + +extension PromiseX on Promise { + Future wait() => promiseToFuture(this); +} + +@JS('openIsar') +external Promise openIsarJs( + String name, + List schemas, + bool relaxedDurability, +); + +@JS('IsarTxn') +class IsarTxnJs { + external Promise commit(); + + external void abort(); + + external bool get write; +} + +@JS('IsarInstance') +class IsarInstanceJs { + external IsarTxnJs beginTxn(bool write); + + external IsarCollectionJs getCollection(String name); + + external Promise close(bool deleteFromDisk); +} + +typedef ChangeCallbackJs = void Function(); + +typedef ObjectChangeCallbackJs = void Function(Object? object); + +typedef QueryChangeCallbackJs = void Function(List results); + +typedef StopWatchingJs = JsFunction; + +@JS('IsarCollection') +class IsarCollectionJs { + external IsarLinkJs getLink(String name); + + external Promise getAll(IsarTxnJs txn, List ids); + + external Promise getAllByIndex( + IsarTxnJs txn, + String indexName, + List> values, + ); + + external Promise putAll(IsarTxnJs txn, List objects); + + external Promise deleteAll(IsarTxnJs txn, List ids); + + external Promise deleteAllByIndex( + IsarTxnJs txn, + String indexName, + List keys, + ); + + external Promise clear(IsarTxnJs txn); + + external StopWatchingJs watchLazy(ChangeCallbackJs callback); + + external StopWatchingJs watchObject(Id id, ObjectChangeCallbackJs callback); + + external StopWatchingJs watchQuery( + QueryJs query, + QueryChangeCallbackJs callback, + ); + + external StopWatchingJs watchQueryLazy( + QueryJs query, + ChangeCallbackJs callback, + ); +} + +@JS('IsarLink') +class IsarLinkJs { + external Promise update( + IsarTxnJs txn, + bool backlink, + Id id, + List addedTargets, + List deletedTargets, + ); + + external Promise clear(IsarTxnJs txn, Id id, bool backlink); +} + +@JS('IdWhereClause') +@anonymous +class IdWhereClauseJs { + external KeyRange? range; +} + +@JS('IndexWhereClause') +@anonymous +class IndexWhereClauseJs { + external String indexName; + external KeyRange? range; +} + +@JS('LinkWhereClause') +@anonymous +class LinkWhereClauseJs { + external String linkCollection; + external String linkName; + external bool backlink; + external Id id; +} + +@JS('Function') +class FilterJs { + external FilterJs(String id, String obj, String method); +} + +@JS('Function') +class SortCmpJs { + external SortCmpJs(String a, String b, String method); +} + +@JS('Function') +class DistinctValueJs { + external DistinctValueJs(String obj, String method); +} + +@JS('IsarQuery') +class QueryJs { + external QueryJs( + IsarCollectionJs collection, + List whereClauses, + bool whereDistinct, + bool whereAscending, + FilterJs? filter, + SortCmpJs? sortCmp, + DistinctValueJs? distinctValue, + int? offset, + int? limit, + ); + + external Promise findFirst(IsarTxnJs txn); + + external Promise findAll(IsarTxnJs txn); + + external Promise deleteFirst(IsarTxnJs txn); + + external Promise deleteAll(IsarTxnJs txn); + + external Promise min(IsarTxnJs txn, String propertyName); + + external Promise max(IsarTxnJs txn, String propertyName); + + external Promise sum(IsarTxnJs txn, String propertyName); + + external Promise average(IsarTxnJs txn, String propertyName); + + external Promise count(IsarTxnJs txn); +} diff --git a/packages_external/isar-3.1.0-1/packages/isar/lib/src/web/isar_collection_impl.dart b/packages_external/isar-3.1.0-1/packages/isar/lib/src/web/isar_collection_impl.dart new file mode 100644 index 00000000..d89ad693 --- /dev/null +++ b/packages_external/isar-3.1.0-1/packages/isar/lib/src/web/isar_collection_impl.dart @@ -0,0 +1,266 @@ +// ignore_for_file: public_member_api_docs, invalid_use_of_protected_member + +import 'dart:async'; +import 'dart:convert'; +import 'dart:js'; +import 'dart:js_util'; +import 'dart:typed_data'; + +import 'package:isar/isar.dart'; +import 'package:isar/src/web/bindings.dart'; +import 'package:isar/src/web/isar_impl.dart'; +import 'package:isar/src/web/isar_reader_impl.dart'; +import 'package:isar/src/web/isar_web.dart'; +import 'package:isar/src/web/isar_writer_impl.dart'; +import 'package:isar/src/web/query_build.dart'; +import 'package:meta/dart2js.dart'; + +class IsarCollectionImpl extends IsarCollection { + IsarCollectionImpl({ + required this.isar, + required this.native, + required this.schema, + }); + + @override + final IsarImpl isar; + final IsarCollectionJs native; + + @override + final CollectionSchema schema; + + @override + String get name => schema.name; + + late final _offsets = isar.offsets[OBJ]!; + + @tryInline + OBJ deserializeObject(Object object) { + final id = getProperty(object, idName); + final reader = IsarReaderImpl(object); + return schema.deserialize(id, reader, _offsets, isar.offsets); + } + + @tryInline + List deserializeObjects(dynamic objects) { + final list = objects as List; + final results = []; + for (final object in list) { + results.add(object is Object ? deserializeObject(object) : null); + } + return results; + } + + @override + Future> getAll(List ids) { + return isar.getTxn(false, (IsarTxnJs txn) async { + final objects = await native.getAll(txn, ids).wait>(); + return deserializeObjects(objects); + }); + } + + @override + Future> getAllByIndex(String indexName, List keys) { + return isar.getTxn(false, (IsarTxnJs txn) async { + final objects = await native + .getAllByIndex(txn, indexName, keys) + .wait>(); + return deserializeObjects(objects); + }); + } + + @override + List getAllSync(List ids) => unsupportedOnWeb(); + + @override + List getAllByIndexSync(String indexName, List keys) => + unsupportedOnWeb(); + + @override + Future> putAll(List objects) { + return putAllByIndex(null, objects); + } + + @override + List putAllSync(List objects, {bool saveLinks = true}) => + unsupportedOnWeb(); + + @override + Future> putAllByIndex(String? indexName, List objects) { + return isar.getTxn(true, (IsarTxnJs txn) async { + final serialized = []; + for (final object in objects) { + final jsObj = newObject(); + final writer = IsarWriterImpl(jsObj); + schema.serialize(object, writer, _offsets, isar.offsets); + setProperty(jsObj, idName, schema.getId(object)); + serialized.add(jsObj); + } + final ids = await native.putAll(txn, serialized).wait>(); + for (var i = 0; i < objects.length; i++) { + final object = objects[i]; + final id = ids[i] as Id; + schema.attach(this, id, object); + } + + return ids.cast().toList(); + }); + } + + @override + List putAllByIndexSync( + String indexName, + List objects, { + bool saveLinks = true, + }) => + unsupportedOnWeb(); + + @override + Future deleteAll(List ids) async { + await isar.getTxn(true, (IsarTxnJs txn) { + return native.deleteAll(txn, ids).wait(); + }); + return ids.length; + } + + @override + Future deleteAllByIndex(String indexName, List keys) { + return isar.getTxn(true, (IsarTxnJs txn) { + return native.deleteAllByIndex(txn, indexName, keys).wait(); + }); + } + + @override + int deleteAllSync(List ids) => unsupportedOnWeb(); + + @override + int deleteAllByIndexSync(String indexName, List keys) => + unsupportedOnWeb(); + + @override + Future clear() { + return isar.getTxn(true, (IsarTxnJs txn) { + return native.clear(txn).wait(); + }); + } + + @override + void clearSync() => unsupportedOnWeb(); + + @override + Future importJson(List> json) { + return isar.getTxn(true, (IsarTxnJs txn) async { + await native.putAll(txn, json.map(jsify).toList()).wait(); + }); + } + + @override + Future importJsonRaw(Uint8List jsonBytes) { + final json = jsonDecode(const Utf8Decoder().convert(jsonBytes)) as List; + return importJson(json.cast()); + } + + @override + void importJsonSync(List> json) => unsupportedOnWeb(); + + @override + void importJsonRawSync(Uint8List jsonBytes) => unsupportedOnWeb(); + + @override + Future count() => where().count(); + + @override + int countSync() => unsupportedOnWeb(); + + @override + Future getSize({ + bool includeIndexes = false, + bool includeLinks = false, + }) => + unsupportedOnWeb(); + + @override + int getSizeSync({ + bool includeIndexes = false, + bool includeLinks = false, + }) => + unsupportedOnWeb(); + + @override + Stream watchLazy({bool fireImmediately = false}) { + JsFunction? stop; + final controller = StreamController( + onCancel: () { + stop?.apply([]); + }, + ); + + final void Function() callback = allowInterop(() => controller.add(null)); + stop = native.watchLazy(callback); + + return controller.stream; + } + + @override + Stream watchObject( + Id id, { + bool fireImmediately = false, + bool deserialize = true, + }) { + JsFunction? stop; + final controller = StreamController( + onCancel: () { + stop?.apply([]); + }, + ); + + final Null Function(Object? obj) callback = allowInterop((Object? obj) { + final object = deserialize && obj != null ? deserializeObject(obj) : null; + controller.add(object); + }); + stop = native.watchObject(id, callback); + + return controller.stream; + } + + @override + Stream watchObjectLazy(Id id, {bool fireImmediately = false}) => + watchObject(id, deserialize: false); + + @override + Query buildQuery({ + List whereClauses = const [], + bool whereDistinct = false, + Sort whereSort = Sort.asc, + FilterOperation? filter, + List sortBy = const [], + List distinctBy = const [], + int? offset, + int? limit, + String? property, + }) { + return buildWebQuery( + this, + whereClauses, + whereDistinct, + whereSort, + filter, + sortBy, + distinctBy, + offset, + limit, + property, + ); + } + + @override + Future verify(List objects) => unsupportedOnWeb(); + + @override + Future verifyLink( + String linkName, + List sourceIds, + List targetIds, + ) => + unsupportedOnWeb(); +} diff --git a/packages_external/isar-3.1.0-1/packages/isar/lib/src/web/isar_impl.dart b/packages_external/isar-3.1.0-1/packages/isar/lib/src/web/isar_impl.dart new file mode 100644 index 00000000..5c0efb41 --- /dev/null +++ b/packages_external/isar-3.1.0-1/packages/isar/lib/src/web/isar_impl.dart @@ -0,0 +1,135 @@ +// ignore_for_file: public_member_api_docs + +import 'dart:async'; +import 'dart:html'; + +import 'package:isar/isar.dart'; + +import 'package:isar/src/web/bindings.dart'; +import 'package:isar/src/web/isar_web.dart'; + +const Symbol _zoneTxn = #zoneTxn; + +class IsarImpl extends Isar { + IsarImpl(super.name, this.instance); + + final IsarInstanceJs instance; + final offsets = >{}; + final List> _activeAsyncTxns = []; + + @override + final String? directory = null; + + void requireNotInTxn() { + if (Zone.current[_zoneTxn] != null) { + throw IsarError( + 'Cannot perform this operation from within an active transaction.', + ); + } + } + + Future _txn( + bool write, + bool silent, + Future Function() callback, + ) async { + requireOpen(); + requireNotInTxn(); + + final completer = Completer(); + _activeAsyncTxns.add(completer.future); + + final txn = instance.beginTxn(write); + + final zone = Zone.current.fork( + zoneValues: {_zoneTxn: txn}, + ); + + T result; + try { + result = await zone.run(callback); + await txn.commit().wait(); + } catch (e) { + txn.abort(); + if (e is DomException) { + if (e.name == DomException.CONSTRAINT) { + throw IsarUniqueViolationError(); + } else { + throw IsarError('${e.name}: ${e.message}'); + } + } else { + rethrow; + } + } finally { + completer.complete(); + _activeAsyncTxns.remove(completer.future); + } + + return result; + } + + @override + Future txn(Future Function() callback) { + return _txn(false, false, callback); + } + + @override + Future writeTxn(Future Function() callback, {bool silent = false}) { + return _txn(true, silent, callback); + } + + @override + T txnSync(T Function() callback) => unsupportedOnWeb(); + + @override + T writeTxnSync(T Function() callback, {bool silent = false}) => + unsupportedOnWeb(); + + Future getTxn(bool write, Future Function(IsarTxnJs txn) callback) { + final currentTxn = Zone.current[_zoneTxn] as IsarTxnJs?; + if (currentTxn != null) { + if (write && !currentTxn.write) { + throw IsarError( + 'Operation cannot be performed within a read transaction.', + ); + } + return callback(currentTxn); + } else if (!write) { + return _txn(false, false, () { + return callback(Zone.current[_zoneTxn] as IsarTxnJs); + }); + } else { + throw IsarError('Write operations require an explicit transaction.'); + } + } + + @override + Future getSize({ + bool includeIndexes = false, + bool includeLinks = false, + }) => + unsupportedOnWeb(); + + @override + int getSizeSync({ + bool includeIndexes = false, + bool includeLinks = false, + }) => + unsupportedOnWeb(); + + @override + Future copyToFile(String targetPath) => unsupportedOnWeb(); + + @override + Future close({bool deleteFromDisk = false}) async { + requireOpen(); + requireNotInTxn(); + await Future.wait(_activeAsyncTxns); + await super.close(); + await instance.close(deleteFromDisk).wait(); + return true; + } + + @override + Future verify() => unsupportedOnWeb(); +} diff --git a/packages_external/isar-3.1.0-1/packages/isar/lib/src/web/isar_link_impl.dart b/packages_external/isar-3.1.0-1/packages/isar/lib/src/web/isar_link_impl.dart new file mode 100644 index 00000000..6efa9c15 --- /dev/null +++ b/packages_external/isar-3.1.0-1/packages/isar/lib/src/web/isar_link_impl.dart @@ -0,0 +1,75 @@ +// ignore_for_file: public_member_api_docs + +import 'package:isar/isar.dart'; +import 'package:isar/src/common/isar_link_base_impl.dart'; +import 'package:isar/src/common/isar_link_common.dart'; +import 'package:isar/src/common/isar_links_common.dart'; +import 'package:isar/src/web/bindings.dart'; +import 'package:isar/src/web/isar_collection_impl.dart'; +import 'package:isar/src/web/isar_web.dart'; + +mixin IsarLinkBaseMixin on IsarLinkBaseImpl { + @override + IsarCollectionImpl get sourceCollection => + super.sourceCollection as IsarCollectionImpl; + + @override + IsarCollectionImpl get targetCollection => + super.targetCollection as IsarCollectionImpl; + + @override + late final Id Function(OBJ) getId = targetCollection.schema.getId; + + late final String? backlinkLinkName = + sourceCollection.schema.link(linkName).linkName; + + late final IsarLinkJs jsLink = backlinkLinkName != null + ? targetCollection.native.getLink(backlinkLinkName!) + : sourceCollection.native.getLink(linkName); + + @override + Future update({ + Iterable link = const [], + Iterable unlink = const [], + bool reset = false, + }) { + final linkList = link.toList(); + final unlinkList = unlink.toList(); + + final containingId = requireAttached(); + final backlink = backlinkLinkName != null; + + final linkIds = List.filled(linkList.length, 0); + for (var i = 0; i < linkList.length; i++) { + linkIds[i] = requireGetId(linkList[i]); + } + + final unlinkIds = List.filled(unlinkList.length, 0); + for (var i = 0; i < unlinkList.length; i++) { + unlinkIds[i] = requireGetId(unlinkList[i]); + } + + return targetCollection.isar.getTxn(true, (IsarTxnJs txn) async { + if (reset) { + await jsLink.clear(txn, containingId, backlink).wait(); + } + return jsLink + .update(txn, backlink, containingId, linkIds, unlinkIds) + .wait(); + }); + } + + @override + void updateSync({ + Iterable link = const [], + Iterable unlink = const [], + bool reset = false, + }) => + unsupportedOnWeb(); +} + +class IsarLinkImpl extends IsarLinkCommon + with IsarLinkBaseMixin {} + +class IsarLinksImpl extends IsarLinksCommon + with IsarLinkBaseMixin {} diff --git a/packages_external/isar-3.1.0-1/packages/isar/lib/src/web/isar_reader_impl.dart b/packages_external/isar-3.1.0-1/packages/isar/lib/src/web/isar_reader_impl.dart new file mode 100644 index 00000000..fac7e8b4 --- /dev/null +++ b/packages_external/isar-3.1.0-1/packages/isar/lib/src/web/isar_reader_impl.dart @@ -0,0 +1,347 @@ +// ignore_for_file: public_member_api_docs + +import 'package:isar/isar.dart'; +import 'package:js/js_util.dart'; +import 'package:meta/dart2js.dart'; + +const nullNumber = double.negativeInfinity; +const idName = '_id'; +final nullDate = DateTime.fromMillisecondsSinceEpoch(0); + +class IsarReaderImpl implements IsarReader { + IsarReaderImpl(this.object); + + final Object object; + + @tryInline + @override + bool readBool(int offset) { + final value = getProperty(object, offset); + return value == 1; + } + + @tryInline + @override + bool? readBoolOrNull(int offset) { + final value = getProperty(object, offset); + return value == 0 + ? false + : value == 1 + ? true + : null; + } + + @tryInline + @override + int readByte(int offset) { + final value = getProperty(object, offset); + return value is int ? value : nullNumber as int; + } + + @tryInline + @override + int? readByteOrNull(int offset) { + final value = getProperty(object, offset); + return value is int && value != nullNumber ? value : null; + } + + @tryInline + @override + int readInt(int offset) { + final value = getProperty(object, offset); + return value is int ? value : nullNumber as int; + } + + @tryInline + @override + int? readIntOrNull(int offset) { + final value = getProperty(object, offset); + return value is int && value != nullNumber ? value : null; + } + + @tryInline + @override + double readFloat(int offset) { + final value = getProperty(object, offset); + return value is double ? value : nullNumber; + } + + @tryInline + @override + double? readFloatOrNull(int offset) { + final value = getProperty(object, offset); + return value is double && value != nullNumber ? value : null; + } + + @tryInline + @override + int readLong(int offset) { + final value = getProperty(object, offset); + return value is int ? value : nullNumber as int; + } + + @tryInline + @override + int? readLongOrNull(int offset) { + final value = getProperty(object, offset); + return value is int && value != nullNumber ? value : null; + } + + @tryInline + @override + double readDouble(int offset) { + final value = getProperty(object, offset); + return value is double && value != nullNumber ? value : nullNumber; + } + + @tryInline + @override + double? readDoubleOrNull(int offset) { + final value = getProperty(object, offset); + return value is double && value != nullNumber ? value : null; + } + + @tryInline + @override + DateTime readDateTime(int offset) { + final value = getProperty(object, offset); + return value is int && value != nullNumber + ? DateTime.fromMillisecondsSinceEpoch(value, isUtc: true).toLocal() + : nullDate; + } + + @tryInline + @override + DateTime? readDateTimeOrNull(int offset) { + final value = getProperty(object, offset); + return value is int && value != nullNumber + ? DateTime.fromMillisecondsSinceEpoch(value, isUtc: true).toLocal() + : null; + } + + @tryInline + @override + String readString(int offset) { + final value = getProperty(object, offset); + return value is String ? value : ''; + } + + @tryInline + @override + String? readStringOrNull(int offset) { + final value = getProperty(object, offset); + return value is String ? value : null; + } + + @tryInline + @override + T? readObjectOrNull( + int offset, + Deserialize deserialize, + Map> allOffsets, + ) { + final value = getProperty(object, offset); + if (value is Object) { + final reader = IsarReaderImpl(value); + return deserialize(0, reader, allOffsets[T]!, allOffsets); + } else { + return null; + } + } + + @tryInline + @override + List? readBoolList(int offset) { + final value = getProperty(object, offset); + return value is List ? value.map((e) => e == 1).toList() : null; + } + + @tryInline + @override + List? readBoolOrNullList(int offset) { + final value = getProperty(object, offset); + return value is List + ? value + .map( + (e) => e == 0 + ? false + : e == 1 + ? true + : null, + ) + .toList() + : null; + } + + @tryInline + @override + List? readByteList(int offset) { + final value = getProperty(object, offset); + return value is List + ? value.map((e) => e is int ? e : nullNumber as int).toList() + : null; + } + + @tryInline + @override + List? readIntList(int offset) { + final value = getProperty(object, offset); + return value is List + ? value.map((e) => e is int ? e : nullNumber as int).toList() + : null; + } + + @tryInline + @override + List? readIntOrNullList(int offset) { + final value = getProperty(object, offset); + return value is List + ? value.map((e) => e is int && e != nullNumber ? e : null).toList() + : null; + } + + @tryInline + @override + List? readFloatList(int offset) { + final value = getProperty(object, offset); + return value is List + ? value.map((e) => e is double ? e : nullNumber).toList() + : null; + } + + @tryInline + @override + List? readFloatOrNullList(int offset) { + final value = getProperty(object, offset); + return value is List + ? value.map((e) => e is double && e != nullNumber ? e : null).toList() + : null; + } + + @tryInline + @override + List? readLongList(int offset) { + final value = getProperty(object, offset); + return value is List + ? value.map((e) => e is int ? e : nullNumber as int).toList() + : null; + } + + @tryInline + @override + List? readLongOrNullList(int offset) { + final value = getProperty(object, offset); + return value is List + ? value.map((e) => e is int && e != nullNumber ? e : null).toList() + : null; + } + + @tryInline + @override + List? readDoubleList(int offset) { + final value = getProperty(object, offset); + return value is List + ? value.map((e) => e is double ? e : nullNumber).toList() + : null; + } + + @tryInline + @override + List? readDoubleOrNullList(int offset) { + final value = getProperty(object, offset); + return value is List + ? value.map((e) => e is double && e != nullNumber ? e : null).toList() + : null; + } + + @tryInline + @override + List? readDateTimeList(int offset) { + final value = getProperty(object, offset); + return value is List + ? value + .map( + (e) => e is int && e != nullNumber + ? DateTime.fromMillisecondsSinceEpoch(e, isUtc: true) + .toLocal() + : nullDate, + ) + .toList() + : null; + } + + @tryInline + @override + List? readDateTimeOrNullList(int offset) { + final value = getProperty(object, offset); + return value is List + ? value + .map( + (e) => e is int && e != nullNumber + ? DateTime.fromMillisecondsSinceEpoch(e, isUtc: true) + .toLocal() + : null, + ) + .toList() + : null; + } + + @tryInline + @override + List? readStringList(int offset) { + final value = getProperty(object, offset); + return value is List + ? value.map((e) => e is String ? e : '').toList() + : null; + } + + @tryInline + @override + List? readStringOrNullList(int offset) { + final value = getProperty(object, offset); + return value is List + ? value.map((e) => e is String ? e : null).toList() + : null; + } + + @tryInline + @override + List? readObjectList( + int offset, + Deserialize deserialize, + Map> allOffsets, + T defaultValue, + ) { + final value = getProperty(object, offset); + return value is List + ? value.map((e) { + if (e is Object) { + final reader = IsarReaderImpl(e); + return deserialize(0, reader, allOffsets[T]!, allOffsets); + } else { + return defaultValue; + } + }).toList() + : null; + } + + @tryInline + @override + List? readObjectOrNullList( + int offset, + Deserialize deserialize, + Map> allOffsets, + ) { + final value = getProperty(object, offset); + return value is List + ? value.map((e) { + if (e is Object) { + final reader = IsarReaderImpl(e); + return deserialize(0, reader, allOffsets[T]!, allOffsets); + } else { + return null; + } + }).toList() + : null; + } +} diff --git a/packages_external/isar-3.1.0-1/packages/isar/lib/src/web/isar_web.dart b/packages_external/isar-3.1.0-1/packages/isar/lib/src/web/isar_web.dart new file mode 100644 index 00000000..0cff278b --- /dev/null +++ b/packages_external/isar-3.1.0-1/packages/isar/lib/src/web/isar_web.dart @@ -0,0 +1,48 @@ +// ignore_for_file: unused_field, public_member_api_docs + +import 'dart:async'; + +import 'package:isar/isar.dart'; +import 'package:meta/meta.dart'; + +/// @nodoc +@protected +const Id isarMinId = -9007199254740990; + +/// @nodoc +@protected +const Id isarMaxId = 9007199254740991; + +/// @nodoc +@protected +const Id isarAutoIncrementId = -9007199254740991; + +/// @nodoc +Never unsupportedOnWeb() { + throw UnsupportedError('This operation is not supported for Isar web'); +} + +class _WebAbi { + static const androidArm = null as dynamic; + static const androidArm64 = null as dynamic; + static const androidIA32 = null as dynamic; + static const androidX64 = null as dynamic; + static const iosArm64 = null as dynamic; + static const iosX64 = null as dynamic; + static const linuxArm64 = null as dynamic; + static const linuxX64 = null as dynamic; + static const macosArm64 = null as dynamic; + static const macosX64 = null as dynamic; + static const windowsArm64 = null as dynamic; + static const windowsX64 = null as dynamic; +} + +/// @nodoc +@protected +typedef IsarAbi = _WebAbi; + +FutureOr initializeCoreBinary({ + Map libraries = const {}, + bool download = false, +}) => + unsupportedOnWeb(); diff --git a/packages_external/isar-3.1.0-1/packages/isar/lib/src/web/isar_writer_impl.dart b/packages_external/isar-3.1.0-1/packages/isar/lib/src/web/isar_writer_impl.dart new file mode 100644 index 00000000..a4a65ca0 --- /dev/null +++ b/packages_external/isar-3.1.0-1/packages/isar/lib/src/web/isar_writer_impl.dart @@ -0,0 +1,171 @@ +// ignore_for_file: public_member_api_docs + +import 'package:isar/isar.dart'; +import 'package:isar/src/web/isar_reader_impl.dart'; +import 'package:js/js_util.dart'; +import 'package:meta/dart2js.dart'; + +class IsarWriterImpl implements IsarWriter { + IsarWriterImpl(this.object); + + final Object object; + + @tryInline + @override + void writeBool(int offset, bool? value) { + final number = value == true + ? 1 + : value == false + ? 0 + : nullNumber; + setProperty(object, offset, number); + } + + @tryInline + @override + void writeByte(int offset, int value) { + setProperty(object, offset, value); + } + + @tryInline + @override + void writeInt(int offset, int? value) { + setProperty(object, offset, value ?? nullNumber); + } + + @tryInline + @override + void writeFloat(int offset, double? value) { + setProperty(object, offset, value ?? nullNumber); + } + + @tryInline + @override + void writeLong(int offset, int? value) { + setProperty(object, offset, value ?? nullNumber); + } + + @tryInline + @override + void writeDouble(int offset, double? value) { + setProperty(object, offset, value ?? nullNumber); + } + + @tryInline + @override + void writeDateTime(int offset, DateTime? value) { + setProperty( + object, + offset, + value?.toUtc().millisecondsSinceEpoch ?? nullNumber, + ); + } + + @tryInline + @override + void writeString(int offset, String? value) { + setProperty(object, offset, value ?? nullNumber); + } + + @tryInline + @override + void writeObject( + int offset, + Map> allOffsets, + Serialize serialize, + T? value, + ) { + if (value != null) { + final object = newObject(); + final writer = IsarWriterImpl(object); + serialize(value, writer, allOffsets[T]!, allOffsets); + setProperty(this.object, offset, object); + } + } + + @tryInline + @override + void writeByteList(int offset, List? values) { + setProperty(object, offset, values ?? nullNumber); + } + + @tryInline + @override + void writeBoolList(int offset, List? values) { + final list = values + ?.map( + (e) => e == false + ? 0 + : e == true + ? 1 + : nullNumber, + ) + .toList(); + setProperty(object, offset, list ?? nullNumber); + } + + @tryInline + @override + void writeIntList(int offset, List? values) { + final list = values?.map((e) => e ?? nullNumber).toList(); + setProperty(object, offset, list ?? nullNumber); + } + + @tryInline + @override + void writeFloatList(int offset, List? values) { + final list = values?.map((e) => e ?? nullNumber).toList(); + setProperty(object, offset, list ?? nullNumber); + } + + @tryInline + @override + void writeLongList(int offset, List? values) { + final list = values?.map((e) => e ?? nullNumber).toList(); + setProperty(object, offset, list ?? nullNumber); + } + + @tryInline + @override + void writeDoubleList(int offset, List? values) { + final list = values?.map((e) => e ?? nullNumber).toList(); + setProperty(object, offset, list ?? nullNumber); + } + + @tryInline + @override + void writeDateTimeList(int offset, List? values) { + final list = values + ?.map((e) => e?.toUtc().millisecondsSinceEpoch ?? nullNumber) + .toList(); + setProperty(object, offset, list ?? nullNumber); + } + + @tryInline + @override + void writeStringList(int offset, List? values) { + final list = values?.map((e) => e ?? nullNumber).toList(); + setProperty(object, offset, list ?? nullNumber); + } + + @tryInline + @override + void writeObjectList( + int offset, + Map> allOffsets, + Serialize serialize, + List? values, + ) { + if (values != null) { + final list = values.map((e) { + if (e != null) { + final object = newObject(); + final writer = IsarWriterImpl(object); + serialize(e, writer, allOffsets[T]!, allOffsets); + return object; + } + }).toList(); + setProperty(object, offset, list); + } + } +} diff --git a/packages_external/isar-3.1.0-1/packages/isar/lib/src/web/open.dart b/packages_external/isar-3.1.0-1/packages/isar/lib/src/web/open.dart new file mode 100644 index 00000000..5e507919 --- /dev/null +++ b/packages_external/isar-3.1.0-1/packages/isar/lib/src/web/open.dart @@ -0,0 +1,82 @@ +// ignore_for_file: public_member_api_docs, invalid_use_of_protected_member + +import 'dart:html'; +//import 'dart:js_util'; + +import 'package:isar/isar.dart'; +/*import 'package:isar/src/common/schemas.dart'; + +import 'package:isar/src/web/bindings.dart'; +import 'package:isar/src/web/isar_collection_impl.dart'; +import 'package:isar/src/web/isar_impl.dart';*/ +import 'package:isar/src/web/isar_web.dart'; +import 'package:meta/meta.dart'; + +bool _loaded = false; +Future initializeIsarWeb([String? jsUrl]) async { + if (_loaded) { + return; + } + _loaded = true; + + final script = ScriptElement(); + script.type = 'text/javascript'; + // ignore: unsafe_html + script.src = 'https://unpkg.com/isar@${Isar.version}/dist/index.js'; + script.async = true; + document.head!.append(script); + await script.onLoad.first.timeout( + const Duration(seconds: 30), + onTimeout: () { + throw IsarError('Failed to load Isar'); + }, + ); +} + +@visibleForTesting +void doNotInitializeIsarWeb() { + _loaded = true; +} + +Future openIsar({ + required List> schemas, + String? directory, + required String name, + required int maxSizeMiB, + required bool relaxedDurability, + CompactCondition? compactOnLaunch, +}) async { + throw IsarError('Please use Isar 2.5.0 if you need web support. ' + 'A 3.x version with web support will be released soon.'); + /*await initializeIsarWeb(); + final schemasJson = getSchemas(schemas).map((e) => e.toJson()); + final schemasJs = jsify(schemasJson.toList()) as List; + final instance = await openIsarJs(name, schemasJs, relaxedDurability) + .wait(); + final isar = IsarImpl(name, instance); + final cols = >{}; + for (final schema in schemas) { + final col = instance.getCollection(schema.name); + schema.toCollection(() { + schema as CollectionSchema; + cols[OBJ] = IsarCollectionImpl( + isar: isar, + native: col, + schema: schema, + ); + }); + } + + isar.attachCollections(cols); + return isar;*/ +} + +Isar openIsarSync({ + required List> schemas, + String? directory, + required String name, + required int maxSizeMiB, + required bool relaxedDurability, + CompactCondition? compactOnLaunch, +}) => + unsupportedOnWeb(); diff --git a/packages_external/isar-3.1.0-1/packages/isar/lib/src/web/query_build.dart b/packages_external/isar-3.1.0-1/packages/isar/lib/src/web/query_build.dart new file mode 100644 index 00000000..12ac2373 --- /dev/null +++ b/packages_external/isar-3.1.0-1/packages/isar/lib/src/web/query_build.dart @@ -0,0 +1,375 @@ +// ignore_for_file: public_member_api_docs, invalid_use_of_protected_member + +import 'dart:indexed_db'; + +import 'package:isar/isar.dart'; + +import 'package:isar/src/web/bindings.dart'; +import 'package:isar/src/web/isar_collection_impl.dart'; +import 'package:isar/src/web/isar_web.dart'; +import 'package:isar/src/web/query_impl.dart'; + +Query buildWebQuery( + IsarCollectionImpl col, + List whereClauses, + bool whereDistinct, + Sort whereSort, + FilterOperation? filter, + List sortBy, + List distinctBy, + int? offset, + int? limit, + String? property, +) { + final whereClausesJs = whereClauses.map((wc) { + if (wc is IdWhereClause) { + return _buildIdWhereClause(wc); + } else if (wc is IndexWhereClause) { + return _buildIndexWhereClause(col.schema, wc); + } else { + return _buildLinkWhereClause(col, wc as LinkWhereClause); + } + }).toList(); + + final filterJs = filter != null ? _buildFilter(col.schema, filter) : null; + final sortJs = sortBy.isNotEmpty ? _buildSort(sortBy) : null; + final distinctJs = distinctBy.isNotEmpty ? _buildDistinct(distinctBy) : null; + + final queryJs = QueryJs( + col.native, + whereClausesJs, + whereDistinct, + whereSort == Sort.asc, + filterJs, + sortJs, + distinctJs, + offset, + limit, + ); + + QueryDeserialize deserialize; + //if (property == null) { + deserialize = col.deserializeObject as T Function(Object); + /*} else { + deserialize = (jsObj) => col.schema.deserializeProp(jsObj, property) as T; + }*/ + + return QueryImpl(col, queryJs, deserialize, property); +} + +dynamic _valueToJs(dynamic value) { + if (value == null) { + return double.negativeInfinity; + } else if (value == true) { + return 1; + } else if (value == false) { + return 0; + } else if (value is DateTime) { + return value.toUtc().millisecondsSinceEpoch; + } else if (value is List) { + return value.map(_valueToJs).toList(); + } else { + return value; + } +} + +IdWhereClauseJs _buildIdWhereClause(IdWhereClause wc) { + return IdWhereClauseJs() + ..range = _buildKeyRange( + wc.lower, + wc.upper, + wc.includeLower, + wc.includeUpper, + ); +} + +IndexWhereClauseJs _buildIndexWhereClause( + CollectionSchema schema, + IndexWhereClause wc, +) { + final index = schema.index(wc.indexName); + + final lower = wc.lower?.toList(); + final upper = wc.upper?.toList(); + if (upper != null) { + while (index.properties.length > upper.length) { + upper.add([]); + } + } + + dynamic lowerUnwrapped = wc.lower; + if (index.properties.length == 1 && lower != null) { + lowerUnwrapped = lower.isNotEmpty ? lower[0] : null; + } + + dynamic upperUnwrapped = upper; + if (index.properties.length == 1 && upper != null) { + upperUnwrapped = upper.isNotEmpty ? upper[0] : double.infinity; + } + + return IndexWhereClauseJs() + ..indexName = wc.indexName + ..range = _buildKeyRange( + wc.lower != null ? _valueToJs(lowerUnwrapped) : null, + wc.upper != null ? _valueToJs(upperUnwrapped) : null, + wc.includeLower, + wc.includeUpper, + ); +} + +LinkWhereClauseJs _buildLinkWhereClause( + IsarCollectionImpl col, + LinkWhereClause wc, +) { + // ignore: unused_local_variable + final linkCol = col.isar.getCollectionByNameInternal(wc.linkCollection)! + as IsarCollectionImpl; + //final backlinkLinkName = linkCol.schema.backlinkLinkNames[wc.linkName]; + return LinkWhereClauseJs() + ..linkCollection = wc.linkCollection + //..linkName = backlinkLinkName ?? wc.linkName + //..backlink = backlinkLinkName != null + ..id = wc.id; +} + +KeyRange? _buildKeyRange( + dynamic lower, + dynamic upper, + bool includeLower, + bool includeUpper, +) { + if (lower != null) { + if (upper != null) { + final boundsEqual = idbCmp(lower, upper) == 0; + if (boundsEqual) { + if (includeLower && includeUpper) { + return KeyRange.only(lower); + } else { + // empty range + return KeyRange.upperBound(double.negativeInfinity, true); + } + } + + return KeyRange.bound( + lower, + upper, + !includeLower, + !includeUpper, + ); + } else { + return KeyRange.lowerBound(lower, !includeLower); + } + } else if (upper != null) { + return KeyRange.upperBound(upper, !includeUpper); + } + return null; +} + +FilterJs? _buildFilter( + CollectionSchema schema, + FilterOperation filter, +) { + final filterStr = _buildFilterOperation(schema, filter); + if (filterStr != null) { + return FilterJs('id', 'obj', 'return $filterStr'); + } else { + return null; + } +} + +String? _buildFilterOperation( + CollectionSchema schema, + FilterOperation filter, +) { + if (filter is FilterGroup) { + return _buildFilterGroup(schema, filter); + } else if (filter is LinkFilter) { + unsupportedOnWeb(); + } else if (filter is FilterCondition) { + return _buildCondition(schema, filter); + } else { + return null; + } +} + +String? _buildFilterGroup(CollectionSchema schema, FilterGroup group) { + final builtConditions = group.filters + .map((op) => _buildFilterOperation(schema, op)) + .where((e) => e != null) + .toList(); + + if (builtConditions.isEmpty) { + return null; + } + + if (group.type == FilterGroupType.not) { + return '!(${builtConditions[0]})'; + } else if (builtConditions.length == 1) { + return builtConditions[0]; + } else if (group.type == FilterGroupType.xor) { + final conditions = builtConditions.join(','); + return 'IsarQuery.xor($conditions)'; + } else { + final op = group.type == FilterGroupType.or ? '||' : '&&'; + final condition = builtConditions.join(op); + return '($condition)'; + } +} + +String _buildCondition( + CollectionSchema schema, + FilterCondition condition, +) { + dynamic prepareFilterValue(dynamic value) { + if (value == null) { + return null; + } else if (value is String) { + return stringify(value); + } else { + return _valueToJs(value); + } + } + + final isListOp = condition.type != FilterConditionType.isNull && + condition.type != FilterConditionType.listLength && + schema.property(condition.property).type.isList; + final accessor = + condition.property == schema.idName ? 'id' : 'obj.${condition.property}'; + final variable = isListOp ? 'e' : accessor; + + final cond = _buildConditionInternal( + conditionType: condition.type, + variable: variable, + val1: prepareFilterValue(condition.value1), + include1: condition.include1, + val2: prepareFilterValue(condition.value2), + include2: condition.include2, + caseSensitive: condition.caseSensitive, + ); + + if (isListOp) { + return '(Array.isArray($accessor) && $accessor.some(e => $cond))'; + } else { + return cond; + } +} + +String _buildConditionInternal({ + required FilterConditionType conditionType, + required String variable, + required Object? val1, + required bool include1, + required Object? val2, + required bool include2, + required bool caseSensitive, +}) { + final isNull = '($variable == null || $variable === -Infinity)'; + switch (conditionType) { + case FilterConditionType.equalTo: + if (val1 == null) { + return isNull; + } else if (val1 is String && !caseSensitive) { + return '$variable?.toLowerCase() === ${val1.toLowerCase()}'; + } else { + return '$variable === $val1'; + } + case FilterConditionType.between: + final val = val1 ?? val2; + final lowerOp = include1 ? '>=' : '>'; + final upperOp = include2 ? '<=' : '<'; + if (val == null) { + return isNull; + } else if ((val1 is String?) && (val2 is String?) && !caseSensitive) { + final lower = val1?.toLowerCase() ?? '-Infinity'; + final upper = val2?.toLowerCase() ?? '-Infinity'; + final variableLc = '$variable?.toLowerCase() ?? -Infinity'; + final lowerCond = 'indexedDB.cmp($variableLc, $lower) $lowerOp 0'; + final upperCond = 'indexedDB.cmp($variableLc, $upper) $upperOp 0'; + return '($lowerCond && $upperCond)'; + } else { + final lowerCond = + 'indexedDB.cmp($variable, ${val1 ?? '-Infinity'}) $lowerOp 0'; + final upperCond = + 'indexedDB.cmp($variable, ${val2 ?? '-Infinity'}) $upperOp 0'; + return '($lowerCond && $upperCond)'; + } + case FilterConditionType.lessThan: + if (val1 == null) { + if (include1) { + return isNull; + } else { + return 'false'; + } + } else { + final op = include1 ? '<=' : '<'; + if (val1 is String && !caseSensitive) { + return 'indexedDB.cmp($variable?.toLowerCase() ?? ' + '-Infinity, ${val1.toLowerCase()}) $op 0'; + } else { + return 'indexedDB.cmp($variable, $val1) $op 0'; + } + } + case FilterConditionType.greaterThan: + if (val1 == null) { + if (include1) { + return 'true'; + } else { + return '!$isNull'; + } + } else { + final op = include1 ? '>=' : '>'; + if (val1 is String && !caseSensitive) { + return 'indexedDB.cmp($variable?.toLowerCase() ?? ' + '-Infinity, ${val1.toLowerCase()}) $op 0'; + } else { + return 'indexedDB.cmp($variable, $val1) $op 0'; + } + } + case FilterConditionType.startsWith: + case FilterConditionType.endsWith: + case FilterConditionType.contains: + final op = conditionType == FilterConditionType.startsWith + ? 'startsWith' + : conditionType == FilterConditionType.endsWith + ? 'endsWith' + : 'includes'; + if (val1 is String) { + final isString = 'typeof $variable == "string"'; + if (!caseSensitive) { + return '($isString && $variable.toLowerCase() ' + '.$op(${val1.toLowerCase()}))'; + } else { + return '($isString && $variable.$op($val1))'; + } + } else { + throw IsarError('Unsupported type for condition'); + } + case FilterConditionType.matches: + throw UnimplementedError(); + case FilterConditionType.isNull: + return isNull; + // ignore: no_default_cases + default: + throw UnimplementedError(); + } +} + +SortCmpJs _buildSort(List properties) { + final sort = properties.map((e) { + final op = e.sort == Sort.asc ? '' : '-'; + return '${op}indexedDB.cmp(a.${e.property} ?? "-Infinity", b.${e.property} ' + '?? "-Infinity")'; + }).join('||'); + return SortCmpJs('a', 'b', 'return $sort'); +} + +DistinctValueJs _buildDistinct(List properties) { + final distinct = properties.map((e) { + if (e.caseSensitive == false) { + return 'obj.${e.property}?.toLowerCase() ?? "-Infinity"'; + } else { + return 'obj.${e.property}?.toString() ?? "-Infinity"'; + } + }).join('+'); + return DistinctValueJs('obj', 'return $distinct'); +} diff --git a/packages_external/isar-3.1.0-1/packages/isar/lib/src/web/query_impl.dart b/packages_external/isar-3.1.0-1/packages/isar/lib/src/web/query_impl.dart new file mode 100644 index 00000000..e2bfc153 --- /dev/null +++ b/packages_external/isar-3.1.0-1/packages/isar/lib/src/web/query_impl.dart @@ -0,0 +1,180 @@ +// ignore_for_file: public_member_api_docs + +import 'dart:async'; +import 'dart:convert'; +import 'dart:js'; +import 'dart:typed_data'; + +import 'package:isar/isar.dart'; +import 'package:isar/src/web/bindings.dart'; + +import 'package:isar/src/web/isar_collection_impl.dart'; +import 'package:isar/src/web/isar_web.dart'; + +typedef QueryDeserialize = T Function(Object); + +class QueryImpl extends Query { + QueryImpl(this.col, this.queryJs, this.deserialize, this.propertyName); + final IsarCollectionImpl col; + final QueryJs queryJs; + final QueryDeserialize deserialize; + final String? propertyName; + + @override + Isar get isar => col.isar; + + @override + Future findFirst() { + return col.isar.getTxn(false, (IsarTxnJs txn) async { + final result = await queryJs.findFirst(txn).wait(); + if (result == null) { + return null; + } + return deserialize(result); + }); + } + + @override + T? findFirstSync() => unsupportedOnWeb(); + + @override + Future> findAll() { + return col.isar.getTxn(false, (IsarTxnJs txn) async { + final result = await queryJs.findAll(txn).wait>(); + return result.map((e) => deserialize(e as Object)).toList(); + }); + } + + @override + List findAllSync() => unsupportedOnWeb(); + + @override + Future aggregate(AggregationOp op) { + return col.isar.getTxn(false, (IsarTxnJs txn) async { + final property = propertyName ?? col.schema.idName; + + num? result; + switch (op) { + case AggregationOp.min: + result = await queryJs.min(txn, property).wait(); + break; + case AggregationOp.max: + result = await queryJs.max(txn, property).wait(); + break; + case AggregationOp.sum: + result = await queryJs.sum(txn, property).wait(); + break; + case AggregationOp.average: + result = await queryJs.average(txn, property).wait(); + break; + case AggregationOp.count: + result = await queryJs.count(txn).wait(); + break; + // ignore: no_default_cases + default: + throw UnimplementedError(); + } + + if (result == null) { + return null; + } + + if (R == DateTime) { + return DateTime.fromMillisecondsSinceEpoch(result.toInt()).toLocal() + as R; + } else if (R == int) { + return result.toInt() as R; + } else if (R == double) { + return result.toDouble() as R; + } else { + return null; + } + }); + } + + @override + R? aggregateSync(AggregationOp op) => unsupportedOnWeb(); + + @override + Future deleteFirst() { + return col.isar.getTxn(true, (IsarTxnJs txn) { + return queryJs.deleteFirst(txn).wait(); + }); + } + + @override + bool deleteFirstSync() => unsupportedOnWeb(); + + @override + Future deleteAll() { + return col.isar.getTxn(true, (IsarTxnJs txn) { + return queryJs.deleteAll(txn).wait(); + }); + } + + @override + int deleteAllSync() => unsupportedOnWeb(); + + @override + Stream> watch({bool fireImmediately = false}) { + JsFunction? stop; + final controller = StreamController>( + onCancel: () { + stop?.apply([]); + }, + ); + + if (fireImmediately) { + findAll().then(controller.add); + } + + final Null Function(List results) callback = + allowInterop((List results) { + controller.add(results.map((e) => deserialize(e as Object)).toList()); + }); + stop = col.native.watchQuery(queryJs, callback); + + return controller.stream; + } + + @override + Stream watchLazy({bool fireImmediately = false}) { + JsFunction? stop; + final controller = StreamController( + onCancel: () { + stop?.apply([]); + }, + ); + + final Null Function() callback = allowInterop(() { + controller.add(null); + }); + stop = col.native.watchQueryLazy(queryJs, callback); + + return controller.stream; + } + + @override + Future exportJsonRaw(R Function(Uint8List) callback) async { + return col.isar.getTxn(false, (IsarTxnJs txn) async { + final result = await queryJs.findAll(txn).wait(); + final jsonStr = stringify(result); + return callback(const Utf8Encoder().convert(jsonStr)); + }); + } + + @override + Future>> exportJson() { + return col.isar.getTxn(false, (IsarTxnJs txn) async { + final result = await queryJs.findAll(txn).wait>(); + return result.map((e) => jsMapToDart(e as Object)).toList(); + }); + } + + @override + R exportJsonRawSync(R Function(Uint8List) callback) => unsupportedOnWeb(); + + @override + List> exportJsonSync({bool primitiveNull = true}) => + unsupportedOnWeb(); +} diff --git a/packages_external/isar-3.1.0-1/packages/isar/lib/src/web/split_words.dart b/packages_external/isar-3.1.0-1/packages/isar/lib/src/web/split_words.dart new file mode 100644 index 00000000..fa29ddd7 --- /dev/null +++ b/packages_external/isar-3.1.0-1/packages/isar/lib/src/web/split_words.dart @@ -0,0 +1,5 @@ +// ignore_for_file: public_member_api_docs + +import 'package:isar/src/web/isar_web.dart'; + +List isarSplitWords(String input) => unsupportedOnWeb(); diff --git a/packages_external/isar-3.1.0-1/packages/isar/pubspec.yaml b/packages_external/isar-3.1.0-1/packages/isar/pubspec.yaml new file mode 100644 index 00000000..3935bdc2 --- /dev/null +++ b/packages_external/isar-3.1.0-1/packages/isar/pubspec.yaml @@ -0,0 +1,23 @@ +name: isar +description: Extremely fast, easy to use, and fully async NoSQL database for Flutter. +version: 3.1.0+1 +repository: https://github.com/isar/isar/tree/main/packages/isar +homepage: https://github.com/isar/isar +issue_tracker: https://github.com/isar/isar/issues +documentation: https://isar.dev +funding: + - https://github.com/sponsors/leisim/ + +environment: + sdk: ">=2.17.0 <3.0.0" + +dependencies: + ffi: ">=2.0.0 <3.0.0" + js: ^0.7.1 + meta: ^1.7.0 + +dev_dependencies: + build_runner: ^2.4.13 + ffigen: ^14.0.1 + test: ^1.21.1 + very_good_analysis: ^6.0.0 diff --git a/packages_external/isar-3.1.0-1/packages/isar/test/isar_reader_writer_test.dart b/packages_external/isar-3.1.0-1/packages/isar/test/isar_reader_writer_test.dart new file mode 100644 index 00000000..2cebf602 --- /dev/null +++ b/packages_external/isar-3.1.0-1/packages/isar/test/isar_reader_writer_test.dart @@ -0,0 +1,287 @@ +@TestOn('vm') + +// ignore_for_file: constant_identifier_names + +import 'dart:convert'; +import 'dart:io'; +import 'dart:typed_data'; + +import 'package:isar/isar.dart'; +import 'package:isar/src/native/isar_core.dart'; +import 'package:isar/src/native/isar_reader_impl.dart'; +import 'package:isar/src/native/isar_writer_impl.dart'; +import 'package:test/test.dart'; + +void main() { + group('Golden Binary', () { + late final json = + File('../isar_core/tests/binary_golden.json').readAsStringSync(); + late final tests = (jsonDecode(json) as List) + .map((e) => BinaryTest.fromJson(e as Map)) + .toList(); + + test('IsarReader', () { + var t = 0; + for (final test in tests) { + final reader = IsarReaderImpl(Uint8List.fromList(test.bytes)); + var offset = 2; + for (var i = 0; i < test.types.length; i++) { + final type = test.types[i]; + final nullableValue = type.read(reader, offset, true); + expect(nullableValue, test.values[i], reason: '${test.types} $t'); + + final nonNullableValue = type.read(reader, offset, false); + _expectIgnoreNull(nonNullableValue, test.values[i], type); + offset += type.size; + } + t++; + } + }); + + test('IsarWriter', () { + for (final test in tests) { + final buffer = Uint8List(10000); + final size = + test.types.fold(0, (sum, type) => sum + type.size) + 2; + + final bufferView = buffer.buffer.asUint8List(0, test.bytes.length); + final writer = IsarWriterImpl(bufferView, size); + var offset = 2; + for (var i = 0; i < test.types.length; i++) { + final type = test.types[i]; + final value = test.values[i]; + type.write(writer, offset, value); + offset += type.size; + } + + expect(buffer.sublist(0, test.bytes.length), test.bytes); + } + }); + }); +} + +enum Type { + Bool(1, false, _readBool, _writeBool), + Byte(1, 0, _readByte, _writeByte), + Int(4, nullInt, _readInt, _writeInt), + Float(4, nullFloat, _readFloat, _writeFloat), + Long(8, nullLong, _readLong, _writeLong), + Double(8, nullDouble, _readDouble, _writeDouble), + String(3, '', _readString, _writeString), + BoolList(3, false, _readBoolList, _writeBoolList), + ByteList(3, 0, _readByteList, _writeByteList), + IntList(3, nullInt, _readIntList, _writeIntList), + FloatList(3, nullFloat, _readFloatList, _writeFloatList), + LongList(3, nullLong, _readLongList, _writeLongList), + DoubleList(3, nullDouble, _readDoubleList, _writeDoubleList), + StringList(3, '', _readStringList, _writeStringList); + + const Type(this.size, this.nullValue, this.read, this.write); + + final int size; + final dynamic nullValue; + final dynamic Function(IsarReader reader, int offset, bool nullable) read; + final void Function(IsarWriter reader, int offset, dynamic value) write; +} + +class BinaryTest { + const BinaryTest(this.types, this.values, this.bytes); + + factory BinaryTest.fromJson(Map json) { + return BinaryTest( + (json['types'] as List) + .map((type) => Type.values.firstWhere((t) => t.name == type)) + .toList(), + json['values'] as List, + (json['bytes'] as List).cast(), + ); + } + + final List types; + final List values; + final List bytes; +} + +void _expectIgnoreNull( + dynamic left, + dynamic right, + Type type, { + bool inList = false, +}) { + if (right == null && (type.index < Type.BoolList.index || inList)) { + if (left is double) { + expect(left, isNaN); + } else { + expect(left, type.nullValue); + } + } else if (right is List) { + left as List; + for (var i = 0; i < right.length; i++) { + _expectIgnoreNull(left[i], right[i], type, inList: true); + } + } else { + expect(left, right); + } +} + +bool? _readBool(IsarReader reader, int offset, bool nullable) { + if (nullable) { + return reader.readBoolOrNull(offset); + } else { + return reader.readBool(offset); + } +} + +void _writeBool(IsarWriter writer, int offset, dynamic value) { + writer.writeBool(offset, value as bool?); +} + +int? _readByte(IsarReader reader, int offset, bool nullable) { + return reader.readByte(offset); +} + +void _writeByte(IsarWriter writer, int offset, dynamic value) { + writer.writeByte(offset, value as int); +} + +int? _readInt(IsarReader reader, int offset, bool nullable) { + if (nullable) { + return reader.readIntOrNull(offset); + } else { + return reader.readInt(offset); + } +} + +void _writeInt(IsarWriter writer, int offset, dynamic value) { + writer.writeInt(offset, value as int?); +} + +double? _readFloat(IsarReader reader, int offset, bool nullable) { + if (nullable) { + return reader.readFloatOrNull(offset); + } else { + return reader.readFloat(offset); + } +} + +void _writeFloat(IsarWriter writer, int offset, dynamic value) { + writer.writeFloat(offset, value as double?); +} + +int? _readLong(IsarReader reader, int offset, bool nullable) { + if (nullable) { + return reader.readLongOrNull(offset); + } else { + return reader.readLong(offset); + } +} + +void _writeLong(IsarWriter writer, int offset, dynamic value) { + writer.writeLong(offset, value as int?); +} + +double? _readDouble(IsarReader reader, int offset, bool nullable) { + if (nullable) { + return reader.readDoubleOrNull(offset); + } else { + return reader.readDouble(offset); + } +} + +void _writeDouble(IsarWriter writer, int offset, dynamic value) { + writer.writeDouble(offset, value as double?); +} + +String? _readString(IsarReader reader, int offset, bool nullable) { + if (nullable) { + return reader.readStringOrNull(offset); + } else { + return reader.readString(offset); + } +} + +void _writeString(IsarWriter writer, int offset, dynamic value) { + final bytes = value is String ? utf8.encode(value) : null; + writer.writeByteList(offset, bytes); +} + +List? _readBoolList(IsarReader reader, int offset, bool nullable) { + if (nullable) { + return reader.readBoolOrNullList(offset); + } else { + return reader.readBoolList(offset); + } +} + +void _writeBoolList(IsarWriter writer, int offset, dynamic value) { + writer.writeBoolList(offset, (value as List?)?.cast()); +} + +List? _readByteList(IsarReader reader, int offset, bool nullable) { + return reader.readByteList(offset); +} + +void _writeByteList(IsarWriter writer, int offset, dynamic value) { + final bytes = value is List ? Uint8List.fromList(value.cast()) : null; + writer.writeByteList(offset, bytes); +} + +List? _readIntList(IsarReader reader, int offset, bool nullable) { + if (nullable) { + return reader.readIntOrNullList(offset); + } else { + return reader.readIntList(offset); + } +} + +void _writeIntList(IsarWriter writer, int offset, dynamic value) { + writer.writeIntList(offset, (value as List?)?.cast()); +} + +List? _readFloatList(IsarReader reader, int offset, bool nullable) { + if (nullable) { + return reader.readFloatOrNullList(offset); + } else { + return reader.readFloatList(offset); + } +} + +void _writeFloatList(IsarWriter writer, int offset, dynamic value) { + writer.writeFloatList(offset, (value as List?)?.cast()); +} + +List? _readLongList(IsarReader reader, int offset, bool nullable) { + if (nullable) { + return reader.readLongOrNullList(offset); + } else { + return reader.readLongList(offset); + } +} + +void _writeLongList(IsarWriter writer, int offset, dynamic value) { + writer.writeLongList(offset, (value as List?)?.cast()); +} + +List? _readDoubleList(IsarReader reader, int offset, bool nullable) { + if (nullable) { + return reader.readDoubleOrNullList(offset); + } else { + return reader.readDoubleList(offset); + } +} + +void _writeDoubleList(IsarWriter writer, int offset, dynamic value) { + writer.writeDoubleList(offset, (value as List?)?.cast()); +} + +List? _readStringList(IsarReader reader, int offset, bool nullable) { + if (nullable) { + return reader.readStringOrNullList(offset); + } else { + return reader.readStringList(offset); + } +} + +void _writeStringList(IsarWriter writer, int offset, dynamic value) { + writer.writeStringList(offset, (value as List?)?.cast()); +} diff --git a/packages_external/isar-3.1.0-1/packages/isar/tool/get_version.dart b/packages_external/isar-3.1.0-1/packages/isar/tool/get_version.dart new file mode 100644 index 00000000..cd12a90a --- /dev/null +++ b/packages_external/isar-3.1.0-1/packages/isar/tool/get_version.dart @@ -0,0 +1,6 @@ +import 'package:isar/isar.dart'; + +void main() { + // ignore: avoid_print + print(Isar.version); +} diff --git a/packages_external/isar-3.1.0-1/packages/isar/tool/verify_release_version.dart b/packages_external/isar-3.1.0-1/packages/isar/tool/verify_release_version.dart new file mode 100644 index 00000000..1ad3e915 --- /dev/null +++ b/packages_external/isar-3.1.0-1/packages/isar/tool/verify_release_version.dart @@ -0,0 +1,9 @@ +import 'package:isar/isar.dart'; + +void main(List args) { + if (Isar.version != args[0]) { + throw StateError( + 'Invalid Isar version for release: ${Isar.version} != ${args[0]}', + ); + } +} diff --git a/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/.pubignore b/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/.pubignore new file mode 100644 index 00000000..f4c9bc13 --- /dev/null +++ b/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/.pubignore @@ -0,0 +1,5 @@ +!*.so +!*.a +!*.dylib +!*.dll +!*.xcframework/ \ No newline at end of file diff --git a/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/CHANGELOG.md b/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/CHANGELOG.md new file mode 100644 index 00000000..1634a089 --- /dev/null +++ b/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/CHANGELOG.md @@ -0,0 +1 @@ +See [Isar Changelog](https://pub.dev/packages/isar/changelog) \ No newline at end of file diff --git a/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/LICENSE b/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/LICENSE new file mode 100644 index 00000000..7a4a3ea2 --- /dev/null +++ b/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/LICENSE @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. \ No newline at end of file diff --git a/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/README.md b/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/README.md new file mode 100644 index 00000000..ab70e970 --- /dev/null +++ b/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/README.md @@ -0,0 +1 @@ +### Flutter binaries for the [Isar Database](https://github.com/isar/isar) please go there for documentation. \ No newline at end of file diff --git a/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/android/.gitignore b/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/android/.gitignore new file mode 100644 index 00000000..c6cbe562 --- /dev/null +++ b/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/android/.gitignore @@ -0,0 +1,8 @@ +*.iml +.gradle +/local.properties +/.idea/workspace.xml +/.idea/libraries +.DS_Store +/build +/captures diff --git a/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/android/build.gradle b/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/android/build.gradle new file mode 100644 index 00000000..12bd1ee5 --- /dev/null +++ b/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/android/build.gradle @@ -0,0 +1,36 @@ +group 'dev.isar.isar_flutter_libs' +version '1.0' + +buildscript { + repositories { + google() + mavenCentral() + } + + dependencies { + classpath 'com.android.tools.build:gradle:7.3.1' + } +} + +rootProject.allprojects { + repositories { + google() + mavenCentral() + } +} + +apply plugin: 'com.android.library' + +android { + namespace 'dev.isar.isar_flutter_libs' + + compileSdkVersion 34 + + defaultConfig { + minSdkVersion 19 + } +} + +dependencies { + implementation "androidx.startup:startup-runtime:1.1.1" +} \ No newline at end of file diff --git a/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/android/gradle.properties b/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/android/gradle.properties new file mode 100644 index 00000000..94adc3a3 --- /dev/null +++ b/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/android/gradle.properties @@ -0,0 +1,3 @@ +org.gradle.jvmargs=-Xmx1536M +android.useAndroidX=true +android.enableJetifier=true diff --git a/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/android/gradle/wrapper/gradle-wrapper.properties b/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/android/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 00000000..0a426381 --- /dev/null +++ b/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/android/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,6 @@ +#Sat Nov 12 16:30:49 CET 2022 +distributionBase=GRADLE_USER_HOME +distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip +distributionPath=wrapper/dists +zipStorePath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME diff --git a/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/android/settings.gradle b/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/android/settings.gradle new file mode 100644 index 00000000..6942e528 --- /dev/null +++ b/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/android/settings.gradle @@ -0,0 +1 @@ +rootProject.name = 'isar_flutter_libs' diff --git a/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/android/src/main/AndroidManifest.xml b/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/android/src/main/AndroidManifest.xml new file mode 100644 index 00000000..4805420d --- /dev/null +++ b/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/android/src/main/AndroidManifest.xml @@ -0,0 +1,3 @@ + \ No newline at end of file diff --git a/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/android/src/main/java/dev/isar/isar_flutter_libs/IsarFlutterLibsPlugin.java b/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/android/src/main/java/dev/isar/isar_flutter_libs/IsarFlutterLibsPlugin.java new file mode 100644 index 00000000..c28ffa3e --- /dev/null +++ b/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/android/src/main/java/dev/isar/isar_flutter_libs/IsarFlutterLibsPlugin.java @@ -0,0 +1,13 @@ +package dev.isar.isar_flutter_libs; + +import androidx.annotation.NonNull; + +import io.flutter.embedding.engine.plugins.FlutterPlugin; + +public class IsarFlutterLibsPlugin implements FlutterPlugin { + @Override + public void onAttachedToEngine(@NonNull FlutterPluginBinding flutterPluginBinding) { } + + @Override + public void onDetachedFromEngine(@NonNull FlutterPluginBinding binding) { } +} diff --git a/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/ios/.gitignore b/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/ios/.gitignore new file mode 100644 index 00000000..0c885071 --- /dev/null +++ b/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/ios/.gitignore @@ -0,0 +1,38 @@ +.idea/ +.vagrant/ +.sconsign.dblite +.svn/ + +.DS_Store +*.swp +profile + +DerivedData/ +build/ +GeneratedPluginRegistrant.h +GeneratedPluginRegistrant.m + +.generated/ + +*.pbxuser +*.mode1v3 +*.mode2v3 +*.perspectivev3 + +!default.pbxuser +!default.mode1v3 +!default.mode2v3 +!default.perspectivev3 + +xcuserdata + +*.moved-aside + +*.pyc +*sync/ +Icon? +.tags* + +/Flutter/Generated.xcconfig +/Flutter/ephemeral/ +/Flutter/flutter_export_environment.sh \ No newline at end of file diff --git a/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/ios/Assets/.gitkeep b/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/ios/Assets/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/ios/Classes/IsarFlutterLibsPlugin.h b/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/ios/Classes/IsarFlutterLibsPlugin.h new file mode 100644 index 00000000..f2a658f8 --- /dev/null +++ b/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/ios/Classes/IsarFlutterLibsPlugin.h @@ -0,0 +1,4 @@ +#import + +@interface IsarFlutterLibsPlugin : NSObject +@end diff --git a/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/ios/Classes/IsarFlutterLibsPlugin.m b/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/ios/Classes/IsarFlutterLibsPlugin.m new file mode 100644 index 00000000..b005a2ba --- /dev/null +++ b/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/ios/Classes/IsarFlutterLibsPlugin.m @@ -0,0 +1,15 @@ +#import "IsarFlutterLibsPlugin.h" +#if __has_include() +#import +#else +// Support project import fallback if the generated compatibility header +// is not copied when this plugin is created as a library. +// https://forums.swift.org/t/swift-static-libraries-dont-copy-generated-objective-c-header/19816 +#import "isar_flutter_libs-Swift.h" +#endif + +@implementation IsarFlutterLibsPlugin ++ (void)registerWithRegistrar:(NSObject*)registrar { + [SwiftIsarFlutterLibsPlugin registerWithRegistrar:registrar]; +} +@end diff --git a/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/ios/Classes/SwiftIsarFlutterLibsPlugin.swift b/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/ios/Classes/SwiftIsarFlutterLibsPlugin.swift new file mode 100644 index 00000000..b4cc232c --- /dev/null +++ b/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/ios/Classes/SwiftIsarFlutterLibsPlugin.swift @@ -0,0 +1,16 @@ +import Flutter +import UIKit + +public class SwiftIsarFlutterLibsPlugin: NSObject, FlutterPlugin { + public static func register(with registrar: FlutterPluginRegistrar) { + } + + public func handle(_ call: FlutterMethodCall, result: @escaping FlutterResult) { + result(nil) + } + + public func dummyMethodToEnforceBundling() { + // dummy calls to prevent tree shaking + isar_get_error(0) + } +} diff --git a/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/ios/Classes/binding.h b/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/ios/Classes/binding.h new file mode 100644 index 00000000..d827bbea --- /dev/null +++ b/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/ios/Classes/binding.h @@ -0,0 +1,6 @@ +#include +#include +#include +#include + +char* isar_get_error(uint32_t err); \ No newline at end of file diff --git a/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/ios/isar_flutter_libs.podspec b/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/ios/isar_flutter_libs.podspec new file mode 100644 index 00000000..8312e532 --- /dev/null +++ b/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/ios/isar_flutter_libs.podspec @@ -0,0 +1,17 @@ +Pod::Spec.new do |s| + s.name = 'isar_flutter_libs' + s.version = '1.0.0' + s.summary = 'Flutter binaries for the Isar Database. Needs to be included for Flutter apps.' + s.homepage = 'https://isar.dev' + s.license = { :file => '../LICENSE' } + s.author = { 'Isar' => 'hello@isar.dev' } + + s.source = { :path => '.' } + s.source_files = 'Classes/**/*' + s.public_header_files = 'Classes/**/*.h' + + s.dependency 'Flutter' + s.platform = :ios, '11.0' + s.swift_version = '5.3' + s.vendored_frameworks = 'isar.xcframework' +end diff --git a/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/lib/isar_flutter_libs.dart b/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/lib/isar_flutter_libs.dart new file mode 100644 index 00000000..e69de29b diff --git a/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/linux/CMakeLists.txt b/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/linux/CMakeLists.txt new file mode 100644 index 00000000..4f22a32b --- /dev/null +++ b/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/linux/CMakeLists.txt @@ -0,0 +1,25 @@ +cmake_minimum_required(VERSION 3.10) +set(PROJECT_NAME "isar_flutter_libs") +project(${PROJECT_NAME} LANGUAGES CXX) + +# This value is used when generating builds using this plugin, so it must +# not be changed +set(PLUGIN_NAME "isar_flutter_libs_plugin") + +add_library(${PLUGIN_NAME} SHARED + "isar_flutter_libs_plugin.cc" +) +apply_standard_settings(${PLUGIN_NAME}) +set_target_properties(${PLUGIN_NAME} PROPERTIES + CXX_VISIBILITY_PRESET hidden) +target_compile_definitions(${PLUGIN_NAME} PRIVATE FLUTTER_PLUGIN_IMPL) +target_include_directories(${PLUGIN_NAME} INTERFACE + "${CMAKE_CURRENT_SOURCE_DIR}/include") +target_link_libraries(${PLUGIN_NAME} PRIVATE flutter) +target_link_libraries(${PLUGIN_NAME} PRIVATE PkgConfig::GTK) + +# List of absolute paths to libraries that should be bundled with the plugin +set(isar_flutter_libs_bundled_libraries + "${CMAKE_CURRENT_SOURCE_DIR}/libisar.so" + PARENT_SCOPE +) diff --git a/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/linux/include/isar_flutter_libs/isar_flutter_libs_plugin.h b/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/linux/include/isar_flutter_libs/isar_flutter_libs_plugin.h new file mode 100644 index 00000000..499bfc87 --- /dev/null +++ b/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/linux/include/isar_flutter_libs/isar_flutter_libs_plugin.h @@ -0,0 +1,26 @@ +#ifndef FLUTTER_PLUGIN_ISAR_FLUTTER_LIBS_PLUGIN_H_ +#define FLUTTER_PLUGIN_ISAR_FLUTTER_LIBS_PLUGIN_H_ + +#include + +G_BEGIN_DECLS + +#ifdef FLUTTER_PLUGIN_IMPL +#define FLUTTER_PLUGIN_EXPORT __attribute__((visibility("default"))) +#else +#define FLUTTER_PLUGIN_EXPORT +#endif + +typedef struct _IsarFlutterLibsPlugin IsarFlutterLibsPlugin; +typedef struct { + GObjectClass parent_class; +} IsarFlutterLibsPluginClass; + +FLUTTER_PLUGIN_EXPORT GType isar_flutter_libs_plugin_get_type(); + +FLUTTER_PLUGIN_EXPORT void isar_flutter_libs_plugin_register_with_registrar( + FlPluginRegistrar* registrar); + +G_END_DECLS + +#endif // FLUTTER_PLUGIN_ISAR_FLUTTER_LIBS_PLUGIN_H_ diff --git a/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/linux/isar_flutter_libs_plugin.cc b/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/linux/isar_flutter_libs_plugin.cc new file mode 100644 index 00000000..50cd846e --- /dev/null +++ b/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/linux/isar_flutter_libs_plugin.cc @@ -0,0 +1,70 @@ +#include "include/isar_flutter_libs/isar_flutter_libs_plugin.h" + +#include +#include +#include + +#include + +#define ISAR_FLUTTER_LIBS_PLUGIN(obj) \ + (G_TYPE_CHECK_INSTANCE_CAST((obj), isar_flutter_libs_plugin_get_type(), \ + IsarFlutterLibsPlugin)) + +struct _IsarFlutterLibsPlugin { + GObject parent_instance; +}; + +G_DEFINE_TYPE(IsarFlutterLibsPlugin, isar_flutter_libs_plugin, g_object_get_type()) + +// Called when a method call is received from Flutter. +static void isar_flutter_libs_plugin_handle_method_call( + IsarFlutterLibsPlugin* self, + FlMethodCall* method_call) { + g_autoptr(FlMethodResponse) response = nullptr; + + const gchar* method = fl_method_call_get_name(method_call); + + if (strcmp(method, "getPlatformVersion") == 0) { + struct utsname uname_data = {}; + uname(&uname_data); + g_autofree gchar *version = g_strdup_printf("Linux %s", uname_data.version); + g_autoptr(FlValue) result = fl_value_new_string(version); + response = FL_METHOD_RESPONSE(fl_method_success_response_new(result)); + } else { + response = FL_METHOD_RESPONSE(fl_method_not_implemented_response_new()); + } + + fl_method_call_respond(method_call, response, nullptr); +} + +static void isar_flutter_libs_plugin_dispose(GObject* object) { + G_OBJECT_CLASS(isar_flutter_libs_plugin_parent_class)->dispose(object); +} + +static void isar_flutter_libs_plugin_class_init(IsarFlutterLibsPluginClass* klass) { + G_OBJECT_CLASS(klass)->dispose = isar_flutter_libs_plugin_dispose; +} + +static void isar_flutter_libs_plugin_init(IsarFlutterLibsPlugin* self) {} + +static void method_call_cb(FlMethodChannel* channel, FlMethodCall* method_call, + gpointer user_data) { + IsarFlutterLibsPlugin* plugin = ISAR_FLUTTER_LIBS_PLUGIN(user_data); + isar_flutter_libs_plugin_handle_method_call(plugin, method_call); +} + +void isar_flutter_libs_plugin_register_with_registrar(FlPluginRegistrar* registrar) { + IsarFlutterLibsPlugin* plugin = ISAR_FLUTTER_LIBS_PLUGIN( + g_object_new(isar_flutter_libs_plugin_get_type(), nullptr)); + + g_autoptr(FlStandardMethodCodec) codec = fl_standard_method_codec_new(); + g_autoptr(FlMethodChannel) channel = + fl_method_channel_new(fl_plugin_registrar_get_messenger(registrar), + "isar_flutter_libs", + FL_METHOD_CODEC(codec)); + fl_method_channel_set_method_call_handler(channel, method_call_cb, + g_object_ref(plugin), + g_object_unref); + + g_object_unref(plugin); +} diff --git a/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/macos/Classes/IsarFlutterLibsPlugin.swift b/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/macos/Classes/IsarFlutterLibsPlugin.swift new file mode 100644 index 00000000..5493fbb9 --- /dev/null +++ b/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/macos/Classes/IsarFlutterLibsPlugin.swift @@ -0,0 +1,19 @@ +import Cocoa +import FlutterMacOS + +public class IsarFlutterLibsPlugin: NSObject, FlutterPlugin { + public static func register(with registrar: FlutterPluginRegistrar) { + let channel = FlutterMethodChannel(name: "isar_flutter_libs", binaryMessenger: registrar.messenger) + let instance = IsarFlutterLibsPlugin() + registrar.addMethodCallDelegate(instance, channel: channel) + } + + public func handle(_ call: FlutterMethodCall, result: @escaping FlutterResult) { + switch call.method { + case "getPlatformVersion": + result("macOS " + ProcessInfo.processInfo.operatingSystemVersionString) + default: + result(FlutterMethodNotImplemented) + } + } +} diff --git a/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/macos/isar_flutter_libs.podspec b/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/macos/isar_flutter_libs.podspec new file mode 100644 index 00000000..08244150 --- /dev/null +++ b/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/macos/isar_flutter_libs.podspec @@ -0,0 +1,17 @@ +Pod::Spec.new do |s| + s.name = 'isar_flutter_libs' + s.version = '1.0.0' + s.summary = 'Flutter binaries for the Isar Database. Needs to be included for Flutter apps.' + s.homepage = 'https://isar.dev' + s.license = { :file => '../LICENSE' } + s.author = { 'Isar' => 'hello@isar.dev' } + + s.source = { :path => '.' } + s.source_files = 'Classes/**/*' + s.public_header_files = 'Classes/**/*.h' + + s.dependency 'FlutterMacOS' + s.platform = :osx, '10.11' + s.swift_version = '5.3' + s.vendored_libraries = 'libisar.dylib' +end \ No newline at end of file diff --git a/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/pubspec.yaml b/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/pubspec.yaml new file mode 100644 index 00000000..e4638a0f --- /dev/null +++ b/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/pubspec.yaml @@ -0,0 +1,33 @@ +name: isar_flutter_libs +description: Isar Core binaries for the Isar Database. Needs to be included for + Flutter apps. +version: 3.1.0+1 +repository: https://github.com/isar/isar +homepage: https://isar.dev + +environment: + sdk: ">=2.17.0 <3.0.0" + flutter: ">=3.0.0" + +dependencies: + flutter: + sdk: flutter + isar: 3.1.0+1 + +dev_dependencies: + build_runner: ^2.4.13 + +flutter: + plugin: + platforms: + android: + package: dev.isar.isar_flutter_libs + pluginClass: IsarFlutterLibsPlugin + ios: + pluginClass: IsarFlutterLibsPlugin + macos: + pluginClass: IsarFlutterLibsPlugin + linux: + pluginClass: IsarFlutterLibsPlugin + windows: + pluginClass: IsarFlutterLibsPlugin diff --git a/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/pubspec_overrides.yaml b/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/pubspec_overrides.yaml new file mode 100644 index 00000000..388e439a --- /dev/null +++ b/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/pubspec_overrides.yaml @@ -0,0 +1,3 @@ +dependency_overrides: + isar: + path: ../isar \ No newline at end of file diff --git a/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/windows/.gitignore b/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/windows/.gitignore new file mode 100644 index 00000000..b3eb2be1 --- /dev/null +++ b/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/windows/.gitignore @@ -0,0 +1,17 @@ +flutter/ + +# Visual Studio user-specific files. +*.suo +*.user +*.userosscache +*.sln.docstates + +# Visual Studio build-related files. +x64/ +x86/ + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!*.[Cc]ache/ diff --git a/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/windows/CMakeLists.txt b/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/windows/CMakeLists.txt new file mode 100644 index 00000000..55206521 --- /dev/null +++ b/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/windows/CMakeLists.txt @@ -0,0 +1,24 @@ +cmake_minimum_required(VERSION 3.14) +set(PROJECT_NAME "isar_flutter_libs") +project(${PROJECT_NAME} LANGUAGES CXX) + +# This value is used when generating builds using this plugin, so it must +# not be changed +set(PLUGIN_NAME "isar_flutter_libs_plugin") + +add_library(${PLUGIN_NAME} SHARED + "isar_flutter_libs_plugin.cpp" +) +apply_standard_settings(${PLUGIN_NAME}) +set_target_properties(${PLUGIN_NAME} PROPERTIES + CXX_VISIBILITY_PRESET hidden) +target_compile_definitions(${PLUGIN_NAME} PRIVATE FLUTTER_PLUGIN_IMPL) +target_include_directories(${PLUGIN_NAME} INTERFACE + "${CMAKE_CURRENT_SOURCE_DIR}/include") +target_link_libraries(${PLUGIN_NAME} PRIVATE flutter flutter_wrapper_plugin) + +# List of absolute paths to libraries that should be bundled with the plugin +set(isar_flutter_libs_bundled_libraries + "${CMAKE_CURRENT_SOURCE_DIR}/isar.dll" + PARENT_SCOPE +) diff --git a/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/windows/include/isar_flutter_libs/isar_flutter_libs_plugin.h b/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/windows/include/isar_flutter_libs/isar_flutter_libs_plugin.h new file mode 100644 index 00000000..d0c066de --- /dev/null +++ b/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/windows/include/isar_flutter_libs/isar_flutter_libs_plugin.h @@ -0,0 +1,23 @@ +#ifndef FLUTTER_PLUGIN_ISAR_FLUTTER_LIBS_PLUGIN_H_ +#define FLUTTER_PLUGIN_ISAR_FLUTTER_LIBS_PLUGIN_H_ + +#include + +#ifdef FLUTTER_PLUGIN_IMPL +#define FLUTTER_PLUGIN_EXPORT __declspec(dllexport) +#else +#define FLUTTER_PLUGIN_EXPORT __declspec(dllimport) +#endif + +#if defined(__cplusplus) +extern "C" { +#endif + +FLUTTER_PLUGIN_EXPORT void IsarFlutterLibsPluginRegisterWithRegistrar( + FlutterDesktopPluginRegistrarRef registrar); + +#if defined(__cplusplus) +} // extern "C" +#endif + +#endif // FLUTTER_PLUGIN_ISAR_FLUTTER_LIBS_PLUGIN_H_ diff --git a/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/windows/isar_flutter_libs_plugin.cpp b/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/windows/isar_flutter_libs_plugin.cpp new file mode 100644 index 00000000..707b9246 --- /dev/null +++ b/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/windows/isar_flutter_libs_plugin.cpp @@ -0,0 +1,82 @@ +#include "include/isar_flutter_libs/isar_flutter_libs_plugin.h" + +// This must be included before many other Windows headers. +#include + +// For getPlatformVersion; remove unless needed for your plugin implementation. +#include + +#include +#include +#include + +#include +#include +#include + +namespace { + +class IsarFlutterLibsPlugin : public flutter::Plugin { + public: + static void RegisterWithRegistrar(flutter::PluginRegistrarWindows *registrar); + + IsarFlutterLibsPlugin(); + + virtual ~IsarFlutterLibsPlugin(); + + private: + // Called when a method is called on this plugin's channel from Dart. + void HandleMethodCall( + const flutter::MethodCall &method_call, + std::unique_ptr> result); +}; + +// static +void IsarFlutterLibsPlugin::RegisterWithRegistrar( + flutter::PluginRegistrarWindows *registrar) { + auto channel = + std::make_unique>( + registrar->messenger(), "isar_flutter_libs", + &flutter::StandardMethodCodec::GetInstance()); + + auto plugin = std::make_unique(); + + channel->SetMethodCallHandler( + [plugin_pointer = plugin.get()](const auto &call, auto result) { + plugin_pointer->HandleMethodCall(call, std::move(result)); + }); + + registrar->AddPlugin(std::move(plugin)); +} + +IsarFlutterLibsPlugin::IsarFlutterLibsPlugin() {} + +IsarFlutterLibsPlugin::~IsarFlutterLibsPlugin() {} + +void IsarFlutterLibsPlugin::HandleMethodCall( + const flutter::MethodCall &method_call, + std::unique_ptr> result) { + if (method_call.method_name().compare("getPlatformVersion") == 0) { + std::ostringstream version_stream; + version_stream << "Windows "; + if (IsWindows10OrGreater()) { + version_stream << "10+"; + } else if (IsWindows8OrGreater()) { + version_stream << "8"; + } else if (IsWindows7OrGreater()) { + version_stream << "7"; + } + result->Success(flutter::EncodableValue(version_stream.str())); + } else { + result->NotImplemented(); + } +} + +} // namespace + +void IsarFlutterLibsPluginRegisterWithRegistrar( + FlutterDesktopPluginRegistrarRef registrar) { + IsarFlutterLibsPlugin::RegisterWithRegistrar( + flutter::PluginRegistrarManager::GetInstance() + ->GetRegistrar(registrar)); +} diff --git a/packages_external/isar-3.1.0-1/tool/build.sh b/packages_external/isar-3.1.0-1/tool/build.sh new file mode 100644 index 00000000..f93bac4f --- /dev/null +++ b/packages_external/isar-3.1.0-1/tool/build.sh @@ -0,0 +1,22 @@ +#!/bin/shuname + +arch=$(uname -m) + +if [ `uname` = "Linux" ] ; +then + if [ $arch = "x86_64" ] ; + then + cargo build --target x86_64-unknown-linux-gnu --release + else + cargo build --target aarch64-unknown-linux-gnu --release + fi +elif [ `uname` = "Darwin" ] ; +then + if [[ $arch == x86_64* ]]; then + cargo build --target x86_64-apple-darwin --release + else + cargo build --target aarch64-apple-darwin --release + fi +else + cargo build --target x86_64-pc-windows-msvc --release +fi \ No newline at end of file diff --git a/packages_external/isar-3.1.0-1/tool/build_android.sh b/packages_external/isar-3.1.0-1/tool/build_android.sh new file mode 100644 index 00000000..cb96b9ab --- /dev/null +++ b/packages_external/isar-3.1.0-1/tool/build_android.sh @@ -0,0 +1,60 @@ +#!/bin/bash + +if [[ "$(uname -s)" == "Darwin" ]]; then + export NDK_HOST_TAG="darwin-x86_64" +elif [[ "$(uname -s)" == "Linux" ]]; then + export NDK_HOST_TAG="linux-x86_64" +else + echo "Unsupported OS." + exit +fi + +NDK=${ANDROID_NDK_HOME:-${ANDROID_NDK_ROOT:-"$ANDROID_SDK_ROOT/ndk"}} +COMPILER_DIR="$NDK/toolchains/llvm/prebuilt/$NDK_HOST_TAG/bin" +export PATH="$COMPILER_DIR:$PATH" + +echo "$COMPILER_DIR" + +export CC_i686_linux_android=$COMPILER_DIR/i686-linux-android21-clang +export AR_i686_linux_android=$COMPILER_DIR/llvm-ar +export CARGO_TARGET_I686_LINUX_ANDROID_LINKER=$COMPILER_DIR/i686-linux-android21-clang +export CARGO_TARGET_I686_LINUX_ANDROID_AR=$COMPILER_DIR/llvm-ar + +export CC_x86_64_linux_android=$COMPILER_DIR/x86_64-linux-android21-clang +export AR_x86_64_linux_android=$COMPILER_DIR/llvm-ar +export CARGO_TARGET_X86_64_LINUX_ANDROID_LINKER=$COMPILER_DIR/x86_64-linux-android21-clang +export CARGO_TARGET_X86_64_LINUX_ANDROID_AR=$COMPILER_DIR/llvm-ar + +export CC_armv7_linux_androideabi=$COMPILER_DIR/armv7a-linux-androideabi21-clang +export AR_armv7_linux_androideabi=$COMPILER_DIR/llvm-ar +export CARGO_TARGET_ARMV7_LINUX_ANDROIDEABI_LINKER=$COMPILER_DIR/armv7a-linux-androideabi21-clang +export CARGO_TARGET_ARMV7_LINUX_ANDROIDEABI_AR=$COMPILER_DIR/llvm-ar + +export CC_aarch64_linux_android=$COMPILER_DIR/aarch64-linux-android21-clang +export AR_aarch64_linux_android=$COMPILER_DIR/llvm-ar +export CARGO_TARGET_AARCH64_LINUX_ANDROID_LINKER=$COMPILER_DIR/aarch64-linux-android21-clang +export CARGO_TARGET_AARCH64_LINUX_ANDROID_AR=$COMPILER_DIR/llvm-ar + +if [ "$1" = "x86" ]; then + rustup target add i686-linux-android + cargo build --target i686-linux-android --release + mv "target/i686-linux-android/release/libisar.so" "libisar_android_x86.so" +elif [ "$1" = "x64" ]; then + rustup target add x86_64-linux-android + cargo build --target x86_64-linux-android --release + mv "target/x86_64-linux-android/release/libisar.so" "libisar_android_x64.so" +elif [ "$1" = "armv7" ]; then + rustup target add armv7-linux-androideabi + cargo build --target armv7-linux-androideabi --release + mv "target/armv7-linux-androideabi/release/libisar.so" "libisar_android_armv7.so" +else + rustup target add aarch64-linux-android + cargo build --target aarch64-linux-android --release + mv "target/aarch64-linux-android/release/libisar.so" "libisar_android_arm64.so" +fi + + + + + + diff --git a/packages_external/isar-3.1.0-1/tool/build_ios.sh b/packages_external/isar-3.1.0-1/tool/build_ios.sh new file mode 100644 index 00000000..58f3b720 --- /dev/null +++ b/packages_external/isar-3.1.0-1/tool/build_ios.sh @@ -0,0 +1,15 @@ +export IPHONEOS_DEPLOYMENT_TARGET=11.0 + +rustup target add aarch64-apple-ios aarch64-apple-ios-sim x86_64-apple-ios +cargo build --target aarch64-apple-ios --release +cargo build --target aarch64-apple-ios-sim --release +cargo build --target x86_64-apple-ios --release + +lipo "target/aarch64-apple-ios-sim/release/libisar.a" "target/x86_64-apple-ios/release/libisar.a" -output "target/aarch64-apple-ios-sim/libisar.a" -create +xcodebuild \ + -create-xcframework \ + -library target/aarch64-apple-ios/release/libisar.a \ + -library target/aarch64-apple-ios-sim/libisar.a \ + -output isar.xcframework + +zip -r isar_ios.xcframework.zip isar.xcframework \ No newline at end of file diff --git a/packages_external/isar-3.1.0-1/tool/build_linux.sh b/packages_external/isar-3.1.0-1/tool/build_linux.sh new file mode 100644 index 00000000..8687beb1 --- /dev/null +++ b/packages_external/isar-3.1.0-1/tool/build_linux.sh @@ -0,0 +1,9 @@ +if [ "$1" = "x64" ]; then + rustup target add target x86_64-unknown-linux-gnu + cargo build --target x86_64-unknown-linux-gnu --release + mv "target/x86_64-unknown-linux-gnu/release/libisar.so" "libisar_linux_x64.so" +else + rustup target add aarch64-unknown-linux-gnu + cargo build --target aarch64-unknown-linux-gnu --release + mv "target/aarch64-unknown-linux-gnu/release/libisar.so" "libisar_linux_arm64.so" +fi \ No newline at end of file diff --git a/packages_external/isar-3.1.0-1/tool/build_macos.sh b/packages_external/isar-3.1.0-1/tool/build_macos.sh new file mode 100644 index 00000000..c13a4992 --- /dev/null +++ b/packages_external/isar-3.1.0-1/tool/build_macos.sh @@ -0,0 +1,8 @@ +export MACOSX_DEPLOYMENT_TARGET=10.11 + +rustup target add aarch64-apple-darwin x86_64-apple-darwin +cargo build --target aarch64-apple-darwin --release +cargo build --target x86_64-apple-darwin --release + +lipo "target/aarch64-apple-darwin/release/libisar.dylib" "target/x86_64-apple-darwin/release/libisar.dylib" -output "libisar_macos.dylib" -create +install_name_tool -id @rpath/libisar.dylib libisar_macos.dylib \ No newline at end of file diff --git a/packages_external/isar-3.1.0-1/tool/build_windows.sh b/packages_external/isar-3.1.0-1/tool/build_windows.sh new file mode 100644 index 00000000..1bacbb8c --- /dev/null +++ b/packages_external/isar-3.1.0-1/tool/build_windows.sh @@ -0,0 +1,9 @@ +if [ "$1" = "x64" ]; then + rustup target add x86_64-pc-windows-msvc + cargo build --target x86_64-pc-windows-msvc --release + mv "target/x86_64-pc-windows-msvc/release/isar.dll" "isar_windows_x64.dll" +else + rustup target add aarch64-pc-windows-msvc + cargo build --target aarch64-pc-windows-msvc --release + mv "target/aarch64-pc-windows-msvc/release/isar.dll" "isar_windows_arm64.dll" +fi \ No newline at end of file diff --git a/packages_external/isar-3.1.0-1/tool/cbindgen.toml b/packages_external/isar-3.1.0-1/tool/cbindgen.toml new file mode 100644 index 00000000..7841a04d --- /dev/null +++ b/packages_external/isar-3.1.0-1/tool/cbindgen.toml @@ -0,0 +1,8 @@ +language = "C" + +[parse] +parse_deps = true +include = ["isar-core", "isar"] + +[parse.expand] +crates = ["isar"] \ No newline at end of file diff --git a/packages_external/isar-3.1.0-1/tool/download_binaries.sh b/packages_external/isar-3.1.0-1/tool/download_binaries.sh new file mode 100644 index 00000000..bd0e61be --- /dev/null +++ b/packages_external/isar-3.1.0-1/tool/download_binaries.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +version=`dart packages/isar/tool/get_version.dart` +github="https://github.com/isar/isar/releases/download/${version}" + + +curl "${github}/libisar_android_arm64.so" -o packages/isar_flutter_libs/android/src/main/jniLibs/arm64-v8a/libisar.so --create-dirs -L -f +curl "${github}/libisar_android_armv7.so" -o packages/isar_flutter_libs/android/src/main/jniLibs/armeabi-v7a/libisar.so --create-dirs -L -f +curl "${github}/libisar_android_x64.so" -o packages/isar_flutter_libs/android/src/main/jniLibs/x86_64/libisar.so --create-dirs -L +curl "${github}/libisar_android_x86.so" -o packages/isar_flutter_libs/android/src/main/jniLibs/x86/libisar.so --create-dirs -L -f + +curl "${github}/isar_ios.xcframework.zip" -o packages/isar_flutter_libs/ios/isar_ios.xcframework.zip --create-dirs -L -f +unzip -o packages/isar_flutter_libs/ios/isar_ios.xcframework.zip -d packages/isar_flutter_libs/ios +rm packages/isar_flutter_libs/ios/isar_ios.xcframework.zip + +curl "${github}/libisar_macos.dylib" -o packages/isar_flutter_libs/macos/libisar.dylib --create-dirs -L -f +curl "${github}/libisar_linux_x64.so" -o packages/isar_flutter_libs/linux/libisar.so --create-dirs -L -f +curl "${github}/isar_windows_x64.dll" -o packages/isar_flutter_libs/windows/isar.dll --create-dirs -L -f \ No newline at end of file diff --git a/packages_external/isar-3.1.0-1/tool/ffigen.yaml b/packages_external/isar-3.1.0-1/tool/ffigen.yaml new file mode 100644 index 00000000..e617e465 --- /dev/null +++ b/packages_external/isar-3.1.0-1/tool/ffigen.yaml @@ -0,0 +1,27 @@ +name: IsarCoreBindings +output: "lib/src/native/bindings.dart" +headers: + entry-points: + - "isar-dart.h" + include-directives: + - '**isar-dart.h' + +structs: + dependency-only: opaque + include: + - CObject + - CObjectSet + - CObjectCollectionSet + - CLink + - CLinkSet + - CObjectLinkSet + rename: + '^(?!C)(.*)': 'C$1' + +unions: + dependency-only: opaque + include: + - 'isar*' + +preamble: | + // ignore_for_file: camel_case_types, non_constant_identifier_names diff --git a/packages_external/isar-3.1.0-1/tool/generate_bindings.sh b/packages_external/isar-3.1.0-1/tool/generate_bindings.sh new file mode 100644 index 00000000..89241d5d --- /dev/null +++ b/packages_external/isar-3.1.0-1/tool/generate_bindings.sh @@ -0,0 +1,13 @@ +#!/bin/sh + +cargo install cbindgen + +cbindgen --config tool/cbindgen.toml --crate isar --output packages/isar/isar-dart.h + +cd packages/isar + +dart pub get +dart run ffigen --config ../../tool/ffigen.yaml +rm isar-dart.h + +dart format --fix lib/src/native/bindings.dart diff --git a/packages_external/isar-3.1.0-1/tool/prepare_tests.sh b/packages_external/isar-3.1.0-1/tool/prepare_tests.sh new file mode 100644 index 00000000..919d115e --- /dev/null +++ b/packages_external/isar-3.1.0-1/tool/prepare_tests.sh @@ -0,0 +1,6 @@ +cd packages/isar_test + +flutter pub get +dart tool/generate_long_double_test.dart +dart tool/generate_all_tests.dart +flutter pub run build_runner build \ No newline at end of file From c0a9c4b50bd77530804098be518a6d0af41ad3da Mon Sep 17 00:00:00 2001 From: ZanderCowboy Date: Sun, 6 Oct 2024 16:01:13 +0200 Subject: [PATCH 04/25] update pubspecs --- apps/multichoice/pubspec.yaml | 8 +++++--- apps/multichoice/pubspec_overrides.yaml | 5 +++++ packages/core/pubspec.yaml | 3 ++- packages/core/pubspec_overrides.yaml | 5 +++++ packages/models/pubspec.yaml | 3 ++- packages/models/pubspec_overrides.yaml | 6 ++++++ packages/theme/pubspec.yaml | 4 +--- pubspec.yaml | 2 +- 8 files changed, 27 insertions(+), 9 deletions(-) create mode 100644 packages/models/pubspec_overrides.yaml diff --git a/apps/multichoice/pubspec.yaml b/apps/multichoice/pubspec.yaml index b30d3784..f36650cc 100644 --- a/apps/multichoice/pubspec.yaml +++ b/apps/multichoice/pubspec.yaml @@ -8,7 +8,7 @@ environment: sdk: ">=3.3.0 <4.0.0" dependencies: - auto_route: ^8.1.3 + auto_route: ^9.2.2 bloc: ^8.1.3 core: ^0.0.1 file_picker: ^8.0.5 @@ -31,12 +31,14 @@ dependencies: path: plugins/window_size dev_dependencies: - auto_route_generator: ^8.0.0 + auto_route_generator: ^9.0.0 build_runner: ^2.4.8 flutter_gen_runner: ^5.5.0+1 flutter_test: sdk: flutter - very_good_analysis: ^5.1.0 + integration_test: + sdk: flutter + very_good_analysis: ^6.0.0 flutter: uses-material-design: true diff --git a/apps/multichoice/pubspec_overrides.yaml b/apps/multichoice/pubspec_overrides.yaml index dcf73b58..b379a5e1 100644 --- a/apps/multichoice/pubspec_overrides.yaml +++ b/apps/multichoice/pubspec_overrides.yaml @@ -1,8 +1,13 @@ +# melos_managed_dependency_overrides: isar,isar_flutter_libs # melos_managed_dependency_overrides: theme # melos_managed_dependency_overrides: core,models dependency_overrides: core: path: ../../packages/core + isar: + path: ..\\..\\packages_external\\isar-3.1.0-1\\packages\\isar + isar_flutter_libs: + path: ..\\..\\packages_external\\isar-3.1.0-1\\packages\\isar_flutter_libs models: path: ../../packages/models theme: diff --git a/packages/core/pubspec.yaml b/packages/core/pubspec.yaml index 37f2c7bc..2ad53158 100644 --- a/packages/core/pubspec.yaml +++ b/packages/core/pubspec.yaml @@ -26,6 +26,7 @@ dependencies: version: ^3.0.2 dev_dependencies: + bloc_test: ^9.1.7 build_runner: ^2.4.8 flutter_test: sdk: flutter @@ -33,7 +34,7 @@ dev_dependencies: injectable_generator: ^2.4.1 json_serializable: ^6.7.1 mockito: ^5.4.4 - very_good_analysis: ^5.1.0 + very_good_analysis: ^6.0.0 global_options: freezed:freezed: diff --git a/packages/core/pubspec_overrides.yaml b/packages/core/pubspec_overrides.yaml index 50b9fd24..78b7c961 100644 --- a/packages/core/pubspec_overrides.yaml +++ b/packages/core/pubspec_overrides.yaml @@ -1,4 +1,9 @@ +# melos_managed_dependency_overrides: isar_flutter_libs,isar # melos_managed_dependency_overrides: models dependency_overrides: + isar: + path: ..\\..\\packages_external\\isar-3.1.0-1\\packages\\isar + isar_flutter_libs: + path: ..\\..\\packages_external\\isar-3.1.0-1\\packages\\isar_flutter_libs models: path: ../models diff --git a/packages/models/pubspec.yaml b/packages/models/pubspec.yaml index 9cd134fb..3a2ccb67 100644 --- a/packages/models/pubspec.yaml +++ b/packages/models/pubspec.yaml @@ -14,7 +14,8 @@ dependencies: sdk: flutter freezed_annotation: ^2.4.1 isar: ^3.1.0+1 - isar_flutter_libs: ^3.1.0+1 + isar_flutter_libs: + path: ../../packages_external/isar-3.1.0-1/packages/isar_flutter_libs json_annotation: ^4.8.1 path_provider: ^2.1.2 uuid: ^4.3.3 diff --git a/packages/models/pubspec_overrides.yaml b/packages/models/pubspec_overrides.yaml new file mode 100644 index 00000000..6ee3107b --- /dev/null +++ b/packages/models/pubspec_overrides.yaml @@ -0,0 +1,6 @@ +# melos_managed_dependency_overrides: isar,isar_flutter_libs +dependency_overrides: + isar: + path: ..\\..\\packages_external\\isar-3.1.0-1\\packages\\isar + isar_flutter_libs: + path: ..\\..\\packages_external\\isar-3.1.0-1\\packages\\isar_flutter_libs diff --git a/packages/theme/pubspec.yaml b/packages/theme/pubspec.yaml index 3b34ae32..af4dcd33 100644 --- a/packages/theme/pubspec.yaml +++ b/packages/theme/pubspec.yaml @@ -17,6 +17,4 @@ dev_dependencies: flutter_test: sdk: flutter theme_tailor: ^3.0.1 - very_good_analysis: ^5.1.0 - -flutter: + very_good_analysis: ^6.0.0 diff --git a/pubspec.yaml b/pubspec.yaml index f07e58a2..16259eb7 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -15,4 +15,4 @@ dev_dependencies: flutter_test: sdk: flutter melos: ^6.0.0 - very_good_analysis: ^5.1.0 + very_good_analysis: ^6.0.0 From c77a1e177a2defcd7a826e96a352c300631f2e36 Mon Sep 17 00:00:00 2001 From: Zander Kotze Date: Thu, 19 Dec 2024 02:13:14 +0200 Subject: [PATCH 05/25] please review this commit --- .config/dotnet-tools.json | 13 ++ .github/workflows/_build-android-app.yml | 19 ++- .gitignore | 1 + .vscode/launch.json | 20 ++++ .vscode/tasks.json | 14 +++ .vscode/test_launch.json | 12 ++ analysis_options.yaml | 3 + apps/multichoice/.metadata | 22 ++-- apps/multichoice/CHANGELOG.txt | 8 ++ .../integration_test/app_test.dart | 78 ++++++++++++ .../lib/app/engine/app_router.dart | 2 +- .../test_driver/integration_test.dart | 3 + melos.yaml | 36 +++++- .../test/application/home/home_bloc_test.dart | 37 ++++++ .../test/services/database_service_test.dart | 28 +++++ .../packages/isar/lib/src/isar.dart | 3 +- .../lib/src/native/isar_collection_impl.dart | 2 +- .../isar/lib/src/query_components.dart | 6 +- .../packages/isar/lib/src/web/open.dart | 4 +- run_all.bat | 11 ++ run_integration_test.bat | 112 ++++++++++++++++++ run_shutdown_emulator.bat | 28 +++++ 22 files changed, 436 insertions(+), 26 deletions(-) create mode 100644 .config/dotnet-tools.json create mode 100644 .vscode/tasks.json create mode 100644 .vscode/test_launch.json create mode 100644 apps/multichoice/integration_test/app_test.dart create mode 100644 apps/multichoice/test_driver/integration_test.dart create mode 100644 packages/core/test/application/home/home_bloc_test.dart create mode 100644 packages/core/test/services/database_service_test.dart create mode 100644 run_all.bat create mode 100644 run_integration_test.bat create mode 100644 run_shutdown_emulator.bat diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json new file mode 100644 index 00000000..9d565f5e --- /dev/null +++ b/.config/dotnet-tools.json @@ -0,0 +1,13 @@ +{ + "version": 1, + "isRoot": true, + "tools": { + "dotnet-reportgenerator-globaltool": { + "version": "5.3.10", + "commands": [ + "reportgenerator" + ], + "rollForward": false + } + } +} \ No newline at end of file diff --git a/.github/workflows/_build-android-app.yml b/.github/workflows/_build-android-app.yml index 707d707e..1a813c64 100644 --- a/.github/workflows/_build-android-app.yml +++ b/.github/workflows/_build-android-app.yml @@ -105,6 +105,23 @@ jobs: name: ${{ inputs.build_artifact }} path: ./apps/multichoice/build/app/outputs/bundle/${{ inputs.environment_flag }}/app-${{ inputs.environment_flag }}.aab + # Generate a changelog based on the latest changes + - name: Install conventional-changelog + run: npm install -g conventional-changelog-cli + + - name: Generate Changelog + run: conventional-changelog -p angular -i CHANGELOG.md -s -r 1 + working-directory: apps/multichoice/ + + # Commit the updated changelog (optional) + - name: Commit Changelog + run: | + git config --global user.name "github-actions[bot]" + git config --global user.email "github-actions[bot]@users.noreply.github.com" + git add apps/multichoice/CHANGELOG.md + git commit -m "chore: update changelog [skip ci]" || echo "No changes to commit" + git push + - name: Upload artifact to Firebase App Distribution if: success() uses: wzieba/Firebase-Distribution-Github-Action@v1 @@ -113,5 +130,5 @@ jobs: serviceCredentialsFileContent: ${{secrets.CREDENTIAL_FILE_CONTENT}} groups: testers file: ./apps/multichoice/build/app/outputs/flutter-apk/app-${{ inputs.environment_flag }}.apk - releaseNotesFile: ./apps/multichoice/CHANGELOG.txt + releaseNotesFile: ./apps/multichoice/CHANGELOG.md debug: true diff --git a/.gitignore b/.gitignore index 289b7500..d9b6d723 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,7 @@ /windows/ /apps/showcase/ +/tools/ # Files and directories created by pub .dart_tool/ diff --git a/.vscode/launch.json b/.vscode/launch.json index 66783dce..5d26ddc2 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -24,5 +24,25 @@ "flutterMode": "release", "program": "apps/multichoice/lib/main.dart" }, + // { + // "name": "Flutter Integration Test", + // "program": "test_driver/integration_test.dart", + // "request": "launch", + // "type": "dart", + // "args": [ + // "drive", + // "--driver", + // "test_driver/integration_test.dart", + // "--target", + // "integration_test/app_test.dart" + // ] + // }, + { + "name": "Run Integration Test with Emulator", + "type": "dart", + "request": "launch", + "program": "${workspaceFolder}/lib/main.dart", + "preLaunchTask": "Start Emulator and Run Integration Test" + } ] } \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 00000000..b3dcef7d --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,14 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "label": "Start Emulator and Run Integration Test", + "type": "shell", + "command": "./run_integration_test.bat", + "problemMatcher": [], + "args": [ + "flutter_emulator" + ] + } + ] +} \ No newline at end of file diff --git a/.vscode/test_launch.json b/.vscode/test_launch.json new file mode 100644 index 00000000..9eaed37b --- /dev/null +++ b/.vscode/test_launch.json @@ -0,0 +1,12 @@ +{ + "version": "0.2.0", + "configurations": [ + { + "name": "multichoice (integration test)", + "request": "launch", + "type": "dart", + "program": "apps/multichoice/test_driver/integration_test.dart", + "preLaunchTask": "flutter drive --target=apps/multichoice/test_driver/integration_test.dart" + } + ] +} \ No newline at end of file diff --git a/analysis_options.yaml b/analysis_options.yaml index 8d7b8dce..ce4f6ac9 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -4,3 +4,6 @@ linter: rules: public_member_api_docs: false lines_longer_than_80_chars: false + analyzer: + exclude: + - packages_external/** diff --git a/apps/multichoice/.metadata b/apps/multichoice/.metadata index 95f4bf6a..ee89be1e 100644 --- a/apps/multichoice/.metadata +++ b/apps/multichoice/.metadata @@ -4,7 +4,7 @@ # This file should be version controlled and should not be manually edited. version: - revision: "300451adae589accbece3490f4396f10bdf15e6e" + revision: "2663184aa79047d0a33a14a3b607954f8fdd8730" channel: "stable" project_type: app @@ -13,20 +13,20 @@ project_type: app migration: platforms: - platform: root - create_revision: 300451adae589accbece3490f4396f10bdf15e6e - base_revision: 300451adae589accbece3490f4396f10bdf15e6e + create_revision: 2663184aa79047d0a33a14a3b607954f8fdd8730 + base_revision: 2663184aa79047d0a33a14a3b607954f8fdd8730 - platform: android - create_revision: 300451adae589accbece3490f4396f10bdf15e6e - base_revision: 300451adae589accbece3490f4396f10bdf15e6e + create_revision: 2663184aa79047d0a33a14a3b607954f8fdd8730 + base_revision: 2663184aa79047d0a33a14a3b607954f8fdd8730 - platform: ios - create_revision: 300451adae589accbece3490f4396f10bdf15e6e - base_revision: 300451adae589accbece3490f4396f10bdf15e6e + create_revision: 2663184aa79047d0a33a14a3b607954f8fdd8730 + base_revision: 2663184aa79047d0a33a14a3b607954f8fdd8730 - platform: web - create_revision: 300451adae589accbece3490f4396f10bdf15e6e - base_revision: 300451adae589accbece3490f4396f10bdf15e6e + create_revision: 2663184aa79047d0a33a14a3b607954f8fdd8730 + base_revision: 2663184aa79047d0a33a14a3b607954f8fdd8730 - platform: windows - create_revision: 300451adae589accbece3490f4396f10bdf15e6e - base_revision: 300451adae589accbece3490f4396f10bdf15e6e + create_revision: 2663184aa79047d0a33a14a3b607954f8fdd8730 + base_revision: 2663184aa79047d0a33a14a3b607954f8fdd8730 # User provided section diff --git a/apps/multichoice/CHANGELOG.txt b/apps/multichoice/CHANGELOG.txt index fdcfb0cf..37b28cc8 100644 --- a/apps/multichoice/CHANGELOG.txt +++ b/apps/multichoice/CHANGELOG.txt @@ -1,5 +1,13 @@ CHANGELOG +Setting up Integration Testing: +https://chatgpt.com/share/66fdf56f-3724-8004-9d18-5a52f68b20a7 +Create documentation + +- start cmd /k "run_integration_test.bat %* && call shutdown_emulator.bat && exit" + + + Version 0.3.0+140: - Added 'data_exchange_service' to import/export data - Update 'home_drawer', added assets and flutter_gen, and cleaned up code diff --git a/apps/multichoice/integration_test/app_test.dart b/apps/multichoice/integration_test/app_test.dart new file mode 100644 index 00000000..97329167 --- /dev/null +++ b/apps/multichoice/integration_test/app_test.dart @@ -0,0 +1,78 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:integration_test/integration_test.dart'; +import 'package:multichoice/main.dart' as app; // Replace with your app import +import 'package:multichoice/presentation/shared/widgets/add_widgets/_base.dart'; + +void main() { + IntegrationTestWidgetsFlutterBinding.ensureInitialized(); + + testWidgets('Test counter increment', (WidgetTester tester) async { + // Launch the app + app.main(); + await tester.pumpAndSettle(const Duration(seconds: 5)); + + // Verify initial value is 0 + expect(find.text('Permission Required'), findsOneWidget); + expect(find.text('Deny'), findsOneWidget); + expect(find.text('Open Settings'), findsOneWidget); + + // Tap the "+" button + await tester.tap(find.text('Deny')); + await tester.pumpAndSettle(); + + // Verify the counter has incremented + expect(find.byIcon(Icons.add_outlined), findsOneWidget); + expect(find.byType(AddTabCard), findsOneWidget); + + expect(find.byIcon(Icons.settings_outlined), findsOneWidget); + await tester.tap(find.byIcon(Icons.settings_outlined)); + await tester.pumpAndSettle(); + + var isVertical = true; + // ignore: unused_local_variable + final layoutSwitch = Switch( + value: isVertical, + onChanged: (bool value) { + isVertical = value; + }, + ); + expect(find.text('Horizontal/Vertical Layout'), findsOneWidget); + // expect(find.byWidget(layoutSwitch), findsOneWidget); + expect(find.byKey(const Key('layoutSwitch')), findsOneWidget); + await tester.tap(find.byKey(const Key('layoutSwitch'))); + await tester.pumpAndSettle(); + + expect(find.byIcon(Icons.close_outlined), findsOneWidget); + await tester.tap(find.byIcon(Icons.close_outlined)); + await tester.pumpAndSettle(); + + expect(find.byIcon(Icons.add_outlined), findsOneWidget); + expect(find.byType(AddTabCard), findsOneWidget); + await tester.tap(find.byType(AddTabCard)); + await tester.pumpAndSettle(); + + expect(find.text('Add New Tab'), findsOneWidget); + expect(find.text('Cancel'), findsOneWidget); + expect(find.text('Add'), findsOneWidget); + + expect(find.byType(TextFormField), findsExactly(2)); + await tester.enterText(find.byType(TextFormField).first, 'Tab 1'); + await tester.enterText(find.byType(TextFormField).last, 'Tab 2'); + await tester.pumpAndSettle(); + expect(find.text('Tab 1'), findsOneWidget); + expect(find.text('Tab 2'), findsOneWidget); + await tester.tap(find.text('Add')); + await tester.pumpAndSettle(); + + expect(find.text('Tab 1'), findsOneWidget); + + await tester.tap(find.byIcon(Icons.search_outlined)); + await tester.pumpAndSettle(); + expect(find.textContaining('not been implemented'), findsOneWidget); + + // await tester.tap(find.text('Cancel')); + // await tester.pumpAndSettle(); + // expect(find.text('Open Modal'), findsOneWidget); + }); +} diff --git a/apps/multichoice/lib/app/engine/app_router.dart b/apps/multichoice/lib/app/engine/app_router.dart index ac7e859e..12ba15cf 100644 --- a/apps/multichoice/lib/app/engine/app_router.dart +++ b/apps/multichoice/lib/app/engine/app_router.dart @@ -2,7 +2,7 @@ import 'package:auto_route/auto_route.dart'; import 'package:multichoice/app/engine/app_router.gr.dart'; @AutoRouterConfig(replaceInRouteName: 'Page,Route,Screen') -class AppRouter extends $AppRouter { +class AppRouter extends RootStackRouter { @override List get routes => [ AutoRoute(page: DataTransferScreenRoute.page), diff --git a/apps/multichoice/test_driver/integration_test.dart b/apps/multichoice/test_driver/integration_test.dart new file mode 100644 index 00000000..b38629cc --- /dev/null +++ b/apps/multichoice/test_driver/integration_test.dart @@ -0,0 +1,3 @@ +import 'package:integration_test/integration_test_driver.dart'; + +Future main() => integrationDriver(); diff --git a/melos.yaml b/melos.yaml index 6117f860..2622485d 100644 --- a/melos.yaml +++ b/melos.yaml @@ -2,6 +2,7 @@ name: multichoice packages: - packages/** + - packages_external/** - apps/** scripts: @@ -46,20 +47,43 @@ scripts: concurrency: 1 test:all: - run: | - melos run test:core --no-select description: | Run all tests available. - + run: | + melos run test:core --no-select && melos run test:multichoice --no-select + # format_coverage --lcov --in coverage/lcov.info -b coverage/html test:core: - run: flutter test -j 1 --coverage + run: flutter test -j 1 --coverage && reportgenerator.exe -reports:coverage/lcov.info -targetdir:coverage/html + exec: - failFast: true + failFast: false + concurrency: 1 + orderDependents: true + packageFilters: + flutter: true + scope: ["core"] + + test:multichoice: + run: flutter test -j 1 --coverage && reportgenerator.exe -reports:coverage/lcov.info -targetdir:coverage/html + + exec: + failFast: false + concurrency: 1 + orderDependents: true + packageFilters: + flutter: true + scope: ["multichoice"] + + test:integration: + run: flutter test -j 1 --coverage && reportgenerator.exe -reports:coverage/lcov.info -targetdir:coverage/html + + exec: + failFast: false concurrency: 1 orderDependents: true packageFilters: flutter: true - scope: "core" + scope: ["integration"] command: bootstrap: diff --git a/packages/core/test/application/home/home_bloc_test.dart b/packages/core/test/application/home/home_bloc_test.dart new file mode 100644 index 00000000..47b32eaf --- /dev/null +++ b/packages/core/test/application/home/home_bloc_test.dart @@ -0,0 +1,37 @@ +import 'package:core/src/application/home/home_bloc.dart'; +import 'package:core/src/repositories/interfaces/entry/i_entry_repository.dart'; +import 'package:core/src/repositories/interfaces/tabs/i_tabs_repository.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:mockito/mockito.dart'; + +class MockTabsRepository extends Mock implements ITabsRepository {} + +class MockEntryRepository extends Mock implements IEntryRepository {} + +void main() { + group('HomeBloc', () { + late HomeBloc homeBloc; + late MockTabsRepository mockTabsRepository; + late MockEntryRepository mockEntryRepository; + + setUp(() { + mockTabsRepository = MockTabsRepository(); + mockEntryRepository = MockEntryRepository(); + homeBloc = HomeBloc(mockTabsRepository, mockEntryRepository); + }); + + tearDown(() { + homeBloc.close(); + }); + + test('initial state is HomeState.initial()', () { + // expect(homeBloc.state, HomeState.initial()); + }); + + // Add more tests here + + test('blank test', () { + // Add your test implementation here + }); + }); +} diff --git a/packages/core/test/services/database_service_test.dart b/packages/core/test/services/database_service_test.dart new file mode 100644 index 00000000..9d042872 --- /dev/null +++ b/packages/core/test/services/database_service_test.dart @@ -0,0 +1,28 @@ +import 'package:flutter_test/flutter_test.dart'; + +void main() { + group('DatabaseService Tests', () { + test('Singleton instance should be the same', () { + // final instance1 = DatabaseService.instance; + // final instance2 = DatabaseService.instance; + + // expect(instance1, same(instance2)); + }); + + test('Initial database should be empty', () { + // final instance = DatabaseService.instance; + + // expect(instance.database, isEmpty); + }); + + test('Adding entries to the database', () { + // final instance = DatabaseService.instance; + // final tab = Tabs.empty(); // Replace with actual tab + // final entry = Entry.empty(); // Replace with actual Entry + + // instance.database[tab] = [entry]; + + // expect(instance.database[tab], contains(entry)); + }); + }); +} diff --git a/packages_external/isar-3.1.0-1/packages/isar/lib/src/isar.dart b/packages_external/isar-3.1.0-1/packages/isar/lib/src/isar.dart index a67ed718..51ca57d2 100644 --- a/packages_external/isar-3.1.0-1/packages/isar/lib/src/isar.dart +++ b/packages_external/isar-3.1.0-1/packages/isar/lib/src/isar.dart @@ -178,7 +178,8 @@ abstract class Isar { void attachCollections(Map> collections) { _collections = collections; _collectionsByName = { - for (IsarCollection col in collections.values) col.name: col, + for (final IsarCollection col in collections.values) + col.name: col, }; } diff --git a/packages_external/isar-3.1.0-1/packages/isar/lib/src/native/isar_collection_impl.dart b/packages_external/isar-3.1.0-1/packages/isar/lib/src/native/isar_collection_impl.dart index 0551ee37..747942e0 100644 --- a/packages_external/isar-3.1.0-1/packages/isar/lib/src/native/isar_collection_impl.dart +++ b/packages_external/isar-3.1.0-1/packages/isar/lib/src/native/isar_collection_impl.dart @@ -247,8 +247,8 @@ class IsarCollectionImpl extends IsarCollection { int putByIndexSyncInternal({ required Txn txn, - int? indexId, required OBJ object, + int? indexId, bool saveLinks = true, }) { final cObjPtr = txn.getCObject(); diff --git a/packages_external/isar-3.1.0-1/packages/isar/lib/src/query_components.dart b/packages_external/isar-3.1.0-1/packages/isar/lib/src/query_components.dart index a2bbfdb1..de680e3f 100644 --- a/packages_external/isar-3.1.0-1/packages/isar/lib/src/query_components.dart +++ b/packages_external/isar-3.1.0-1/packages/isar/lib/src/query_components.dart @@ -122,8 +122,8 @@ class IndexWhereClause extends WhereClause { const IndexWhereClause.between({ required this.indexName, required IndexKey this.lower, - this.includeLower = true, required IndexKey this.upper, + this.includeLower = true, this.includeUpper = true, this.epsilon = Query.epsilon, }) : super._(); @@ -223,11 +223,11 @@ class FilterCondition extends FilterOperation { const FilterCondition({ required this.type, required this.property, - this.value1, - this.value2, required this.include1, required this.include2, required this.caseSensitive, + this.value1, + this.value2, this.epsilon = Query.epsilon, }) : super._(); diff --git a/packages_external/isar-3.1.0-1/packages/isar/lib/src/web/open.dart b/packages_external/isar-3.1.0-1/packages/isar/lib/src/web/open.dart index 5e507919..3ee4c84e 100644 --- a/packages_external/isar-3.1.0-1/packages/isar/lib/src/web/open.dart +++ b/packages_external/isar-3.1.0-1/packages/isar/lib/src/web/open.dart @@ -40,10 +40,10 @@ void doNotInitializeIsarWeb() { Future openIsar({ required List> schemas, - String? directory, required String name, required int maxSizeMiB, required bool relaxedDurability, + String? directory, CompactCondition? compactOnLaunch, }) async { throw IsarError('Please use Isar 2.5.0 if you need web support. ' @@ -73,10 +73,10 @@ Future openIsar({ Isar openIsarSync({ required List> schemas, - String? directory, required String name, required int maxSizeMiB, required bool relaxedDurability, + String? directory, CompactCondition? compactOnLaunch, }) => unsupportedOnWeb(); diff --git a/run_all.bat b/run_all.bat new file mode 100644 index 00000000..a7831ad8 --- /dev/null +++ b/run_all.bat @@ -0,0 +1,11 @@ +@echo off +setlocal + +:: Call the startup-test script to run the tests and capture emulator info +call run_integration_test.bat %* + +:: Call the shutdown script to close the emulator +call run_shutdown_emulator.bat + +endlocal +exit /b diff --git a/run_integration_test.bat b/run_integration_test.bat new file mode 100644 index 00000000..92025e22 --- /dev/null +++ b/run_integration_test.bat @@ -0,0 +1,112 @@ +@echo off +setlocal enabledelayedexpansion + +set EMULATOR_DEVICE="" +set EMULATOR_STARTED=0 + +:: Check if an emulator name is passed as a parameter +if "%1"=="" ( + echo No emulator name provided, listing available emulators... + + :: List available emulators, filter out unnecessary info + set EMULATOR_COUNT=0 + for /f "tokens=1" %%i in ('emulator -list-avds 2^>nul ^| findstr /v "INFO"') do ( + set /a EMULATOR_COUNT+=1 + echo [!EMULATOR_COUNT!] %%i + set EMULATOR_NAME_%%EMULATOR_COUNT%%=%%i + ) + + :: Check if any emulators were found + if !EMULATOR_COUNT! equ 0 ( + echo No emulators found. + exit /b 1 + ) + + :: Prompt the user to select an emulator + set /p EMULATOR_CHOICE="Enter the number of the emulator you want to use: " + + :: Validate the choice + if !EMULATOR_CHOICE! lss 1 ( + echo Invalid selection. + exit /b 1 + ) + if !EMULATOR_CHOICE! gtr !EMULATOR_COUNT! ( + echo Invalid selection. + exit /b 1 + ) + + for /L %%i in (1,1,%EMULATOR_COUNT%) do ( + if "!EMULATOR_CHOICE!"=="%%i" ( + set EMULATOR_NAME=!EMULATOR_NAME_%%i! + ) + ) + echo Emulator selected: !EMULATOR_NAME! + + if "!EMULATOR_NAME!"=="" ( + echo Invalid selection. + exit /b 1 + ) +) else ( + :: Use the provided emulator name + set EMULATOR_NAME=%1 +) + +:: Check if an Android device or emulator is already connected by filtering out desktop devices +set ANDROID_DEVICE_FOUND=0 +for /f "tokens=*" %%i in ('flutter devices ^| findstr /i "android" /i "mobile") do ( + echo %%i + set ANDROID_DEVICE_FOUND=1 +) + +echo Android device or emulator found: !ANDROID_DEVICE_FOUND! + +:: If no Android emulator or device is found, start the selected emulator +if !ANDROID_DEVICE_FOUND! equ 0 ( + echo No Android emulators or devices found. Starting emulator: !EMULATOR_NAME!... + start "" emulator -avd !EMULATOR_NAME! + set EMULATOR_STARTED=1 + echo Waiting for the emulator to start... + + :: Wait for the emulator to boot up + adb wait-for-device +) else ( + echo Android device or emulator is already connected. +) + +:: Check again to ensure the Android device or emulator is ready +set ANDROID_DEVICE_READY=0 +for /f "tokens=*" %%i in ('adb devices ^| findstr /i "device"') do ( + set ANDROID_DEVICE_READY=1 +) + +if !ANDROID_DEVICE_READY! equ 0 ( + echo No Android emulator or device found, exiting... + exit /b 1 +) + +:: Debugging info - print emulator startup status +echo Emulator started: !EMULATOR_STARTED! +echo Emulator device: !EMULATOR_NAME! + +:: Save emulator state to a temporary file for the shutdown script to use +( + echo EMULATOR_STARTED=!EMULATOR_STARTED! + echo EMULATOR_DEVICE=!EMULATOR_NAME! +) > tmp/emulator_state.txt + +:: Debugging: Ensure the file was written by printing its contents +echo Emulator state saved to file: +type tmp/emulator_state.txt + +:: Change directory to apps/multichoice +cd apps/multichoice + +:: Run the Flutter integration test +echo Running Flutter integration test... +flutter drive --driver=test_driver/integration_test.dart --target=integration_test/app_test.dart + +:: Return to the original directory +cd ../../ + +endlocal +exit /b diff --git a/run_shutdown_emulator.bat b/run_shutdown_emulator.bat new file mode 100644 index 00000000..c3ddcd7f --- /dev/null +++ b/run_shutdown_emulator.bat @@ -0,0 +1,28 @@ +@echo off +setlocal + +:: Read the emulator state from the temporary file +for /f "tokens=2 delims==" %%i in ('findstr "EMULATOR_STARTED" emulator_state.txt') do set EMULATOR_STARTED=%%i +for /f "tokens=2 delims==" %%i in ('findstr "EMULATOR_DEVICE" emulator_state.txt') do set EMULATOR_DEVICE=%%i + +:: Check if an emulator was started by the script +:: Check if any emulators are connected +for /f "tokens=1" %%i in ('adb devices ^| findstr /i "emulator"') do ( + echo Closing emulator %%i... + adb -s %%i emu kill +) + +:: Check if the script started an emulator +if "%EMULATOR_STARTED%"=="1" ( + echo Also closing the emulator %EMULATOR_DEVICE% started by this script... + adb -s %EMULATOR_DEVICE% emu kill +) else ( + echo No emulator explicitly started by this script. +) + + +:: Clean up the state file +del emulator_state.txt + +endlocal +exit /b From c4ef1ef91789c49c41a37f16a615f42b248f0223 Mon Sep 17 00:00:00 2001 From: ZanderCowboy Date: Thu, 6 Mar 2025 02:19:34 +0200 Subject: [PATCH 06/25] remove all packages_external --- .../isar-3.1.0-1/.all-contributorsrc | 214 -- packages_external/isar-3.1.0-1/.gitignore | 74 - packages_external/isar-3.1.0-1/Cargo.toml | 12 - packages_external/isar-3.1.0-1/LICENSE | 202 -- packages_external/isar-3.1.0-1/README.md | 1 - packages_external/isar-3.1.0-1/TODO.md | 110 - .../isar-3.1.0-1/packages/isar/.gitignore | 1 - .../isar-3.1.0-1/packages/isar/CHANGELOG.md | 431 ---- .../isar-3.1.0-1/packages/isar/LICENSE | 202 -- .../isar-3.1.0-1/packages/isar/README.md | 267 -- .../packages/isar/analysis_options.yaml | 11 - .../packages/isar/example/README.md | 3 - .../isar-3.1.0-1/packages/isar/lib/isar.dart | 49 - .../isar/lib/src/annotations/backlink.dart | 11 - .../isar/lib/src/annotations/collection.dart | 34 - .../isar/lib/src/annotations/embedded.dart | 17 - .../isar/lib/src/annotations/enumerated.dart | 33 - .../isar/lib/src/annotations/ignore.dart | 11 - .../isar/lib/src/annotations/index.dart | 76 - .../isar/lib/src/annotations/name.dart | 13 - .../isar/lib/src/annotations/type.dart | 20 - .../isar/lib/src/common/isar_common.dart | 222 -- .../lib/src/common/isar_link_base_impl.dart | 108 - .../isar/lib/src/common/isar_link_common.dart | 92 - .../lib/src/common/isar_links_common.dart | 223 -- .../packages/isar/lib/src/common/schemas.dart | 13 - .../packages/isar/lib/src/isar.dart | 348 --- .../isar/lib/src/isar_collection.dart | 342 --- .../packages/isar/lib/src/isar_connect.dart | 263 -- .../isar/lib/src/isar_connect_api.dart | 215 -- .../packages/isar/lib/src/isar_error.dart | 23 - .../packages/isar/lib/src/isar_link.dart | 113 - .../packages/isar/lib/src/isar_reader.dart | 88 - .../packages/isar/lib/src/isar_writer.dart | 53 - .../isar/lib/src/native/bindings.dart | 2241 ----------------- .../isar/lib/src/native/encode_string.dart | 54 - .../isar/lib/src/native/index_key.dart | 257 -- .../lib/src/native/isar_collection_impl.dart | 649 ----- .../isar/lib/src/native/isar_core.dart | 234 -- .../isar/lib/src/native/isar_impl.dart | 139 - .../isar/lib/src/native/isar_link_impl.dart | 121 - .../isar/lib/src/native/isar_reader_impl.dart | 591 ----- .../isar/lib/src/native/isar_writer_impl.dart | 284 --- .../packages/isar/lib/src/native/open.dart | 159 -- .../isar/lib/src/native/query_build.dart | 1040 -------- .../isar/lib/src/native/query_impl.dart | 261 -- .../isar/lib/src/native/split_words.dart | 33 - .../packages/isar/lib/src/native/txn.dart | 113 - .../packages/isar/lib/src/query.dart | 204 -- .../packages/isar/lib/src/query_builder.dart | 403 --- .../lib/src/query_builder_extensions.dart | 303 --- .../isar/lib/src/query_components.dart | 597 ----- .../lib/src/schema/collection_schema.dart | 152 -- .../isar/lib/src/schema/index_schema.dart | 104 - .../isar/lib/src/schema/link_schema.dart | 64 - .../isar/lib/src/schema/property_schema.dart | 183 -- .../packages/isar/lib/src/schema/schema.dart | 126 - .../packages/isar/lib/src/web/bindings.dart | 188 -- .../lib/src/web/isar_collection_impl.dart | 266 -- .../packages/isar/lib/src/web/isar_impl.dart | 135 - .../isar/lib/src/web/isar_link_impl.dart | 75 - .../isar/lib/src/web/isar_reader_impl.dart | 347 --- .../packages/isar/lib/src/web/isar_web.dart | 48 - .../isar/lib/src/web/isar_writer_impl.dart | 171 -- .../packages/isar/lib/src/web/open.dart | 82 - .../isar/lib/src/web/query_build.dart | 375 --- .../packages/isar/lib/src/web/query_impl.dart | 180 -- .../isar/lib/src/web/split_words.dart | 5 - .../isar-3.1.0-1/packages/isar/pubspec.yaml | 23 - .../isar/test/isar_reader_writer_test.dart | 287 --- .../packages/isar/tool/get_version.dart | 6 - .../isar/tool/verify_release_version.dart | 9 - .../packages/isar_flutter_libs/.pubignore | 5 - .../packages/isar_flutter_libs/CHANGELOG.md | 1 - .../packages/isar_flutter_libs/LICENSE | 202 -- .../packages/isar_flutter_libs/README.md | 1 - .../isar_flutter_libs/android/.gitignore | 8 - .../isar_flutter_libs/android/build.gradle | 36 - .../android/gradle.properties | 3 - .../gradle/wrapper/gradle-wrapper.properties | 6 - .../isar_flutter_libs/android/settings.gradle | 1 - .../android/src/main/AndroidManifest.xml | 3 - .../IsarFlutterLibsPlugin.java | 13 - .../packages/isar_flutter_libs/ios/.gitignore | 38 - .../isar_flutter_libs/ios/Assets/.gitkeep | 0 .../ios/Classes/IsarFlutterLibsPlugin.h | 4 - .../ios/Classes/IsarFlutterLibsPlugin.m | 15 - .../Classes/SwiftIsarFlutterLibsPlugin.swift | 16 - .../isar_flutter_libs/ios/Classes/binding.h | 6 - .../ios/isar_flutter_libs.podspec | 17 - .../lib/isar_flutter_libs.dart | 0 .../isar_flutter_libs/linux/CMakeLists.txt | 25 - .../isar_flutter_libs_plugin.h | 26 - .../linux/isar_flutter_libs_plugin.cc | 70 - .../macos/Classes/IsarFlutterLibsPlugin.swift | 19 - .../macos/isar_flutter_libs.podspec | 17 - .../packages/isar_flutter_libs/pubspec.yaml | 33 - .../isar_flutter_libs/pubspec_overrides.yaml | 3 - .../isar_flutter_libs/windows/.gitignore | 17 - .../isar_flutter_libs/windows/CMakeLists.txt | 24 - .../isar_flutter_libs_plugin.h | 23 - .../windows/isar_flutter_libs_plugin.cpp | 82 - packages_external/isar-3.1.0-1/tool/build.sh | 22 - .../isar-3.1.0-1/tool/build_android.sh | 60 - .../isar-3.1.0-1/tool/build_ios.sh | 15 - .../isar-3.1.0-1/tool/build_linux.sh | 9 - .../isar-3.1.0-1/tool/build_macos.sh | 8 - .../isar-3.1.0-1/tool/build_windows.sh | 9 - .../isar-3.1.0-1/tool/cbindgen.toml | 8 - .../isar-3.1.0-1/tool/download_binaries.sh | 18 - .../isar-3.1.0-1/tool/ffigen.yaml | 27 - .../isar-3.1.0-1/tool/generate_bindings.sh | 13 - .../isar-3.1.0-1/tool/prepare_tests.sh | 6 - 113 files changed, 15313 deletions(-) delete mode 100644 packages_external/isar-3.1.0-1/.all-contributorsrc delete mode 100644 packages_external/isar-3.1.0-1/.gitignore delete mode 100644 packages_external/isar-3.1.0-1/Cargo.toml delete mode 100644 packages_external/isar-3.1.0-1/LICENSE delete mode 100644 packages_external/isar-3.1.0-1/README.md delete mode 100644 packages_external/isar-3.1.0-1/TODO.md delete mode 100644 packages_external/isar-3.1.0-1/packages/isar/.gitignore delete mode 100644 packages_external/isar-3.1.0-1/packages/isar/CHANGELOG.md delete mode 100644 packages_external/isar-3.1.0-1/packages/isar/LICENSE delete mode 100644 packages_external/isar-3.1.0-1/packages/isar/README.md delete mode 100644 packages_external/isar-3.1.0-1/packages/isar/analysis_options.yaml delete mode 100644 packages_external/isar-3.1.0-1/packages/isar/example/README.md delete mode 100644 packages_external/isar-3.1.0-1/packages/isar/lib/isar.dart delete mode 100644 packages_external/isar-3.1.0-1/packages/isar/lib/src/annotations/backlink.dart delete mode 100644 packages_external/isar-3.1.0-1/packages/isar/lib/src/annotations/collection.dart delete mode 100644 packages_external/isar-3.1.0-1/packages/isar/lib/src/annotations/embedded.dart delete mode 100644 packages_external/isar-3.1.0-1/packages/isar/lib/src/annotations/enumerated.dart delete mode 100644 packages_external/isar-3.1.0-1/packages/isar/lib/src/annotations/ignore.dart delete mode 100644 packages_external/isar-3.1.0-1/packages/isar/lib/src/annotations/index.dart delete mode 100644 packages_external/isar-3.1.0-1/packages/isar/lib/src/annotations/name.dart delete mode 100644 packages_external/isar-3.1.0-1/packages/isar/lib/src/annotations/type.dart delete mode 100644 packages_external/isar-3.1.0-1/packages/isar/lib/src/common/isar_common.dart delete mode 100644 packages_external/isar-3.1.0-1/packages/isar/lib/src/common/isar_link_base_impl.dart delete mode 100644 packages_external/isar-3.1.0-1/packages/isar/lib/src/common/isar_link_common.dart delete mode 100644 packages_external/isar-3.1.0-1/packages/isar/lib/src/common/isar_links_common.dart delete mode 100644 packages_external/isar-3.1.0-1/packages/isar/lib/src/common/schemas.dart delete mode 100644 packages_external/isar-3.1.0-1/packages/isar/lib/src/isar.dart delete mode 100644 packages_external/isar-3.1.0-1/packages/isar/lib/src/isar_collection.dart delete mode 100644 packages_external/isar-3.1.0-1/packages/isar/lib/src/isar_connect.dart delete mode 100644 packages_external/isar-3.1.0-1/packages/isar/lib/src/isar_connect_api.dart delete mode 100644 packages_external/isar-3.1.0-1/packages/isar/lib/src/isar_error.dart delete mode 100644 packages_external/isar-3.1.0-1/packages/isar/lib/src/isar_link.dart delete mode 100644 packages_external/isar-3.1.0-1/packages/isar/lib/src/isar_reader.dart delete mode 100644 packages_external/isar-3.1.0-1/packages/isar/lib/src/isar_writer.dart delete mode 100644 packages_external/isar-3.1.0-1/packages/isar/lib/src/native/bindings.dart delete mode 100644 packages_external/isar-3.1.0-1/packages/isar/lib/src/native/encode_string.dart delete mode 100644 packages_external/isar-3.1.0-1/packages/isar/lib/src/native/index_key.dart delete mode 100644 packages_external/isar-3.1.0-1/packages/isar/lib/src/native/isar_collection_impl.dart delete mode 100644 packages_external/isar-3.1.0-1/packages/isar/lib/src/native/isar_core.dart delete mode 100644 packages_external/isar-3.1.0-1/packages/isar/lib/src/native/isar_impl.dart delete mode 100644 packages_external/isar-3.1.0-1/packages/isar/lib/src/native/isar_link_impl.dart delete mode 100644 packages_external/isar-3.1.0-1/packages/isar/lib/src/native/isar_reader_impl.dart delete mode 100644 packages_external/isar-3.1.0-1/packages/isar/lib/src/native/isar_writer_impl.dart delete mode 100644 packages_external/isar-3.1.0-1/packages/isar/lib/src/native/open.dart delete mode 100644 packages_external/isar-3.1.0-1/packages/isar/lib/src/native/query_build.dart delete mode 100644 packages_external/isar-3.1.0-1/packages/isar/lib/src/native/query_impl.dart delete mode 100644 packages_external/isar-3.1.0-1/packages/isar/lib/src/native/split_words.dart delete mode 100644 packages_external/isar-3.1.0-1/packages/isar/lib/src/native/txn.dart delete mode 100644 packages_external/isar-3.1.0-1/packages/isar/lib/src/query.dart delete mode 100644 packages_external/isar-3.1.0-1/packages/isar/lib/src/query_builder.dart delete mode 100644 packages_external/isar-3.1.0-1/packages/isar/lib/src/query_builder_extensions.dart delete mode 100644 packages_external/isar-3.1.0-1/packages/isar/lib/src/query_components.dart delete mode 100644 packages_external/isar-3.1.0-1/packages/isar/lib/src/schema/collection_schema.dart delete mode 100644 packages_external/isar-3.1.0-1/packages/isar/lib/src/schema/index_schema.dart delete mode 100644 packages_external/isar-3.1.0-1/packages/isar/lib/src/schema/link_schema.dart delete mode 100644 packages_external/isar-3.1.0-1/packages/isar/lib/src/schema/property_schema.dart delete mode 100644 packages_external/isar-3.1.0-1/packages/isar/lib/src/schema/schema.dart delete mode 100644 packages_external/isar-3.1.0-1/packages/isar/lib/src/web/bindings.dart delete mode 100644 packages_external/isar-3.1.0-1/packages/isar/lib/src/web/isar_collection_impl.dart delete mode 100644 packages_external/isar-3.1.0-1/packages/isar/lib/src/web/isar_impl.dart delete mode 100644 packages_external/isar-3.1.0-1/packages/isar/lib/src/web/isar_link_impl.dart delete mode 100644 packages_external/isar-3.1.0-1/packages/isar/lib/src/web/isar_reader_impl.dart delete mode 100644 packages_external/isar-3.1.0-1/packages/isar/lib/src/web/isar_web.dart delete mode 100644 packages_external/isar-3.1.0-1/packages/isar/lib/src/web/isar_writer_impl.dart delete mode 100644 packages_external/isar-3.1.0-1/packages/isar/lib/src/web/open.dart delete mode 100644 packages_external/isar-3.1.0-1/packages/isar/lib/src/web/query_build.dart delete mode 100644 packages_external/isar-3.1.0-1/packages/isar/lib/src/web/query_impl.dart delete mode 100644 packages_external/isar-3.1.0-1/packages/isar/lib/src/web/split_words.dart delete mode 100644 packages_external/isar-3.1.0-1/packages/isar/pubspec.yaml delete mode 100644 packages_external/isar-3.1.0-1/packages/isar/test/isar_reader_writer_test.dart delete mode 100644 packages_external/isar-3.1.0-1/packages/isar/tool/get_version.dart delete mode 100644 packages_external/isar-3.1.0-1/packages/isar/tool/verify_release_version.dart delete mode 100644 packages_external/isar-3.1.0-1/packages/isar_flutter_libs/.pubignore delete mode 100644 packages_external/isar-3.1.0-1/packages/isar_flutter_libs/CHANGELOG.md delete mode 100644 packages_external/isar-3.1.0-1/packages/isar_flutter_libs/LICENSE delete mode 100644 packages_external/isar-3.1.0-1/packages/isar_flutter_libs/README.md delete mode 100644 packages_external/isar-3.1.0-1/packages/isar_flutter_libs/android/.gitignore delete mode 100644 packages_external/isar-3.1.0-1/packages/isar_flutter_libs/android/build.gradle delete mode 100644 packages_external/isar-3.1.0-1/packages/isar_flutter_libs/android/gradle.properties delete mode 100644 packages_external/isar-3.1.0-1/packages/isar_flutter_libs/android/gradle/wrapper/gradle-wrapper.properties delete mode 100644 packages_external/isar-3.1.0-1/packages/isar_flutter_libs/android/settings.gradle delete mode 100644 packages_external/isar-3.1.0-1/packages/isar_flutter_libs/android/src/main/AndroidManifest.xml delete mode 100644 packages_external/isar-3.1.0-1/packages/isar_flutter_libs/android/src/main/java/dev/isar/isar_flutter_libs/IsarFlutterLibsPlugin.java delete mode 100644 packages_external/isar-3.1.0-1/packages/isar_flutter_libs/ios/.gitignore delete mode 100644 packages_external/isar-3.1.0-1/packages/isar_flutter_libs/ios/Assets/.gitkeep delete mode 100644 packages_external/isar-3.1.0-1/packages/isar_flutter_libs/ios/Classes/IsarFlutterLibsPlugin.h delete mode 100644 packages_external/isar-3.1.0-1/packages/isar_flutter_libs/ios/Classes/IsarFlutterLibsPlugin.m delete mode 100644 packages_external/isar-3.1.0-1/packages/isar_flutter_libs/ios/Classes/SwiftIsarFlutterLibsPlugin.swift delete mode 100644 packages_external/isar-3.1.0-1/packages/isar_flutter_libs/ios/Classes/binding.h delete mode 100644 packages_external/isar-3.1.0-1/packages/isar_flutter_libs/ios/isar_flutter_libs.podspec delete mode 100644 packages_external/isar-3.1.0-1/packages/isar_flutter_libs/lib/isar_flutter_libs.dart delete mode 100644 packages_external/isar-3.1.0-1/packages/isar_flutter_libs/linux/CMakeLists.txt delete mode 100644 packages_external/isar-3.1.0-1/packages/isar_flutter_libs/linux/include/isar_flutter_libs/isar_flutter_libs_plugin.h delete mode 100644 packages_external/isar-3.1.0-1/packages/isar_flutter_libs/linux/isar_flutter_libs_plugin.cc delete mode 100644 packages_external/isar-3.1.0-1/packages/isar_flutter_libs/macos/Classes/IsarFlutterLibsPlugin.swift delete mode 100644 packages_external/isar-3.1.0-1/packages/isar_flutter_libs/macos/isar_flutter_libs.podspec delete mode 100644 packages_external/isar-3.1.0-1/packages/isar_flutter_libs/pubspec.yaml delete mode 100644 packages_external/isar-3.1.0-1/packages/isar_flutter_libs/pubspec_overrides.yaml delete mode 100644 packages_external/isar-3.1.0-1/packages/isar_flutter_libs/windows/.gitignore delete mode 100644 packages_external/isar-3.1.0-1/packages/isar_flutter_libs/windows/CMakeLists.txt delete mode 100644 packages_external/isar-3.1.0-1/packages/isar_flutter_libs/windows/include/isar_flutter_libs/isar_flutter_libs_plugin.h delete mode 100644 packages_external/isar-3.1.0-1/packages/isar_flutter_libs/windows/isar_flutter_libs_plugin.cpp delete mode 100644 packages_external/isar-3.1.0-1/tool/build.sh delete mode 100644 packages_external/isar-3.1.0-1/tool/build_android.sh delete mode 100644 packages_external/isar-3.1.0-1/tool/build_ios.sh delete mode 100644 packages_external/isar-3.1.0-1/tool/build_linux.sh delete mode 100644 packages_external/isar-3.1.0-1/tool/build_macos.sh delete mode 100644 packages_external/isar-3.1.0-1/tool/build_windows.sh delete mode 100644 packages_external/isar-3.1.0-1/tool/cbindgen.toml delete mode 100644 packages_external/isar-3.1.0-1/tool/download_binaries.sh delete mode 100644 packages_external/isar-3.1.0-1/tool/ffigen.yaml delete mode 100644 packages_external/isar-3.1.0-1/tool/generate_bindings.sh delete mode 100644 packages_external/isar-3.1.0-1/tool/prepare_tests.sh diff --git a/packages_external/isar-3.1.0-1/.all-contributorsrc b/packages_external/isar-3.1.0-1/.all-contributorsrc deleted file mode 100644 index c75bdc9d..00000000 --- a/packages_external/isar-3.1.0-1/.all-contributorsrc +++ /dev/null @@ -1,214 +0,0 @@ -{ - "files": [ - "packages/isar/README.md" - ], - "imageSize": 100, - "commit": false, - "contributors": [ - { - "login": "Jtplouffe", - "name": "JT", - "avatar_url": "https://avatars.githubusercontent.com/u/32107801?v=4", - "profile": "https://github.com/Jtplouffe", - "contributions": [ - "test", - "bug" - ] - }, - { - "login": "leisim", - "name": "Simon Leier", - "avatar_url": "https://avatars.githubusercontent.com/u/13610195?v=4", - "profile": "https://www.linkedin.com/in/simon-leier/", - "contributions": [ - "bug", - "code", - "doc", - "test", - "example" - ] - }, - { - "login": "h1376h", - "name": "Hamed H.", - "avatar_url": "https://avatars.githubusercontent.com/u/3498335?v=4", - "profile": "https://github.com/h1376h", - "contributions": [ - "code", - "maintenance" - ] - }, - { - "login": "Viper-Bit", - "name": "Peyman", - "avatar_url": "https://avatars.githubusercontent.com/u/24822764?v=4", - "profile": "https://github.com/Viper-Bit", - "contributions": [ - "bug", - "code" - ] - }, - { - "login": "blendthink", - "name": "blendthink", - "avatar_url": "https://avatars.githubusercontent.com/u/32213113?v=4", - "profile": "https://github.com/blendthink", - "contributions": [ - "maintenance" - ] - }, - { - "login": "Moseco", - "name": "Moseco", - "avatar_url": "https://avatars.githubusercontent.com/u/10720298?v=4", - "profile": "https://github.com/Moseco", - "contributions": [ - "bug" - ] - }, - { - "login": "Frostedfox", - "name": "Frostedfox", - "avatar_url": "https://avatars.githubusercontent.com/u/84601232?v=4", - "profile": "https://github.com/Frostedfox", - "contributions": [ - "doc" - ] - }, - { - "login": "nohli", - "name": "Joachim Nohl", - "avatar_url": "https://avatars.githubusercontent.com/u/43643339?v=4", - "profile": "http://achim.io", - "contributions": [ - "maintenance" - ] - }, - { - "login": "VoidxHoshi", - "name": "LaLucid", - "avatar_url": "https://avatars.githubusercontent.com/u/55886143?v=4", - "profile": "https://github.com/VoidxHoshi", - "contributions": [ - "maintenance" - ] - }, - { - "login": "vothvovo", - "name": "Johnson", - "avatar_url": "https://avatars.githubusercontent.com/u/20894472?v=4", - "profile": "https://github.com/vothvovo", - "contributions": [ - "bug" - ] - }, - { - "login": "ika020202", - "name": "Ura", - "avatar_url": "https://avatars.githubusercontent.com/u/42883378?v=4", - "profile": "https://zenn.dev/urasan", - "contributions": [ - "translation" - ] - }, - { - "login": "mnkeis", - "name": "mnkeis", - "avatar_url": "https://avatars.githubusercontent.com/u/41247357?v=4", - "profile": "https://github.com/mnkeis", - "contributions": [ - "translation" - ] - }, - { - "login": "CarloDotLog", - "name": "Carlo Loguercio", - "avatar_url": "https://avatars.githubusercontent.com/u/13763473?v=4", - "profile": "https://github.com/CarloDotLog", - "contributions": [ - "translation" - ] - }, - { - "login": "hafeezrana", - "name": "Hafeez Rana", - "avatar_url": "https://avatars.githubusercontent.com/u/87476445?v=4", - "profile": "https://g.dev/hafeezrana", - "contributions": [ - "doc" - ] - }, - { - "login": "inkomomutane", - "name": "Nelson Mutane", - "avatar_url": "https://avatars.githubusercontent.com/u/57417802?v=4", - "profile": "https://github.com/inkomomutane", - "contributions": [ - "translation" - ] - }, - { - "login": "lodisy", - "name": "Michael", - "avatar_url": "https://avatars.githubusercontent.com/u/8101584?v=4", - "profile": "https://github.com/lodisy", - "contributions": [ - "translation" - ] - }, - { - "login": "ritksm", - "name": "Jack Rivers", - "avatar_url": "https://avatars.githubusercontent.com/u/111809?v=4", - "profile": "http://blog.jackrivers.me/", - "contributions": [ - "translation" - ] - }, - { - "login": "buraktabn", - "name": "Burak", - "avatar_url": "https://avatars.githubusercontent.com/u/49204989?v=4", - "profile": "http://buraktaban.ca", - "contributions": [ - "bug" - ] - }, - { - "login": "AlexisL61", - "name": "Alexis", - "avatar_url": "https://avatars.githubusercontent.com/u/30233189?v=4", - "profile": "https://github.com/AlexisL61", - "contributions": [ - "bug" - ] - }, - { - "login": "letyletylety", - "name": "Lety", - "avatar_url": "https://avatars.githubusercontent.com/u/16468579?v=4", - "profile": "https://letyarch.blogspot.com/", - "contributions": [ - "doc" - ] - }, - { - "login": "nobkd", - "name": "nobkd", - "avatar_url": "https://avatars.githubusercontent.com/u/44443899?v=4", - "profile": "https://github.com/nobkd", - "contributions": [ - "doc" - ] - } - ], - "contributorTemplate": "\">\" width=\"<%= options.imageSize %>px;\" alt=\"\"/>
<%= contributor.name %>
", - "contributorsPerLine": 7, - "contributorsSortAlphabetically": true, - "projectName": "isar", - "projectOwner": "isar", - "repoType": "github", - "repoHost": "https://github.com", - "skipCi": true, - "commitConvention": "angular" -} diff --git a/packages_external/isar-3.1.0-1/.gitignore b/packages_external/isar-3.1.0-1/.gitignore deleted file mode 100644 index bda0b43a..00000000 --- a/packages_external/isar-3.1.0-1/.gitignore +++ /dev/null @@ -1,74 +0,0 @@ -# Miscellaneous -*.class -*.lock -*.log -.DS_Store -.vscode/ -.idea - -# Dart related -.dart_tool/ -.flutter-plugins -.flutter-plugins-dependencies -**/generated_plugin_registrant.dart -.packages -.pub-cache/ -.pub/ -build/ - -# Rust related -target/ -*.a -*.so -*.dylib -*.dll -*.zip -*.xcframework/ -isar-dart.h - -# Android related -**/android/**/gradle-wrapper.jar -.gradle/ -**/android/captures/ -**/android/gradlew -**/android/gradlew.bat -**/android/local.properties -**/android/**/GeneratedPluginRegistrant.java - -# iOS/XCode related -**/ios/**/*.mode1v3 -**/ios/**/*.mode2v3 -**/ios/**/*.moved-aside -**/ios/**/*.pbxuser -**/ios/**/*.perspectivev3 -**/ios/**/*sync/ -**/ios/**/.sconsign.dblite -**/ios/**/.tags* -**/ios/**/.vagrant/ -**/ios/**/DerivedData/ -**/ios/**/Icon? -**/ios/**/Pods/ -**/ios/**/.symlinks/ -**/ios/**/profile -**/ios/**/xcuserdata -**/ios/.generated/ -**/ios/Flutter/.last_build_id -**/ios/Flutter/App.framework -**/ios/Flutter/Flutter.framework -**/ios/Flutter/Flutter.podspec -**/ios/Flutter/Generated.xcconfig -**/ios/Flutter/ephemeral -**/ios/Flutter/app.flx -**/ios/Flutter/app.zip -**/ios/Flutter/flutter_assets/ -**/ios/Flutter/flutter_export_environment.sh -**/ios/ServiceDefinitions.json -**/ios/Runner/GeneratedPluginRegistrant.* - -# macOS -**/macos/Flutter/GeneratedPluginRegistrant.swift -**/ephemeral -**/.plugin_symlinks/ - -# Coverage -coverage/ diff --git a/packages_external/isar-3.1.0-1/Cargo.toml b/packages_external/isar-3.1.0-1/Cargo.toml deleted file mode 100644 index df62b1bd..00000000 --- a/packages_external/isar-3.1.0-1/Cargo.toml +++ /dev/null @@ -1,12 +0,0 @@ -[workspace] -members = [ - "packages/isar_core", - "packages/isar_core_ffi", - "packages/mdbx_sys" -] - -[profile.release] -lto = true -codegen-units = 1 -panic = "abort" -strip = "symbols" \ No newline at end of file diff --git a/packages_external/isar-3.1.0-1/LICENSE b/packages_external/isar-3.1.0-1/LICENSE deleted file mode 100644 index 7a4a3ea2..00000000 --- a/packages_external/isar-3.1.0-1/LICENSE +++ /dev/null @@ -1,202 +0,0 @@ - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. \ No newline at end of file diff --git a/packages_external/isar-3.1.0-1/README.md b/packages_external/isar-3.1.0-1/README.md deleted file mode 100644 index 0f4dcb03..00000000 --- a/packages_external/isar-3.1.0-1/README.md +++ /dev/null @@ -1 +0,0 @@ -packages/isar/README.md \ No newline at end of file diff --git a/packages_external/isar-3.1.0-1/TODO.md b/packages_external/isar-3.1.0-1/TODO.md deleted file mode 100644 index b89f04e3..00000000 --- a/packages_external/isar-3.1.0-1/TODO.md +++ /dev/null @@ -1,110 +0,0 @@ -

Roadmap and TODOs

- - -# Documentation - -## API Docs - -- [ ] Document all public APIs - -## Schema - -- [x] Update schema migration instructions -- [ ] Document all annotation options - -## CRUD - -- [ ] Document sync operations -- [x] `getAll()`, `putAll`, `deleteAll()` -- [ ] `getBy...()`, `deleteBy...()` - -## Queries - -- [x] Filter groups -- [x] Boolean operators `and()`, `or()`, `not()` -- [x] Offset, limit -- [x] Distinct where clauses -- [x] Different filter operations (`equalTo`, `beginsWith()` etc.) -- [ ] Better explanation for distinct and sorted where clauses -- [ ] Watching queries - -## Indexes - -- [ ] Intro -- [x] What are they -- [ ] Why use them -- [x] How to in isar? - -## Examples - -- [ ] Create minimal example -- [ ] Create complex example with indexes, filter groups etc. -- [ ] More Sample Apps - -## Tutorials - -- [ ] How to write fast queries -- [ ] Build a simple offline first app -- [ ] Advanced queries - - ----- - - -# Isar Dart - -## Features - -- [x] Distinct by -- [x] Offset, Limit -- [x] Sorted by - -## Fixes - -- [x] Provide an option to change collection accessor names - -## Unit tests - -- [x] Download binaries automatically for tests - -### Queries - -- [x] Restructure query tests to make them less verbose -- [x] Define models that can be reused across tests -- [x] Where clauses with string indexes (value, hash, words, case-sensitive) -- [x] Distinct where clauses -- [x] String filter operations - - ----- - - -# Isar Core - -## Features (low priority) - -- [ ] Draft Synchronization -- [x] Relationships - -## Unit tests - -- [ ] Make mdbx unit tests bulletproof -- [x] Migration tests -- [x] Binary format -- [x] CRUD -- [x] Links -- [ ] QueryBuilder -- [ ] WhereClause -- [ ] WhereExecutor -- [x] CollectionMigrator -- [ ] Watchers - - ----- - - -# Isar Web - -- [ ] MVP - - diff --git a/packages_external/isar-3.1.0-1/packages/isar/.gitignore b/packages_external/isar-3.1.0-1/packages/isar/.gitignore deleted file mode 100644 index 25361338..00000000 --- a/packages_external/isar-3.1.0-1/packages/isar/.gitignore +++ /dev/null @@ -1 +0,0 @@ -*.g.dart \ No newline at end of file diff --git a/packages_external/isar-3.1.0-1/packages/isar/CHANGELOG.md b/packages_external/isar-3.1.0-1/packages/isar/CHANGELOG.md deleted file mode 100644 index c88e534e..00000000 --- a/packages_external/isar-3.1.0-1/packages/isar/CHANGELOG.md +++ /dev/null @@ -1,431 +0,0 @@ -## 3.1.0+1 - -### Fixes - -- Fixed error building MacOS library - -## 3.1.0 - -### Breaking - -Sorry for this breaking change. Unfortunately, it was necessary to fix stability issues on Android. - -- `directory` is now required for `Isar.open()` and `Isar.openSync()` - -### Fixes - -- Fixed a crash that occasionally occurred when opening Isar -- Fixed a schema migration issue -- Fixed an issue where embedded class renaming didn't work correctly - -### Enhancements - -- Many internal improvements -- Performance improvements - -## 3.0.6 - -### Fixes - -- Add check to verify transactions are used for correct instance -- Add check to verify that async transactions are still active -- Fix upstream issue with opening databases - -## 3.0.5 - -### Enhancements - -- Improved performance for all operations -- Added `maxSizeMiB` option to `Isar.open()` to specify the maximum size of the database file -- Significantly reduced native library size -- With the help of the community, the docs have been translated into a range of languages -- Improved API docs -- Added integration tests for more platforms to ensure high-quality releases -- Support for unicode paths on Windows - -### Fixes - -- Fixed crash while opening Isar -- Fixed crash on older Android devices -- Fixed a native port that was not closed correctly in some cases -- Added swift version to podspec -- Fixed crash on Windows -- Fixed "IndexNotFound" error - -## 3.0.4 - -REDACTED. - -## 3.0.3 - -REDACTED. - -## 3.0.2 - -### Enhancements - -- The Inspector now supports creating objects and importing JSON -- Added Inspector check to make sure Chrome is used - -### Fixes - -- Added support for the latest analyzer -- Fixed native ports that were not closed correctly in some cases -- Added support for Ubuntu 18.04 and older -- Fixed issue with aborting transactions -- Fixed crash when invalid JSON was provided to `importJsonRaw()` -- Added missing `exportJsonSync()` and `exportJsonRawSync()` -- Fixed issue where secondary instance could not be selected in the Inspector - -## 3.0.1 - -### Enhancements - -- Support for arm64 iOS Simulators - -### Fixes - -- Fixed issue where `.anyOf()`, `.allOf()`, and `.oneOf()` could not be negated -- Fixed too low min-iOS version. The minimum supported is 11.0 -- Fixed error during macOS App Store build - -## 3.0.0 - -This release has been a lot of work! Thanks to everyone who contributed and joined the countless discussions. You are really awesome! - -Special thanks to [@Jtplouffe](https://github.com/Jtplouffe) and [@Peyman](https://github.com/Viper-Bit) for their incredible work. - -### Web support - -This version does not support the web target yet. It will be back in the next version. Please continue using 2.5.0 if you need web support. - -### Enhancements - -- Completely new Isar inspector that does not need to be installed anymore -- Extreme performance improvements for almost all operations (up to 50%) -- Support for embedded objects using `@embedded` -- Support for enums using `@enumerated` -- Vastly improved Isar binary format space efficiency resulting in about 20% smaller databases -- Added `id`, `byte`, `short` and `float` typedefs -- `IsarLinks` now support all `Set` methods based on the Isar `Id` of objects -- Added `download` option to `Isar.initializeIsarCore()` to download binaries automatically -- Added `replace` option for indexes -- Added verification for correct Isar binary version -- Added `collection.getSize()` and `collection.getSizeSync()` -- Added `query.anyOf()` and `query.allOf()` query modifiers -- Support for much more complex composite index queries -- Support for logical XOR and the `.oneOf()` query modifier -- Made providing a path optional -- The default Isar name is now `default` and stored in `dir/name.isar` and `dir/name.isar.lock` -- On non-web platforms, `IsarLink` and `IsarLinks` will load automatically -- `.putSync()`, `.putAllSync()` etc. will now save links recursively by default -- Added `isar.getSize()` and `isar.getSizeSync()` -- Added `linksLengthEqualTo()`, `linksIsEmpty()`, `linksIsNotEmpty()`, `linksLengthGreaterThan()`, `linksLengthLessThan()`, `linksLengthBetween()` and `linkIsNull()` filters -- Added `listLengthEqualTo()`, `listIsEmpty()`, `listIsNotEmpty()`, `listLengthGreaterThan()`, `listLengthLessThan()`, `listLengthBetween()` filters -- Added `isNotNull()` filters -- Added `compactOnLaunch` conditions to `Isar.open()` for automatic database compaction -- Added `isar.copyToFile()` which copies a compacted version of the database to a path -- Added check to verify that linked collections schemas are provided for opening an instance -- Apply default values from constructor during deserialization -- Added `isar.verify()` and `col.verify()` methods for checking database integrity in unit tests -- Added missing float and double queries and an `epsilon` parameter - -### Breaking changes - -- Removed `TypeConverter` support in favor of `@embedded` and `@enumerated` -- Removed `@Id()` and `@Size32()` annotations in favor of the `Id` and `short` types -- Changed the `schemas` parameter from named to positional -- The maximum size of objects is now 16MB -- Removed `replaceOnConflict` and `saveLinks` parameter from `collection.put()` and `collection.putAll()` -- Removed `isar` parameter from `Isar.txn()`, `Isar.writeTxn()`, `Isar.txnSync()` and `Isar.writeTxnSync()` -- Removed `query.repeat()` -- Removed `query.sortById()` and `query.distinctById()` -- Fixed `.or()` instead of `.and()` being used implicitly when combining filters -- Renamed multi-entry where clauses from `.yourListAnyEqualTo()` to `.yourListElementEqualTo()` to avoid confusion -- Isar will no longer create the provided directory. Make sure it exists before opening an Isar Instance. -- Changed the default index type for all `List`s to `IndexType.hash` -- Renamed `isar.getCollection()` to `isar.collection()` -- It is no longer allowed to extend or implement another collection -- Unsupported properties will no longer be ignored by default -- Renamed the `initialReturn` parameter to `fireImmediately` -- Renamed `Isar.initializeLibraries()` to `Isar.initializeIsarCore()` - -### Fixes - -There are too many fixes to list them all. - -- A lot of link fixes and a slight behavior change to make them super reliable -- Fixed missing symbols on older Android phones -- Fixed composite queries -- Fixed various generator issues -- Fixed error retrieving the id property in a query -- Fixed missing symbols on 32-bit Android 5 & 6 devices -- Fixed inconsistent `null` handling in json export -- Fixed default directory issue on Android -- Fixed different where clauses returning duplicate results -- Fixed hash index issue where multiple list values resulted in the same hash -- Fixed edge case where creating a new index failed - -## 2.5.0 - -### Enhancements - -- Support for Android x86 (32 bit emulator) and macOS arm64 (Apple Silicon) -- Greatly improved test coverage for sync methods -- `col.clear()` now resets the auto increment counter to `0` -- Significantly reduced Isar Core binary size (about 1.4MB -> 800KB) - -### Minor Breaking - -- Changed `initializeLibraries(Map libraries)` to `initializeLibraries(Map libraries)` -- Changed min Dart SDK to `2.16.0` - -### Fixes - -- Fixed issue with `IsarLink.saveSync()` -- Fixed `id` queries -- Fixed error thrown by `BroadcastChannel` in Firefox -- Fixed Isar Inspector connection issue - -## 2.4.0 - -### Enhancements - -- Support for querying links -- Support for filtering and sorting links -- Added methods to update and count links without loading them -- Added `isLoaded` property to links -- Added methods to count the number of objects in a collection -- Big internal improvements - -### Minor Breaking - -- There are now different kinds of where clauses for dynamic queries -- `isar.getCollection()` no longer requires the name of the collection -- `Isar.instanceNames` now returns a `Set` instead of a `List` - -### Fixes - -- Fixed iOS crash that frequently happened on older devices -- Fixed 32bit issue on Android -- Fixed link issues -- Fixed missing `BroadcastChannel` API for older Safari versions - -## 2.2.1 - -### Enhancements - -- Reduced Isar web code size by 50% -- Made `directory` parameter of `Isar.open()` optional for web -- Made `name` parameter of `Isar.getInstance()` optional -- Added `Isar.defaultName` constant -- Enabled `TypeConverter`s with supertypes -- Added message if `TypeConverter` nullability doesn't match -- Added more tests - -### Fixes - -- Fixed issue with date queries -- Fixed `FilterGroup.not` constructor (thanks for the PR @jtzell) - -## 2.2.0 - -Isar now has full web support 🎉. No changes to your code required, just run it. - -_Web passes all unit tests but is still considered beta for now._ - -### Minor Breaking - -- Added `saveLinks` parameter to `.put()` and `.putAll()` which defaults to `false` -- Changed default `overrideChanges` parameter of `links.load()` to `true` to avoid unintended behavior - -### Enhancements - -- Full web support! -- Improved write performance -- Added `deleteFromDisk` option to `isar.close()` -- Added `.reset()` and `.resetSync()` methods to `IsarLink` and `IsarLinks` -- Improved `links.save()` performance -- Added many tests - -### Fixed - -- Fixed value of `null` dates to be `DateTime.fromMillisecondsSinceEpoch(0)` -- Fixed problem with migration -- Fixed incorrect list values for new properties (`[]` instead of `null`) -- Improved handling of link edge-cases - -## 2.1.4 - -- Removed `path` dependency -- Fixed incorrect return value of `deleteByIndex()` -- Fixed wrong auto increment ids in some cases (thanks @robban112) -- Fixed an issue with `Isar.close()` (thanks @msxenon) -- Fixed `$` escaping in generated code (thanks @jtzell) -- Fixed broken link in pub.dev example page - -## 2.1.0 - -`isar_connect` is now integrated into `isar` - -### Enhancements - -- Added check for outdated generated files -- Added check for changed schema across isolates -- Added `Isar.openSync()` -- Added `col.importJsonRawSync()`, `col.importJsonSync()`, `query.exportJsonRawSync()`, `query.exportJsonSync()` -- Improved performance for queries -- Improved handling of ffi memory -- More tests - -### Fixed - -- Fixed issue where imported json required existing ids -- Fixed issue with transaction handling (thanks @Peng-Qian for the awesome help) -- Fixed issue with `@Ignore` annotation not always working -- Fixed issue with `getByIndex()` not returning correct object id (thanks @jtzell) - -## 2.0.0 - -### Breaking - -- The id for non-final objects is now assigned automatically after `.put()` and `.putSync()` -- `double` and `List` indexes can no longer be at the beginning of a composite index -- `List` indexes can no longer be hashed -- `.greaterThan()`, `.lessThan()` and `.between()` filters and are now excluding for `double` values (`>=` -> `>`) -- Changed the default index type for lists to `IndexType.value` -- `IsarLink` and `IsarLinks` will no longer be initialized by Isar and must not be `nullable` or `late`. -- Dart `2.14` or higher is required - -### Enhancements - -- Added API docs for all public methods -- Added `isar.clear()`, `isar.clearSync()`, `col.clear()` and `col.clearSync()` -- Added `col.filter()` as shortcut for `col.where().filter()` -- Added `include` parameter to `.greaterThan()` and `.lessThan()` filters and where clauses -- Added `includeLower` and `includeUpper` parameters to `.between()` filters and where clauses -- Added `Isar.autoIncrement` to allow non-nullable auto-incrementing ids -- `Isar.close()` now returns whether the last instance was closed -- List values in composite indexes are now of type `IndexType.hash` automatically -- Allowed multiple indexes on the same property -- Removed exported packages from API docs -- Improved generated code -- Improved Isar Core error messages -- Minor performance improvements -- Automatic XCode configuration -- Updated analyzer to `3.0.0` -- More tests - -### Fixed - -- `IsarLink` and `IsarLinks` can now be final -- Fixed multi-entry index queries returning items multiple times in some cases -- Fixed `.anyLessThan()` and `.anyGreaterThan()` issues -- Fixed issues with backlinks -- Fixed issue where query only returned the first `99999` results -- Fixed issue with id where clauses -- Fixed default index type for lists and bytes -- Fixed issue where renaming indexes was not possible -- Fixed issue where wrong index name was used for `.getByX()` and `.deleteByX()` -- Fixed issue where composite indexes did not allow non-hashed Strings as last value -- Fixed issue where `@Ignore()` fields were not ignored - -## 1.0.5 - -### Enhancements - -- Updated dependencies - -### Fixes: - -- Included desktop binaries -- Fixed "Cannot allocate memory" error on older iOS devices -- Fixed stripped binaries for iOS release builds -- Fixed IsarInspector issues (thanks to [RubenBez](https://github.com/RubenBez) and [rizzi37](https://github.com/rizzi37)) - -## 1.0.0+1 - -Added missing binaries - -## 1.0.0 - -Switched from liblmdb to libmdbx for better performance, more stability and many internal improvements. - -### Breaking - -The internal database format has been changed to improve performance. Old databases do not work anymore! - -### Fixes - -- Fix issue with links being removed after object update -- Fix String index problems - -### Enhancements - -- Support `greaterThan`, `lessThan` and `between` queries for String values -- Support for inheritance (enabled by default) -- Support for `final` properties and getters -- Support for `freezed` and other code generators -- Support getting / deleting objects by a key `col.deleteByName('Anne')` -- Support for list indexes (hash an element based) -- Generator now creates individual files instead of one big file -- Allow specifying the collection accessor name -- Unsupported properties are now ignored automatically -- Returns the assigned ids after `.put()` operations (objects are no longer mutated) -- Introduces `replaceOnConflict` option for `.put()` (instead of specifying it for index) -- many more... - -### Internal - -- Improve generated code -- Many new unit tests - -## 0.4.0 - -### Breaking - -- Remove `.where...In()` and `...In()` extension methods -- Split `.watch(lazy: bool)` into `.watch()` and `.watchLazy()` -- Remove `include` option for filters - -### Fixes - -- Generate id for JSON imports that don't have an id -- Enable `sortBy` and `thenBy` generation - -### Enhancements - -- Add `.optional()` and `.repeat()` query modifiers -- Support property queries -- Support query aggregation -- Support dynamic queries (for custom query languages) -- Support multi package configuration with `@ExternalCollection()` -- Add `caseSensitive` option to `.distinctBy()` - -### Internal - -- Change iOS linking -- Improve generated code -- Set up integration tests and improve unit tests -- Use CORE/0.4.0 - -## 0.2.0 - -- Link support -- Many improvements and fixes - -## 0.1.0 - -- Support for links and backlinks - -## 0.0.4 - -- Bugfixes and many improvements - -## 0.0.2 - -Fix dependency issue - -## 0.0.1 - -Initial release diff --git a/packages_external/isar-3.1.0-1/packages/isar/LICENSE b/packages_external/isar-3.1.0-1/packages/isar/LICENSE deleted file mode 100644 index f0d4b836..00000000 --- a/packages_external/isar-3.1.0-1/packages/isar/LICENSE +++ /dev/null @@ -1,202 +0,0 @@ - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright 2022 Simon Leier - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. \ No newline at end of file diff --git a/packages_external/isar-3.1.0-1/packages/isar/README.md b/packages_external/isar-3.1.0-1/packages/isar/README.md deleted file mode 100644 index 2466b448..00000000 --- a/packages_external/isar-3.1.0-1/packages/isar/README.md +++ /dev/null @@ -1,267 +0,0 @@ -

- - - -

Isar Database

-

- -

- - - - - - - - - - - - - - - -

- -

- Quickstart • - Documentation • - Sample Apps • - Support & Ideas • - Pub.dev -

- -> #### Isar [ee-zahr]: -> -> 1. River in Bavaria, Germany. -> 2. [Crazy fast](#benchmarks) NoSQL database that is a joy to use. - -## Features - -- 💙 **Made for Flutter**. Easy to use, no config, no boilerplate -- 🚀 **Highly scalable** The sky is the limit (pun intended) -- 🍭 **Feature rich**. Composite & multi-entry indexes, query modifiers, JSON support etc. -- ⏱ **Asynchronous**. Parallel query operations & multi-isolate support by default -- 🦄 **Open source**. Everything is open source and free forever! - -Isar database can do much more (and we are just getting started) - -- 🕵️ **Full-text search**. Make searching fast and fun -- 📱 **Multiplatform**. iOS, Android, Desktop -- 🧪 **ACID semantics**. Rely on database consistency -- 💃 **Static typing**. Compile-time checked and autocompleted queries -- ✨ **Beautiful documentation**. Readable, easy to understand and ever-improving - -Join the [Telegram group](https://t.me/isardb) for discussion and sneak peeks of new versions of the DB. - -If you want to say thank you, star us on GitHub and like us on pub.dev 🙌💙 - -## Quickstart - -Holy smokes you're here! Let's get started on using the coolest Flutter database out there... - -### 1. Add to pubspec.yaml - -```yaml -isar_version: &isar_version 3.1.0 # define the version to be used - -dependencies: - isar: *isar_version - isar_flutter_libs: *isar_version # contains Isar Core - -dev_dependencies: - isar_generator: *isar_version - build_runner: any -``` - -### 2. Annotate a Collection - -```dart -part 'email.g.dart'; - -@collection -class Email { - Id id = Isar.autoIncrement; // you can also use id = null to auto increment - - @Index(type: IndexType.value) - String? title; - - List? recipients; - - @enumerated - Status status = Status.pending; -} - -@embedded -class Recipient { - String? name; - - String? address; -} - -enum Status { - draft, - pending, - sent, -} -``` - -### 3. Open a database instance - -```dart -final dir = await getApplicationDocumentsDirectory(); -final isar = await Isar.open( - [EmailSchema], - directory: dir.path, -); -``` - -### 4. Query the database - -```dart -final emails = await isar.emails.filter() - .titleContains('awesome', caseSensitive: false) - .sortByStatusDesc() - .limit(10) - .findAll(); -``` - -## Isar Database Inspector - -The Isar Inspector allows you to inspect the Isar instances & collections of your app in real-time. You can execute queries, edit properties, switch between instances and sort the data. - - - -To launch the inspector, just run your Isar app in debug mode and open the Inspector link in the logs. - -## CRUD operations - -All basic crud operations are available via the `IsarCollection`. - -```dart -final newEmail = Email()..title = 'Amazing new database'; - -await isar.writeTxn(() { - await isar.emails.put(newEmail); // insert & update -}); - -final existingEmail = await isar.emails.get(newEmail.id!); // get - -await isar.writeTxn(() { - await isar.emails.delete(existingEmail.id!); // delete -}); -``` - -## Database Queries - -Isar database has a powerful query language that allows you to make use of your indexes, filter distinct objects, use complex `and()`, `or()` and `.xor()` groups, query links and sort the results. - -```dart -final importantEmails = isar.emails - .where() - .titleStartsWith('Important') // use index - .limit(10) - .findAll() - -final specificEmails = isar.emails - .filter() - .recipient((q) => q.nameEqualTo('David')) // query embedded objects - .or() - .titleMatches('*university*', caseSensitive: false) // title containing 'university' (case insensitive) - .findAll() -``` - -## Database Watchers - -With Isar database, you can watch collections, objects, or queries. A watcher is notified after a transaction commits successfully and the target actually changes. -Watchers can be lazy and not reload the data or they can be non-lazy and fetch new results in the background. - -```dart -Stream collectionStream = isar.emails.watchLazy(); - -Stream> queryStream = importantEmails.watch(); - -queryStream.listen((newResult) { - // do UI updates -}) -``` - -## Benchmarks - -Benchmarks only give a rough idea of the performance of a database but as you can see, Isar NoSQL database is quite fast 😇 - -| | | -| ---------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------- | -| | | - -If you are interested in more benchmarks or want to check how Isar performs on your device you can run the [benchmarks](https://github.com/isar/isar_benchmark) yourself. - -## Unit tests - -If you want to use Isar database in unit tests or Dart code, call `await Isar.initializeIsarCore(download: true)` before using Isar in your tests. - -Isar NoSQL database will automatically download the correct binary for your platform. You can also pass a `libraries` map to adjust the download location for each platform. - -Make sure to use `flutter test -j 1` to avoid tests running in parallel. This would break the automatic download. - -## Contributors ✨ - -Big thanks go to these wonderful people: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Alexis

Burak

Carlo Loguercio

Frostedfox

Hafeez Rana

Hamed H.

JT

Jack Rivers

Joachim Nohl

Johnson

LaLucid

Lety

Michael

Moseco

Nelson Mutane

Peyman

Simon Leier

Ura

blendthink

mnkeis

nobkd
- - - - - - -### License - -``` -Copyright 2022 Simon Leier - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -``` diff --git a/packages_external/isar-3.1.0-1/packages/isar/analysis_options.yaml b/packages_external/isar-3.1.0-1/packages/isar/analysis_options.yaml deleted file mode 100644 index ee7facbd..00000000 --- a/packages_external/isar-3.1.0-1/packages/isar/analysis_options.yaml +++ /dev/null @@ -1,11 +0,0 @@ -include: package:very_good_analysis/analysis_options.yaml - -analyzer: - exclude: - - "lib/src/native/bindings.dart" - - errors: - cascade_invocations: ignore - avoid_positional_boolean_parameters: ignore - parameter_assignments: ignore - prefer_asserts_with_message: ignore \ No newline at end of file diff --git a/packages_external/isar-3.1.0-1/packages/isar/example/README.md b/packages_external/isar-3.1.0-1/packages/isar/example/README.md deleted file mode 100644 index e43ff5cc..00000000 --- a/packages_external/isar-3.1.0-1/packages/isar/example/README.md +++ /dev/null @@ -1,3 +0,0 @@ -## The fastest way to get started is by following the [Quickstart Guide](https://isar.dev/tutorials/quickstart.html)! - -Have fun using Isar! \ No newline at end of file diff --git a/packages_external/isar-3.1.0-1/packages/isar/lib/isar.dart b/packages_external/isar-3.1.0-1/packages/isar/lib/isar.dart deleted file mode 100644 index 429086e5..00000000 --- a/packages_external/isar-3.1.0-1/packages/isar/lib/isar.dart +++ /dev/null @@ -1,49 +0,0 @@ -library isar; - -import 'dart:async'; -import 'dart:convert'; -import 'dart:developer'; -import 'dart:typed_data'; - -import 'package:isar/src/isar_connect_api.dart'; -import 'package:isar/src/native/isar_core.dart' - if (dart.library.html) 'package:isar/src/web/isar_web.dart'; -import 'package:isar/src/native/isar_link_impl.dart' - if (dart.library.html) 'package:isar/src/web/isar_link_impl.dart'; -import 'package:isar/src/native/open.dart' - if (dart.library.html) 'package:isar/src/web/open.dart'; -import 'package:isar/src/native/split_words.dart' - if (dart.library.html) 'package:isar/src/web/split_words.dart'; -import 'package:meta/meta.dart'; -import 'package:meta/meta_meta.dart'; - -part 'src/annotations/backlink.dart'; -part 'src/annotations/collection.dart'; -part 'src/annotations/embedded.dart'; -part 'src/annotations/enumerated.dart'; -part 'src/annotations/ignore.dart'; -part 'src/annotations/index.dart'; -part 'src/annotations/name.dart'; -part 'src/annotations/type.dart'; -part 'src/isar.dart'; -part 'src/isar_collection.dart'; -part 'src/isar_connect.dart'; -part 'src/isar_error.dart'; -part 'src/isar_link.dart'; -part 'src/isar_reader.dart'; -part 'src/isar_writer.dart'; -part 'src/query.dart'; -part 'src/query_builder.dart'; -part 'src/query_builder_extensions.dart'; -part 'src/query_components.dart'; -part 'src/schema/collection_schema.dart'; -part 'src/schema/index_schema.dart'; -part 'src/schema/link_schema.dart'; -part 'src/schema/property_schema.dart'; -part 'src/schema/schema.dart'; - -/// @nodoc -@protected -typedef IsarUint8List = Uint8List; - -const bool _kIsWeb = identical(0, 0.0); diff --git a/packages_external/isar-3.1.0-1/packages/isar/lib/src/annotations/backlink.dart b/packages_external/isar-3.1.0-1/packages/isar/lib/src/annotations/backlink.dart deleted file mode 100644 index 54b0ab2b..00000000 --- a/packages_external/isar-3.1.0-1/packages/isar/lib/src/annotations/backlink.dart +++ /dev/null @@ -1,11 +0,0 @@ -part of isar; - -/// Annotation to create a backlink to an existing link. -@Target({TargetKind.field}) -class Backlink { - /// Annotation to create a backlink to an existing link. - const Backlink({required this.to}); - - /// The Dart name of the target link. - final String to; -} diff --git a/packages_external/isar-3.1.0-1/packages/isar/lib/src/annotations/collection.dart b/packages_external/isar-3.1.0-1/packages/isar/lib/src/annotations/collection.dart deleted file mode 100644 index 979efb02..00000000 --- a/packages_external/isar-3.1.0-1/packages/isar/lib/src/annotations/collection.dart +++ /dev/null @@ -1,34 +0,0 @@ -part of isar; - -/// Annotation to create an Isar collection. -const collection = Collection(); - -/// Annotation to create an Isar collection. -@Target({TargetKind.classType}) -class Collection { - /// Annotation to create an Isar collection. - const Collection({ - this.inheritance = true, - this.accessor, - this.ignore = const {}, - }); - - /// Should properties and accessors of parent classes and mixins be included? - final bool inheritance; - - /// Allows you to override the default collection accessor. - /// - /// Example: - /// ```dart - /// @Collection(accessor: 'col') - /// class MyCol { - /// Id? id; - /// } - /// - /// // access collection using: isar.col - /// ``` - final String? accessor; - - /// A list of properties or getter names that Isar should ignore. - final Set ignore; -} diff --git a/packages_external/isar-3.1.0-1/packages/isar/lib/src/annotations/embedded.dart b/packages_external/isar-3.1.0-1/packages/isar/lib/src/annotations/embedded.dart deleted file mode 100644 index d8f5ce93..00000000 --- a/packages_external/isar-3.1.0-1/packages/isar/lib/src/annotations/embedded.dart +++ /dev/null @@ -1,17 +0,0 @@ -part of isar; - -/// Annotation to nest objects of this type in collections. -const embedded = Embedded(); - -/// Annotation to nest objects of this type in collections. -@Target({TargetKind.classType}) -class Embedded { - /// Annotation to nest objects of this type in collections. - const Embedded({this.inheritance = true, this.ignore = const {}}); - - /// Should properties and accessors of parent classes and mixins be included? - final bool inheritance; - - /// A list of properties or getter names that Isar should ignore. - final Set ignore; -} diff --git a/packages_external/isar-3.1.0-1/packages/isar/lib/src/annotations/enumerated.dart b/packages_external/isar-3.1.0-1/packages/isar/lib/src/annotations/enumerated.dart deleted file mode 100644 index ade7e5fe..00000000 --- a/packages_external/isar-3.1.0-1/packages/isar/lib/src/annotations/enumerated.dart +++ /dev/null @@ -1,33 +0,0 @@ -part of isar; - -/// Annotation to specify how an enum property should be serialized. -const enumerated = Enumerated(EnumType.ordinal); - -/// Annotation to specify how an enum property should be serialized. -@Target({TargetKind.field, TargetKind.getter}) -class Enumerated { - /// Annotation to specify how an enum property should be serialized. - const Enumerated(this.type, [this.property]); - - /// How the enum property should be serialized. - final EnumType type; - - /// The property to use for the enum values. - final String? property; -} - -/// Enum type for enum values. -enum EnumType { - /// Stores the index of the enum as a byte value. - ordinal, - - /// Stores the index of the enum as a 4-byte value. Use this type if your enum - /// has more than 256 values or needs to be nullable. - ordinal32, - - /// Uses the name of the enum value. - name, - - /// Uses a custom enum value. - value -} diff --git a/packages_external/isar-3.1.0-1/packages/isar/lib/src/annotations/ignore.dart b/packages_external/isar-3.1.0-1/packages/isar/lib/src/annotations/ignore.dart deleted file mode 100644 index 181224ef..00000000 --- a/packages_external/isar-3.1.0-1/packages/isar/lib/src/annotations/ignore.dart +++ /dev/null @@ -1,11 +0,0 @@ -part of isar; - -/// Annotate a property or accessor in an Isar collection to ignore it. -const ignore = Ignore(); - -/// Annotate a property or accessor in an Isar collection to ignore it. -@Target({TargetKind.field, TargetKind.getter}) -class Ignore { - /// Annotate a property or accessor in an Isar collection to ignore it. - const Ignore(); -} diff --git a/packages_external/isar-3.1.0-1/packages/isar/lib/src/annotations/index.dart b/packages_external/isar-3.1.0-1/packages/isar/lib/src/annotations/index.dart deleted file mode 100644 index 62546a92..00000000 --- a/packages_external/isar-3.1.0-1/packages/isar/lib/src/annotations/index.dart +++ /dev/null @@ -1,76 +0,0 @@ -part of isar; - -/// Specifies how an index is stored in Isar. -enum IndexType { - /// Stores the value as-is in the index. - value, - - /// Strings or Lists can be hashed to reduce the storage required by the - /// index. The disadvantage of hash indexes is that they can't be used for - /// prefix scans (`startsWith()` where clauses). String and list indexes are - /// hashed by default. - hash, - - /// `List` can hash its elements. - hashElements, -} - -/// Annotate properties to build an index. -@Target({TargetKind.field, TargetKind.getter}) -class Index { - /// Annotate properties to build an index. - const Index({ - this.name, - this.composite = const [], - this.unique = false, - this.replace = false, - this.type, - this.caseSensitive, - }); - - /// Name of the index. By default, the names of the properties are - /// concatenated using "_" - final String? name; - - /// Specify up to two other properties to build a composite index. - final List composite; - - /// A unique index ensures the index does not contain any duplicate values. - /// Any attempt to insert or update data into the unique index that causes a - /// duplicate will result in an error. - final bool unique; - - /// If set to `true`, inserting a duplicate unique value will replace the - /// existing object instead of throwing an error. - final bool replace; - - /// Specifies how an index is stored in Isar. - /// - /// Defaults to: - /// - `IndexType.hash` for `String`s and `List`s - /// - `IndexType.value` for all other types - final IndexType? type; - - /// String or `List` indexes can be case sensitive (default) or case - /// insensitive. - final bool? caseSensitive; -} - -/// Another property that is part of the composite index. -class CompositeIndex { - /// Another property that is part of the composite index. - const CompositeIndex( - this.property, { - this.type, - this.caseSensitive, - }); - - /// Dart name of the property. - final String property; - - /// See [Index.type]. - final IndexType? type; - - /// See [Index.caseSensitive]. - final bool? caseSensitive; -} diff --git a/packages_external/isar-3.1.0-1/packages/isar/lib/src/annotations/name.dart b/packages_external/isar-3.1.0-1/packages/isar/lib/src/annotations/name.dart deleted file mode 100644 index a950ac4c..00000000 --- a/packages_external/isar-3.1.0-1/packages/isar/lib/src/annotations/name.dart +++ /dev/null @@ -1,13 +0,0 @@ -part of isar; - -/// Annotate Isar collections or properties to change their name. -/// -/// Can be used to change the name in Dart independently of Isar. -@Target({TargetKind.classType, TargetKind.field, TargetKind.getter}) -class Name { - /// Annotate Isar collections or properties to change their name. - const Name(this.name); - - /// The name this entity should have in the database. - final String name; -} diff --git a/packages_external/isar-3.1.0-1/packages/isar/lib/src/annotations/type.dart b/packages_external/isar-3.1.0-1/packages/isar/lib/src/annotations/type.dart deleted file mode 100644 index 87322651..00000000 --- a/packages_external/isar-3.1.0-1/packages/isar/lib/src/annotations/type.dart +++ /dev/null @@ -1,20 +0,0 @@ -// ignore_for_file: camel_case_types - -part of isar; - -/// Type to specify the id property of a collection. -typedef Id = int; - -/// Type to mark an [int] property or List as 8-bit sized. -/// -/// You may only store values between 0 and 255 in such a property. -typedef byte = int; - -/// Type to mark an [int] property or List as 32-bit sized. -/// -/// You may only store values between -2147483648 and 2147483647 in such a -/// property. -typedef short = int; - -/// Type to mark a [double] property or List to have 32-bit precision. -typedef float = double; diff --git a/packages_external/isar-3.1.0-1/packages/isar/lib/src/common/isar_common.dart b/packages_external/isar-3.1.0-1/packages/isar/lib/src/common/isar_common.dart deleted file mode 100644 index ea0873e3..00000000 --- a/packages_external/isar-3.1.0-1/packages/isar/lib/src/common/isar_common.dart +++ /dev/null @@ -1,222 +0,0 @@ -// ignore_for_file: invalid_use_of_protected_member - -import 'dart:async'; - -import 'package:isar/isar.dart'; - -const Symbol _zoneTxn = #zoneTxn; - -/// @nodoc -abstract class IsarCommon extends Isar { - /// @nodoc - IsarCommon(super.name); - - final List> _activeAsyncTxns = []; - var _asyncWriteTxnsActive = 0; - - Transaction? _currentTxnSync; - - void _requireNotInTxn() { - if (_currentTxnSync != null || Zone.current[_zoneTxn] != null) { - throw IsarError( - 'Cannot perform this operation from within an active transaction. ' - 'Isar does not support nesting transactions.', - ); - } - } - - /// @nodoc - Future beginTxn(bool write, bool silent); - - Future _beginTxn( - bool write, - bool silent, - Future Function() callback, - ) async { - requireOpen(); - _requireNotInTxn(); - - final completer = Completer(); - _activeAsyncTxns.add(completer.future); - - try { - if (write) { - _asyncWriteTxnsActive++; - } - - final txn = await beginTxn(write, silent); - - final zone = Zone.current.fork( - zoneValues: {_zoneTxn: txn}, - ); - - T result; - try { - result = await zone.run(callback); - await txn.commit(); - } catch (e) { - await txn.abort(); - rethrow; - } finally { - txn.free(); - } - return result; - } finally { - completer.complete(); - _activeAsyncTxns.remove(completer.future); - if (write) { - _asyncWriteTxnsActive--; - } - } - } - - @override - Future txn(Future Function() callback) { - return _beginTxn(false, false, callback); - } - - @override - Future writeTxn(Future Function() callback, {bool silent = false}) { - return _beginTxn(true, silent, callback); - } - - /// @nodoc - Future getTxn( - bool write, - Future Function(T txn) callback, - ) { - final currentTxn = Zone.current[_zoneTxn] as T?; - if (currentTxn != null) { - if (!currentTxn.active) { - throw IsarError('Transaction is not active anymore. Make sure to await ' - 'all your asynchronous code within transactions to prevent it from ' - 'being closed prematurely.'); - } else if (write && !currentTxn.write) { - throw IsarError('Operation cannot be performed within a read ' - 'transaction. Use isar.writeTxn() instead.'); - } else if (currentTxn.isar != this) { - throw IsarError('Transaction does not match Isar instance. ' - 'Make sure to use transactions from the same Isar instance.'); - } - return callback(currentTxn); - } else if (!write) { - return _beginTxn(false, false, () { - return callback(Zone.current[_zoneTxn] as T); - }); - } else { - throw IsarError('Write operations require an explicit transaction. ' - 'Wrap your code in isar.writeTxn()'); - } - } - - /// @nodoc - Transaction beginTxnSync(bool write, bool silent); - - T _beginTxnSync(bool write, bool silent, T Function() callback) { - requireOpen(); - _requireNotInTxn(); - - if (write && _asyncWriteTxnsActive > 0) { - throw IsarError( - 'An async write transaction is already in progress in this isolate. ' - 'You cannot begin a sync write transaction until it is finished. ' - 'Use asynchroneous transactions if you want to queue multiple write ' - 'transactions.', - ); - } - - final txn = beginTxnSync(write, silent); - _currentTxnSync = txn; - - T result; - try { - result = callback(); - txn.commitSync(); - } catch (e) { - txn.abortSync(); - rethrow; - } finally { - _currentTxnSync = null; - txn.free(); - } - - return result; - } - - @override - T txnSync(T Function() callback) { - return _beginTxnSync(false, false, callback); - } - - @override - T writeTxnSync(T Function() callback, {bool silent = false}) { - return _beginTxnSync(true, silent, callback); - } - - /// @nodoc - R getTxnSync( - bool write, - R Function(T txn) callback, - ) { - if (_currentTxnSync != null) { - if (write && !_currentTxnSync!.write) { - throw IsarError( - 'Operation cannot be performed within a read transaction. ' - 'Use isar.writeTxnSync() instead.', - ); - } - return callback(_currentTxnSync! as T); - } else if (!write) { - return _beginTxnSync(false, false, () => callback(_currentTxnSync! as T)); - } else { - throw IsarError('Write operations require an explicit transaction. ' - 'Wrap your code in isar.writeTxnSync()'); - } - } - - @override - Future close({bool deleteFromDisk = false}) async { - requireOpen(); - _requireNotInTxn(); - await Future.wait(_activeAsyncTxns); - await super.close(); - - return performClose(deleteFromDisk); - } - - /// @nodoc - bool performClose(bool deleteFromDisk); -} - -/// @nodoc -abstract class Transaction { - /// @nodoc - Transaction(this.isar, this.sync, this.write); - - /// @nodoc - final Isar isar; - - /// @nodoc - final bool sync; - - /// @nodoc - final bool write; - - /// @nodoc - bool get active; - - /// @nodoc - Future commit(); - - /// @nodoc - void commitSync(); - - /// @nodoc - Future abort(); - - /// @nodoc - void abortSync(); - - /// @nodoc - void free() {} -} diff --git a/packages_external/isar-3.1.0-1/packages/isar/lib/src/common/isar_link_base_impl.dart b/packages_external/isar-3.1.0-1/packages/isar/lib/src/common/isar_link_base_impl.dart deleted file mode 100644 index 1a19192d..00000000 --- a/packages_external/isar-3.1.0-1/packages/isar/lib/src/common/isar_link_base_impl.dart +++ /dev/null @@ -1,108 +0,0 @@ -import 'package:isar/isar.dart'; - -/// @nodoc -abstract class IsarLinkBaseImpl implements IsarLinkBase { - var _initialized = false; - - Id? _objectId; - - /// The isar name of the link - late final String linkName; - - /// The origin collection of the link. For backlinks it is actually the target - /// collection. - late final IsarCollection sourceCollection; - - /// The target collection of the link. For backlinks it is actually the origin - /// collection. - late final IsarCollection targetCollection; - - @override - bool get isAttached => _objectId != null; - - @override - void attach( - IsarCollection sourceCollection, - IsarCollection targetCollection, - String linkName, - Id? objectId, - ) { - if (_initialized) { - if (linkName != this.linkName || - !identical(sourceCollection, this.sourceCollection) || - !identical(targetCollection, this.targetCollection)) { - throw IsarError( - 'Link has been moved! It is not allowed to move ' - 'a link to a different collection.', - ); - } - } else { - _initialized = true; - this.sourceCollection = sourceCollection; - this.targetCollection = targetCollection; - this.linkName = linkName; - } - - _objectId = objectId; - } - - /// Returns the containing object's id or throws an exception if this link has - /// not been attached to an object yet. - Id requireAttached() { - if (_objectId == null) { - throw IsarError( - 'Containing object needs to be managed by Isar to use this method. ' - 'Use collection.put(yourObject) to add it to the database.', - ); - } else { - return _objectId!; - } - } - - /// Returns the id of a linked object. - Id Function(OBJ obj) get getId; - - /// Returns the id of a linked object or throws an exception if the id is - /// `null` or set to `Isar.autoIncrement`. - Id requireGetId(OBJ object) { - final id = getId(object); - if (id != Isar.autoIncrement) { - return id; - } else { - throw IsarError( - 'Object "$object" has no id and can therefore not be linked. ' - 'Make sure to .put() objects before you use them in links.', - ); - } - } - - /// See [IsarLinks.filter]. - QueryBuilder filter() { - final containingId = requireAttached(); - final qb = QueryBuilderInternal( - collection: targetCollection, - whereClauses: [ - LinkWhereClause( - linkCollection: sourceCollection.name, - linkName: linkName, - id: containingId, - ), - ], - ); - return QueryBuilder(qb); - } - - /// See [IsarLinks.update]. - Future update({ - Iterable link = const [], - Iterable unlink = const [], - bool reset = false, - }); - - /// See [IsarLinks.updateSync]. - void updateSync({ - Iterable link = const [], - Iterable unlink = const [], - bool reset = false, - }); -} diff --git a/packages_external/isar-3.1.0-1/packages/isar/lib/src/common/isar_link_common.dart b/packages_external/isar-3.1.0-1/packages/isar/lib/src/common/isar_link_common.dart deleted file mode 100644 index 410ccd3b..00000000 --- a/packages_external/isar-3.1.0-1/packages/isar/lib/src/common/isar_link_common.dart +++ /dev/null @@ -1,92 +0,0 @@ -import 'package:isar/isar.dart'; -import 'package:isar/src/common/isar_link_base_impl.dart'; - -const bool _kIsWeb = identical(0, 0.0); - -/// @nodoc -abstract class IsarLinkCommon extends IsarLinkBaseImpl - with IsarLink { - OBJ? _value; - - @override - bool isChanged = false; - - @override - bool isLoaded = false; - - @override - OBJ? get value { - if (isAttached && !isLoaded && !isChanged && !_kIsWeb) { - loadSync(); - } - return _value; - } - - @override - set value(OBJ? value) { - isChanged |= !identical(_value, value); - _value = value; - isLoaded = true; - } - - @override - Future load() async { - _value = await filter().findFirst(); - isChanged = false; - isLoaded = true; - } - - @override - void loadSync() { - _value = filter().findFirstSync(); - isChanged = false; - isLoaded = true; - } - - @override - Future save() async { - if (!isChanged) { - return; - } - - final object = value; - - await update(link: [if (object != null) object], reset: true); - isChanged = false; - isLoaded = true; - } - - @override - void saveSync() { - if (!isChanged) { - return; - } - - final object = _value; - updateSync(link: [if (object != null) object], reset: true); - - isChanged = false; - isLoaded = true; - } - - @override - Future reset() async { - await update(reset: true); - _value = null; - isChanged = false; - isLoaded = true; - } - - @override - void resetSync() { - updateSync(reset: true); - _value = null; - isChanged = false; - isLoaded = true; - } - - @override - String toString() { - return 'IsarLink($_value)'; - } -} diff --git a/packages_external/isar-3.1.0-1/packages/isar/lib/src/common/isar_links_common.dart b/packages_external/isar-3.1.0-1/packages/isar/lib/src/common/isar_links_common.dart deleted file mode 100644 index 98975b76..00000000 --- a/packages_external/isar-3.1.0-1/packages/isar/lib/src/common/isar_links_common.dart +++ /dev/null @@ -1,223 +0,0 @@ -import 'dart:collection'; - -import 'package:isar/isar.dart'; -import 'package:isar/src/common/isar_link_base_impl.dart'; - -const bool _kIsWeb = identical(0, 0.0); - -/// @nodoc -abstract class IsarLinksCommon extends IsarLinkBaseImpl - with IsarLinks, SetMixin { - final _objects = {}; - - /// @nodoc - final addedObjects = HashSet.identity(); - - /// @nodoc - final removedObjects = HashSet.identity(); - - @override - bool isLoaded = false; - - @override - bool get isChanged => addedObjects.isNotEmpty || removedObjects.isNotEmpty; - - Map get _loadedObjects { - if (isAttached && !isLoaded && !_kIsWeb) { - loadSync(); - } - return _objects; - } - - @override - void attach( - IsarCollection sourceCollection, - IsarCollection targetCollection, - String linkName, - Id? objectId, - ) { - super.attach(sourceCollection, targetCollection, linkName, objectId); - - _applyAddedRemoved(); - } - - @override - Future load({bool overrideChanges = false}) async { - final objects = await filter().findAll(); - _applyLoaded(objects, overrideChanges); - } - - @override - void loadSync({bool overrideChanges = false}) { - final objects = filter().findAllSync(); - _applyLoaded(objects, overrideChanges); - } - - void _applyLoaded(List objects, bool overrideChanges) { - _objects.clear(); - for (final object in objects) { - final id = getId(object); - if (id != Isar.autoIncrement) { - _objects[id] = object; - } - } - - if (overrideChanges) { - addedObjects.clear(); - removedObjects.clear(); - } else { - _applyAddedRemoved(); - } - - isLoaded = true; - } - - void _applyAddedRemoved() { - for (final object in addedObjects) { - final id = getId(object); - if (id != Isar.autoIncrement) { - _objects[id] = object; - } - } - - for (final object in removedObjects) { - final id = getId(object); - if (id != Isar.autoIncrement) { - _objects.remove(id); - } - } - } - - @override - Future save() async { - if (!isChanged) { - return; - } - - await update(link: addedObjects, unlink: removedObjects); - - addedObjects.clear(); - removedObjects.clear(); - isLoaded = true; - } - - @override - void saveSync() { - if (!isChanged) { - return; - } - - updateSync(link: addedObjects, unlink: removedObjects); - - addedObjects.clear(); - removedObjects.clear(); - isLoaded = true; - } - - @override - Future reset() async { - await update(reset: true); - clear(); - isLoaded = true; - } - - @override - void resetSync() { - updateSync(reset: true); - clear(); - isLoaded = true; - } - - @override - bool add(OBJ value) { - if (isAttached) { - final id = getId(value); - if (id != Isar.autoIncrement) { - if (_objects.containsKey(id)) { - return false; - } - _objects[id] = value; - } - } - - removedObjects.remove(value); - return addedObjects.add(value); - } - - @override - bool contains(Object? element) { - requireAttached(); - - if (element is OBJ) { - final id = getId(element); - if (id != Isar.autoIncrement) { - return _loadedObjects.containsKey(id); - } - } - return false; - } - - @override - Iterator get iterator => _loadedObjects.values.iterator; - - @override - int get length => _loadedObjects.length; - - @override - OBJ? lookup(Object? element) { - requireAttached(); - - if (element is OBJ) { - final id = getId(element); - if (id != Isar.autoIncrement) { - return _loadedObjects[id]; - } - } - return null; - } - - @override - bool remove(Object? value) { - if (value is! OBJ) { - return false; - } - - if (isAttached) { - final id = getId(value); - if (id != Isar.autoIncrement) { - if (isLoaded && !_objects.containsKey(id)) { - return false; - } - _objects.remove(id); - } - } - - addedObjects.remove(value); - return removedObjects.add(value); - } - - @override - Set toSet() { - requireAttached(); - return HashSet( - equals: (o1, o2) => getId(o1) == getId(o2), - // ignore: noop_primitive_operations - hashCode: (o) => getId(o).toInt(), - isValidKey: (o) => o is OBJ && getId(o) != Isar.autoIncrement, - )..addAll(_loadedObjects.values); - } - - @override - void clear() { - _objects.clear(); - addedObjects.clear(); - removedObjects.clear(); - } - - @override - String toString() { - final content = - IterableBase.iterableToFullString(_objects.values, '{', '}'); - return 'IsarLinks($content)'; - } -} diff --git a/packages_external/isar-3.1.0-1/packages/isar/lib/src/common/schemas.dart b/packages_external/isar-3.1.0-1/packages/isar/lib/src/common/schemas.dart deleted file mode 100644 index 06085d81..00000000 --- a/packages_external/isar-3.1.0-1/packages/isar/lib/src/common/schemas.dart +++ /dev/null @@ -1,13 +0,0 @@ -import 'package:isar/isar.dart'; - -/// @nodoc -List> getSchemas( - List> collectionSchemas, -) { - final schemas = >{}; - for (final collectionSchema in collectionSchemas) { - schemas.add(collectionSchema); - schemas.addAll(collectionSchema.embeddedSchemas.values); - } - return schemas.toList(); -} diff --git a/packages_external/isar-3.1.0-1/packages/isar/lib/src/isar.dart b/packages_external/isar-3.1.0-1/packages/isar/lib/src/isar.dart deleted file mode 100644 index 51ca57d2..00000000 --- a/packages_external/isar-3.1.0-1/packages/isar/lib/src/isar.dart +++ /dev/null @@ -1,348 +0,0 @@ -part of isar; - -/// Callback for a newly opened Isar instance. -typedef IsarOpenCallback = void Function(Isar isar); - -/// Callback for a release Isar instance. -typedef IsarCloseCallback = void Function(String isarName); - -/// An instance of the Isar Database. -abstract class Isar { - /// @nodoc - @protected - Isar(this.name) { - _instances[name] = this; - for (final callback in _openCallbacks) { - callback(this); - } - } - - /// The version of the Isar library. - static const version = '3.1.0+1'; - - /// Smallest valid id. - static const Id minId = isarMinId; - - /// Largest valid id. - static const Id maxId = isarMaxId; - - /// The default Isar instance name. - static const String defaultName = 'default'; - - /// The default max Isar size. - static const int defaultMaxSizeMiB = 1024; - - /// Placeholder for an auto-increment id. - static const Id autoIncrement = isarAutoIncrementId; - - static final Map _instances = {}; - static final Set _openCallbacks = {}; - static final Set _closeCallbacks = {}; - - /// Name of the instance. - final String name; - - /// The directory containing the database file or `null` on the web. - String? get directory; - - /// The full path of the database file is `directory/name.isar` and the lock - /// file `directory/name.isar.lock`. - String? get path => directory != null ? '$directory/$name.isar' : null; - - late final Map> _collections; - late final Map> _collectionsByName; - - bool _isOpen = true; - - static void _checkOpen(String name, List> schemas) { - if (name.isEmpty || name.startsWith('_')) { - throw IsarError('Instance names must not be empty or start with "_".'); - } - if (_instances.containsKey(name)) { - throw IsarError('Instance has already been opened.'); - } - if (schemas.isEmpty) { - throw IsarError('At least one collection needs to be opened.'); - } - - final schemaNames = {}; - for (final schema in schemas) { - if (!schemaNames.add(schema.name)) { - throw IsarError('Duplicate collection ${schema.name}.'); - } - } - for (final schema in schemas) { - final dependencies = schema.links.values.map((e) => e.target); - for (final dependency in dependencies) { - if (!schemaNames.contains(dependency)) { - throw IsarError( - "Collection ${schema.name} depends on $dependency but it's schema " - 'was not provided.', - ); - } - } - } - } - - /// Open a new Isar instance. - static Future open( - List> schemas, { - required String directory, - String name = defaultName, - int maxSizeMiB = Isar.defaultMaxSizeMiB, - bool relaxedDurability = true, - CompactCondition? compactOnLaunch, - bool inspector = true, - }) { - _checkOpen(name, schemas); - - /// Tree shake the inspector for profile and release builds. - assert(() { - if (!_kIsWeb && inspector) { - _IsarConnect.initialize(schemas); - } - return true; - }()); - - return openIsar( - schemas: schemas, - directory: directory, - name: name, - maxSizeMiB: maxSizeMiB, - relaxedDurability: relaxedDurability, - compactOnLaunch: compactOnLaunch, - ); - } - - /// Open a new Isar instance. - static Isar openSync( - List> schemas, { - required String directory, - String name = defaultName, - int maxSizeMiB = Isar.defaultMaxSizeMiB, - bool relaxedDurability = true, - CompactCondition? compactOnLaunch, - bool inspector = true, - }) { - _checkOpen(name, schemas); - - /// Tree shake the inspector for profile and release builds. - assert(() { - if (!_kIsWeb && inspector) { - _IsarConnect.initialize(schemas); - } - return true; - }()); - - return openIsarSync( - schemas: schemas, - directory: directory, - name: name, - maxSizeMiB: maxSizeMiB, - relaxedDurability: relaxedDurability, - compactOnLaunch: compactOnLaunch, - ); - } - - /// Is the instance open? - bool get isOpen => _isOpen; - - /// @nodoc - @protected - void requireOpen() { - if (!isOpen) { - throw IsarError('Isar instance has already been closed'); - } - } - - /// Executes an asynchronous read-only transaction. - Future txn(Future Function() callback); - - /// Executes an asynchronous read-write transaction. - /// - /// If [silent] is `true`, watchers are not notified about changes in this - /// transaction. - Future writeTxn(Future Function() callback, {bool silent = false}); - - /// Executes a synchronous read-only transaction. - T txnSync(T Function() callback); - - /// Executes a synchronous read-write transaction. - /// - /// If [silent] is `true`, watchers are not notified about changes in this - /// transaction. - T writeTxnSync(T Function() callback, {bool silent = false}); - - /// @nodoc - @protected - void attachCollections(Map> collections) { - _collections = collections; - _collectionsByName = { - for (final IsarCollection col in collections.values) - col.name: col, - }; - } - - /// Get a collection by its type. - /// - /// You should use the generated extension methods instead. - IsarCollection collection() { - requireOpen(); - final collection = _collections[T]; - if (collection == null) { - throw IsarError('Missing ${T.runtimeType}Schema in Isar.open'); - } - return collection as IsarCollection; - } - - /// @nodoc - @protected - IsarCollection? getCollectionByNameInternal(String name) { - return _collectionsByName[name]; - } - - /// Remove all data in this instance and reset the auto increment values. - Future clear() async { - for (final col in _collections.values) { - await col.clear(); - } - } - - /// Remove all data in this instance and reset the auto increment values. - void clearSync() { - for (final col in _collections.values) { - col.clearSync(); - } - } - - /// Returns the size of all the collections in bytes. Not supported on web. - /// - /// This method is extremely fast and independent of the number of objects in - /// the instance. - Future getSize({bool includeIndexes = false, bool includeLinks = false}); - - /// Returns the size of all collections in bytes. Not supported on web. - /// - /// This method is extremely fast and independent of the number of objects in - /// the instance. - int getSizeSync({bool includeIndexes = false, bool includeLinks = false}); - - /// Copy a compacted version of the database to the specified file. - /// - /// If you want to backup your database, you should always use a compacted - /// version. Compacted does not mean compressed. - /// - /// Do not run this method while other transactions are active to avoid - /// unnecessary growth of the database. - Future copyToFile(String targetPath); - - /// Releases an Isar instance. - /// - /// If this is the only isolate that holds a reference to this instance, the - /// Isar instance will be closed. [deleteFromDisk] additionally removes all - /// database files if enabled. - /// - /// Returns whether the instance was actually closed. - Future close({bool deleteFromDisk = false}) { - requireOpen(); - _isOpen = false; - if (identical(_instances[name], this)) { - _instances.remove(name); - } - for (final callback in _closeCallbacks) { - callback(name); - } - return Future.value(false); - } - - /// Verifies the integrity of the database file. - /// - /// Do not use this method in production apps. - @visibleForTesting - @experimental - Future verify(); - - /// A list of all Isar instances opened in the current isolate. - static Set get instanceNames => _instances.keys.toSet(); - - /// Returns an Isar instance opened in the current isolate by its name. If - /// no name is provided, the default instance is returned. - static Isar? getInstance([String name = defaultName]) { - return _instances[name]; - } - - /// Registers a listener that is called whenever an Isar instance is opened. - static void addOpenListener(IsarOpenCallback callback) { - _openCallbacks.add(callback); - } - - /// Removes a previously registered `IsarOpenCallback`. - static void removeOpenListener(IsarOpenCallback callback) { - _openCallbacks.remove(callback); - } - - /// Registers a listener that is called whenever an Isar instance is - /// released. - static void addCloseListener(IsarCloseCallback callback) { - _closeCallbacks.add(callback); - } - - /// Removes a previously registered `IsarOpenCallback`. - static void removeCloseListener(IsarCloseCallback callback) { - _closeCallbacks.remove(callback); - } - - /// Initialize Isar Core manually. You need to provide Isar Core libraries - /// for every platform your app will run on. - /// - /// If [download] is `true`, Isar will attempt to download the correct - /// library and place it in the specified path or the script directory. - /// - /// Be careful if multiple unit tests try to download the library at the - /// same time. Always use `flutter test -j 1` when you rely on auto - /// downloading to ensure that only one test is running at a time. - /// - /// Only use this method for non-Flutter code or unit tests. - static Future initializeIsarCore({ - Map libraries = const {}, - bool download = false, - }) async { - await initializeCoreBinary( - libraries: libraries, - download: download, - ); - } - - /// Split a String into words according to Unicode Annex #29. Only words - /// containing at least one alphanumeric character will be included. - static List splitWords(String input) => isarSplitWords(input); -} - -/// Isar databases can contain unused space that will be reused for later -/// operations. You can specify conditions to trigger manual compaction where -/// the entire database is copied and unused space freed. -/// -/// This operation can only be performed while a database is being opened and -/// should only be used if absolutely necessary. -class CompactCondition { - /// Compaction will happen if all of the specified conditions are true. - const CompactCondition({ - this.minFileSize, - this.minBytes, - this.minRatio, - }) : assert( - minFileSize != null || minBytes != null || minRatio != null, - 'At least one condition needs to be specified.', - ); - - /// The minimum size in bytes of the database file to trigger compaction. It - /// is highly discouraged to trigger compaction solely on this condition. - final int? minFileSize; - - /// The minimum number of bytes that can be freed with compaction. - final int? minBytes; - - /// The minimum compaction ration. For example `2.0` would trigger compaction - /// as soon as the file size can be halved. - final double? minRatio; -} diff --git a/packages_external/isar-3.1.0-1/packages/isar/lib/src/isar_collection.dart b/packages_external/isar-3.1.0-1/packages/isar/lib/src/isar_collection.dart deleted file mode 100644 index 2d2b8142..00000000 --- a/packages_external/isar-3.1.0-1/packages/isar/lib/src/isar_collection.dart +++ /dev/null @@ -1,342 +0,0 @@ -part of isar; - -/// Normal keys consist of a single object, composite keys multiple. -typedef IndexKey = List; - -/// Use `IsarCollection` instances to find, query, and create new objects of a -/// given type in Isar. -/// -/// You can get an instance of `IsarCollection` by calling `isar.get()` or -/// by using the generated `isar.yourCollections` getter. -abstract class IsarCollection { - /// The corresponding Isar instance. - Isar get isar; - - /// Get the schema of the collection. - CollectionSchema get schema; - - /// The name of the collection. - String get name => schema.name; - - /// {@template col_get} - /// Get a single object by its [id] or `null` if the object does not exist. - /// {@endtemplate} - Future get(Id id) { - return getAll([id]).then((List objects) => objects[0]); - } - - /// {@macro col_get} - OBJ? getSync(Id id) { - return getAllSync([id])[0]; - } - - /// {@template col_get_all} - /// Get a list of objects by their [ids] or `null` if an object does not - /// exist. - /// {@endtemplate} - Future> getAll(List ids); - - /// {@macro col_get_all} - List getAllSync(List ids); - - /// {@template col_get_by_index} - /// Get a single object by the unique index [indexName] and [key]. - /// - /// Returns `null` if the object does not exist. - /// - /// If possible, you should use the generated type-safe methods instead. - /// {@endtemplate} - @experimental - Future getByIndex(String indexName, IndexKey key) { - return getAllByIndex(indexName, [key]) - .then((List objects) => objects[0]); - } - - /// {@macro col_get_by_index} - @experimental - OBJ? getByIndexSync(String indexName, IndexKey key) { - return getAllByIndexSync(indexName, [key])[0]; - } - - /// {@template col_get_all_by_index} - /// Get a list of objects by the unique index [indexName] and [keys]. - /// - /// Returns `null` if the object does not exist. - /// - /// If possible, you should use the generated type-safe methods instead. - /// {@endtemplate} - @experimental - Future> getAllByIndex(String indexName, List keys); - - /// {@macro col_get_all_by_index}' - @experimental - List getAllByIndexSync(String indexName, List keys); - - /// {@template col_put} - /// Insert or update an [object]. Returns the id of the new or updated object. - /// - /// If the object has an non-final id property, it will be set to the assigned - /// id. Otherwise you should use the returned id to update the object. - /// {@endtemplate} - Future put(OBJ object) { - return putAll([object]).then((List ids) => ids[0]); - } - - /// {@macro col_put} - Id putSync(OBJ object, {bool saveLinks = true}) { - return putAllSync([object], saveLinks: saveLinks)[0]; - } - - /// {@template col_put_all} - /// Insert or update a list of [objects]. Returns the list of ids of the new - /// or updated objects. - /// - /// If the objects have an non-final id property, it will be set to the - /// assigned id. Otherwise you should use the returned ids to update the - /// objects. - /// {@endtemplate} - Future> putAll(List objects); - - /// {@macro col_put_all} - List putAllSync(List objects, {bool saveLinks = true}); - - /// {@template col_put_by_index} - /// Insert or update the [object] by the unique index [indexName]. Returns the - /// id of the new or updated object. - /// - /// If there is already an object with the same index key, it will be - /// updated and all links will be preserved. Otherwise a new object will be - /// inserted. - /// - /// If the object has an non-final id property, it will be set to the assigned - /// id. Otherwise you should use the returned id to update the object. - /// - /// If possible, you should use the generated type-safe methods instead. - /// {@endtemplate} - @experimental - Future putByIndex(String indexName, OBJ object) { - return putAllByIndex(indexName, [object]).then((List ids) => ids[0]); - } - - /// {@macro col_put_by_index} - @experimental - Id putByIndexSync(String indexName, OBJ object, {bool saveLinks = true}) { - return putAllByIndexSync(indexName, [object])[0]; - } - - /// {@template col_put_all_by_index} - /// Insert or update a list of [objects] by the unique index [indexName]. - /// Returns the list of ids of the new or updated objects. - /// - /// If there is already an object with the same index key, it will be - /// updated and all links will be preserved. Otherwise a new object will be - /// inserted. - /// - /// If the objects have an non-final id property, it will be set to the - /// assigned id. Otherwise you should use the returned ids to update the - /// objects. - /// - /// If possible, you should use the generated type-safe methods instead. - /// {@endtemplate} - @experimental - Future> putAllByIndex(String indexName, List objects); - - /// {@macro col_put_all_by_index} - @experimental - List putAllByIndexSync( - String indexName, - List objects, { - bool saveLinks = true, - }); - - /// {@template col_delete} - /// Delete a single object by its [id]. - /// - /// Returns whether the object has been deleted. Isar web always returns - /// `true`. - /// {@endtemplate} - Future delete(Id id) { - return deleteAll([id]).then((int count) => count == 1); - } - - /// {@macro col_delete} - bool deleteSync(Id id) { - return deleteAllSync([id]) == 1; - } - - /// {@template col_delete_all} - /// Delete a list of objects by their [ids]. - /// - /// Returns the number of objects that have been deleted. Isar web always - /// returns `ids.length`. - /// {@endtemplate} - Future deleteAll(List ids); - - /// {@macro col_delete_all} - int deleteAllSync(List ids); - - /// {@template col_delete_by_index} - /// Delete a single object by the unique index [indexName] and [key]. - /// - /// Returns whether the object has been deleted. Isar web always returns - /// `true`. - /// {@endtemplate} - @experimental - Future deleteByIndex(String indexName, IndexKey key) { - return deleteAllByIndex(indexName, [key]).then((int count) => count == 1); - } - - /// {@macro col_delete_by_index} - @experimental - bool deleteByIndexSync(String indexName, IndexKey key) { - return deleteAllByIndexSync(indexName, [key]) == 1; - } - - /// {@template col_delete_all_by_index} - /// Delete a list of objects by the unique index [indexName] and [keys]. - /// - /// Returns the number of objects that have been deleted. Isar web always - /// returns `keys.length`. - /// {@endtemplate} - @experimental - Future deleteAllByIndex(String indexName, List keys); - - /// {@macro col_delete_all_by_index} - @experimental - int deleteAllByIndexSync(String indexName, List keys); - - /// {@template col_clear} - /// Remove all data in this collection and reset the auto increment value. - /// {@endtemplate} - Future clear(); - - /// {@macro col_clear} - void clearSync(); - - /// {@template col_import_json_raw} - /// Import a list of json objects encoded as a byte array. - /// - /// The json objects must have the same structure as the objects in this - /// collection. Otherwise an exception will be thrown. - /// {@endtemplate} - Future importJsonRaw(Uint8List jsonBytes); - - /// {@macro col_import_json_raw} - void importJsonRawSync(Uint8List jsonBytes); - - /// {@template col_import_json} - /// Import a list of json objects. - /// - /// The json objects must have the same structure as the objects in this - /// collection. Otherwise an exception will be thrown. - /// {@endtemplate} - Future importJson(List> json); - - /// {@macro col_import_json} - void importJsonSync(List> json); - - /// Start building a query using the [QueryBuilder]. - /// - /// You can use where clauses to only return [distinct] results. If you want - /// to reverse the order, set [sort] to [Sort.desc]. - QueryBuilder where({ - bool distinct = false, - Sort sort = Sort.asc, - }) { - final qb = QueryBuilderInternal( - collection: this, - whereDistinct: distinct, - whereSort: sort, - ); - return QueryBuilder(qb); - } - - /// Start building a query using the [QueryBuilder]. - /// - /// Shortcut if you don't want to use where clauses. - QueryBuilder filter() => where().filter(); - - /// Build a query dynamically for example to build a custom query language. - /// - /// It is highly discouraged to use this method. Only in very special cases - /// should it be used. If you open an issue please always mention that you - /// used this method. - /// - /// The type argument [R] needs to be equal to [OBJ] if no [property] is - /// specified. Otherwise it should be the type of the property. - @experimental - Query buildQuery({ - List whereClauses = const [], - bool whereDistinct = false, - Sort whereSort = Sort.asc, - FilterOperation? filter, - List sortBy = const [], - List distinctBy = const [], - int? offset, - int? limit, - String? property, - }); - - /// {@template col_count} - /// Returns the total number of objects in this collection. - /// - /// For non-web apps, this method is extremely fast and independent of the - /// number of objects in the collection. - /// {@endtemplate} - Future count(); - - /// {@macro col_count} - int countSync(); - - /// {@template col_size} - /// Returns the size of the collection in bytes. Not supported on web. - /// - /// For non-web apps, this method is extremely fast and independent of the - /// number of objects in the collection. - /// {@endtemplate} - Future getSize({bool includeIndexes = false, bool includeLinks = false}); - - /// {@macro col_size} - int getSizeSync({bool includeIndexes = false, bool includeLinks = false}); - - /// Watch the collection for changes. - /// - /// If [fireImmediately] is `true`, an event will be fired immediately. - Stream watchLazy({bool fireImmediately = false}); - - /// Watch the object with [id] for changes. If a change occurs, the new object - /// will be returned in the stream. - /// - /// Objects that don't exist (yet) can also be watched. If [fireImmediately] - /// is `true`, the object will be sent to the consumer immediately. - Stream watchObject(Id id, {bool fireImmediately = false}); - - /// Watch the object with [id] for changes. - /// - /// If [fireImmediately] is `true`, an event will be fired immediately. - Stream watchObjectLazy(Id id, {bool fireImmediately = false}); - - /// Verifies the integrity of the collection and its indexes. - /// - /// Throws an exception if the collection does not contain exactly the - /// provided [objects]. - /// - /// Do not use this method in production apps. - @visibleForTesting - @experimental - Future verify(List objects); - - /// Verifies the integrity of a link. - /// - /// Throws an exception if not exactly [sourceIds] as linked to the - /// [targetIds]. - /// - /// Do not use this method in production apps. - @visibleForTesting - @experimental - Future verifyLink( - String linkName, - List sourceIds, - List targetIds, - ); -} diff --git a/packages_external/isar-3.1.0-1/packages/isar/lib/src/isar_connect.dart b/packages_external/isar-3.1.0-1/packages/isar/lib/src/isar_connect.dart deleted file mode 100644 index b6eee88a..00000000 --- a/packages_external/isar-3.1.0-1/packages/isar/lib/src/isar_connect.dart +++ /dev/null @@ -1,263 +0,0 @@ -// coverage:ignore-file -// ignore_for_file: avoid_print - -part of isar; - -abstract class _IsarConnect { - static const Map Function(Map _)> _handlers = { - ConnectAction.getSchema: _getSchema, - ConnectAction.listInstances: _listInstances, - ConnectAction.watchInstance: _watchInstance, - ConnectAction.executeQuery: _executeQuery, - ConnectAction.removeQuery: _removeQuery, - ConnectAction.importJson: _importJson, - ConnectAction.exportJson: _exportJson, - ConnectAction.editProperty: _editProperty, - }; - - static List>? _schemas; - - // ignore: cancel_subscriptions - static final _querySubscription = >[]; - static final List> _collectionSubscriptions = - >[]; - - static void initialize(List> schemas) { - if (_schemas != null) { - return; - } - _schemas = schemas; - - Isar.addOpenListener((_) { - postEvent(ConnectEvent.instancesChanged.event, {}); - }); - - Isar.addCloseListener((_) { - postEvent(ConnectEvent.instancesChanged.event, {}); - }); - - for (final handler in _handlers.entries) { - registerExtension(handler.key.method, - (String method, Map parameters) async { - try { - final args = parameters.containsKey('args') - ? jsonDecode(parameters['args']!) as Map - : {}; - final result = {'result': await handler.value(args)}; - return ServiceExtensionResponse.result(jsonEncode(result)); - } catch (e) { - return ServiceExtensionResponse.error( - ServiceExtensionResponse.extensionError, - e.toString(), - ); - } - }); - } - - _printConnection(); - } - - static void _printConnection() { - Service.getInfo().then((ServiceProtocolInfo info) { - final serviceUri = info.serverUri; - if (serviceUri == null) { - return; - } - final port = serviceUri.port; - var path = serviceUri.path; - if (path.endsWith('/')) { - path = path.substring(0, path.length - 1); - } - if (path.endsWith('=')) { - path = path.substring(0, path.length - 1); - } - final url = ' https://inspect.isar.dev/${Isar.version}/#/$port$path '; - String line(String text, String fill) { - final fillCount = url.length - text.length; - final left = List.filled(fillCount ~/ 2, fill); - final right = List.filled(fillCount - left.length, fill); - return left.join() + text + right.join(); - } - - print('╔${line('', '═')}╗'); - print('║${line('ISAR CONNECT STARTED', ' ')}║'); - print('╟${line('', '─')}╢'); - print('║${line('Open the link to connect to the Isar', ' ')}║'); - print('║${line('Inspector while this build is running.', ' ')}║'); - print('╟${line('', '─')}╢'); - print('║$url║'); - print('╚${line('', '═')}╝'); - }); - } - - static Future _getSchema(Map _) async { - return _schemas!.map((e) => e.toJson()).toList(); - } - - static Future _listInstances(Map _) async { - return Isar.instanceNames.toList(); - } - - static Future _watchInstance(Map params) async { - for (final sub in _collectionSubscriptions) { - unawaited(sub.cancel()); - } - - _collectionSubscriptions.clear(); - if (params.isEmpty) { - return true; - } - - final instanceName = params['instance'] as String; - final instance = Isar.getInstance(instanceName)!; - - for (final collection in instance._collections.values) { - final sub = collection.watchLazy(fireImmediately: true).listen((_) { - _sendCollectionInfo(collection); - }); - _collectionSubscriptions.add(sub); - } - - return true; - } - - static void _sendCollectionInfo(IsarCollection collection) { - final count = collection.countSync(); - final size = collection.getSizeSync( - includeIndexes: true, - includeLinks: true, - ); - final collectionInfo = ConnectCollectionInfo( - instance: collection.isar.name, - collection: collection.name, - size: size, - count: count, - ); - postEvent( - ConnectEvent.collectionInfoChanged.event, - collectionInfo.toJson(), - ); - } - - static Future> _executeQuery( - Map params, - ) async { - for (final sub in _querySubscription) { - unawaited(sub.cancel()); - } - _querySubscription.clear(); - - final cQuery = ConnectQuery.fromJson(params); - final instance = Isar.getInstance(cQuery.instance)!; - - final links = - _schemas!.firstWhere((e) => e.name == cQuery.collection).links.values; - - final query = cQuery.toQuery(); - params.remove('limit'); - params.remove('offset'); - final countQuery = ConnectQuery.fromJson(params).toQuery(); - - _querySubscription.add( - query.watchLazy().listen((_) { - postEvent(ConnectEvent.queryChanged.event, {}); - }), - ); - final subscribed = {cQuery.collection}; - for (final link in links) { - if (subscribed.add(link.target)) { - final target = instance.getCollectionByNameInternal(link.target)!; - _querySubscription.add( - target.watchLazy().listen((_) { - postEvent(ConnectEvent.queryChanged.event, {}); - }), - ); - } - } - - final objects = await query.exportJson(); - if (links.isNotEmpty) { - final source = instance.getCollectionByNameInternal(cQuery.collection)!; - for (final object in objects) { - for (final link in links) { - final target = instance.getCollectionByNameInternal(link.target)!; - final links = await target.buildQuery( - whereClauses: [ - LinkWhereClause( - linkCollection: source.name, - linkName: link.name, - id: object[source.schema.idName] as int, - ), - ], - limit: link.single ? 1 : null, - ).exportJson(); - - if (link.single) { - object[link.name] = links.isEmpty ? null : links.first; - } else { - object[link.name] = links; - } - } - } - } - - return { - 'objects': objects, - 'count': await countQuery.count(), - }; - } - - static Future _removeQuery(Map params) async { - final query = ConnectQuery.fromJson(params).toQuery(); - await query.isar.writeTxn(query.deleteAll); - return true; - } - - static Future _importJson(Map params) async { - final instance = Isar.getInstance(params['instance'] as String)!; - final collection = - instance.getCollectionByNameInternal(params['collection'] as String)!; - final objects = (params['objects'] as List).cast>(); - await instance.writeTxn(() async { - await collection.importJson(objects); - }); - } - - static Future> _exportJson(Map params) async { - final query = ConnectQuery.fromJson(params).toQuery(); - return query.exportJson(); - } - - static Future _editProperty(Map params) async { - final cEdit = ConnectEdit.fromJson(params); - final isar = Isar.getInstance(cEdit.instance)!; - final collection = isar.getCollectionByNameInternal(cEdit.collection)!; - final keys = cEdit.path.split('.'); - - final query = collection.buildQuery( - whereClauses: [IdWhereClause.equalTo(value: cEdit.id)], - ); - - final objects = await query.exportJson(); - if (objects.isNotEmpty) { - dynamic object = objects.first; - for (var i = 0; i < keys.length; i++) { - if (i == keys.length - 1 && object is Map) { - object[keys[i]] = cEdit.value; - } else if (object is Map) { - object = object[keys[i]]; - } else if (object is List) { - object = object[int.parse(keys[i])]; - } - } - try { - await isar.writeTxn(() async { - await collection.importJson(objects); - }); - } catch (e) { - print(e); - } - } - } -} diff --git a/packages_external/isar-3.1.0-1/packages/isar/lib/src/isar_connect_api.dart b/packages_external/isar-3.1.0-1/packages/isar/lib/src/isar_connect_api.dart deleted file mode 100644 index 4f182876..00000000 --- a/packages_external/isar-3.1.0-1/packages/isar/lib/src/isar_connect_api.dart +++ /dev/null @@ -1,215 +0,0 @@ -// coverage:ignore-file -// ignore_for_file: public_member_api_docs - -import 'package:isar/isar.dart'; - -enum ConnectAction { - getSchema('ext.isar.getSchema'), - listInstances('ext.isar.listInstances'), - watchInstance('ext.isar.watchInstance'), - executeQuery('ext.isar.executeQuery'), - removeQuery('ext.isar.removeQuery'), - importJson('ext.isar.importJson'), - exportJson('ext.isar.exportJson'), - editProperty('ext.isar.editProperty'); - - const ConnectAction(this.method); - - final String method; -} - -enum ConnectEvent { - instancesChanged('isar.instancesChanged'), - queryChanged('isar.queryChanged'), - collectionInfoChanged('isar.collectionInfoChanged'); - - const ConnectEvent(this.event); - - final String event; -} - -class ConnectQuery { - ConnectQuery({ - required this.instance, - required this.collection, - this.filter, - this.offset, - this.limit, - this.sortProperty, - this.sortAsc, - }); - - factory ConnectQuery.fromJson(Map json) { - return ConnectQuery( - instance: json['instance'] as String, - collection: json['collection'] as String, - filter: _filterFromJson(json['filter'] as Map?), - offset: json['offset'] as int?, - limit: json['limit'] as int?, - sortProperty: json['sortProperty'] as String?, - sortAsc: json['sortAsc'] as bool?, - ); - } - - final String instance; - final String collection; - final FilterOperation? filter; - final int? offset; - final int? limit; - final String? sortProperty; - final bool? sortAsc; - - Map toJson() { - return { - 'instance': instance, - 'collection': collection, - if (filter != null) 'filter': _filterToJson(filter!), - if (offset != null) 'offset': offset, - if (limit != null) 'limit': limit, - if (sortProperty != null) 'sortProperty': sortProperty, - if (sortAsc != null) 'sortAsc': sortAsc, - }; - } - - static FilterOperation? _filterFromJson(Map? json) { - if (json == null) { - return null; - } - if (json.containsKey('filters')) { - final filters = (json['filters'] as List) - .map((e) => _filterFromJson(e as Map?)!) - .toList(); - return FilterGroup( - type: FilterGroupType.values[json['type'] as int], - filters: filters, - ); - } else { - return FilterCondition( - type: FilterConditionType.values[json['type'] as int], - property: json['property'] as String, - value1: json['value1'], - value2: json['value2'], - include1: json['include1'] as bool, - include2: json['include2'] as bool, - caseSensitive: json['caseSensitive'] as bool, - ); - } - } - - static Map _filterToJson(FilterOperation filter) { - if (filter is FilterCondition) { - return { - 'type': filter.type.index, - 'property': filter.property, - 'value1': filter.value1, - 'value2': filter.value2, - 'include1': filter.include1, - 'include2': filter.include2, - 'caseSensitive': filter.caseSensitive, - }; - } else if (filter is FilterGroup) { - return { - 'type': filter.type.index, - 'filters': filter.filters.map(_filterToJson).toList(), - }; - } else { - throw UnimplementedError(); - } - } - - Query toQuery() { - final isar = Isar.getInstance(instance)!; - // ignore: invalid_use_of_protected_member - final collection = isar.getCollectionByNameInternal(this.collection)!; - WhereClause? whereClause; - var whereSort = Sort.asc; - - SortProperty? sortProperty; - if (this.sortProperty != null) { - if (this.sortProperty == collection.schema.idName) { - whereClause = const IdWhereClause.any(); - whereSort = sortAsc == true ? Sort.asc : Sort.desc; - } else { - sortProperty = SortProperty( - property: this.sortProperty!, - sort: sortAsc == true ? Sort.asc : Sort.desc, - ); - } - } - return collection.buildQuery( - whereClauses: [if (whereClause != null) whereClause], - whereSort: whereSort, - filter: filter, - offset: offset, - limit: limit, - sortBy: [if (sortProperty != null) sortProperty], - ); - } -} - -class ConnectEdit { - ConnectEdit({ - required this.instance, - required this.collection, - required this.id, - required this.path, - required this.value, - }); - - factory ConnectEdit.fromJson(Map json) { - return ConnectEdit( - instance: json['instance'] as String, - collection: json['collection'] as String, - id: json['id'] as Id, - path: json['path'] as String, - value: json['value'], - ); - } - - final String instance; - final String collection; - final Id id; - final String path; - final dynamic value; - - Map toJson() { - return { - 'instance': instance, - 'collection': collection, - 'id': id, - 'path': path, - 'value': value, - }; - } -} - -class ConnectCollectionInfo { - ConnectCollectionInfo({ - required this.instance, - required this.collection, - required this.size, - required this.count, - }); - - factory ConnectCollectionInfo.fromJson(Map json) { - return ConnectCollectionInfo( - instance: json['instance'] as String, - collection: json['collection'] as String, - size: json['size'] as int, - count: json['count'] as int, - ); - } - final String instance; - final String collection; - final int size; - final int count; - - Map toJson() { - return { - 'instance': instance, - 'collection': collection, - 'size': size, - 'count': count, - }; - } -} diff --git a/packages_external/isar-3.1.0-1/packages/isar/lib/src/isar_error.dart b/packages_external/isar-3.1.0-1/packages/isar/lib/src/isar_error.dart deleted file mode 100644 index 18f92e1b..00000000 --- a/packages_external/isar-3.1.0-1/packages/isar/lib/src/isar_error.dart +++ /dev/null @@ -1,23 +0,0 @@ -part of isar; - -/// An error raised by Isar. -class IsarError extends Error { - /// @nodoc - @protected - IsarError(this.message); - - /// The message - final String message; - - @override - String toString() { - return 'IsarError: $message'; - } -} - -/// This error is returned when a unique index constraint is violated. -class IsarUniqueViolationError extends IsarError { - /// @nodoc - @protected - IsarUniqueViolationError() : super('Unique index violated'); -} diff --git a/packages_external/isar-3.1.0-1/packages/isar/lib/src/isar_link.dart b/packages_external/isar-3.1.0-1/packages/isar/lib/src/isar_link.dart deleted file mode 100644 index d5893833..00000000 --- a/packages_external/isar-3.1.0-1/packages/isar/lib/src/isar_link.dart +++ /dev/null @@ -1,113 +0,0 @@ -part of isar; - -/// @nodoc -@sealed -abstract class IsarLinkBase { - /// Is the containing object managed by Isar? - bool get isAttached; - - /// Have the contents been changed? If not, `.save()` is a no-op. - bool get isChanged; - - /// Has this link been loaded? - bool get isLoaded; - - /// {@template link_load} - /// Loads the linked object(s) from the database - /// {@endtemplate} - Future load(); - - /// {@macro link_load} - void loadSync(); - - /// {@template link_save} - /// Saves the linked object(s) to the database if there are changes. - /// - /// Also puts new objects into the database that have id set to `null` or - /// `Isar.autoIncrement`. - /// {@endtemplate} - Future save(); - - /// {@macro link_save} - void saveSync(); - - /// {@template link_reset} - /// Unlinks all linked object(s). - /// - /// You can even call this method on links that have not been loaded yet. - /// {@endtemplate} - Future reset(); - - /// {@macro link_reset} - void resetSync(); - - /// @nodoc - @protected - void attach( - IsarCollection sourceCollection, - IsarCollection targetCollection, - String linkName, - Id? objectId, - ); -} - -/// Establishes a 1:1 relationship with the same or another collection. The -/// target collection is specified by the generic type argument. -abstract class IsarLink implements IsarLinkBase { - /// Create an empty, unattached link. Make sure to provide the correct - /// generic argument. - factory IsarLink() => IsarLinkImpl(); - - /// The linked object or `null` if no object is linked. - OBJ? get value; - - /// The linked object or `null` if no object is linked. - set value(OBJ? obj); -} - -/// Establishes a 1:n relationship with the same or another collection. The -/// target collection is specified by the generic type argument. -abstract class IsarLinks implements IsarLinkBase, Set { - /// Create an empty, unattached link. Make sure to provide the correct - /// generic argument. - factory IsarLinks() => IsarLinksImpl(); - - @override - Future load({bool overrideChanges = true}); - - @override - void loadSync({bool overrideChanges = true}); - - /// {@template links_update} - /// Creates and removes the specified links in the database. - /// - /// This operation does not alter the state of the local copy of this link - /// and it can even be used without loading the link. - /// {@endtemplate} - Future update({ - Iterable link = const [], - Iterable unlink = const [], - bool reset = false, - }); - - /// {@macro links_update} - void updateSync({ - Iterable link = const [], - Iterable unlink = const [], - bool reset = false, - }); - - /// Starts a query for linked objects. - QueryBuilder filter(); - - /// {@template links_count} - /// Counts the linked objects in the database. - /// - /// It does not take the local state into account and can even be used - /// without loading the link. - /// {@endtemplate} - Future count() => filter().count(); - - /// {@macro links_count} - int countSync() => filter().countSync(); -} diff --git a/packages_external/isar-3.1.0-1/packages/isar/lib/src/isar_reader.dart b/packages_external/isar-3.1.0-1/packages/isar/lib/src/isar_reader.dart deleted file mode 100644 index 1601ed98..00000000 --- a/packages_external/isar-3.1.0-1/packages/isar/lib/src/isar_reader.dart +++ /dev/null @@ -1,88 +0,0 @@ -// ignore_for_file: public_member_api_docs - -part of isar; - -/// @nodoc -@protected -abstract class IsarReader { - bool readBool(int offset); - - bool? readBoolOrNull(int offset); - - int readByte(int offset); - - int? readByteOrNull(int offset); - - int readInt(int offset); - - int? readIntOrNull(int offset); - - double readFloat(int offset); - - double? readFloatOrNull(int offset); - - int readLong(int offset); - - int? readLongOrNull(int offset); - - double readDouble(int offset); - - double? readDoubleOrNull(int offset); - - DateTime readDateTime(int offset); - - DateTime? readDateTimeOrNull(int offset); - - String readString(int offset); - - String? readStringOrNull(int offset); - - T? readObjectOrNull( - int offset, - Deserialize deserialize, - Map> allOffsets, - ); - - List? readBoolList(int offset); - - List? readBoolOrNullList(int offset); - - List? readByteList(int offset); - - List? readIntList(int offset); - - List? readIntOrNullList(int offset); - - List? readFloatList(int offset); - - List? readFloatOrNullList(int offset); - - List? readLongList(int offset); - - List? readLongOrNullList(int offset); - - List? readDoubleList(int offset); - - List? readDoubleOrNullList(int offset); - - List? readDateTimeList(int offset); - - List? readDateTimeOrNullList(int offset); - - List? readStringList(int offset); - - List? readStringOrNullList(int offset); - - List? readObjectList( - int offset, - Deserialize deserialize, - Map> allOffsets, - T defaultValue, - ); - - List? readObjectOrNullList( - int offset, - Deserialize deserialize, - Map> allOffsets, - ); -} diff --git a/packages_external/isar-3.1.0-1/packages/isar/lib/src/isar_writer.dart b/packages_external/isar-3.1.0-1/packages/isar/lib/src/isar_writer.dart deleted file mode 100644 index 518802a0..00000000 --- a/packages_external/isar-3.1.0-1/packages/isar/lib/src/isar_writer.dart +++ /dev/null @@ -1,53 +0,0 @@ -// ignore_for_file: public_member_api_docs - -part of isar; - -/// @nodoc -@protected -abstract class IsarWriter { - void writeBool(int offset, bool? value); - - void writeByte(int offset, int value); - - void writeInt(int offset, int? value); - - void writeFloat(int offset, double? value); - - void writeLong(int offset, int? value); - - void writeDouble(int offset, double? value); - - void writeDateTime(int offset, DateTime? value); - - void writeString(int offset, String? value); - - void writeObject( - int offset, - Map> allOffsets, - Serialize serialize, - T? value, - ); - - void writeByteList(int offset, List? values); - - void writeBoolList(int offset, List? values); - - void writeIntList(int offset, List? values); - - void writeFloatList(int offset, List? values); - - void writeLongList(int offset, List? values); - - void writeDoubleList(int offset, List? values); - - void writeDateTimeList(int offset, List? values); - - void writeStringList(int offset, List? values); - - void writeObjectList( - int offset, - Map> allOffsets, - Serialize serialize, - List? values, - ); -} diff --git a/packages_external/isar-3.1.0-1/packages/isar/lib/src/native/bindings.dart b/packages_external/isar-3.1.0-1/packages/isar/lib/src/native/bindings.dart deleted file mode 100644 index 734bc9d1..00000000 --- a/packages_external/isar-3.1.0-1/packages/isar/lib/src/native/bindings.dart +++ /dev/null @@ -1,2241 +0,0 @@ -// ignore_for_file: camel_case_types, non_constant_identifier_names - -// AUTO GENERATED FILE, DO NOT EDIT. -// -// Generated by `package:ffigen`. -import 'dart:ffi' as ffi; - -class IsarCoreBindings { - /// Holds the symbol lookup function. - final ffi.Pointer Function(String symbolName) - _lookup; - - /// The symbols are looked up in [dynamicLibrary]. - IsarCoreBindings(ffi.DynamicLibrary dynamicLibrary) - : _lookup = dynamicLibrary.lookup; - - /// The symbols are looked up with [lookup]. - IsarCoreBindings.fromLookup( - ffi.Pointer Function(String symbolName) - lookup) - : _lookup = lookup; - - ffi.Pointer isar_find_word_boundaries( - ffi.Pointer input_bytes, - int length, - ffi.Pointer number_words, - ) { - return _isar_find_word_boundaries( - input_bytes, - length, - number_words, - ); - } - - late final _isar_find_word_boundariesPtr = _lookup< - ffi.NativeFunction< - ffi.Pointer Function(ffi.Pointer, ffi.Uint32, - ffi.Pointer)>>('isar_find_word_boundaries'); - late final _isar_find_word_boundaries = - _isar_find_word_boundariesPtr.asFunction< - ffi.Pointer Function( - ffi.Pointer, int, ffi.Pointer)>(); - - void isar_free_word_boundaries( - ffi.Pointer boundaries, - int word_count, - ) { - return _isar_free_word_boundaries( - boundaries, - word_count, - ); - } - - late final _isar_free_word_boundariesPtr = _lookup< - ffi.NativeFunction< - ffi.Void Function(ffi.Pointer, - ffi.Uint32)>>('isar_free_word_boundaries'); - late final _isar_free_word_boundaries = _isar_free_word_boundariesPtr - .asFunction, int)>(); - - void isar_free_string( - ffi.Pointer string, - ) { - return _isar_free_string( - string, - ); - } - - late final _isar_free_stringPtr = - _lookup)>>( - 'isar_free_string'); - late final _isar_free_string = - _isar_free_stringPtr.asFunction)>(); - - ffi.Pointer isar_get_error( - int err_code, - ) { - return _isar_get_error( - err_code, - ); - } - - late final _isar_get_errorPtr = - _lookup Function(ffi.Int64)>>( - 'isar_get_error'); - late final _isar_get_error = - _isar_get_errorPtr.asFunction Function(int)>(); - - void isar_free_c_object_set( - ffi.Pointer ros, - ) { - return _isar_free_c_object_set( - ros, - ); - } - - late final _isar_free_c_object_setPtr = - _lookup)>>( - 'isar_free_c_object_set'); - late final _isar_free_c_object_set = _isar_free_c_object_setPtr - .asFunction)>(); - - int isar_get( - ffi.Pointer collection, - ffi.Pointer txn, - ffi.Pointer object, - ) { - return _isar_get( - collection, - txn, - object, - ); - } - - late final _isar_getPtr = _lookup< - ffi.NativeFunction< - ffi.Int64 Function(ffi.Pointer, - ffi.Pointer, ffi.Pointer)>>('isar_get'); - late final _isar_get = _isar_getPtr.asFunction< - int Function(ffi.Pointer, ffi.Pointer, - ffi.Pointer)>(); - - int isar_get_by_index( - ffi.Pointer collection, - ffi.Pointer txn, - int index_id, - ffi.Pointer key, - ffi.Pointer object, - ) { - return _isar_get_by_index( - collection, - txn, - index_id, - key, - object, - ); - } - - late final _isar_get_by_indexPtr = _lookup< - ffi.NativeFunction< - ffi.Int64 Function( - ffi.Pointer, - ffi.Pointer, - ffi.Uint64, - ffi.Pointer, - ffi.Pointer)>>('isar_get_by_index'); - late final _isar_get_by_index = _isar_get_by_indexPtr.asFunction< - int Function(ffi.Pointer, ffi.Pointer, int, - ffi.Pointer, ffi.Pointer)>(); - - int isar_get_all( - ffi.Pointer collection, - ffi.Pointer txn, - ffi.Pointer objects, - ) { - return _isar_get_all( - collection, - txn, - objects, - ); - } - - late final _isar_get_allPtr = _lookup< - ffi.NativeFunction< - ffi.Int64 Function(ffi.Pointer, - ffi.Pointer, ffi.Pointer)>>('isar_get_all'); - late final _isar_get_all = _isar_get_allPtr.asFunction< - int Function(ffi.Pointer, ffi.Pointer, - ffi.Pointer)>(); - - int isar_get_all_by_index( - ffi.Pointer collection, - ffi.Pointer txn, - int index_id, - ffi.Pointer> keys, - ffi.Pointer objects, - ) { - return _isar_get_all_by_index( - collection, - txn, - index_id, - keys, - objects, - ); - } - - late final _isar_get_all_by_indexPtr = _lookup< - ffi.NativeFunction< - ffi.Int64 Function( - ffi.Pointer, - ffi.Pointer, - ffi.Uint64, - ffi.Pointer>, - ffi.Pointer)>>('isar_get_all_by_index'); - late final _isar_get_all_by_index = _isar_get_all_by_indexPtr.asFunction< - int Function(ffi.Pointer, ffi.Pointer, int, - ffi.Pointer>, ffi.Pointer)>(); - - int isar_put( - ffi.Pointer collection, - ffi.Pointer txn, - ffi.Pointer object, - ) { - return _isar_put( - collection, - txn, - object, - ); - } - - late final _isar_putPtr = _lookup< - ffi.NativeFunction< - ffi.Int64 Function(ffi.Pointer, - ffi.Pointer, ffi.Pointer)>>('isar_put'); - late final _isar_put = _isar_putPtr.asFunction< - int Function(ffi.Pointer, ffi.Pointer, - ffi.Pointer)>(); - - int isar_put_by_index( - ffi.Pointer collection, - ffi.Pointer txn, - int index_id, - ffi.Pointer object, - ) { - return _isar_put_by_index( - collection, - txn, - index_id, - object, - ); - } - - late final _isar_put_by_indexPtr = _lookup< - ffi.NativeFunction< - ffi.Int64 Function( - ffi.Pointer, - ffi.Pointer, - ffi.Uint64, - ffi.Pointer)>>('isar_put_by_index'); - late final _isar_put_by_index = _isar_put_by_indexPtr.asFunction< - int Function(ffi.Pointer, ffi.Pointer, int, - ffi.Pointer)>(); - - int isar_put_all( - ffi.Pointer collection, - ffi.Pointer txn, - ffi.Pointer objects, - ) { - return _isar_put_all( - collection, - txn, - objects, - ); - } - - late final _isar_put_allPtr = _lookup< - ffi.NativeFunction< - ffi.Int64 Function(ffi.Pointer, - ffi.Pointer, ffi.Pointer)>>('isar_put_all'); - late final _isar_put_all = _isar_put_allPtr.asFunction< - int Function(ffi.Pointer, ffi.Pointer, - ffi.Pointer)>(); - - int isar_put_all_by_index( - ffi.Pointer collection, - ffi.Pointer txn, - int index_id, - ffi.Pointer objects, - ) { - return _isar_put_all_by_index( - collection, - txn, - index_id, - objects, - ); - } - - late final _isar_put_all_by_indexPtr = _lookup< - ffi.NativeFunction< - ffi.Int64 Function( - ffi.Pointer, - ffi.Pointer, - ffi.Uint64, - ffi.Pointer)>>('isar_put_all_by_index'); - late final _isar_put_all_by_index = _isar_put_all_by_indexPtr.asFunction< - int Function(ffi.Pointer, ffi.Pointer, int, - ffi.Pointer)>(); - - int isar_delete( - ffi.Pointer collection, - ffi.Pointer txn, - int id, - ffi.Pointer deleted, - ) { - return _isar_delete( - collection, - txn, - id, - deleted, - ); - } - - late final _isar_deletePtr = _lookup< - ffi.NativeFunction< - ffi.Int64 Function( - ffi.Pointer, - ffi.Pointer, - ffi.Int64, - ffi.Pointer)>>('isar_delete'); - late final _isar_delete = _isar_deletePtr.asFunction< - int Function(ffi.Pointer, ffi.Pointer, int, - ffi.Pointer)>(); - - int isar_delete_by_index( - ffi.Pointer collection, - ffi.Pointer txn, - int index_id, - ffi.Pointer key, - ffi.Pointer deleted, - ) { - return _isar_delete_by_index( - collection, - txn, - index_id, - key, - deleted, - ); - } - - late final _isar_delete_by_indexPtr = _lookup< - ffi.NativeFunction< - ffi.Int64 Function( - ffi.Pointer, - ffi.Pointer, - ffi.Uint64, - ffi.Pointer, - ffi.Pointer)>>('isar_delete_by_index'); - late final _isar_delete_by_index = _isar_delete_by_indexPtr.asFunction< - int Function(ffi.Pointer, ffi.Pointer, int, - ffi.Pointer, ffi.Pointer)>(); - - int isar_delete_all( - ffi.Pointer collection, - ffi.Pointer txn, - ffi.Pointer ids, - int ids_length, - ffi.Pointer count, - ) { - return _isar_delete_all( - collection, - txn, - ids, - ids_length, - count, - ); - } - - late final _isar_delete_allPtr = _lookup< - ffi.NativeFunction< - ffi.Int64 Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Uint32, - ffi.Pointer)>>('isar_delete_all'); - late final _isar_delete_all = _isar_delete_allPtr.asFunction< - int Function(ffi.Pointer, ffi.Pointer, - ffi.Pointer, int, ffi.Pointer)>(); - - int isar_delete_all_by_index( - ffi.Pointer collection, - ffi.Pointer txn, - int index_id, - ffi.Pointer> keys, - int keys_length, - ffi.Pointer count, - ) { - return _isar_delete_all_by_index( - collection, - txn, - index_id, - keys, - keys_length, - count, - ); - } - - late final _isar_delete_all_by_indexPtr = _lookup< - ffi.NativeFunction< - ffi.Int64 Function( - ffi.Pointer, - ffi.Pointer, - ffi.Uint64, - ffi.Pointer>, - ffi.Uint32, - ffi.Pointer)>>('isar_delete_all_by_index'); - late final _isar_delete_all_by_index = - _isar_delete_all_by_indexPtr.asFunction< - int Function( - ffi.Pointer, - ffi.Pointer, - int, - ffi.Pointer>, - int, - ffi.Pointer)>(); - - int isar_clear( - ffi.Pointer collection, - ffi.Pointer txn, - ) { - return _isar_clear( - collection, - txn, - ); - } - - late final _isar_clearPtr = _lookup< - ffi.NativeFunction< - ffi.Int64 Function(ffi.Pointer, - ffi.Pointer)>>('isar_clear'); - late final _isar_clear = _isar_clearPtr.asFunction< - int Function(ffi.Pointer, ffi.Pointer)>(); - - int isar_json_import( - ffi.Pointer collection, - ffi.Pointer txn, - ffi.Pointer id_name, - ffi.Pointer json_bytes, - int json_length, - ) { - return _isar_json_import( - collection, - txn, - id_name, - json_bytes, - json_length, - ); - } - - late final _isar_json_importPtr = _lookup< - ffi.NativeFunction< - ffi.Int64 Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Uint32)>>('isar_json_import'); - late final _isar_json_import = _isar_json_importPtr.asFunction< - int Function(ffi.Pointer, ffi.Pointer, - ffi.Pointer, ffi.Pointer, int)>(); - - int isar_count( - ffi.Pointer collection, - ffi.Pointer txn, - ffi.Pointer count, - ) { - return _isar_count( - collection, - txn, - count, - ); - } - - late final _isar_countPtr = _lookup< - ffi.NativeFunction< - ffi.Int64 Function(ffi.Pointer, - ffi.Pointer, ffi.Pointer)>>('isar_count'); - late final _isar_count = _isar_countPtr.asFunction< - int Function(ffi.Pointer, ffi.Pointer, - ffi.Pointer)>(); - - int isar_get_size( - ffi.Pointer collection, - ffi.Pointer txn, - bool include_indexes, - bool include_links, - ffi.Pointer size, - ) { - return _isar_get_size( - collection, - txn, - include_indexes, - include_links, - size, - ); - } - - late final _isar_get_sizePtr = _lookup< - ffi.NativeFunction< - ffi.Int64 Function( - ffi.Pointer, - ffi.Pointer, - ffi.Bool, - ffi.Bool, - ffi.Pointer)>>('isar_get_size'); - late final _isar_get_size = _isar_get_sizePtr.asFunction< - int Function(ffi.Pointer, ffi.Pointer, bool, - bool, ffi.Pointer)>(); - - int isar_verify( - ffi.Pointer collection, - ffi.Pointer txn, - ffi.Pointer objects, - ) { - return _isar_verify( - collection, - txn, - objects, - ); - } - - late final _isar_verifyPtr = _lookup< - ffi.NativeFunction< - ffi.Int64 Function(ffi.Pointer, - ffi.Pointer, ffi.Pointer)>>('isar_verify'); - late final _isar_verify = _isar_verifyPtr.asFunction< - int Function(ffi.Pointer, ffi.Pointer, - ffi.Pointer)>(); - - void isar_connect_dart_api( - DartPostCObjectFnType ptr, - ) { - return _isar_connect_dart_api( - ptr, - ); - } - - late final _isar_connect_dart_apiPtr = - _lookup>( - 'isar_connect_dart_api'); - late final _isar_connect_dart_api = _isar_connect_dart_apiPtr - .asFunction(); - - void isar_filter_static( - ffi.Pointer> filter, - bool value, - ) { - return _isar_filter_static( - filter, - value, - ); - } - - late final _isar_filter_staticPtr = _lookup< - ffi.NativeFunction< - ffi.Void Function(ffi.Pointer>, - ffi.Bool)>>('isar_filter_static'); - late final _isar_filter_static = _isar_filter_staticPtr - .asFunction>, bool)>(); - - void isar_filter_and_or_xor( - ffi.Pointer> filter, - bool and, - bool exclusive, - ffi.Pointer> conditions, - int length, - ) { - return _isar_filter_and_or_xor( - filter, - and, - exclusive, - conditions, - length, - ); - } - - late final _isar_filter_and_or_xorPtr = _lookup< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer>, - ffi.Bool, - ffi.Bool, - ffi.Pointer>, - ffi.Uint32)>>('isar_filter_and_or_xor'); - late final _isar_filter_and_or_xor = _isar_filter_and_or_xorPtr.asFunction< - void Function(ffi.Pointer>, bool, bool, - ffi.Pointer>, int)>(); - - void isar_filter_not( - ffi.Pointer> filter, - ffi.Pointer condition, - ) { - return _isar_filter_not( - filter, - condition, - ); - } - - late final _isar_filter_notPtr = _lookup< - ffi.NativeFunction< - ffi.Void Function(ffi.Pointer>, - ffi.Pointer)>>('isar_filter_not'); - late final _isar_filter_not = _isar_filter_notPtr.asFunction< - void Function(ffi.Pointer>, ffi.Pointer)>(); - - int isar_filter_object( - ffi.Pointer collection, - ffi.Pointer> filter, - ffi.Pointer condition, - int embedded_col_id, - int property_id, - ) { - return _isar_filter_object( - collection, - filter, - condition, - embedded_col_id, - property_id, - ); - } - - late final _isar_filter_objectPtr = _lookup< - ffi.NativeFunction< - ffi.Int64 Function( - ffi.Pointer, - ffi.Pointer>, - ffi.Pointer, - ffi.Uint64, - ffi.Uint64)>>('isar_filter_object'); - late final _isar_filter_object = _isar_filter_objectPtr.asFunction< - int Function(ffi.Pointer, - ffi.Pointer>, ffi.Pointer, int, int)>(); - - int isar_filter_link( - ffi.Pointer collection, - ffi.Pointer> filter, - ffi.Pointer condition, - int link_id, - ) { - return _isar_filter_link( - collection, - filter, - condition, - link_id, - ); - } - - late final _isar_filter_linkPtr = _lookup< - ffi.NativeFunction< - ffi.Int64 Function( - ffi.Pointer, - ffi.Pointer>, - ffi.Pointer, - ffi.Uint64)>>('isar_filter_link'); - late final _isar_filter_link = _isar_filter_linkPtr.asFunction< - int Function(ffi.Pointer, - ffi.Pointer>, ffi.Pointer, int)>(); - - int isar_filter_link_length( - ffi.Pointer collection, - ffi.Pointer> filter, - int lower, - int upper, - int link_id, - ) { - return _isar_filter_link_length( - collection, - filter, - lower, - upper, - link_id, - ); - } - - late final _isar_filter_link_lengthPtr = _lookup< - ffi.NativeFunction< - ffi.Int64 Function( - ffi.Pointer, - ffi.Pointer>, - ffi.Uint32, - ffi.Uint32, - ffi.Uint64)>>('isar_filter_link_length'); - late final _isar_filter_link_length = _isar_filter_link_lengthPtr.asFunction< - int Function(ffi.Pointer, - ffi.Pointer>, int, int, int)>(); - - int isar_filter_list_length( - ffi.Pointer collection, - ffi.Pointer> filter, - int lower, - int upper, - int embedded_col_id, - int property_id, - ) { - return _isar_filter_list_length( - collection, - filter, - lower, - upper, - embedded_col_id, - property_id, - ); - } - - late final _isar_filter_list_lengthPtr = _lookup< - ffi.NativeFunction< - ffi.Int64 Function( - ffi.Pointer, - ffi.Pointer>, - ffi.Uint32, - ffi.Uint32, - ffi.Uint64, - ffi.Uint64)>>('isar_filter_list_length'); - late final _isar_filter_list_length = _isar_filter_list_lengthPtr.asFunction< - int Function(ffi.Pointer, - ffi.Pointer>, int, int, int, int)>(); - - int isar_filter_null( - ffi.Pointer collection, - ffi.Pointer> filter, - int embedded_col_id, - int property_id, - ) { - return _isar_filter_null( - collection, - filter, - embedded_col_id, - property_id, - ); - } - - late final _isar_filter_nullPtr = _lookup< - ffi.NativeFunction< - ffi.Int64 Function( - ffi.Pointer, - ffi.Pointer>, - ffi.Uint64, - ffi.Uint64)>>('isar_filter_null'); - late final _isar_filter_null = _isar_filter_nullPtr.asFunction< - int Function(ffi.Pointer, - ffi.Pointer>, int, int)>(); - - void isar_filter_id( - ffi.Pointer> filter, - int lower, - bool include_lower, - int upper, - bool include_upper, - ) { - return _isar_filter_id( - filter, - lower, - include_lower, - upper, - include_upper, - ); - } - - late final _isar_filter_idPtr = _lookup< - ffi.NativeFunction< - ffi.Void Function(ffi.Pointer>, ffi.Int64, - ffi.Bool, ffi.Int64, ffi.Bool)>>('isar_filter_id'); - late final _isar_filter_id = _isar_filter_idPtr.asFunction< - void Function(ffi.Pointer>, int, bool, int, bool)>(); - - int isar_filter_long( - ffi.Pointer collection, - ffi.Pointer> filter, - int lower, - bool include_lower, - int upper, - bool include_upper, - int embedded_col_id, - int property_id, - ) { - return _isar_filter_long( - collection, - filter, - lower, - include_lower, - upper, - include_upper, - embedded_col_id, - property_id, - ); - } - - late final _isar_filter_longPtr = _lookup< - ffi.NativeFunction< - ffi.Int64 Function( - ffi.Pointer, - ffi.Pointer>, - ffi.Int64, - ffi.Bool, - ffi.Int64, - ffi.Bool, - ffi.Uint64, - ffi.Uint64)>>('isar_filter_long'); - late final _isar_filter_long = _isar_filter_longPtr.asFunction< - int Function(ffi.Pointer, - ffi.Pointer>, int, bool, int, bool, int, int)>(); - - int isar_filter_double( - ffi.Pointer collection, - ffi.Pointer> filter, - double lower, - double upper, - int embedded_col_id, - int property_id, - ) { - return _isar_filter_double( - collection, - filter, - lower, - upper, - embedded_col_id, - property_id, - ); - } - - late final _isar_filter_doublePtr = _lookup< - ffi.NativeFunction< - ffi.Int64 Function( - ffi.Pointer, - ffi.Pointer>, - ffi.Double, - ffi.Double, - ffi.Uint64, - ffi.Uint64)>>('isar_filter_double'); - late final _isar_filter_double = _isar_filter_doublePtr.asFunction< - int Function(ffi.Pointer, - ffi.Pointer>, double, double, int, int)>(); - - int isar_filter_string( - ffi.Pointer collection, - ffi.Pointer> filter, - ffi.Pointer lower, - bool include_lower, - ffi.Pointer upper, - bool include_upper, - bool case_sensitive, - int embedded_col_id, - int property_id, - ) { - return _isar_filter_string( - collection, - filter, - lower, - include_lower, - upper, - include_upper, - case_sensitive, - embedded_col_id, - property_id, - ); - } - - late final _isar_filter_stringPtr = _lookup< - ffi.NativeFunction< - ffi.Int64 Function( - ffi.Pointer, - ffi.Pointer>, - ffi.Pointer, - ffi.Bool, - ffi.Pointer, - ffi.Bool, - ffi.Bool, - ffi.Uint64, - ffi.Uint64)>>('isar_filter_string'); - late final _isar_filter_string = _isar_filter_stringPtr.asFunction< - int Function( - ffi.Pointer, - ffi.Pointer>, - ffi.Pointer, - bool, - ffi.Pointer, - bool, - bool, - int, - int)>(); - - int isar_filter_string_starts_with( - ffi.Pointer collection, - ffi.Pointer> filter, - ffi.Pointer value, - bool case_sensitive, - int embedded_col_id, - int property_id, - ) { - return _isar_filter_string_starts_with( - collection, - filter, - value, - case_sensitive, - embedded_col_id, - property_id, - ); - } - - late final _isar_filter_string_starts_withPtr = _lookup< - ffi.NativeFunction< - ffi.Int64 Function( - ffi.Pointer, - ffi.Pointer>, - ffi.Pointer, - ffi.Bool, - ffi.Uint64, - ffi.Uint64)>>('isar_filter_string_starts_with'); - late final _isar_filter_string_starts_with = - _isar_filter_string_starts_withPtr.asFunction< - int Function( - ffi.Pointer, - ffi.Pointer>, - ffi.Pointer, - bool, - int, - int)>(); - - int isar_filter_string_ends_with( - ffi.Pointer collection, - ffi.Pointer> filter, - ffi.Pointer value, - bool case_sensitive, - int embedded_col_id, - int property_id, - ) { - return _isar_filter_string_ends_with( - collection, - filter, - value, - case_sensitive, - embedded_col_id, - property_id, - ); - } - - late final _isar_filter_string_ends_withPtr = _lookup< - ffi.NativeFunction< - ffi.Int64 Function( - ffi.Pointer, - ffi.Pointer>, - ffi.Pointer, - ffi.Bool, - ffi.Uint64, - ffi.Uint64)>>('isar_filter_string_ends_with'); - late final _isar_filter_string_ends_with = - _isar_filter_string_ends_withPtr.asFunction< - int Function( - ffi.Pointer, - ffi.Pointer>, - ffi.Pointer, - bool, - int, - int)>(); - - int isar_filter_string_contains( - ffi.Pointer collection, - ffi.Pointer> filter, - ffi.Pointer value, - bool case_sensitive, - int embedded_col_id, - int property_id, - ) { - return _isar_filter_string_contains( - collection, - filter, - value, - case_sensitive, - embedded_col_id, - property_id, - ); - } - - late final _isar_filter_string_containsPtr = _lookup< - ffi.NativeFunction< - ffi.Int64 Function( - ffi.Pointer, - ffi.Pointer>, - ffi.Pointer, - ffi.Bool, - ffi.Uint64, - ffi.Uint64)>>('isar_filter_string_contains'); - late final _isar_filter_string_contains = - _isar_filter_string_containsPtr.asFunction< - int Function( - ffi.Pointer, - ffi.Pointer>, - ffi.Pointer, - bool, - int, - int)>(); - - int isar_filter_string_matches( - ffi.Pointer collection, - ffi.Pointer> filter, - ffi.Pointer value, - bool case_sensitive, - int embedded_col_id, - int property_id, - ) { - return _isar_filter_string_matches( - collection, - filter, - value, - case_sensitive, - embedded_col_id, - property_id, - ); - } - - late final _isar_filter_string_matchesPtr = _lookup< - ffi.NativeFunction< - ffi.Int64 Function( - ffi.Pointer, - ffi.Pointer>, - ffi.Pointer, - ffi.Bool, - ffi.Uint64, - ffi.Uint64)>>('isar_filter_string_matches'); - late final _isar_filter_string_matches = - _isar_filter_string_matchesPtr.asFunction< - int Function( - ffi.Pointer, - ffi.Pointer>, - ffi.Pointer, - bool, - int, - int)>(); - - void isar_key_create( - ffi.Pointer> key, - ) { - return _isar_key_create( - key, - ); - } - - late final _isar_key_createPtr = _lookup< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer>)>>('isar_key_create'); - late final _isar_key_create = _isar_key_createPtr - .asFunction>)>(); - - bool isar_key_increase( - ffi.Pointer key, - ) { - return _isar_key_increase( - key, - ); - } - - late final _isar_key_increasePtr = - _lookup)>>( - 'isar_key_increase'); - late final _isar_key_increase = - _isar_key_increasePtr.asFunction)>(); - - bool isar_key_decrease( - ffi.Pointer key, - ) { - return _isar_key_decrease( - key, - ); - } - - late final _isar_key_decreasePtr = - _lookup)>>( - 'isar_key_decrease'); - late final _isar_key_decrease = - _isar_key_decreasePtr.asFunction)>(); - - void isar_key_add_byte( - ffi.Pointer key, - int value, - ) { - return _isar_key_add_byte( - key, - value, - ); - } - - late final _isar_key_add_bytePtr = _lookup< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, ffi.Uint8)>>('isar_key_add_byte'); - late final _isar_key_add_byte = _isar_key_add_bytePtr - .asFunction, int)>(); - - void isar_key_add_int( - ffi.Pointer key, - int value, - ) { - return _isar_key_add_int( - key, - value, - ); - } - - late final _isar_key_add_intPtr = _lookup< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, ffi.Int32)>>('isar_key_add_int'); - late final _isar_key_add_int = _isar_key_add_intPtr - .asFunction, int)>(); - - void isar_key_add_long( - ffi.Pointer key, - int value, - ) { - return _isar_key_add_long( - key, - value, - ); - } - - late final _isar_key_add_longPtr = _lookup< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, ffi.Int64)>>('isar_key_add_long'); - late final _isar_key_add_long = _isar_key_add_longPtr - .asFunction, int)>(); - - void isar_key_add_float( - ffi.Pointer key, - double value, - ) { - return _isar_key_add_float( - key, - value, - ); - } - - late final _isar_key_add_floatPtr = _lookup< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, ffi.Double)>>('isar_key_add_float'); - late final _isar_key_add_float = _isar_key_add_floatPtr - .asFunction, double)>(); - - void isar_key_add_double( - ffi.Pointer key, - double value, - ) { - return _isar_key_add_double( - key, - value, - ); - } - - late final _isar_key_add_doublePtr = _lookup< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, ffi.Double)>>('isar_key_add_double'); - late final _isar_key_add_double = _isar_key_add_doublePtr - .asFunction, double)>(); - - void isar_key_add_string( - ffi.Pointer key, - ffi.Pointer value, - bool case_sensitive, - ) { - return _isar_key_add_string( - key, - value, - case_sensitive, - ); - } - - late final _isar_key_add_stringPtr = _lookup< - ffi.NativeFunction< - ffi.Void Function(ffi.Pointer, ffi.Pointer, - ffi.Bool)>>('isar_key_add_string'); - late final _isar_key_add_string = _isar_key_add_stringPtr.asFunction< - void Function(ffi.Pointer, ffi.Pointer, bool)>(); - - void isar_key_add_string_hash( - ffi.Pointer key, - ffi.Pointer value, - bool case_sensitive, - ) { - return _isar_key_add_string_hash( - key, - value, - case_sensitive, - ); - } - - late final _isar_key_add_string_hashPtr = _lookup< - ffi.NativeFunction< - ffi.Void Function(ffi.Pointer, ffi.Pointer, - ffi.Bool)>>('isar_key_add_string_hash'); - late final _isar_key_add_string_hash = - _isar_key_add_string_hashPtr.asFunction< - void Function(ffi.Pointer, ffi.Pointer, bool)>(); - - void isar_key_add_string_list_hash( - ffi.Pointer key, - ffi.Pointer> value, - int length, - bool case_sensitive, - ) { - return _isar_key_add_string_list_hash( - key, - value, - length, - case_sensitive, - ); - } - - late final _isar_key_add_string_list_hashPtr = _lookup< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer>, - ffi.Uint32, - ffi.Bool)>>('isar_key_add_string_list_hash'); - late final _isar_key_add_string_list_hash = - _isar_key_add_string_list_hashPtr.asFunction< - void Function(ffi.Pointer, - ffi.Pointer>, int, bool)>(); - - void isar_key_add_byte_list_hash( - ffi.Pointer key, - ffi.Pointer value, - int length, - ) { - return _isar_key_add_byte_list_hash( - key, - value, - length, - ); - } - - late final _isar_key_add_byte_list_hashPtr = _lookup< - ffi.NativeFunction< - ffi.Void Function(ffi.Pointer, ffi.Pointer, - ffi.Uint32)>>('isar_key_add_byte_list_hash'); - late final _isar_key_add_byte_list_hash = - _isar_key_add_byte_list_hashPtr.asFunction< - void Function(ffi.Pointer, ffi.Pointer, int)>(); - - void isar_key_add_int_list_hash( - ffi.Pointer key, - ffi.Pointer value, - int length, - ) { - return _isar_key_add_int_list_hash( - key, - value, - length, - ); - } - - late final _isar_key_add_int_list_hashPtr = _lookup< - ffi.NativeFunction< - ffi.Void Function(ffi.Pointer, ffi.Pointer, - ffi.Uint32)>>('isar_key_add_int_list_hash'); - late final _isar_key_add_int_list_hash = - _isar_key_add_int_list_hashPtr.asFunction< - void Function(ffi.Pointer, ffi.Pointer, int)>(); - - void isar_key_add_long_list_hash( - ffi.Pointer key, - ffi.Pointer value, - int length, - ) { - return _isar_key_add_long_list_hash( - key, - value, - length, - ); - } - - late final _isar_key_add_long_list_hashPtr = _lookup< - ffi.NativeFunction< - ffi.Void Function(ffi.Pointer, ffi.Pointer, - ffi.Uint32)>>('isar_key_add_long_list_hash'); - late final _isar_key_add_long_list_hash = - _isar_key_add_long_list_hashPtr.asFunction< - void Function(ffi.Pointer, ffi.Pointer, int)>(); - - ffi.Pointer isar_version() { - return _isar_version(); - } - - late final _isar_versionPtr = - _lookup Function()>>( - 'isar_version'); - late final _isar_version = - _isar_versionPtr.asFunction Function()>(); - - int isar_instance_create( - ffi.Pointer> isar, - ffi.Pointer name, - ffi.Pointer path, - ffi.Pointer schema_json, - int max_size_mib, - bool relaxed_durability, - int compact_min_file_size, - int compact_min_bytes, - double compact_min_ratio, - ) { - return _isar_instance_create( - isar, - name, - path, - schema_json, - max_size_mib, - relaxed_durability, - compact_min_file_size, - compact_min_bytes, - compact_min_ratio, - ); - } - - late final _isar_instance_createPtr = _lookup< - ffi.NativeFunction< - ffi.Int64 Function( - ffi.Pointer>, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Int64, - ffi.Bool, - ffi.Uint32, - ffi.Uint32, - ffi.Double)>>('isar_instance_create'); - late final _isar_instance_create = _isar_instance_createPtr.asFunction< - int Function( - ffi.Pointer>, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - int, - bool, - int, - int, - double)>(); - - void isar_instance_create_async( - ffi.Pointer> isar, - ffi.Pointer name, - ffi.Pointer path, - ffi.Pointer schema_json, - int max_size_mib, - bool relaxed_durability, - int compact_min_file_size, - int compact_min_bytes, - double compact_min_ratio, - int port, - ) { - return _isar_instance_create_async( - isar, - name, - path, - schema_json, - max_size_mib, - relaxed_durability, - compact_min_file_size, - compact_min_bytes, - compact_min_ratio, - port, - ); - } - - late final _isar_instance_create_asyncPtr = _lookup< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer>, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Int64, - ffi.Bool, - ffi.Uint32, - ffi.Uint32, - ffi.Double, - DartPort)>>('isar_instance_create_async'); - late final _isar_instance_create_async = - _isar_instance_create_asyncPtr.asFunction< - void Function( - ffi.Pointer>, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - int, - bool, - int, - int, - double, - int)>(); - - bool isar_instance_close( - ffi.Pointer isar, - ) { - return _isar_instance_close( - isar, - ); - } - - late final _isar_instance_closePtr = _lookup< - ffi.NativeFunction)>>( - 'isar_instance_close'); - late final _isar_instance_close = _isar_instance_closePtr - .asFunction)>(); - - bool isar_instance_close_and_delete( - ffi.Pointer isar, - ) { - return _isar_instance_close_and_delete( - isar, - ); - } - - late final _isar_instance_close_and_deletePtr = _lookup< - ffi.NativeFunction)>>( - 'isar_instance_close_and_delete'); - late final _isar_instance_close_and_delete = - _isar_instance_close_and_deletePtr - .asFunction)>(); - - ffi.Pointer isar_instance_get_path( - ffi.Pointer isar, - ) { - return _isar_instance_get_path( - isar, - ); - } - - late final _isar_instance_get_pathPtr = _lookup< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer)>>('isar_instance_get_path'); - late final _isar_instance_get_path = _isar_instance_get_pathPtr - .asFunction Function(ffi.Pointer)>(); - - int isar_instance_get_collection( - ffi.Pointer isar, - ffi.Pointer> collection, - int collection_id, - ) { - return _isar_instance_get_collection( - isar, - collection, - collection_id, - ); - } - - late final _isar_instance_get_collectionPtr = _lookup< - ffi.NativeFunction< - ffi.Int64 Function( - ffi.Pointer, - ffi.Pointer>, - ffi.Uint64)>>('isar_instance_get_collection'); - late final _isar_instance_get_collection = - _isar_instance_get_collectionPtr.asFunction< - int Function(ffi.Pointer, - ffi.Pointer>, int)>(); - - int isar_instance_get_size( - ffi.Pointer instance, - ffi.Pointer txn, - bool include_indexes, - bool include_links, - ffi.Pointer size, - ) { - return _isar_instance_get_size( - instance, - txn, - include_indexes, - include_links, - size, - ); - } - - late final _isar_instance_get_sizePtr = _lookup< - ffi.NativeFunction< - ffi.Int64 Function( - ffi.Pointer, - ffi.Pointer, - ffi.Bool, - ffi.Bool, - ffi.Pointer)>>('isar_instance_get_size'); - late final _isar_instance_get_size = _isar_instance_get_sizePtr.asFunction< - int Function(ffi.Pointer, ffi.Pointer, bool, - bool, ffi.Pointer)>(); - - void isar_instance_copy_to_file( - ffi.Pointer instance, - ffi.Pointer path, - int port, - ) { - return _isar_instance_copy_to_file( - instance, - path, - port, - ); - } - - late final _isar_instance_copy_to_filePtr = _lookup< - ffi.NativeFunction< - ffi.Void Function(ffi.Pointer, ffi.Pointer, - DartPort)>>('isar_instance_copy_to_file'); - late final _isar_instance_copy_to_file = - _isar_instance_copy_to_filePtr.asFunction< - void Function( - ffi.Pointer, ffi.Pointer, int)>(); - - int isar_instance_verify( - ffi.Pointer instance, - ffi.Pointer txn, - ) { - return _isar_instance_verify( - instance, - txn, - ); - } - - late final _isar_instance_verifyPtr = _lookup< - ffi.NativeFunction< - ffi.Int64 Function(ffi.Pointer, - ffi.Pointer)>>('isar_instance_verify'); - late final _isar_instance_verify = _isar_instance_verifyPtr.asFunction< - int Function(ffi.Pointer, ffi.Pointer)>(); - - int isar_get_offsets( - ffi.Pointer collection, - int embedded_col_id, - ffi.Pointer offsets, - ) { - return _isar_get_offsets( - collection, - embedded_col_id, - offsets, - ); - } - - late final _isar_get_offsetsPtr = _lookup< - ffi.NativeFunction< - ffi.Uint32 Function(ffi.Pointer, ffi.Uint64, - ffi.Pointer)>>('isar_get_offsets'); - late final _isar_get_offsets = _isar_get_offsetsPtr.asFunction< - int Function( - ffi.Pointer, int, ffi.Pointer)>(); - - int isar_link( - ffi.Pointer collection, - ffi.Pointer txn, - int link_id, - int id, - int target_id, - ) { - return _isar_link( - collection, - txn, - link_id, - id, - target_id, - ); - } - - late final _isar_linkPtr = _lookup< - ffi.NativeFunction< - ffi.Int64 Function( - ffi.Pointer, - ffi.Pointer, - ffi.Uint64, - ffi.Int64, - ffi.Int64)>>('isar_link'); - late final _isar_link = _isar_linkPtr.asFunction< - int Function(ffi.Pointer, ffi.Pointer, int, - int, int)>(); - - int isar_link_unlink( - ffi.Pointer collection, - ffi.Pointer txn, - int link_id, - int id, - int target_id, - ) { - return _isar_link_unlink( - collection, - txn, - link_id, - id, - target_id, - ); - } - - late final _isar_link_unlinkPtr = _lookup< - ffi.NativeFunction< - ffi.Int64 Function( - ffi.Pointer, - ffi.Pointer, - ffi.Uint64, - ffi.Int64, - ffi.Int64)>>('isar_link_unlink'); - late final _isar_link_unlink = _isar_link_unlinkPtr.asFunction< - int Function(ffi.Pointer, ffi.Pointer, int, - int, int)>(); - - int isar_link_unlink_all( - ffi.Pointer collection, - ffi.Pointer txn, - int link_id, - int id, - ) { - return _isar_link_unlink_all( - collection, - txn, - link_id, - id, - ); - } - - late final _isar_link_unlink_allPtr = _lookup< - ffi.NativeFunction< - ffi.Int64 Function( - ffi.Pointer, - ffi.Pointer, - ffi.Uint64, - ffi.Int64)>>('isar_link_unlink_all'); - late final _isar_link_unlink_all = _isar_link_unlink_allPtr.asFunction< - int Function( - ffi.Pointer, ffi.Pointer, int, int)>(); - - int isar_link_update_all( - ffi.Pointer collection, - ffi.Pointer txn, - int link_id, - int id, - ffi.Pointer ids, - int link_count, - int unlink_count, - bool replace, - ) { - return _isar_link_update_all( - collection, - txn, - link_id, - id, - ids, - link_count, - unlink_count, - replace, - ); - } - - late final _isar_link_update_allPtr = _lookup< - ffi.NativeFunction< - ffi.Int64 Function( - ffi.Pointer, - ffi.Pointer, - ffi.Uint64, - ffi.Int64, - ffi.Pointer, - ffi.Uint32, - ffi.Uint32, - ffi.Bool)>>('isar_link_update_all'); - late final _isar_link_update_all = _isar_link_update_allPtr.asFunction< - int Function(ffi.Pointer, ffi.Pointer, int, - int, ffi.Pointer, int, int, bool)>(); - - int isar_link_verify( - ffi.Pointer collection, - ffi.Pointer txn, - int link_id, - ffi.Pointer ids, - int ids_count, - ) { - return _isar_link_verify( - collection, - txn, - link_id, - ids, - ids_count, - ); - } - - late final _isar_link_verifyPtr = _lookup< - ffi.NativeFunction< - ffi.Int64 Function( - ffi.Pointer, - ffi.Pointer, - ffi.Uint64, - ffi.Pointer, - ffi.Uint32)>>('isar_link_verify'); - late final _isar_link_verify = _isar_link_verifyPtr.asFunction< - int Function(ffi.Pointer, ffi.Pointer, int, - ffi.Pointer, int)>(); - - ffi.Pointer isar_qb_create( - ffi.Pointer collection, - ) { - return _isar_qb_create( - collection, - ); - } - - late final _isar_qb_createPtr = _lookup< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer)>>('isar_qb_create'); - late final _isar_qb_create = _isar_qb_createPtr.asFunction< - ffi.Pointer Function(ffi.Pointer)>(); - - int isar_qb_add_id_where_clause( - ffi.Pointer builder, - int start_id, - int end_id, - ) { - return _isar_qb_add_id_where_clause( - builder, - start_id, - end_id, - ); - } - - late final _isar_qb_add_id_where_clausePtr = _lookup< - ffi.NativeFunction< - ffi.Int64 Function(ffi.Pointer, ffi.Int64, - ffi.Int64)>>('isar_qb_add_id_where_clause'); - late final _isar_qb_add_id_where_clause = _isar_qb_add_id_where_clausePtr - .asFunction, int, int)>(); - - int isar_qb_add_index_where_clause( - ffi.Pointer builder, - int index_id, - ffi.Pointer lower_key, - ffi.Pointer upper_key, - bool sort_asc, - bool skip_duplicates, - ) { - return _isar_qb_add_index_where_clause( - builder, - index_id, - lower_key, - upper_key, - sort_asc, - skip_duplicates, - ); - } - - late final _isar_qb_add_index_where_clausePtr = _lookup< - ffi.NativeFunction< - ffi.Int64 Function( - ffi.Pointer, - ffi.Uint64, - ffi.Pointer, - ffi.Pointer, - ffi.Bool, - ffi.Bool)>>('isar_qb_add_index_where_clause'); - late final _isar_qb_add_index_where_clause = - _isar_qb_add_index_where_clausePtr.asFunction< - int Function(ffi.Pointer, int, ffi.Pointer, - ffi.Pointer, bool, bool)>(); - - int isar_qb_add_link_where_clause( - ffi.Pointer builder, - ffi.Pointer source_collection, - int link_id, - int id, - ) { - return _isar_qb_add_link_where_clause( - builder, - source_collection, - link_id, - id, - ); - } - - late final _isar_qb_add_link_where_clausePtr = _lookup< - ffi.NativeFunction< - ffi.Int64 Function( - ffi.Pointer, - ffi.Pointer, - ffi.Uint64, - ffi.Int64)>>('isar_qb_add_link_where_clause'); - late final _isar_qb_add_link_where_clause = - _isar_qb_add_link_where_clausePtr.asFunction< - int Function(ffi.Pointer, ffi.Pointer, - int, int)>(); - - void isar_qb_set_filter( - ffi.Pointer builder, - ffi.Pointer filter, - ) { - return _isar_qb_set_filter( - builder, - filter, - ); - } - - late final _isar_qb_set_filterPtr = _lookup< - ffi.NativeFunction< - ffi.Void Function(ffi.Pointer, - ffi.Pointer)>>('isar_qb_set_filter'); - late final _isar_qb_set_filter = _isar_qb_set_filterPtr.asFunction< - void Function(ffi.Pointer, ffi.Pointer)>(); - - int isar_qb_add_sort_by( - ffi.Pointer builder, - int property_id, - bool asc, - ) { - return _isar_qb_add_sort_by( - builder, - property_id, - asc, - ); - } - - late final _isar_qb_add_sort_byPtr = _lookup< - ffi.NativeFunction< - ffi.Int64 Function(ffi.Pointer, ffi.Uint64, - ffi.Bool)>>('isar_qb_add_sort_by'); - late final _isar_qb_add_sort_by = _isar_qb_add_sort_byPtr - .asFunction, int, bool)>(); - - int isar_qb_add_distinct_by( - ffi.Pointer builder, - int property_id, - bool case_sensitive, - ) { - return _isar_qb_add_distinct_by( - builder, - property_id, - case_sensitive, - ); - } - - late final _isar_qb_add_distinct_byPtr = _lookup< - ffi.NativeFunction< - ffi.Int64 Function(ffi.Pointer, ffi.Uint64, - ffi.Bool)>>('isar_qb_add_distinct_by'); - late final _isar_qb_add_distinct_by = _isar_qb_add_distinct_byPtr - .asFunction, int, bool)>(); - - void isar_qb_set_offset_limit( - ffi.Pointer builder, - int offset, - int limit, - ) { - return _isar_qb_set_offset_limit( - builder, - offset, - limit, - ); - } - - late final _isar_qb_set_offset_limitPtr = _lookup< - ffi.NativeFunction< - ffi.Void Function(ffi.Pointer, ffi.Int64, - ffi.Int64)>>('isar_qb_set_offset_limit'); - late final _isar_qb_set_offset_limit = _isar_qb_set_offset_limitPtr - .asFunction, int, int)>(); - - ffi.Pointer isar_qb_build( - ffi.Pointer builder, - ) { - return _isar_qb_build( - builder, - ); - } - - late final _isar_qb_buildPtr = _lookup< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer)>>('isar_qb_build'); - late final _isar_qb_build = _isar_qb_buildPtr - .asFunction Function(ffi.Pointer)>(); - - void isar_q_free( - ffi.Pointer query, - ) { - return _isar_q_free( - query, - ); - } - - late final _isar_q_freePtr = - _lookup)>>( - 'isar_q_free'); - late final _isar_q_free = - _isar_q_freePtr.asFunction)>(); - - int isar_q_find( - ffi.Pointer query, - ffi.Pointer txn, - ffi.Pointer result, - int limit, - ) { - return _isar_q_find( - query, - txn, - result, - limit, - ); - } - - late final _isar_q_findPtr = _lookup< - ffi.NativeFunction< - ffi.Int64 Function(ffi.Pointer, ffi.Pointer, - ffi.Pointer, ffi.Uint32)>>('isar_q_find'); - late final _isar_q_find = _isar_q_findPtr.asFunction< - int Function(ffi.Pointer, ffi.Pointer, - ffi.Pointer, int)>(); - - int isar_q_delete( - ffi.Pointer query, - ffi.Pointer collection, - ffi.Pointer txn, - int limit, - ffi.Pointer count, - ) { - return _isar_q_delete( - query, - collection, - txn, - limit, - count, - ); - } - - late final _isar_q_deletePtr = _lookup< - ffi.NativeFunction< - ffi.Int64 Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Uint32, - ffi.Pointer)>>('isar_q_delete'); - late final _isar_q_delete = _isar_q_deletePtr.asFunction< - int Function(ffi.Pointer, ffi.Pointer, - ffi.Pointer, int, ffi.Pointer)>(); - - int isar_q_export_json( - ffi.Pointer query, - ffi.Pointer collection, - ffi.Pointer txn, - ffi.Pointer id_name, - ffi.Pointer> json_bytes, - ffi.Pointer json_length, - ) { - return _isar_q_export_json( - query, - collection, - txn, - id_name, - json_bytes, - json_length, - ); - } - - late final _isar_q_export_jsonPtr = _lookup< - ffi.NativeFunction< - ffi.Int64 Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer>, - ffi.Pointer)>>('isar_q_export_json'); - late final _isar_q_export_json = _isar_q_export_jsonPtr.asFunction< - int Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer>, - ffi.Pointer)>(); - - void isar_free_json( - ffi.Pointer json_bytes, - int json_length, - ) { - return _isar_free_json( - json_bytes, - json_length, - ); - } - - late final _isar_free_jsonPtr = _lookup< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, ffi.Uint32)>>('isar_free_json'); - late final _isar_free_json = _isar_free_jsonPtr - .asFunction, int)>(); - - int isar_q_aggregate( - ffi.Pointer collection, - ffi.Pointer query, - ffi.Pointer txn, - int operation, - int property_id, - ffi.Pointer> result, - ) { - return _isar_q_aggregate( - collection, - query, - txn, - operation, - property_id, - result, - ); - } - - late final _isar_q_aggregatePtr = _lookup< - ffi.NativeFunction< - ffi.Int64 Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Uint8, - ffi.Uint64, - ffi.Pointer>)>>( - 'isar_q_aggregate'); - late final _isar_q_aggregate = _isar_q_aggregatePtr.asFunction< - int Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - int, - int, - ffi.Pointer>)>(); - - int isar_q_aggregate_long_result( - ffi.Pointer result, - ) { - return _isar_q_aggregate_long_result( - result, - ); - } - - late final _isar_q_aggregate_long_resultPtr = _lookup< - ffi.NativeFunction< - ffi.Int64 Function(ffi.Pointer)>>( - 'isar_q_aggregate_long_result'); - late final _isar_q_aggregate_long_result = _isar_q_aggregate_long_resultPtr - .asFunction)>(); - - double isar_q_aggregate_double_result( - ffi.Pointer result, - ) { - return _isar_q_aggregate_double_result( - result, - ); - } - - late final _isar_q_aggregate_double_resultPtr = _lookup< - ffi.NativeFunction< - ffi.Double Function(ffi.Pointer)>>( - 'isar_q_aggregate_double_result'); - late final _isar_q_aggregate_double_result = - _isar_q_aggregate_double_resultPtr - .asFunction)>(); - - int isar_txn_begin( - ffi.Pointer isar, - ffi.Pointer> txn, - bool sync1, - bool write, - bool silent, - int port, - ) { - return _isar_txn_begin( - isar, - txn, - sync1, - write, - silent, - port, - ); - } - - late final _isar_txn_beginPtr = _lookup< - ffi.NativeFunction< - ffi.Int64 Function( - ffi.Pointer, - ffi.Pointer>, - ffi.Bool, - ffi.Bool, - ffi.Bool, - DartPort)>>('isar_txn_begin'); - late final _isar_txn_begin = _isar_txn_beginPtr.asFunction< - int Function(ffi.Pointer, - ffi.Pointer>, bool, bool, bool, int)>(); - - int isar_txn_finish( - ffi.Pointer txn, - bool commit, - ) { - return _isar_txn_finish( - txn, - commit, - ); - } - - late final _isar_txn_finishPtr = _lookup< - ffi.NativeFunction< - ffi.Int64 Function( - ffi.Pointer, ffi.Bool)>>('isar_txn_finish'); - late final _isar_txn_finish = _isar_txn_finishPtr - .asFunction, bool)>(); - - ffi.Pointer isar_watch_collection( - ffi.Pointer isar, - ffi.Pointer collection, - int port, - ) { - return _isar_watch_collection( - isar, - collection, - port, - ); - } - - late final _isar_watch_collectionPtr = _lookup< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - DartPort)>>('isar_watch_collection'); - late final _isar_watch_collection = _isar_watch_collectionPtr.asFunction< - ffi.Pointer Function( - ffi.Pointer, ffi.Pointer, int)>(); - - ffi.Pointer isar_watch_object( - ffi.Pointer isar, - ffi.Pointer collection, - int id, - int port, - ) { - return _isar_watch_object( - isar, - collection, - id, - port, - ); - } - - late final _isar_watch_objectPtr = _lookup< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ffi.Int64, - DartPort)>>('isar_watch_object'); - late final _isar_watch_object = _isar_watch_objectPtr.asFunction< - ffi.Pointer Function(ffi.Pointer, - ffi.Pointer, int, int)>(); - - ffi.Pointer isar_watch_query( - ffi.Pointer isar, - ffi.Pointer collection, - ffi.Pointer query, - int port, - ) { - return _isar_watch_query( - isar, - collection, - query, - port, - ); - } - - late final _isar_watch_queryPtr = _lookup< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - DartPort)>>('isar_watch_query'); - late final _isar_watch_query = _isar_watch_queryPtr.asFunction< - ffi.Pointer Function(ffi.Pointer, - ffi.Pointer, ffi.Pointer, int)>(); - - void isar_stop_watching( - ffi.Pointer handle, - ) { - return _isar_stop_watching( - handle, - ); - } - - late final _isar_stop_watchingPtr = - _lookup)>>( - 'isar_stop_watching'); - late final _isar_stop_watching = _isar_stop_watchingPtr - .asFunction)>(); -} - -class CObject extends ffi.Struct { - @ffi.Int64() - external int id; - - external ffi.Pointer buffer; - - @ffi.Uint32() - external int buffer_length; -} - -class CObjectSet extends ffi.Struct { - external ffi.Pointer objects; - - @ffi.Uint32() - external int length; -} - -class CIsarCollection extends ffi.Opaque {} - -class CIsarTxn extends ffi.Opaque {} - -class CIndexKey extends ffi.Opaque {} - -typedef DartPostCObjectFnType = ffi.Pointer< - ffi.NativeFunction)>>; -typedef DartPort = ffi.Int64; - -class CDartCObject extends ffi.Opaque {} - -class CFilter extends ffi.Opaque {} - -class CIsarInstance extends ffi.Opaque {} - -class CQueryBuilder extends ffi.Opaque {} - -class CQuery extends ffi.Opaque {} - -class CAggregationResult extends ffi.Opaque {} - -class CWatchHandle extends ffi.Opaque {} - -const int IsarIndex_MAX_STRING_INDEX_SIZE = 1024; - -const int IsarObject_NULL_BYTE = 0; - -const int IsarObject_NULL_BOOL = 0; - -const int IsarObject_FALSE_BOOL = 1; - -const int IsarObject_TRUE_BOOL = 2; - -const int IsarObject_NULL_INT = -2147483648; - -const int IsarObject_NULL_LONG = -9223372036854775808; - -const int IsarObject_MAX_SIZE = 33554432; - -const int SchemaManager_ISAR_FILE_VERSION = 2; diff --git a/packages_external/isar-3.1.0-1/packages/isar/lib/src/native/encode_string.dart b/packages_external/isar-3.1.0-1/packages/isar/lib/src/native/encode_string.dart deleted file mode 100644 index a21aa545..00000000 --- a/packages_external/isar-3.1.0-1/packages/isar/lib/src/native/encode_string.dart +++ /dev/null @@ -1,54 +0,0 @@ -import 'dart:ffi'; -import 'dart:typed_data'; - -const int _oneByteLimit = 0x7f; // 7 bits -const int _twoByteLimit = 0x7ff; // 11 bits -const int _surrogateTagMask = 0xFC00; -const int _surrogateValueMask = 0x3FF; -const int _leadSurrogateMin = 0xD800; - -/// Encodes a Dart String to UTF8, writes it at [offset] into [buffer] and -/// returns the number of written bytes. -/// -/// The buffer needs to have a capacity of at least `offset + str.length * 3`. -int encodeString(String str, Uint8List buffer, int offset) { - final startOffset = offset; - for (var stringIndex = 0; stringIndex < str.length; stringIndex++) { - final codeUnit = str.codeUnitAt(stringIndex); - // ASCII has the same representation in UTF-8 and UTF-16. - if (codeUnit <= _oneByteLimit) { - buffer[offset++] = codeUnit; - } else if ((codeUnit & _surrogateTagMask) == _leadSurrogateMin) { - // combine surrogate pair - final nextCodeUnit = str.codeUnitAt(++stringIndex); - final rune = 0x10000 + ((codeUnit & _surrogateValueMask) << 10) | - (nextCodeUnit & _surrogateValueMask); - // If the rune is encoded with 2 code-units then it must be encoded - // with 4 bytes in UTF-8. - buffer[offset++] = 0xF0 | (rune >> 18); - buffer[offset++] = 0x80 | ((rune >> 12) & 0x3f); - buffer[offset++] = 0x80 | ((rune >> 6) & 0x3f); - buffer[offset++] = 0x80 | (rune & 0x3f); - } else if (codeUnit <= _twoByteLimit) { - buffer[offset++] = 0xC0 | (codeUnit >> 6); - buffer[offset++] = 0x80 | (codeUnit & 0x3f); - } else { - buffer[offset++] = 0xE0 | (codeUnit >> 12); - buffer[offset++] = 0x80 | ((codeUnit >> 6) & 0x3f); - buffer[offset++] = 0x80 | (codeUnit & 0x3f); - } - } - return offset - startOffset; -} - -/// @nodoc -extension CString on String { - /// Create a zero terminated C-String from a Dart String - Pointer toCString(Allocator alloc) { - final bufferPtr = alloc(length * 3 + 1); - final buffer = bufferPtr.asTypedList(length * 3 + 1); - final size = encodeString(this, buffer, 0); - buffer[size] = 0; - return bufferPtr.cast(); - } -} diff --git a/packages_external/isar-3.1.0-1/packages/isar/lib/src/native/index_key.dart b/packages_external/isar-3.1.0-1/packages/isar/lib/src/native/index_key.dart deleted file mode 100644 index 04225785..00000000 --- a/packages_external/isar-3.1.0-1/packages/isar/lib/src/native/index_key.dart +++ /dev/null @@ -1,257 +0,0 @@ -// ignore_for_file: public_member_api_docs - -import 'dart:ffi'; - -import 'package:ffi/ffi.dart'; -import 'package:isar/isar.dart'; -import 'package:isar/src/native/bindings.dart'; -import 'package:isar/src/native/encode_string.dart'; -import 'package:isar/src/native/isar_core.dart'; -import 'package:isar/src/native/isar_writer_impl.dart'; - -final _keyPtrPtr = malloc>(); - -Pointer buildIndexKey( - CollectionSchema schema, - IndexSchema index, - IndexKey key, -) { - if (key.length > index.properties.length) { - throw IsarError('Invalid number of values for index ${index.name}.'); - } - - IC.isar_key_create(_keyPtrPtr); - final keyPtr = _keyPtrPtr.value; - - for (var i = 0; i < key.length; i++) { - final indexProperty = index.properties[i]; - _addKeyValue( - keyPtr, - key[i], - schema.property(indexProperty.name), - indexProperty.type, - indexProperty.caseSensitive, - ); - } - - return keyPtr; -} - -Pointer buildLowerUnboundedIndexKey() { - IC.isar_key_create(_keyPtrPtr); - return _keyPtrPtr.value; -} - -Pointer buildUpperUnboundedIndexKey() { - IC.isar_key_create(_keyPtrPtr); - final keyPtr = _keyPtrPtr.value; - IC.isar_key_add_long(keyPtr, maxLong); - - return keyPtr; -} - -void _addKeyValue( - Pointer keyPtr, - Object? value, - PropertySchema property, - IndexType type, - bool caseSensitive, -) { - if (property.enumMap != null) { - if (value is Enum) { - value = property.enumMap![value.name]; - } else if (value is List) { - value = value.map((e) { - if (e is Enum) { - return property.enumMap![e.name]; - } else { - return e; - } - }).toList(); - } - } - - final isarType = - type != IndexType.hash ? property.type.scalarType : property.type; - switch (isarType) { - case IsarType.bool: - IC.isar_key_add_byte(keyPtr, (value as bool?).byteValue); - break; - case IsarType.byte: - IC.isar_key_add_byte(keyPtr, (value ?? 0) as int); - break; - case IsarType.int: - IC.isar_key_add_int(keyPtr, (value as int?) ?? nullInt); - break; - case IsarType.float: - IC.isar_key_add_float(keyPtr, (value as double?) ?? nullFloat); - break; - case IsarType.long: - IC.isar_key_add_long(keyPtr, (value as int?) ?? nullLong); - break; - case IsarType.double: - IC.isar_key_add_double(keyPtr, (value as double?) ?? nullDouble); - break; - case IsarType.dateTime: - IC.isar_key_add_long(keyPtr, (value as DateTime?).longValue); - break; - case IsarType.string: - final strPtr = _strToNative(value as String?); - if (type == IndexType.value) { - IC.isar_key_add_string(keyPtr, strPtr, caseSensitive); - } else { - IC.isar_key_add_string_hash(keyPtr, strPtr, caseSensitive); - } - _freeStr(strPtr); - break; - case IsarType.boolList: - if (value == null) { - IC.isar_key_add_byte_list_hash(keyPtr, nullptr, 0); - } else { - value as List; - final boolListPtr = malloc(value.length); - boolListPtr - .asTypedList(value.length) - .setAll(0, value.map((e) => e.byteValue)); - IC.isar_key_add_byte_list_hash(keyPtr, boolListPtr, value.length); - malloc.free(boolListPtr); - } - break; - case IsarType.byteList: - if (value == null) { - IC.isar_key_add_byte_list_hash(keyPtr, nullptr, 0); - } else { - value as List; - final bytesPtr = malloc(value.length); - bytesPtr.asTypedList(value.length).setAll(0, value); - IC.isar_key_add_byte_list_hash(keyPtr, bytesPtr, value.length); - malloc.free(bytesPtr); - } - break; - case IsarType.intList: - if (value == null) { - IC.isar_key_add_int_list_hash(keyPtr, nullptr, 0); - } else { - value as List; - final intListPtr = malloc(value.length); - intListPtr - .asTypedList(value.length) - .setAll(0, value.map((e) => e ?? nullInt)); - IC.isar_key_add_int_list_hash(keyPtr, intListPtr, value.length); - malloc.free(intListPtr); - } - break; - case IsarType.longList: - if (value == null) { - IC.isar_key_add_long_list_hash(keyPtr, nullptr, 0); - } else { - value as List; - final longListPtr = malloc(value.length); - longListPtr - .asTypedList(value.length) - .setAll(0, value.map((e) => e ?? nullLong)); - IC.isar_key_add_long_list_hash(keyPtr, longListPtr, value.length); - malloc.free(longListPtr); - } - break; - case IsarType.dateTimeList: - if (value == null) { - IC.isar_key_add_long_list_hash(keyPtr, nullptr, 0); - } else { - value as List; - final longListPtr = malloc(value.length); - for (var i = 0; i < value.length; i++) { - longListPtr[i] = value[i].longValue; - } - IC.isar_key_add_long_list_hash(keyPtr, longListPtr, value.length); - } - break; - case IsarType.stringList: - if (value == null) { - IC.isar_key_add_string_list_hash(keyPtr, nullptr, 0, false); - } else { - value as List; - final stringListPtr = malloc>(value.length); - for (var i = 0; i < value.length; i++) { - stringListPtr[i] = _strToNative(value[i]); - } - IC.isar_key_add_string_list_hash( - keyPtr, - stringListPtr, - value.length, - caseSensitive, - ); - for (var i = 0; i < value.length; i++) { - _freeStr(stringListPtr[i]); - } - } - break; - case IsarType.object: - case IsarType.floatList: - case IsarType.doubleList: - case IsarType.objectList: - throw IsarError('Unsupported property type.'); - } -} - -Pointer _strToNative(String? str) { - if (str == null) { - return Pointer.fromAddress(0); - } else { - return str.toCString(malloc); - } -} - -void _freeStr(Pointer strPtr) { - if (!strPtr.isNull) { - malloc.free(strPtr); - } -} - -double? adjustFloatBound({ - required double? value, - required bool lowerBound, - required bool include, - required double epsilon, -}) { - value ??= double.nan; - - if (lowerBound) { - if (include) { - if (value.isFinite) { - return value - epsilon; - } - } else { - if (value.isNaN) { - return double.negativeInfinity; - } else if (value == double.negativeInfinity) { - return -double.maxFinite; - } else if (value == double.maxFinite) { - return double.infinity; - } else if (value == double.infinity) { - return null; - } else { - return value + epsilon; - } - } - } else { - if (include) { - if (value.isFinite) { - return value + epsilon; - } - } else { - if (value.isNaN) { - return null; - } else if (value == double.negativeInfinity) { - return double.nan; - } else if (value == -double.maxFinite) { - return double.negativeInfinity; - } else if (value == double.infinity) { - return double.maxFinite; - } else { - return value - epsilon; - } - } - } - return value; -} diff --git a/packages_external/isar-3.1.0-1/packages/isar/lib/src/native/isar_collection_impl.dart b/packages_external/isar-3.1.0-1/packages/isar/lib/src/native/isar_collection_impl.dart deleted file mode 100644 index 747942e0..00000000 --- a/packages_external/isar-3.1.0-1/packages/isar/lib/src/native/isar_collection_impl.dart +++ /dev/null @@ -1,649 +0,0 @@ -// ignore_for_file: public_member_api_docs, invalid_use_of_protected_member - -import 'dart:async'; -import 'dart:convert'; -import 'dart:ffi'; -import 'dart:isolate'; -import 'dart:typed_data'; - -import 'package:ffi/ffi.dart'; -import 'package:isar/isar.dart'; -import 'package:isar/src/native/bindings.dart'; -import 'package:isar/src/native/encode_string.dart'; -import 'package:isar/src/native/index_key.dart'; -import 'package:isar/src/native/isar_core.dart'; -import 'package:isar/src/native/isar_impl.dart'; -import 'package:isar/src/native/isar_reader_impl.dart'; -import 'package:isar/src/native/isar_writer_impl.dart'; -import 'package:isar/src/native/query_build.dart'; -import 'package:isar/src/native/txn.dart'; - -class IsarCollectionImpl extends IsarCollection { - IsarCollectionImpl({ - required this.isar, - required this.ptr, - required this.schema, - }); - - @override - final IsarImpl isar; - final Pointer ptr; - - @override - final CollectionSchema schema; - - late final _offsets = isar.offsets[OBJ]!; - late final _staticSize = _offsets.last; - - @pragma('vm:prefer-inline') - OBJ deserializeObject(CObject cObj) { - final buffer = cObj.buffer.asTypedList(cObj.buffer_length); - final reader = IsarReaderImpl(buffer); - final object = schema.deserialize( - cObj.id, - reader, - _offsets, - isar.offsets, - ); - schema.attach(this, cObj.id, object); - return object; - } - - @pragma('vm:prefer-inline') - OBJ? deserializeObjectOrNull(CObject cObj) { - if (!cObj.buffer.isNull) { - return deserializeObject(cObj); - } else { - return null; - } - } - - @pragma('vm:prefer-inline') - List deserializeObjects(CObjectSet objectSet) { - final objects = []; - for (var i = 0; i < objectSet.length; i++) { - final cObjPtr = objectSet.objects.elementAt(i); - final object = deserializeObject(cObjPtr.ref); - objects.add(object); - } - return objects; - } - - @pragma('vm:prefer-inline') - List deserializeObjectsOrNull(CObjectSet objectSet) { - final objects = List.filled(objectSet.length, null); - for (var i = 0; i < objectSet.length; i++) { - final cObj = objectSet.objects.elementAt(i).ref; - if (!cObj.buffer.isNull) { - objects[i] = deserializeObject(cObj); - } - } - return objects; - } - - @pragma('vm:prefer-inline') - Pointer> _getKeysPtr( - String indexName, - List keys, - Allocator alloc, - ) { - final keysPtrPtr = alloc>(keys.length); - for (var i = 0; i < keys.length; i++) { - keysPtrPtr[i] = buildIndexKey(schema, schema.index(indexName), keys[i]); - } - return keysPtrPtr; - } - - List deserializeProperty(CObjectSet objectSet, int? propertyId) { - final values = []; - if (propertyId != null) { - final propertyOffset = _offsets[propertyId]; - for (var i = 0; i < objectSet.length; i++) { - final cObj = objectSet.objects.elementAt(i).ref; - final buffer = cObj.buffer.asTypedList(cObj.buffer_length); - values.add( - schema.deserializeProp( - IsarReaderImpl(buffer), - propertyId, - propertyOffset, - isar.offsets, - ) as T, - ); - } - } else { - for (var i = 0; i < objectSet.length; i++) { - final cObj = objectSet.objects.elementAt(i).ref; - values.add(cObj.id as T); - } - } - return values; - } - - void serializeObjects( - Txn txn, - Pointer objectsPtr, - List objects, - ) { - var maxBufferSize = 0; - for (var i = 0; i < objects.length; i++) { - final object = objects[i]; - maxBufferSize += schema.estimateSize(object, _offsets, isar.offsets); - } - final bufferPtr = txn.alloc(maxBufferSize); - final buffer = bufferPtr.asTypedList(maxBufferSize).buffer; - - var writtenBytes = 0; - for (var i = 0; i < objects.length; i++) { - final objBuffer = buffer.asUint8List(writtenBytes); - final binaryWriter = IsarWriterImpl(objBuffer, _staticSize); - - final object = objects[i]; - schema.serialize( - object, - binaryWriter, - _offsets, - isar.offsets, - ); - final size = binaryWriter.usedBytes; - - final cObj = objectsPtr.elementAt(i).ref; - cObj.id = schema.getId(object); - cObj.buffer = bufferPtr.elementAt(writtenBytes); - cObj.buffer_length = size; - - writtenBytes += size; - } - } - - @override - Future> getAll(List ids) { - return isar.getTxn(false, (Txn txn) async { - final cObjSetPtr = txn.newCObjectSet(ids.length); - final objectsPtr = cObjSetPtr.ref.objects; - for (var i = 0; i < ids.length; i++) { - objectsPtr.elementAt(i).ref.id = ids[i]; - } - IC.isar_get_all(ptr, txn.ptr, cObjSetPtr); - await txn.wait(); - return deserializeObjectsOrNull(cObjSetPtr.ref); - }); - } - - @override - List getAllSync(List ids) { - return isar.getTxnSync(false, (Txn txn) { - final cObjPtr = txn.getCObject(); - final cObj = cObjPtr.ref; - - final objects = List.filled(ids.length, null); - for (var i = 0; i < ids.length; i++) { - cObj.id = ids[i]; - nCall(IC.isar_get(ptr, txn.ptr, cObjPtr)); - objects[i] = deserializeObjectOrNull(cObj); - } - - return objects; - }); - } - - @override - Future> getAllByIndex(String indexName, List keys) { - return isar.getTxn(false, (Txn txn) async { - final cObjSetPtr = txn.newCObjectSet(keys.length); - final keysPtrPtr = _getKeysPtr(indexName, keys, txn.alloc); - IC.isar_get_all_by_index( - ptr, - txn.ptr, - schema.index(indexName).id, - keysPtrPtr, - cObjSetPtr, - ); - await txn.wait(); - return deserializeObjectsOrNull(cObjSetPtr.ref); - }); - } - - @override - List getAllByIndexSync(String indexName, List keys) { - final index = schema.index(indexName); - - return isar.getTxnSync(false, (Txn txn) { - final cObjPtr = txn.getCObject(); - final cObj = cObjPtr.ref; - - final objects = List.filled(keys.length, null); - for (var i = 0; i < keys.length; i++) { - final keyPtr = buildIndexKey(schema, index, keys[i]); - nCall(IC.isar_get_by_index(ptr, txn.ptr, index.id, keyPtr, cObjPtr)); - objects[i] = deserializeObjectOrNull(cObj); - } - - return objects; - }); - } - - @override - int putSync(OBJ object, {bool saveLinks = true}) { - return isar.getTxnSync(true, (Txn txn) { - return putByIndexSyncInternal( - txn: txn, - object: object, - saveLinks: saveLinks, - ); - }); - } - - @override - int putByIndexSync(String indexName, OBJ object, {bool saveLinks = true}) { - return isar.getTxnSync(true, (Txn txn) { - return putByIndexSyncInternal( - txn: txn, - object: object, - indexId: schema.index(indexName).id, - saveLinks: saveLinks, - ); - }); - } - - int putByIndexSyncInternal({ - required Txn txn, - required OBJ object, - int? indexId, - bool saveLinks = true, - }) { - final cObjPtr = txn.getCObject(); - final cObj = cObjPtr.ref; - - final estimatedSize = schema.estimateSize(object, _offsets, isar.offsets); - cObj.buffer = txn.getBuffer(estimatedSize); - final buffer = cObj.buffer.asTypedList(estimatedSize); - - final writer = IsarWriterImpl(buffer, _staticSize); - schema.serialize( - object, - writer, - _offsets, - isar.offsets, - ); - cObj.buffer_length = writer.usedBytes; - - cObj.id = schema.getId(object); - - if (indexId != null) { - nCall(IC.isar_put_by_index(ptr, txn.ptr, indexId, cObjPtr)); - } else { - nCall(IC.isar_put(ptr, txn.ptr, cObjPtr)); - } - - final id = cObj.id; - schema.attach(this, id, object); - - if (saveLinks) { - for (final link in schema.getLinks(object)) { - link.saveSync(); - } - } - - return id; - } - - @override - Future> putAll(List objects) { - return putAllByIndex(null, objects); - } - - @override - List putAllSync(List objects, {bool saveLinks = true}) { - return putAllByIndexSync(null, objects, saveLinks: saveLinks); - } - - @override - Future> putAllByIndex(String? indexName, List objects) { - final indexId = indexName != null ? schema.index(indexName).id : null; - - return isar.getTxn(true, (Txn txn) async { - final cObjSetPtr = txn.newCObjectSet(objects.length); - serializeObjects(txn, cObjSetPtr.ref.objects, objects); - - if (indexId != null) { - IC.isar_put_all_by_index(ptr, txn.ptr, indexId, cObjSetPtr); - } else { - IC.isar_put_all(ptr, txn.ptr, cObjSetPtr); - } - - await txn.wait(); - final cObjectSet = cObjSetPtr.ref; - final ids = List.filled(objects.length, 0); - for (var i = 0; i < objects.length; i++) { - final cObjPtr = cObjectSet.objects.elementAt(i); - final id = cObjPtr.ref.id; - ids[i] = id; - - final object = objects[i]; - schema.attach(this, id, object); - } - return ids; - }); - } - - @override - List putAllByIndexSync( - String? indexName, - List objects, { - bool saveLinks = true, - }) { - final indexId = indexName != null ? schema.index(indexName).id : null; - final ids = List.filled(objects.length, 0); - isar.getTxnSync(true, (Txn txn) { - for (var i = 0; i < objects.length; i++) { - ids[i] = putByIndexSyncInternal( - txn: txn, - object: objects[i], - indexId: indexId, - saveLinks: saveLinks, - ); - } - }); - return ids; - } - - @override - Future deleteAll(List ids) { - return isar.getTxn(true, (Txn txn) async { - final countPtr = txn.alloc(); - final idsPtr = txn.alloc(ids.length); - idsPtr.asTypedList(ids.length).setAll(0, ids); - - IC.isar_delete_all(ptr, txn.ptr, idsPtr, ids.length, countPtr); - await txn.wait(); - - return countPtr.value; - }); - } - - @override - int deleteAllSync(List ids) { - return isar.getTxnSync(true, (Txn txn) { - final deletedPtr = txn.alloc(); - - var counter = 0; - for (var i = 0; i < ids.length; i++) { - nCall(IC.isar_delete(ptr, txn.ptr, ids[i], deletedPtr)); - if (deletedPtr.value) { - counter++; - } - } - return counter; - }); - } - - @override - Future deleteAllByIndex(String indexName, List keys) { - return isar.getTxn(true, (Txn txn) async { - final countPtr = txn.alloc(); - final keysPtrPtr = _getKeysPtr(indexName, keys, txn.alloc); - - IC.isar_delete_all_by_index( - ptr, - txn.ptr, - schema.index(indexName).id, - keysPtrPtr, - keys.length, - countPtr, - ); - await txn.wait(); - - return countPtr.value; - }); - } - - @override - int deleteAllByIndexSync(String indexName, List keys) { - return isar.getTxnSync(true, (Txn txn) { - final countPtr = txn.alloc(); - final keysPtrPtr = _getKeysPtr(indexName, keys, txn.alloc); - - nCall( - IC.isar_delete_all_by_index( - ptr, - txn.ptr, - schema.index(indexName).id, - keysPtrPtr, - keys.length, - countPtr, - ), - ); - return countPtr.value; - }); - } - - @override - Future clear() { - return isar.getTxn(true, (Txn txn) async { - IC.isar_clear(ptr, txn.ptr); - await txn.wait(); - }); - } - - @override - void clearSync() { - isar.getTxnSync(true, (Txn txn) { - nCall(IC.isar_clear(ptr, txn.ptr)); - }); - } - - @override - Future importJson(List> json) { - final bytes = const Utf8Encoder().convert(jsonEncode(json)); - return importJsonRaw(bytes); - } - - @override - Future importJsonRaw(Uint8List jsonBytes) { - return isar.getTxn(true, (Txn txn) async { - final bytesPtr = txn.alloc(jsonBytes.length); - bytesPtr.asTypedList(jsonBytes.length).setAll(0, jsonBytes); - final idNamePtr = schema.idName.toCString(txn.alloc); - - IC.isar_json_import( - ptr, - txn.ptr, - idNamePtr, - bytesPtr, - jsonBytes.length, - ); - await txn.wait(); - }); - } - - @override - void importJsonSync(List> json) { - final bytes = const Utf8Encoder().convert(jsonEncode(json)); - importJsonRawSync(bytes); - } - - @override - void importJsonRawSync(Uint8List jsonBytes) { - return isar.getTxnSync(true, (Txn txn) async { - final bytesPtr = txn.getBuffer(jsonBytes.length); - bytesPtr.asTypedList(jsonBytes.length).setAll(0, jsonBytes); - final idNamePtr = schema.idName.toCString(txn.alloc); - - nCall( - IC.isar_json_import( - ptr, - txn.ptr, - idNamePtr, - bytesPtr, - jsonBytes.length, - ), - ); - }); - } - - @override - Future count() { - return isar.getTxn(false, (Txn txn) async { - final countPtr = txn.alloc(); - IC.isar_count(ptr, txn.ptr, countPtr); - await txn.wait(); - return countPtr.value; - }); - } - - @override - int countSync() { - return isar.getTxnSync(false, (Txn txn) { - final countPtr = txn.alloc(); - nCall(IC.isar_count(ptr, txn.ptr, countPtr)); - return countPtr.value; - }); - } - - @override - Future getSize({ - bool includeIndexes = false, - bool includeLinks = false, - }) { - return isar.getTxn(false, (Txn txn) async { - final sizePtr = txn.alloc(); - IC.isar_get_size(ptr, txn.ptr, includeIndexes, includeLinks, sizePtr); - await txn.wait(); - return sizePtr.value; - }); - } - - @override - int getSizeSync({bool includeIndexes = false, bool includeLinks = false}) { - return isar.getTxnSync(false, (Txn txn) { - final sizePtr = txn.alloc(); - nCall( - IC.isar_get_size( - ptr, - txn.ptr, - includeIndexes, - includeLinks, - sizePtr, - ), - ); - return sizePtr.value; - }); - } - - @override - Stream watchLazy({bool fireImmediately = false}) { - isar.requireOpen(); - final port = ReceivePort(); - final handle = - IC.isar_watch_collection(isar.ptr, ptr, port.sendPort.nativePort); - final controller = StreamController( - onCancel: () { - IC.isar_stop_watching(handle); - port.close(); - }, - ); - - if (fireImmediately) { - controller.add(null); - } - - controller.addStream(port); - return controller.stream; - } - - @override - Stream watchObject(Id id, {bool fireImmediately = false}) { - return watchObjectLazy(id, fireImmediately: fireImmediately) - .asyncMap((event) => get(id)); - } - - @override - Stream watchObjectLazy(Id id, {bool fireImmediately = false}) { - isar.requireOpen(); - final cObjPtr = malloc(); - - final port = ReceivePort(); - final handle = - IC.isar_watch_object(isar.ptr, ptr, id, port.sendPort.nativePort); - malloc.free(cObjPtr); - - final controller = StreamController( - onCancel: () { - IC.isar_stop_watching(handle); - port.close(); - }, - ); - - if (fireImmediately) { - controller.add(null); - } - - controller.addStream(port); - return controller.stream; - } - - @override - Query buildQuery({ - List whereClauses = const [], - bool whereDistinct = false, - Sort whereSort = Sort.asc, - FilterOperation? filter, - List sortBy = const [], - List distinctBy = const [], - int? offset, - int? limit, - String? property, - }) { - isar.requireOpen(); - return buildNativeQuery( - this, - whereClauses, - whereDistinct, - whereSort, - filter, - sortBy, - distinctBy, - offset, - limit, - property, - ); - } - - @override - Future verify(List objects) async { - await isar.verify(); - return isar.getTxn(false, (Txn txn) async { - final cObjSetPtr = txn.newCObjectSet(objects.length); - serializeObjects(txn, cObjSetPtr.ref.objects, objects); - - IC.isar_verify(ptr, txn.ptr, cObjSetPtr); - await txn.wait(); - }); - } - - @override - Future verifyLink( - String linkName, - List sourceIds, - List targetIds, - ) async { - final link = schema.link(linkName); - - return isar.getTxn(false, (Txn txn) async { - final idsPtr = txn.alloc(sourceIds.length + targetIds.length); - for (var i = 0; i < sourceIds.length; i++) { - idsPtr[i * 2] = sourceIds[i]; - idsPtr[i * 2 + 1] = targetIds[i]; - } - - IC.isar_link_verify( - ptr, - txn.ptr, - link.id, - idsPtr, - sourceIds.length + targetIds.length, - ); - await txn.wait(); - }); - } -} diff --git a/packages_external/isar-3.1.0-1/packages/isar/lib/src/native/isar_core.dart b/packages_external/isar-3.1.0-1/packages/isar/lib/src/native/isar_core.dart deleted file mode 100644 index 6ca7389a..00000000 --- a/packages_external/isar-3.1.0-1/packages/isar/lib/src/native/isar_core.dart +++ /dev/null @@ -1,234 +0,0 @@ -// ignore_for_file: public_member_api_docs - -import 'dart:async'; -import 'dart:ffi'; -import 'dart:io'; -import 'dart:isolate'; - -import 'package:ffi/ffi.dart'; -import 'package:isar/isar.dart'; -import 'package:isar/src/native/bindings.dart'; - -const Id isarMinId = -9223372036854775807; - -const Id isarMaxId = 9223372036854775807; - -const Id isarAutoIncrementId = -9223372036854775808; - -typedef IsarAbi = Abi; - -const int minByte = 0; -const int maxByte = 255; -const int minInt = -2147483648; -const int maxInt = 2147483647; -const int minLong = -9223372036854775808; -const int maxLong = 9223372036854775807; -const double minDouble = double.nan; -const double maxDouble = double.infinity; - -const nullByte = IsarObject_NULL_BYTE; -const nullInt = IsarObject_NULL_INT; -const nullLong = IsarObject_NULL_LONG; -const nullFloat = double.nan; -const nullDouble = double.nan; -final nullDate = DateTime.fromMillisecondsSinceEpoch(0); - -const nullBool = IsarObject_NULL_BOOL; -const falseBool = IsarObject_FALSE_BOOL; -const trueBool = IsarObject_TRUE_BOOL; - -const String _githubUrl = 'https://github.com/isar/isar/releases/download'; - -bool _isarInitialized = false; - -// ignore: non_constant_identifier_names -late final IsarCoreBindings IC; - -typedef FinalizerFunction = void Function(Pointer token); -late final Pointer isarClose; -late final Pointer isarQueryFree; - -FutureOr initializeCoreBinary({ - Map libraries = const {}, - bool download = false, -}) { - if (_isarInitialized) { - return null; - } - - String? libraryPath; - if (!Platform.isIOS) { - libraryPath = libraries[Abi.current()] ?? Abi.current().localName; - } - - try { - _initializePath(libraryPath); - } catch (e) { - if (!Platform.isAndroid && !Platform.isIOS) { - final downloadPath = _getLibraryDownloadPath(libraries); - if (download) { - return _downloadIsarCore(downloadPath).then((value) { - _initializePath(downloadPath); - }); - } else { - // try to use the binary at the download path anyway - _initializePath(downloadPath); - } - } else { - throw IsarError( - 'Could not initialize IsarCore library for processor architecture ' - '"${Abi.current()}". If you create a Flutter app, make sure to add ' - 'isar_flutter_libs to your dependencies.\n$e', - ); - } - } -} - -void _initializePath(String? libraryPath) { - late DynamicLibrary dylib; - if (Platform.isIOS) { - dylib = DynamicLibrary.process(); - } else { - dylib = DynamicLibrary.open(libraryPath!); - } - - final bindings = IsarCoreBindings(dylib); - - final coreVersion = bindings.isar_version().cast().toDartString(); - if (coreVersion != Isar.version && coreVersion != 'debug') { - throw IsarError( - 'Incorrect Isar Core version: Required ${Isar.version} found ' - '$coreVersion. Make sure to use the latest isar_flutter_libs. If you ' - 'have a Dart only project, make sure that old Isar Core binaries are ' - 'deleted.', - ); - } - - IC = bindings; - isarClose = dylib.lookup('isar_instance_close'); - isarQueryFree = dylib.lookup('isar_q_free'); - _isarInitialized = true; -} - -String _getLibraryDownloadPath(Map libraries) { - final providedPath = libraries[Abi.current()]; - if (providedPath != null) { - return providedPath; - } else { - final name = Abi.current().localName; - if (Platform.script.path.isEmpty) { - return name; - } - var dir = Platform.script.pathSegments - .sublist(0, Platform.script.pathSegments.length - 1) - .join(Platform.pathSeparator); - if (!Platform.isWindows) { - // Not on windows, add leading platform path separator - dir = '${Platform.pathSeparator}$dir'; - } - return '$dir${Platform.pathSeparator}$name'; - } -} - -Future _downloadIsarCore(String libraryPath) async { - final libraryFile = File(libraryPath); - // ignore: avoid_slow_async_io - if (await libraryFile.exists()) { - return; - } - final remoteName = Abi.current().remoteName; - final uri = Uri.parse('$_githubUrl/${Isar.version}/$remoteName'); - final request = await HttpClient().getUrl(uri); - final response = await request.close(); - if (response.statusCode != 200) { - throw IsarError( - 'Could not download IsarCore library: ${response.reasonPhrase}', - ); - } - await response.pipe(libraryFile.openWrite()); -} - -IsarError? isarErrorFromResult(int result) { - if (result != 0) { - final error = IC.isar_get_error(result); - if (error.address == 0) { - throw IsarError( - 'There was an error but it could not be loaded from IsarCore.', - ); - } - try { - final message = error.cast().toDartString(); - return IsarError(message); - } finally { - IC.isar_free_string(error); - } - } else { - return null; - } -} - -@pragma('vm:prefer-inline') -void nCall(int result) { - final error = isarErrorFromResult(result); - if (error != null) { - throw error; - } -} - -Stream wrapIsarPort(ReceivePort port) { - final portStreamController = StreamController(onCancel: port.close); - port.listen((event) { - if (event == 0) { - portStreamController.add(null); - } else { - final error = isarErrorFromResult(event as int); - portStreamController.addError(error!); - } - }); - return portStreamController.stream; -} - -extension PointerX on Pointer { - @pragma('vm:prefer-inline') - bool get isNull => address == 0; -} - -extension on Abi { - String get localName { - switch (Abi.current()) { - case Abi.androidArm: - case Abi.androidArm64: - case Abi.androidIA32: - case Abi.androidX64: - return 'libisar.so'; - case Abi.macosArm64: - case Abi.macosX64: - return 'libisar.dylib'; - case Abi.linuxX64: - return 'libisar.so'; - case Abi.windowsArm64: - case Abi.windowsX64: - return 'isar.dll'; - default: - throw IsarError( - 'Unsupported processor architecture "${Abi.current()}". ' - 'Please open an issue on GitHub to request it.', - ); - } - } - - String get remoteName { - switch (Abi.current()) { - case Abi.macosArm64: - case Abi.macosX64: - return 'libisar_macos.dylib'; - case Abi.linuxX64: - return 'libisar_linux_x64.so'; - case Abi.windowsArm64: - return 'isar_windows_arm64.dll'; - case Abi.windowsX64: - return 'isar_windows_x64.dll'; - } - throw UnimplementedError(); - } -} diff --git a/packages_external/isar-3.1.0-1/packages/isar/lib/src/native/isar_impl.dart b/packages_external/isar-3.1.0-1/packages/isar/lib/src/native/isar_impl.dart deleted file mode 100644 index c2d47a23..00000000 --- a/packages_external/isar-3.1.0-1/packages/isar/lib/src/native/isar_impl.dart +++ /dev/null @@ -1,139 +0,0 @@ -// ignore_for_file: public_member_api_docs - -import 'dart:async'; -import 'dart:ffi'; -import 'dart:isolate'; - -import 'package:ffi/ffi.dart'; -import 'package:isar/src/common/isar_common.dart'; -import 'package:isar/src/native/bindings.dart'; -import 'package:isar/src/native/encode_string.dart'; -import 'package:isar/src/native/isar_core.dart'; -import 'package:isar/src/native/txn.dart'; - -class IsarImpl extends IsarCommon implements Finalizable { - IsarImpl(super.name, this.ptr) { - _finalizer = NativeFinalizer(isarClose); - _finalizer.attach(this, ptr.cast(), detach: this); - } - - final Pointer ptr; - late final NativeFinalizer _finalizer; - - final offsets = >{}; - - final Pointer> _syncTxnPtrPtr = malloc>(); - - String? _directory; - - @override - String get directory { - requireOpen(); - - if (_directory == null) { - final dirPtr = IC.isar_instance_get_path(ptr); - try { - _directory = dirPtr.cast().toDartString(); - } finally { - IC.isar_free_string(dirPtr); - } - } - - return _directory!; - } - - @override - Future beginTxn(bool write, bool silent) async { - final port = ReceivePort(); - final portStream = wrapIsarPort(port); - - final txnPtrPtr = malloc>(); - IC.isar_txn_begin( - ptr, - txnPtrPtr, - false, - write, - silent, - port.sendPort.nativePort, - ); - - final txn = Txn.async(this, txnPtrPtr.value, write, portStream); - await txn.wait(); - return txn; - } - - @override - Transaction beginTxnSync(bool write, bool silent) { - nCall(IC.isar_txn_begin(ptr, _syncTxnPtrPtr, true, write, silent, 0)); - return Txn.sync(this, _syncTxnPtrPtr.value, write); - } - - @override - bool performClose(bool deleteFromDisk) { - _finalizer.detach(this); - if (deleteFromDisk) { - return IC.isar_instance_close_and_delete(ptr); - } else { - return IC.isar_instance_close(ptr); - } - } - - @override - Future getSize({ - bool includeIndexes = false, - bool includeLinks = false, - }) { - return getTxn(false, (Txn txn) async { - final sizePtr = txn.alloc(); - IC.isar_instance_get_size( - ptr, - txn.ptr, - includeIndexes, - includeLinks, - sizePtr, - ); - await txn.wait(); - return sizePtr.value; - }); - } - - @override - int getSizeSync({bool includeIndexes = false, bool includeLinks = false}) { - return getTxnSync(false, (Txn txn) { - final sizePtr = txn.alloc(); - nCall( - IC.isar_instance_get_size( - ptr, - txn.ptr, - includeIndexes, - includeLinks, - sizePtr, - ), - ); - return sizePtr.value; - }); - } - - @override - Future copyToFile(String targetPath) async { - final pathPtr = targetPath.toCString(malloc); - final receivePort = ReceivePort(); - final nativePort = receivePort.sendPort.nativePort; - - try { - final stream = wrapIsarPort(receivePort); - IC.isar_instance_copy_to_file(ptr, pathPtr, nativePort); - await stream.first; - } finally { - malloc.free(pathPtr); - } - } - - @override - Future verify() async { - return getTxn(false, (Txn txn) async { - IC.isar_instance_verify(ptr, txn.ptr); - await txn.wait(); - }); - } -} diff --git a/packages_external/isar-3.1.0-1/packages/isar/lib/src/native/isar_link_impl.dart b/packages_external/isar-3.1.0-1/packages/isar/lib/src/native/isar_link_impl.dart deleted file mode 100644 index 3c954c7d..00000000 --- a/packages_external/isar-3.1.0-1/packages/isar/lib/src/native/isar_link_impl.dart +++ /dev/null @@ -1,121 +0,0 @@ -// ignore_for_file: public_member_api_docs - -import 'dart:ffi'; - -import 'package:isar/isar.dart'; -import 'package:isar/src/common/isar_link_base_impl.dart'; -import 'package:isar/src/common/isar_link_common.dart'; -import 'package:isar/src/common/isar_links_common.dart'; -import 'package:isar/src/native/isar_collection_impl.dart'; -import 'package:isar/src/native/isar_core.dart'; -import 'package:isar/src/native/txn.dart'; - -mixin IsarLinkBaseMixin on IsarLinkBaseImpl { - @override - IsarCollectionImpl get sourceCollection => - super.sourceCollection as IsarCollectionImpl; - - @override - IsarCollectionImpl get targetCollection => - super.targetCollection as IsarCollectionImpl; - - late final int linkId = sourceCollection.schema.link(linkName).id; - - @override - late final getId = targetCollection.schema.getId; - - @override - Future update({ - Iterable link = const [], - Iterable unlink = const [], - bool reset = false, - }) { - final linkList = link.toList(); - final unlinkList = unlink.toList(); - - final containingId = requireAttached(); - return targetCollection.isar.getTxn(true, (Txn txn) { - final count = linkList.length + unlinkList.length; - final idsPtr = txn.alloc(count); - final ids = idsPtr.asTypedList(count); - - for (var i = 0; i < linkList.length; i++) { - ids[i] = requireGetId(linkList[i]); - } - for (var i = 0; i < unlinkList.length; i++) { - ids[linkList.length + i] = requireGetId(unlinkList[i]); - } - - IC.isar_link_update_all( - sourceCollection.ptr, - txn.ptr, - linkId, - containingId, - idsPtr, - linkList.length, - unlinkList.length, - reset, - ); - return txn.wait(); - }); - } - - @override - void updateSync({ - Iterable link = const [], - Iterable unlink = const [], - bool reset = false, - }) { - final containingId = requireAttached(); - targetCollection.isar.getTxnSync(true, (Txn txn) { - if (reset) { - nCall( - IC.isar_link_unlink_all( - sourceCollection.ptr, - txn.ptr, - linkId, - containingId, - ), - ); - } - - for (final object in link) { - var id = getId(object); - if (id == Isar.autoIncrement) { - id = targetCollection.putByIndexSyncInternal( - txn: txn, - object: object, - ); - } - - nCall( - IC.isar_link( - sourceCollection.ptr, - txn.ptr, - linkId, - containingId, - id, - ), - ); - } - for (final object in unlink) { - final unlinkId = requireGetId(object); - nCall( - IC.isar_link_unlink( - sourceCollection.ptr, - txn.ptr, - linkId, - containingId, - unlinkId, - ), - ); - } - }); - } -} - -class IsarLinkImpl extends IsarLinkCommon - with IsarLinkBaseMixin {} - -class IsarLinksImpl extends IsarLinksCommon - with IsarLinkBaseMixin {} diff --git a/packages_external/isar-3.1.0-1/packages/isar/lib/src/native/isar_reader_impl.dart b/packages_external/isar-3.1.0-1/packages/isar/lib/src/native/isar_reader_impl.dart deleted file mode 100644 index 96969cb0..00000000 --- a/packages_external/isar-3.1.0-1/packages/isar/lib/src/native/isar_reader_impl.dart +++ /dev/null @@ -1,591 +0,0 @@ -// ignore_for_file: public_member_api_docs - -import 'dart:convert'; -import 'dart:typed_data'; - -import 'package:isar/isar.dart'; -import 'package:isar/src/native/isar_core.dart'; -import 'package:meta/meta.dart'; - -/// @nodoc -@protected -class IsarReaderImpl implements IsarReader { - IsarReaderImpl(this._buffer) - : _byteData = ByteData.view(_buffer.buffer, _buffer.offsetInBytes) { - _staticSize = _byteData.getUint16(0, Endian.little); - } - - static const Utf8Decoder utf8Decoder = Utf8Decoder(); - - final Uint8List _buffer; - final ByteData _byteData; - late int _staticSize; - - @pragma('vm:prefer-inline') - bool _readBool(int offset) { - final value = _buffer[offset]; - if (value == trueBool) { - return true; - } else { - return false; - } - } - - @pragma('vm:prefer-inline') - @override - bool readBool(int offset) { - if (offset >= _staticSize) { - return false; - } - return _readBool(offset); - } - - @pragma('vm:prefer-inline') - bool? _readBoolOrNull(int offset) { - final value = _buffer[offset]; - if (value == trueBool) { - return true; - } else if (value == falseBool) { - return false; - } else { - return null; - } - } - - @pragma('vm:prefer-inline') - @override - bool? readBoolOrNull(int offset) { - if (offset >= _staticSize) { - return null; - } - return _readBoolOrNull(offset); - } - - @pragma('vm:prefer-inline') - @override - int readByte(int offset) { - if (offset >= _staticSize) { - return 0; - } - return _buffer[offset]; - } - - @pragma('vm:prefer-inline') - @override - int? readByteOrNull(int offset) { - if (offset >= _staticSize) { - return null; - } - return _buffer[offset]; - } - - @pragma('vm:prefer-inline') - @override - int readInt(int offset) { - if (offset >= _staticSize) { - return nullInt; - } - return _byteData.getInt32(offset, Endian.little); - } - - @pragma('vm:prefer-inline') - int? _readIntOrNull(int offset) { - final value = _byteData.getInt32(offset, Endian.little); - if (value != nullInt) { - return value; - } else { - return null; - } - } - - @pragma('vm:prefer-inline') - @override - int? readIntOrNull(int offset) { - if (offset >= _staticSize) { - return null; - } - return _readIntOrNull(offset); - } - - @pragma('vm:prefer-inline') - @override - double readFloat(int offset) { - if (offset >= _staticSize) { - return nullDouble; - } - return _byteData.getFloat32(offset, Endian.little); - } - - @pragma('vm:prefer-inline') - double? _readFloatOrNull(int offset) { - final value = _byteData.getFloat32(offset, Endian.little); - if (!value.isNaN) { - return value; - } else { - return null; - } - } - - @pragma('vm:prefer-inline') - @override - double? readFloatOrNull(int offset) { - if (offset >= _staticSize) { - return null; - } - return _readFloatOrNull(offset); - } - - @pragma('vm:prefer-inline') - @override - int readLong(int offset) { - if (offset >= _staticSize) { - return nullLong; - } - return _byteData.getInt64(offset, Endian.little); - } - - @pragma('vm:prefer-inline') - int? _readLongOrNull(int offset) { - final value = _byteData.getInt64(offset, Endian.little); - if (value != nullLong) { - return value; - } else { - return null; - } - } - - @pragma('vm:prefer-inline') - @override - int? readLongOrNull(int offset) { - if (offset >= _staticSize) { - return null; - } - return _readLongOrNull(offset); - } - - @pragma('vm:prefer-inline') - @override - double readDouble(int offset) { - if (offset >= _staticSize) { - return nullDouble; - } - return _byteData.getFloat64(offset, Endian.little); - } - - @pragma('vm:prefer-inline') - double? _readDoubleOrNull(int offset) { - final value = _byteData.getFloat64(offset, Endian.little); - if (!value.isNaN) { - return value; - } else { - return null; - } - } - - @pragma('vm:prefer-inline') - @override - double? readDoubleOrNull(int offset) { - if (offset >= _staticSize) { - return null; - } - return _readDoubleOrNull(offset); - } - - @pragma('vm:prefer-inline') - @override - DateTime readDateTime(int offset) { - final time = readLongOrNull(offset); - return time != null - ? DateTime.fromMicrosecondsSinceEpoch(time, isUtc: true).toLocal() - : nullDate; - } - - @pragma('vm:prefer-inline') - @override - DateTime? readDateTimeOrNull(int offset) { - final time = readLongOrNull(offset); - if (time != null) { - return DateTime.fromMicrosecondsSinceEpoch(time, isUtc: true).toLocal(); - } else { - return null; - } - } - - @pragma('vm:prefer-inline') - int _readUint24(int offset) { - return _buffer[offset] | - _buffer[offset + 1] << 8 | - _buffer[offset + 2] << 16; - } - - @pragma('vm:prefer-inline') - @override - String readString(int offset) { - return readStringOrNull(offset) ?? ''; - } - - @pragma('vm:prefer-inline') - @override - String? readStringOrNull(int offset) { - if (offset >= _staticSize) { - return null; - } - - var bytesOffset = _readUint24(offset); - if (bytesOffset == 0) { - return null; - } - - final length = _readUint24(bytesOffset); - bytesOffset += 3; - - return utf8Decoder.convert(_buffer, bytesOffset, bytesOffset + length); - } - - @pragma('vm:prefer-inline') - @override - T? readObjectOrNull( - int offset, - Deserialize deserialize, - Map> allOffsets, - ) { - if (offset >= _staticSize) { - return null; - } - - var bytesOffset = _readUint24(offset); - if (bytesOffset == 0) { - return null; - } - - final length = _readUint24(bytesOffset); - bytesOffset += 3; - - final buffer = - Uint8List.sublistView(_buffer, bytesOffset, bytesOffset + length); - final reader = IsarReaderImpl(buffer); - final offsets = allOffsets[T]!; - return deserialize(0, reader, offsets, allOffsets); - } - - @override - List? readBoolList(int offset) { - if (offset >= _staticSize) { - return null; - } - - var listOffset = _readUint24(offset); - if (listOffset == 0) { - return null; - } - - final length = _readUint24(listOffset); - listOffset += 3; - - final list = List.filled(length, false); - for (var i = 0; i < length; i++) { - list[i] = _readBool(listOffset + i); - } - return list; - } - - @override - List? readBoolOrNullList(int offset) { - if (offset >= _staticSize) { - return null; - } - - var listOffset = _readUint24(offset); - if (listOffset == 0) { - return null; - } - - final length = _readUint24(listOffset); - listOffset += 3; - - final list = List.filled(length, null); - for (var i = 0; i < length; i++) { - list[i] = _readBoolOrNull(listOffset + i); - } - return list; - } - - @override - List? readByteList(int offset) { - if (offset >= _staticSize) { - return null; - } - - var listOffset = _readUint24(offset); - if (listOffset == 0) { - return null; - } - - final length = _readUint24(listOffset); - listOffset += 3; - - return _buffer.sublist(listOffset, listOffset + length); - } - - @override - List? readIntList(int offset) { - if (offset >= _staticSize) { - return null; - } - - var listOffset = _readUint24(offset); - if (listOffset == 0) { - return null; - } - - final length = _readUint24(listOffset); - listOffset += 3; - - final list = Int32List(length); - for (var i = 0; i < length; i++) { - list[i] = _byteData.getInt32(listOffset + i * 4, Endian.little); - } - return list; - } - - @override - List? readIntOrNullList(int offset) { - if (offset >= _staticSize) { - return null; - } - - var listOffset = _readUint24(offset); - if (listOffset == 0) { - return null; - } - - final length = _readUint24(listOffset); - listOffset += 3; - - final list = List.filled(length, null); - for (var i = 0; i < length; i++) { - list[i] = _readIntOrNull(listOffset + i * 4); - } - return list; - } - - @override - List? readFloatList(int offset) { - if (offset >= _staticSize) { - return null; - } - - var listOffset = _readUint24(offset); - if (listOffset == 0) { - return null; - } - - final length = _readUint24(listOffset); - listOffset += 3; - - final list = Float32List(length); - for (var i = 0; i < length; i++) { - list[i] = _byteData.getFloat32(listOffset + i * 4, Endian.little); - } - return list; - } - - @override - List? readFloatOrNullList(int offset) { - if (offset >= _staticSize) { - return null; - } - - var listOffset = _readUint24(offset); - if (listOffset == 0) { - return null; - } - - final length = _readUint24(listOffset); - listOffset += 3; - - final list = List.filled(length, null); - for (var i = 0; i < length; i++) { - list[i] = _readFloatOrNull(listOffset + i * 4); - } - return list; - } - - @override - List? readLongList(int offset) { - if (offset >= _staticSize) { - return null; - } - - var listOffset = _readUint24(offset); - if (listOffset == 0) { - return null; - } - - final length = _readUint24(listOffset); - listOffset += 3; - - final list = Int64List(length); - for (var i = 0; i < length; i++) { - list[i] = _byteData.getInt64(listOffset + i * 8, Endian.little); - } - return list; - } - - @override - List? readLongOrNullList(int offset) { - if (offset >= _staticSize) { - return null; - } - - var listOffset = _readUint24(offset); - if (listOffset == 0) { - return null; - } - - final length = _readUint24(listOffset); - listOffset += 3; - - final list = List.filled(length, null); - for (var i = 0; i < length; i++) { - list[i] = _readLongOrNull(listOffset + i * 8); - } - return list; - } - - @override - List? readDoubleList(int offset) { - if (offset >= _staticSize) { - return null; - } - - var listOffset = _readUint24(offset); - if (listOffset == 0) { - return null; - } - - final length = _readUint24(listOffset); - listOffset += 3; - - final list = Float64List(length); - for (var i = 0; i < length; i++) { - list[i] = _byteData.getFloat64(listOffset + i * 8, Endian.little); - } - return list; - } - - @override - List? readDoubleOrNullList(int offset) { - if (offset >= _staticSize) { - return null; - } - - var listOffset = _readUint24(offset); - if (listOffset == 0) { - return null; - } - - final length = _readUint24(listOffset); - listOffset += 3; - - final list = List.filled(length, null); - for (var i = 0; i < length; i++) { - list[i] = _readDoubleOrNull(listOffset + i * 8); - } - return list; - } - - @override - List? readDateTimeList(int offset) { - return readLongOrNullList(offset)?.map((e) { - if (e != null) { - return DateTime.fromMicrosecondsSinceEpoch(e, isUtc: true).toLocal(); - } else { - return nullDate; - } - }).toList(); - } - - @override - List? readDateTimeOrNullList(int offset) { - return readLongOrNullList(offset)?.map((e) { - if (e != null) { - return DateTime.fromMicrosecondsSinceEpoch(e, isUtc: true).toLocal(); - } - }).toList(); - } - - List? readDynamicList( - int offset, - T nullValue, - T Function(int startOffset, int endOffset) transform, - ) { - if (offset >= _staticSize) { - return null; - } - - var listOffset = _readUint24(offset); - if (listOffset == 0) { - return null; - } - - final length = _readUint24(listOffset); - listOffset += 3; - - final list = List.filled(length, nullValue); - var contentOffset = listOffset + length * 3; - for (var i = 0; i < length; i++) { - final itemSize = _readUint24(listOffset + i * 3); - - if (itemSize != 0) { - list[i] = transform(contentOffset, contentOffset + itemSize - 1); - contentOffset += itemSize - 1; - } - } - - return list; - } - - @override - List? readStringList(int offset) { - return readDynamicList(offset, '', (startOffset, endOffset) { - return utf8Decoder.convert(_buffer, startOffset, endOffset); - }); - } - - @override - List? readStringOrNullList(int offset) { - return readDynamicList(offset, null, (startOffset, endOffset) { - return utf8Decoder.convert(_buffer, startOffset, endOffset); - }); - } - - @override - List? readObjectList( - int offset, - Deserialize deserialize, - Map> allOffsets, - T defaultValue, - ) { - final offsets = allOffsets[T]!; - return readDynamicList(offset, defaultValue, (startOffset, endOffset) { - final buffer = Uint8List.sublistView(_buffer, startOffset, endOffset); - final reader = IsarReaderImpl(buffer); - return deserialize(0, reader, offsets, allOffsets); - }); - } - - @override - List? readObjectOrNullList( - int offset, - Deserialize deserialize, - Map> allOffsets, - ) { - final offsets = allOffsets[T]!; - return readDynamicList(offset, null, (startOffset, endOffset) { - final buffer = Uint8List.sublistView(_buffer, startOffset, endOffset); - final reader = IsarReaderImpl(buffer); - return deserialize(0, reader, offsets, allOffsets); - }); - } -} diff --git a/packages_external/isar-3.1.0-1/packages/isar/lib/src/native/isar_writer_impl.dart b/packages_external/isar-3.1.0-1/packages/isar/lib/src/native/isar_writer_impl.dart deleted file mode 100644 index 7509e67d..00000000 --- a/packages_external/isar-3.1.0-1/packages/isar/lib/src/native/isar_writer_impl.dart +++ /dev/null @@ -1,284 +0,0 @@ -// ignore_for_file: public_member_api_docs, prefer_asserts_with_message, -// avoid_positional_boolean_parameters - -import 'dart:typed_data'; - -import 'package:isar/isar.dart'; -import 'package:isar/src/native/encode_string.dart'; -import 'package:isar/src/native/isar_core.dart'; -import 'package:meta/meta.dart'; - -/// @nodoc -@protected -class IsarWriterImpl implements IsarWriter { - IsarWriterImpl(Uint8List buffer, int staticSize) - : _dynamicOffset = staticSize, - _buffer = buffer, - _byteData = ByteData.view(buffer.buffer, buffer.offsetInBytes) { - _byteData.setUint16(0, staticSize, Endian.little); - - // Required because we don't want to persist uninitialized memory. - for (var i = 2; i < staticSize; i++) { - _buffer[i] = 0; - } - } - - final Uint8List _buffer; - - final ByteData _byteData; - - int _dynamicOffset; - - int get usedBytes => _dynamicOffset; - - @override - @pragma('vm:prefer-inline') - void writeBool(int offset, bool? value) { - _buffer[offset] = value.byteValue; - } - - @override - @pragma('vm:prefer-inline') - void writeByte(int offset, int value) { - assert(value >= minByte && value <= maxByte); - _buffer[offset] = value; - } - - @override - @pragma('vm:prefer-inline') - void writeInt(int offset, int? value) { - value ??= nullInt; - assert(value >= minInt && value <= maxInt); - _byteData.setInt32(offset, value, Endian.little); - } - - @override - @pragma('vm:prefer-inline') - void writeFloat(int offset, double? value) { - _byteData.setFloat32(offset, value ?? double.nan, Endian.little); - } - - @override - @pragma('vm:prefer-inline') - void writeLong(int offset, int? value) { - _byteData.setInt64(offset, value ?? nullLong, Endian.little); - } - - @override - @pragma('vm:prefer-inline') - void writeDouble(int offset, double? value) { - _byteData.setFloat64(offset, value ?? double.nan, Endian.little); - } - - @override - @pragma('vm:prefer-inline') - void writeDateTime(int offset, DateTime? value) { - writeLong(offset, value?.toUtc().microsecondsSinceEpoch); - } - - @pragma('vm:prefer-inline') - void _writeUint24(int offset, int value) { - _buffer[offset] = value; - _buffer[offset + 1] = value >> 8; - _buffer[offset + 2] = value >> 16; - } - - @override - @pragma('vm:prefer-inline') - void writeString(int offset, String? value) { - if (value != null) { - final byteCount = encodeString(value, _buffer, _dynamicOffset + 3); - _writeUint24(offset, _dynamicOffset); - _writeUint24(_dynamicOffset, byteCount); - _dynamicOffset += byteCount + 3; - } else { - _writeUint24(offset, 0); - } - } - - @override - @pragma('vm:prefer-inline') - void writeObject( - int offset, - Map> allOffsets, - Serialize serialize, - T? value, - ) { - if (value != null) { - final buffer = Uint8List.sublistView(_buffer, _dynamicOffset + 3); - final offsets = allOffsets[T]!; - final binaryWriter = IsarWriterImpl(buffer, offsets.last); - serialize(value, binaryWriter, offsets, allOffsets); - final byteCount = binaryWriter.usedBytes; - _writeUint24(offset, _dynamicOffset); - _writeUint24(_dynamicOffset, byteCount); - _dynamicOffset += byteCount + 3; - } else { - _writeUint24(offset, 0); - } - } - - @pragma('vm:prefer-inline') - void _writeListOffset(int offset, int? length) { - if (length == null) { - _writeUint24(offset, 0); - } else { - _writeUint24(offset, _dynamicOffset); - _writeUint24(_dynamicOffset, length); - _dynamicOffset += 3; - } - } - - @override - @pragma('vm:prefer-inline') - void writeByteList(int offset, List? values) { - _writeListOffset(offset, values?.length); - - if (values != null) { - for (var i = 0; i < values.length; i++) { - _buffer[_dynamicOffset++] = values[i]; - } - } - } - - @override - void writeBoolList(int offset, List? values) { - _writeListOffset(offset, values?.length); - - if (values != null) { - for (var i = 0; i < values.length; i++) { - _buffer[_dynamicOffset++] = values[i].byteValue; - } - } - } - - @override - void writeIntList(int offset, List? values) { - _writeListOffset(offset, values?.length); - - if (values != null) { - for (var value in values) { - value ??= nullInt; - assert(value >= minInt && value <= maxInt); - _byteData.setUint32(_dynamicOffset, value, Endian.little); - _dynamicOffset += 4; - } - } - } - - @override - void writeFloatList(int offset, List? values) { - _writeListOffset(offset, values?.length); - - if (values != null) { - for (var i = 0; i < values.length; i++) { - _byteData.setFloat32( - _dynamicOffset, - values[i] ?? nullFloat, - Endian.little, - ); - _dynamicOffset += 4; - } - } - } - - @override - void writeLongList(int offset, List? values) { - _writeListOffset(offset, values?.length); - - if (values != null) { - for (var i = 0; i < values.length; i++) { - _byteData.setInt64( - _dynamicOffset, - values[i] ?? nullLong, - Endian.little, - ); - _dynamicOffset += 8; - } - } - } - - @override - void writeDoubleList(int offset, List? values) { - _writeListOffset(offset, values?.length); - - if (values != null) { - for (var i = 0; i < values.length; i++) { - _byteData.setFloat64( - _dynamicOffset, - values[i] ?? nullDouble, - Endian.little, - ); - _dynamicOffset += 8; - } - } - } - - @override - void writeDateTimeList(int offset, List? values) { - final longList = values?.map((e) => e.longValue).toList(); - writeLongList(offset, longList); - } - - @override - void writeStringList(int offset, List? values) { - _writeListOffset(offset, values?.length); - - if (values != null) { - final offsetListOffset = _dynamicOffset; - _dynamicOffset += values.length * 3; - for (var i = 0; i < values.length; i++) { - final value = values[i]; - if (value != null) { - final byteCount = encodeString(value, _buffer, _dynamicOffset); - _writeUint24(offsetListOffset + i * 3, byteCount + 1); - _dynamicOffset += byteCount; - } else { - _writeUint24(offsetListOffset + i * 3, 0); - } - } - } - } - - @override - void writeObjectList( - int offset, - Map> allOffsets, - Serialize serialize, - List? values, - ) { - _writeListOffset(offset, values?.length); - - if (values != null) { - final offsetListOffset = _dynamicOffset; - _dynamicOffset += values.length * 3; - - final offsets = allOffsets[T]!; - final staticSize = offsets.last; - for (var i = 0; i < values.length; i++) { - final value = values[i]; - if (value != null) { - final buffer = Uint8List.sublistView(_buffer, _dynamicOffset); - final binaryWriter = IsarWriterImpl(buffer, staticSize); - serialize(value, binaryWriter, offsets, allOffsets); - final byteCount = binaryWriter.usedBytes; - _writeUint24(offsetListOffset + i * 3, byteCount + 1); - _dynamicOffset += byteCount; - } else { - _writeUint24(offsetListOffset + i * 3, 0); - } - } - } - } -} - -extension IsarBoolValue on bool? { - @pragma('vm:prefer-inline') - int get byteValue => - this == null ? nullBool : (this == true ? trueBool : falseBool); -} - -extension IsarDateTimeValue on DateTime? { - @pragma('vm:prefer-inline') - int get longValue => this?.toUtc().microsecondsSinceEpoch ?? nullLong; -} diff --git a/packages_external/isar-3.1.0-1/packages/isar/lib/src/native/open.dart b/packages_external/isar-3.1.0-1/packages/isar/lib/src/native/open.dart deleted file mode 100644 index 1b169e0c..00000000 --- a/packages_external/isar-3.1.0-1/packages/isar/lib/src/native/open.dart +++ /dev/null @@ -1,159 +0,0 @@ -// ignore_for_file: public_member_api_docs, invalid_use_of_protected_member - -import 'dart:convert'; -import 'dart:ffi'; -import 'dart:isolate'; - -import 'package:ffi/ffi.dart'; -import 'package:isar/isar.dart'; -import 'package:isar/src/common/schemas.dart'; -import 'package:isar/src/native/bindings.dart'; -import 'package:isar/src/native/encode_string.dart'; -import 'package:isar/src/native/isar_collection_impl.dart'; -import 'package:isar/src/native/isar_core.dart'; -import 'package:isar/src/native/isar_impl.dart'; - -final Pointer> _isarPtrPtr = - malloc>(); - -List _getOffsets( - Pointer colPtr, - int propertiesCount, - int embeddedColId, -) { - final offsetsPtr = malloc(propertiesCount); - final staticSize = IC.isar_get_offsets(colPtr, embeddedColId, offsetsPtr); - final offsets = offsetsPtr.asTypedList(propertiesCount).toList(); - offsets.add(staticSize); - malloc.free(offsetsPtr); - return offsets; -} - -void _initializeInstance( - IsarImpl isar, - List> schemas, -) { - final colPtrPtr = malloc>(); - - final cols = >{}; - for (final schema in schemas) { - nCall(IC.isar_instance_get_collection(isar.ptr, colPtrPtr, schema.id)); - - final offsets = _getOffsets(colPtrPtr.value, schema.properties.length, 0); - - for (final embeddedSchema in schema.embeddedSchemas.values) { - final embeddedType = embeddedSchema.type; - if (!isar.offsets.containsKey(embeddedType)) { - final offsets = _getOffsets( - colPtrPtr.value, - embeddedSchema.properties.length, - embeddedSchema.id, - ); - isar.offsets[embeddedType] = offsets; - } - } - - schema.toCollection(() { - isar.offsets[OBJ] = offsets; - - schema as CollectionSchema; - cols[OBJ] = IsarCollectionImpl( - isar: isar, - ptr: colPtrPtr.value, - schema: schema, - ); - }); - } - - malloc.free(colPtrPtr); - - isar.attachCollections(cols); -} - -Future openIsar({ - required List> schemas, - required String directory, - required String name, - required int maxSizeMiB, - required bool relaxedDurability, - CompactCondition? compactOnLaunch, -}) async { - initializeCoreBinary(); - IC.isar_connect_dart_api(NativeApi.postCObject.cast()); - - return using((Arena alloc) async { - final namePtr = name.toCString(alloc); - final dirPtr = directory.toCString(alloc); - - final schemasJson = getSchemas(schemas).map((e) => e.toJson()); - final schemaStrPtr = jsonEncode(schemasJson.toList()).toCString(alloc); - - final compactMinFileSize = compactOnLaunch?.minFileSize; - final compactMinBytes = compactOnLaunch?.minBytes; - final compactMinRatio = - compactOnLaunch == null ? double.nan : compactOnLaunch.minRatio; - - final receivePort = ReceivePort(); - final nativePort = receivePort.sendPort.nativePort; - final stream = wrapIsarPort(receivePort); - IC.isar_instance_create_async( - _isarPtrPtr, - namePtr, - dirPtr, - schemaStrPtr, - maxSizeMiB, - relaxedDurability, - compactMinFileSize ?? 0, - compactMinBytes ?? 0, - compactMinRatio ?? 0, - nativePort, - ); - await stream.first; - - final isar = IsarImpl(name, _isarPtrPtr.value); - _initializeInstance(isar, schemas); - return isar; - }); -} - -Isar openIsarSync({ - required List> schemas, - required String directory, - required String name, - required int maxSizeMiB, - required bool relaxedDurability, - CompactCondition? compactOnLaunch, -}) { - initializeCoreBinary(); - IC.isar_connect_dart_api(NativeApi.postCObject.cast()); - return using((Arena alloc) { - final namePtr = name.toCString(alloc); - final dirPtr = directory.toCString(alloc); - - final schemasJson = getSchemas(schemas).map((e) => e.toJson()); - final schemaStrPtr = jsonEncode(schemasJson.toList()).toCString(alloc); - - final compactMinFileSize = compactOnLaunch?.minFileSize; - final compactMinBytes = compactOnLaunch?.minBytes; - final compactMinRatio = - compactOnLaunch == null ? double.nan : compactOnLaunch.minRatio; - - nCall( - IC.isar_instance_create( - _isarPtrPtr, - namePtr, - dirPtr, - schemaStrPtr, - maxSizeMiB, - relaxedDurability, - compactMinFileSize ?? 0, - compactMinBytes ?? 0, - compactMinRatio ?? 0, - ), - ); - - final isar = IsarImpl(name, _isarPtrPtr.value); - _initializeInstance(isar, schemas); - return isar; - }); -} diff --git a/packages_external/isar-3.1.0-1/packages/isar/lib/src/native/query_build.dart b/packages_external/isar-3.1.0-1/packages/isar/lib/src/native/query_build.dart deleted file mode 100644 index 1e787174..00000000 --- a/packages_external/isar-3.1.0-1/packages/isar/lib/src/native/query_build.dart +++ /dev/null @@ -1,1040 +0,0 @@ -// ignore_for_file: invalid_use_of_protected_member, public_member_api_docs - -import 'dart:ffi'; - -import 'package:ffi/ffi.dart'; -import 'package:isar/isar.dart'; -import 'package:isar/src/native/bindings.dart'; -import 'package:isar/src/native/encode_string.dart'; -import 'package:isar/src/native/index_key.dart'; -import 'package:isar/src/native/isar_collection_impl.dart'; -import 'package:isar/src/native/isar_core.dart'; -import 'package:isar/src/native/isar_writer_impl.dart'; -import 'package:isar/src/native/query_impl.dart'; - -final Pointer maxStr = '\u{FFFFF}'.toNativeUtf8().cast(); - -Query buildNativeQuery( - IsarCollectionImpl col, - List whereClauses, - bool whereDistinct, - Sort whereSort, - FilterOperation? filter, - List sortBy, - List distinctBy, - int? offset, - int? limit, - String? property, -) { - final qbPtr = IC.isar_qb_create(col.ptr); - - for (final wc in whereClauses) { - if (wc is IdWhereClause) { - _addIdWhereClause(qbPtr, wc, whereSort); - } else if (wc is IndexWhereClause) { - _addIndexWhereClause( - col.schema, - qbPtr, - wc, - whereDistinct, - whereSort, - ); - } else { - _addLinkWhereClause(col.isar, qbPtr, wc as LinkWhereClause); - } - } - - if (filter != null) { - final alloc = Arena(malloc); - try { - final filterPtr = _buildFilter(col, null, filter, alloc); - if (filterPtr != null) { - IC.isar_qb_set_filter(qbPtr, filterPtr); - } - } finally { - alloc.releaseAll(); - } - } - - for (final sortProperty in sortBy) { - final property = col.schema.property(sortProperty.property); - nCall( - IC.isar_qb_add_sort_by( - qbPtr, - property.id, - sortProperty.sort == Sort.asc, - ), - ); - } - - if (offset != null || limit != null) { - IC.isar_qb_set_offset_limit(qbPtr, offset ?? -1, limit ?? -1); - } - - for (final distinctByProperty in distinctBy) { - final property = col.schema.property(distinctByProperty.property); - nCall( - IC.isar_qb_add_distinct_by( - qbPtr, - property.id, - distinctByProperty.caseSensitive ?? true, - ), - ); - } - - QueryDeserialize deserialize; - int? propertyId; - if (property == null) { - deserialize = (col as IsarCollectionImpl).deserializeObjects; - } else { - propertyId = - property != col.schema.idName ? col.schema.property(property).id : null; - deserialize = - (CObjectSet cObjSet) => col.deserializeProperty(cObjSet, propertyId); - } - - final queryPtr = IC.isar_qb_build(qbPtr); - return QueryImpl(col, queryPtr, deserialize, propertyId); -} - -void _addIdWhereClause( - Pointer qbPtr, - IdWhereClause wc, - Sort sort, -) { - final lower = (wc.lower ?? minLong) + (wc.includeLower ? 0 : 1); - final upper = (wc.upper ?? maxLong) - (wc.includeUpper ? 0 : 1); - nCall( - IC.isar_qb_add_id_where_clause( - qbPtr, - sort == Sort.asc ? lower : upper, - sort == Sort.asc ? upper : lower, - ), - ); -} - -Pointer? _buildLowerIndexBound( - CollectionSchema schema, - IndexSchema index, - IndexWhereClause wc, -) { - if (wc.lower == null) { - return buildLowerUnboundedIndexKey(); - } - - final firstVal = wc.lower!.length == 1 ? wc.lower!.first : null; - if (firstVal is double) { - final adjusted = adjustFloatBound( - value: firstVal, - lowerBound: true, - include: wc.includeLower, - epsilon: wc.epsilon, - ); - if (adjusted == null) { - return null; - } - - return buildIndexKey(schema, index, [adjusted]); - } else { - final lowerPtr = buildIndexKey(schema, index, wc.lower!); - - if (!wc.includeLower) { - if (!IC.isar_key_increase(lowerPtr)) { - return null; - } - } - - return lowerPtr; - } -} - -Pointer? _buildUpperIndexBound( - CollectionSchema schema, - IndexSchema index, - IndexWhereClause wc, -) { - if (wc.upper == null) { - return buildUpperUnboundedIndexKey(); - } - - final firstVal = wc.upper!.length == 1 ? wc.upper!.first : null; - if (firstVal is double) { - final adjusted = adjustFloatBound( - value: firstVal, - lowerBound: false, - include: wc.includeUpper, - epsilon: wc.epsilon, - ); - if (adjusted == null) { - return null; - } else { - return buildIndexKey(schema, index, [adjusted]); - } - } else { - final upperPtr = buildIndexKey(schema, index, wc.upper!); - - if (!wc.includeUpper) { - if (!IC.isar_key_decrease(upperPtr)) { - return null; - } - } - - // Also include composite indexes for upper keys - if (index.properties.length > wc.upper!.length) { - IC.isar_key_add_long(upperPtr, maxLong); - } - - return upperPtr; - } -} - -void _addIndexWhereClause( - CollectionSchema schema, - Pointer qbPtr, - IndexWhereClause wc, - bool distinct, - Sort sort, -) { - final index = schema.index(wc.indexName); - final lowerPtr = _buildLowerIndexBound(schema, index, wc); - final upperPtr = _buildUpperIndexBound(schema, index, wc); - - if (lowerPtr != null && upperPtr != null) { - nCall( - IC.isar_qb_add_index_where_clause( - qbPtr, - schema.index(wc.indexName).id, - lowerPtr, - upperPtr, - sort == Sort.asc, - distinct, - ), - ); - } else { - // this where clause does not match any objects - nCall( - IC.isar_qb_add_id_where_clause( - qbPtr, - Isar.autoIncrement, - Isar.autoIncrement, - ), - ); - } -} - -void _addLinkWhereClause( - Isar isar, - Pointer qbPtr, - LinkWhereClause wc, -) { - final linkCol = isar.getCollectionByNameInternal(wc.linkCollection)!; - linkCol as IsarCollectionImpl; - - final linkId = linkCol.schema.link(wc.linkName).id; - nCall(IC.isar_qb_add_link_where_clause(qbPtr, linkCol.ptr, linkId, wc.id)); -} - -Pointer? _buildFilter( - IsarCollectionImpl col, - Schema? embeddedCol, - FilterOperation filter, - Allocator alloc, -) { - if (filter is FilterGroup) { - return _buildFilterGroup(col, embeddedCol, filter, alloc); - } else if (filter is LinkFilter) { - return _buildLink(col, filter, alloc); - } else if (filter is ObjectFilter) { - return _buildObject(col, embeddedCol, filter, alloc); - } else if (filter is FilterCondition) { - return _buildCondition(col, embeddedCol, filter, alloc); - } else { - return null; - } -} - -Pointer? _buildFilterGroup( - IsarCollectionImpl col, - Schema? embeddedCol, - FilterGroup group, - Allocator alloc, -) { - final builtConditions = group.filters - .map((FilterOperation op) => _buildFilter(col, embeddedCol, op, alloc)) - .where((Pointer? it) => it != null) - .toList(); - - if (builtConditions.isEmpty) { - return null; - } - - final filterPtrPtr = alloc>(); - if (group.type == FilterGroupType.not) { - IC.isar_filter_not( - filterPtrPtr, - builtConditions.first!, - ); - } else if (builtConditions.length == 1) { - return builtConditions[0]; - } else { - final conditionsPtrPtr = alloc>(builtConditions.length); - for (var i = 0; i < builtConditions.length; i++) { - conditionsPtrPtr[i] = builtConditions[i]!; - } - IC.isar_filter_and_or_xor( - filterPtrPtr, - group.type == FilterGroupType.and, - group.type == FilterGroupType.xor, - conditionsPtrPtr, - builtConditions.length, - ); - } - - return filterPtrPtr.value; -} - -Pointer? _buildLink( - IsarCollectionImpl col, - LinkFilter link, - Allocator alloc, -) { - final linkSchema = col.schema.link(link.linkName); - final linkTargetCol = - col.isar.getCollectionByNameInternal(linkSchema.target)!; - final linkId = col.schema.link(link.linkName).id; - - final filterPtrPtr = alloc>(); - - if (link.filter != null) { - final condition = _buildFilter( - linkTargetCol as IsarCollectionImpl, - null, - link.filter!, - alloc, - ); - if (condition == null) { - return null; - } - - nCall( - IC.isar_filter_link( - col.ptr, - filterPtrPtr, - condition, - linkId, - ), - ); - } else { - nCall( - IC.isar_filter_link_length( - col.ptr, - filterPtrPtr, - link.lower!, - link.upper!, - linkId, - ), - ); - } - - return filterPtrPtr.value; -} - -Pointer? _buildObject( - IsarCollectionImpl col, - Schema? embeddedCol, - ObjectFilter objectFilter, - Allocator alloc, -) { - final property = (embeddedCol ?? col.schema).property(objectFilter.property); - - final condition = _buildFilter( - col, - col.schema.embeddedSchemas[property.target], - objectFilter.filter, - alloc, - ); - if (condition == null) { - return null; - } - - final filterPtrPtr = alloc>(); - nCall( - IC.isar_filter_object( - col.ptr, - filterPtrPtr, - condition, - embeddedCol?.id ?? 0, - property.id, - ), - ); - - return filterPtrPtr.value; -} - -Object _prepareValue( - Object? value, - Allocator alloc, - IsarType type, - Map? enumMap, -) { - if (value is bool) { - return value.byteValue; - } else if (value is DateTime) { - return value.longValue; - } else if (value is Enum) { - return _prepareValue(enumMap![value.name], alloc, type, null); - } else if (value is String) { - return value.toCString(alloc); - } else if (value == null) { - switch (type) { - case IsarType.bool: - case IsarType.byte: - case IsarType.boolList: - case IsarType.byteList: - return minByte; - case IsarType.int: - case IsarType.intList: - return minInt; - case IsarType.long: - case IsarType.longList: - case IsarType.dateTime: - case IsarType.dateTimeList: - return minLong; - case IsarType.float: - case IsarType.double: - case IsarType.floatList: - case IsarType.doubleList: - return minDouble; - case IsarType.string: - case IsarType.stringList: - case IsarType.object: - case IsarType.objectList: - return nullptr; - } - } else { - return value; - } -} - -Pointer _buildCondition( - IsarCollectionImpl col, - Schema? embeddedCol, - FilterCondition condition, - Allocator alloc, -) { - final property = condition.property != col.schema.idName - ? (embeddedCol ?? col.schema).property(condition.property) - : null; - - final value1 = _prepareValue( - condition.value1, - alloc, - property?.type ?? IsarType.long, - property?.enumMap, - ); - final value2 = _prepareValue( - condition.value2, - alloc, - property?.type ?? IsarType.long, - property?.enumMap, - ); - final filterPtr = alloc>(); - - switch (condition.type) { - case FilterConditionType.equalTo: - _buildConditionEqual( - colPtr: col.ptr, - filterPtr: filterPtr, - embeddedColId: embeddedCol?.id, - propertyId: property?.id, - val: value1, - caseSensitive: condition.caseSensitive, - epsilon: condition.epsilon, - ); - break; - case FilterConditionType.between: - _buildConditionBetween( - colPtr: col.ptr, - filterPtr: filterPtr, - embeddedColId: embeddedCol?.id, - propertyId: property?.id, - lower: value1, - includeLower: condition.include1, - upper: value2, - includeUpper: condition.include2, - caseSensitive: condition.caseSensitive, - epsilon: condition.epsilon, - ); - break; - case FilterConditionType.lessThan: - _buildConditionLessThan( - colPtr: col.ptr, - filterPtr: filterPtr, - embeddedColId: embeddedCol?.id, - propertyId: property?.id, - val: value1, - include: condition.include1, - caseSensitive: condition.caseSensitive, - epsilon: condition.epsilon, - ); - break; - case FilterConditionType.greaterThan: - _buildConditionGreaterThan( - colPtr: col.ptr, - filterPtr: filterPtr, - embeddedColId: embeddedCol?.id, - propertyId: property?.id, - val: value1, - include: condition.include1, - caseSensitive: condition.caseSensitive, - epsilon: condition.epsilon, - ); - break; - case FilterConditionType.startsWith: - case FilterConditionType.endsWith: - case FilterConditionType.contains: - case FilterConditionType.matches: - _buildConditionStringOp( - colPtr: col.ptr, - filterPtr: filterPtr, - conditionType: condition.type, - embeddedColId: embeddedCol?.id, - propertyId: property?.id, - val: value1, - include: condition.include1, - caseSensitive: condition.caseSensitive, - ); - break; - case FilterConditionType.isNull: - _buildConditionIsNull( - colPtr: col.ptr, - filterPtr: filterPtr, - embeddedColId: embeddedCol?.id, - propertyId: property?.id, - ); - break; - case FilterConditionType.isNotNull: - _buildConditionIsNotNull( - colPtr: col.ptr, - filterPtr: filterPtr, - embeddedColId: embeddedCol?.id, - propertyId: property?.id, - alloc: alloc, - ); - break; - case FilterConditionType.elementIsNull: - _buildConditionElementIsNull( - colPtr: col.ptr, - filterPtr: filterPtr, - embeddedColId: embeddedCol?.id, - propertyId: property?.id, - isObjectList: property?.type == IsarType.objectList, - nullValue: value1, - ); - break; - case FilterConditionType.elementIsNotNull: - _buildConditionElementIsNotNull( - colPtr: col.ptr, - filterPtr: filterPtr, - embeddedColId: embeddedCol?.id, - propertyId: property?.id, - isObjectList: property?.type == IsarType.objectList, - nullValue: value1, - alloc: alloc, - ); - break; - case FilterConditionType.listLength: - _buildListLength( - colPtr: col.ptr, - filterPtr: filterPtr, - embeddedColId: embeddedCol?.id, - propertyId: property?.id, - lower: value1, - upper: value2, - ); - break; - } - - return filterPtr.value; -} - -void _buildConditionIsNull({ - required Pointer colPtr, - required Pointer> filterPtr, - required int? embeddedColId, - required int? propertyId, -}) { - if (propertyId != null) { - nCall( - IC.isar_filter_null( - colPtr, - filterPtr, - embeddedColId ?? 0, - propertyId, - ), - ); - } else { - IC.isar_filter_static(filterPtr, false); - } -} - -void _buildConditionIsNotNull({ - required Pointer colPtr, - required Pointer> filterPtr, - required int? embeddedColId, - required int? propertyId, - required Allocator alloc, -}) { - if (propertyId != null) { - final conditionPtr = alloc>(); - nCall( - IC.isar_filter_null( - colPtr, - conditionPtr, - embeddedColId ?? 0, - propertyId, - ), - ); - IC.isar_filter_not(filterPtr, conditionPtr.value); - } else { - IC.isar_filter_static(filterPtr, true); - } -} - -void _buildConditionElementIsNull({ - required Pointer colPtr, - required Pointer> filterPtr, - required int? embeddedColId, - required int? propertyId, - required bool isObjectList, - required Object nullValue, -}) { - if (isObjectList) { - IC.isar_filter_object( - colPtr, - filterPtr, - nullptr, - embeddedColId ?? 0, - propertyId ?? 0, - ); - } else { - _buildConditionEqual( - colPtr: colPtr, - filterPtr: filterPtr, - embeddedColId: embeddedColId, - propertyId: propertyId, - val: nullValue, - epsilon: 0, - caseSensitive: true, - ); - } -} - -void _buildConditionElementIsNotNull({ - required Pointer colPtr, - required Pointer> filterPtr, - required int? embeddedColId, - required int? propertyId, - required bool isObjectList, - required Object nullValue, - required Allocator alloc, -}) { - if (isObjectList) { - final objFilterPtrPtr = alloc>(); - IC.isar_filter_static(objFilterPtrPtr, true); - IC.isar_filter_object( - colPtr, - filterPtr, - objFilterPtrPtr.value, - embeddedColId ?? 0, - propertyId ?? 0, - ); - } else { - _buildConditionGreaterThan( - colPtr: colPtr, - filterPtr: filterPtr, - embeddedColId: embeddedColId, - propertyId: propertyId, - val: nullValue, - include: false, - epsilon: 0, - caseSensitive: true, - ); - } -} - -void _buildConditionEqual({ - required Pointer colPtr, - required Pointer> filterPtr, - required int? embeddedColId, - required int? propertyId, - required Object val, - required bool caseSensitive, - required double epsilon, -}) { - if (val is int) { - if (propertyId == null) { - IC.isar_filter_id(filterPtr, val, true, val, true); - } else { - nCall( - IC.isar_filter_long( - colPtr, - filterPtr, - val, - true, - val, - true, - embeddedColId ?? 0, - propertyId, - ), - ); - } - } else if (val is double) { - final lower = adjustFloatBound( - value: val, - lowerBound: true, - include: true, - epsilon: epsilon, - ); - final upper = adjustFloatBound( - value: val, - lowerBound: false, - include: true, - epsilon: epsilon, - ); - if (lower == null || upper == null) { - IC.isar_filter_static(filterPtr, false); - } else { - nCall( - IC.isar_filter_double( - colPtr, - filterPtr, - lower, - upper, - embeddedColId ?? 0, - propertyId!, - ), - ); - } - } else if (val is Pointer) { - nCall( - IC.isar_filter_string( - colPtr, - filterPtr, - val, - true, - val, - true, - caseSensitive, - embeddedColId ?? 0, - propertyId!, - ), - ); - } else { - throw IsarError('Unsupported type for condition'); - } -} - -void _buildConditionBetween({ - required Pointer colPtr, - required Pointer> filterPtr, - required int? embeddedColId, - required int? propertyId, - required Object lower, - required bool includeLower, - required Object upper, - required bool includeUpper, - required bool caseSensitive, - required double epsilon, -}) { - if (lower is int && upper is int) { - if (propertyId == null) { - IC.isar_filter_id(filterPtr, lower, includeLower, upper, includeUpper); - } else { - nCall( - IC.isar_filter_long( - colPtr, - filterPtr, - lower, - includeLower, - upper, - includeUpper, - embeddedColId ?? 0, - propertyId, - ), - ); - } - } else if (lower is double && upper is double) { - final adjustedLower = adjustFloatBound( - value: lower, - lowerBound: true, - include: includeLower, - epsilon: epsilon, - ); - final adjustedUpper = adjustFloatBound( - value: upper, - lowerBound: false, - include: includeUpper, - epsilon: epsilon, - ); - if (adjustedLower == null || adjustedUpper == null) { - IC.isar_filter_static(filterPtr, false); - } else { - nCall( - IC.isar_filter_double( - colPtr, - filterPtr, - adjustedLower, - adjustedUpper, - embeddedColId ?? 0, - propertyId!, - ), - ); - } - } else if (lower is Pointer && upper is Pointer) { - nCall( - IC.isar_filter_string( - colPtr, - filterPtr, - lower, - includeLower, - upper, - includeUpper, - caseSensitive, - embeddedColId ?? 0, - propertyId!, - ), - ); - } else { - throw IsarError('Unsupported type for condition'); - } -} - -void _buildConditionLessThan({ - required Pointer colPtr, - required Pointer> filterPtr, - required int? embeddedColId, - required int? propertyId, - required Object val, - required bool include, - required bool caseSensitive, - required double epsilon, -}) { - if (val is int) { - if (propertyId == null) { - IC.isar_filter_id(filterPtr, minLong, true, val, include); - } else { - nCall( - IC.isar_filter_long( - colPtr, - filterPtr, - minLong, - true, - val, - include, - embeddedColId ?? 0, - propertyId, - ), - ); - } - } else if (val is double) { - final upper = adjustFloatBound( - value: val, - lowerBound: false, - include: include, - epsilon: epsilon, - ); - if (upper == null) { - IC.isar_filter_static(filterPtr, false); - } else { - nCall( - IC.isar_filter_double( - colPtr, - filterPtr, - minDouble, - upper, - embeddedColId ?? 0, - propertyId!, - ), - ); - } - } else if (val is Pointer) { - nCall( - IC.isar_filter_string( - colPtr, - filterPtr, - nullptr, - true, - val, - include, - caseSensitive, - embeddedColId ?? 0, - propertyId!, - ), - ); - } else { - throw IsarError('Unsupported type for condition'); - } -} - -void _buildConditionGreaterThan({ - required Pointer colPtr, - required Pointer> filterPtr, - required int? embeddedColId, - required int? propertyId, - required Object val, - required bool include, - required bool caseSensitive, - required double epsilon, -}) { - if (val is int) { - if (propertyId == null) { - IC.isar_filter_id(filterPtr, val, include, maxLong, true); - } else { - nCall( - IC.isar_filter_long( - colPtr, - filterPtr, - val, - include, - maxLong, - true, - embeddedColId ?? 0, - propertyId, - ), - ); - } - } else if (val is double) { - final lower = adjustFloatBound( - value: val, - lowerBound: true, - include: include, - epsilon: epsilon, - ); - if (lower == null) { - IC.isar_filter_static(filterPtr, false); - } else { - nCall( - IC.isar_filter_double( - colPtr, - filterPtr, - lower, - maxDouble, - embeddedColId ?? 0, - propertyId!, - ), - ); - } - } else if (val is Pointer) { - nCall( - IC.isar_filter_string( - colPtr, - filterPtr, - val, - include, - maxStr, - true, - caseSensitive, - embeddedColId ?? 0, - propertyId!, - ), - ); - } else { - throw IsarError('Unsupported type for condition'); - } -} - -void _buildConditionStringOp({ - required Pointer colPtr, - required Pointer> filterPtr, - required FilterConditionType conditionType, - required int? embeddedColId, - required int? propertyId, - required Object val, - required bool include, - required bool caseSensitive, -}) { - if (val is Pointer) { - if (val.isNull) { - throw IsarError('String operation value must not be null'); - } - - // ignore: missing_enum_constant_in_switch - switch (conditionType) { - case FilterConditionType.startsWith: - nCall( - IC.isar_filter_string_starts_with( - colPtr, - filterPtr, - val, - caseSensitive, - embeddedColId ?? 0, - propertyId!, - ), - ); - break; - case FilterConditionType.endsWith: - nCall( - IC.isar_filter_string_ends_with( - colPtr, - filterPtr, - val, - caseSensitive, - embeddedColId ?? 0, - propertyId!, - ), - ); - break; - case FilterConditionType.contains: - nCall( - IC.isar_filter_string_contains( - colPtr, - filterPtr, - val, - caseSensitive, - embeddedColId ?? 0, - propertyId!, - ), - ); - break; - case FilterConditionType.matches: - nCall( - IC.isar_filter_string_matches( - colPtr, - filterPtr, - val, - caseSensitive, - embeddedColId ?? 0, - propertyId!, - ), - ); - break; - } - } else { - throw IsarError('Unsupported type for condition'); - } -} - -void _buildListLength({ - required Pointer colPtr, - required Pointer> filterPtr, - required int? embeddedColId, - required int? propertyId, - required Object? lower, - required Object? upper, -}) { - if (lower is int && upper is int) { - nCall( - IC.isar_filter_list_length( - colPtr, - filterPtr, - lower, - upper, - embeddedColId ?? 0, - propertyId!, - ), - ); - } else { - throw IsarError('Unsupported type for condition'); - } -} diff --git a/packages_external/isar-3.1.0-1/packages/isar/lib/src/native/query_impl.dart b/packages_external/isar-3.1.0-1/packages/isar/lib/src/native/query_impl.dart deleted file mode 100644 index a5d2452f..00000000 --- a/packages_external/isar-3.1.0-1/packages/isar/lib/src/native/query_impl.dart +++ /dev/null @@ -1,261 +0,0 @@ -// ignore_for_file: public_member_api_docs - -import 'dart:async'; -import 'dart:ffi'; -import 'dart:isolate'; -import 'dart:typed_data'; - -import 'package:isar/isar.dart'; -import 'package:isar/src/native/bindings.dart'; -import 'package:isar/src/native/encode_string.dart'; -import 'package:isar/src/native/isar_collection_impl.dart'; -import 'package:isar/src/native/isar_core.dart'; -import 'package:isar/src/native/txn.dart'; - -typedef QueryDeserialize = List Function(CObjectSet); - -class QueryImpl extends Query implements Finalizable { - QueryImpl(this.col, this.queryPtr, this.deserialize, this.propertyId) { - NativeFinalizer(isarQueryFree).attach(this, queryPtr.cast()); - } - static const int maxLimit = 4294967295; - - final IsarCollectionImpl col; - final Pointer queryPtr; - final QueryDeserialize deserialize; - final int? propertyId; - - @override - Isar get isar => col.isar; - - @override - Future findFirst() { - return findInternal(maxLimit).then((List result) { - if (result.isNotEmpty) { - return result[0]; - } else { - return null; - } - }); - } - - @override - Future> findAll() => findInternal(maxLimit); - - Future> findInternal(int limit) { - return col.isar.getTxn(false, (Txn txn) async { - final resultsPtr = txn.alloc(); - try { - IC.isar_q_find(queryPtr, txn.ptr, resultsPtr, limit); - await txn.wait(); - return deserialize(resultsPtr.ref).cast(); - } finally { - IC.isar_free_c_object_set(resultsPtr); - } - }); - } - - @override - T? findFirstSync() { - final results = findSyncInternal(1); - if (results.isNotEmpty) { - return results[0]; - } else { - return null; - } - } - - @override - List findAllSync() => findSyncInternal(maxLimit); - - List findSyncInternal(int limit) { - return col.isar.getTxnSync(false, (Txn txn) { - final resultsPtr = txn.getCObjectsSet(); - try { - nCall(IC.isar_q_find(queryPtr, txn.ptr, resultsPtr, limit)); - return deserialize(resultsPtr.ref).cast(); - } finally { - IC.isar_free_c_object_set(resultsPtr); - } - }); - } - - @override - Future deleteFirst() => - deleteInternal(1).then((int count) => count == 1); - - @override - Future deleteAll() => deleteInternal(maxLimit); - - Future deleteInternal(int limit) { - return col.isar.getTxn(false, (Txn txn) async { - final countPtr = txn.alloc(); - IC.isar_q_delete(queryPtr, col.ptr, txn.ptr, limit, countPtr); - await txn.wait(); - return countPtr.value; - }); - } - - @override - bool deleteFirstSync() => deleteSyncInternal(1) == 1; - - @override - int deleteAllSync() => deleteSyncInternal(maxLimit); - - int deleteSyncInternal(int limit) { - return col.isar.getTxnSync(false, (Txn txn) { - final countPtr = txn.alloc(); - nCall(IC.isar_q_delete(queryPtr, col.ptr, txn.ptr, limit, countPtr)); - return countPtr.value; - }); - } - - @override - Stream> watch({bool fireImmediately = false}) { - return watchLazy(fireImmediately: fireImmediately) - .asyncMap((event) => findAll()); - } - - @override - Stream watchLazy({bool fireImmediately = false}) { - final port = ReceivePort(); - final handle = IC.isar_watch_query( - col.isar.ptr, - col.ptr, - queryPtr, - port.sendPort.nativePort, - ); - - final controller = StreamController( - onCancel: () { - IC.isar_stop_watching(handle); - port.close(); - }, - ); - - if (fireImmediately) { - controller.add(null); - } - - controller.addStream(port); - return controller.stream; - } - - @override - Future exportJsonRaw(R Function(Uint8List) callback) { - return col.isar.getTxn(false, (Txn txn) async { - final bytesPtrPtr = txn.alloc>(); - final lengthPtr = txn.alloc(); - final idNamePtr = col.schema.idName.toCString(txn.alloc); - - nCall( - IC.isar_q_export_json( - queryPtr, - col.ptr, - txn.ptr, - idNamePtr, - bytesPtrPtr, - lengthPtr, - ), - ); - - try { - await txn.wait(); - final bytes = bytesPtrPtr.value.asTypedList(lengthPtr.value); - return callback(bytes); - } finally { - IC.isar_free_json(bytesPtrPtr.value, lengthPtr.value); - } - }); - } - - @override - R exportJsonRawSync(R Function(Uint8List) callback) { - return col.isar.getTxnSync(false, (Txn txn) { - final bytesPtrPtr = txn.alloc>(); - final lengthPtr = txn.alloc(); - final idNamePtr = col.schema.idName.toCString(txn.alloc); - - try { - nCall( - IC.isar_q_export_json( - queryPtr, - col.ptr, - txn.ptr, - idNamePtr, - bytesPtrPtr, - lengthPtr, - ), - ); - final bytes = bytesPtrPtr.value.asTypedList(lengthPtr.value); - return callback(bytes); - } finally { - IC.isar_free_json(bytesPtrPtr.value, lengthPtr.value); - } - }); - } - - @override - Future aggregate(AggregationOp op) async { - return col.isar.getTxn(false, (Txn txn) async { - final resultPtrPtr = txn.alloc>(); - - IC.isar_q_aggregate( - col.ptr, - queryPtr, - txn.ptr, - op.index, - propertyId ?? 0, - resultPtrPtr, - ); - await txn.wait(); - - return _convertAggregatedResult(resultPtrPtr.value, op); - }); - } - - @override - R? aggregateSync(AggregationOp op) { - return col.isar.getTxnSync(false, (Txn txn) { - final resultPtrPtr = txn.alloc>(); - - nCall( - IC.isar_q_aggregate( - col.ptr, - queryPtr, - txn.ptr, - op.index, - propertyId ?? 0, - resultPtrPtr, - ), - ); - return _convertAggregatedResult(resultPtrPtr.value, op); - }); - } - - R? _convertAggregatedResult( - Pointer resultPtr, - AggregationOp op, - ) { - final nullable = op == AggregationOp.min || op == AggregationOp.max; - if (R == int || R == DateTime) { - final value = IC.isar_q_aggregate_long_result(resultPtr); - if (nullable && value == nullLong) { - return null; - } - if (R == int) { - return value as R; - } else { - return DateTime.fromMicrosecondsSinceEpoch(value, isUtc: true).toLocal() - as R; - } - } else { - final value = IC.isar_q_aggregate_double_result(resultPtr); - if (nullable && value.isNaN) { - return null; - } else { - return value as R; - } - } - } -} diff --git a/packages_external/isar-3.1.0-1/packages/isar/lib/src/native/split_words.dart b/packages_external/isar-3.1.0-1/packages/isar/lib/src/native/split_words.dart deleted file mode 100644 index 6a887fb4..00000000 --- a/packages_external/isar-3.1.0-1/packages/isar/lib/src/native/split_words.dart +++ /dev/null @@ -1,33 +0,0 @@ -import 'dart:ffi'; - -import 'package:ffi/ffi.dart'; -import 'package:isar/src/native/encode_string.dart'; -import 'package:isar/src/native/isar_core.dart'; -import 'package:isar/src/native/isar_reader_impl.dart'; - -// ignore: public_member_api_docs -List isarSplitWords(String input) { - initializeCoreBinary(); - - final bytesPtr = malloc(input.length * 3); - final bytes = bytesPtr.asTypedList(input.length * 3); - final byteCount = encodeString(input, bytes, 0); - - final wordCountPtr = malloc(); - final boundariesPtr = - IC.isar_find_word_boundaries(bytesPtr.cast(), byteCount, wordCountPtr); - final wordCount = wordCountPtr.value; - final boundaries = boundariesPtr.asTypedList(wordCount * 2); - - final words = []; - for (var i = 0; i < wordCount * 2; i++) { - final wordBytes = bytes.sublist(boundaries[i++], boundaries[i]); - words.add(IsarReaderImpl.utf8Decoder.convert(wordBytes)); - } - - IC.isar_free_word_boundaries(boundariesPtr, wordCount); - malloc.free(bytesPtr); - malloc.free(wordCountPtr); - - return words; -} diff --git a/packages_external/isar-3.1.0-1/packages/isar/lib/src/native/txn.dart b/packages_external/isar-3.1.0-1/packages/isar/lib/src/native/txn.dart deleted file mode 100644 index 6017aef4..00000000 --- a/packages_external/isar-3.1.0-1/packages/isar/lib/src/native/txn.dart +++ /dev/null @@ -1,113 +0,0 @@ -import 'dart:async'; -import 'dart:collection'; -import 'dart:ffi'; - -import 'package:ffi/ffi.dart'; -import 'package:isar/isar.dart'; -import 'package:isar/src/common/isar_common.dart'; -import 'package:isar/src/native/bindings.dart'; -import 'package:isar/src/native/isar_core.dart'; - -/// @nodoc -class Txn extends Transaction { - /// @nodoc - Txn.sync(Isar isar, this.ptr, bool write) : super(isar, true, write); - - /// @nodoc - Txn.async(Isar isar, this.ptr, bool write, Stream stream) - : super(isar, false, write) { - _completers = Queue(); - _portSubscription = stream.listen( - (_) => _completers.removeFirst().complete(), - onError: (Object e) => _completers.removeFirst().completeError(e), - ); - } - - @override - bool active = true; - - /// An arena allocator that has the same lifetime as this transaction. - final alloc = Arena(malloc); - - /// The pointer to the native transaction. - final Pointer ptr; - Pointer? _cObjPtr; - Pointer? _cObjSetPtr; - - late Pointer _buffer; - int _bufferLen = -1; - - late final Queue> _completers; - late final StreamSubscription? _portSubscription; - - /// Get a shared CObject pointer - Pointer getCObject() { - _cObjPtr ??= alloc(); - return _cObjPtr!; - } - - /// Get a shared CObjectSet pointer - Pointer getCObjectsSet() { - _cObjSetPtr ??= alloc(); - return _cObjSetPtr!; - } - - /// Allocate a new CObjectSet with the given capacity. - Pointer newCObjectSet(int length) { - final cObjSetPtr = alloc(); - cObjSetPtr.ref - ..objects = alloc(length) - ..length = length; - return cObjSetPtr; - } - - /// Get a shared buffer with at least the specified size. - Pointer getBuffer(int size) { - if (_bufferLen < size) { - final allocSize = (size * 1.3).toInt(); - _buffer = alloc(allocSize); - _bufferLen = allocSize; - } - return _buffer; - } - - /// Wait for the latest async operation to complete. - Future wait() { - final completer = Completer(); - _completers.add(completer); - return completer.future; - } - - @override - Future commit() async { - active = false; - IC.isar_txn_finish(ptr, true); - await wait(); - unawaited(_portSubscription!.cancel()); - } - - @override - void commitSync() { - active = false; - nCall(IC.isar_txn_finish(ptr, true)); - } - - @override - Future abort() async { - active = false; - IC.isar_txn_finish(ptr, false); - await wait(); - unawaited(_portSubscription!.cancel()); - } - - @override - void abortSync() { - active = false; - nCall(IC.isar_txn_finish(ptr, false)); - } - - @override - void free() { - alloc.releaseAll(); - } -} diff --git a/packages_external/isar-3.1.0-1/packages/isar/lib/src/query.dart b/packages_external/isar-3.1.0-1/packages/isar/lib/src/query.dart deleted file mode 100644 index 89c7bd74..00000000 --- a/packages_external/isar-3.1.0-1/packages/isar/lib/src/query.dart +++ /dev/null @@ -1,204 +0,0 @@ -part of isar; - -/// Querying is how you find records that match certain conditions. -abstract class Query { - /// The default precision for floating point number queries. - static const double epsilon = 0.00001; - - /// The corresponding Isar instance. - Isar get isar; - - /// {@template query_find_first} - /// Find the first object that matches this query or `null` if no object - /// matches. - /// {@endtemplate} - Future findFirst(); - - /// {@macro query_find_first} - T? findFirstSync(); - - /// {@template query_find_all} - /// Find all objects that match this query. - /// {@endtemplate} - Future> findAll(); - - /// {@macro query_find_all} - List findAllSync(); - - /// @nodoc - @protected - Future aggregate(AggregationOp op); - - /// @nodoc - @protected - R? aggregateSync(AggregationOp op); - - /// {@template query_count} - /// Count how many objects match this query. - /// - /// This operation is much faster than using `findAll().length`. - /// {@endtemplate} - Future count() => - aggregate(AggregationOp.count).then((int? value) => value!); - - /// {@macro query_count} - int countSync() => aggregateSync(AggregationOp.count)!; - - /// {@template query_is_empty} - /// Returns `true` if there are no objects that match this query. - /// - /// This operation is faster than using `count() == 0`. - /// {@endtemplate} - Future isEmpty() => - aggregate(AggregationOp.isEmpty).then((value) => value == 1); - - /// {@macro query_is_empty} - bool isEmptySync() => aggregateSync(AggregationOp.isEmpty) == 1; - - /// {@template query_is_not_empty} - /// Returns `true` if there are objects that match this query. - /// - /// This operation is faster than using `count() > 0`. - /// {@endtemplate} - Future isNotEmpty() => - aggregate(AggregationOp.isEmpty).then((value) => value == 0); - - /// {@macro query_is_not_empty} - bool isNotEmptySync() => aggregateSync(AggregationOp.isEmpty) == 0; - - /// {@template query_delete_first} - /// Delete the first object that matches this query. Returns whether a object - /// has been deleted. - /// {@endtemplate} - Future deleteFirst(); - - /// {@macro query_delete_first} - bool deleteFirstSync(); - - /// {@template query_delete_all} - /// Delete all objects that match this query. Returns the number of deleted - /// objects. - /// {@endtemplate} - Future deleteAll(); - - /// {@macro query_delete_all} - int deleteAllSync(); - - /// {@template query_watch} - /// Create a watcher that yields the results of this query whenever its - /// results have (potentially) changed. - /// - /// If you don't always use the results, consider using `watchLazy` and rerun - /// the query manually. If [fireImmediately] is `true`, the results will be - /// sent to the consumer immediately. - /// {@endtemplate} - Stream> watch({bool fireImmediately = false}); - - /// {@template query_watch_lazy} - /// Watch the query for changes. If [fireImmediately] is `true`, an event will - /// be fired immediately. - /// {@endtemplate} - Stream watchLazy({bool fireImmediately = false}); - - /// {@template query_export_json_raw} - /// Export the results of this query as json bytes. - /// - /// **IMPORTANT:** Do not leak the bytes outside the callback. If you need to - /// use the bytes outside, create a copy of the `Uint8List`. - /// {@endtemplate} - Future exportJsonRaw(R Function(Uint8List) callback); - - /// {@macro query_export_json_raw} - R exportJsonRawSync(R Function(Uint8List) callback); - - /// {@template query_export_json} - /// Export the results of this query as json. - /// {@endtemplate} - Future>> exportJson() { - return exportJsonRaw((Uint8List bytes) { - final json = jsonDecode(const Utf8Decoder().convert(bytes)) as List; - return json.cast>(); - }); - } - - /// {@macro query_export_json} - List> exportJsonSync() { - return exportJsonRawSync((Uint8List bytes) { - final json = jsonDecode(const Utf8Decoder().convert(bytes)) as List; - return json.cast>(); - }); - } -} - -/// @nodoc -@protected -enum AggregationOp { - /// Finds the smallest value. - min, - - /// Finds the largest value. - max, - - /// Calculates the sum of all values. - sum, - - /// Calculates the average of all values. - average, - - /// Counts all values. - count, - - /// Returns `true` if the query has no results. - isEmpty, -} - -/// Extension for Queries -extension QueryAggregation on Query { - /// {@template aggregation_min} - /// Returns the minimum value of this query. - /// {@endtemplate} - Future min() => aggregate(AggregationOp.min); - - /// {@macro aggregation_min} - T? minSync() => aggregateSync(AggregationOp.min); - - /// {@template aggregation_max} - /// Returns the maximum value of this query. - /// {@endtemplate} - Future max() => aggregate(AggregationOp.max); - - /// {@macro aggregation_max} - T? maxSync() => aggregateSync(AggregationOp.max); - - /// {@template aggregation_average} - /// Returns the average value of this query. - /// {@endtemplate} - Future average() => - aggregate(AggregationOp.average).then((double? value) => value!); - - /// {@macro aggregation_average} - double averageSync() => aggregateSync(AggregationOp.average)!; - - /// {@template aggregation_sum} - /// Returns the sum of all values of this query. - /// {@endtemplate} - Future sum() => aggregate(AggregationOp.sum).then((value) => value!); - - /// {@macro aggregation_sum} - T sumSync() => aggregateSync(AggregationOp.sum)!; -} - -/// Extension for Queries -extension QueryDateAggregation on Query { - /// {@macro aggregation_min} - Future min() => aggregate(AggregationOp.min); - - /// {@macro aggregation_min} - DateTime? minSync() => aggregateSync(AggregationOp.min); - - /// {@macro aggregation_max} - Future max() => aggregate(AggregationOp.max); - - /// {@macro aggregation_max} - DateTime? maxSync() => aggregateSync(AggregationOp.max); -} diff --git a/packages_external/isar-3.1.0-1/packages/isar/lib/src/query_builder.dart b/packages_external/isar-3.1.0-1/packages/isar/lib/src/query_builder.dart deleted file mode 100644 index a29e6d25..00000000 --- a/packages_external/isar-3.1.0-1/packages/isar/lib/src/query_builder.dart +++ /dev/null @@ -1,403 +0,0 @@ -part of isar; - -/// @nodoc -@protected -typedef FilterQuery = QueryBuilder - Function(QueryBuilder q); - -/// Query builders are used to create queries in a safe way. -/// -/// Acquire a `QueryBuilder` instance using `collection.where()` or -/// `collection.filter()`. -class QueryBuilder { - /// @nodoc - @protected - const QueryBuilder(this._query); - - final QueryBuilderInternal _query; - - /// @nodoc - @protected - static QueryBuilder apply( - QueryBuilder qb, - QueryBuilderInternal Function(QueryBuilderInternal query) - transform, - ) { - return QueryBuilder(transform(qb._query)); - } -} - -/// @nodoc -@protected -class QueryBuilderInternal { - /// @nodoc - const QueryBuilderInternal({ - this.collection, - this.whereClauses = const [], - this.whereDistinct = false, - this.whereSort = Sort.asc, - this.filter = const FilterGroup.and([]), - this.filterGroupType = FilterGroupType.and, - this.filterNot = false, - this.distinctByProperties = const [], - this.sortByProperties = const [], - this.offset, - this.limit, - this.propertyName, - }); - - /// @nodoc - final IsarCollection? collection; - - /// @nodoc - final List whereClauses; - - /// @nodoc - final bool whereDistinct; - - /// @nodoc - final Sort whereSort; - - /// @nodoc - final FilterGroup filter; - - /// @nodoc - final FilterGroupType filterGroupType; - - /// @nodoc - final bool filterNot; - - /// @nodoc - final List distinctByProperties; - - /// @nodoc - final List sortByProperties; - - /// @nodoc - final int? offset; - - /// @nodoc - final int? limit; - - /// @nodoc - final String? propertyName; - - /// @nodoc - QueryBuilderInternal addFilterCondition(FilterOperation cond) { - if (filterNot) { - cond = FilterGroup.not(cond); - } - - late FilterGroup filterGroup; - - if (filter.type == filterGroupType || filter.filters.length <= 1) { - filterGroup = FilterGroup( - type: filterGroupType, - filters: [...filter.filters, cond], - ); - } else if (filterGroupType == FilterGroupType.and) { - filterGroup = FilterGroup( - type: filter.type, - filters: [ - ...filter.filters.sublist(0, filter.filters.length - 1), - FilterGroup( - type: filterGroupType, - filters: [filter.filters.last, cond], - ), - ], - ); - } else { - filterGroup = FilterGroup( - type: filterGroupType, - filters: [filter, cond], - ); - } - - return copyWith( - filter: filterGroup, - filterGroupType: FilterGroupType.and, - filterNot: false, - ); - } - - /// @nodoc - QueryBuilderInternal addWhereClause(WhereClause where) { - return copyWith(whereClauses: [...whereClauses, where]); - } - - /// @nodoc - QueryBuilderInternal group(FilterQuery q) { - // ignore: prefer_const_constructors - final qb = q(QueryBuilder(QueryBuilderInternal())); - return addFilterCondition(qb._query.filter); - } - - /// @nodoc - QueryBuilderInternal listLength( - String property, - int lower, - bool includeLower, - int upper, - bool includeUpper, - ) { - if (!includeLower) { - lower += 1; - } - if (!includeUpper) { - if (upper == 0) { - lower = 1; - } else { - upper -= 1; - } - } - return addFilterCondition( - FilterCondition.listLength( - property: property, - lower: lower, - upper: upper, - ), - ); - } - - /// @nodoc - QueryBuilderInternal object( - FilterQuery q, - String property, - ) { - // ignore: prefer_const_constructors - final qb = q(QueryBuilder(QueryBuilderInternal())); - return addFilterCondition( - ObjectFilter(filter: qb._query.filter, property: property), - ); - } - - /// @nodoc - QueryBuilderInternal link( - FilterQuery q, - String linkName, - ) { - // ignore: prefer_const_constructors - final qb = q(QueryBuilder(QueryBuilderInternal())); - return addFilterCondition( - LinkFilter(filter: qb._query.filter, linkName: linkName), - ); - } - - /// @nodoc - QueryBuilderInternal linkLength( - String linkName, - int lower, - bool includeLower, - int upper, - bool includeUpper, - ) { - if (!includeLower) { - lower += 1; - } - if (!includeUpper) { - if (upper == 0) { - lower = 1; - } else { - upper -= 1; - } - } - return addFilterCondition( - LinkFilter.length( - lower: lower, - upper: upper, - linkName: linkName, - ), - ); - } - - /// @nodoc - QueryBuilderInternal addSortBy(String propertyName, Sort sort) { - return copyWith( - sortByProperties: [ - ...sortByProperties, - SortProperty(property: propertyName, sort: sort), - ], - ); - } - - /// @nodoc - QueryBuilderInternal addDistinctBy( - String propertyName, { - bool? caseSensitive, - }) { - return copyWith( - distinctByProperties: [ - ...distinctByProperties, - DistinctProperty( - property: propertyName, - caseSensitive: caseSensitive, - ), - ], - ); - } - - /// @nodoc - QueryBuilderInternal addPropertyName(String propertyName) { - return copyWith(propertyName: propertyName); - } - - /// @nodoc - QueryBuilderInternal copyWith({ - List? whereClauses, - FilterGroup? filter, - bool? filterIsGrouped, - FilterGroupType? filterGroupType, - bool? filterNot, - List? parentFilters, - List? distinctByProperties, - List? sortByProperties, - int? offset, - int? limit, - String? propertyName, - }) { - assert(offset == null || offset >= 0, 'Invalid offset'); - assert(limit == null || limit >= 0, 'Invalid limit'); - return QueryBuilderInternal( - collection: collection, - whereClauses: whereClauses ?? List.unmodifiable(this.whereClauses), - whereDistinct: whereDistinct, - whereSort: whereSort, - filter: filter ?? this.filter, - filterGroupType: filterGroupType ?? this.filterGroupType, - filterNot: filterNot ?? this.filterNot, - distinctByProperties: - distinctByProperties ?? List.unmodifiable(this.distinctByProperties), - sortByProperties: - sortByProperties ?? List.unmodifiable(this.sortByProperties), - offset: offset ?? this.offset, - limit: limit ?? this.limit, - propertyName: propertyName ?? this.propertyName, - ); - } - - /// @nodoc - @protected - Query build() { - return collection!.buildQuery( - whereDistinct: whereDistinct, - whereSort: whereSort, - whereClauses: whereClauses, - filter: filter, - sortBy: sortByProperties, - distinctBy: distinctByProperties, - offset: offset, - limit: limit, - property: propertyName, - ); - } -} - -/// @nodoc -/// -/// Right after query starts -@protected -class QWhere - implements - QWhereClause, - QFilter, - QSortBy, - QDistinct, - QOffset, - QLimit, - QQueryProperty {} - -/// @nodoc -/// -/// No more where conditions are allowed -@protected -class QAfterWhere - implements QFilter, QSortBy, QDistinct, QOffset, QLimit, QQueryProperty {} - -/// @nodoc -@protected -class QWhereClause {} - -/// @nodoc -@protected -class QAfterWhereClause - implements - QWhereOr, - QFilter, - QSortBy, - QDistinct, - QOffset, - QLimit, - QQueryProperty {} - -/// @nodoc -@protected -class QWhereOr {} - -/// @nodoc -@protected -class QFilter {} - -/// @nodoc -@protected -class QFilterCondition {} - -/// @nodoc -@protected -class QAfterFilterCondition - implements - QFilterCondition, - QFilterOperator, - QSortBy, - QDistinct, - QOffset, - QLimit, - QQueryProperty {} - -/// @nodoc -@protected -class QFilterOperator {} - -/// @nodoc -@protected -class QAfterFilterOperator implements QFilterCondition {} - -/// @nodoc -@protected -class QSortBy {} - -/// @nodoc -@protected -class QAfterSortBy - implements QSortThenBy, QDistinct, QOffset, QLimit, QQueryProperty {} - -/// @nodoc -@protected -class QSortThenBy {} - -/// @nodoc -@protected -class QDistinct implements QOffset, QLimit, QQueryProperty {} - -/// @nodoc -@protected -class QOffset {} - -/// @nodoc -@protected -class QAfterOffset implements QLimit, QQueryProperty {} - -/// @nodoc -@protected -class QLimit {} - -/// @nodoc -@protected -class QAfterLimit implements QQueryProperty {} - -/// @nodoc -@protected -class QQueryProperty implements QQueryOperations {} - -/// @nodoc -@protected -class QQueryOperations {} diff --git a/packages_external/isar-3.1.0-1/packages/isar/lib/src/query_builder_extensions.dart b/packages_external/isar-3.1.0-1/packages/isar/lib/src/query_builder_extensions.dart deleted file mode 100644 index 70be3c05..00000000 --- a/packages_external/isar-3.1.0-1/packages/isar/lib/src/query_builder_extensions.dart +++ /dev/null @@ -1,303 +0,0 @@ -part of isar; - -/// Extension for QueryBuilders. -extension QueryWhereOr on QueryBuilder { - /// Union of two where clauses. - QueryBuilder or() { - return QueryBuilder(_query); - } -} - -/// @nodoc -@protected -typedef WhereRepeatModifier = QueryBuilder - Function(QueryBuilder q, E element); - -/// Extension for QueryBuilders. -extension QueryWhere on QueryBuilder { - /// Joins the results of the [modifier] for each item in [items] using logical - /// OR. So an object will be included if it matches at least one of the - /// resulting where clauses. - /// - /// If [items] is empty, this is a no-op. - QueryBuilder anyOf( - Iterable items, - WhereRepeatModifier modifier, - ) { - QueryBuilder? q; - for (final e in items) { - q = modifier(q?.or() ?? QueryBuilder(_query), e); - } - return q ?? QueryBuilder(_query); - } -} - -/// Extension for QueryBuilders. -extension QueryFilters on QueryBuilder { - /// Start using filter conditions. - QueryBuilder filter() { - return QueryBuilder(_query); - } -} - -/// @nodoc -@protected -typedef FilterRepeatModifier - = QueryBuilder Function( - QueryBuilder q, - E element, -); - -/// Extension for QueryBuilders. -extension QueryFilterAndOr on QueryBuilder { - /// Intersection of two filter conditions. - QueryBuilder and() { - return QueryBuilder.apply( - this, - (q) => q.copyWith(filterGroupType: FilterGroupType.and), - ); - } - - /// Union of two filter conditions. - QueryBuilder or() { - return QueryBuilder.apply( - this, - (q) => q.copyWith(filterGroupType: FilterGroupType.or), - ); - } - - /// Logical XOR of two filter conditions. - QueryBuilder xor() { - return QueryBuilder.apply( - this, - (q) => q.copyWith(filterGroupType: FilterGroupType.xor), - ); - } -} - -/// Extension for QueryBuilders. -extension QueryFilterNot on QueryBuilder { - /// Complement the next filter condition or group. - QueryBuilder not() { - return QueryBuilder.apply( - this, - (q) => q.copyWith(filterNot: !q.filterNot), - ); - } - - /// Joins the results of the [modifier] for each item in [items] using logical - /// OR. So an object will be included if it matches at least one of the - /// resulting filters. - /// - /// If [items] is empty, this is a no-op. - QueryBuilder anyOf( - Iterable items, - FilterRepeatModifier modifier, - ) { - return QueryBuilder.apply(this, (query) { - return query.group((q) { - var q2 = QueryBuilder(q._query); - for (final e in items) { - q2 = modifier(q2.or(), e); - } - return q2; - }); - }); - } - - /// Joins the results of the [modifier] for each item in [items] using logical - /// AND. So an object will be included if it matches all of the resulting - /// filters. - /// - /// If [items] is empty, this is a no-op. - QueryBuilder allOf( - Iterable items, - FilterRepeatModifier modifier, - ) { - return QueryBuilder.apply(this, (query) { - return query.group((q) { - var q2 = QueryBuilder(q._query); - for (final e in items) { - q2 = modifier(q2.and(), e); - } - return q2; - }); - }); - } - - /// Joins the results of the [modifier] for each item in [items] using logical - /// XOR. So an object will be included if it matches exactly one of the - /// resulting filters. - /// - /// If [items] is empty, this is a no-op. - QueryBuilder oneOf( - Iterable items, - FilterRepeatModifier modifier, - ) { - QueryBuilder? q; - for (final e in items) { - q = modifier(q?.xor() ?? QueryBuilder(_query), e); - } - return q ?? QueryBuilder(_query); - } -} - -/// Extension for QueryBuilders. -extension QueryFilterNoGroups - on QueryBuilder { - /// Group filter conditions. - QueryBuilder group(FilterQuery q) { - return QueryBuilder.apply(this, (query) => query.group(q)); - } -} - -/// Extension for QueryBuilders. -extension QueryOffset on QueryBuilder { - /// Offset the query results by a static number. - QueryBuilder offset(int offset) { - return QueryBuilder.apply(this, (q) => q.copyWith(offset: offset)); - } -} - -/// Extension for QueryBuilders. -extension QueryLimit on QueryBuilder { - /// Limit the maximum number of query results. - QueryBuilder limit(int limit) { - return QueryBuilder.apply(this, (q) => q.copyWith(limit: limit)); - } -} - -/// @nodoc -@protected -typedef QueryOption = QueryBuilder Function( - QueryBuilder q, -); - -/// Extension for QueryBuilders. -extension QueryModifier on QueryBuilder { - /// Only apply a part of the query if `enabled` is true. - QueryBuilder optional( - bool enabled, - QueryOption option, - ) { - if (enabled) { - return option(this); - } else { - return QueryBuilder(_query); - } - } -} - -/// Extension for QueryBuilders -extension QueryExecute on QueryBuilder { - /// Create a query from this query builder. - Query build() => _query.build(); - - /// {@macro query_find_first} - Future findFirst() => build().findFirst(); - - /// {@macro query_find_first} - R? findFirstSync() => build().findFirstSync(); - - /// {@macro query_find_all} - Future> findAll() => build().findAll(); - - /// {@macro query_find_all} - List findAllSync() => build().findAllSync(); - - /// {@macro query_count} - Future count() => build().count(); - - /// {@macro query_count} - int countSync() => build().countSync(); - - /// {@macro query_is_empty} - Future isEmpty() => build().isEmpty(); - - /// {@macro query_is_empty} - bool isEmptySync() => build().isEmptySync(); - - /// {@macro query_is_not_empty} - Future isNotEmpty() => build().isNotEmpty(); - - /// {@macro query_is_not_empty} - bool isNotEmptySync() => build().isNotEmptySync(); - - /// {@macro query_delete_first} - Future deleteFirst() => build().deleteFirst(); - - /// {@macro query_delete_first} - bool deleteFirstSync() => build().deleteFirstSync(); - - /// {@macro query_delete_all} - Future deleteAll() => build().deleteAll(); - - /// {@macro query_delete_all} - int deleteAllSync() => build().deleteAllSync(); - - /// {@macro query_watch} - Stream> watch({bool fireImmediately = false}) => - build().watch(fireImmediately: fireImmediately); - - /// {@macro query_watch_lazy} - Stream watchLazy({bool fireImmediately = false}) => - build().watchLazy(fireImmediately: fireImmediately); - - /// {@macro query_export_json_raw} - Future exportJsonRaw(T Function(Uint8List) callback) => - build().exportJsonRaw(callback); - - /// {@macro query_export_json_raw} - T exportJsonRawSync(T Function(Uint8List) callback) => - build().exportJsonRawSync(callback); - - /// {@macro query_export_json} - Future>> exportJson() => build().exportJson(); - - /// {@macro query_export_json} - List> exportJsonSync() => build().exportJsonSync(); -} - -/// Extension for QueryBuilders -extension QueryExecuteAggregation - on QueryBuilder { - /// {@macro aggregation_min} - Future min() => build().min(); - - /// {@macro aggregation_min} - T? minSync() => build().minSync(); - - /// {@macro aggregation_max} - Future max() => build().max(); - - /// {@macro aggregation_max} - T? maxSync() => build().maxSync(); - - /// {@macro aggregation_average} - Future average() => build().average(); - - /// {@macro aggregation_average} - double averageSync() => build().averageSync(); - - /// {@macro aggregation_sum} - Future sum() => build().sum(); - - /// {@macro aggregation_sum} - T sumSync() => build().sumSync(); -} - -/// Extension for QueryBuilders -extension QueryExecuteDateAggregation - on QueryBuilder { - /// {@macro aggregation_min} - Future min() => build().min(); - - /// {@macro aggregation_min} - DateTime? minSync() => build().minSync(); - - /// {@macro aggregation_max} - Future max() => build().max(); - - /// {@macro aggregation_max} - DateTime? maxSync() => build().maxSync(); -} diff --git a/packages_external/isar-3.1.0-1/packages/isar/lib/src/query_components.dart b/packages_external/isar-3.1.0-1/packages/isar/lib/src/query_components.dart deleted file mode 100644 index de680e3f..00000000 --- a/packages_external/isar-3.1.0-1/packages/isar/lib/src/query_components.dart +++ /dev/null @@ -1,597 +0,0 @@ -part of isar; - -/// A where clause to traverse an Isar index. -abstract class WhereClause { - const WhereClause._(); -} - -/// A where clause traversing the primary index (ids). -class IdWhereClause extends WhereClause { - /// Where clause that matches all ids. Useful to get sorted results. - const IdWhereClause.any() - : lower = null, - upper = null, - includeLower = true, - includeUpper = true, - super._(); - - /// Where clause that matches all id values greater than the given [lower] - /// bound. - const IdWhereClause.greaterThan({ - required Id this.lower, - this.includeLower = true, - }) : upper = null, - includeUpper = true, - super._(); - - /// Where clause that matches all id values less than the given [upper] - /// bound. - const IdWhereClause.lessThan({ - required Id this.upper, - this.includeUpper = true, - }) : lower = null, - includeLower = true, - super._(); - - /// Where clause that matches the id value equal to the given [value]. - const IdWhereClause.equalTo({ - required Id value, - }) : lower = value, - upper = value, - includeLower = true, - includeUpper = true, - super._(); - - /// Where clause that matches all id values between the given [lower] and - /// [upper] bounds. - const IdWhereClause.between({ - this.lower, - this.includeLower = true, - this.upper, - this.includeUpper = true, - }) : super._(); - - /// The lower bound id or `null` for unbounded. - final Id? lower; - - /// Whether the lower bound should be included in the results. - final bool includeLower; - - /// The upper bound id or `null` for unbounded. - final Id? upper; - - /// Whether the upper bound should be included in the results. - final bool includeUpper; -} - -/// A where clause traversing an index. -class IndexWhereClause extends WhereClause { - /// Where clause that matches all index values. Useful to get sorted results. - const IndexWhereClause.any({required this.indexName}) - : lower = null, - upper = null, - includeLower = true, - includeUpper = true, - epsilon = Query.epsilon, - super._(); - - /// Where clause that matches all index values greater than the given [lower] - /// bound. - /// - /// For composite indexes, the first elements of the [lower] list are checked - /// for equality. - const IndexWhereClause.greaterThan({ - required this.indexName, - required IndexKey this.lower, - this.includeLower = true, - this.epsilon = Query.epsilon, - }) : upper = null, - includeUpper = true, - super._(); - - /// Where clause that matches all index values less than the given [upper] - /// bound. - /// - /// For composite indexes, the first elements of the [upper] list are checked - /// for equality. - const IndexWhereClause.lessThan({ - required this.indexName, - required IndexKey this.upper, - this.includeUpper = true, - this.epsilon = Query.epsilon, - }) : lower = null, - includeLower = true, - super._(); - - /// Where clause that matches all index values equal to the given [value]. - const IndexWhereClause.equalTo({ - required this.indexName, - required IndexKey value, - this.epsilon = Query.epsilon, - }) : lower = value, - upper = value, - includeLower = true, - includeUpper = true, - super._(); - - /// Where clause that matches all index values between the given [lower] and - /// [upper] bounds. - /// - /// For composite indexes, the first elements of the [lower] and [upper] lists - /// are checked for equality. - const IndexWhereClause.between({ - required this.indexName, - required IndexKey this.lower, - required IndexKey this.upper, - this.includeLower = true, - this.includeUpper = true, - this.epsilon = Query.epsilon, - }) : super._(); - - /// The Isar name of the index to be used. - final String indexName; - - /// The lower bound of the where clause. - final IndexKey? lower; - - /// Whether the lower bound should be included in the results. Double values - /// are never included. - final bool includeLower; - - /// The upper bound of the where clause. - final IndexKey? upper; - - /// Whether the upper bound should be included in the results. Double values - /// are never included. - final bool includeUpper; - - /// The precision to use for floating point values. - final double epsilon; -} - -/// A where clause traversing objects linked to the specified object. -class LinkWhereClause extends WhereClause { - /// Create a where clause for the specified link. - const LinkWhereClause({ - required this.linkCollection, - required this.linkName, - required this.id, - }) : super._(); - - /// The name of the collection the link originates from. - final String linkCollection; - - /// The isar name of the link to be used. - final String linkName; - - /// The id of the source object. - final Id id; -} - -/// @nodoc -@protected -abstract class FilterOperation { - const FilterOperation._(); -} - -/// The type of dynamic filter conditions. -enum FilterConditionType { - /// Filter checking for equality. - equalTo, - - /// Filter matching values greater than the bound. - greaterThan, - - /// Filter matching values smaller than the bound. - lessThan, - - /// Filter matching values between the bounds. - between, - - /// Filter matching String values starting with the prefix. - startsWith, - - /// Filter matching String values ending with the suffix. - endsWith, - - /// Filter matching String values containing the String. - contains, - - /// Filter matching String values matching the wildcard. - matches, - - /// Filter matching values that are `null`. - isNull, - - /// Filter matching values that are not `null`. - isNotNull, - - /// Filter matching lists that contain `null`. - elementIsNull, - - /// Filter matching lists that contain an element that is not `null`. - elementIsNotNull, - - /// Filter matching the length of a list. - listLength, -} - -/// Create a filter condition dynamically. -class FilterCondition extends FilterOperation { - /// @nodoc - @protected - const FilterCondition({ - required this.type, - required this.property, - required this.include1, - required this.include2, - required this.caseSensitive, - this.value1, - this.value2, - this.epsilon = Query.epsilon, - }) : super._(); - - /// Filters the results to only include objects where the property equals - /// [value]. - /// - /// For lists, at least one of the values in the list has to match. - const FilterCondition.equalTo({ - required this.property, - required Object? value, - this.caseSensitive = true, - this.epsilon = Query.epsilon, - }) : type = FilterConditionType.equalTo, - value1 = value, - include1 = true, - value2 = null, - include2 = false, - super._(); - - /// Filters the results to only include objects where the property is greater - /// than [value]. - /// - /// For lists, at least one of the values in the list has to match. - const FilterCondition.greaterThan({ - required this.property, - required Object? value, - bool include = false, - this.caseSensitive = true, - this.epsilon = Query.epsilon, - }) : type = FilterConditionType.greaterThan, - value1 = value, - include1 = include, - value2 = null, - include2 = false, - super._(); - - /// Filters the results to only include objects where the property is less - /// than [value]. - /// - /// For lists, at least one of the values in the list has to match. - const FilterCondition.lessThan({ - required this.property, - required Object? value, - bool include = false, - this.caseSensitive = true, - this.epsilon = Query.epsilon, - }) : type = FilterConditionType.lessThan, - value1 = value, - include1 = include, - value2 = null, - include2 = false, - super._(); - - /// Filters the results to only include objects where the property is - /// between [lower] and [upper]. - /// - /// For lists, at least one of the values in the list has to match. - const FilterCondition.between({ - required this.property, - Object? lower, - bool includeLower = true, - Object? upper, - bool includeUpper = true, - this.caseSensitive = true, - this.epsilon = Query.epsilon, - }) : value1 = lower, - include1 = includeLower, - value2 = upper, - include2 = includeUpper, - type = FilterConditionType.between, - super._(); - - /// Filters the results to only include objects where the property starts - /// with [value]. - /// - /// For String lists, at least one of the values in the list has to match. - const FilterCondition.startsWith({ - required this.property, - required String value, - this.caseSensitive = true, - }) : type = FilterConditionType.startsWith, - value1 = value, - include1 = true, - value2 = null, - include2 = false, - epsilon = Query.epsilon, - super._(); - - /// Filters the results to only include objects where the property ends with - /// [value]. - /// - /// For String lists, at least one of the values in the list has to match. - const FilterCondition.endsWith({ - required this.property, - required String value, - this.caseSensitive = true, - }) : type = FilterConditionType.endsWith, - value1 = value, - include1 = true, - value2 = null, - include2 = false, - epsilon = Query.epsilon, - super._(); - - /// Filters the results to only include objects where the String property - /// contains [value]. - /// - /// For String lists, at least one of the values in the list has to match. - const FilterCondition.contains({ - required this.property, - required String value, - this.caseSensitive = true, - }) : type = FilterConditionType.contains, - value1 = value, - include1 = true, - value2 = null, - include2 = false, - epsilon = Query.epsilon, - super._(); - - /// Filters the results to only include objects where the property matches - /// the [wildcard]. - /// - /// For String lists, at least one of the values in the list has to match. - const FilterCondition.matches({ - required this.property, - required String wildcard, - this.caseSensitive = true, - }) : type = FilterConditionType.matches, - value1 = wildcard, - include1 = true, - value2 = null, - include2 = false, - epsilon = Query.epsilon, - super._(); - - /// Filters the results to only include objects where the property is null. - const FilterCondition.isNull({ - required this.property, - }) : type = FilterConditionType.isNull, - value1 = null, - include1 = false, - value2 = null, - include2 = false, - caseSensitive = false, - epsilon = Query.epsilon, - super._(); - - /// Filters the results to only include objects where the property is not - /// null. - const FilterCondition.isNotNull({ - required this.property, - }) : type = FilterConditionType.isNotNull, - value1 = null, - include1 = false, - value2 = null, - include2 = false, - caseSensitive = false, - epsilon = Query.epsilon, - super._(); - - /// Filters the results to only include lists that contain `null`. - const FilterCondition.elementIsNull({ - required this.property, - }) : type = FilterConditionType.elementIsNull, - value1 = null, - include1 = false, - value2 = null, - include2 = false, - caseSensitive = false, - epsilon = Query.epsilon, - super._(); - - /// Filters the results to only include lists that do not contain `null`. - const FilterCondition.elementIsNotNull({ - required this.property, - }) : type = FilterConditionType.elementIsNotNull, - value1 = null, - include1 = false, - value2 = null, - include2 = false, - caseSensitive = false, - epsilon = Query.epsilon, - super._(); - - /// Filters the results to only include objects where the length of - /// [property] is between [lower] (included) and [upper] (included). - /// - /// Only list properties are supported. - const FilterCondition.listLength({ - required this.property, - required int lower, - required int upper, - }) : type = FilterConditionType.listLength, - value1 = lower, - include1 = true, - value2 = upper, - include2 = true, - caseSensitive = false, - epsilon = Query.epsilon, - assert(lower >= 0 && upper >= 0, 'List length must be positive.'), - super._(); - - /// Type of the filter condition. - final FilterConditionType type; - - /// Property used for comparisons. - final String property; - - /// Value used for comparisons. Lower bound for `ConditionType.between`. - final Object? value1; - - /// Should `value1` be part of the results. - final bool include1; - - /// Upper bound for `ConditionType.between`. - final Object? value2; - - /// Should `value1` be part of the results. - final bool include2; - - /// Are string operations case sensitive. - final bool caseSensitive; - - /// The precision to use for floating point values. - final double epsilon; -} - -/// The type of filter groups. -enum FilterGroupType { - /// Logical AND. - and, - - /// Logical OR. - or, - - /// Logical XOR. - xor, - - /// Logical NOT. - not, -} - -/// Group one or more filter conditions. -class FilterGroup extends FilterOperation { - /// @nodoc - @protected - FilterGroup({ - required this.type, - required this.filters, - }) : super._(); - - /// Create a logical AND filter group. - /// - /// Matches when all [filters] match. - const FilterGroup.and(this.filters) - : type = FilterGroupType.and, - super._(); - - /// Create a logical OR filter group. - /// - /// Matches when any of the [filters] matches. - const FilterGroup.or(this.filters) - : type = FilterGroupType.or, - super._(); - - /// Create a logical XOR filter group. - /// - /// Matches when exactly one of the [filters] matches. - const FilterGroup.xor(this.filters) - : type = FilterGroupType.xor, - super._(); - - /// Negate a filter. - /// - /// Matches when any of the [filter] doesn't matches. - FilterGroup.not(FilterOperation filter) - : filters = [filter], - type = FilterGroupType.not, - super._(); - - /// Type of this group. - final FilterGroupType type; - - /// The filter(s) to be grouped. - final List filters; -} - -/// Sort order -enum Sort { - /// Ascending sort order. - asc, - - /// Descending sort order. - desc, -} - -/// Property used to sort query results. -class SortProperty { - /// Create a sort property. - const SortProperty({required this.property, required this.sort}); - - /// Isar name of the property used for sorting. - final String property; - - /// Sort order. - final Sort sort; -} - -/// Property used to filter duplicate values. -class DistinctProperty { - /// Create a distinct property. - const DistinctProperty({required this.property, this.caseSensitive}); - - /// Isar name of the property used for sorting. - final String property; - - /// Should Strings be case sensitive? - final bool? caseSensitive; -} - -/// Filter condition based on an embedded object. -class ObjectFilter extends FilterOperation { - /// Create a filter condition based on an embedded object. - const ObjectFilter({ - required this.property, - required this.filter, - }) : super._(); - - /// Property containing the embedded object(s). - final String property; - - /// Filter condition that should be applied - final FilterOperation filter; -} - -/// Filter condition based on a link. -class LinkFilter extends FilterOperation { - /// Create a filter condition based on a link. - const LinkFilter({ - required this.linkName, - required FilterOperation this.filter, - }) : lower = null, - upper = null, - super._(); - - /// Create a filter condition based on the number of linked objects. - const LinkFilter.length({ - required this.linkName, - required int this.lower, - required int this.upper, - }) : filter = null, - assert(lower >= 0 && upper >= 0, 'Link length must be positive.'), - super._(); - - /// Isar name of the link. - final String linkName; - - /// Filter condition that should be applied - final FilterOperation? filter; - - /// The minumum number of linked objects - final int? lower; - - /// The maximum number of linked objects - final int? upper; -} diff --git a/packages_external/isar-3.1.0-1/packages/isar/lib/src/schema/collection_schema.dart b/packages_external/isar-3.1.0-1/packages/isar/lib/src/schema/collection_schema.dart deleted file mode 100644 index 24d280a1..00000000 --- a/packages_external/isar-3.1.0-1/packages/isar/lib/src/schema/collection_schema.dart +++ /dev/null @@ -1,152 +0,0 @@ -part of isar; - -/// This schema represents a collection. -class CollectionSchema extends Schema { - /// @nodoc - @protected - const CollectionSchema({ - required super.id, - required super.name, - required super.properties, - required super.estimateSize, - required super.serialize, - required super.deserialize, - required super.deserializeProp, - required this.idName, - required this.indexes, - required this.links, - required this.embeddedSchemas, - required this.getId, - required this.getLinks, - required this.attach, - required this.version, - }) : assert( - Isar.version == version, - 'Outdated generated code. Please re-run code ' - 'generation using the latest generator.', - ); - - /// @nodoc - @protected - factory CollectionSchema.fromJson(Map json) { - final collection = Schema.fromJson(json); - return CollectionSchema( - id: collection.id, - name: collection.name, - properties: collection.properties, - idName: json['idName'] as String, - indexes: { - for (final index in json['indexes'] as List) - (index as Map)['name'] as String: - IndexSchema.fromJson(index), - }, - links: { - for (final link in json['links'] as List) - (link as Map)['name'] as String: - LinkSchema.fromJson(link), - }, - embeddedSchemas: { - for (final schema in json['embeddedSchemas'] as List) - (schema as Map)['name'] as String: - Schema.fromJson(schema), - }, - estimateSize: (_, __, ___) => throw UnimplementedError(), - serialize: (_, __, ___, ____) => throw UnimplementedError(), - deserialize: (_, __, ___, ____) => throw UnimplementedError(), - deserializeProp: (_, __, ___, ____) => throw UnimplementedError(), - getId: (_) => throw UnimplementedError(), - getLinks: (_) => throw UnimplementedError(), - attach: (_, __, ___) => throw UnimplementedError(), - version: Isar.version, - ); - } - - /// Name of the id property - final String idName; - - @override - bool get embedded => false; - - /// A map of name -> index pairs - final Map indexes; - - /// A map of name -> link pairs - final Map links; - - /// A map of name -> embedded schema pairs - final Map> embeddedSchemas; - - /// @nodoc - final GetId getId; - - /// @nodoc - final GetLinks getLinks; - - /// @nodoc - final Attach attach; - - /// @nodoc - final String version; - - /// @nodoc - void toCollection(void Function() callback) => callback(); - - /// @nodoc - @pragma('vm:prefer-inline') - IndexSchema index(String indexName) { - final index = indexes[indexName]; - if (index != null) { - return index; - } else { - throw IsarError('Unknown index "$indexName"'); - } - } - - /// @nodoc - @pragma('vm:prefer-inline') - LinkSchema link(String linkName) { - final link = links[linkName]; - if (link != null) { - return link; - } else { - throw IsarError('Unknown link "$linkName"'); - } - } - - /// @nodoc - @protected - @override - Map toJson() { - final json = { - ...super.toJson(), - 'idName': idName, - 'indexes': [ - for (final index in indexes.values) index.toJson(), - ], - 'links': [ - for (final link in links.values) link.toJson(), - ], - }; - - assert(() { - json['embeddedSchemas'] = [ - for (final schema in embeddedSchemas.values) schema.toJson(), - ]; - return true; - }()); - - return json; - } -} - -/// @nodoc -@protected -typedef GetId = Id Function(T object); - -/// @nodoc -@protected -typedef GetLinks = List> Function(T object); - -/// @nodoc -@protected -typedef Attach = void Function(IsarCollection col, Id id, T object); diff --git a/packages_external/isar-3.1.0-1/packages/isar/lib/src/schema/index_schema.dart b/packages_external/isar-3.1.0-1/packages/isar/lib/src/schema/index_schema.dart deleted file mode 100644 index d8ceb8b9..00000000 --- a/packages_external/isar-3.1.0-1/packages/isar/lib/src/schema/index_schema.dart +++ /dev/null @@ -1,104 +0,0 @@ -part of isar; - -/// This schema represents an index. -class IndexSchema { - /// @nodoc - @protected - const IndexSchema({ - required this.id, - required this.name, - required this.unique, - required this.replace, - required this.properties, - }); - - /// @nodoc - @protected - factory IndexSchema.fromJson(Map json) { - return IndexSchema( - id: -1, - name: json['name'] as String, - unique: json['unique'] as bool, - replace: json['replace'] as bool, - properties: (json['properties'] as List) - .map((e) => IndexPropertySchema.fromJson(e as Map)) - .toList(), - ); - } - - /// Internal id of this index. - final int id; - - /// Name of this index. - final String name; - - /// Whether duplicates are disallowed in this index. - final bool unique; - - /// Whether duplocates will be replaced or throw an error. - final bool replace; - - /// Composite properties. - final List properties; - - /// @nodoc - @protected - Map toJson() { - final json = { - 'name': name, - 'unique': unique, - 'replace': replace, - 'properties': [ - for (final property in properties) property.toJson(), - ], - }; - - return json; - } -} - -/// This schema represents a composite index property. -class IndexPropertySchema { - /// @nodoc - @protected - const IndexPropertySchema({ - required this.name, - required this.type, - required this.caseSensitive, - }); - - /// @nodoc - @protected - factory IndexPropertySchema.fromJson(Map json) { - return IndexPropertySchema( - name: json['name'] as String, - type: IndexType.values.firstWhere((e) => _typeName[e] == json['type']), - caseSensitive: json['caseSensitive'] as bool, - ); - } - - /// Isar name of the property. - final String name; - - /// Type of index. - final IndexType type; - - /// Whether String properties should be stored with casing. - final bool caseSensitive; - - /// @nodoc - @protected - Map toJson() { - return { - 'name': name, - 'type': _typeName[type], - 'caseSensitive': caseSensitive, - }; - } - - static const _typeName = { - IndexType.value: 'Value', - IndexType.hash: 'Hash', - IndexType.hashElements: 'HashElements', - }; -} diff --git a/packages_external/isar-3.1.0-1/packages/isar/lib/src/schema/link_schema.dart b/packages_external/isar-3.1.0-1/packages/isar/lib/src/schema/link_schema.dart deleted file mode 100644 index 046ed645..00000000 --- a/packages_external/isar-3.1.0-1/packages/isar/lib/src/schema/link_schema.dart +++ /dev/null @@ -1,64 +0,0 @@ -part of isar; - -/// This schema represents a link to the same or another collection. -class LinkSchema { - /// @nodoc - @protected - const LinkSchema({ - required this.id, - required this.name, - required this.target, - required this.single, - this.linkName, - }); - - /// @nodoc - @protected - factory LinkSchema.fromJson(Map json) { - return LinkSchema( - id: -1, - name: json['name'] as String, - target: json['target'] as String, - single: json['single'] as bool, - linkName: json['linkName'] as String?, - ); - } - - /// Internal id of this link. - final int id; - - /// Name of this link. - final String name; - - /// Isar name of the target collection. - final String target; - - /// Whether this is link can only hold a single target object. - final bool single; - - /// If this is a backlink, [linkName] is the name of the source link in the - /// [target] collection. - final String? linkName; - - /// Whether this link is a backlink. - bool get isBacklink => linkName != null; - - /// @nodoc - @protected - Map toJson() { - final json = { - 'name': name, - 'target': target, - 'single': single, - }; - - assert(() { - if (linkName != null) { - json['linkName'] = linkName; - } - return true; - }()); - - return json; - } -} diff --git a/packages_external/isar-3.1.0-1/packages/isar/lib/src/schema/property_schema.dart b/packages_external/isar-3.1.0-1/packages/isar/lib/src/schema/property_schema.dart deleted file mode 100644 index 9f34c13b..00000000 --- a/packages_external/isar-3.1.0-1/packages/isar/lib/src/schema/property_schema.dart +++ /dev/null @@ -1,183 +0,0 @@ -part of isar; - -/// A single propery of a collection or embedded object. -class PropertySchema { - /// @nodoc - @protected - const PropertySchema({ - required this.id, - required this.name, - required this.type, - this.enumMap, - this.target, - }); - - /// @nodoc - @protected - factory PropertySchema.fromJson(Map json) { - return PropertySchema( - id: -1, - name: json['name'] as String, - type: IsarType.values.firstWhere((e) => e.schemaName == json['type']), - enumMap: json['enumMap'] as Map?, - target: json['target'] as String?, - ); - } - - /// Internal id of this property. - final int id; - - /// Name of the property - final String name; - - /// Isar type of the property - final IsarType type; - - /// Maps enum names to database values - final Map? enumMap; - - /// For embedded objects: Name of the target schema - final String? target; - - /// @nodoc - @protected - Map toJson() { - final json = { - 'name': name, - 'type': type.schemaName, - if (target != null) 'target': target, - }; - - assert(() { - if (enumMap != null) { - json['enumMap'] = enumMap; - } - return true; - }()); - - return json; - } -} - -/// Supported Isar types -enum IsarType { - /// Boolean - bool('Bool'), - - /// 8-bit unsigned integer - byte('Byte'), - - /// 32-bit singed integer - int('Int'), - - /// 32-bit float - float('Float'), - - /// 64-bit singed integer - long('Long'), - - /// 64-bit float - double('Double'), - - /// DateTime - dateTime('DateTime'), - - /// String - string('String'), - - /// Embedded object - object('Object'), - - /// Boolean list - boolList('BoolList'), - - /// 8-bit unsigned integer list - byteList('ByteList'), - - /// 32-bit singed integer list - intList('IntList'), - - /// 32-bit float list - floatList('FloatList'), - - /// 64-bit singed integer list - longList('LongList'), - - /// 64-bit float list - doubleList('DoubleList'), - - /// DateTime list - dateTimeList('DateTimeList'), - - /// String list - stringList('StringList'), - - /// Embedded object list - objectList('ObjectList'); - - /// @nodoc - const IsarType(this.schemaName); - - /// @nodoc - final String schemaName; -} - -/// @nodoc -extension IsarTypeX on IsarType { - /// Whether this type represents a list - bool get isList => index >= IsarType.boolList.index; - - /// @nodoc - IsarType get scalarType { - switch (this) { - case IsarType.boolList: - return IsarType.bool; - case IsarType.byteList: - return IsarType.byte; - case IsarType.intList: - return IsarType.int; - case IsarType.floatList: - return IsarType.float; - case IsarType.longList: - return IsarType.long; - case IsarType.doubleList: - return IsarType.double; - case IsarType.dateTimeList: - return IsarType.dateTime; - case IsarType.stringList: - return IsarType.string; - case IsarType.objectList: - return IsarType.object; - // ignore: no_default_cases - default: - return this; - } - } - - /// @nodoc - IsarType get listType { - switch (this) { - case IsarType.bool: - return IsarType.boolList; - case IsarType.byte: - return IsarType.byteList; - case IsarType.int: - return IsarType.intList; - case IsarType.float: - return IsarType.floatList; - case IsarType.long: - return IsarType.longList; - case IsarType.double: - return IsarType.doubleList; - case IsarType.dateTime: - return IsarType.dateTimeList; - case IsarType.string: - return IsarType.stringList; - case IsarType.object: - return IsarType.objectList; - // ignore: no_default_cases - default: - return this; - } - } -} diff --git a/packages_external/isar-3.1.0-1/packages/isar/lib/src/schema/schema.dart b/packages_external/isar-3.1.0-1/packages/isar/lib/src/schema/schema.dart deleted file mode 100644 index 8cdf73a8..00000000 --- a/packages_external/isar-3.1.0-1/packages/isar/lib/src/schema/schema.dart +++ /dev/null @@ -1,126 +0,0 @@ -part of isar; - -/// This schema either represents a collection or embedded object. -class Schema { - /// @nodoc - @protected - const Schema({ - required this.id, - required this.name, - required this.properties, - required this.estimateSize, - required this.serialize, - required this.deserialize, - required this.deserializeProp, - }); - - /// @nodoc - @protected - factory Schema.fromJson(Map json) { - return Schema( - id: -1, - name: json['name'] as String, - properties: { - for (final property in json['properties'] as List) - (property as Map)['name'] as String: - PropertySchema.fromJson(property), - }, - estimateSize: (_, __, ___) => throw UnimplementedError(), - serialize: (_, __, ___, ____) => throw UnimplementedError(), - deserialize: (_, __, ___, ____) => throw UnimplementedError(), - deserializeProp: (_, __, ___, ____) => throw UnimplementedError(), - ); - } - - /// Internal id of this collection or embedded object. - final int id; - - /// Name of the collection or embedded object - final String name; - - /// Whether this is an embedded object - bool get embedded => true; - - /// A map of name -> property pairs - final Map properties; - - /// @nodoc - @protected - final EstimateSize estimateSize; - - /// @nodoc - @protected - final Serialize serialize; - - /// @nodoc - @protected - final Deserialize deserialize; - - /// @nodoc - @protected - final DeserializeProp deserializeProp; - - /// Returns a property by its name or throws an error. - @pragma('vm:prefer-inline') - PropertySchema property(String propertyName) { - final property = properties[propertyName]; - if (property != null) { - return property; - } else { - throw IsarError('Unknown property "$propertyName"'); - } - } - - /// @nodoc - @protected - Map toJson() { - final json = { - 'name': name, - 'embedded': embedded, - 'properties': [ - for (final property in properties.values) property.toJson(), - ], - }; - - return json; - } - - /// @nodoc - @protected - Type get type => OBJ; -} - -/// @nodoc -@protected -typedef EstimateSize = int Function( - T object, - List offsets, - Map> allOffsets, -); - -/// @nodoc -@protected -typedef Serialize = void Function( - T object, - IsarWriter writer, - List offsets, - Map> allOffsets, -); - -/// @nodoc -@protected -typedef Deserialize = T Function( - Id id, - IsarReader reader, - List offsets, - Map> allOffsets, -); - -/// @nodoc -@protected -typedef DeserializeProp = dynamic Function( - IsarReader reader, - int propertyId, - int offset, - Map> allOffsets, -); diff --git a/packages_external/isar-3.1.0-1/packages/isar/lib/src/web/bindings.dart b/packages_external/isar-3.1.0-1/packages/isar/lib/src/web/bindings.dart deleted file mode 100644 index d4a1b76b..00000000 --- a/packages_external/isar-3.1.0-1/packages/isar/lib/src/web/bindings.dart +++ /dev/null @@ -1,188 +0,0 @@ -// ignore_for_file: public_member_api_docs - -import 'dart:indexed_db'; -import 'dart:js'; - -import 'package:isar/isar.dart'; -import 'package:js/js.dart'; -import 'package:js/js_util.dart'; - -@JS('JSON.stringify') -external String stringify(dynamic value); - -@JS('indexedDB.cmp') -external int idbCmp(dynamic value1, dynamic value2); - -@JS('Object.keys') -external List objectKeys(dynamic obj); - -Map jsMapToDart(Object obj) { - final keys = objectKeys(obj); - final map = {}; - for (final key in keys) { - map[key] = getProperty(obj, key); - } - return map; -} - -@JS('Promise') -class Promise {} - -extension PromiseX on Promise { - Future wait() => promiseToFuture(this); -} - -@JS('openIsar') -external Promise openIsarJs( - String name, - List schemas, - bool relaxedDurability, -); - -@JS('IsarTxn') -class IsarTxnJs { - external Promise commit(); - - external void abort(); - - external bool get write; -} - -@JS('IsarInstance') -class IsarInstanceJs { - external IsarTxnJs beginTxn(bool write); - - external IsarCollectionJs getCollection(String name); - - external Promise close(bool deleteFromDisk); -} - -typedef ChangeCallbackJs = void Function(); - -typedef ObjectChangeCallbackJs = void Function(Object? object); - -typedef QueryChangeCallbackJs = void Function(List results); - -typedef StopWatchingJs = JsFunction; - -@JS('IsarCollection') -class IsarCollectionJs { - external IsarLinkJs getLink(String name); - - external Promise getAll(IsarTxnJs txn, List ids); - - external Promise getAllByIndex( - IsarTxnJs txn, - String indexName, - List> values, - ); - - external Promise putAll(IsarTxnJs txn, List objects); - - external Promise deleteAll(IsarTxnJs txn, List ids); - - external Promise deleteAllByIndex( - IsarTxnJs txn, - String indexName, - List keys, - ); - - external Promise clear(IsarTxnJs txn); - - external StopWatchingJs watchLazy(ChangeCallbackJs callback); - - external StopWatchingJs watchObject(Id id, ObjectChangeCallbackJs callback); - - external StopWatchingJs watchQuery( - QueryJs query, - QueryChangeCallbackJs callback, - ); - - external StopWatchingJs watchQueryLazy( - QueryJs query, - ChangeCallbackJs callback, - ); -} - -@JS('IsarLink') -class IsarLinkJs { - external Promise update( - IsarTxnJs txn, - bool backlink, - Id id, - List addedTargets, - List deletedTargets, - ); - - external Promise clear(IsarTxnJs txn, Id id, bool backlink); -} - -@JS('IdWhereClause') -@anonymous -class IdWhereClauseJs { - external KeyRange? range; -} - -@JS('IndexWhereClause') -@anonymous -class IndexWhereClauseJs { - external String indexName; - external KeyRange? range; -} - -@JS('LinkWhereClause') -@anonymous -class LinkWhereClauseJs { - external String linkCollection; - external String linkName; - external bool backlink; - external Id id; -} - -@JS('Function') -class FilterJs { - external FilterJs(String id, String obj, String method); -} - -@JS('Function') -class SortCmpJs { - external SortCmpJs(String a, String b, String method); -} - -@JS('Function') -class DistinctValueJs { - external DistinctValueJs(String obj, String method); -} - -@JS('IsarQuery') -class QueryJs { - external QueryJs( - IsarCollectionJs collection, - List whereClauses, - bool whereDistinct, - bool whereAscending, - FilterJs? filter, - SortCmpJs? sortCmp, - DistinctValueJs? distinctValue, - int? offset, - int? limit, - ); - - external Promise findFirst(IsarTxnJs txn); - - external Promise findAll(IsarTxnJs txn); - - external Promise deleteFirst(IsarTxnJs txn); - - external Promise deleteAll(IsarTxnJs txn); - - external Promise min(IsarTxnJs txn, String propertyName); - - external Promise max(IsarTxnJs txn, String propertyName); - - external Promise sum(IsarTxnJs txn, String propertyName); - - external Promise average(IsarTxnJs txn, String propertyName); - - external Promise count(IsarTxnJs txn); -} diff --git a/packages_external/isar-3.1.0-1/packages/isar/lib/src/web/isar_collection_impl.dart b/packages_external/isar-3.1.0-1/packages/isar/lib/src/web/isar_collection_impl.dart deleted file mode 100644 index d89ad693..00000000 --- a/packages_external/isar-3.1.0-1/packages/isar/lib/src/web/isar_collection_impl.dart +++ /dev/null @@ -1,266 +0,0 @@ -// ignore_for_file: public_member_api_docs, invalid_use_of_protected_member - -import 'dart:async'; -import 'dart:convert'; -import 'dart:js'; -import 'dart:js_util'; -import 'dart:typed_data'; - -import 'package:isar/isar.dart'; -import 'package:isar/src/web/bindings.dart'; -import 'package:isar/src/web/isar_impl.dart'; -import 'package:isar/src/web/isar_reader_impl.dart'; -import 'package:isar/src/web/isar_web.dart'; -import 'package:isar/src/web/isar_writer_impl.dart'; -import 'package:isar/src/web/query_build.dart'; -import 'package:meta/dart2js.dart'; - -class IsarCollectionImpl extends IsarCollection { - IsarCollectionImpl({ - required this.isar, - required this.native, - required this.schema, - }); - - @override - final IsarImpl isar; - final IsarCollectionJs native; - - @override - final CollectionSchema schema; - - @override - String get name => schema.name; - - late final _offsets = isar.offsets[OBJ]!; - - @tryInline - OBJ deserializeObject(Object object) { - final id = getProperty(object, idName); - final reader = IsarReaderImpl(object); - return schema.deserialize(id, reader, _offsets, isar.offsets); - } - - @tryInline - List deserializeObjects(dynamic objects) { - final list = objects as List; - final results = []; - for (final object in list) { - results.add(object is Object ? deserializeObject(object) : null); - } - return results; - } - - @override - Future> getAll(List ids) { - return isar.getTxn(false, (IsarTxnJs txn) async { - final objects = await native.getAll(txn, ids).wait>(); - return deserializeObjects(objects); - }); - } - - @override - Future> getAllByIndex(String indexName, List keys) { - return isar.getTxn(false, (IsarTxnJs txn) async { - final objects = await native - .getAllByIndex(txn, indexName, keys) - .wait>(); - return deserializeObjects(objects); - }); - } - - @override - List getAllSync(List ids) => unsupportedOnWeb(); - - @override - List getAllByIndexSync(String indexName, List keys) => - unsupportedOnWeb(); - - @override - Future> putAll(List objects) { - return putAllByIndex(null, objects); - } - - @override - List putAllSync(List objects, {bool saveLinks = true}) => - unsupportedOnWeb(); - - @override - Future> putAllByIndex(String? indexName, List objects) { - return isar.getTxn(true, (IsarTxnJs txn) async { - final serialized = []; - for (final object in objects) { - final jsObj = newObject(); - final writer = IsarWriterImpl(jsObj); - schema.serialize(object, writer, _offsets, isar.offsets); - setProperty(jsObj, idName, schema.getId(object)); - serialized.add(jsObj); - } - final ids = await native.putAll(txn, serialized).wait>(); - for (var i = 0; i < objects.length; i++) { - final object = objects[i]; - final id = ids[i] as Id; - schema.attach(this, id, object); - } - - return ids.cast().toList(); - }); - } - - @override - List putAllByIndexSync( - String indexName, - List objects, { - bool saveLinks = true, - }) => - unsupportedOnWeb(); - - @override - Future deleteAll(List ids) async { - await isar.getTxn(true, (IsarTxnJs txn) { - return native.deleteAll(txn, ids).wait(); - }); - return ids.length; - } - - @override - Future deleteAllByIndex(String indexName, List keys) { - return isar.getTxn(true, (IsarTxnJs txn) { - return native.deleteAllByIndex(txn, indexName, keys).wait(); - }); - } - - @override - int deleteAllSync(List ids) => unsupportedOnWeb(); - - @override - int deleteAllByIndexSync(String indexName, List keys) => - unsupportedOnWeb(); - - @override - Future clear() { - return isar.getTxn(true, (IsarTxnJs txn) { - return native.clear(txn).wait(); - }); - } - - @override - void clearSync() => unsupportedOnWeb(); - - @override - Future importJson(List> json) { - return isar.getTxn(true, (IsarTxnJs txn) async { - await native.putAll(txn, json.map(jsify).toList()).wait(); - }); - } - - @override - Future importJsonRaw(Uint8List jsonBytes) { - final json = jsonDecode(const Utf8Decoder().convert(jsonBytes)) as List; - return importJson(json.cast()); - } - - @override - void importJsonSync(List> json) => unsupportedOnWeb(); - - @override - void importJsonRawSync(Uint8List jsonBytes) => unsupportedOnWeb(); - - @override - Future count() => where().count(); - - @override - int countSync() => unsupportedOnWeb(); - - @override - Future getSize({ - bool includeIndexes = false, - bool includeLinks = false, - }) => - unsupportedOnWeb(); - - @override - int getSizeSync({ - bool includeIndexes = false, - bool includeLinks = false, - }) => - unsupportedOnWeb(); - - @override - Stream watchLazy({bool fireImmediately = false}) { - JsFunction? stop; - final controller = StreamController( - onCancel: () { - stop?.apply([]); - }, - ); - - final void Function() callback = allowInterop(() => controller.add(null)); - stop = native.watchLazy(callback); - - return controller.stream; - } - - @override - Stream watchObject( - Id id, { - bool fireImmediately = false, - bool deserialize = true, - }) { - JsFunction? stop; - final controller = StreamController( - onCancel: () { - stop?.apply([]); - }, - ); - - final Null Function(Object? obj) callback = allowInterop((Object? obj) { - final object = deserialize && obj != null ? deserializeObject(obj) : null; - controller.add(object); - }); - stop = native.watchObject(id, callback); - - return controller.stream; - } - - @override - Stream watchObjectLazy(Id id, {bool fireImmediately = false}) => - watchObject(id, deserialize: false); - - @override - Query buildQuery({ - List whereClauses = const [], - bool whereDistinct = false, - Sort whereSort = Sort.asc, - FilterOperation? filter, - List sortBy = const [], - List distinctBy = const [], - int? offset, - int? limit, - String? property, - }) { - return buildWebQuery( - this, - whereClauses, - whereDistinct, - whereSort, - filter, - sortBy, - distinctBy, - offset, - limit, - property, - ); - } - - @override - Future verify(List objects) => unsupportedOnWeb(); - - @override - Future verifyLink( - String linkName, - List sourceIds, - List targetIds, - ) => - unsupportedOnWeb(); -} diff --git a/packages_external/isar-3.1.0-1/packages/isar/lib/src/web/isar_impl.dart b/packages_external/isar-3.1.0-1/packages/isar/lib/src/web/isar_impl.dart deleted file mode 100644 index 5c0efb41..00000000 --- a/packages_external/isar-3.1.0-1/packages/isar/lib/src/web/isar_impl.dart +++ /dev/null @@ -1,135 +0,0 @@ -// ignore_for_file: public_member_api_docs - -import 'dart:async'; -import 'dart:html'; - -import 'package:isar/isar.dart'; - -import 'package:isar/src/web/bindings.dart'; -import 'package:isar/src/web/isar_web.dart'; - -const Symbol _zoneTxn = #zoneTxn; - -class IsarImpl extends Isar { - IsarImpl(super.name, this.instance); - - final IsarInstanceJs instance; - final offsets = >{}; - final List> _activeAsyncTxns = []; - - @override - final String? directory = null; - - void requireNotInTxn() { - if (Zone.current[_zoneTxn] != null) { - throw IsarError( - 'Cannot perform this operation from within an active transaction.', - ); - } - } - - Future _txn( - bool write, - bool silent, - Future Function() callback, - ) async { - requireOpen(); - requireNotInTxn(); - - final completer = Completer(); - _activeAsyncTxns.add(completer.future); - - final txn = instance.beginTxn(write); - - final zone = Zone.current.fork( - zoneValues: {_zoneTxn: txn}, - ); - - T result; - try { - result = await zone.run(callback); - await txn.commit().wait(); - } catch (e) { - txn.abort(); - if (e is DomException) { - if (e.name == DomException.CONSTRAINT) { - throw IsarUniqueViolationError(); - } else { - throw IsarError('${e.name}: ${e.message}'); - } - } else { - rethrow; - } - } finally { - completer.complete(); - _activeAsyncTxns.remove(completer.future); - } - - return result; - } - - @override - Future txn(Future Function() callback) { - return _txn(false, false, callback); - } - - @override - Future writeTxn(Future Function() callback, {bool silent = false}) { - return _txn(true, silent, callback); - } - - @override - T txnSync(T Function() callback) => unsupportedOnWeb(); - - @override - T writeTxnSync(T Function() callback, {bool silent = false}) => - unsupportedOnWeb(); - - Future getTxn(bool write, Future Function(IsarTxnJs txn) callback) { - final currentTxn = Zone.current[_zoneTxn] as IsarTxnJs?; - if (currentTxn != null) { - if (write && !currentTxn.write) { - throw IsarError( - 'Operation cannot be performed within a read transaction.', - ); - } - return callback(currentTxn); - } else if (!write) { - return _txn(false, false, () { - return callback(Zone.current[_zoneTxn] as IsarTxnJs); - }); - } else { - throw IsarError('Write operations require an explicit transaction.'); - } - } - - @override - Future getSize({ - bool includeIndexes = false, - bool includeLinks = false, - }) => - unsupportedOnWeb(); - - @override - int getSizeSync({ - bool includeIndexes = false, - bool includeLinks = false, - }) => - unsupportedOnWeb(); - - @override - Future copyToFile(String targetPath) => unsupportedOnWeb(); - - @override - Future close({bool deleteFromDisk = false}) async { - requireOpen(); - requireNotInTxn(); - await Future.wait(_activeAsyncTxns); - await super.close(); - await instance.close(deleteFromDisk).wait(); - return true; - } - - @override - Future verify() => unsupportedOnWeb(); -} diff --git a/packages_external/isar-3.1.0-1/packages/isar/lib/src/web/isar_link_impl.dart b/packages_external/isar-3.1.0-1/packages/isar/lib/src/web/isar_link_impl.dart deleted file mode 100644 index 6efa9c15..00000000 --- a/packages_external/isar-3.1.0-1/packages/isar/lib/src/web/isar_link_impl.dart +++ /dev/null @@ -1,75 +0,0 @@ -// ignore_for_file: public_member_api_docs - -import 'package:isar/isar.dart'; -import 'package:isar/src/common/isar_link_base_impl.dart'; -import 'package:isar/src/common/isar_link_common.dart'; -import 'package:isar/src/common/isar_links_common.dart'; -import 'package:isar/src/web/bindings.dart'; -import 'package:isar/src/web/isar_collection_impl.dart'; -import 'package:isar/src/web/isar_web.dart'; - -mixin IsarLinkBaseMixin on IsarLinkBaseImpl { - @override - IsarCollectionImpl get sourceCollection => - super.sourceCollection as IsarCollectionImpl; - - @override - IsarCollectionImpl get targetCollection => - super.targetCollection as IsarCollectionImpl; - - @override - late final Id Function(OBJ) getId = targetCollection.schema.getId; - - late final String? backlinkLinkName = - sourceCollection.schema.link(linkName).linkName; - - late final IsarLinkJs jsLink = backlinkLinkName != null - ? targetCollection.native.getLink(backlinkLinkName!) - : sourceCollection.native.getLink(linkName); - - @override - Future update({ - Iterable link = const [], - Iterable unlink = const [], - bool reset = false, - }) { - final linkList = link.toList(); - final unlinkList = unlink.toList(); - - final containingId = requireAttached(); - final backlink = backlinkLinkName != null; - - final linkIds = List.filled(linkList.length, 0); - for (var i = 0; i < linkList.length; i++) { - linkIds[i] = requireGetId(linkList[i]); - } - - final unlinkIds = List.filled(unlinkList.length, 0); - for (var i = 0; i < unlinkList.length; i++) { - unlinkIds[i] = requireGetId(unlinkList[i]); - } - - return targetCollection.isar.getTxn(true, (IsarTxnJs txn) async { - if (reset) { - await jsLink.clear(txn, containingId, backlink).wait(); - } - return jsLink - .update(txn, backlink, containingId, linkIds, unlinkIds) - .wait(); - }); - } - - @override - void updateSync({ - Iterable link = const [], - Iterable unlink = const [], - bool reset = false, - }) => - unsupportedOnWeb(); -} - -class IsarLinkImpl extends IsarLinkCommon - with IsarLinkBaseMixin {} - -class IsarLinksImpl extends IsarLinksCommon - with IsarLinkBaseMixin {} diff --git a/packages_external/isar-3.1.0-1/packages/isar/lib/src/web/isar_reader_impl.dart b/packages_external/isar-3.1.0-1/packages/isar/lib/src/web/isar_reader_impl.dart deleted file mode 100644 index fac7e8b4..00000000 --- a/packages_external/isar-3.1.0-1/packages/isar/lib/src/web/isar_reader_impl.dart +++ /dev/null @@ -1,347 +0,0 @@ -// ignore_for_file: public_member_api_docs - -import 'package:isar/isar.dart'; -import 'package:js/js_util.dart'; -import 'package:meta/dart2js.dart'; - -const nullNumber = double.negativeInfinity; -const idName = '_id'; -final nullDate = DateTime.fromMillisecondsSinceEpoch(0); - -class IsarReaderImpl implements IsarReader { - IsarReaderImpl(this.object); - - final Object object; - - @tryInline - @override - bool readBool(int offset) { - final value = getProperty(object, offset); - return value == 1; - } - - @tryInline - @override - bool? readBoolOrNull(int offset) { - final value = getProperty(object, offset); - return value == 0 - ? false - : value == 1 - ? true - : null; - } - - @tryInline - @override - int readByte(int offset) { - final value = getProperty(object, offset); - return value is int ? value : nullNumber as int; - } - - @tryInline - @override - int? readByteOrNull(int offset) { - final value = getProperty(object, offset); - return value is int && value != nullNumber ? value : null; - } - - @tryInline - @override - int readInt(int offset) { - final value = getProperty(object, offset); - return value is int ? value : nullNumber as int; - } - - @tryInline - @override - int? readIntOrNull(int offset) { - final value = getProperty(object, offset); - return value is int && value != nullNumber ? value : null; - } - - @tryInline - @override - double readFloat(int offset) { - final value = getProperty(object, offset); - return value is double ? value : nullNumber; - } - - @tryInline - @override - double? readFloatOrNull(int offset) { - final value = getProperty(object, offset); - return value is double && value != nullNumber ? value : null; - } - - @tryInline - @override - int readLong(int offset) { - final value = getProperty(object, offset); - return value is int ? value : nullNumber as int; - } - - @tryInline - @override - int? readLongOrNull(int offset) { - final value = getProperty(object, offset); - return value is int && value != nullNumber ? value : null; - } - - @tryInline - @override - double readDouble(int offset) { - final value = getProperty(object, offset); - return value is double && value != nullNumber ? value : nullNumber; - } - - @tryInline - @override - double? readDoubleOrNull(int offset) { - final value = getProperty(object, offset); - return value is double && value != nullNumber ? value : null; - } - - @tryInline - @override - DateTime readDateTime(int offset) { - final value = getProperty(object, offset); - return value is int && value != nullNumber - ? DateTime.fromMillisecondsSinceEpoch(value, isUtc: true).toLocal() - : nullDate; - } - - @tryInline - @override - DateTime? readDateTimeOrNull(int offset) { - final value = getProperty(object, offset); - return value is int && value != nullNumber - ? DateTime.fromMillisecondsSinceEpoch(value, isUtc: true).toLocal() - : null; - } - - @tryInline - @override - String readString(int offset) { - final value = getProperty(object, offset); - return value is String ? value : ''; - } - - @tryInline - @override - String? readStringOrNull(int offset) { - final value = getProperty(object, offset); - return value is String ? value : null; - } - - @tryInline - @override - T? readObjectOrNull( - int offset, - Deserialize deserialize, - Map> allOffsets, - ) { - final value = getProperty(object, offset); - if (value is Object) { - final reader = IsarReaderImpl(value); - return deserialize(0, reader, allOffsets[T]!, allOffsets); - } else { - return null; - } - } - - @tryInline - @override - List? readBoolList(int offset) { - final value = getProperty(object, offset); - return value is List ? value.map((e) => e == 1).toList() : null; - } - - @tryInline - @override - List? readBoolOrNullList(int offset) { - final value = getProperty(object, offset); - return value is List - ? value - .map( - (e) => e == 0 - ? false - : e == 1 - ? true - : null, - ) - .toList() - : null; - } - - @tryInline - @override - List? readByteList(int offset) { - final value = getProperty(object, offset); - return value is List - ? value.map((e) => e is int ? e : nullNumber as int).toList() - : null; - } - - @tryInline - @override - List? readIntList(int offset) { - final value = getProperty(object, offset); - return value is List - ? value.map((e) => e is int ? e : nullNumber as int).toList() - : null; - } - - @tryInline - @override - List? readIntOrNullList(int offset) { - final value = getProperty(object, offset); - return value is List - ? value.map((e) => e is int && e != nullNumber ? e : null).toList() - : null; - } - - @tryInline - @override - List? readFloatList(int offset) { - final value = getProperty(object, offset); - return value is List - ? value.map((e) => e is double ? e : nullNumber).toList() - : null; - } - - @tryInline - @override - List? readFloatOrNullList(int offset) { - final value = getProperty(object, offset); - return value is List - ? value.map((e) => e is double && e != nullNumber ? e : null).toList() - : null; - } - - @tryInline - @override - List? readLongList(int offset) { - final value = getProperty(object, offset); - return value is List - ? value.map((e) => e is int ? e : nullNumber as int).toList() - : null; - } - - @tryInline - @override - List? readLongOrNullList(int offset) { - final value = getProperty(object, offset); - return value is List - ? value.map((e) => e is int && e != nullNumber ? e : null).toList() - : null; - } - - @tryInline - @override - List? readDoubleList(int offset) { - final value = getProperty(object, offset); - return value is List - ? value.map((e) => e is double ? e : nullNumber).toList() - : null; - } - - @tryInline - @override - List? readDoubleOrNullList(int offset) { - final value = getProperty(object, offset); - return value is List - ? value.map((e) => e is double && e != nullNumber ? e : null).toList() - : null; - } - - @tryInline - @override - List? readDateTimeList(int offset) { - final value = getProperty(object, offset); - return value is List - ? value - .map( - (e) => e is int && e != nullNumber - ? DateTime.fromMillisecondsSinceEpoch(e, isUtc: true) - .toLocal() - : nullDate, - ) - .toList() - : null; - } - - @tryInline - @override - List? readDateTimeOrNullList(int offset) { - final value = getProperty(object, offset); - return value is List - ? value - .map( - (e) => e is int && e != nullNumber - ? DateTime.fromMillisecondsSinceEpoch(e, isUtc: true) - .toLocal() - : null, - ) - .toList() - : null; - } - - @tryInline - @override - List? readStringList(int offset) { - final value = getProperty(object, offset); - return value is List - ? value.map((e) => e is String ? e : '').toList() - : null; - } - - @tryInline - @override - List? readStringOrNullList(int offset) { - final value = getProperty(object, offset); - return value is List - ? value.map((e) => e is String ? e : null).toList() - : null; - } - - @tryInline - @override - List? readObjectList( - int offset, - Deserialize deserialize, - Map> allOffsets, - T defaultValue, - ) { - final value = getProperty(object, offset); - return value is List - ? value.map((e) { - if (e is Object) { - final reader = IsarReaderImpl(e); - return deserialize(0, reader, allOffsets[T]!, allOffsets); - } else { - return defaultValue; - } - }).toList() - : null; - } - - @tryInline - @override - List? readObjectOrNullList( - int offset, - Deserialize deserialize, - Map> allOffsets, - ) { - final value = getProperty(object, offset); - return value is List - ? value.map((e) { - if (e is Object) { - final reader = IsarReaderImpl(e); - return deserialize(0, reader, allOffsets[T]!, allOffsets); - } else { - return null; - } - }).toList() - : null; - } -} diff --git a/packages_external/isar-3.1.0-1/packages/isar/lib/src/web/isar_web.dart b/packages_external/isar-3.1.0-1/packages/isar/lib/src/web/isar_web.dart deleted file mode 100644 index 0cff278b..00000000 --- a/packages_external/isar-3.1.0-1/packages/isar/lib/src/web/isar_web.dart +++ /dev/null @@ -1,48 +0,0 @@ -// ignore_for_file: unused_field, public_member_api_docs - -import 'dart:async'; - -import 'package:isar/isar.dart'; -import 'package:meta/meta.dart'; - -/// @nodoc -@protected -const Id isarMinId = -9007199254740990; - -/// @nodoc -@protected -const Id isarMaxId = 9007199254740991; - -/// @nodoc -@protected -const Id isarAutoIncrementId = -9007199254740991; - -/// @nodoc -Never unsupportedOnWeb() { - throw UnsupportedError('This operation is not supported for Isar web'); -} - -class _WebAbi { - static const androidArm = null as dynamic; - static const androidArm64 = null as dynamic; - static const androidIA32 = null as dynamic; - static const androidX64 = null as dynamic; - static const iosArm64 = null as dynamic; - static const iosX64 = null as dynamic; - static const linuxArm64 = null as dynamic; - static const linuxX64 = null as dynamic; - static const macosArm64 = null as dynamic; - static const macosX64 = null as dynamic; - static const windowsArm64 = null as dynamic; - static const windowsX64 = null as dynamic; -} - -/// @nodoc -@protected -typedef IsarAbi = _WebAbi; - -FutureOr initializeCoreBinary({ - Map libraries = const {}, - bool download = false, -}) => - unsupportedOnWeb(); diff --git a/packages_external/isar-3.1.0-1/packages/isar/lib/src/web/isar_writer_impl.dart b/packages_external/isar-3.1.0-1/packages/isar/lib/src/web/isar_writer_impl.dart deleted file mode 100644 index a4a65ca0..00000000 --- a/packages_external/isar-3.1.0-1/packages/isar/lib/src/web/isar_writer_impl.dart +++ /dev/null @@ -1,171 +0,0 @@ -// ignore_for_file: public_member_api_docs - -import 'package:isar/isar.dart'; -import 'package:isar/src/web/isar_reader_impl.dart'; -import 'package:js/js_util.dart'; -import 'package:meta/dart2js.dart'; - -class IsarWriterImpl implements IsarWriter { - IsarWriterImpl(this.object); - - final Object object; - - @tryInline - @override - void writeBool(int offset, bool? value) { - final number = value == true - ? 1 - : value == false - ? 0 - : nullNumber; - setProperty(object, offset, number); - } - - @tryInline - @override - void writeByte(int offset, int value) { - setProperty(object, offset, value); - } - - @tryInline - @override - void writeInt(int offset, int? value) { - setProperty(object, offset, value ?? nullNumber); - } - - @tryInline - @override - void writeFloat(int offset, double? value) { - setProperty(object, offset, value ?? nullNumber); - } - - @tryInline - @override - void writeLong(int offset, int? value) { - setProperty(object, offset, value ?? nullNumber); - } - - @tryInline - @override - void writeDouble(int offset, double? value) { - setProperty(object, offset, value ?? nullNumber); - } - - @tryInline - @override - void writeDateTime(int offset, DateTime? value) { - setProperty( - object, - offset, - value?.toUtc().millisecondsSinceEpoch ?? nullNumber, - ); - } - - @tryInline - @override - void writeString(int offset, String? value) { - setProperty(object, offset, value ?? nullNumber); - } - - @tryInline - @override - void writeObject( - int offset, - Map> allOffsets, - Serialize serialize, - T? value, - ) { - if (value != null) { - final object = newObject(); - final writer = IsarWriterImpl(object); - serialize(value, writer, allOffsets[T]!, allOffsets); - setProperty(this.object, offset, object); - } - } - - @tryInline - @override - void writeByteList(int offset, List? values) { - setProperty(object, offset, values ?? nullNumber); - } - - @tryInline - @override - void writeBoolList(int offset, List? values) { - final list = values - ?.map( - (e) => e == false - ? 0 - : e == true - ? 1 - : nullNumber, - ) - .toList(); - setProperty(object, offset, list ?? nullNumber); - } - - @tryInline - @override - void writeIntList(int offset, List? values) { - final list = values?.map((e) => e ?? nullNumber).toList(); - setProperty(object, offset, list ?? nullNumber); - } - - @tryInline - @override - void writeFloatList(int offset, List? values) { - final list = values?.map((e) => e ?? nullNumber).toList(); - setProperty(object, offset, list ?? nullNumber); - } - - @tryInline - @override - void writeLongList(int offset, List? values) { - final list = values?.map((e) => e ?? nullNumber).toList(); - setProperty(object, offset, list ?? nullNumber); - } - - @tryInline - @override - void writeDoubleList(int offset, List? values) { - final list = values?.map((e) => e ?? nullNumber).toList(); - setProperty(object, offset, list ?? nullNumber); - } - - @tryInline - @override - void writeDateTimeList(int offset, List? values) { - final list = values - ?.map((e) => e?.toUtc().millisecondsSinceEpoch ?? nullNumber) - .toList(); - setProperty(object, offset, list ?? nullNumber); - } - - @tryInline - @override - void writeStringList(int offset, List? values) { - final list = values?.map((e) => e ?? nullNumber).toList(); - setProperty(object, offset, list ?? nullNumber); - } - - @tryInline - @override - void writeObjectList( - int offset, - Map> allOffsets, - Serialize serialize, - List? values, - ) { - if (values != null) { - final list = values.map((e) { - if (e != null) { - final object = newObject(); - final writer = IsarWriterImpl(object); - serialize(e, writer, allOffsets[T]!, allOffsets); - return object; - } - }).toList(); - setProperty(object, offset, list); - } - } -} diff --git a/packages_external/isar-3.1.0-1/packages/isar/lib/src/web/open.dart b/packages_external/isar-3.1.0-1/packages/isar/lib/src/web/open.dart deleted file mode 100644 index 3ee4c84e..00000000 --- a/packages_external/isar-3.1.0-1/packages/isar/lib/src/web/open.dart +++ /dev/null @@ -1,82 +0,0 @@ -// ignore_for_file: public_member_api_docs, invalid_use_of_protected_member - -import 'dart:html'; -//import 'dart:js_util'; - -import 'package:isar/isar.dart'; -/*import 'package:isar/src/common/schemas.dart'; - -import 'package:isar/src/web/bindings.dart'; -import 'package:isar/src/web/isar_collection_impl.dart'; -import 'package:isar/src/web/isar_impl.dart';*/ -import 'package:isar/src/web/isar_web.dart'; -import 'package:meta/meta.dart'; - -bool _loaded = false; -Future initializeIsarWeb([String? jsUrl]) async { - if (_loaded) { - return; - } - _loaded = true; - - final script = ScriptElement(); - script.type = 'text/javascript'; - // ignore: unsafe_html - script.src = 'https://unpkg.com/isar@${Isar.version}/dist/index.js'; - script.async = true; - document.head!.append(script); - await script.onLoad.first.timeout( - const Duration(seconds: 30), - onTimeout: () { - throw IsarError('Failed to load Isar'); - }, - ); -} - -@visibleForTesting -void doNotInitializeIsarWeb() { - _loaded = true; -} - -Future openIsar({ - required List> schemas, - required String name, - required int maxSizeMiB, - required bool relaxedDurability, - String? directory, - CompactCondition? compactOnLaunch, -}) async { - throw IsarError('Please use Isar 2.5.0 if you need web support. ' - 'A 3.x version with web support will be released soon.'); - /*await initializeIsarWeb(); - final schemasJson = getSchemas(schemas).map((e) => e.toJson()); - final schemasJs = jsify(schemasJson.toList()) as List; - final instance = await openIsarJs(name, schemasJs, relaxedDurability) - .wait(); - final isar = IsarImpl(name, instance); - final cols = >{}; - for (final schema in schemas) { - final col = instance.getCollection(schema.name); - schema.toCollection(() { - schema as CollectionSchema; - cols[OBJ] = IsarCollectionImpl( - isar: isar, - native: col, - schema: schema, - ); - }); - } - - isar.attachCollections(cols); - return isar;*/ -} - -Isar openIsarSync({ - required List> schemas, - required String name, - required int maxSizeMiB, - required bool relaxedDurability, - String? directory, - CompactCondition? compactOnLaunch, -}) => - unsupportedOnWeb(); diff --git a/packages_external/isar-3.1.0-1/packages/isar/lib/src/web/query_build.dart b/packages_external/isar-3.1.0-1/packages/isar/lib/src/web/query_build.dart deleted file mode 100644 index 12ac2373..00000000 --- a/packages_external/isar-3.1.0-1/packages/isar/lib/src/web/query_build.dart +++ /dev/null @@ -1,375 +0,0 @@ -// ignore_for_file: public_member_api_docs, invalid_use_of_protected_member - -import 'dart:indexed_db'; - -import 'package:isar/isar.dart'; - -import 'package:isar/src/web/bindings.dart'; -import 'package:isar/src/web/isar_collection_impl.dart'; -import 'package:isar/src/web/isar_web.dart'; -import 'package:isar/src/web/query_impl.dart'; - -Query buildWebQuery( - IsarCollectionImpl col, - List whereClauses, - bool whereDistinct, - Sort whereSort, - FilterOperation? filter, - List sortBy, - List distinctBy, - int? offset, - int? limit, - String? property, -) { - final whereClausesJs = whereClauses.map((wc) { - if (wc is IdWhereClause) { - return _buildIdWhereClause(wc); - } else if (wc is IndexWhereClause) { - return _buildIndexWhereClause(col.schema, wc); - } else { - return _buildLinkWhereClause(col, wc as LinkWhereClause); - } - }).toList(); - - final filterJs = filter != null ? _buildFilter(col.schema, filter) : null; - final sortJs = sortBy.isNotEmpty ? _buildSort(sortBy) : null; - final distinctJs = distinctBy.isNotEmpty ? _buildDistinct(distinctBy) : null; - - final queryJs = QueryJs( - col.native, - whereClausesJs, - whereDistinct, - whereSort == Sort.asc, - filterJs, - sortJs, - distinctJs, - offset, - limit, - ); - - QueryDeserialize deserialize; - //if (property == null) { - deserialize = col.deserializeObject as T Function(Object); - /*} else { - deserialize = (jsObj) => col.schema.deserializeProp(jsObj, property) as T; - }*/ - - return QueryImpl(col, queryJs, deserialize, property); -} - -dynamic _valueToJs(dynamic value) { - if (value == null) { - return double.negativeInfinity; - } else if (value == true) { - return 1; - } else if (value == false) { - return 0; - } else if (value is DateTime) { - return value.toUtc().millisecondsSinceEpoch; - } else if (value is List) { - return value.map(_valueToJs).toList(); - } else { - return value; - } -} - -IdWhereClauseJs _buildIdWhereClause(IdWhereClause wc) { - return IdWhereClauseJs() - ..range = _buildKeyRange( - wc.lower, - wc.upper, - wc.includeLower, - wc.includeUpper, - ); -} - -IndexWhereClauseJs _buildIndexWhereClause( - CollectionSchema schema, - IndexWhereClause wc, -) { - final index = schema.index(wc.indexName); - - final lower = wc.lower?.toList(); - final upper = wc.upper?.toList(); - if (upper != null) { - while (index.properties.length > upper.length) { - upper.add([]); - } - } - - dynamic lowerUnwrapped = wc.lower; - if (index.properties.length == 1 && lower != null) { - lowerUnwrapped = lower.isNotEmpty ? lower[0] : null; - } - - dynamic upperUnwrapped = upper; - if (index.properties.length == 1 && upper != null) { - upperUnwrapped = upper.isNotEmpty ? upper[0] : double.infinity; - } - - return IndexWhereClauseJs() - ..indexName = wc.indexName - ..range = _buildKeyRange( - wc.lower != null ? _valueToJs(lowerUnwrapped) : null, - wc.upper != null ? _valueToJs(upperUnwrapped) : null, - wc.includeLower, - wc.includeUpper, - ); -} - -LinkWhereClauseJs _buildLinkWhereClause( - IsarCollectionImpl col, - LinkWhereClause wc, -) { - // ignore: unused_local_variable - final linkCol = col.isar.getCollectionByNameInternal(wc.linkCollection)! - as IsarCollectionImpl; - //final backlinkLinkName = linkCol.schema.backlinkLinkNames[wc.linkName]; - return LinkWhereClauseJs() - ..linkCollection = wc.linkCollection - //..linkName = backlinkLinkName ?? wc.linkName - //..backlink = backlinkLinkName != null - ..id = wc.id; -} - -KeyRange? _buildKeyRange( - dynamic lower, - dynamic upper, - bool includeLower, - bool includeUpper, -) { - if (lower != null) { - if (upper != null) { - final boundsEqual = idbCmp(lower, upper) == 0; - if (boundsEqual) { - if (includeLower && includeUpper) { - return KeyRange.only(lower); - } else { - // empty range - return KeyRange.upperBound(double.negativeInfinity, true); - } - } - - return KeyRange.bound( - lower, - upper, - !includeLower, - !includeUpper, - ); - } else { - return KeyRange.lowerBound(lower, !includeLower); - } - } else if (upper != null) { - return KeyRange.upperBound(upper, !includeUpper); - } - return null; -} - -FilterJs? _buildFilter( - CollectionSchema schema, - FilterOperation filter, -) { - final filterStr = _buildFilterOperation(schema, filter); - if (filterStr != null) { - return FilterJs('id', 'obj', 'return $filterStr'); - } else { - return null; - } -} - -String? _buildFilterOperation( - CollectionSchema schema, - FilterOperation filter, -) { - if (filter is FilterGroup) { - return _buildFilterGroup(schema, filter); - } else if (filter is LinkFilter) { - unsupportedOnWeb(); - } else if (filter is FilterCondition) { - return _buildCondition(schema, filter); - } else { - return null; - } -} - -String? _buildFilterGroup(CollectionSchema schema, FilterGroup group) { - final builtConditions = group.filters - .map((op) => _buildFilterOperation(schema, op)) - .where((e) => e != null) - .toList(); - - if (builtConditions.isEmpty) { - return null; - } - - if (group.type == FilterGroupType.not) { - return '!(${builtConditions[0]})'; - } else if (builtConditions.length == 1) { - return builtConditions[0]; - } else if (group.type == FilterGroupType.xor) { - final conditions = builtConditions.join(','); - return 'IsarQuery.xor($conditions)'; - } else { - final op = group.type == FilterGroupType.or ? '||' : '&&'; - final condition = builtConditions.join(op); - return '($condition)'; - } -} - -String _buildCondition( - CollectionSchema schema, - FilterCondition condition, -) { - dynamic prepareFilterValue(dynamic value) { - if (value == null) { - return null; - } else if (value is String) { - return stringify(value); - } else { - return _valueToJs(value); - } - } - - final isListOp = condition.type != FilterConditionType.isNull && - condition.type != FilterConditionType.listLength && - schema.property(condition.property).type.isList; - final accessor = - condition.property == schema.idName ? 'id' : 'obj.${condition.property}'; - final variable = isListOp ? 'e' : accessor; - - final cond = _buildConditionInternal( - conditionType: condition.type, - variable: variable, - val1: prepareFilterValue(condition.value1), - include1: condition.include1, - val2: prepareFilterValue(condition.value2), - include2: condition.include2, - caseSensitive: condition.caseSensitive, - ); - - if (isListOp) { - return '(Array.isArray($accessor) && $accessor.some(e => $cond))'; - } else { - return cond; - } -} - -String _buildConditionInternal({ - required FilterConditionType conditionType, - required String variable, - required Object? val1, - required bool include1, - required Object? val2, - required bool include2, - required bool caseSensitive, -}) { - final isNull = '($variable == null || $variable === -Infinity)'; - switch (conditionType) { - case FilterConditionType.equalTo: - if (val1 == null) { - return isNull; - } else if (val1 is String && !caseSensitive) { - return '$variable?.toLowerCase() === ${val1.toLowerCase()}'; - } else { - return '$variable === $val1'; - } - case FilterConditionType.between: - final val = val1 ?? val2; - final lowerOp = include1 ? '>=' : '>'; - final upperOp = include2 ? '<=' : '<'; - if (val == null) { - return isNull; - } else if ((val1 is String?) && (val2 is String?) && !caseSensitive) { - final lower = val1?.toLowerCase() ?? '-Infinity'; - final upper = val2?.toLowerCase() ?? '-Infinity'; - final variableLc = '$variable?.toLowerCase() ?? -Infinity'; - final lowerCond = 'indexedDB.cmp($variableLc, $lower) $lowerOp 0'; - final upperCond = 'indexedDB.cmp($variableLc, $upper) $upperOp 0'; - return '($lowerCond && $upperCond)'; - } else { - final lowerCond = - 'indexedDB.cmp($variable, ${val1 ?? '-Infinity'}) $lowerOp 0'; - final upperCond = - 'indexedDB.cmp($variable, ${val2 ?? '-Infinity'}) $upperOp 0'; - return '($lowerCond && $upperCond)'; - } - case FilterConditionType.lessThan: - if (val1 == null) { - if (include1) { - return isNull; - } else { - return 'false'; - } - } else { - final op = include1 ? '<=' : '<'; - if (val1 is String && !caseSensitive) { - return 'indexedDB.cmp($variable?.toLowerCase() ?? ' - '-Infinity, ${val1.toLowerCase()}) $op 0'; - } else { - return 'indexedDB.cmp($variable, $val1) $op 0'; - } - } - case FilterConditionType.greaterThan: - if (val1 == null) { - if (include1) { - return 'true'; - } else { - return '!$isNull'; - } - } else { - final op = include1 ? '>=' : '>'; - if (val1 is String && !caseSensitive) { - return 'indexedDB.cmp($variable?.toLowerCase() ?? ' - '-Infinity, ${val1.toLowerCase()}) $op 0'; - } else { - return 'indexedDB.cmp($variable, $val1) $op 0'; - } - } - case FilterConditionType.startsWith: - case FilterConditionType.endsWith: - case FilterConditionType.contains: - final op = conditionType == FilterConditionType.startsWith - ? 'startsWith' - : conditionType == FilterConditionType.endsWith - ? 'endsWith' - : 'includes'; - if (val1 is String) { - final isString = 'typeof $variable == "string"'; - if (!caseSensitive) { - return '($isString && $variable.toLowerCase() ' - '.$op(${val1.toLowerCase()}))'; - } else { - return '($isString && $variable.$op($val1))'; - } - } else { - throw IsarError('Unsupported type for condition'); - } - case FilterConditionType.matches: - throw UnimplementedError(); - case FilterConditionType.isNull: - return isNull; - // ignore: no_default_cases - default: - throw UnimplementedError(); - } -} - -SortCmpJs _buildSort(List properties) { - final sort = properties.map((e) { - final op = e.sort == Sort.asc ? '' : '-'; - return '${op}indexedDB.cmp(a.${e.property} ?? "-Infinity", b.${e.property} ' - '?? "-Infinity")'; - }).join('||'); - return SortCmpJs('a', 'b', 'return $sort'); -} - -DistinctValueJs _buildDistinct(List properties) { - final distinct = properties.map((e) { - if (e.caseSensitive == false) { - return 'obj.${e.property}?.toLowerCase() ?? "-Infinity"'; - } else { - return 'obj.${e.property}?.toString() ?? "-Infinity"'; - } - }).join('+'); - return DistinctValueJs('obj', 'return $distinct'); -} diff --git a/packages_external/isar-3.1.0-1/packages/isar/lib/src/web/query_impl.dart b/packages_external/isar-3.1.0-1/packages/isar/lib/src/web/query_impl.dart deleted file mode 100644 index e2bfc153..00000000 --- a/packages_external/isar-3.1.0-1/packages/isar/lib/src/web/query_impl.dart +++ /dev/null @@ -1,180 +0,0 @@ -// ignore_for_file: public_member_api_docs - -import 'dart:async'; -import 'dart:convert'; -import 'dart:js'; -import 'dart:typed_data'; - -import 'package:isar/isar.dart'; -import 'package:isar/src/web/bindings.dart'; - -import 'package:isar/src/web/isar_collection_impl.dart'; -import 'package:isar/src/web/isar_web.dart'; - -typedef QueryDeserialize = T Function(Object); - -class QueryImpl extends Query { - QueryImpl(this.col, this.queryJs, this.deserialize, this.propertyName); - final IsarCollectionImpl col; - final QueryJs queryJs; - final QueryDeserialize deserialize; - final String? propertyName; - - @override - Isar get isar => col.isar; - - @override - Future findFirst() { - return col.isar.getTxn(false, (IsarTxnJs txn) async { - final result = await queryJs.findFirst(txn).wait(); - if (result == null) { - return null; - } - return deserialize(result); - }); - } - - @override - T? findFirstSync() => unsupportedOnWeb(); - - @override - Future> findAll() { - return col.isar.getTxn(false, (IsarTxnJs txn) async { - final result = await queryJs.findAll(txn).wait>(); - return result.map((e) => deserialize(e as Object)).toList(); - }); - } - - @override - List findAllSync() => unsupportedOnWeb(); - - @override - Future aggregate(AggregationOp op) { - return col.isar.getTxn(false, (IsarTxnJs txn) async { - final property = propertyName ?? col.schema.idName; - - num? result; - switch (op) { - case AggregationOp.min: - result = await queryJs.min(txn, property).wait(); - break; - case AggregationOp.max: - result = await queryJs.max(txn, property).wait(); - break; - case AggregationOp.sum: - result = await queryJs.sum(txn, property).wait(); - break; - case AggregationOp.average: - result = await queryJs.average(txn, property).wait(); - break; - case AggregationOp.count: - result = await queryJs.count(txn).wait(); - break; - // ignore: no_default_cases - default: - throw UnimplementedError(); - } - - if (result == null) { - return null; - } - - if (R == DateTime) { - return DateTime.fromMillisecondsSinceEpoch(result.toInt()).toLocal() - as R; - } else if (R == int) { - return result.toInt() as R; - } else if (R == double) { - return result.toDouble() as R; - } else { - return null; - } - }); - } - - @override - R? aggregateSync(AggregationOp op) => unsupportedOnWeb(); - - @override - Future deleteFirst() { - return col.isar.getTxn(true, (IsarTxnJs txn) { - return queryJs.deleteFirst(txn).wait(); - }); - } - - @override - bool deleteFirstSync() => unsupportedOnWeb(); - - @override - Future deleteAll() { - return col.isar.getTxn(true, (IsarTxnJs txn) { - return queryJs.deleteAll(txn).wait(); - }); - } - - @override - int deleteAllSync() => unsupportedOnWeb(); - - @override - Stream> watch({bool fireImmediately = false}) { - JsFunction? stop; - final controller = StreamController>( - onCancel: () { - stop?.apply([]); - }, - ); - - if (fireImmediately) { - findAll().then(controller.add); - } - - final Null Function(List results) callback = - allowInterop((List results) { - controller.add(results.map((e) => deserialize(e as Object)).toList()); - }); - stop = col.native.watchQuery(queryJs, callback); - - return controller.stream; - } - - @override - Stream watchLazy({bool fireImmediately = false}) { - JsFunction? stop; - final controller = StreamController( - onCancel: () { - stop?.apply([]); - }, - ); - - final Null Function() callback = allowInterop(() { - controller.add(null); - }); - stop = col.native.watchQueryLazy(queryJs, callback); - - return controller.stream; - } - - @override - Future exportJsonRaw(R Function(Uint8List) callback) async { - return col.isar.getTxn(false, (IsarTxnJs txn) async { - final result = await queryJs.findAll(txn).wait(); - final jsonStr = stringify(result); - return callback(const Utf8Encoder().convert(jsonStr)); - }); - } - - @override - Future>> exportJson() { - return col.isar.getTxn(false, (IsarTxnJs txn) async { - final result = await queryJs.findAll(txn).wait>(); - return result.map((e) => jsMapToDart(e as Object)).toList(); - }); - } - - @override - R exportJsonRawSync(R Function(Uint8List) callback) => unsupportedOnWeb(); - - @override - List> exportJsonSync({bool primitiveNull = true}) => - unsupportedOnWeb(); -} diff --git a/packages_external/isar-3.1.0-1/packages/isar/lib/src/web/split_words.dart b/packages_external/isar-3.1.0-1/packages/isar/lib/src/web/split_words.dart deleted file mode 100644 index fa29ddd7..00000000 --- a/packages_external/isar-3.1.0-1/packages/isar/lib/src/web/split_words.dart +++ /dev/null @@ -1,5 +0,0 @@ -// ignore_for_file: public_member_api_docs - -import 'package:isar/src/web/isar_web.dart'; - -List isarSplitWords(String input) => unsupportedOnWeb(); diff --git a/packages_external/isar-3.1.0-1/packages/isar/pubspec.yaml b/packages_external/isar-3.1.0-1/packages/isar/pubspec.yaml deleted file mode 100644 index 3935bdc2..00000000 --- a/packages_external/isar-3.1.0-1/packages/isar/pubspec.yaml +++ /dev/null @@ -1,23 +0,0 @@ -name: isar -description: Extremely fast, easy to use, and fully async NoSQL database for Flutter. -version: 3.1.0+1 -repository: https://github.com/isar/isar/tree/main/packages/isar -homepage: https://github.com/isar/isar -issue_tracker: https://github.com/isar/isar/issues -documentation: https://isar.dev -funding: - - https://github.com/sponsors/leisim/ - -environment: - sdk: ">=2.17.0 <3.0.0" - -dependencies: - ffi: ">=2.0.0 <3.0.0" - js: ^0.7.1 - meta: ^1.7.0 - -dev_dependencies: - build_runner: ^2.4.13 - ffigen: ^14.0.1 - test: ^1.21.1 - very_good_analysis: ^6.0.0 diff --git a/packages_external/isar-3.1.0-1/packages/isar/test/isar_reader_writer_test.dart b/packages_external/isar-3.1.0-1/packages/isar/test/isar_reader_writer_test.dart deleted file mode 100644 index 2cebf602..00000000 --- a/packages_external/isar-3.1.0-1/packages/isar/test/isar_reader_writer_test.dart +++ /dev/null @@ -1,287 +0,0 @@ -@TestOn('vm') - -// ignore_for_file: constant_identifier_names - -import 'dart:convert'; -import 'dart:io'; -import 'dart:typed_data'; - -import 'package:isar/isar.dart'; -import 'package:isar/src/native/isar_core.dart'; -import 'package:isar/src/native/isar_reader_impl.dart'; -import 'package:isar/src/native/isar_writer_impl.dart'; -import 'package:test/test.dart'; - -void main() { - group('Golden Binary', () { - late final json = - File('../isar_core/tests/binary_golden.json').readAsStringSync(); - late final tests = (jsonDecode(json) as List) - .map((e) => BinaryTest.fromJson(e as Map)) - .toList(); - - test('IsarReader', () { - var t = 0; - for (final test in tests) { - final reader = IsarReaderImpl(Uint8List.fromList(test.bytes)); - var offset = 2; - for (var i = 0; i < test.types.length; i++) { - final type = test.types[i]; - final nullableValue = type.read(reader, offset, true); - expect(nullableValue, test.values[i], reason: '${test.types} $t'); - - final nonNullableValue = type.read(reader, offset, false); - _expectIgnoreNull(nonNullableValue, test.values[i], type); - offset += type.size; - } - t++; - } - }); - - test('IsarWriter', () { - for (final test in tests) { - final buffer = Uint8List(10000); - final size = - test.types.fold(0, (sum, type) => sum + type.size) + 2; - - final bufferView = buffer.buffer.asUint8List(0, test.bytes.length); - final writer = IsarWriterImpl(bufferView, size); - var offset = 2; - for (var i = 0; i < test.types.length; i++) { - final type = test.types[i]; - final value = test.values[i]; - type.write(writer, offset, value); - offset += type.size; - } - - expect(buffer.sublist(0, test.bytes.length), test.bytes); - } - }); - }); -} - -enum Type { - Bool(1, false, _readBool, _writeBool), - Byte(1, 0, _readByte, _writeByte), - Int(4, nullInt, _readInt, _writeInt), - Float(4, nullFloat, _readFloat, _writeFloat), - Long(8, nullLong, _readLong, _writeLong), - Double(8, nullDouble, _readDouble, _writeDouble), - String(3, '', _readString, _writeString), - BoolList(3, false, _readBoolList, _writeBoolList), - ByteList(3, 0, _readByteList, _writeByteList), - IntList(3, nullInt, _readIntList, _writeIntList), - FloatList(3, nullFloat, _readFloatList, _writeFloatList), - LongList(3, nullLong, _readLongList, _writeLongList), - DoubleList(3, nullDouble, _readDoubleList, _writeDoubleList), - StringList(3, '', _readStringList, _writeStringList); - - const Type(this.size, this.nullValue, this.read, this.write); - - final int size; - final dynamic nullValue; - final dynamic Function(IsarReader reader, int offset, bool nullable) read; - final void Function(IsarWriter reader, int offset, dynamic value) write; -} - -class BinaryTest { - const BinaryTest(this.types, this.values, this.bytes); - - factory BinaryTest.fromJson(Map json) { - return BinaryTest( - (json['types'] as List) - .map((type) => Type.values.firstWhere((t) => t.name == type)) - .toList(), - json['values'] as List, - (json['bytes'] as List).cast(), - ); - } - - final List types; - final List values; - final List bytes; -} - -void _expectIgnoreNull( - dynamic left, - dynamic right, - Type type, { - bool inList = false, -}) { - if (right == null && (type.index < Type.BoolList.index || inList)) { - if (left is double) { - expect(left, isNaN); - } else { - expect(left, type.nullValue); - } - } else if (right is List) { - left as List; - for (var i = 0; i < right.length; i++) { - _expectIgnoreNull(left[i], right[i], type, inList: true); - } - } else { - expect(left, right); - } -} - -bool? _readBool(IsarReader reader, int offset, bool nullable) { - if (nullable) { - return reader.readBoolOrNull(offset); - } else { - return reader.readBool(offset); - } -} - -void _writeBool(IsarWriter writer, int offset, dynamic value) { - writer.writeBool(offset, value as bool?); -} - -int? _readByte(IsarReader reader, int offset, bool nullable) { - return reader.readByte(offset); -} - -void _writeByte(IsarWriter writer, int offset, dynamic value) { - writer.writeByte(offset, value as int); -} - -int? _readInt(IsarReader reader, int offset, bool nullable) { - if (nullable) { - return reader.readIntOrNull(offset); - } else { - return reader.readInt(offset); - } -} - -void _writeInt(IsarWriter writer, int offset, dynamic value) { - writer.writeInt(offset, value as int?); -} - -double? _readFloat(IsarReader reader, int offset, bool nullable) { - if (nullable) { - return reader.readFloatOrNull(offset); - } else { - return reader.readFloat(offset); - } -} - -void _writeFloat(IsarWriter writer, int offset, dynamic value) { - writer.writeFloat(offset, value as double?); -} - -int? _readLong(IsarReader reader, int offset, bool nullable) { - if (nullable) { - return reader.readLongOrNull(offset); - } else { - return reader.readLong(offset); - } -} - -void _writeLong(IsarWriter writer, int offset, dynamic value) { - writer.writeLong(offset, value as int?); -} - -double? _readDouble(IsarReader reader, int offset, bool nullable) { - if (nullable) { - return reader.readDoubleOrNull(offset); - } else { - return reader.readDouble(offset); - } -} - -void _writeDouble(IsarWriter writer, int offset, dynamic value) { - writer.writeDouble(offset, value as double?); -} - -String? _readString(IsarReader reader, int offset, bool nullable) { - if (nullable) { - return reader.readStringOrNull(offset); - } else { - return reader.readString(offset); - } -} - -void _writeString(IsarWriter writer, int offset, dynamic value) { - final bytes = value is String ? utf8.encode(value) : null; - writer.writeByteList(offset, bytes); -} - -List? _readBoolList(IsarReader reader, int offset, bool nullable) { - if (nullable) { - return reader.readBoolOrNullList(offset); - } else { - return reader.readBoolList(offset); - } -} - -void _writeBoolList(IsarWriter writer, int offset, dynamic value) { - writer.writeBoolList(offset, (value as List?)?.cast()); -} - -List? _readByteList(IsarReader reader, int offset, bool nullable) { - return reader.readByteList(offset); -} - -void _writeByteList(IsarWriter writer, int offset, dynamic value) { - final bytes = value is List ? Uint8List.fromList(value.cast()) : null; - writer.writeByteList(offset, bytes); -} - -List? _readIntList(IsarReader reader, int offset, bool nullable) { - if (nullable) { - return reader.readIntOrNullList(offset); - } else { - return reader.readIntList(offset); - } -} - -void _writeIntList(IsarWriter writer, int offset, dynamic value) { - writer.writeIntList(offset, (value as List?)?.cast()); -} - -List? _readFloatList(IsarReader reader, int offset, bool nullable) { - if (nullable) { - return reader.readFloatOrNullList(offset); - } else { - return reader.readFloatList(offset); - } -} - -void _writeFloatList(IsarWriter writer, int offset, dynamic value) { - writer.writeFloatList(offset, (value as List?)?.cast()); -} - -List? _readLongList(IsarReader reader, int offset, bool nullable) { - if (nullable) { - return reader.readLongOrNullList(offset); - } else { - return reader.readLongList(offset); - } -} - -void _writeLongList(IsarWriter writer, int offset, dynamic value) { - writer.writeLongList(offset, (value as List?)?.cast()); -} - -List? _readDoubleList(IsarReader reader, int offset, bool nullable) { - if (nullable) { - return reader.readDoubleOrNullList(offset); - } else { - return reader.readDoubleList(offset); - } -} - -void _writeDoubleList(IsarWriter writer, int offset, dynamic value) { - writer.writeDoubleList(offset, (value as List?)?.cast()); -} - -List? _readStringList(IsarReader reader, int offset, bool nullable) { - if (nullable) { - return reader.readStringOrNullList(offset); - } else { - return reader.readStringList(offset); - } -} - -void _writeStringList(IsarWriter writer, int offset, dynamic value) { - writer.writeStringList(offset, (value as List?)?.cast()); -} diff --git a/packages_external/isar-3.1.0-1/packages/isar/tool/get_version.dart b/packages_external/isar-3.1.0-1/packages/isar/tool/get_version.dart deleted file mode 100644 index cd12a90a..00000000 --- a/packages_external/isar-3.1.0-1/packages/isar/tool/get_version.dart +++ /dev/null @@ -1,6 +0,0 @@ -import 'package:isar/isar.dart'; - -void main() { - // ignore: avoid_print - print(Isar.version); -} diff --git a/packages_external/isar-3.1.0-1/packages/isar/tool/verify_release_version.dart b/packages_external/isar-3.1.0-1/packages/isar/tool/verify_release_version.dart deleted file mode 100644 index 1ad3e915..00000000 --- a/packages_external/isar-3.1.0-1/packages/isar/tool/verify_release_version.dart +++ /dev/null @@ -1,9 +0,0 @@ -import 'package:isar/isar.dart'; - -void main(List args) { - if (Isar.version != args[0]) { - throw StateError( - 'Invalid Isar version for release: ${Isar.version} != ${args[0]}', - ); - } -} diff --git a/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/.pubignore b/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/.pubignore deleted file mode 100644 index f4c9bc13..00000000 --- a/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/.pubignore +++ /dev/null @@ -1,5 +0,0 @@ -!*.so -!*.a -!*.dylib -!*.dll -!*.xcframework/ \ No newline at end of file diff --git a/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/CHANGELOG.md b/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/CHANGELOG.md deleted file mode 100644 index 1634a089..00000000 --- a/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/CHANGELOG.md +++ /dev/null @@ -1 +0,0 @@ -See [Isar Changelog](https://pub.dev/packages/isar/changelog) \ No newline at end of file diff --git a/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/LICENSE b/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/LICENSE deleted file mode 100644 index 7a4a3ea2..00000000 --- a/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/LICENSE +++ /dev/null @@ -1,202 +0,0 @@ - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. \ No newline at end of file diff --git a/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/README.md b/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/README.md deleted file mode 100644 index ab70e970..00000000 --- a/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/README.md +++ /dev/null @@ -1 +0,0 @@ -### Flutter binaries for the [Isar Database](https://github.com/isar/isar) please go there for documentation. \ No newline at end of file diff --git a/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/android/.gitignore b/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/android/.gitignore deleted file mode 100644 index c6cbe562..00000000 --- a/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/android/.gitignore +++ /dev/null @@ -1,8 +0,0 @@ -*.iml -.gradle -/local.properties -/.idea/workspace.xml -/.idea/libraries -.DS_Store -/build -/captures diff --git a/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/android/build.gradle b/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/android/build.gradle deleted file mode 100644 index 12bd1ee5..00000000 --- a/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/android/build.gradle +++ /dev/null @@ -1,36 +0,0 @@ -group 'dev.isar.isar_flutter_libs' -version '1.0' - -buildscript { - repositories { - google() - mavenCentral() - } - - dependencies { - classpath 'com.android.tools.build:gradle:7.3.1' - } -} - -rootProject.allprojects { - repositories { - google() - mavenCentral() - } -} - -apply plugin: 'com.android.library' - -android { - namespace 'dev.isar.isar_flutter_libs' - - compileSdkVersion 34 - - defaultConfig { - minSdkVersion 19 - } -} - -dependencies { - implementation "androidx.startup:startup-runtime:1.1.1" -} \ No newline at end of file diff --git a/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/android/gradle.properties b/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/android/gradle.properties deleted file mode 100644 index 94adc3a3..00000000 --- a/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/android/gradle.properties +++ /dev/null @@ -1,3 +0,0 @@ -org.gradle.jvmargs=-Xmx1536M -android.useAndroidX=true -android.enableJetifier=true diff --git a/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/android/gradle/wrapper/gradle-wrapper.properties b/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/android/gradle/wrapper/gradle-wrapper.properties deleted file mode 100644 index 0a426381..00000000 --- a/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/android/gradle/wrapper/gradle-wrapper.properties +++ /dev/null @@ -1,6 +0,0 @@ -#Sat Nov 12 16:30:49 CET 2022 -distributionBase=GRADLE_USER_HOME -distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip -distributionPath=wrapper/dists -zipStorePath=wrapper/dists -zipStoreBase=GRADLE_USER_HOME diff --git a/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/android/settings.gradle b/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/android/settings.gradle deleted file mode 100644 index 6942e528..00000000 --- a/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/android/settings.gradle +++ /dev/null @@ -1 +0,0 @@ -rootProject.name = 'isar_flutter_libs' diff --git a/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/android/src/main/AndroidManifest.xml b/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/android/src/main/AndroidManifest.xml deleted file mode 100644 index 4805420d..00000000 --- a/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/android/src/main/AndroidManifest.xml +++ /dev/null @@ -1,3 +0,0 @@ - \ No newline at end of file diff --git a/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/android/src/main/java/dev/isar/isar_flutter_libs/IsarFlutterLibsPlugin.java b/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/android/src/main/java/dev/isar/isar_flutter_libs/IsarFlutterLibsPlugin.java deleted file mode 100644 index c28ffa3e..00000000 --- a/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/android/src/main/java/dev/isar/isar_flutter_libs/IsarFlutterLibsPlugin.java +++ /dev/null @@ -1,13 +0,0 @@ -package dev.isar.isar_flutter_libs; - -import androidx.annotation.NonNull; - -import io.flutter.embedding.engine.plugins.FlutterPlugin; - -public class IsarFlutterLibsPlugin implements FlutterPlugin { - @Override - public void onAttachedToEngine(@NonNull FlutterPluginBinding flutterPluginBinding) { } - - @Override - public void onDetachedFromEngine(@NonNull FlutterPluginBinding binding) { } -} diff --git a/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/ios/.gitignore b/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/ios/.gitignore deleted file mode 100644 index 0c885071..00000000 --- a/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/ios/.gitignore +++ /dev/null @@ -1,38 +0,0 @@ -.idea/ -.vagrant/ -.sconsign.dblite -.svn/ - -.DS_Store -*.swp -profile - -DerivedData/ -build/ -GeneratedPluginRegistrant.h -GeneratedPluginRegistrant.m - -.generated/ - -*.pbxuser -*.mode1v3 -*.mode2v3 -*.perspectivev3 - -!default.pbxuser -!default.mode1v3 -!default.mode2v3 -!default.perspectivev3 - -xcuserdata - -*.moved-aside - -*.pyc -*sync/ -Icon? -.tags* - -/Flutter/Generated.xcconfig -/Flutter/ephemeral/ -/Flutter/flutter_export_environment.sh \ No newline at end of file diff --git a/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/ios/Assets/.gitkeep b/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/ios/Assets/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/ios/Classes/IsarFlutterLibsPlugin.h b/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/ios/Classes/IsarFlutterLibsPlugin.h deleted file mode 100644 index f2a658f8..00000000 --- a/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/ios/Classes/IsarFlutterLibsPlugin.h +++ /dev/null @@ -1,4 +0,0 @@ -#import - -@interface IsarFlutterLibsPlugin : NSObject -@end diff --git a/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/ios/Classes/IsarFlutterLibsPlugin.m b/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/ios/Classes/IsarFlutterLibsPlugin.m deleted file mode 100644 index b005a2ba..00000000 --- a/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/ios/Classes/IsarFlutterLibsPlugin.m +++ /dev/null @@ -1,15 +0,0 @@ -#import "IsarFlutterLibsPlugin.h" -#if __has_include() -#import -#else -// Support project import fallback if the generated compatibility header -// is not copied when this plugin is created as a library. -// https://forums.swift.org/t/swift-static-libraries-dont-copy-generated-objective-c-header/19816 -#import "isar_flutter_libs-Swift.h" -#endif - -@implementation IsarFlutterLibsPlugin -+ (void)registerWithRegistrar:(NSObject*)registrar { - [SwiftIsarFlutterLibsPlugin registerWithRegistrar:registrar]; -} -@end diff --git a/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/ios/Classes/SwiftIsarFlutterLibsPlugin.swift b/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/ios/Classes/SwiftIsarFlutterLibsPlugin.swift deleted file mode 100644 index b4cc232c..00000000 --- a/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/ios/Classes/SwiftIsarFlutterLibsPlugin.swift +++ /dev/null @@ -1,16 +0,0 @@ -import Flutter -import UIKit - -public class SwiftIsarFlutterLibsPlugin: NSObject, FlutterPlugin { - public static func register(with registrar: FlutterPluginRegistrar) { - } - - public func handle(_ call: FlutterMethodCall, result: @escaping FlutterResult) { - result(nil) - } - - public func dummyMethodToEnforceBundling() { - // dummy calls to prevent tree shaking - isar_get_error(0) - } -} diff --git a/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/ios/Classes/binding.h b/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/ios/Classes/binding.h deleted file mode 100644 index d827bbea..00000000 --- a/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/ios/Classes/binding.h +++ /dev/null @@ -1,6 +0,0 @@ -#include -#include -#include -#include - -char* isar_get_error(uint32_t err); \ No newline at end of file diff --git a/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/ios/isar_flutter_libs.podspec b/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/ios/isar_flutter_libs.podspec deleted file mode 100644 index 8312e532..00000000 --- a/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/ios/isar_flutter_libs.podspec +++ /dev/null @@ -1,17 +0,0 @@ -Pod::Spec.new do |s| - s.name = 'isar_flutter_libs' - s.version = '1.0.0' - s.summary = 'Flutter binaries for the Isar Database. Needs to be included for Flutter apps.' - s.homepage = 'https://isar.dev' - s.license = { :file => '../LICENSE' } - s.author = { 'Isar' => 'hello@isar.dev' } - - s.source = { :path => '.' } - s.source_files = 'Classes/**/*' - s.public_header_files = 'Classes/**/*.h' - - s.dependency 'Flutter' - s.platform = :ios, '11.0' - s.swift_version = '5.3' - s.vendored_frameworks = 'isar.xcframework' -end diff --git a/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/lib/isar_flutter_libs.dart b/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/lib/isar_flutter_libs.dart deleted file mode 100644 index e69de29b..00000000 diff --git a/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/linux/CMakeLists.txt b/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/linux/CMakeLists.txt deleted file mode 100644 index 4f22a32b..00000000 --- a/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/linux/CMakeLists.txt +++ /dev/null @@ -1,25 +0,0 @@ -cmake_minimum_required(VERSION 3.10) -set(PROJECT_NAME "isar_flutter_libs") -project(${PROJECT_NAME} LANGUAGES CXX) - -# This value is used when generating builds using this plugin, so it must -# not be changed -set(PLUGIN_NAME "isar_flutter_libs_plugin") - -add_library(${PLUGIN_NAME} SHARED - "isar_flutter_libs_plugin.cc" -) -apply_standard_settings(${PLUGIN_NAME}) -set_target_properties(${PLUGIN_NAME} PROPERTIES - CXX_VISIBILITY_PRESET hidden) -target_compile_definitions(${PLUGIN_NAME} PRIVATE FLUTTER_PLUGIN_IMPL) -target_include_directories(${PLUGIN_NAME} INTERFACE - "${CMAKE_CURRENT_SOURCE_DIR}/include") -target_link_libraries(${PLUGIN_NAME} PRIVATE flutter) -target_link_libraries(${PLUGIN_NAME} PRIVATE PkgConfig::GTK) - -# List of absolute paths to libraries that should be bundled with the plugin -set(isar_flutter_libs_bundled_libraries - "${CMAKE_CURRENT_SOURCE_DIR}/libisar.so" - PARENT_SCOPE -) diff --git a/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/linux/include/isar_flutter_libs/isar_flutter_libs_plugin.h b/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/linux/include/isar_flutter_libs/isar_flutter_libs_plugin.h deleted file mode 100644 index 499bfc87..00000000 --- a/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/linux/include/isar_flutter_libs/isar_flutter_libs_plugin.h +++ /dev/null @@ -1,26 +0,0 @@ -#ifndef FLUTTER_PLUGIN_ISAR_FLUTTER_LIBS_PLUGIN_H_ -#define FLUTTER_PLUGIN_ISAR_FLUTTER_LIBS_PLUGIN_H_ - -#include - -G_BEGIN_DECLS - -#ifdef FLUTTER_PLUGIN_IMPL -#define FLUTTER_PLUGIN_EXPORT __attribute__((visibility("default"))) -#else -#define FLUTTER_PLUGIN_EXPORT -#endif - -typedef struct _IsarFlutterLibsPlugin IsarFlutterLibsPlugin; -typedef struct { - GObjectClass parent_class; -} IsarFlutterLibsPluginClass; - -FLUTTER_PLUGIN_EXPORT GType isar_flutter_libs_plugin_get_type(); - -FLUTTER_PLUGIN_EXPORT void isar_flutter_libs_plugin_register_with_registrar( - FlPluginRegistrar* registrar); - -G_END_DECLS - -#endif // FLUTTER_PLUGIN_ISAR_FLUTTER_LIBS_PLUGIN_H_ diff --git a/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/linux/isar_flutter_libs_plugin.cc b/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/linux/isar_flutter_libs_plugin.cc deleted file mode 100644 index 50cd846e..00000000 --- a/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/linux/isar_flutter_libs_plugin.cc +++ /dev/null @@ -1,70 +0,0 @@ -#include "include/isar_flutter_libs/isar_flutter_libs_plugin.h" - -#include -#include -#include - -#include - -#define ISAR_FLUTTER_LIBS_PLUGIN(obj) \ - (G_TYPE_CHECK_INSTANCE_CAST((obj), isar_flutter_libs_plugin_get_type(), \ - IsarFlutterLibsPlugin)) - -struct _IsarFlutterLibsPlugin { - GObject parent_instance; -}; - -G_DEFINE_TYPE(IsarFlutterLibsPlugin, isar_flutter_libs_plugin, g_object_get_type()) - -// Called when a method call is received from Flutter. -static void isar_flutter_libs_plugin_handle_method_call( - IsarFlutterLibsPlugin* self, - FlMethodCall* method_call) { - g_autoptr(FlMethodResponse) response = nullptr; - - const gchar* method = fl_method_call_get_name(method_call); - - if (strcmp(method, "getPlatformVersion") == 0) { - struct utsname uname_data = {}; - uname(&uname_data); - g_autofree gchar *version = g_strdup_printf("Linux %s", uname_data.version); - g_autoptr(FlValue) result = fl_value_new_string(version); - response = FL_METHOD_RESPONSE(fl_method_success_response_new(result)); - } else { - response = FL_METHOD_RESPONSE(fl_method_not_implemented_response_new()); - } - - fl_method_call_respond(method_call, response, nullptr); -} - -static void isar_flutter_libs_plugin_dispose(GObject* object) { - G_OBJECT_CLASS(isar_flutter_libs_plugin_parent_class)->dispose(object); -} - -static void isar_flutter_libs_plugin_class_init(IsarFlutterLibsPluginClass* klass) { - G_OBJECT_CLASS(klass)->dispose = isar_flutter_libs_plugin_dispose; -} - -static void isar_flutter_libs_plugin_init(IsarFlutterLibsPlugin* self) {} - -static void method_call_cb(FlMethodChannel* channel, FlMethodCall* method_call, - gpointer user_data) { - IsarFlutterLibsPlugin* plugin = ISAR_FLUTTER_LIBS_PLUGIN(user_data); - isar_flutter_libs_plugin_handle_method_call(plugin, method_call); -} - -void isar_flutter_libs_plugin_register_with_registrar(FlPluginRegistrar* registrar) { - IsarFlutterLibsPlugin* plugin = ISAR_FLUTTER_LIBS_PLUGIN( - g_object_new(isar_flutter_libs_plugin_get_type(), nullptr)); - - g_autoptr(FlStandardMethodCodec) codec = fl_standard_method_codec_new(); - g_autoptr(FlMethodChannel) channel = - fl_method_channel_new(fl_plugin_registrar_get_messenger(registrar), - "isar_flutter_libs", - FL_METHOD_CODEC(codec)); - fl_method_channel_set_method_call_handler(channel, method_call_cb, - g_object_ref(plugin), - g_object_unref); - - g_object_unref(plugin); -} diff --git a/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/macos/Classes/IsarFlutterLibsPlugin.swift b/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/macos/Classes/IsarFlutterLibsPlugin.swift deleted file mode 100644 index 5493fbb9..00000000 --- a/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/macos/Classes/IsarFlutterLibsPlugin.swift +++ /dev/null @@ -1,19 +0,0 @@ -import Cocoa -import FlutterMacOS - -public class IsarFlutterLibsPlugin: NSObject, FlutterPlugin { - public static func register(with registrar: FlutterPluginRegistrar) { - let channel = FlutterMethodChannel(name: "isar_flutter_libs", binaryMessenger: registrar.messenger) - let instance = IsarFlutterLibsPlugin() - registrar.addMethodCallDelegate(instance, channel: channel) - } - - public func handle(_ call: FlutterMethodCall, result: @escaping FlutterResult) { - switch call.method { - case "getPlatformVersion": - result("macOS " + ProcessInfo.processInfo.operatingSystemVersionString) - default: - result(FlutterMethodNotImplemented) - } - } -} diff --git a/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/macos/isar_flutter_libs.podspec b/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/macos/isar_flutter_libs.podspec deleted file mode 100644 index 08244150..00000000 --- a/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/macos/isar_flutter_libs.podspec +++ /dev/null @@ -1,17 +0,0 @@ -Pod::Spec.new do |s| - s.name = 'isar_flutter_libs' - s.version = '1.0.0' - s.summary = 'Flutter binaries for the Isar Database. Needs to be included for Flutter apps.' - s.homepage = 'https://isar.dev' - s.license = { :file => '../LICENSE' } - s.author = { 'Isar' => 'hello@isar.dev' } - - s.source = { :path => '.' } - s.source_files = 'Classes/**/*' - s.public_header_files = 'Classes/**/*.h' - - s.dependency 'FlutterMacOS' - s.platform = :osx, '10.11' - s.swift_version = '5.3' - s.vendored_libraries = 'libisar.dylib' -end \ No newline at end of file diff --git a/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/pubspec.yaml b/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/pubspec.yaml deleted file mode 100644 index e4638a0f..00000000 --- a/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/pubspec.yaml +++ /dev/null @@ -1,33 +0,0 @@ -name: isar_flutter_libs -description: Isar Core binaries for the Isar Database. Needs to be included for - Flutter apps. -version: 3.1.0+1 -repository: https://github.com/isar/isar -homepage: https://isar.dev - -environment: - sdk: ">=2.17.0 <3.0.0" - flutter: ">=3.0.0" - -dependencies: - flutter: - sdk: flutter - isar: 3.1.0+1 - -dev_dependencies: - build_runner: ^2.4.13 - -flutter: - plugin: - platforms: - android: - package: dev.isar.isar_flutter_libs - pluginClass: IsarFlutterLibsPlugin - ios: - pluginClass: IsarFlutterLibsPlugin - macos: - pluginClass: IsarFlutterLibsPlugin - linux: - pluginClass: IsarFlutterLibsPlugin - windows: - pluginClass: IsarFlutterLibsPlugin diff --git a/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/pubspec_overrides.yaml b/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/pubspec_overrides.yaml deleted file mode 100644 index 388e439a..00000000 --- a/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/pubspec_overrides.yaml +++ /dev/null @@ -1,3 +0,0 @@ -dependency_overrides: - isar: - path: ../isar \ No newline at end of file diff --git a/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/windows/.gitignore b/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/windows/.gitignore deleted file mode 100644 index b3eb2be1..00000000 --- a/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/windows/.gitignore +++ /dev/null @@ -1,17 +0,0 @@ -flutter/ - -# Visual Studio user-specific files. -*.suo -*.user -*.userosscache -*.sln.docstates - -# Visual Studio build-related files. -x64/ -x86/ - -# Visual Studio cache files -# files ending in .cache can be ignored -*.[Cc]ache -# but keep track of directories ending in .cache -!*.[Cc]ache/ diff --git a/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/windows/CMakeLists.txt b/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/windows/CMakeLists.txt deleted file mode 100644 index 55206521..00000000 --- a/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/windows/CMakeLists.txt +++ /dev/null @@ -1,24 +0,0 @@ -cmake_minimum_required(VERSION 3.14) -set(PROJECT_NAME "isar_flutter_libs") -project(${PROJECT_NAME} LANGUAGES CXX) - -# This value is used when generating builds using this plugin, so it must -# not be changed -set(PLUGIN_NAME "isar_flutter_libs_plugin") - -add_library(${PLUGIN_NAME} SHARED - "isar_flutter_libs_plugin.cpp" -) -apply_standard_settings(${PLUGIN_NAME}) -set_target_properties(${PLUGIN_NAME} PROPERTIES - CXX_VISIBILITY_PRESET hidden) -target_compile_definitions(${PLUGIN_NAME} PRIVATE FLUTTER_PLUGIN_IMPL) -target_include_directories(${PLUGIN_NAME} INTERFACE - "${CMAKE_CURRENT_SOURCE_DIR}/include") -target_link_libraries(${PLUGIN_NAME} PRIVATE flutter flutter_wrapper_plugin) - -# List of absolute paths to libraries that should be bundled with the plugin -set(isar_flutter_libs_bundled_libraries - "${CMAKE_CURRENT_SOURCE_DIR}/isar.dll" - PARENT_SCOPE -) diff --git a/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/windows/include/isar_flutter_libs/isar_flutter_libs_plugin.h b/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/windows/include/isar_flutter_libs/isar_flutter_libs_plugin.h deleted file mode 100644 index d0c066de..00000000 --- a/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/windows/include/isar_flutter_libs/isar_flutter_libs_plugin.h +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef FLUTTER_PLUGIN_ISAR_FLUTTER_LIBS_PLUGIN_H_ -#define FLUTTER_PLUGIN_ISAR_FLUTTER_LIBS_PLUGIN_H_ - -#include - -#ifdef FLUTTER_PLUGIN_IMPL -#define FLUTTER_PLUGIN_EXPORT __declspec(dllexport) -#else -#define FLUTTER_PLUGIN_EXPORT __declspec(dllimport) -#endif - -#if defined(__cplusplus) -extern "C" { -#endif - -FLUTTER_PLUGIN_EXPORT void IsarFlutterLibsPluginRegisterWithRegistrar( - FlutterDesktopPluginRegistrarRef registrar); - -#if defined(__cplusplus) -} // extern "C" -#endif - -#endif // FLUTTER_PLUGIN_ISAR_FLUTTER_LIBS_PLUGIN_H_ diff --git a/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/windows/isar_flutter_libs_plugin.cpp b/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/windows/isar_flutter_libs_plugin.cpp deleted file mode 100644 index 707b9246..00000000 --- a/packages_external/isar-3.1.0-1/packages/isar_flutter_libs/windows/isar_flutter_libs_plugin.cpp +++ /dev/null @@ -1,82 +0,0 @@ -#include "include/isar_flutter_libs/isar_flutter_libs_plugin.h" - -// This must be included before many other Windows headers. -#include - -// For getPlatformVersion; remove unless needed for your plugin implementation. -#include - -#include -#include -#include - -#include -#include -#include - -namespace { - -class IsarFlutterLibsPlugin : public flutter::Plugin { - public: - static void RegisterWithRegistrar(flutter::PluginRegistrarWindows *registrar); - - IsarFlutterLibsPlugin(); - - virtual ~IsarFlutterLibsPlugin(); - - private: - // Called when a method is called on this plugin's channel from Dart. - void HandleMethodCall( - const flutter::MethodCall &method_call, - std::unique_ptr> result); -}; - -// static -void IsarFlutterLibsPlugin::RegisterWithRegistrar( - flutter::PluginRegistrarWindows *registrar) { - auto channel = - std::make_unique>( - registrar->messenger(), "isar_flutter_libs", - &flutter::StandardMethodCodec::GetInstance()); - - auto plugin = std::make_unique(); - - channel->SetMethodCallHandler( - [plugin_pointer = plugin.get()](const auto &call, auto result) { - plugin_pointer->HandleMethodCall(call, std::move(result)); - }); - - registrar->AddPlugin(std::move(plugin)); -} - -IsarFlutterLibsPlugin::IsarFlutterLibsPlugin() {} - -IsarFlutterLibsPlugin::~IsarFlutterLibsPlugin() {} - -void IsarFlutterLibsPlugin::HandleMethodCall( - const flutter::MethodCall &method_call, - std::unique_ptr> result) { - if (method_call.method_name().compare("getPlatformVersion") == 0) { - std::ostringstream version_stream; - version_stream << "Windows "; - if (IsWindows10OrGreater()) { - version_stream << "10+"; - } else if (IsWindows8OrGreater()) { - version_stream << "8"; - } else if (IsWindows7OrGreater()) { - version_stream << "7"; - } - result->Success(flutter::EncodableValue(version_stream.str())); - } else { - result->NotImplemented(); - } -} - -} // namespace - -void IsarFlutterLibsPluginRegisterWithRegistrar( - FlutterDesktopPluginRegistrarRef registrar) { - IsarFlutterLibsPlugin::RegisterWithRegistrar( - flutter::PluginRegistrarManager::GetInstance() - ->GetRegistrar(registrar)); -} diff --git a/packages_external/isar-3.1.0-1/tool/build.sh b/packages_external/isar-3.1.0-1/tool/build.sh deleted file mode 100644 index f93bac4f..00000000 --- a/packages_external/isar-3.1.0-1/tool/build.sh +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/shuname - -arch=$(uname -m) - -if [ `uname` = "Linux" ] ; -then - if [ $arch = "x86_64" ] ; - then - cargo build --target x86_64-unknown-linux-gnu --release - else - cargo build --target aarch64-unknown-linux-gnu --release - fi -elif [ `uname` = "Darwin" ] ; -then - if [[ $arch == x86_64* ]]; then - cargo build --target x86_64-apple-darwin --release - else - cargo build --target aarch64-apple-darwin --release - fi -else - cargo build --target x86_64-pc-windows-msvc --release -fi \ No newline at end of file diff --git a/packages_external/isar-3.1.0-1/tool/build_android.sh b/packages_external/isar-3.1.0-1/tool/build_android.sh deleted file mode 100644 index cb96b9ab..00000000 --- a/packages_external/isar-3.1.0-1/tool/build_android.sh +++ /dev/null @@ -1,60 +0,0 @@ -#!/bin/bash - -if [[ "$(uname -s)" == "Darwin" ]]; then - export NDK_HOST_TAG="darwin-x86_64" -elif [[ "$(uname -s)" == "Linux" ]]; then - export NDK_HOST_TAG="linux-x86_64" -else - echo "Unsupported OS." - exit -fi - -NDK=${ANDROID_NDK_HOME:-${ANDROID_NDK_ROOT:-"$ANDROID_SDK_ROOT/ndk"}} -COMPILER_DIR="$NDK/toolchains/llvm/prebuilt/$NDK_HOST_TAG/bin" -export PATH="$COMPILER_DIR:$PATH" - -echo "$COMPILER_DIR" - -export CC_i686_linux_android=$COMPILER_DIR/i686-linux-android21-clang -export AR_i686_linux_android=$COMPILER_DIR/llvm-ar -export CARGO_TARGET_I686_LINUX_ANDROID_LINKER=$COMPILER_DIR/i686-linux-android21-clang -export CARGO_TARGET_I686_LINUX_ANDROID_AR=$COMPILER_DIR/llvm-ar - -export CC_x86_64_linux_android=$COMPILER_DIR/x86_64-linux-android21-clang -export AR_x86_64_linux_android=$COMPILER_DIR/llvm-ar -export CARGO_TARGET_X86_64_LINUX_ANDROID_LINKER=$COMPILER_DIR/x86_64-linux-android21-clang -export CARGO_TARGET_X86_64_LINUX_ANDROID_AR=$COMPILER_DIR/llvm-ar - -export CC_armv7_linux_androideabi=$COMPILER_DIR/armv7a-linux-androideabi21-clang -export AR_armv7_linux_androideabi=$COMPILER_DIR/llvm-ar -export CARGO_TARGET_ARMV7_LINUX_ANDROIDEABI_LINKER=$COMPILER_DIR/armv7a-linux-androideabi21-clang -export CARGO_TARGET_ARMV7_LINUX_ANDROIDEABI_AR=$COMPILER_DIR/llvm-ar - -export CC_aarch64_linux_android=$COMPILER_DIR/aarch64-linux-android21-clang -export AR_aarch64_linux_android=$COMPILER_DIR/llvm-ar -export CARGO_TARGET_AARCH64_LINUX_ANDROID_LINKER=$COMPILER_DIR/aarch64-linux-android21-clang -export CARGO_TARGET_AARCH64_LINUX_ANDROID_AR=$COMPILER_DIR/llvm-ar - -if [ "$1" = "x86" ]; then - rustup target add i686-linux-android - cargo build --target i686-linux-android --release - mv "target/i686-linux-android/release/libisar.so" "libisar_android_x86.so" -elif [ "$1" = "x64" ]; then - rustup target add x86_64-linux-android - cargo build --target x86_64-linux-android --release - mv "target/x86_64-linux-android/release/libisar.so" "libisar_android_x64.so" -elif [ "$1" = "armv7" ]; then - rustup target add armv7-linux-androideabi - cargo build --target armv7-linux-androideabi --release - mv "target/armv7-linux-androideabi/release/libisar.so" "libisar_android_armv7.so" -else - rustup target add aarch64-linux-android - cargo build --target aarch64-linux-android --release - mv "target/aarch64-linux-android/release/libisar.so" "libisar_android_arm64.so" -fi - - - - - - diff --git a/packages_external/isar-3.1.0-1/tool/build_ios.sh b/packages_external/isar-3.1.0-1/tool/build_ios.sh deleted file mode 100644 index 58f3b720..00000000 --- a/packages_external/isar-3.1.0-1/tool/build_ios.sh +++ /dev/null @@ -1,15 +0,0 @@ -export IPHONEOS_DEPLOYMENT_TARGET=11.0 - -rustup target add aarch64-apple-ios aarch64-apple-ios-sim x86_64-apple-ios -cargo build --target aarch64-apple-ios --release -cargo build --target aarch64-apple-ios-sim --release -cargo build --target x86_64-apple-ios --release - -lipo "target/aarch64-apple-ios-sim/release/libisar.a" "target/x86_64-apple-ios/release/libisar.a" -output "target/aarch64-apple-ios-sim/libisar.a" -create -xcodebuild \ - -create-xcframework \ - -library target/aarch64-apple-ios/release/libisar.a \ - -library target/aarch64-apple-ios-sim/libisar.a \ - -output isar.xcframework - -zip -r isar_ios.xcframework.zip isar.xcframework \ No newline at end of file diff --git a/packages_external/isar-3.1.0-1/tool/build_linux.sh b/packages_external/isar-3.1.0-1/tool/build_linux.sh deleted file mode 100644 index 8687beb1..00000000 --- a/packages_external/isar-3.1.0-1/tool/build_linux.sh +++ /dev/null @@ -1,9 +0,0 @@ -if [ "$1" = "x64" ]; then - rustup target add target x86_64-unknown-linux-gnu - cargo build --target x86_64-unknown-linux-gnu --release - mv "target/x86_64-unknown-linux-gnu/release/libisar.so" "libisar_linux_x64.so" -else - rustup target add aarch64-unknown-linux-gnu - cargo build --target aarch64-unknown-linux-gnu --release - mv "target/aarch64-unknown-linux-gnu/release/libisar.so" "libisar_linux_arm64.so" -fi \ No newline at end of file diff --git a/packages_external/isar-3.1.0-1/tool/build_macos.sh b/packages_external/isar-3.1.0-1/tool/build_macos.sh deleted file mode 100644 index c13a4992..00000000 --- a/packages_external/isar-3.1.0-1/tool/build_macos.sh +++ /dev/null @@ -1,8 +0,0 @@ -export MACOSX_DEPLOYMENT_TARGET=10.11 - -rustup target add aarch64-apple-darwin x86_64-apple-darwin -cargo build --target aarch64-apple-darwin --release -cargo build --target x86_64-apple-darwin --release - -lipo "target/aarch64-apple-darwin/release/libisar.dylib" "target/x86_64-apple-darwin/release/libisar.dylib" -output "libisar_macos.dylib" -create -install_name_tool -id @rpath/libisar.dylib libisar_macos.dylib \ No newline at end of file diff --git a/packages_external/isar-3.1.0-1/tool/build_windows.sh b/packages_external/isar-3.1.0-1/tool/build_windows.sh deleted file mode 100644 index 1bacbb8c..00000000 --- a/packages_external/isar-3.1.0-1/tool/build_windows.sh +++ /dev/null @@ -1,9 +0,0 @@ -if [ "$1" = "x64" ]; then - rustup target add x86_64-pc-windows-msvc - cargo build --target x86_64-pc-windows-msvc --release - mv "target/x86_64-pc-windows-msvc/release/isar.dll" "isar_windows_x64.dll" -else - rustup target add aarch64-pc-windows-msvc - cargo build --target aarch64-pc-windows-msvc --release - mv "target/aarch64-pc-windows-msvc/release/isar.dll" "isar_windows_arm64.dll" -fi \ No newline at end of file diff --git a/packages_external/isar-3.1.0-1/tool/cbindgen.toml b/packages_external/isar-3.1.0-1/tool/cbindgen.toml deleted file mode 100644 index 7841a04d..00000000 --- a/packages_external/isar-3.1.0-1/tool/cbindgen.toml +++ /dev/null @@ -1,8 +0,0 @@ -language = "C" - -[parse] -parse_deps = true -include = ["isar-core", "isar"] - -[parse.expand] -crates = ["isar"] \ No newline at end of file diff --git a/packages_external/isar-3.1.0-1/tool/download_binaries.sh b/packages_external/isar-3.1.0-1/tool/download_binaries.sh deleted file mode 100644 index bd0e61be..00000000 --- a/packages_external/isar-3.1.0-1/tool/download_binaries.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/bash - -version=`dart packages/isar/tool/get_version.dart` -github="https://github.com/isar/isar/releases/download/${version}" - - -curl "${github}/libisar_android_arm64.so" -o packages/isar_flutter_libs/android/src/main/jniLibs/arm64-v8a/libisar.so --create-dirs -L -f -curl "${github}/libisar_android_armv7.so" -o packages/isar_flutter_libs/android/src/main/jniLibs/armeabi-v7a/libisar.so --create-dirs -L -f -curl "${github}/libisar_android_x64.so" -o packages/isar_flutter_libs/android/src/main/jniLibs/x86_64/libisar.so --create-dirs -L -curl "${github}/libisar_android_x86.so" -o packages/isar_flutter_libs/android/src/main/jniLibs/x86/libisar.so --create-dirs -L -f - -curl "${github}/isar_ios.xcframework.zip" -o packages/isar_flutter_libs/ios/isar_ios.xcframework.zip --create-dirs -L -f -unzip -o packages/isar_flutter_libs/ios/isar_ios.xcframework.zip -d packages/isar_flutter_libs/ios -rm packages/isar_flutter_libs/ios/isar_ios.xcframework.zip - -curl "${github}/libisar_macos.dylib" -o packages/isar_flutter_libs/macos/libisar.dylib --create-dirs -L -f -curl "${github}/libisar_linux_x64.so" -o packages/isar_flutter_libs/linux/libisar.so --create-dirs -L -f -curl "${github}/isar_windows_x64.dll" -o packages/isar_flutter_libs/windows/isar.dll --create-dirs -L -f \ No newline at end of file diff --git a/packages_external/isar-3.1.0-1/tool/ffigen.yaml b/packages_external/isar-3.1.0-1/tool/ffigen.yaml deleted file mode 100644 index e617e465..00000000 --- a/packages_external/isar-3.1.0-1/tool/ffigen.yaml +++ /dev/null @@ -1,27 +0,0 @@ -name: IsarCoreBindings -output: "lib/src/native/bindings.dart" -headers: - entry-points: - - "isar-dart.h" - include-directives: - - '**isar-dart.h' - -structs: - dependency-only: opaque - include: - - CObject - - CObjectSet - - CObjectCollectionSet - - CLink - - CLinkSet - - CObjectLinkSet - rename: - '^(?!C)(.*)': 'C$1' - -unions: - dependency-only: opaque - include: - - 'isar*' - -preamble: | - // ignore_for_file: camel_case_types, non_constant_identifier_names diff --git a/packages_external/isar-3.1.0-1/tool/generate_bindings.sh b/packages_external/isar-3.1.0-1/tool/generate_bindings.sh deleted file mode 100644 index 89241d5d..00000000 --- a/packages_external/isar-3.1.0-1/tool/generate_bindings.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/sh - -cargo install cbindgen - -cbindgen --config tool/cbindgen.toml --crate isar --output packages/isar/isar-dart.h - -cd packages/isar - -dart pub get -dart run ffigen --config ../../tool/ffigen.yaml -rm isar-dart.h - -dart format --fix lib/src/native/bindings.dart diff --git a/packages_external/isar-3.1.0-1/tool/prepare_tests.sh b/packages_external/isar-3.1.0-1/tool/prepare_tests.sh deleted file mode 100644 index 919d115e..00000000 --- a/packages_external/isar-3.1.0-1/tool/prepare_tests.sh +++ /dev/null @@ -1,6 +0,0 @@ -cd packages/isar_test - -flutter pub get -dart tool/generate_long_double_test.dart -dart tool/generate_all_tests.dart -flutter pub run build_runner build \ No newline at end of file From 671085d49105c1c680b5c0e305c9b6ecab9041b0 Mon Sep 17 00:00:00 2001 From: ZanderCowboy Date: Thu, 6 Mar 2025 02:19:57 +0200 Subject: [PATCH 07/25] complete a flutter upgrade and use community isar --- apps/multichoice/pubspec.yaml | 14 +++++++------- apps/multichoice/pubspec_overrides.yaml | 5 ----- packages/core/pubspec.yaml | 20 +++++++++++--------- packages/core/pubspec_overrides.yaml | 4 ---- packages/models/pubspec.yaml | 17 +++++++++++------ packages/models/pubspec_overrides.yaml | 5 ----- packages/theme/pubspec.yaml | 2 +- 7 files changed, 30 insertions(+), 37 deletions(-) diff --git a/apps/multichoice/pubspec.yaml b/apps/multichoice/pubspec.yaml index 6ca37aa6..e57785a6 100644 --- a/apps/multichoice/pubspec.yaml +++ b/apps/multichoice/pubspec.yaml @@ -8,15 +8,15 @@ environment: sdk: ">=3.3.0 <4.0.0" dependencies: - auto_route: ^9.2.2 - bloc: ^8.1.3 + auto_route: ^10.0.1 + bloc: ^9.0.0 core: ^0.0.1 - file_picker: ^8.0.5 + file_picker: ^9.0.2 firebase_core: ^3.0.0 flutter: sdk: flutter - flutter_bloc: ^8.1.4 - flutter_hooks: ^0.20.5 + flutter_bloc: ^9.1.0 + flutter_hooks: ^0.21.2 flutter_svg: ^2.0.10+1 flutter_svg_provider: ^1.0.7 gap: ^3.0.1 @@ -31,14 +31,14 @@ dependencies: path: plugins/window_size dev_dependencies: - auto_route_generator: ^9.0.0 + auto_route_generator: ^10.0.1 build_runner: ^2.4.8 flutter_gen_runner: ^5.5.0+1 flutter_test: sdk: flutter integration_test: sdk: flutter - very_good_analysis: ^6.0.0 + very_good_analysis: ^7.0.0 flutter: uses-material-design: true diff --git a/apps/multichoice/pubspec_overrides.yaml b/apps/multichoice/pubspec_overrides.yaml index b379a5e1..dcf73b58 100644 --- a/apps/multichoice/pubspec_overrides.yaml +++ b/apps/multichoice/pubspec_overrides.yaml @@ -1,13 +1,8 @@ -# melos_managed_dependency_overrides: isar,isar_flutter_libs # melos_managed_dependency_overrides: theme # melos_managed_dependency_overrides: core,models dependency_overrides: core: path: ../../packages/core - isar: - path: ..\\..\\packages_external\\isar-3.1.0-1\\packages\\isar - isar_flutter_libs: - path: ..\\..\\packages_external\\isar-3.1.0-1\\packages\\isar_flutter_libs models: path: ../../packages/models theme: diff --git a/packages/core/pubspec.yaml b/packages/core/pubspec.yaml index 2ad53158..ee1fb825 100644 --- a/packages/core/pubspec.yaml +++ b/packages/core/pubspec.yaml @@ -8,15 +8,17 @@ environment: flutter: ">=1.17.0" dependencies: - bloc: ^8.1.3 - file_picker: ^8.0.5 + bloc: ^9.0.0 + file_picker: ^9.0.2 flutter: sdk: flutter - flutter_bloc: ^8.1.4 - freezed_annotation: ^2.4.1 - get_it: ^7.6.4 + flutter_bloc: ^9.1.0 + freezed_annotation: ^3.0.0 + get_it: ^8.0.3 injectable: ^2.3.2 - isar: ^3.1.0+1 + isar: + version: ^3.1.8 + hosted: https://pub.isar-community.dev/ json_annotation: ^4.8.1 models: ^0.0.1 package_info_plus: ^8.0.0 @@ -26,15 +28,15 @@ dependencies: version: ^3.0.2 dev_dependencies: - bloc_test: ^9.1.7 + bloc_test: ^10.0.0 build_runner: ^2.4.8 flutter_test: sdk: flutter - freezed: ^2.4.5 + freezed: ^3.0.0-0.0.dev injectable_generator: ^2.4.1 json_serializable: ^6.7.1 mockito: ^5.4.4 - very_good_analysis: ^6.0.0 + very_good_analysis: ^7.0.0 global_options: freezed:freezed: diff --git a/packages/core/pubspec_overrides.yaml b/packages/core/pubspec_overrides.yaml index 78b7c961..ad19a73a 100644 --- a/packages/core/pubspec_overrides.yaml +++ b/packages/core/pubspec_overrides.yaml @@ -1,9 +1,5 @@ # melos_managed_dependency_overrides: isar_flutter_libs,isar # melos_managed_dependency_overrides: models dependency_overrides: - isar: - path: ..\\..\\packages_external\\isar-3.1.0-1\\packages\\isar - isar_flutter_libs: - path: ..\\..\\packages_external\\isar-3.1.0-1\\packages\\isar_flutter_libs models: path: ../models diff --git a/packages/models/pubspec.yaml b/packages/models/pubspec.yaml index 3a2ccb67..d1f9c15e 100644 --- a/packages/models/pubspec.yaml +++ b/packages/models/pubspec.yaml @@ -12,10 +12,13 @@ dependencies: auto_mappr_annotation: ^2.1.0 flutter: sdk: flutter - freezed_annotation: ^2.4.1 - isar: ^3.1.0+1 + freezed_annotation: ^3.0.0 + isar: + version: ^3.1.8 + hosted: https://pub.isar-community.dev/ isar_flutter_libs: - path: ../../packages_external/isar-3.1.0-1/packages/isar_flutter_libs + version: ^3.1.8 + hosted: https://pub.isar-community.dev/ json_annotation: ^4.8.1 path_provider: ^2.1.2 uuid: ^4.3.3 @@ -24,10 +27,12 @@ dev_dependencies: build_runner: ^2.4.8 flutter_test: sdk: flutter - freezed: ^2.4.5 - isar_generator: ^3.1.0+1 + freezed: ^3.0.0-0.0.dev + isar_generator: + version: ^3.1.8 + hosted: https://pub.isar-community.dev/ json_serializable: ^6.7.1 - very_good_analysis: ^6.0.0 + very_good_analysis: ^7.0.0 global_options: freezed:freezed: diff --git a/packages/models/pubspec_overrides.yaml b/packages/models/pubspec_overrides.yaml index 6ee3107b..37ad7582 100644 --- a/packages/models/pubspec_overrides.yaml +++ b/packages/models/pubspec_overrides.yaml @@ -1,6 +1 @@ -# melos_managed_dependency_overrides: isar,isar_flutter_libs dependency_overrides: - isar: - path: ..\\..\\packages_external\\isar-3.1.0-1\\packages\\isar - isar_flutter_libs: - path: ..\\..\\packages_external\\isar-3.1.0-1\\packages\\isar_flutter_libs diff --git a/packages/theme/pubspec.yaml b/packages/theme/pubspec.yaml index af4dcd33..4876e735 100644 --- a/packages/theme/pubspec.yaml +++ b/packages/theme/pubspec.yaml @@ -17,4 +17,4 @@ dev_dependencies: flutter_test: sdk: flutter theme_tailor: ^3.0.1 - very_good_analysis: ^6.0.0 + very_good_analysis: ^7.0.0 From 4be6c1b5f9984ea29a661473b2d2b02aa4095fe5 Mon Sep 17 00:00:00 2001 From: ZanderCowboy Date: Sat, 8 Mar 2025 18:52:06 +0200 Subject: [PATCH 08/25] clean up and linting issues --- apps/multichoice/integration_test/app_test.dart | 3 ++- .../presentation/shared/widgets/modals/delete_modal_test.dart | 1 + apps/multichoice/test/widget_test.dart | 1 - lib/main.dart | 1 - packages/core/pubspec.yaml | 2 +- packages/models/pubspec_overrides.yaml | 1 - test/widget_test.dart | 1 - 7 files changed, 4 insertions(+), 6 deletions(-) delete mode 100644 apps/multichoice/test/widget_test.dart delete mode 100644 lib/main.dart delete mode 100644 packages/models/pubspec_overrides.yaml delete mode 100644 test/widget_test.dart diff --git a/apps/multichoice/integration_test/app_test.dart b/apps/multichoice/integration_test/app_test.dart index 97329167..e0fda2c4 100644 --- a/apps/multichoice/integration_test/app_test.dart +++ b/apps/multichoice/integration_test/app_test.dart @@ -1,7 +1,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:integration_test/integration_test.dart'; -import 'package:multichoice/main.dart' as app; // Replace with your app import +import 'package:multichoice/main.dart' as app; import 'package:multichoice/presentation/shared/widgets/add_widgets/_base.dart'; void main() { @@ -30,6 +30,7 @@ void main() { await tester.pumpAndSettle(); var isVertical = true; + // Will still possibly be used. // ignore: unused_local_variable final layoutSwitch = Switch( value: isVertical, diff --git a/apps/multichoice/test/presentation/shared/widgets/modals/delete_modal_test.dart b/apps/multichoice/test/presentation/shared/widgets/modals/delete_modal_test.dart index 54e8ec20..76815077 100644 --- a/apps/multichoice/test/presentation/shared/widgets/modals/delete_modal_test.dart +++ b/apps/multichoice/test/presentation/shared/widgets/modals/delete_modal_test.dart @@ -90,6 +90,7 @@ void main() { (WidgetTester tester) async { // Track if the onConfirm callback is triggered var confirmPressed = false; + // Will still possibly be used. // ignore: unused_local_variable const cancelPressed = false; diff --git a/apps/multichoice/test/widget_test.dart b/apps/multichoice/test/widget_test.dart deleted file mode 100644 index ab73b3a2..00000000 --- a/apps/multichoice/test/widget_test.dart +++ /dev/null @@ -1 +0,0 @@ -void main() {} diff --git a/lib/main.dart b/lib/main.dart deleted file mode 100644 index ab73b3a2..00000000 --- a/lib/main.dart +++ /dev/null @@ -1 +0,0 @@ -void main() {} diff --git a/packages/core/pubspec.yaml b/packages/core/pubspec.yaml index 6a5f1f23..24246e17 100644 --- a/packages/core/pubspec.yaml +++ b/packages/core/pubspec.yaml @@ -32,7 +32,7 @@ dev_dependencies: build_runner: ^2.4.8 flutter_test: sdk: flutter - freezed: ^3.0.0-0.0.dev + freezed: ^2.4.5 injectable_generator: ^2.4.1 json_serializable: ^6.7.1 mockito: ^5.4.4 diff --git a/packages/models/pubspec_overrides.yaml b/packages/models/pubspec_overrides.yaml deleted file mode 100644 index 37ad7582..00000000 --- a/packages/models/pubspec_overrides.yaml +++ /dev/null @@ -1 +0,0 @@ -dependency_overrides: diff --git a/test/widget_test.dart b/test/widget_test.dart deleted file mode 100644 index ab73b3a2..00000000 --- a/test/widget_test.dart +++ /dev/null @@ -1 +0,0 @@ -void main() {} From 5596b5f55a65432f0ded77f0c5821ec86e1ce1dd Mon Sep 17 00:00:00 2001 From: ZanderCowboy Date: Sat, 8 Mar 2025 18:52:53 +0200 Subject: [PATCH 09/25] create and update docs; should still be finished --- README.md | 10 ++++++++++ apps/multichoice/{CHANGELOG.txt => CHANGELOG.md} | 11 +++++------ docs/explaining-the-bat-scripts.md | 0 docs/explaining-the-vscode-folder.md | 1 + docs/setting-up-integration-tests.md | 6 ++++++ 5 files changed, 22 insertions(+), 6 deletions(-) rename apps/multichoice/{CHANGELOG.txt => CHANGELOG.md} (93%) create mode 100644 docs/explaining-the-bat-scripts.md create mode 100644 docs/explaining-the-vscode-folder.md create mode 100644 docs/setting-up-integration-tests.md diff --git a/README.md b/README.md index b1c4f62f..52f5ffd9 100644 --- a/README.md +++ b/README.md @@ -75,3 +75,13 @@ ON PUSH - TO MAIN ## Errors and Fixes ### Android Gradle Upgrade + +## Configuration + +### config.yml + +Found in root. + +### Makefile + +Write about usage diff --git a/apps/multichoice/CHANGELOG.txt b/apps/multichoice/CHANGELOG.md similarity index 93% rename from apps/multichoice/CHANGELOG.txt rename to apps/multichoice/CHANGELOG.md index 37b28cc8..6838eae3 100644 --- a/apps/multichoice/CHANGELOG.txt +++ b/apps/multichoice/CHANGELOG.md @@ -1,13 +1,12 @@ -CHANGELOG +# CHANGELOG Setting up Integration Testing: -https://chatgpt.com/share/66fdf56f-3724-8004-9d18-5a52f68b20a7 + Create documentation - start cmd /k "run_integration_test.bat %* && call shutdown_emulator.bat && exit" - - +--- Version 0.3.0+140: - Added 'data_exchange_service' to import/export data - Update 'home_drawer', added assets and flutter_gen, and cleaned up code @@ -38,11 +37,11 @@ Version 0.1.4+124: - Moved `deleteAll` button to drawer and replaced with a `Search` button (not implemented yet) - Added SliverPadding to have initial padding around tabs, but falls away as user scrolls - +--- Version 0.1.4+119: - Added a change log - Added custom launcher icons - Designed a custom icon with drawio Version 0.1.4+117: -- Earlier version details \ No newline at end of file +- Earlier version details diff --git a/docs/explaining-the-bat-scripts.md b/docs/explaining-the-bat-scripts.md new file mode 100644 index 00000000..e69de29b diff --git a/docs/explaining-the-vscode-folder.md b/docs/explaining-the-vscode-folder.md new file mode 100644 index 00000000..7f851613 --- /dev/null +++ b/docs/explaining-the-vscode-folder.md @@ -0,0 +1 @@ +# `.vscode` folder diff --git a/docs/setting-up-integration-tests.md b/docs/setting-up-integration-tests.md new file mode 100644 index 00000000..1ea1505c --- /dev/null +++ b/docs/setting-up-integration-tests.md @@ -0,0 +1,6 @@ +# Integration Testing + +## How to run integration tests + +- Run `apps\multichoice\integration_test\app_test.dart` +- From 972c35d31d15b87e39a83a4b74201d963ae8cabe Mon Sep 17 00:00:00 2001 From: ZanderCowboy Date: Sat, 8 Mar 2025 19:12:22 +0200 Subject: [PATCH 10/25] revert changes to move to a new branch --- .config/dotnet-tools.json | 13 -- .github/workflows/_build-android-app.yml | 19 +-- .vscode/launch.json | 20 ---- .vscode/tasks.json | 14 --- README.md | 10 -- analysis_options.yaml | 3 - .../{CHANGELOG.md => CHANGELOG.txt} | 0 apps/multichoice/android/app/build.gradle | 5 +- docs/explaining-the-bat-scripts.md | 0 docs/explaining-the-vscode-folder.md | 1 - melos.yaml | 12 +- packages/core/pubspec_overrides.yaml | 1 - run_all.bat | 11 -- run_integration_test.bat | 112 ------------------ run_shutdown_emulator.bat | 28 ----- 15 files changed, 6 insertions(+), 243 deletions(-) delete mode 100644 .config/dotnet-tools.json delete mode 100644 .vscode/tasks.json rename apps/multichoice/{CHANGELOG.md => CHANGELOG.txt} (100%) delete mode 100644 docs/explaining-the-bat-scripts.md delete mode 100644 docs/explaining-the-vscode-folder.md delete mode 100644 run_all.bat delete mode 100644 run_integration_test.bat delete mode 100644 run_shutdown_emulator.bat diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json deleted file mode 100644 index 9d565f5e..00000000 --- a/.config/dotnet-tools.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "version": 1, - "isRoot": true, - "tools": { - "dotnet-reportgenerator-globaltool": { - "version": "5.3.10", - "commands": [ - "reportgenerator" - ], - "rollForward": false - } - } -} \ No newline at end of file diff --git a/.github/workflows/_build-android-app.yml b/.github/workflows/_build-android-app.yml index 354ff835..fb167324 100644 --- a/.github/workflows/_build-android-app.yml +++ b/.github/workflows/_build-android-app.yml @@ -105,23 +105,6 @@ jobs: name: ${{ inputs.build_artifact }} path: ./apps/multichoice/build/app/outputs/bundle/${{ inputs.environment_flag }}/app-${{ inputs.environment_flag }}.aab - # Generate a changelog based on the latest changes - - name: Install conventional-changelog - run: npm install -g conventional-changelog-cli - - - name: Generate Changelog - run: conventional-changelog -p angular -i CHANGELOG.md -s -r 1 - working-directory: apps/multichoice/ - - # Commit the updated changelog (optional) - - name: Commit Changelog - run: | - git config --global user.name "github-actions[bot]" - git config --global user.email "github-actions[bot]@users.noreply.github.com" - git add apps/multichoice/CHANGELOG.md - git commit -m "chore: update changelog [skip ci]" || echo "No changes to commit" - git push - - name: Upload artifact to Firebase App Distribution if: success() uses: wzieba/Firebase-Distribution-Github-Action@v1 @@ -130,5 +113,5 @@ jobs: serviceCredentialsFileContent: ${{secrets.CREDENTIAL_FILE_CONTENT}} groups: testers file: ./apps/multichoice/build/app/outputs/flutter-apk/app-${{ inputs.environment_flag }}.apk - releaseNotesFile: ./apps/multichoice/CHANGELOG.md + releaseNotesFile: ./apps/multichoice/CHANGELOG.txt debug: true diff --git a/.vscode/launch.json b/.vscode/launch.json index 5d26ddc2..66783dce 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -24,25 +24,5 @@ "flutterMode": "release", "program": "apps/multichoice/lib/main.dart" }, - // { - // "name": "Flutter Integration Test", - // "program": "test_driver/integration_test.dart", - // "request": "launch", - // "type": "dart", - // "args": [ - // "drive", - // "--driver", - // "test_driver/integration_test.dart", - // "--target", - // "integration_test/app_test.dart" - // ] - // }, - { - "name": "Run Integration Test with Emulator", - "type": "dart", - "request": "launch", - "program": "${workspaceFolder}/lib/main.dart", - "preLaunchTask": "Start Emulator and Run Integration Test" - } ] } \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json deleted file mode 100644 index b3dcef7d..00000000 --- a/.vscode/tasks.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "version": "2.0.0", - "tasks": [ - { - "label": "Start Emulator and Run Integration Test", - "type": "shell", - "command": "./run_integration_test.bat", - "problemMatcher": [], - "args": [ - "flutter_emulator" - ] - } - ] -} \ No newline at end of file diff --git a/README.md b/README.md index 52f5ffd9..b1c4f62f 100644 --- a/README.md +++ b/README.md @@ -75,13 +75,3 @@ ON PUSH - TO MAIN ## Errors and Fixes ### Android Gradle Upgrade - -## Configuration - -### config.yml - -Found in root. - -### Makefile - -Write about usage diff --git a/analysis_options.yaml b/analysis_options.yaml index ce4f6ac9..8d7b8dce 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -4,6 +4,3 @@ linter: rules: public_member_api_docs: false lines_longer_than_80_chars: false - analyzer: - exclude: - - packages_external/** diff --git a/apps/multichoice/CHANGELOG.md b/apps/multichoice/CHANGELOG.txt similarity index 100% rename from apps/multichoice/CHANGELOG.md rename to apps/multichoice/CHANGELOG.txt diff --git a/apps/multichoice/android/app/build.gradle b/apps/multichoice/android/app/build.gradle index 0903575a..bddacba4 100644 --- a/apps/multichoice/android/app/build.gradle +++ b/apps/multichoice/android/app/build.gradle @@ -42,9 +42,6 @@ android { targetSdk = flutter.targetSdkVersion versionCode = flutter.versionCode versionName = flutter.versionName - ndk { - debugSymbolLevel = 'FULL' - } } signingConfigs { @@ -60,7 +57,7 @@ android { release { signingConfig = signingConfigs.release ndk { - debugSymbolLevel = 'FULL' + debugSymbolLevel 'FULL' } } } diff --git a/docs/explaining-the-bat-scripts.md b/docs/explaining-the-bat-scripts.md deleted file mode 100644 index e69de29b..00000000 diff --git a/docs/explaining-the-vscode-folder.md b/docs/explaining-the-vscode-folder.md deleted file mode 100644 index 7f851613..00000000 --- a/docs/explaining-the-vscode-folder.md +++ /dev/null @@ -1 +0,0 @@ -# `.vscode` folder diff --git a/melos.yaml b/melos.yaml index 6afaf403..0997b9b2 100644 --- a/melos.yaml +++ b/melos.yaml @@ -2,7 +2,6 @@ name: multichoice packages: - packages/** - - packages_external/** - apps/** ignore: @@ -54,10 +53,9 @@ scripts: Run all tests available. run: | melos run test:core --no-select && melos run test:multichoice --no-select - # format_coverage --lcov --in coverage/lcov.info -b coverage/html - test:core: - run: flutter test -j 1 --coverage && reportgenerator.exe -reports:coverage/lcov.info -targetdir:coverage/html + test:core: + run: flutter test -j 1 exec: failFast: false concurrency: 1 @@ -67,8 +65,7 @@ scripts: scope: ["core"] test:multichoice: - run: flutter test -j 1 --coverage && reportgenerator.exe -reports:coverage/lcov.info -targetdir:coverage/html - + run: flutter test -j 1 --coverage exec: failFast: false concurrency: 1 @@ -78,8 +75,7 @@ scripts: scope: ["multichoice"] test:integration: - run: flutter test -j 1 --coverage && reportgenerator.exe -reports:coverage/lcov.info -targetdir:coverage/html - + run: flutter test -j 1 --coverage exec: failFast: false concurrency: 1 diff --git a/packages/core/pubspec_overrides.yaml b/packages/core/pubspec_overrides.yaml index ad19a73a..50b9fd24 100644 --- a/packages/core/pubspec_overrides.yaml +++ b/packages/core/pubspec_overrides.yaml @@ -1,4 +1,3 @@ -# melos_managed_dependency_overrides: isar_flutter_libs,isar # melos_managed_dependency_overrides: models dependency_overrides: models: diff --git a/run_all.bat b/run_all.bat deleted file mode 100644 index a7831ad8..00000000 --- a/run_all.bat +++ /dev/null @@ -1,11 +0,0 @@ -@echo off -setlocal - -:: Call the startup-test script to run the tests and capture emulator info -call run_integration_test.bat %* - -:: Call the shutdown script to close the emulator -call run_shutdown_emulator.bat - -endlocal -exit /b diff --git a/run_integration_test.bat b/run_integration_test.bat deleted file mode 100644 index 92025e22..00000000 --- a/run_integration_test.bat +++ /dev/null @@ -1,112 +0,0 @@ -@echo off -setlocal enabledelayedexpansion - -set EMULATOR_DEVICE="" -set EMULATOR_STARTED=0 - -:: Check if an emulator name is passed as a parameter -if "%1"=="" ( - echo No emulator name provided, listing available emulators... - - :: List available emulators, filter out unnecessary info - set EMULATOR_COUNT=0 - for /f "tokens=1" %%i in ('emulator -list-avds 2^>nul ^| findstr /v "INFO"') do ( - set /a EMULATOR_COUNT+=1 - echo [!EMULATOR_COUNT!] %%i - set EMULATOR_NAME_%%EMULATOR_COUNT%%=%%i - ) - - :: Check if any emulators were found - if !EMULATOR_COUNT! equ 0 ( - echo No emulators found. - exit /b 1 - ) - - :: Prompt the user to select an emulator - set /p EMULATOR_CHOICE="Enter the number of the emulator you want to use: " - - :: Validate the choice - if !EMULATOR_CHOICE! lss 1 ( - echo Invalid selection. - exit /b 1 - ) - if !EMULATOR_CHOICE! gtr !EMULATOR_COUNT! ( - echo Invalid selection. - exit /b 1 - ) - - for /L %%i in (1,1,%EMULATOR_COUNT%) do ( - if "!EMULATOR_CHOICE!"=="%%i" ( - set EMULATOR_NAME=!EMULATOR_NAME_%%i! - ) - ) - echo Emulator selected: !EMULATOR_NAME! - - if "!EMULATOR_NAME!"=="" ( - echo Invalid selection. - exit /b 1 - ) -) else ( - :: Use the provided emulator name - set EMULATOR_NAME=%1 -) - -:: Check if an Android device or emulator is already connected by filtering out desktop devices -set ANDROID_DEVICE_FOUND=0 -for /f "tokens=*" %%i in ('flutter devices ^| findstr /i "android" /i "mobile") do ( - echo %%i - set ANDROID_DEVICE_FOUND=1 -) - -echo Android device or emulator found: !ANDROID_DEVICE_FOUND! - -:: If no Android emulator or device is found, start the selected emulator -if !ANDROID_DEVICE_FOUND! equ 0 ( - echo No Android emulators or devices found. Starting emulator: !EMULATOR_NAME!... - start "" emulator -avd !EMULATOR_NAME! - set EMULATOR_STARTED=1 - echo Waiting for the emulator to start... - - :: Wait for the emulator to boot up - adb wait-for-device -) else ( - echo Android device or emulator is already connected. -) - -:: Check again to ensure the Android device or emulator is ready -set ANDROID_DEVICE_READY=0 -for /f "tokens=*" %%i in ('adb devices ^| findstr /i "device"') do ( - set ANDROID_DEVICE_READY=1 -) - -if !ANDROID_DEVICE_READY! equ 0 ( - echo No Android emulator or device found, exiting... - exit /b 1 -) - -:: Debugging info - print emulator startup status -echo Emulator started: !EMULATOR_STARTED! -echo Emulator device: !EMULATOR_NAME! - -:: Save emulator state to a temporary file for the shutdown script to use -( - echo EMULATOR_STARTED=!EMULATOR_STARTED! - echo EMULATOR_DEVICE=!EMULATOR_NAME! -) > tmp/emulator_state.txt - -:: Debugging: Ensure the file was written by printing its contents -echo Emulator state saved to file: -type tmp/emulator_state.txt - -:: Change directory to apps/multichoice -cd apps/multichoice - -:: Run the Flutter integration test -echo Running Flutter integration test... -flutter drive --driver=test_driver/integration_test.dart --target=integration_test/app_test.dart - -:: Return to the original directory -cd ../../ - -endlocal -exit /b diff --git a/run_shutdown_emulator.bat b/run_shutdown_emulator.bat deleted file mode 100644 index c3ddcd7f..00000000 --- a/run_shutdown_emulator.bat +++ /dev/null @@ -1,28 +0,0 @@ -@echo off -setlocal - -:: Read the emulator state from the temporary file -for /f "tokens=2 delims==" %%i in ('findstr "EMULATOR_STARTED" emulator_state.txt') do set EMULATOR_STARTED=%%i -for /f "tokens=2 delims==" %%i in ('findstr "EMULATOR_DEVICE" emulator_state.txt') do set EMULATOR_DEVICE=%%i - -:: Check if an emulator was started by the script -:: Check if any emulators are connected -for /f "tokens=1" %%i in ('adb devices ^| findstr /i "emulator"') do ( - echo Closing emulator %%i... - adb -s %%i emu kill -) - -:: Check if the script started an emulator -if "%EMULATOR_STARTED%"=="1" ( - echo Also closing the emulator %EMULATOR_DEVICE% started by this script... - adb -s %EMULATOR_DEVICE% emu kill -) else ( - echo No emulator explicitly started by this script. -) - - -:: Clean up the state file -del emulator_state.txt - -endlocal -exit /b From b6d3cdd3883a6e5034b725a82f4006ccf6cc905b Mon Sep 17 00:00:00 2001 From: ZanderCowboy <59666243+ZanderCowboy@users.noreply.github.com> Date: Sat, 8 Mar 2025 17:20:18 +0000 Subject: [PATCH 11/25] Bump pubspec version to '0.3.0+152' --- apps/multichoice/pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/multichoice/pubspec.yaml b/apps/multichoice/pubspec.yaml index 0997e23d..d4547287 100644 --- a/apps/multichoice/pubspec.yaml +++ b/apps/multichoice/pubspec.yaml @@ -2,7 +2,7 @@ name: multichoice description: "The application for the Multichoice repo" publish_to: "none" -version: 0.3.0+148 +version: 0.3.0+152 environment: sdk: ">=3.3.0 <4.0.0" From 574907a30ff17b014a48cf4b359271d790b46f68 Mon Sep 17 00:00:00 2001 From: ZanderCowboy <59666243+ZanderCowboy@users.noreply.github.com> Date: Wed, 12 Mar 2025 22:40:04 +0000 Subject: [PATCH 12/25] Bump pubspec version to '0.3.0+153' --- apps/multichoice/pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/multichoice/pubspec.yaml b/apps/multichoice/pubspec.yaml index 4f26bd7c..5e94072b 100644 --- a/apps/multichoice/pubspec.yaml +++ b/apps/multichoice/pubspec.yaml @@ -2,7 +2,7 @@ name: multichoice description: "The application for the Multichoice repo" publish_to: "none" -version: 0.3.0+152 +version: 0.3.0+153 environment: sdk: ">=3.3.0 <4.0.0" From 40908bb95c1bdd0e9993f649c81bf08d51bba2ca Mon Sep 17 00:00:00 2001 From: ZanderCowboy <59666243+ZanderCowboy@users.noreply.github.com> Date: Sat, 31 May 2025 11:00:43 +0000 Subject: [PATCH 13/25] Bump pubspec version to '0.3.0+159' --- apps/multichoice/pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/multichoice/pubspec.yaml b/apps/multichoice/pubspec.yaml index d6b35d5e..d4d4d06f 100644 --- a/apps/multichoice/pubspec.yaml +++ b/apps/multichoice/pubspec.yaml @@ -2,7 +2,7 @@ name: multichoice description: "The application for the Multichoice repo" publish_to: "none" -version: 0.3.0+158 +version: 0.3.0+159 environment: sdk: ">=3.3.0 <4.0.0" From 300400a7d100fe1c68688521ef21747c28a60744 Mon Sep 17 00:00:00 2001 From: ZanderCowboy Date: Sat, 31 May 2025 13:02:09 +0200 Subject: [PATCH 14/25] chore: import change --- .../integration_test/app_test.dart | 18 --------------- .../widgets/add_widgets/entry_test.dart | 2 +- .../shared/widgets/add_widgets/tab_test.dart | 6 ----- .../widgets/modals/delete_modal_test.dart | 3 --- .../test/services/database_service_test.dart | 23 +++---------------- 5 files changed, 4 insertions(+), 48 deletions(-) diff --git a/apps/multichoice/integration_test/app_test.dart b/apps/multichoice/integration_test/app_test.dart index e0fda2c4..aa305b5d 100644 --- a/apps/multichoice/integration_test/app_test.dart +++ b/apps/multichoice/integration_test/app_test.dart @@ -8,20 +8,16 @@ void main() { IntegrationTestWidgetsFlutterBinding.ensureInitialized(); testWidgets('Test counter increment', (WidgetTester tester) async { - // Launch the app app.main(); await tester.pumpAndSettle(const Duration(seconds: 5)); - // Verify initial value is 0 expect(find.text('Permission Required'), findsOneWidget); expect(find.text('Deny'), findsOneWidget); expect(find.text('Open Settings'), findsOneWidget); - // Tap the "+" button await tester.tap(find.text('Deny')); await tester.pumpAndSettle(); - // Verify the counter has incremented expect(find.byIcon(Icons.add_outlined), findsOneWidget); expect(find.byType(AddTabCard), findsOneWidget); @@ -29,17 +25,7 @@ void main() { await tester.tap(find.byIcon(Icons.settings_outlined)); await tester.pumpAndSettle(); - var isVertical = true; - // Will still possibly be used. - // ignore: unused_local_variable - final layoutSwitch = Switch( - value: isVertical, - onChanged: (bool value) { - isVertical = value; - }, - ); expect(find.text('Horizontal/Vertical Layout'), findsOneWidget); - // expect(find.byWidget(layoutSwitch), findsOneWidget); expect(find.byKey(const Key('layoutSwitch')), findsOneWidget); await tester.tap(find.byKey(const Key('layoutSwitch'))); await tester.pumpAndSettle(); @@ -71,9 +57,5 @@ void main() { await tester.tap(find.byIcon(Icons.search_outlined)); await tester.pumpAndSettle(); expect(find.textContaining('not been implemented'), findsOneWidget); - - // await tester.tap(find.text('Cancel')); - // await tester.pumpAndSettle(); - // expect(find.text('Open Modal'), findsOneWidget); }); } diff --git a/apps/multichoice/test/presentation/shared/widgets/add_widgets/entry_test.dart b/apps/multichoice/test/presentation/shared/widgets/add_widgets/entry_test.dart index 18fc61d5..535342b1 100644 --- a/apps/multichoice/test/presentation/shared/widgets/add_widgets/entry_test.dart +++ b/apps/multichoice/test/presentation/shared/widgets/add_widgets/entry_test.dart @@ -2,7 +2,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:multichoice/presentation/shared/widgets/add_widgets/_base.dart'; -import '../../../../helpers/widget_wrapper.dart'; +import '../../../../helpers/export.dart'; void main() { testWidgets('AddEntryCard renders correctly and responds to tap', diff --git a/apps/multichoice/test/presentation/shared/widgets/add_widgets/tab_test.dart b/apps/multichoice/test/presentation/shared/widgets/add_widgets/tab_test.dart index 98916668..7ba49d7a 100644 --- a/apps/multichoice/test/presentation/shared/widgets/add_widgets/tab_test.dart +++ b/apps/multichoice/test/presentation/shared/widgets/add_widgets/tab_test.dart @@ -32,13 +32,7 @@ void main() { final cardWidget = tester.widget(find.byType(Card)); expect(cardWidget.color, equals(testColor)); - // debugDumpApp(); final sizedBox = tester.widget( - // find.descendant( - // of: find.byType(Padding), - // matching: find.byType(SizedBox), - // matchRoot: true, - // ), find.byKey(const Key('AddTabSizedBox')), ); diff --git a/apps/multichoice/test/presentation/shared/widgets/modals/delete_modal_test.dart b/apps/multichoice/test/presentation/shared/widgets/modals/delete_modal_test.dart index effec6bc..6738e011 100644 --- a/apps/multichoice/test/presentation/shared/widgets/modals/delete_modal_test.dart +++ b/apps/multichoice/test/presentation/shared/widgets/modals/delete_modal_test.dart @@ -75,9 +75,6 @@ void main() { testWidgets('deleteModal displays correctly and handles actions', (WidgetTester tester) async { var confirmPressed = false; - // Will still possibly be used. - // ignore: unused_local_variable - const cancelPressed = false; await tester.pumpWidget( MaterialApp( diff --git a/packages/core/test/services/database_service_test.dart b/packages/core/test/services/database_service_test.dart index 9d042872..debf987f 100644 --- a/packages/core/test/services/database_service_test.dart +++ b/packages/core/test/services/database_service_test.dart @@ -2,27 +2,10 @@ import 'package:flutter_test/flutter_test.dart'; void main() { group('DatabaseService Tests', () { - test('Singleton instance should be the same', () { - // final instance1 = DatabaseService.instance; - // final instance2 = DatabaseService.instance; + test('Singleton instance should be the same', () {}); - // expect(instance1, same(instance2)); - }); + test('Initial database should be empty', () {}); - test('Initial database should be empty', () { - // final instance = DatabaseService.instance; - - // expect(instance.database, isEmpty); - }); - - test('Adding entries to the database', () { - // final instance = DatabaseService.instance; - // final tab = Tabs.empty(); // Replace with actual tab - // final entry = Entry.empty(); // Replace with actual Entry - - // instance.database[tab] = [entry]; - - // expect(instance.database[tab], contains(entry)); - }); + test('Adding entries to the database', () {}); }); } From 3a943f89c26105e93a54bbbcfa7ec355788a9d50 Mon Sep 17 00:00:00 2001 From: ZanderCowboy <59666243+ZanderCowboy@users.noreply.github.com> Date: Sat, 31 May 2025 11:09:43 +0000 Subject: [PATCH 15/25] Bump pubspec version to '0.3.0+160' --- apps/multichoice/pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/multichoice/pubspec.yaml b/apps/multichoice/pubspec.yaml index d4d4d06f..c440734d 100644 --- a/apps/multichoice/pubspec.yaml +++ b/apps/multichoice/pubspec.yaml @@ -2,7 +2,7 @@ name: multichoice description: "The application for the Multichoice repo" publish_to: "none" -version: 0.3.0+159 +version: 0.3.0+160 environment: sdk: ">=3.3.0 <4.0.0" From 96ee9bff3679ca4ed253c31e0837cf8973b32de7 Mon Sep 17 00:00:00 2001 From: ZanderCowboy Date: Sat, 31 May 2025 14:42:03 +0200 Subject: [PATCH 16/25] chore: update docs --- apps/multichoice/CHANGELOG.txt | 4 +- docs/setting-up-integration-tests.md | 157 ++++++++++++++++++++++++++- 2 files changed, 155 insertions(+), 6 deletions(-) diff --git a/apps/multichoice/CHANGELOG.txt b/apps/multichoice/CHANGELOG.txt index 763255b2..599202dd 100644 --- a/apps/multichoice/CHANGELOG.txt +++ b/apps/multichoice/CHANGELOG.txt @@ -1,9 +1,7 @@ # CHANGELOG Setting up Integration Testing: - -Create documentation - +- Create documentation (refer to `docs/setting-up-integration-tests.md`) - start cmd /k "run_integration_test.bat %* && call shutdown_emulator.bat && exit" --- diff --git a/docs/setting-up-integration-tests.md b/docs/setting-up-integration-tests.md index 1ea1505c..891868e2 100644 --- a/docs/setting-up-integration-tests.md +++ b/docs/setting-up-integration-tests.md @@ -1,6 +1,157 @@ -# Integration Testing +# Flutter Integration Test Automation on Windows (for Android) + +This guide explains how to: + +* Set up Flutter integration testing for a mobile app. +* Automatically detect whether an Android emulator is running. +* Start an emulator if none is running. +* Run integration tests using `flutter drive`. +* Avoid launching desktop/web devices like Chrome, Edge, or Windows. + +--- ## How to run integration tests -- Run `apps\multichoice\integration_test\app_test.dart` -- +- Run `apps/multichoice/integration_test/app_test.dart` + +## 1. Prerequisites + +* Flutter SDK installed and properly configured. +* Android Studio installed with at least one virtual device (AVD) created. +* Java installed (used by Android tools). +* A Flutter app with `integration_test` and `test_driver` folders set up. +* Windows system with access to Command Prompt or PowerShell. + +--- + +## 2. File & Folder Structure + +Ensure the following paths exist in your project: + +* `apps/multichoice/test_driver/integration_test.dart` +* `apps/multichoice/integration_test/app_test.dart` + +These are required by your integration test. + +--- + +## 3. Custom Batch Script: `run_integration_test.bat` + +This script: + +* Checks for connected Android devices/emulators. +* Ignores non-mobile devices (like Chrome or Windows). +* Starts the first available emulator if none is running. +* Runs the `flutter drive` test command for integration. + +Place the following script in your project root as `run_integration_test.bat`: + +```batch +@echo off + +:: Check if an Android device or emulator is running +flutter devices | findstr /C:"No devices" >nul +if %errorlevel%==0 ( + echo No devices found. Starting emulator... + + :: Get the first available Android emulator + for /f "tokens=*" %%i in ('emulator -list-avds') do ( + set EMULATOR_NAME=%%i + goto :start_emulator + ) + + echo No emulator found. Please create one in Android Studio. + exit /b 1 + + :start_emulator + echo Starting emulator %EMULATOR_NAME%... + start emulator -avd %EMULATOR_NAME% + + :: Wait for it to be fully online + echo Waiting for emulator to start... + adb wait-for-device +) else ( + :: Check if a mobile (Android) device is connected + flutter devices | findstr /C:"android" >nul + if %errorlevel%==1 ( + echo No Android devices or emulators found. Starting an emulator... + + for /f "tokens=*" %%i in ('emulator -list-avds') do ( + set EMULATOR_NAME=%%i + goto :start_emulator + ) + + echo No emulator found. Please create one in Android Studio. + exit /b 1 + ) else ( + echo Android device or emulator already connected. + ) +) + +:: Run integration test +echo Running Flutter integration test... +flutter drive --driver=apps/multichoice/test_driver/integration_test.dart --target=apps/multichoice/integration_test/app_test.dart +``` + +--- + +## 4. Add Android Emulator to System PATH + +### Problem + +If you get the error: + +```text +'emulator' is not recognized as an internal or external command, +operable program or batch file. +``` + +### Solution + +Add the following paths to your Windows system PATH: + +* `C:\Users\YourUsername\AppData\Local\Android\Sdk\emulator` +* `C:\Users\YourUsername\AppData\Local\Android\Sdk\platform-tools` + +### Steps + +1. Open Control Panel → System → Advanced system settings → Environment Variables. +2. Under System Variables, select `Path` → Edit → Add the above directories. +3. Restart your terminal. + +### Verify + +* Run `emulator -list-avds` to see available emulators. +* Run `adb devices` to confirm devices are connected. + +--- + +## 5. Usage + +Open Command Prompt or PowerShell and run: + +```batch +run_integration_test.bat +``` + +It will: + +* Detect running Android devices or emulators. +* Start one if needed. +* Run your `flutter drive` integration test. + +--- + +## 6. Gotchas + +* Emulator must exist (create one via Android Studio → Tools → AVD Manager). +* If only Chrome, Edge, or Windows devices are detected, they will be ignored. +* Emulators may take time to boot up on first launch. +* Integration tests must be run using `flutter drive`, not `flutter run`. +* This script assumes Android-only testing (not desktop/web). + +--- + +## 7. Optional: VS Code Integration + +You can run the batch script from a VS Code launch configuration using `preLaunchTask`. Ask for setup details if needed. From 6e7257b46e0ec1757d9b8c39640f386f02f66f99 Mon Sep 17 00:00:00 2001 From: ZanderCowboy Date: Sat, 31 May 2025 14:42:23 +0200 Subject: [PATCH 17/25] chore: add tasks.json --- .vscode/tasks.json | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 .vscode/tasks.json diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 00000000..6254ab7b --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,35 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "label": "Flutter Integration Test", + "type": "shell", + "command": "flutter", + "args": [ + "drive", + "--target=apps/multichoice/test_driver/integration_test.dart" + ], + "group": "test", + "problemMatcher": [] + }, + { + "label": "Uninstall App", + "type": "shell", + "command": "adb", + "args": [ + "uninstall", + "co.za.zanderkotze.multichoice" + ], + "problemMatcher": [] + }, + { + "label": "Uninstall and Run Integration Test", + "dependsOn": [ + "Uninstall App", + "Flutter Integration Test" + ], + "dependsOrder": "sequence", + "group": "test" + } + ] +} \ No newline at end of file From a1afc4af240bf4b9a61c1d0562d32f0d6bc92bf5 Mon Sep 17 00:00:00 2001 From: ZanderCowboy Date: Sat, 31 May 2025 14:42:33 +0200 Subject: [PATCH 18/25] chore: PR comments --- .vscode/test_launch.json | 2 +- .../integration_test/app_test.dart | 32 +++++++++++++++---- .../lib/app/engine/widget_keys.dart | 1 + .../lib/presentation/drawer/home_drawer.dart | 14 ++++---- .../widgets/_light_dark_mode_button.dart | 1 + 5 files changed, 35 insertions(+), 15 deletions(-) diff --git a/.vscode/test_launch.json b/.vscode/test_launch.json index 9eaed37b..ad10d644 100644 --- a/.vscode/test_launch.json +++ b/.vscode/test_launch.json @@ -6,7 +6,7 @@ "request": "launch", "type": "dart", "program": "apps/multichoice/test_driver/integration_test.dart", - "preLaunchTask": "flutter drive --target=apps/multichoice/test_driver/integration_test.dart" + "preLaunchTask": "Flutter Integration Test" } ] } \ No newline at end of file diff --git a/apps/multichoice/integration_test/app_test.dart b/apps/multichoice/integration_test/app_test.dart index aa305b5d..ec78ac44 100644 --- a/apps/multichoice/integration_test/app_test.dart +++ b/apps/multichoice/integration_test/app_test.dart @@ -1,48 +1,54 @@ import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:integration_test/integration_test.dart'; +import 'package:multichoice/app/export.dart'; import 'package:multichoice/main.dart' as app; import 'package:multichoice/presentation/shared/widgets/add_widgets/_base.dart'; void main() { IntegrationTestWidgetsFlutterBinding.ensureInitialized(); + final keys = WidgetKeys.instance; testWidgets('Test counter increment', (WidgetTester tester) async { app.main(); - await tester.pumpAndSettle(const Duration(seconds: 5)); + // Wait for the app to settle + await tester.pumpAndSettle(const Duration(seconds: 2)); + // Verify a Permission Required dialog appears expect(find.text('Permission Required'), findsOneWidget); expect(find.text('Deny'), findsOneWidget); expect(find.text('Open Settings'), findsOneWidget); - await tester.tap(find.text('Deny')); await tester.pumpAndSettle(); + // On Home Screen - Verify Add Tab Card expect(find.byIcon(Icons.add_outlined), findsOneWidget); expect(find.byType(AddTabCard), findsOneWidget); + // Open Settings Drawer - Test Layout Switch expect(find.byIcon(Icons.settings_outlined), findsOneWidget); await tester.tap(find.byIcon(Icons.settings_outlined)); await tester.pumpAndSettle(); - expect(find.text('Horizontal/Vertical Layout'), findsOneWidget); - expect(find.byKey(const Key('layoutSwitch')), findsOneWidget); - await tester.tap(find.byKey(const Key('layoutSwitch'))); + expect(find.byKey(keys.layoutSwitch), findsOneWidget); + await tester.tap(find.byKey(keys.layoutSwitch)); await tester.pumpAndSettle(); - expect(find.byIcon(Icons.close_outlined), findsOneWidget); await tester.tap(find.byIcon(Icons.close_outlined)); await tester.pumpAndSettle(); + // On Home Screen - Add New Tab expect(find.byIcon(Icons.add_outlined), findsOneWidget); expect(find.byType(AddTabCard), findsOneWidget); await tester.tap(find.byType(AddTabCard)); await tester.pumpAndSettle(); + // Add New Tab Dialog expect(find.text('Add New Tab'), findsOneWidget); expect(find.text('Cancel'), findsOneWidget); expect(find.text('Add'), findsOneWidget); + // Enter Tab Data expect(find.byType(TextFormField), findsExactly(2)); await tester.enterText(find.byType(TextFormField).first, 'Tab 1'); await tester.enterText(find.byType(TextFormField).last, 'Tab 2'); @@ -54,6 +60,20 @@ void main() { expect(find.text('Tab 1'), findsOneWidget); + // Open Settings Drawer - Test Light/Dark Mode + await tester.tap(find.byIcon(Icons.settings_outlined)); + await tester.pumpAndSettle(); + expect(find.text('Light / Dark Mode'), findsOneWidget); + expect(find.byKey(keys.lightDarkModeSwitch), findsOneWidget); + await tester.tap(find.byKey(keys.lightDarkModeSwitch)); + await tester.pumpAndSettle(); + expect(find.text('Tab 1'), findsOneWidget); + expect(find.byType(AddTabCard), findsOneWidget); + final BuildContext context = tester.element(find.byType(AddTabCard)); + final theme = Theme.of(context); + expect(theme.brightness, Brightness.dark); + + // On Home Screen await tester.tap(find.byIcon(Icons.search_outlined)); await tester.pumpAndSettle(); expect(find.textContaining('not been implemented'), findsOneWidget); diff --git a/apps/multichoice/lib/app/engine/widget_keys.dart b/apps/multichoice/lib/app/engine/widget_keys.dart index 988b2b83..2db2b72b 100644 --- a/apps/multichoice/lib/app/engine/widget_keys.dart +++ b/apps/multichoice/lib/app/engine/widget_keys.dart @@ -7,6 +7,7 @@ class WidgetKeys { final deleteModalTitle = const Key('DeleteModalTitle'); final layoutSwitch = const Key('LayoutSwitch'); + final lightDarkModeSwitch = const Key('LightDarkSwitch'); final addTabSizedBox = const Key('AddTabSizedBox'); } diff --git a/apps/multichoice/lib/presentation/drawer/home_drawer.dart b/apps/multichoice/lib/presentation/drawer/home_drawer.dart index cd88c8d9..68cdb1db 100644 --- a/apps/multichoice/lib/presentation/drawer/home_drawer.dart +++ b/apps/multichoice/lib/presentation/drawer/home_drawer.dart @@ -58,15 +58,13 @@ class HomeDrawer extends StatelessWidget { physics: const NeverScrollableScrollPhysics(), children: [ const _LightDarkModeButton(), - ListTile( + SwitchListTile( + key: context.keys.layoutSwitch, title: const Text('Horizontal/Vertical Layout'), - trailing: Switch( - key: context.keys.layoutSwitch, - value: context.watch().appLayout, - onChanged: (value) { - context.read().appLayout = value; - }, - ), + value: context.watch().appLayout, + onChanged: (value) { + context.read().appLayout = value; + }, ), ListTile( title: const Text('Delete All Data'), diff --git a/apps/multichoice/lib/presentation/drawer/widgets/_light_dark_mode_button.dart b/apps/multichoice/lib/presentation/drawer/widgets/_light_dark_mode_button.dart index 33440297..1c1f2728 100644 --- a/apps/multichoice/lib/presentation/drawer/widgets/_light_dark_mode_button.dart +++ b/apps/multichoice/lib/presentation/drawer/widgets/_light_dark_mode_button.dart @@ -13,6 +13,7 @@ class _LightDarkModeButton extends HookWidget { final isDark = useState(isDarkMode); return SwitchListTile( + key: context.keys.lightDarkModeSwitch, title: const Text('Light / Dark Mode'), value: isDark.value, activeThumbImage: AssetImage(Assets.images.sleepMode.path), From be37a4bacacf8ea209c09996f79d12b35c181193 Mon Sep 17 00:00:00 2001 From: ZanderCowboy <59666243+ZanderCowboy@users.noreply.github.com> Date: Sat, 31 May 2025 12:49:55 +0000 Subject: [PATCH 19/25] Bump pubspec version to '0.3.0+161' --- apps/multichoice/pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/multichoice/pubspec.yaml b/apps/multichoice/pubspec.yaml index c440734d..f9c02a92 100644 --- a/apps/multichoice/pubspec.yaml +++ b/apps/multichoice/pubspec.yaml @@ -2,7 +2,7 @@ name: multichoice description: "The application for the Multichoice repo" publish_to: "none" -version: 0.3.0+160 +version: 0.3.0+161 environment: sdk: ">=3.3.0 <4.0.0" From d87fef16b052dc61497de6422fc486d4fbb3c30a Mon Sep 17 00:00:00 2001 From: ZanderCowboy Date: Sat, 31 May 2025 14:57:13 +0200 Subject: [PATCH 20/25] fix sonarcloud workflow issue --- .github/workflows/_build-android-app.yml | 2 +- .github/workflows/sonarcloud.yml | 20 ++++++++++++++++---- CHANGELOG.md | 6 ++++++ 3 files changed, 23 insertions(+), 5 deletions(-) create mode 100644 CHANGELOG.md diff --git a/.github/workflows/_build-android-app.yml b/.github/workflows/_build-android-app.yml index f0b181e3..4af81f3d 100644 --- a/.github/workflows/_build-android-app.yml +++ b/.github/workflows/_build-android-app.yml @@ -113,5 +113,5 @@ jobs: serviceCredentialsFileContent: ${{secrets.CREDENTIAL_FILE_CONTENT}} groups: testers file: ./apps/multichoice/build/app/outputs/flutter-apk/app-${{ inputs.environment_flag }}.apk - releaseNotesFile: ./apps/multichoice/CHANGELOG.txt + releaseNotesFile: ./CHANGELOG.md debug: true diff --git a/.github/workflows/sonarcloud.yml b/.github/workflows/sonarcloud.yml index 6f0ad6f1..71755513 100644 --- a/.github/workflows/sonarcloud.yml +++ b/.github/workflows/sonarcloud.yml @@ -59,14 +59,26 @@ jobs: - name: Run tests and generate coverage run: melos coverage:core - - name: Aggregate coverage report + - name: Format app coverage run: | flutter pub global activate coverage flutter pub global run coverage:format_coverage \ --lcov \ - --in=packages/core/coverage \ - --out=coverage/lcov.info \ - --report-on=apps/multichoice/lib,packages/core/lib + --in=apps/multichoice/coverage/lcov.info \ + --out=coverage/app_lcov.info \ + --report-on=apps/multichoice/lib + + - name: Format core coverage + run: | + flutter pub global run coverage:format_coverage \ + --lcov \ + --in=packages/core/coverage/lcov.info \ + --out=coverage/core_lcov.info \ + --report-on=packages/core/lib + + - name: Merge coverage reports + run: | + cat coverage/app_lcov.info coverage/core_lcov.info > coverage/lcov.info # if requied, change 'Aggregate coverage report' with 'Move coverage report' # - name: Move coverage report diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 00000000..d71ebf88 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,6 @@ +# Set up integration tests + +- Add integration tests +- Setup integration tests +- Add tasks.json file +- Update _build-android-app file to use this ROOT changelog From 783ca0aac479ab4e9832d8d9c8fc3174c66836a6 Mon Sep 17 00:00:00 2001 From: ZanderCowboy Date: Sat, 31 May 2025 15:08:22 +0200 Subject: [PATCH 21/25] chore: update melos and sonarcloud to use correct scripts --- .github/workflows/sonarcloud.yml | 16 ++++++---------- melos.yaml | 20 ++++++++++++++++++-- 2 files changed, 24 insertions(+), 12 deletions(-) diff --git a/.github/workflows/sonarcloud.yml b/.github/workflows/sonarcloud.yml index 71755513..9fa90eaf 100644 --- a/.github/workflows/sonarcloud.yml +++ b/.github/workflows/sonarcloud.yml @@ -57,14 +57,16 @@ jobs: uses: ./.github/actions/setup-java-flutter - name: Run tests and generate coverage - run: melos coverage:core + run: melos coverage:all + + - name: Install coverage tool + run: flutter pub global activate coverage - - name: Format app coverage + - name: Format Multichoice coverage run: | - flutter pub global activate coverage flutter pub global run coverage:format_coverage \ --lcov \ - --in=apps/multichoice/coverage/lcov.info \ + --in=apps\multichoice\coverage\lcov.info \ --out=coverage/app_lcov.info \ --report-on=apps/multichoice/lib @@ -80,12 +82,6 @@ jobs: run: | cat coverage/app_lcov.info coverage/core_lcov.info > coverage/lcov.info - # if requied, change 'Aggregate coverage report' with 'Move coverage report' - # - name: Move coverage report - # run: | - # mkdir -p coverage - # cp packages/core/coverage/lcov.info coverage/lcov.info - - name: Analyze with SonarCloud uses: SonarSource/sonarcloud-github-action@master env: diff --git a/melos.yaml b/melos.yaml index 649d94c7..96ea31d8 100644 --- a/melos.yaml +++ b/melos.yaml @@ -84,7 +84,13 @@ scripts: flutter: true scope: ["integration"] - coverage:core: + coverage:all: + description: | + Run all tests and generate coverage reports. + run: | + melos run coverage:core --no-select && melos run coverage:multichoice --no-select + + coverage:integration: run: flutter test -j 1 --coverage exec: failFast: true @@ -94,6 +100,16 @@ scripts: flutter: true scope: ["integration"] + coverage:core: + run: flutter test -j 1 --coverage + exec: + failFast: true + concurrency: 1 + orderDependents: true + packageFilters: + flutter: true + scope: ["core"] + coverage:multichoice: run: flutter test -j 1 --coverage exec: @@ -102,7 +118,7 @@ scripts: orderDependents: true packageFilters: flutter: true - scope: "core" + scope: ["multichoice"] coverage:multichoice:windows: run: flutter test -j 1 --coverage && perl "C:\\ProgramData\\chocolatey\\lib\\lcov\\tools\\bin\\genhtml" --no-function-coverage -o coverage\html coverage\lcov.info && start coverage\html\index.html From 8ace6e62bad55d4e40a56728cee850924c3a5a74 Mon Sep 17 00:00:00 2001 From: ZanderCowboy Date: Sat, 31 May 2025 15:15:01 +0200 Subject: [PATCH 22/25] sonarcloud issue --- .github/workflows/sonarcloud.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/sonarcloud.yml b/.github/workflows/sonarcloud.yml index 9fa90eaf..ba1121da 100644 --- a/.github/workflows/sonarcloud.yml +++ b/.github/workflows/sonarcloud.yml @@ -66,7 +66,7 @@ jobs: run: | flutter pub global run coverage:format_coverage \ --lcov \ - --in=apps\multichoice\coverage\lcov.info \ + --in=apps/multichoice/coverage/lcov.info \ --out=coverage/app_lcov.info \ --report-on=apps/multichoice/lib From c0d7bcac88d1c73286914637745e624b069c3ef2 Mon Sep 17 00:00:00 2001 From: ZanderCowboy <59666243+ZanderCowboy@users.noreply.github.com> Date: Sat, 31 May 2025 13:23:02 +0000 Subject: [PATCH 23/25] Bump pubspec version to '0.3.0+162' --- apps/multichoice/pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/multichoice/pubspec.yaml b/apps/multichoice/pubspec.yaml index f9c02a92..a8b7c638 100644 --- a/apps/multichoice/pubspec.yaml +++ b/apps/multichoice/pubspec.yaml @@ -2,7 +2,7 @@ name: multichoice description: "The application for the Multichoice repo" publish_to: "none" -version: 0.3.0+161 +version: 0.3.0+162 environment: sdk: ">=3.3.0 <4.0.0" From b12c096da30c48f82a4f775eb3b6bec1778faa36 Mon Sep 17 00:00:00 2001 From: ZanderCowboy Date: Sat, 31 May 2025 16:05:09 +0200 Subject: [PATCH 24/25] sonarcloud issue --- .github/workflows/sonarcloud.yml | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/.github/workflows/sonarcloud.yml b/.github/workflows/sonarcloud.yml index ba1121da..89a1987c 100644 --- a/.github/workflows/sonarcloud.yml +++ b/.github/workflows/sonarcloud.yml @@ -59,28 +59,16 @@ jobs: - name: Run tests and generate coverage run: melos coverage:all - - name: Install coverage tool - run: flutter pub global activate coverage - - - name: Format Multichoice coverage - run: | - flutter pub global run coverage:format_coverage \ - --lcov \ - --in=apps/multichoice/coverage/lcov.info \ - --out=coverage/app_lcov.info \ - --report-on=apps/multichoice/lib - - - name: Format core coverage + - name: Debug coverage files run: | - flutter pub global run coverage:format_coverage \ - --lcov \ - --in=packages/core/coverage/lcov.info \ - --out=coverage/core_lcov.info \ - --report-on=packages/core/lib + ls -la apps/multichoice/coverage/ + ls -la packages/core/coverage/ - name: Merge coverage reports run: | - cat coverage/app_lcov.info coverage/core_lcov.info > coverage/lcov.info + mkdir -p coverage + cat apps/multichoice/coverage/lcov.info packages/core/coverage/lcov.info > coverage/lcov.info + cat coverage/lcov.info - name: Analyze with SonarCloud uses: SonarSource/sonarcloud-github-action@master From 674c79d600c99f73f696f4b5488441421c91fe6f Mon Sep 17 00:00:00 2001 From: ZanderCowboy <59666243+ZanderCowboy@users.noreply.github.com> Date: Sat, 31 May 2025 14:13:17 +0000 Subject: [PATCH 25/25] Bump pubspec version to '0.3.0+163' --- apps/multichoice/pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/multichoice/pubspec.yaml b/apps/multichoice/pubspec.yaml index a8b7c638..1b82deb7 100644 --- a/apps/multichoice/pubspec.yaml +++ b/apps/multichoice/pubspec.yaml @@ -2,7 +2,7 @@ name: multichoice description: "The application for the Multichoice repo" publish_to: "none" -version: 0.3.0+162 +version: 0.3.0+163 environment: sdk: ">=3.3.0 <4.0.0"