diff --git a/.github/actions/setup-runner/action.yml b/.github/actions/setup-runner/action.yml new file mode 100644 index 000000000..9948f0a5d --- /dev/null +++ b/.github/actions/setup-runner/action.yml @@ -0,0 +1,87 @@ +name: Setup runner +description: Setup the runner with the necessary tools and dependencies. + +inputs: + flutter-version: + description: Flutter version to use. + default: stable + cache-key: + description: Cache key to use for restoring and saving the cache. + default: ${{ hashFiles('**/pubspec.yaml') }} + +runs: + using: "composite" + steps: + - name: Setup environment + # By forcing puro (and hence the pub-cache) onto the same drive as the checkout, + # we can avoid symlink issue between local and network drives on windows. + id: setup + shell: bash + run: | + export PURO_ROOT=$(dirname $GITHUB_WORKSPACE)/puro + mkdir -p $PURO_ROOT + + echo $PURO_ROOT/bin >> $GITHUB_PATH + echo $PURO_ROOT/shared/pub_cache/bin/ >> $GITHUB_PATH + echo $PURO_ROOT/envs/default/flutter/bin/ >> $GITHUB_PATH + + echo PURO_ROOT=$PURO_ROOT >> $GITHUB_ENV + echo PUB_CACHE=$PURO_ROOT/shared/pub_cache >> $GITHUB_ENV + echo MELOS_SDK_PATH=$PURO_ROOT/envs/default/flutter/ >> $GITHUB_ENV + + echo "week=$(date +'%Y-%U')" >> $GITHUB_OUTPUT + + - name: Restore cache + # TODO: Avoid skipping restore on Windows + # (see https://github.com/pingbird/puro/issues/87) + if: runner.os != 'Windows' + id: restore + uses: actions/cache/restore@v4 + with: + path: ${{ env.PURO_ROOT }} + key: setup-runner-${{ runner.os }}-${{ runner.arch }}-${{ steps.setup.outputs.week }}-${{ inputs.cache-key }} + restore-keys: setup-runner-${{ runner.os }}-${{ runner.arch }}- + + - name: Install puro (posix) + # See https://puro.dev/ + # Skip on any cache hit (partial or full) + if: runner.os != 'Windows' && steps.restore.outputs.cache-matched-key == '' + shell: bash + run: curl -sS -o- https://puro.dev/install.sh | PURO_VERSION="1.4.6" bash + + - name: Install puro (windows) + # We always install on windows, as we currently don't restore a cache (see TODO above) + if: runner.os == 'Windows' && steps.restore.outputs.cache-matched-key == '' + shell: pwsh + run: >- + Invoke-WebRequest + -Uri "https://puro.dev/builds/1.4.6/windows-x64/puro.exe" + -OutFile "$Env:PURO_ROOT"; + &"$Env:PURO_ROOT\puro.exe" install-puro --promote + + - name: Upgrade puro and flutter + shell: bash + run: | + puro upgrade-puro + puro use --global ${{ inputs.flutter-version }} + puro upgrade ${{ inputs.flutter-version }} + puro gc + + - name: Activate melos + if: steps.restore.outputs.cache-matched-key == '' + shell: bash + run: puro pub global run melos --version || puro pub global activate melos + + - name: Melos bootstrap + shell: bash + run: puro pub global run melos bootstrap + + - name: Save cache + # Saving on feature branches will only benefit reruns, so we don't bother. + # Feature branches inherit the cache from the main branch anyway. + # This saves on cache storage. + if: github.ref == 'refs/heads/main' && steps.restore.outputs.cache-hit != 'true' + uses: actions/cache/save@v4 + with: + path: ${{ env.PURO_ROOT }} + key: ${{ steps.restore.outputs.cache-primary-key }} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4058963b5..e866b86a7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -321,13 +321,16 @@ jobs: with: submodules: "recursive" + - name: Setup runner + uses: ./.github/actions/setup-runner + - name: Bump ulimit run: | ulimit -n ulimit -n 10240 - name: Enable ccache - run: echo "PATH=/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH" >> $GITHUB_ENV + run: echo "/usr/lib/ccache:/usr/local/opt/ccache/libexec" >> $GITHUB_PATH - name: Fetch artifacts uses: actions/download-artifact@v4 @@ -335,19 +338,6 @@ jobs: name: librealm-ios path: packages/realm_dart/binary/ios - - name: Setup Flutter - uses: subosito/flutter-action@v2 - with: - channel: "stable" - - - name: Setup Melos - run: | - dart pub global activate melos - dart pub global run melos bootstrap - - - name: Install dependencies - run: dart pub get - - name: Launch Simulator uses: futureware-tech/simulator-action@v3 with: @@ -431,18 +421,8 @@ jobs: name: librealm-android path: packages/realm_dart/binary/android - - name: Setup Flutter - uses: subosito/flutter-action@v2 - with: - channel: "stable" - - - name: Setup Melos - run: | - dart pub global activate melos - dart pub global run melos bootstrap - - - name: Install dependencies - run: dart pub get + - name: Setup Runner + uses: ./.github/actions/setup-runner # Hack to free up space on the runner to ensure we have enough diskspace to run the emulator - name: Remove unnecessary files (dotnet, etc.) @@ -526,15 +506,8 @@ jobs: with: submodules: "recursive" - - name: Setup Flutter - uses: subosito/flutter-action@v2 - with: - channel: "stable" - - - name: Setup Melos - run: | - dart pub global activate melos - dart pub global run melos bootstrap + - name: Setup Runner + uses: ./.github/actions/setup-runner - name: Delete generated files in realm_dart run: | @@ -629,15 +602,8 @@ jobs: with: submodules: "recursive" - - name: Setup Flutter - uses: subosito/flutter-action@v2 - with: - channel: "stable" - - - name: Setup Melos - run: | - dart pub global activate melos - dart pub global run melos bootstrap + - name: Setup Runner + uses: ./.github/actions/setup-runner - name: Compile to wasm run: flutter build web --wasm -t integration_test/all_tests.dart diff --git a/.github/workflows/dart-desktop-tests.yml b/.github/workflows/dart-desktop-tests.yml index 1d65b3cca..0a22a26c2 100644 --- a/.github/workflows/dart-desktop-tests.yml +++ b/.github/workflows/dart-desktop-tests.yml @@ -50,16 +50,8 @@ jobs: name: librealm-${{ steps.runner_os_lowercase.outputs.os }} path: packages/realm_dart/binary/${{ steps.runner_os_lowercase.outputs.os }} - - name: Setup Dart SDK - uses: dart-lang/setup-dart@main - with: - sdk: stable - - - name: Setup Melos - run: | - dart pub global activate melos - melos bootstrap --no-flutter - melos setup + - name: Setup Runner + uses: ./.github/actions/setup-runner - name: Bump ulimit on macos run: | @@ -85,6 +77,7 @@ jobs: if: inputs.runner == 'ubuntu-latest' run: | sudo apt-get install lcov + melos setup melos coverage:convert melos coverage:gather melos coverage:groom diff --git a/.github/workflows/deploy-baas.yml b/.github/workflows/deploy-baas.yml index 3e7263aa8..15a5a897a 100644 --- a/.github/workflows/deploy-baas.yml +++ b/.github/workflows/deploy-baas.yml @@ -25,19 +25,8 @@ jobs: with: submodules: false - - name: Setup Dart SDK - uses: dart-lang/setup-dart@main - with: - sdk: stable - architecture: 'x64' - - - name: Setup Melos - run: | - dart pub global activate melos - dart pub global run melos bootstrap --no-flutter - - - name: Install dependencies - run: dart pub get + - name: Setup Runner + uses: ./.github/actions/setup-runner - name: Deploy cluster and apps run: dart run realm_dart deploy-apps --baasaas-api-key ${{ secrets.BAASAAS_API_KEY }} --differentiator ${{ inputs.differentiator }} diff --git a/.github/workflows/flutter-desktop-tests.yml b/.github/workflows/flutter-desktop-tests.yml index a5234499b..13c55e297 100644 --- a/.github/workflows/flutter-desktop-tests.yml +++ b/.github/workflows/flutter-desktop-tests.yml @@ -61,19 +61,8 @@ jobs: name: librealm-${{ steps.runner_os_lowercase.outputs.os }} path: packages/realm_dart/binary/${{ steps.runner_os_lowercase.outputs.os }} - - name: Setup Flutter - uses: subosito/flutter-action@v2 - with: - channel: 'stable' - architecture: ${{ inputs.arch }} - - - name: Setup Melos - run: | - dart pub global activate melos - dart pub global run melos bootstrap - - - name: Install dependencies - run: dart pub get + - name: Setup Runner + uses: ./.github/actions/setup-runner - name: Bump ulimit run: | diff --git a/.github/workflows/prepare-release.yml b/.github/workflows/prepare-release.yml index 06a0edf42..334e97cf7 100644 --- a/.github/workflows/prepare-release.yml +++ b/.github/workflows/prepare-release.yml @@ -27,14 +27,8 @@ jobs: version: ${{ inputs.version }} version-suffix: '' - - name : Setup Dart SDK - uses: dart-lang/setup-dart@main - with: - sdk: stable - architecture: 'x64' - - - name: Setup Melos - run: dart pub global activate melos + - name: Setup Runner + uses: ./.github/actions/setup-runner - name: Update pubspec.yaml files run: REALM_VERSION=${{ steps.update-changelog.outputs.new-version }} melos run update:version:realm @@ -46,15 +40,15 @@ jobs: replace: " s.version$1= '${{ steps.update-changelog.outputs.new-version }}'" include: '**realm.podspec' - - name: Update libraryVersion in realm_core.dart + - name: Update libraryVersion in realm_library.dart id: update-libraryVersion uses: jacobtomlinson/gha-find-replace@b76729678e8d52dadb12e0e16454a93e301a919d #! 2.0.0 with: find: "const libraryVersion = '[^']*';" replace: "const libraryVersion = '${{ steps.update-changelog.outputs.new-version }}';" - include: 'packages/realm_dart/lib/src/native/realm_core.dart' + include: 'packages/realm_dart/lib/src/handles/native/realm_library.dart' - - name: Make sure we updated libraryVersion in realm_core.dart + - name: Make sure we updated libraryVersion in realm_library.dart run: | if [ '${{ steps.update-libraryVersion.outputs.modifiedFiles }}' != '1' ]; then echo 'Expected exactly one modified file, got ${{ steps.update-libraryVersion.outputs.modifiedFiles }}' diff --git a/.github/workflows/publish-release.yml b/.github/workflows/publish-release.yml index d531907b0..ead5bb1a1 100644 --- a/.github/workflows/publish-release.yml +++ b/.github/workflows/publish-release.yml @@ -30,15 +30,8 @@ jobs: echo "version=$pkgVersion$pkgSuffix" >> $GITHUB_OUTPUT shell: bash - - name: Setup Flutter - uses: subosito/flutter-action@v2 - with: - channel: 'stable' - - - name: Setup Melos - run: | - dart pub global activate melos - dart pub global run melos bootstrap + - name: Setup Runner + uses: ./.github/actions/setup-runner - name: Download all artifacts uses: dawidd6/action-download-artifact@71072fbb1229e1317f1a8de6b04206afb461bd67 # 3.1.2 @@ -161,15 +154,8 @@ jobs: name: release-bundle path: release - - name: Setup Flutter - uses: subosito/flutter-action@v2 - with: - channel: 'stable' - - - name: Setup Melos - run: | - dart pub global activate melos - dart pub global run melos bootstrap + - name: Setup Runner + uses: ./.github/actions/setup-runner # realm_flutter has symlinks to native binaries which should not be packaged - name: Cleanup symlinks diff --git a/.github/workflows/setup-runner.yml b/.github/workflows/setup-runner.yml deleted file mode 100644 index 5cb457cca..000000000 --- a/.github/workflows/setup-runner.yml +++ /dev/null @@ -1,39 +0,0 @@ -name: Setup runner - -on: - workflow_dispatch: # For debug - workflow_call: - inputs: - runner: - description: Platforms to execute on. - required: true - type: string - flutter-version: - description: Flutter version to use. - type: string - default: stable - -jobs: - setup-runner: - runs-on: ${{ inputs.runner }} - steps: - - name: Puro - run: >- - which puro - || curl -o- https://puro.dev/install.sh | PURO_VERSION="1.4.5" bash - shell: bash - - run: puro upgrade-puro - - run: puro use ${{ inputs.flutter-version }} - - - name: Checkout - uses: actions/checkout@v4 - with: - submodules: "recursive" - - - name: Melos - run: puro pub global activate melos - - run: melos bootstrap - - run: melos setup - - - diff --git a/.github/workflows/terminate-baas.yml b/.github/workflows/terminate-baas.yml index 547d5a32a..7336dc931 100644 --- a/.github/workflows/terminate-baas.yml +++ b/.github/workflows/terminate-baas.yml @@ -25,19 +25,8 @@ jobs: with: submodules: false - - name: Setup Dart SDK - uses: dart-lang/setup-dart@main - with: - sdk: stable - architecture: 'x64' - - - name: Setup Melos - run: | - dart pub global activate melos - dart pub global run melos bootstrap --no-flutter - - - name: Install dependencies - run: dart pub get + - name: Setup Runner + uses: ./.github/actions/setup-runner - name: Terminate baas run: dart run realm_dart delete-apps --baasaas-api-key ${{ secrets.BAASAAS_API_KEY }} --differentiator ${{ inputs.differentiator }} diff --git a/.vscode/settings.json b/.vscode/settings.json index 483d755b2..86eebf893 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -24,6 +24,7 @@ "fnum", "geospatial", "HRESULT", + "intf", "keepalive", "keypaths", "loggable", @@ -32,6 +33,8 @@ "nodoc", "nullptr", "posix", + "puro", + "pwsh", "riscv", "sublist", "sublists", diff --git a/CHANGELOG.md b/CHANGELOG.md index 6f365ff35..c39e33b18 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,10 +1,51 @@ ## vNext (TBD) +### Enhancements +* None + +### Fixed +* None + +### Compatibility +* Realm Studio: 15.0.0 or later. + +### Internal +* Using Core x.y.z. + +## 3.0.0 (2024-06-07) + ### Breaking Changes * To avoid dependency on `dart:io` - `AppConfiguration.httpClient` is now of type [`Client`](https://pub.dev/documentation/http/latest/http/Client-class.html) and - - `AppConfiguration.baseFilePath` is now of type `String` - + - `AppConfiguration.baseFilePath` is now of type `String`. + + Assuming you are configuring these today, migration is easy: + ```dart + import 'dart:io'; + import 'package:realm_dart/realm.dart'; + + final client = HttpClient(); + final dir = Directory.current; + final config = AppConfiguration( + 'your-app-id', + httpClient: client, + baseFilePath: dir, + ); + ``` + becomes: + ```dart + import 'dart:io'; + import 'package:realm_dart/realm.dart'; + import 'package:http/io_client.dart'; + + final client = HttpClient(); + final dir = Directory.current; + final config = AppConfiguration( + 'your-app-id', + httpClient: IOClient(client), + baseFilePath: dir.path, + ); + ``` (Issue [#1374](https://github.com/realm/realm-dart/issues/1374)) ### Enhancements @@ -43,6 +84,7 @@ * Disabled codesigning of Apple binaries. (Issue [#1679](https://github.com/realm/realm-dart/issues/1679)) * Drop building xcframework for catalyst. (Issue [#1695](https://github.com/realm/realm-dart/issues/1695)) * Using xcode 15.4 for native build. (Issue [#1547](https://github.com/realm/realm-dart/issues/1547)) +* Using puro on CI. ([#1710](https://github.com/realm/realm-dart/pull/1710)) ## 2.3.0 (2024-05-23) diff --git a/melos.yaml b/melos.yaml index 7cc7c4cba..92539f09d 100644 --- a/melos.yaml +++ b/melos.yaml @@ -40,7 +40,7 @@ scripts: - build:native - build:binding - build:dart - + build:native: exec: dev build packageFilters: @@ -121,7 +121,7 @@ scripts: run: >- find lib test integration_test -name '*.dart' -not -name '*.g.dart' -not -name '*.realm.dart' -not -name 'realm_bindings.dart' 2> /dev/null | xargs dart format --fix --line-length 160 - exec: + exec: concurrency: 1 # only one project at a time to keep output sane upgrade: @@ -143,7 +143,7 @@ scripts: run: >- find lib test integration_test -name '*.dart' -not -name '*.g.dart' -not -name '*.realm.dart' -not -name 'realm_bindings.dart' 2> /dev/null | xargs dart format --fix --line-length 160 --output none --set-exit-if-changed - exec: + exec: concurrency: 1 # only one project at a time to keep output sane lint:pana: @@ -152,7 +152,7 @@ scripts: concurrency: 1 # only one project at a time to keep output sane packageFilters: published: true - + coverage: description: Generate, check and render coverage. steps: @@ -223,4 +223,3 @@ scripts: - coverage - analyze - lint - \ No newline at end of file diff --git a/packages/realm/example/pubspec.yaml b/packages/realm/example/pubspec.yaml index 507f4ac87..9325d070a 100644 --- a/packages/realm/example/pubspec.yaml +++ b/packages/realm/example/pubspec.yaml @@ -11,7 +11,7 @@ environment: dependencies: flutter: sdk: flutter - realm: ^2.3.0 + realm: ^3.0.0 characters: ^1.1.0 dev_dependencies: diff --git a/packages/realm/ios/realm.podspec b/packages/realm/ios/realm.podspec index ea3217075..1d7500d5a 100644 --- a/packages/realm/ios/realm.podspec +++ b/packages/realm/ios/realm.podspec @@ -19,7 +19,7 @@ puts "bundleId is #{bundleId}" Pod::Spec.new do |s| s.name = 'realm' - s.version = '2.3.0' + s.version = '3.0.0' s.summary = 'The official Realm SDK for Flutter' s.description = <<-DESC Realm is a mobile database - an alternative to SQLite and key-value stores. diff --git a/packages/realm/macos/realm.podspec b/packages/realm/macos/realm.podspec index 53b968505..bfb61b9db 100644 --- a/packages/realm/macos/realm.podspec +++ b/packages/realm/macos/realm.podspec @@ -36,7 +36,7 @@ puts "bundleId is #{bundleId}" Pod::Spec.new do |s| s.name = 'realm' - s.version = '2.3.0' + s.version = '3.0.0' s.summary = 'The official Realm SDK for Flutter' s.description = <<-DESC Realm is a mobile database - an alternative to SQLite and key-value stores. diff --git a/packages/realm/pubspec.yaml b/packages/realm/pubspec.yaml index ca476a6e2..0b2264332 100644 --- a/packages/realm/pubspec.yaml +++ b/packages/realm/pubspec.yaml @@ -1,6 +1,6 @@ name: realm description: The official Realm SDK for Flutter. Realm is a mobile database - an alternative to SQLite and key-value stores. -version: 2.3.0 +version: 3.0.0 homepage: https://www.realm.io repository: https://github.com/realm/realm-dart @@ -13,7 +13,7 @@ environment: dependencies: flutter: sdk: flutter - realm_dart: ^2.3.0 + realm_dart: ^3.0.0 flutter: plugin: diff --git a/packages/realm_common/pubspec.yaml b/packages/realm_common/pubspec.yaml index b9d7cfcca..e97f238ed 100644 --- a/packages/realm_common/pubspec.yaml +++ b/packages/realm_common/pubspec.yaml @@ -3,7 +3,7 @@ description: >- Hosts the common code shared between realm, realm_dart and realm_generator packages. This package is part of the official Realm Flutter and Realm Dart SDKs. -version: 2.3.0 +version: 3.0.0 homepage: https://www.realm.io repository: https://github.com/realm/realm-dart diff --git a/packages/realm_dart/lib/src/cli/metrics/metrics_command.dart b/packages/realm_dart/lib/src/cli/metrics/metrics_command.dart index 2fb0f1f75..b18b582fc 100644 --- a/packages/realm_dart/lib/src/cli/metrics/metrics_command.dart +++ b/packages/realm_dart/lib/src/cli/metrics/metrics_command.dart @@ -18,7 +18,7 @@ import 'options.dart'; import '../common/utils.dart'; // stamped into the library by the build system (see prepare-release.yml) -const realmCoreVersion = '14.7.0'; +const realmCoreVersion = '14.9.0'; class MetricsCommand extends Command { @override diff --git a/packages/realm_dart/lib/src/handles/native/realm_library.dart b/packages/realm_dart/lib/src/handles/native/realm_library.dart index a574bc298..bfc585d62 100644 --- a/packages/realm_dart/lib/src/handles/native/realm_library.dart +++ b/packages/realm_dart/lib/src/handles/native/realm_library.dart @@ -10,7 +10,7 @@ import 'realm_bindings.dart'; const bugInTheSdkMessage = "This is likely a bug in the Realm SDK - please file an issue at https://github.com/realm/realm-dart/issues"; // stamped into the library by the build system (see prepare-release.yml) -const libraryVersion = '2.3.0'; +const libraryVersion = '3.0.0'; final realmLib = () { final result = RealmLibrary(initRealm()); diff --git a/packages/realm_dart/lib/src/handles/web/decimal128.dart b/packages/realm_dart/lib/src/handles/web/decimal128.dart index 58240b22b..342433918 100644 --- a/packages/realm_dart/lib/src/handles/web/decimal128.dart +++ b/packages/realm_dart/lib/src/handles/web/decimal128.dart @@ -1,9 +1,27 @@ // Copyright 2024 MongoDB, Inc. // SPDX-License-Identifier: Apache-2.0 -import '../decimal128.dart' as intf; +import 'package:decimal/decimal.dart'; + +import 'package:realm_dart/src/convert.dart'; + import 'web_not_supported.dart'; +import '../decimal128.dart' as intf; + +/// This is not a compliant IEEE 754-2008 Decimal128 implementation, as it is +/// just based on the [decimal](https://pub.dev/packages/decimal) package. +/// Which is based on the [rational](https://pub.dev/packages/rational) package, +/// which is again based on the [BigInt] class. +/// +/// The issues are mostly in some of the odd corner cases of IEEE 754-2008 +/// Decimal128, such as: +/// * -0 < 0, +/// * NaN != NaN, +/// * 1 / 0 = Inf, etc. +/// +/// Also, be warned that this class is incredible slow compared to the native +/// implementation. class Decimal128 implements intf.Decimal128 { static final zero = Decimal128.fromInt(0); @@ -23,17 +41,75 @@ class Decimal128 implements intf.Decimal128 { static final negativeInfinity = -infinity; /// Parses a string into a [Decimal128]. Returns `null` if the string is not a valid [Decimal128]. - static Decimal128? tryParse(String source) => webNotSupported(); + static Decimal128? tryParse(String source) => Decimal.tryParse(source).convert(Decimal128._); /// Parses a string into a [Decimal128]. Throws a [FormatException] if the string is not a valid [Decimal128]. - factory Decimal128.parse(String source) => webNotSupported(); + factory Decimal128.parse(String source) => Decimal128._(Decimal.parse(source)); /// Converts a `int` into a [Decimal128]. - factory Decimal128.fromInt(int value) => webNotSupported(); + factory Decimal128.fromInt(int value) => Decimal128._(Decimal.fromInt(value)); /// Converts a `double` into a [Decimal128]. - factory Decimal128.fromDouble(double value) => webNotSupported(); + factory Decimal128.fromDouble(double value) { + if (value.isNaN) return nan; + if (value.isInfinite) return value.isNegative ? negativeInfinity : infinity; + return Decimal128._(Decimal.parse(value.toString())); + } + + final Decimal _value; + Decimal128._(Decimal value) : _value = value.truncate(scale: 6144); + + @override + Decimal128 operator *(covariant Decimal128 other) => Decimal128._(_value * other._value); + + @override + Decimal128 operator +(covariant Decimal128 other) => Decimal128._(_value + other._value); + + @override + Decimal128 operator -() => Decimal128._(-_value); + + @override + Decimal128 operator -(covariant Decimal128 other) => Decimal128._(_value - other._value); + + // Note IEEE 754 Decimal128 defines division with zero as infinity, similar to double + @override + Decimal128 operator /(covariant Decimal128 other) => Decimal128._((_value / other._value).toDecimal(scaleOnInfinitePrecision: 6144)); + + @override + bool operator <(covariant Decimal128 other) => _value < other._value; + + @override + bool operator <=(covariant Decimal128 other) => _value <= other._value; + + @override + bool operator >(covariant Decimal128 other) => _value > other._value; + + @override + bool operator >=(covariant Decimal128 other) => _value >= other._value; + + @override + Decimal128 abs() => Decimal128._(_value.abs()); + + @override + int compareTo(covariant Decimal128 other) { + final sign = _value.compareTo(other._value); + if (sign < 0) return -1; + if (sign > 0) return 1; + return 0; + } + + @override + bool get isNaN => this == nan; + + @override + int toInt() => _value.toBigInt().toInt(); + + @override + String toString() => _value.toStringAsExponential(27); + + @override + operator ==(Object other) => other is Decimal128 && _value == other._value; @override - noSuchMethod(Invocation invocation) => webNotSupported(); + int get hashCode => _value.hashCode; } diff --git a/packages/realm_dart/pubspec.yaml b/packages/realm_dart/pubspec.yaml index b4a63abd2..7099fdcd4 100644 --- a/packages/realm_dart/pubspec.yaml +++ b/packages/realm_dart/pubspec.yaml @@ -1,6 +1,6 @@ name: realm_dart description: The official Realm SDK for Dart. Realm is a mobile database - an alternative to SQLite and key-value stores. -version: 2.3.0 +version: 3.0.0 homepage: https://www.realm.io repository: https://github.com/realm/realm-dart @@ -23,12 +23,14 @@ dependencies: path: ^1.0.0 pubspec_parse: ^1.0.0 pub_semver: ^2.1.0 - realm_common: ^2.3.0 - realm_generator: ^2.3.0 + realm_common: ^3.0.0 + realm_generator: ^3.0.0 tar: ^1.0.1 build_runner: ^2.1.0 http: ^1.0.0 cancellation_token: ^2.0.0 + decimal: ^3.0.1 + rational: ^2.2.3 dev_dependencies: build_cli: ^2.2.2 diff --git a/packages/realm_dart/src/realm_dart.cpp b/packages/realm_dart/src/realm_dart.cpp index 5bab1f20c..c3a2599f1 100644 --- a/packages/realm_dart/src/realm_dart.cpp +++ b/packages/realm_dart/src/realm_dart.cpp @@ -80,7 +80,7 @@ RLM_API void realm_dart_invoke_unlock_callback(realm_userdata_t error, void* unl // Stamped into the library by the build system (see prepare-release.yml) // Keep this method as it is written and do not format it. // We have a github workflow that looks for and replaces this string as it is written here. -RLM_API const char* realm_dart_library_version() { return "2.3.0"; } +RLM_API const char* realm_dart_library_version() { return "3.0.0"; } //for debugging only // RLM_API void realm_dart_gc() { diff --git a/packages/realm_generator/pubspec.yaml b/packages/realm_generator/pubspec.yaml index 55c312122..01e367f66 100644 --- a/packages/realm_generator/pubspec.yaml +++ b/packages/realm_generator/pubspec.yaml @@ -3,7 +3,7 @@ description: >- Generates RealmObject classes from Realm data model classes. This package is part of the official Realm Flutter and Realm Dart SDKs. -version: 2.3.0 +version: 3.0.0 homepage: https://www.realm.io repository: https://github.com/realm/realm-dart @@ -17,7 +17,7 @@ dependencies: build_resolvers: ^2.0.9 build: ^2.0.0 dart_style: ^2.2.0 - realm_common: ^2.3.0 + realm_common: ^3.0.0 source_gen: ^1.1.0 source_span: ^1.8.0 collection: ^1.18.0