diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index fb3a0ec4..6a63085c 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -5,6 +5,8 @@ on: - "powersync-v[0-9]+.[0-9]+.[0-9]+" - "powersync_attachments_helper-v[0-9]+.[0-9]+.[0-9]+*" - "powersync_flutter_libs-v[0-9]+.[0-9]+.[0-9]+*" + - "powersync_core-v[0-9]+.[0-9]+.[0-9]+*" + - "powersync_sqlcipher-v[0-9]+.[0-9]+.[0-9]+*" workflow_dispatch: jobs: @@ -35,7 +37,7 @@ jobs: env: GITHUBREF: ${{ github.ref }} run: | - PACKAGE_NAME=$(sed -E 's/refs\/tags\/([a-z0-9_]+)-v([0-9]+\.[0-9]+\.[0-9]+)/\1/' <<< $GITHUBREF) && \ + PACKAGE_NAME=$(sed -E 's/refs\/tags\/([a-z0-9_]+)-v([0-9]+\.[0-9]+\.[0-9]+(\+[0-9]+)?)/\1/' <<< $GITHUBREF) && \ echo "PACKAGE_NAME=$PACKAGE_NAME" >> $GITHUB_ENV echo "Package name: $PACKAGE_NAME" diff --git a/CHANGELOG.md b/CHANGELOG.md index c49add44..979d45ae 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,34 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## 2024-11-12 + +### Changes + +--- + +Packages with breaking changes: + + - There are no breaking changes in this release. + +Packages with other changes: + + - [`powersync` - `v1.10.0`](#powersync---v1100) + - [`powersync_attachments_helper` - `v0.6.16`](#powersync_attachments_helper---v0616) + - [`powersync_core` - `v1.0.0`](#powersync_core---v100) + - [`powersync_sqlcipher` - `v0.1.0`](#powersync_sqlcipher---v010) + +--- + +#### `powersync` - `v1.10.0` + +#### `powersync_attachments_helper` - `v0.6.16` + +#### `powersync_core` - `v1.0.0` + +#### `powersync_sqlcipher` - `v0.1.0` + + ## 2024-11-11 ### Changes diff --git a/demos/benchmarks/ios/Flutter/Debug.xcconfig b/demos/benchmarks/ios/Flutter/Debug.xcconfig index 592ceee8..ec97fc6f 100644 --- a/demos/benchmarks/ios/Flutter/Debug.xcconfig +++ b/demos/benchmarks/ios/Flutter/Debug.xcconfig @@ -1 +1,2 @@ +#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig" #include "Generated.xcconfig" diff --git a/demos/benchmarks/ios/Flutter/Release.xcconfig b/demos/benchmarks/ios/Flutter/Release.xcconfig index 592ceee8..c4855bfe 100644 --- a/demos/benchmarks/ios/Flutter/Release.xcconfig +++ b/demos/benchmarks/ios/Flutter/Release.xcconfig @@ -1 +1,2 @@ +#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" #include "Generated.xcconfig" diff --git a/demos/benchmarks/ios/Podfile b/demos/benchmarks/ios/Podfile new file mode 100644 index 00000000..d97f17e2 --- /dev/null +++ b/demos/benchmarks/ios/Podfile @@ -0,0 +1,44 @@ +# Uncomment this line to define a global platform for your project +# platform :ios, '12.0' + +# CocoaPods analytics sends network stats synchronously affecting flutter build latency. +ENV['COCOAPODS_DISABLE_STATS'] = 'true' + +project 'Runner', { + 'Debug' => :debug, + 'Profile' => :release, + 'Release' => :release, +} + +def flutter_root + generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__) + unless File.exist?(generated_xcode_build_settings_path) + raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first" + end + + File.foreach(generated_xcode_build_settings_path) do |line| + matches = line.match(/FLUTTER_ROOT\=(.*)/) + return matches[1].strip if matches + end + raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get" +end + +require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root) + +flutter_ios_podfile_setup + +target 'Runner' do + use_frameworks! + use_modular_headers! + + flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__)) + target 'RunnerTests' do + inherit! :search_paths + end +end + +post_install do |installer| + installer.pods_project.targets.each do |target| + flutter_additional_ios_build_settings(target) + end +end diff --git a/demos/benchmarks/macos/Flutter/Flutter-Debug.xcconfig b/demos/benchmarks/macos/Flutter/Flutter-Debug.xcconfig index c2efd0b6..4b81f9b2 100644 --- a/demos/benchmarks/macos/Flutter/Flutter-Debug.xcconfig +++ b/demos/benchmarks/macos/Flutter/Flutter-Debug.xcconfig @@ -1 +1,2 @@ +#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig" #include "ephemeral/Flutter-Generated.xcconfig" diff --git a/demos/benchmarks/macos/Flutter/Flutter-Release.xcconfig b/demos/benchmarks/macos/Flutter/Flutter-Release.xcconfig index c2efd0b6..5caa9d15 100644 --- a/demos/benchmarks/macos/Flutter/Flutter-Release.xcconfig +++ b/demos/benchmarks/macos/Flutter/Flutter-Release.xcconfig @@ -1 +1,2 @@ +#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" #include "ephemeral/Flutter-Generated.xcconfig" diff --git a/demos/benchmarks/macos/Podfile b/demos/benchmarks/macos/Podfile new file mode 100644 index 00000000..c795730d --- /dev/null +++ b/demos/benchmarks/macos/Podfile @@ -0,0 +1,43 @@ +platform :osx, '10.14' + +# CocoaPods analytics sends network stats synchronously affecting flutter build latency. +ENV['COCOAPODS_DISABLE_STATS'] = 'true' + +project 'Runner', { + 'Debug' => :debug, + 'Profile' => :release, + 'Release' => :release, +} + +def flutter_root + generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'ephemeral', 'Flutter-Generated.xcconfig'), __FILE__) + unless File.exist?(generated_xcode_build_settings_path) + raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure \"flutter pub get\" is executed first" + end + + File.foreach(generated_xcode_build_settings_path) do |line| + matches = line.match(/FLUTTER_ROOT\=(.*)/) + return matches[1].strip if matches + end + raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Flutter-Generated.xcconfig, then run \"flutter pub get\"" +end + +require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root) + +flutter_macos_podfile_setup + +target 'Runner' do + use_frameworks! + use_modular_headers! + + flutter_install_all_macos_pods File.dirname(File.realpath(__FILE__)) + target 'RunnerTests' do + inherit! :search_paths + end +end + +post_install do |installer| + installer.pods_project.targets.each do |target| + flutter_additional_macos_build_settings(target) + end +end diff --git a/demos/benchmarks/pubspec.lock b/demos/benchmarks/pubspec.lock index 687f1f3c..7381f7b3 100644 --- a/demos/benchmarks/pubspec.lock +++ b/demos/benchmarks/pubspec.lock @@ -306,6 +306,13 @@ packages: relative: true source: path version: "1.9.2" + powersync_core: + dependency: "direct overridden" + description: + path: "../../packages/powersync_core" + relative: true + source: path + version: "0.0.1" powersync_flutter_libs: dependency: "direct overridden" description: diff --git a/demos/benchmarks/pubspec.yaml b/demos/benchmarks/pubspec.yaml index 8e360c04..4f4b1cd4 100644 --- a/demos/benchmarks/pubspec.yaml +++ b/demos/benchmarks/pubspec.yaml @@ -10,7 +10,7 @@ environment: dependencies: flutter: sdk: flutter - powersync: ^1.9.3 + powersync: ^1.10.0 path_provider: ^2.1.1 path: ^1.8.3 logging: ^1.2.0 diff --git a/demos/django-todolist/pubspec.lock b/demos/django-todolist/pubspec.lock index 6f759278..8e18eaec 100644 --- a/demos/django-todolist/pubspec.lock +++ b/demos/django-todolist/pubspec.lock @@ -319,6 +319,13 @@ packages: relative: true source: path version: "1.9.2" + powersync_core: + dependency: "direct overridden" + description: + path: "../../packages/powersync_core" + relative: true + source: path + version: "0.0.1" powersync_flutter_libs: dependency: "direct overridden" description: diff --git a/demos/django-todolist/pubspec.yaml b/demos/django-todolist/pubspec.yaml index 096120d1..13415b5d 100644 --- a/demos/django-todolist/pubspec.yaml +++ b/demos/django-todolist/pubspec.yaml @@ -10,7 +10,7 @@ environment: dependencies: flutter: sdk: flutter - powersync: ^1.9.3 + powersync: ^1.10.0 path_provider: ^2.1.1 path: ^1.8.3 logging: ^1.2.0 diff --git a/demos/supabase-anonymous-auth/pubspec.lock b/demos/supabase-anonymous-auth/pubspec.lock index 452c0ea1..aa452b67 100644 --- a/demos/supabase-anonymous-auth/pubspec.lock +++ b/demos/supabase-anonymous-auth/pubspec.lock @@ -375,6 +375,13 @@ packages: relative: true source: path version: "1.9.2" + powersync_core: + dependency: "direct overridden" + description: + path: "../../packages/powersync_core" + relative: true + source: path + version: "0.0.1" powersync_flutter_libs: dependency: "direct overridden" description: diff --git a/demos/supabase-anonymous-auth/pubspec.yaml b/demos/supabase-anonymous-auth/pubspec.yaml index 2e7b1a14..3118a1e3 100644 --- a/demos/supabase-anonymous-auth/pubspec.yaml +++ b/demos/supabase-anonymous-auth/pubspec.yaml @@ -11,7 +11,7 @@ dependencies: flutter: sdk: flutter - powersync: ^1.9.3 + powersync: ^1.10.0 path_provider: ^2.1.1 supabase_flutter: ^2.0.2 path: ^1.8.3 diff --git a/demos/supabase-edge-function-auth/pubspec.lock b/demos/supabase-edge-function-auth/pubspec.lock index 08973ab4..1d427270 100644 --- a/demos/supabase-edge-function-auth/pubspec.lock +++ b/demos/supabase-edge-function-auth/pubspec.lock @@ -399,6 +399,13 @@ packages: relative: true source: path version: "1.9.2" + powersync_core: + dependency: "direct overridden" + description: + path: "../../packages/powersync_core" + relative: true + source: path + version: "0.0.1" powersync_flutter_libs: dependency: "direct overridden" description: diff --git a/demos/supabase-edge-function-auth/pubspec.yaml b/demos/supabase-edge-function-auth/pubspec.yaml index 9a576368..60dc9b40 100644 --- a/demos/supabase-edge-function-auth/pubspec.yaml +++ b/demos/supabase-edge-function-auth/pubspec.yaml @@ -11,7 +11,7 @@ dependencies: flutter: sdk: flutter - powersync: ^1.9.3 + powersync: ^1.10.0 path_provider: ^2.1.1 supabase_flutter: ^2.0.2 path: ^1.8.3 diff --git a/demos/supabase-simple-chat/pubspec.lock b/demos/supabase-simple-chat/pubspec.lock index bfc1ed6a..17865ceb 100644 --- a/demos/supabase-simple-chat/pubspec.lock +++ b/demos/supabase-simple-chat/pubspec.lock @@ -415,6 +415,13 @@ packages: relative: true source: path version: "1.9.2" + powersync_core: + dependency: "direct overridden" + description: + path: "../../packages/powersync_core" + relative: true + source: path + version: "0.0.1" powersync_flutter_libs: dependency: "direct overridden" description: diff --git a/demos/supabase-simple-chat/pubspec.yaml b/demos/supabase-simple-chat/pubspec.yaml index 3e563cf8..8449ddda 100644 --- a/demos/supabase-simple-chat/pubspec.yaml +++ b/demos/supabase-simple-chat/pubspec.yaml @@ -37,7 +37,7 @@ dependencies: supabase_flutter: ^2.0.2 timeago: ^3.6.0 - powersync: ^1.9.3 + powersync: ^1.10.0 path_provider: ^2.1.1 path: ^1.8.3 logging: ^1.2.0 diff --git a/demos/supabase-todolist-drift/pubspec.lock b/demos/supabase-todolist-drift/pubspec.lock index 5a70fd5f..3f02e983 100644 --- a/demos/supabase-todolist-drift/pubspec.lock +++ b/demos/supabase-todolist-drift/pubspec.lock @@ -694,6 +694,13 @@ packages: relative: true source: path version: "0.6.15+1" + powersync_core: + dependency: "direct overridden" + description: + path: "../../packages/powersync_core" + relative: true + source: path + version: "0.0.1" powersync_flutter_libs: dependency: "direct overridden" description: diff --git a/demos/supabase-todolist-drift/pubspec.yaml b/demos/supabase-todolist-drift/pubspec.yaml index 22418c30..e13a1c73 100644 --- a/demos/supabase-todolist-drift/pubspec.yaml +++ b/demos/supabase-todolist-drift/pubspec.yaml @@ -9,8 +9,8 @@ environment: dependencies: flutter: sdk: flutter - powersync_attachments_helper: ^0.6.15+2 - powersync: ^1.9.3 + powersync_attachments_helper: ^0.6.16 + powersync: ^1.10.0 path_provider: ^2.1.1 supabase_flutter: ^2.0.1 path: ^1.8.3 diff --git a/demos/supabase-todolist-optional-sync/pubspec.lock b/demos/supabase-todolist-optional-sync/pubspec.lock index 3264656a..2ff6fdf5 100644 --- a/demos/supabase-todolist-optional-sync/pubspec.lock +++ b/demos/supabase-todolist-optional-sync/pubspec.lock @@ -479,6 +479,13 @@ packages: relative: true source: path version: "1.9.2" + powersync_core: + dependency: "direct overridden" + description: + path: "../../packages/powersync_core" + relative: true + source: path + version: "0.0.1" powersync_flutter_libs: dependency: "direct overridden" description: diff --git a/demos/supabase-todolist-optional-sync/pubspec.yaml b/demos/supabase-todolist-optional-sync/pubspec.yaml index 27c10b42..cce01eca 100644 --- a/demos/supabase-todolist-optional-sync/pubspec.yaml +++ b/demos/supabase-todolist-optional-sync/pubspec.yaml @@ -10,7 +10,7 @@ environment: dependencies: flutter: sdk: flutter - powersync: ^1.9.3 + powersync: ^1.10.0 path_provider: ^2.1.1 supabase_flutter: ^2.0.1 path: ^1.8.3 diff --git a/demos/supabase-todolist/ios/Runner.xcodeproj/project.pbxproj b/demos/supabase-todolist/ios/Runner.xcodeproj/project.pbxproj index 16636b7a..e32e9fa6 100644 --- a/demos/supabase-todolist/ios/Runner.xcodeproj/project.pbxproj +++ b/demos/supabase-todolist/ios/Runner.xcodeproj/project.pbxproj @@ -13,7 +13,7 @@ 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; }; 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; }; 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; }; - B2C70762C97CE3E3CEB912CB /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 7B9CC0EA1BA15CD3CCAD0356 /* Pods_Runner.framework */; }; + FE22D026B50D91C63EC1E548 /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3246A2C54ACF47297A0D9A97 /* Pods_Runner.framework */; }; /* End PBXBuildFile section */ /* Begin PBXCopyFilesBuildPhase section */ @@ -32,13 +32,13 @@ /* Begin PBXFileReference section */ 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = ""; }; 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = ""; }; - 15764CEB058B2B69D5E35280 /* Pods-Runner.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.profile.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig"; sourceTree = ""; }; - 3153F415177CAE497AE7D235 /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = ""; }; + 1AC6D6834A180EC866A1A907 /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = ""; }; + 3246A2C54ACF47297A0D9A97 /* Pods_Runner.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Runner.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = ""; }; 74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Runner-Bridging-Header.h"; sourceTree = ""; }; 74858FAE1ED2DC5600515810 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = ""; }; - 7B9CC0EA1BA15CD3CCAD0356 /* Pods_Runner.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Runner.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + 7F544BD3701C5CF77F2FF87F /* Pods-Runner.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.profile.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig"; sourceTree = ""; }; 9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Debug.xcconfig; path = Flutter/Debug.xcconfig; sourceTree = ""; }; 9740EEB31CF90195004384FC /* Generated.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Generated.xcconfig; path = Flutter/Generated.xcconfig; sourceTree = ""; }; 97C146EE1CF9000F007C117D /* Runner.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Runner.app; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -46,7 +46,7 @@ 97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; - CDF8C9971FE1B0CF3262ED53 /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = ""; }; + F866E203CA1A8E0C6D9ABA5C /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -54,13 +54,21 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - B2C70762C97CE3E3CEB912CB /* Pods_Runner.framework in Frameworks */, + FE22D026B50D91C63EC1E548 /* Pods_Runner.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ + 114FDDDC75E03531AE956759 /* Frameworks */ = { + isa = PBXGroup; + children = ( + 3246A2C54ACF47297A0D9A97 /* Pods_Runner.framework */, + ); + name = Frameworks; + sourceTree = ""; + }; 9740EEB11CF90186004384FC /* Flutter */ = { isa = PBXGroup; children = ( @@ -79,7 +87,7 @@ 97C146F01CF9000F007C117D /* Runner */, 97C146EF1CF9000F007C117D /* Products */, A151B04DC3D1415EEF784588 /* Pods */, - C1E97B63847FB6B811E12FEA /* Frameworks */, + 114FDDDC75E03531AE956759 /* Frameworks */, ); sourceTree = ""; }; @@ -109,21 +117,13 @@ A151B04DC3D1415EEF784588 /* Pods */ = { isa = PBXGroup; children = ( - 3153F415177CAE497AE7D235 /* Pods-Runner.debug.xcconfig */, - CDF8C9971FE1B0CF3262ED53 /* Pods-Runner.release.xcconfig */, - 15764CEB058B2B69D5E35280 /* Pods-Runner.profile.xcconfig */, + F866E203CA1A8E0C6D9ABA5C /* Pods-Runner.debug.xcconfig */, + 1AC6D6834A180EC866A1A907 /* Pods-Runner.release.xcconfig */, + 7F544BD3701C5CF77F2FF87F /* Pods-Runner.profile.xcconfig */, ); path = Pods; sourceTree = ""; }; - C1E97B63847FB6B811E12FEA /* Frameworks */ = { - isa = PBXGroup; - children = ( - 7B9CC0EA1BA15CD3CCAD0356 /* Pods_Runner.framework */, - ); - name = Frameworks; - sourceTree = ""; - }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */ @@ -131,14 +131,14 @@ isa = PBXNativeTarget; buildConfigurationList = 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */; buildPhases = ( - E916CBFE94483EF7C2F17F6C /* [CP] Check Pods Manifest.lock */, + 39B3199DCFC6D38A9384399C /* [CP] Check Pods Manifest.lock */, 9740EEB61CF901F6004384FC /* Run Script */, 97C146EA1CF9000F007C117D /* Sources */, 97C146EB1CF9000F007C117D /* Frameworks */, 97C146EC1CF9000F007C117D /* Resources */, 9705A1C41CF9048500538489 /* Embed Frameworks */, 3B06AD1E1E4923F5004D2608 /* Thin Binary */, - 0A5FBCADCBC1AF2E0353A84D /* [CP] Embed Pods Frameworks */, + FE8EB41334261949D37FC328 /* [CP] Embed Pods Frameworks */, ); buildRules = ( ); @@ -197,21 +197,26 @@ /* End PBXResourcesBuildPhase section */ /* Begin PBXShellScriptBuildPhase section */ - 0A5FBCADCBC1AF2E0353A84D /* [CP] Embed Pods Frameworks */ = { + 39B3199DCFC6D38A9384399C /* [CP] Check Pods Manifest.lock */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( ); inputFileListPaths = ( - "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-input-files.xcfilelist", ); - name = "[CP] Embed Pods Frameworks"; + inputPaths = ( + "${PODS_PODFILE_DIR_PATH}/Podfile.lock", + "${PODS_ROOT}/Manifest.lock", + ); + name = "[CP] Check Pods Manifest.lock"; outputFileListPaths = ( - "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-output-files.xcfilelist", + ); + outputPaths = ( + "$(DERIVED_FILE_DIR)/Pods-Runner-checkManifestLockResult.txt", ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n"; + shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; showEnvVarsInLog = 0; }; 3B06AD1E1E4923F5004D2608 /* Thin Binary */ = { @@ -245,26 +250,21 @@ shellPath = /bin/sh; shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build"; }; - E916CBFE94483EF7C2F17F6C /* [CP] Check Pods Manifest.lock */ = { + FE8EB41334261949D37FC328 /* [CP] Embed Pods Frameworks */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( ); inputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-input-files.xcfilelist", ); - inputPaths = ( - "${PODS_PODFILE_DIR_PATH}/Podfile.lock", - "${PODS_ROOT}/Manifest.lock", - ); - name = "[CP] Check Pods Manifest.lock"; + name = "[CP] Embed Pods Frameworks"; outputFileListPaths = ( - ); - outputPaths = ( - "$(DERIVED_FILE_DIR)/Pods-Runner-checkManifestLockResult.txt", + "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-output-files.xcfilelist", ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n"; showEnvVarsInLog = 0; }; /* End PBXShellScriptBuildPhase section */ diff --git a/demos/supabase-todolist/macos/Runner.xcodeproj/project.pbxproj b/demos/supabase-todolist/macos/Runner.xcodeproj/project.pbxproj index fe47ba76..5581abf6 100644 --- a/demos/supabase-todolist/macos/Runner.xcodeproj/project.pbxproj +++ b/demos/supabase-todolist/macos/Runner.xcodeproj/project.pbxproj @@ -21,14 +21,14 @@ /* End PBXAggregateTarget section */ /* Begin PBXBuildFile section */ - 04EE2EEA1AF4432FCFE4D947 /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 386AF35B349F70B5D676F5EC /* Pods_Runner.framework */; }; - 2F56F886B3B1884D3E437FD0 /* Pods_RunnerTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C2FC729F34600C40853A030B /* Pods_RunnerTests.framework */; }; 335BBD1B22A9A15E00E9071D /* GeneratedPluginRegistrant.swift in Sources */ = {isa = PBXBuildFile; fileRef = 335BBD1A22A9A15E00E9071D /* GeneratedPluginRegistrant.swift */; }; 33CC10F12044A3C60003C045 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 33CC10F02044A3C60003C045 /* AppDelegate.swift */; }; 33CC10F32044A3C60003C045 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 33CC10F22044A3C60003C045 /* Assets.xcassets */; }; 33CC10F62044A3C60003C045 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 33CC10F42044A3C60003C045 /* MainMenu.xib */; }; 33CC11132044BFA00003C045 /* MainFlutterWindow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 33CC11122044BFA00003C045 /* MainFlutterWindow.swift */; }; + 75E48BA0AEB945CF7281B8D7 /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 610323F3498FEA93EE8D7ECD /* Pods_Runner.framework */; }; 8B5261612A7C463D00E9899E /* powersync_flutter_demoTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8B5261602A7C463D00E9899E /* powersync_flutter_demoTests.swift */; }; + 9381A48772266D9C49309994 /* Pods_RunnerTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 991B2149AEB0B3DAB09CB3BE /* Pods_RunnerTests.framework */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -62,7 +62,7 @@ /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ - 1FB90A99EA939D06EE287C09 /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = ""; }; + 10C22D07423926C20887DE48 /* Pods-RunnerTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RunnerTests.release.xcconfig"; path = "Target Support Files/Pods-RunnerTests/Pods-RunnerTests.release.xcconfig"; sourceTree = ""; }; 333000ED22D3DE5D00554162 /* Warnings.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Warnings.xcconfig; sourceTree = ""; }; 335BBD1A22A9A15E00E9071D /* GeneratedPluginRegistrant.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GeneratedPluginRegistrant.swift; sourceTree = ""; }; 33CC10ED2044A3C60003C045 /* powersync_flutter_demo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = powersync_flutter_demo.app; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -77,17 +77,17 @@ 33E51913231747F40026EE4D /* DebugProfile.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = DebugProfile.entitlements; sourceTree = ""; }; 33E51914231749380026EE4D /* Release.entitlements */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.entitlements; path = Release.entitlements; sourceTree = ""; }; 33E5194F232828860026EE4D /* AppInfo.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = AppInfo.xcconfig; sourceTree = ""; }; - 386AF35B349F70B5D676F5EC /* Pods_Runner.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Runner.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + 4D425E3DE8C8153AB8C55A47 /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = ""; }; + 610323F3498FEA93EE8D7ECD /* Pods_Runner.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Runner.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Release.xcconfig; sourceTree = ""; }; - 859D7659433CF3D1320F86CC /* Pods-RunnerTests.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RunnerTests.profile.xcconfig"; path = "Target Support Files/Pods-RunnerTests/Pods-RunnerTests.profile.xcconfig"; sourceTree = ""; }; 8B52615E2A7C463D00E9899E /* RunnerTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = RunnerTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 8B5261602A7C463D00E9899E /* powersync_flutter_demoTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = powersync_flutter_demoTests.swift; sourceTree = ""; }; 9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Debug.xcconfig; sourceTree = ""; }; - 9DCB9EDE28DF57E29440CF22 /* Pods-RunnerTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RunnerTests.debug.xcconfig"; path = "Target Support Files/Pods-RunnerTests/Pods-RunnerTests.debug.xcconfig"; sourceTree = ""; }; - AF676D80A0CF80705DF388CF /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = ""; }; - C1A05183B57D5869377A17B4 /* Pods-Runner.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.profile.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig"; sourceTree = ""; }; - C2FC729F34600C40853A030B /* Pods_RunnerTests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_RunnerTests.framework; sourceTree = BUILT_PRODUCTS_DIR; }; - D0A6A6185A7A65698B8F4B1D /* Pods-RunnerTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RunnerTests.release.xcconfig"; path = "Target Support Files/Pods-RunnerTests/Pods-RunnerTests.release.xcconfig"; sourceTree = ""; }; + 991B2149AEB0B3DAB09CB3BE /* Pods_RunnerTests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_RunnerTests.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + AE0A38BE3137E8F7E92FEF51 /* Pods-RunnerTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RunnerTests.debug.xcconfig"; path = "Target Support Files/Pods-RunnerTests/Pods-RunnerTests.debug.xcconfig"; sourceTree = ""; }; + D7EC9DA661EA44265DC94A0B /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = ""; }; + DD914308A8C7B352FD10170F /* Pods-RunnerTests.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RunnerTests.profile.xcconfig"; path = "Target Support Files/Pods-RunnerTests/Pods-RunnerTests.profile.xcconfig"; sourceTree = ""; }; + EE686A5A317D10AC330E1BF9 /* Pods-Runner.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.profile.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig"; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -95,7 +95,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - 04EE2EEA1AF4432FCFE4D947 /* Pods_Runner.framework in Frameworks */, + 75E48BA0AEB945CF7281B8D7 /* Pods_Runner.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -103,7 +103,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - 2F56F886B3B1884D3E437FD0 /* Pods_RunnerTests.framework in Frameworks */, + 9381A48772266D9C49309994 /* Pods_RunnerTests.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -128,8 +128,8 @@ 33CEB47122A05771004F2AC0 /* Flutter */, 8B52615F2A7C463D00E9899E /* powersync_flutter_demoTests */, 33CC10EE2044A3C60003C045 /* Products */, - D73912EC22F37F3D000D13A0 /* Frameworks */, - B6C445B3E9905835336FDF92 /* Pods */, + 85152821BF893F70AB178223 /* Pods */, + B7D43289954627B8B1B9B1F8 /* Frameworks */, ); sourceTree = ""; }; @@ -177,33 +177,33 @@ path = Runner; sourceTree = ""; }; - 8B52615F2A7C463D00E9899E /* powersync_flutter_demoTests */ = { + 85152821BF893F70AB178223 /* Pods */ = { isa = PBXGroup; children = ( - 8B5261602A7C463D00E9899E /* powersync_flutter_demoTests.swift */, + 4D425E3DE8C8153AB8C55A47 /* Pods-Runner.debug.xcconfig */, + D7EC9DA661EA44265DC94A0B /* Pods-Runner.release.xcconfig */, + EE686A5A317D10AC330E1BF9 /* Pods-Runner.profile.xcconfig */, + AE0A38BE3137E8F7E92FEF51 /* Pods-RunnerTests.debug.xcconfig */, + 10C22D07423926C20887DE48 /* Pods-RunnerTests.release.xcconfig */, + DD914308A8C7B352FD10170F /* Pods-RunnerTests.profile.xcconfig */, ); - path = powersync_flutter_demoTests; + name = Pods; + path = Pods; sourceTree = ""; }; - B6C445B3E9905835336FDF92 /* Pods */ = { + 8B52615F2A7C463D00E9899E /* powersync_flutter_demoTests */ = { isa = PBXGroup; children = ( - 1FB90A99EA939D06EE287C09 /* Pods-Runner.debug.xcconfig */, - AF676D80A0CF80705DF388CF /* Pods-Runner.release.xcconfig */, - C1A05183B57D5869377A17B4 /* Pods-Runner.profile.xcconfig */, - 9DCB9EDE28DF57E29440CF22 /* Pods-RunnerTests.debug.xcconfig */, - D0A6A6185A7A65698B8F4B1D /* Pods-RunnerTests.release.xcconfig */, - 859D7659433CF3D1320F86CC /* Pods-RunnerTests.profile.xcconfig */, + 8B5261602A7C463D00E9899E /* powersync_flutter_demoTests.swift */, ); - name = Pods; - path = Pods; + path = powersync_flutter_demoTests; sourceTree = ""; }; - D73912EC22F37F3D000D13A0 /* Frameworks */ = { + B7D43289954627B8B1B9B1F8 /* Frameworks */ = { isa = PBXGroup; children = ( - 386AF35B349F70B5D676F5EC /* Pods_Runner.framework */, - C2FC729F34600C40853A030B /* Pods_RunnerTests.framework */, + 610323F3498FEA93EE8D7ECD /* Pods_Runner.framework */, + 991B2149AEB0B3DAB09CB3BE /* Pods_RunnerTests.framework */, ); name = Frameworks; sourceTree = ""; @@ -215,13 +215,13 @@ isa = PBXNativeTarget; buildConfigurationList = 33CC10FB2044A3C60003C045 /* Build configuration list for PBXNativeTarget "Runner" */; buildPhases = ( - 9E5C59BA43BACEF39908FBDE /* [CP] Check Pods Manifest.lock */, + 179983970B20315AFC123D9D /* [CP] Check Pods Manifest.lock */, 33CC10E92044A3C60003C045 /* Sources */, 33CC10EA2044A3C60003C045 /* Frameworks */, 33CC10EB2044A3C60003C045 /* Resources */, 33CC110E2044A8840003C045 /* Bundle Framework */, 3399D490228B24CF009A79C7 /* ShellScript */, - 44F34942EBFBB7F6E89ED4BA /* [CP] Embed Pods Frameworks */, + F30CD4FEA1BDB49C8B84FB01 /* [CP] Embed Pods Frameworks */, ); buildRules = ( ); @@ -237,7 +237,7 @@ isa = PBXNativeTarget; buildConfigurationList = 8B5261672A7C463D00E9899E /* Build configuration list for PBXNativeTarget "RunnerTests" */; buildPhases = ( - 9BD4CD7B4DFE9A6CC5BE206C /* [CP] Check Pods Manifest.lock */, + 6C234BEFE02FE63D2DBBAA50 /* [CP] Check Pods Manifest.lock */, 8B52615A2A7C463D00E9899E /* Sources */, 8B52615B2A7C463D00E9899E /* Frameworks */, 8B52615C2A7C463D00E9899E /* Resources */, @@ -322,62 +322,67 @@ /* End PBXResourcesBuildPhase section */ /* Begin PBXShellScriptBuildPhase section */ - 3399D490228B24CF009A79C7 /* ShellScript */ = { + 179983970B20315AFC123D9D /* [CP] Check Pods Manifest.lock */ = { isa = PBXShellScriptBuildPhase; - alwaysOutOfDate = 1; buildActionMask = 2147483647; files = ( ); inputFileListPaths = ( ); inputPaths = ( + "${PODS_PODFILE_DIR_PATH}/Podfile.lock", + "${PODS_ROOT}/Manifest.lock", ); + name = "[CP] Check Pods Manifest.lock"; outputFileListPaths = ( ); outputPaths = ( + "$(DERIVED_FILE_DIR)/Pods-Runner-checkManifestLockResult.txt", ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "echo \"$PRODUCT_NAME.app\" > \"$PROJECT_DIR\"/Flutter/ephemeral/.app_filename && \"$FLUTTER_ROOT\"/packages/flutter_tools/bin/macos_assemble.sh embed\n"; + shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; + showEnvVarsInLog = 0; }; - 33CC111E2044C6BF0003C045 /* ShellScript */ = { + 3399D490228B24CF009A79C7 /* ShellScript */ = { isa = PBXShellScriptBuildPhase; + alwaysOutOfDate = 1; buildActionMask = 2147483647; files = ( ); inputFileListPaths = ( - Flutter/ephemeral/FlutterInputs.xcfilelist, ); inputPaths = ( - Flutter/ephemeral/tripwire, ); outputFileListPaths = ( - Flutter/ephemeral/FlutterOutputs.xcfilelist, ); outputPaths = ( ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "\"$FLUTTER_ROOT\"/packages/flutter_tools/bin/macos_assemble.sh && touch Flutter/ephemeral/tripwire"; + shellScript = "echo \"$PRODUCT_NAME.app\" > \"$PROJECT_DIR\"/Flutter/ephemeral/.app_filename && \"$FLUTTER_ROOT\"/packages/flutter_tools/bin/macos_assemble.sh embed\n"; }; - 44F34942EBFBB7F6E89ED4BA /* [CP] Embed Pods Frameworks */ = { + 33CC111E2044C6BF0003C045 /* ShellScript */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( ); inputFileListPaths = ( - "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-input-files.xcfilelist", + Flutter/ephemeral/FlutterInputs.xcfilelist, + ); + inputPaths = ( + Flutter/ephemeral/tripwire, ); - name = "[CP] Embed Pods Frameworks"; outputFileListPaths = ( - "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-output-files.xcfilelist", + Flutter/ephemeral/FlutterOutputs.xcfilelist, + ); + outputPaths = ( ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n"; - showEnvVarsInLog = 0; + shellScript = "\"$FLUTTER_ROOT\"/packages/flutter_tools/bin/macos_assemble.sh && touch Flutter/ephemeral/tripwire"; }; - 9BD4CD7B4DFE9A6CC5BE206C /* [CP] Check Pods Manifest.lock */ = { + 6C234BEFE02FE63D2DBBAA50 /* [CP] Check Pods Manifest.lock */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( @@ -399,26 +404,21 @@ shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; showEnvVarsInLog = 0; }; - 9E5C59BA43BACEF39908FBDE /* [CP] Check Pods Manifest.lock */ = { + F30CD4FEA1BDB49C8B84FB01 /* [CP] Embed Pods Frameworks */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( ); inputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-input-files.xcfilelist", ); - inputPaths = ( - "${PODS_PODFILE_DIR_PATH}/Podfile.lock", - "${PODS_ROOT}/Manifest.lock", - ); - name = "[CP] Check Pods Manifest.lock"; + name = "[CP] Embed Pods Frameworks"; outputFileListPaths = ( - ); - outputPaths = ( - "$(DERIVED_FILE_DIR)/Pods-Runner-checkManifestLockResult.txt", + "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-output-files.xcfilelist", ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n"; showEnvVarsInLog = 0; }; /* End PBXShellScriptBuildPhase section */ @@ -699,7 +699,7 @@ }; 8B5261642A7C463D00E9899E /* Debug */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 9DCB9EDE28DF57E29440CF22 /* Pods-RunnerTests.debug.xcconfig */; + baseConfigurationReference = AE0A38BE3137E8F7E92FEF51 /* Pods-RunnerTests.debug.xcconfig */; buildSettings = { BUNDLE_LOADER = "$(TEST_HOST)"; CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; @@ -729,7 +729,7 @@ }; 8B5261652A7C463D00E9899E /* Release */ = { isa = XCBuildConfiguration; - baseConfigurationReference = D0A6A6185A7A65698B8F4B1D /* Pods-RunnerTests.release.xcconfig */; + baseConfigurationReference = 10C22D07423926C20887DE48 /* Pods-RunnerTests.release.xcconfig */; buildSettings = { BUNDLE_LOADER = "$(TEST_HOST)"; CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; @@ -758,7 +758,7 @@ }; 8B5261662A7C463D00E9899E /* Profile */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 859D7659433CF3D1320F86CC /* Pods-RunnerTests.profile.xcconfig */; + baseConfigurationReference = DD914308A8C7B352FD10170F /* Pods-RunnerTests.profile.xcconfig */; buildSettings = { BUNDLE_LOADER = "$(TEST_HOST)"; CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; diff --git a/demos/supabase-todolist/pubspec.lock b/demos/supabase-todolist/pubspec.lock index c88b85fe..90c0e7bd 100644 --- a/demos/supabase-todolist/pubspec.lock +++ b/demos/supabase-todolist/pubspec.lock @@ -486,6 +486,13 @@ packages: relative: true source: path version: "0.6.15+1" + powersync_core: + dependency: "direct overridden" + description: + path: "../../packages/powersync_core" + relative: true + source: path + version: "0.0.1" powersync_flutter_libs: dependency: "direct overridden" description: diff --git a/demos/supabase-todolist/pubspec.yaml b/demos/supabase-todolist/pubspec.yaml index c13903d8..f3a3a78c 100644 --- a/demos/supabase-todolist/pubspec.yaml +++ b/demos/supabase-todolist/pubspec.yaml @@ -10,8 +10,8 @@ environment: dependencies: flutter: sdk: flutter - powersync_attachments_helper: ^0.6.15+2 - powersync: ^1.9.3 + powersync_attachments_helper: ^0.6.16 + powersync: ^1.10.0 path_provider: ^2.1.1 supabase_flutter: ^2.0.1 path: ^1.8.3 diff --git a/melos.yaml b/melos.yaml index 1a04f0a1..b06f3f1c 100644 --- a/melos.yaml +++ b/melos.yaml @@ -18,7 +18,7 @@ command: # Automatically update libraryVersion: preCommit: | dart run tool/update_version.dart - git add packages/powersync/lib/src/version.dart + git add packages/powersync_core/lib/src/version.dart publish: hooks: pre: dart ./scripts/download_core_binary_demos.dart # Download latest core binaries when publishing @@ -42,7 +42,7 @@ scripts: prepare:assets: description: Download Sqlite3 WASM for tests - run: dart ./bin/setup_web.dart --no-worker --output-dir assets + run: dart ./bin/setup_web.dart --no-worker --output-dir ../powersync_core/assets exec: concurrency: 1 packageFilters: diff --git a/packages/powersync/CHANGELOG.md b/packages/powersync/CHANGELOG.md index 43b2adf0..13037b47 100644 --- a/packages/powersync/CHANGELOG.md +++ b/packages/powersync/CHANGELOG.md @@ -1,10 +1,14 @@ +## 1.10.0 + +- This package now uses the `powersync_core` package to provide its base functionality. + ## 1.9.3 - - Update a dependency to the latest release. +- Update a dependency to the latest release. ## 1.9.2 - - [Web] Automatically flush IndexedDB storage to fix durability issues +- [Web] Automatically flush IndexedDB storage to fix durability issues ## 1.9.1 diff --git a/packages/powersync/README.md b/packages/powersync/README.md index e9fcf03d..472f153f 100644 --- a/packages/powersync/README.md +++ b/packages/powersync/README.md @@ -2,14 +2,20 @@

-# PowerSync SDK for Dart/Flutter +# PowerSync SDK for Flutter -*[PowerSync](https://www.powersync.com) is a sync engine for building local-first apps with instantly-responsive UI/UX and simplified state transfer. Syncs between SQLite on the client-side and Postgres, MongoDB or MySQL on the server-side.* +_[PowerSync](https://www.powersync.com) is a sync engine for building local-first apps with instantly-responsive UI/UX and simplified state transfer. Syncs between SQLite on the client-side and Postgres, MongoDB or MySQL on the server-side._ -This package (`powersync`) is the PowerSync client SDK for Dart/Flutter. +This package (`powersync`) is the PowerSync client SDK for Flutter. See a summary of features [here](https://docs.powersync.com/client-sdk-references/flutter). +> **Note** +> This package is recommended for Flutter applications that do not require on-device encryption. + +> - For Flutter applications that require encryption, use the [`powersync_sqlcipher`](https://pub.dev/packages/powersync_sqlcipher) package. +> - For use cases such as server-side Dart or non-Flutter Dart environments, use the [`powersync_core`](https://pub.dev/packages/powersync_core) package. + # Installation ```bash diff --git a/packages/powersync/example/README.md b/packages/powersync/example/README.md index 26741f48..9db577ab 100644 --- a/packages/powersync/example/README.md +++ b/packages/powersync/example/README.md @@ -1,5 +1,5 @@ # Examples - * [Getting started](./getting_started.dart) - * [Watching queries](./watching_changes.dart) - * [Batch writes](./batch_writes.dart) +- [Getting started](./getting_started.dart) +- [Watching queries](./watching_changes.dart) +- [Batch writes](./batch_writes.dart) diff --git a/packages/powersync/lib/powersync.dart b/packages/powersync/lib/powersync.dart index d931d4f4..c5e05872 100644 --- a/packages/powersync/lib/powersync.dart +++ b/packages/powersync/lib/powersync.dart @@ -1,15 +1,6 @@ -/// PowerSync Dart SDK. +/// PowerSync Flutter SDK. /// /// Use [PowerSyncDatabase] to open a database. library; -export 'src/connector.dart'; -export 'src/crud.dart'; -export 'src/database/powersync_database.dart'; -export 'src/exceptions.dart'; -export 'src/log.dart'; -export 'src/open_factory.dart'; -export 'src/powersync_database.dart'; -export 'src/schema.dart'; -export 'src/sync_status.dart'; -export 'src/uuid.dart'; +export 'package:powersync_core/powersync_core.dart'; diff --git a/packages/powersync/lib/sqlite3.dart b/packages/powersync/lib/sqlite3.dart index 66f87ad4..2941247e 100644 --- a/packages/powersync/lib/sqlite3.dart +++ b/packages/powersync/lib/sqlite3.dart @@ -2,4 +2,4 @@ /// adding it as a direct dependency. library; -export 'package:sqlite_async/sqlite3.dart'; +export 'package:powersync_core/sqlite3.dart'; diff --git a/packages/powersync/lib/sqlite3_common.dart b/packages/powersync/lib/sqlite3_common.dart index df84a8e0..52887937 100644 --- a/packages/powersync/lib/sqlite3_common.dart +++ b/packages/powersync/lib/sqlite3_common.dart @@ -2,4 +2,4 @@ /// adding it as a direct dependency. library; -export 'package:sqlite_async/sqlite3_common.dart'; +export 'package:powersync_core/sqlite3_common.dart'; diff --git a/packages/powersync/lib/sqlite3_open.dart b/packages/powersync/lib/sqlite3_open.dart new file mode 100644 index 00000000..fd364dc4 --- /dev/null +++ b/packages/powersync/lib/sqlite3_open.dart @@ -0,0 +1,5 @@ +/// Re-exports [sqlite3_open](https://pub.dev/packages/sqlite3) to expose sqlite3_open without +/// adding it as a direct dependency. +library; + +export 'package:powersync_core/sqlite3_open.dart'; diff --git a/packages/powersync/lib/sqlite_async.dart b/packages/powersync/lib/sqlite_async.dart index 1d09936d..6deed835 100644 --- a/packages/powersync/lib/sqlite_async.dart +++ b/packages/powersync/lib/sqlite_async.dart @@ -2,4 +2,4 @@ /// adding it as a direct dependency. library; -export 'package:sqlite_async/sqlite_async.dart'; +export 'package:powersync_core/sqlite_async.dart'; diff --git a/packages/powersync/lib/src/powersync_database.dart b/packages/powersync/lib/src/powersync_database.dart deleted file mode 100644 index c051b90d..00000000 --- a/packages/powersync/lib/src/powersync_database.dart +++ /dev/null @@ -1 +0,0 @@ -export 'package:powersync/src/database/powersync_database.dart'; diff --git a/packages/powersync/lib/src/version.dart b/packages/powersync/lib/src/version.dart deleted file mode 100644 index f3ee1336..00000000 --- a/packages/powersync/lib/src/version.dart +++ /dev/null @@ -1 +0,0 @@ -const String libraryVersion = '1.9.3'; diff --git a/packages/powersync/lib/web_worker.dart b/packages/powersync/lib/web_worker.dart index 19983751..5d7b86d3 100644 --- a/packages/powersync/lib/web_worker.dart +++ b/packages/powersync/lib/web_worker.dart @@ -1 +1 @@ -export 'src/web/powersync_db.worker.dart'; +export 'package:powersync_core/src/web/powersync_db.worker.dart'; diff --git a/packages/powersync/pubspec.yaml b/packages/powersync/pubspec.yaml index e7d7b91a..2faa17f4 100644 --- a/packages/powersync/pubspec.yaml +++ b/packages/powersync/pubspec.yaml @@ -1,5 +1,5 @@ name: powersync -version: 1.9.3 +version: 1.10.0 homepage: https://powersync.com repository: https://github.com/powersync-ja/powersync.dart description: PowerSync Flutter SDK - sync engine for building local-first apps. @@ -10,36 +10,17 @@ dependencies: flutter: sdk: flutter - sqlite_async: ^0.11.0 - # We only use sqlite3 as a transitive dependency, - # but right now we need a minimum of v2.4.6. - sqlite3: ^2.4.6 - universal_io: ^2.0.0 sqlite3_flutter_libs: ^0.5.23 + powersync_core: ^1.0.0 powersync_flutter_libs: ^0.4.3 - meta: ^1.0.0 - http: ^1.1.0 - uuid: ^4.2.0 - async: ^2.10.0 - logging: ^1.1.1 collection: ^1.17.0 - fetch_client: ^1.1.2 pubspec_parse: ^1.3.0 args: ^2.5.0 pub_semver: ^2.1.4 - js: ^0.7.0 - web: ^1.0.0 dev_dependencies: - dcli: ^4.0.0 lints: ^3.0.0 - test: ^1.25.0 - test_api: ^0.7.0 - path_provider: ^2.0.13 - shelf: ^1.4.1 - shelf_router: ^1.1.4 - shelf_static: ^1.1.2 - stream_channel: ^2.1.2 path: ^1.8.3 + path_provider: ^2.0.13 platforms: android: diff --git a/packages/powersync_attachments_helper/CHANGELOG.md b/packages/powersync_attachments_helper/CHANGELOG.md index 74acae9b..564b41c7 100644 --- a/packages/powersync_attachments_helper/CHANGELOG.md +++ b/packages/powersync_attachments_helper/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.6.16 + + - Update a dependency to the latest release. + ## 0.6.15+2 - Update a dependency to the latest release. diff --git a/packages/powersync_attachments_helper/README.md b/packages/powersync_attachments_helper/README.md index a44f8c9d..dbd65bef 100644 --- a/packages/powersync_attachments_helper/README.md +++ b/packages/powersync_attachments_helper/README.md @@ -4,14 +4,14 @@ ## Features -* Handles syncing uploads, downloads and deletes between local and remote storage. +- Handles syncing uploads, downloads and deletes between local and remote storage. ## Getting started ```dart import 'dart:async'; import 'package:powersync_attachments_helper/powersync_attachments_helper.dart'; -import 'package:powersync/powersync.dart'; +import 'package:powersync_core/powersync_core.dart'; // Set up schema with an id field that can be used in watchIds(). // In this case it is photo_id diff --git a/packages/powersync_attachments_helper/example/getting_started.dart b/packages/powersync_attachments_helper/example/getting_started.dart index f5302508..5ed2000b 100644 --- a/packages/powersync_attachments_helper/example/getting_started.dart +++ b/packages/powersync_attachments_helper/example/getting_started.dart @@ -1,7 +1,7 @@ import 'dart:async'; import 'package:powersync_attachments_helper/powersync_attachments_helper.dart'; -import 'package:powersync/powersync.dart'; +import 'package:powersync_core/powersync_core.dart'; const schema = Schema([ Table('users', [Column.text('name'), Column.text('photo_id')]) diff --git a/packages/powersync_attachments_helper/lib/src/attachments_queue.dart b/packages/powersync_attachments_helper/lib/src/attachments_queue.dart index 7ceb8208..1f2a1b35 100644 --- a/packages/powersync_attachments_helper/lib/src/attachments_queue.dart +++ b/packages/powersync_attachments_helper/lib/src/attachments_queue.dart @@ -6,7 +6,7 @@ import './local_storage_adapter.dart'; import './remote_storage_adapter.dart'; import './syncing_service.dart'; import 'package:logging/logging.dart'; -import 'package:powersync/powersync.dart'; +import 'package:powersync_core/powersync_core.dart'; /// Logger for the attachment queue final log = Logger('AttachmentQueue'); diff --git a/packages/powersync_attachments_helper/lib/src/attachments_queue_table.dart b/packages/powersync_attachments_helper/lib/src/attachments_queue_table.dart index 91e940b5..ffa3fb20 100644 --- a/packages/powersync_attachments_helper/lib/src/attachments_queue_table.dart +++ b/packages/powersync_attachments_helper/lib/src/attachments_queue_table.dart @@ -1,5 +1,5 @@ -import 'package:powersync/powersync.dart'; -import 'package:powersync/sqlite3_common.dart' as sqlite; +import 'package:powersync_core/powersync_core.dart'; +import 'package:powersync_core/sqlite3_common.dart' as sqlite; const defaultAttachmentsQueueTableName = 'attachments_queue'; diff --git a/packages/powersync_attachments_helper/lib/src/attachments_service.dart b/packages/powersync_attachments_helper/lib/src/attachments_service.dart index 0383a393..689fef22 100644 --- a/packages/powersync_attachments_helper/lib/src/attachments_service.dart +++ b/packages/powersync_attachments_helper/lib/src/attachments_service.dart @@ -1,8 +1,8 @@ import './attachments_queue.dart'; import './attachments_queue_table.dart'; import './local_storage_adapter.dart'; -import 'package:powersync/powersync.dart'; -import 'package:powersync/sqlite3_common.dart'; +import 'package:powersync_core/powersync_core.dart'; +import 'package:powersync_core/sqlite3_common.dart'; /// Service for interacting with the attachment queue. class AttachmentsService { diff --git a/packages/powersync_attachments_helper/lib/src/syncing_service.dart b/packages/powersync_attachments_helper/lib/src/syncing_service.dart index 93c2300c..664f068b 100644 --- a/packages/powersync_attachments_helper/lib/src/syncing_service.dart +++ b/packages/powersync_attachments_helper/lib/src/syncing_service.dart @@ -4,7 +4,7 @@ import 'dart:typed_data'; import './attachments_queue.dart'; import './local_storage_adapter.dart'; import './remote_storage_adapter.dart'; -import 'package:powersync/powersync.dart'; +import 'package:powersync_core/powersync_core.dart'; import 'attachments_queue_table.dart'; import 'attachments_service.dart'; diff --git a/packages/powersync_attachments_helper/pubspec.yaml b/packages/powersync_attachments_helper/pubspec.yaml index 53779451..35be20be 100644 --- a/packages/powersync_attachments_helper/pubspec.yaml +++ b/packages/powersync_attachments_helper/pubspec.yaml @@ -1,6 +1,6 @@ name: powersync_attachments_helper description: A helper library for handling attachments when using PowerSync. -version: 0.6.15+2 +version: 0.6.16 repository: https://github.com/powersync-ja/powersync.dart homepage: https://www.powersync.com/ environment: @@ -10,7 +10,7 @@ dependencies: flutter: sdk: flutter - powersync: ^1.9.3 + powersync_core: ^1.0.0 logging: ^1.2.0 sqlite_async: ^0.11.0 path_provider: ^2.0.13 diff --git a/packages/powersync_core/.gitignore b/packages/powersync_core/.gitignore new file mode 100644 index 00000000..ddfb9c2a --- /dev/null +++ b/packages/powersync_core/.gitignore @@ -0,0 +1,9 @@ +# https://dart.dev/guides/libraries/private-files +# Created by `dart pub` +.dart_tool/ + +# Avoid committing pubspec.lock for library packages; see +# https://dart.dev/guides/libraries/private-files#pubspeclock. +pubspec.lock + +/test-db \ No newline at end of file diff --git a/packages/powersync_core/CHANGELOG.md b/packages/powersync_core/CHANGELOG.md new file mode 100644 index 00000000..9b19f65d --- /dev/null +++ b/packages/powersync_core/CHANGELOG.md @@ -0,0 +1,3 @@ +## 1.0.0 + + - Dart library for Powersync for use cases such as server-side Dart or non-Flutter Dart environments initial release. diff --git a/packages/powersync_core/LICENSE b/packages/powersync_core/LICENSE new file mode 100644 index 00000000..f433b1a5 --- /dev/null +++ b/packages/powersync_core/LICENSE @@ -0,0 +1,177 @@ + + 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 diff --git a/packages/powersync_core/NOTICE b/packages/powersync_core/NOTICE new file mode 100644 index 00000000..da0d4ce5 --- /dev/null +++ b/packages/powersync_core/NOTICE @@ -0,0 +1 @@ +Copyright 2024 Journey Mobile, Inc. diff --git a/packages/powersync_core/README.md b/packages/powersync_core/README.md new file mode 100644 index 00000000..642baa15 --- /dev/null +++ b/packages/powersync_core/README.md @@ -0,0 +1,36 @@ +

+ +

+ +# PowerSync SDK for Dart + +*[PowerSync](https://www.powersync.com) is a sync engine for building local-first apps with instantly-responsive UI/UX and simplified state transfer. Syncs between SQLite on the client-side and Postgres, MongoDB or MySQL on the server-side.* + +This package (`powersync_core`) is the PowerSync client SDK for Dart. + +> **Note** +> +> This is a Dart library for Powersync for use cases such as server-side Dart or non-Flutter Dart environments. +> This library requires sqlite3 with extension loading enabled to be installed on your system. +> +> If you are developing a Flutter application, use [powersync](https://pub.dev/packages/powersync) or [powersync_sqlcipher](https://pub.dev/packages/powersync_sqlcipher) instead. The `powersync_core` package is for non-Flutter Dart environments. + +# Installation + +```bash +dart pub add powersync_core +``` + +# Changelog + +A changelog for this SDK is available [here](https://pub.dev/packages/powersync_core/changelog). + +# API Reference + +The full API reference for this SDK can be found [here](https://pub.dev/documentation/powersync_core/latest/powersync_core/powersync_core-library.html). + +# Found a bug or need help? + +- Join our [Discord server](https://discord.gg/powersync) where you can browse topics from our community, ask questions, share feedback, or just say hello :) +- Please open a [GitHub issue](https://github.com/powersync-ja/powersync.dart/issues) when you come across a bug. +- Have feedback or an idea? [Submit an idea](https://roadmap.powersync.com/tabs/5-roadmap/submit-idea) via our public roadmap or [schedule a chat](https://calendly.com/powersync/powersync-chat) with someone from our product team. diff --git a/packages/powersync_core/analysis_options.yaml b/packages/powersync_core/analysis_options.yaml new file mode 100644 index 00000000..dee8927a --- /dev/null +++ b/packages/powersync_core/analysis_options.yaml @@ -0,0 +1,30 @@ +# This file configures the static analysis results for your project (errors, +# warnings, and lints). +# +# This enables the 'recommended' set of lints from `package:lints`. +# This set helps identify many issues that may lead to problems when running +# or consuming Dart code, and enforces writing Dart using a single, idiomatic +# style and format. +# +# If you want a smaller set of lints you can change this to specify +# 'package:lints/core.yaml'. These are just the most critical lints +# (the recommended set includes the core lints). +# The core lints are also what is used by pub.dev for scoring packages. + +include: package:lints/recommended.yaml + +# Uncomment the following section to specify additional rules. + +# linter: +# rules: +# - camel_case_types + +# analyzer: +# exclude: +# - path/to/excluded/files/** + +# For more information about the core and recommended set of lints, see +# https://dart.dev/go/core-lints + +# For additional information about configuring this file, see +# https://dart.dev/guides/language/analysis-options diff --git a/packages/powersync_core/assets/.gitkeep b/packages/powersync_core/assets/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/packages/powersync_core/example/README.md b/packages/powersync_core/example/README.md new file mode 100644 index 00000000..8dbcfb60 --- /dev/null +++ b/packages/powersync_core/example/README.md @@ -0,0 +1,3 @@ +# Examples + +- [Getting started](./getting_started.dart) diff --git a/packages/powersync_core/example/getting_started.dart b/packages/powersync_core/example/getting_started.dart new file mode 100644 index 00000000..eb291b3b --- /dev/null +++ b/packages/powersync_core/example/getting_started.dart @@ -0,0 +1,109 @@ +import 'dart:ffi'; +import 'dart:io'; + +import 'package:powersync_core/powersync_core.dart'; +import 'package:path/path.dart'; +import 'package:powersync_core/sqlite3.dart' as sqlite; +import 'package:powersync_core/sqlite3_common.dart'; +import 'package:powersync_core/sqlite_async.dart'; +import 'package:powersync_core/sqlite3_open.dart' as sqlite_open; + +const schema = Schema([ + Table('customers', [Column.text('name'), Column.text('email')]) +]); + +late PowerSyncDatabase db; + +// Setup connector to backend if you would like to sync data. +class BackendConnector extends PowerSyncBackendConnector { + PowerSyncDatabase db; + + BackendConnector(this.db); + @override + // ignore: body_might_complete_normally_nullable + Future fetchCredentials() async { + // implement fetchCredentials + } + @override + Future uploadData(PowerSyncDatabase database) async { + // implement uploadData + } +} + +/// Custom factory to load the PowerSync extension. +/// This is required to load the extension from a custom location. +/// The extension is required to sync data with the backend. +/// On macOS and Linux, the default sqlite3 library is overridden to load the extension. +class PowerSyncDartOpenFactory extends PowerSyncOpenFactory { + PowerSyncDartOpenFactory({required super.path, super.sqliteOptions}); + + @override + CommonDatabase open(SqliteOpenOptions options) { + sqlite_open.open.overrideFor(sqlite_open.OperatingSystem.linux, () { + return DynamicLibrary.open('libsqlite3.so.0'); + }); + sqlite_open.open.overrideFor(sqlite_open.OperatingSystem.macOS, () { + return DynamicLibrary.open('libsqlite3.dylib'); + }); + return super.open(options); + } + + @override + void enableExtension() { + var powersyncLib = DynamicLibrary.open(getLibraryForPlatform()); + sqlite.sqlite3.ensureExtensionLoaded(sqlite.SqliteExtension.inLibrary( + powersyncLib, 'sqlite3_powersync_init')); + } + + @override + String getLibraryForPlatform({String? path = "."}) { + switch (Abi.current()) { + case Abi.androidArm: + case Abi.androidArm64: + case Abi.androidX64: + return '$path/libpowersync.so'; + case Abi.macosArm64: + case Abi.macosX64: + return '$path/libpowersync.dylib'; + case Abi.linuxX64: + case Abi.linuxArm64: + return '$path/libpowersync.so'; + case Abi.windowsX64: + return '$path/powersync.dll'; + case Abi.androidIA32: + throw PowersyncNotReadyException( + 'Unsupported processor architecture. X86 Android emulators are not ' + 'supported. Please use an x86_64 emulator instead. All physical ' + 'Android devices are supported including 32bit ARM.', + ); + default: + throw PowersyncNotReadyException( + 'Unsupported processor architecture "${Abi.current()}". ' + 'Please open an issue on GitHub to request it.', + ); + } + } +} + +Future getDatabasePath() async { + const dbFilename = 'powersync-demo.db'; + final dir = (Directory.current.uri).toFilePath(); + return join(dir, dbFilename); +} + +openDatabase() async { + // Setup the database. + final psFactory = PowerSyncDartOpenFactory(path: await getDatabasePath()); + db = PowerSyncDatabase.withFactory(psFactory, schema: schema); + + // Initialise the database. + await db.initialize(); + + // Run local statements. + await db.execute( + 'INSERT INTO customers(id, name, email) VALUES(uuid(), ?, ?)', + ['Fred', 'fred@example.org']); + + // Connect to backend + db.connect(connector: BackendConnector(db)); +} diff --git a/packages/powersync_core/lib/powersync_core.dart b/packages/powersync_core/lib/powersync_core.dart new file mode 100644 index 00000000..d931d4f4 --- /dev/null +++ b/packages/powersync_core/lib/powersync_core.dart @@ -0,0 +1,15 @@ +/// PowerSync Dart SDK. +/// +/// Use [PowerSyncDatabase] to open a database. +library; + +export 'src/connector.dart'; +export 'src/crud.dart'; +export 'src/database/powersync_database.dart'; +export 'src/exceptions.dart'; +export 'src/log.dart'; +export 'src/open_factory.dart'; +export 'src/powersync_database.dart'; +export 'src/schema.dart'; +export 'src/sync_status.dart'; +export 'src/uuid.dart'; diff --git a/packages/powersync_core/lib/sqlite3.dart b/packages/powersync_core/lib/sqlite3.dart new file mode 100644 index 00000000..66f87ad4 --- /dev/null +++ b/packages/powersync_core/lib/sqlite3.dart @@ -0,0 +1,5 @@ +/// Re-exports [sqlite3](https://pub.dev/packages/sqlite3) to expose sqlite3 without +/// adding it as a direct dependency. +library; + +export 'package:sqlite_async/sqlite3.dart'; diff --git a/packages/powersync_core/lib/sqlite3_common.dart b/packages/powersync_core/lib/sqlite3_common.dart new file mode 100644 index 00000000..df84a8e0 --- /dev/null +++ b/packages/powersync_core/lib/sqlite3_common.dart @@ -0,0 +1,5 @@ +/// Re-exports [sqlite3_common](https://pub.dev/packages/sqlite3) to expose sqlite3_common without +/// adding it as a direct dependency. +library; + +export 'package:sqlite_async/sqlite3_common.dart'; diff --git a/packages/powersync_core/lib/sqlite3_open.dart b/packages/powersync_core/lib/sqlite3_open.dart new file mode 100644 index 00000000..b5659245 --- /dev/null +++ b/packages/powersync_core/lib/sqlite3_open.dart @@ -0,0 +1,5 @@ +/// Re-exports [sqlite3_open](https://pub.dev/packages/sqlite3) to expose sqlite3_open without +/// adding it as a direct dependency. +library; + +export 'package:sqlite_async/sqlite3_open.dart'; diff --git a/packages/powersync_core/lib/sqlite_async.dart b/packages/powersync_core/lib/sqlite_async.dart new file mode 100644 index 00000000..1d09936d --- /dev/null +++ b/packages/powersync_core/lib/sqlite_async.dart @@ -0,0 +1,5 @@ +/// Re-exports [sqlite_async](https://pub.dev/packages/sqlite_async) to expose sqlite_async without +/// adding it as a direct dependency. +library; + +export 'package:sqlite_async/sqlite_async.dart'; diff --git a/packages/powersync/lib/src/abort_controller.dart b/packages/powersync_core/lib/src/abort_controller.dart similarity index 100% rename from packages/powersync/lib/src/abort_controller.dart rename to packages/powersync_core/lib/src/abort_controller.dart diff --git a/packages/powersync/lib/src/bucket_storage.dart b/packages/powersync_core/lib/src/bucket_storage.dart similarity index 99% rename from packages/powersync/lib/src/bucket_storage.dart rename to packages/powersync_core/lib/src/bucket_storage.dart index ab26f654..27c090a1 100644 --- a/packages/powersync/lib/src/bucket_storage.dart +++ b/packages/powersync_core/lib/src/bucket_storage.dart @@ -2,8 +2,8 @@ import 'dart:async'; import 'dart:convert'; import 'package:collection/collection.dart'; -import 'package:powersync/sqlite_async.dart'; -import 'package:powersync/sqlite3_common.dart'; +import 'package:powersync_core/sqlite_async.dart'; +import 'package:powersync_core/sqlite3_common.dart'; import 'crud.dart'; import 'schema_logic.dart'; diff --git a/packages/powersync/lib/src/connector.dart b/packages/powersync_core/lib/src/connector.dart similarity index 100% rename from packages/powersync/lib/src/connector.dart rename to packages/powersync_core/lib/src/connector.dart diff --git a/packages/powersync/lib/src/crud.dart b/packages/powersync_core/lib/src/crud.dart similarity index 98% rename from packages/powersync/lib/src/crud.dart rename to packages/powersync_core/lib/src/crud.dart index 3ca4c288..5a11ae4d 100644 --- a/packages/powersync/lib/src/crud.dart +++ b/packages/powersync_core/lib/src/crud.dart @@ -1,7 +1,7 @@ import 'dart:convert'; import 'package:collection/collection.dart'; -import 'package:powersync/sqlite3_common.dart' as sqlite; +import 'package:powersync_core/sqlite3_common.dart' as sqlite; /// A batch of client-side changes. class CrudBatch { diff --git a/packages/powersync/lib/src/database/native/native_powersync_database.dart b/packages/powersync_core/lib/src/database/native/native_powersync_database.dart similarity index 94% rename from packages/powersync/lib/src/database/native/native_powersync_database.dart rename to packages/powersync_core/lib/src/database/native/native_powersync_database.dart index e62f8ac8..a2a6d028 100644 --- a/packages/powersync/lib/src/database/native/native_powersync_database.dart +++ b/packages/powersync_core/lib/src/database/native/native_powersync_database.dart @@ -4,20 +4,20 @@ import 'package:meta/meta.dart'; import 'package:http/http.dart' as http; import 'package:logging/logging.dart'; -import 'package:powersync/src/abort_controller.dart'; -import 'package:powersync/src/bucket_storage.dart'; -import 'package:powersync/src/connector.dart'; -import 'package:powersync/src/database/powersync_database.dart'; -import 'package:powersync/src/database/powersync_db_mixin.dart'; -import 'package:powersync/src/isolate_completer.dart'; -import 'package:powersync/src/log.dart'; -import 'package:powersync/src/log_internal.dart'; -import 'package:powersync/src/open_factory/abstract_powersync_open_factory.dart'; -import 'package:powersync/src/open_factory/native/native_open_factory.dart'; -import 'package:powersync/src/schema.dart'; -import 'package:powersync/src/schema_logic.dart'; -import 'package:powersync/src/streaming_sync.dart'; -import 'package:powersync/src/sync_status.dart'; +import 'package:powersync_core/src/abort_controller.dart'; +import 'package:powersync_core/src/bucket_storage.dart'; +import 'package:powersync_core/src/connector.dart'; +import 'package:powersync_core/src/database/powersync_database.dart'; +import 'package:powersync_core/src/database/powersync_db_mixin.dart'; +import 'package:powersync_core/src/isolate_completer.dart'; +import 'package:powersync_core/src/log.dart'; +import 'package:powersync_core/src/log_internal.dart'; +import 'package:powersync_core/src/open_factory/abstract_powersync_open_factory.dart'; +import 'package:powersync_core/src/open_factory/native/native_open_factory.dart'; +import 'package:powersync_core/src/schema.dart'; +import 'package:powersync_core/src/schema_logic.dart'; +import 'package:powersync_core/src/streaming_sync.dart'; +import 'package:powersync_core/src/sync_status.dart'; import 'package:sqlite_async/sqlite3_common.dart'; import 'package:sqlite_async/sqlite_async.dart'; diff --git a/packages/powersync/lib/src/database/powersync_database.dart b/packages/powersync_core/lib/src/database/powersync_database.dart similarity index 92% rename from packages/powersync/lib/src/database/powersync_database.dart rename to packages/powersync_core/lib/src/database/powersync_database.dart index 96a48ef6..528b029f 100644 --- a/packages/powersync/lib/src/database/powersync_database.dart +++ b/packages/powersync_core/lib/src/database/powersync_database.dart @@ -1,7 +1,7 @@ import 'package:logging/logging.dart'; -import 'package:powersync/src/database/powersync_database_impl.dart'; -import 'package:powersync/src/database/powersync_db_mixin.dart'; -import 'package:powersync/src/open_factory/abstract_powersync_open_factory.dart'; +import 'package:powersync_core/src/database/powersync_database_impl.dart'; +import 'package:powersync_core/src/database/powersync_db_mixin.dart'; +import 'package:powersync_core/src/open_factory/abstract_powersync_open_factory.dart'; import 'package:sqlite_async/sqlite_async.dart'; import '../schema.dart'; diff --git a/packages/powersync/lib/src/database/powersync_database_impl.dart b/packages/powersync_core/lib/src/database/powersync_database_impl.dart similarity index 100% rename from packages/powersync/lib/src/database/powersync_database_impl.dart rename to packages/powersync_core/lib/src/database/powersync_database_impl.dart diff --git a/packages/powersync/lib/src/database/powersync_database_impl_stub.dart b/packages/powersync_core/lib/src/database/powersync_database_impl_stub.dart similarity index 94% rename from packages/powersync/lib/src/database/powersync_database_impl_stub.dart rename to packages/powersync_core/lib/src/database/powersync_database_impl_stub.dart index 68faf631..a4b0ce80 100644 --- a/packages/powersync/lib/src/database/powersync_database_impl_stub.dart +++ b/packages/powersync_core/lib/src/database/powersync_database_impl_stub.dart @@ -2,9 +2,9 @@ import 'dart:async'; import 'package:logging/logging.dart'; import 'package:meta/meta.dart'; -import 'package:powersync/sqlite_async.dart'; -import 'package:powersync/src/database/powersync_db_mixin.dart'; -import 'package:powersync/src/open_factory/abstract_powersync_open_factory.dart'; +import 'package:powersync_core/sqlite_async.dart'; +import 'package:powersync_core/src/database/powersync_db_mixin.dart'; +import 'package:powersync_core/src/open_factory/abstract_powersync_open_factory.dart'; import 'powersync_database.dart'; import '../connector.dart'; diff --git a/packages/powersync/lib/src/database/powersync_db_mixin.dart b/packages/powersync_core/lib/src/database/powersync_db_mixin.dart similarity index 96% rename from packages/powersync/lib/src/database/powersync_db_mixin.dart rename to packages/powersync_core/lib/src/database/powersync_db_mixin.dart index af8156e1..bc359616 100644 --- a/packages/powersync/lib/src/database/powersync_db_mixin.dart +++ b/packages/powersync_core/lib/src/database/powersync_db_mixin.dart @@ -2,15 +2,15 @@ import 'dart:async'; import 'package:logging/logging.dart'; import 'package:meta/meta.dart'; -import 'package:powersync/sqlite3_common.dart'; -import 'package:powersync/sqlite_async.dart'; -import 'package:powersync/src/abort_controller.dart'; -import 'package:powersync/src/connector.dart'; -import 'package:powersync/src/crud.dart'; -import 'package:powersync/src/powersync_update_notification.dart'; -import 'package:powersync/src/schema.dart'; -import 'package:powersync/src/schema_logic.dart'; -import 'package:powersync/src/sync_status.dart'; +import 'package:powersync_core/sqlite3_common.dart'; +import 'package:powersync_core/sqlite_async.dart'; +import 'package:powersync_core/src/abort_controller.dart'; +import 'package:powersync_core/src/connector.dart'; +import 'package:powersync_core/src/crud.dart'; +import 'package:powersync_core/src/powersync_update_notification.dart'; +import 'package:powersync_core/src/schema.dart'; +import 'package:powersync_core/src/schema_logic.dart'; +import 'package:powersync_core/src/sync_status.dart'; mixin PowerSyncDatabaseMixin implements SqliteConnection { /// Schema used for the local database. diff --git a/packages/powersync/lib/src/database/web/web_powersync_database.dart b/packages/powersync_core/lib/src/database/web/web_powersync_database.dart similarity index 91% rename from packages/powersync/lib/src/database/web/web_powersync_database.dart rename to packages/powersync_core/lib/src/database/web/web_powersync_database.dart index f75c7beb..b981319c 100644 --- a/packages/powersync/lib/src/database/web/web_powersync_database.dart +++ b/packages/powersync_core/lib/src/database/web/web_powersync_database.dart @@ -2,18 +2,18 @@ import 'dart:async'; import 'package:meta/meta.dart'; import 'package:fetch_client/fetch_client.dart'; import 'package:logging/logging.dart'; -import 'package:powersync/src/abort_controller.dart'; -import 'package:powersync/src/bucket_storage.dart'; -import 'package:powersync/src/connector.dart'; -import 'package:powersync/src/database/powersync_database.dart'; -import 'package:powersync/src/database/powersync_db_mixin.dart'; -import 'package:powersync/src/log.dart'; -import 'package:powersync/src/open_factory/abstract_powersync_open_factory.dart'; -import 'package:powersync/src/open_factory/web/web_open_factory.dart'; -import 'package:powersync/src/schema.dart'; -import 'package:powersync/src/streaming_sync.dart'; +import 'package:powersync_core/src/abort_controller.dart'; +import 'package:powersync_core/src/bucket_storage.dart'; +import 'package:powersync_core/src/connector.dart'; +import 'package:powersync_core/src/database/powersync_database.dart'; +import 'package:powersync_core/src/database/powersync_db_mixin.dart'; +import 'package:powersync_core/src/log.dart'; +import 'package:powersync_core/src/open_factory/abstract_powersync_open_factory.dart'; +import 'package:powersync_core/src/open_factory/web/web_open_factory.dart'; +import 'package:powersync_core/src/schema.dart'; +import 'package:powersync_core/src/streaming_sync.dart'; import 'package:sqlite_async/sqlite_async.dart'; -import 'package:powersync/src/schema_logic.dart' as schema_logic; +import 'package:powersync_core/src/schema_logic.dart' as schema_logic; import '../../web/sync_controller.dart'; diff --git a/packages/powersync/lib/src/exceptions.dart b/packages/powersync_core/lib/src/exceptions.dart similarity index 100% rename from packages/powersync/lib/src/exceptions.dart rename to packages/powersync_core/lib/src/exceptions.dart diff --git a/packages/powersync/lib/src/isolate_completer.dart b/packages/powersync_core/lib/src/isolate_completer.dart similarity index 100% rename from packages/powersync/lib/src/isolate_completer.dart rename to packages/powersync_core/lib/src/isolate_completer.dart diff --git a/packages/powersync/lib/src/log.dart b/packages/powersync_core/lib/src/log.dart similarity index 95% rename from packages/powersync/lib/src/log.dart rename to packages/powersync_core/lib/src/log.dart index c628295b..0d0ef1ce 100644 --- a/packages/powersync/lib/src/log.dart +++ b/packages/powersync_core/lib/src/log.dart @@ -1,5 +1,5 @@ import 'package:logging/logging.dart'; -import 'package:powersync/src/log_internal.dart'; +import 'package:powersync_core/src/log_internal.dart'; /// Logger that outputs to the console in debug mode, and nothing /// in release and profile modes. diff --git a/packages/powersync/lib/src/log_internal.dart b/packages/powersync_core/lib/src/log_internal.dart similarity index 100% rename from packages/powersync/lib/src/log_internal.dart rename to packages/powersync_core/lib/src/log_internal.dart diff --git a/packages/powersync/lib/src/open_factory.dart b/packages/powersync_core/lib/src/open_factory.dart similarity index 100% rename from packages/powersync/lib/src/open_factory.dart rename to packages/powersync_core/lib/src/open_factory.dart diff --git a/packages/powersync/lib/src/open_factory/abstract_powersync_open_factory.dart b/packages/powersync_core/lib/src/open_factory/abstract_powersync_open_factory.dart similarity index 95% rename from packages/powersync/lib/src/open_factory/abstract_powersync_open_factory.dart rename to packages/powersync_core/lib/src/open_factory/abstract_powersync_open_factory.dart index 06e8feda..d5666fad 100644 --- a/packages/powersync/lib/src/open_factory/abstract_powersync_open_factory.dart +++ b/packages/powersync_core/lib/src/open_factory/abstract_powersync_open_factory.dart @@ -2,8 +2,8 @@ import 'dart:async'; import 'package:universal_io/io.dart'; import 'dart:math'; -import 'package:powersync/sqlite_async.dart'; -import 'package:powersync/src/open_factory/common_db_functions.dart'; +import 'package:powersync_core/sqlite_async.dart'; +import 'package:powersync_core/src/open_factory/common_db_functions.dart'; import 'package:sqlite_async/sqlite3_common.dart'; const powerSyncDefaultSqliteOptions = SqliteOptions( diff --git a/packages/powersync/lib/src/open_factory/common_db_functions.dart b/packages/powersync_core/lib/src/open_factory/common_db_functions.dart similarity index 100% rename from packages/powersync/lib/src/open_factory/common_db_functions.dart rename to packages/powersync_core/lib/src/open_factory/common_db_functions.dart diff --git a/packages/powersync/lib/src/open_factory/native/native_open_factory.dart b/packages/powersync_core/lib/src/open_factory/native/native_open_factory.dart similarity index 94% rename from packages/powersync/lib/src/open_factory/native/native_open_factory.dart rename to packages/powersync_core/lib/src/open_factory/native/native_open_factory.dart index e2cbd575..f564d349 100644 --- a/packages/powersync/lib/src/open_factory/native/native_open_factory.dart +++ b/packages/powersync_core/lib/src/open_factory/native/native_open_factory.dart @@ -1,9 +1,10 @@ import 'dart:ffi'; -import 'package:powersync/powersync.dart'; +import 'package:powersync_core/src/exceptions.dart'; +import 'package:powersync_core/src/log.dart'; import 'package:universal_io/io.dart'; import 'dart:isolate'; -import 'package:powersync/src/open_factory/abstract_powersync_open_factory.dart'; +import 'package:powersync_core/src/open_factory/abstract_powersync_open_factory.dart'; import 'package:sqlite_async/sqlite3.dart' as sqlite; import 'package:sqlite_async/sqlite3_common.dart'; import 'package:sqlite_async/sqlite_async.dart'; diff --git a/packages/powersync/lib/src/open_factory/open_factory_stub.dart b/packages/powersync_core/lib/src/open_factory/open_factory_stub.dart similarity index 100% rename from packages/powersync/lib/src/open_factory/open_factory_stub.dart rename to packages/powersync_core/lib/src/open_factory/open_factory_stub.dart diff --git a/packages/powersync/lib/src/open_factory/web/web_open_factory.dart b/packages/powersync_core/lib/src/open_factory/web/web_open_factory.dart similarity index 91% rename from packages/powersync/lib/src/open_factory/web/web_open_factory.dart rename to packages/powersync_core/lib/src/open_factory/web/web_open_factory.dart index 8c137393..bf4cf979 100644 --- a/packages/powersync/lib/src/open_factory/web/web_open_factory.dart +++ b/packages/powersync_core/lib/src/open_factory/web/web_open_factory.dart @@ -1,7 +1,7 @@ import 'dart:async'; -import 'package:powersync/src/open_factory/abstract_powersync_open_factory.dart'; -import 'package:powersync/src/uuid.dart'; +import 'package:powersync_core/src/open_factory/abstract_powersync_open_factory.dart'; +import 'package:powersync_core/src/uuid.dart'; import 'package:sqlite_async/sqlite3_common.dart'; import 'package:sqlite_async/sqlite_async.dart'; diff --git a/packages/powersync_core/lib/src/powersync_database.dart b/packages/powersync_core/lib/src/powersync_database.dart new file mode 100644 index 00000000..144a7df4 --- /dev/null +++ b/packages/powersync_core/lib/src/powersync_database.dart @@ -0,0 +1 @@ +export 'package:powersync_core/src/database/powersync_database.dart'; diff --git a/packages/powersync/lib/src/powersync_update_notification.dart b/packages/powersync_core/lib/src/powersync_update_notification.dart similarity index 100% rename from packages/powersync/lib/src/powersync_update_notification.dart rename to packages/powersync_core/lib/src/powersync_update_notification.dart diff --git a/packages/powersync/lib/src/schema.dart b/packages/powersync_core/lib/src/schema.dart similarity index 100% rename from packages/powersync/lib/src/schema.dart rename to packages/powersync_core/lib/src/schema.dart diff --git a/packages/powersync/lib/src/schema_logic.dart b/packages/powersync_core/lib/src/schema_logic.dart similarity index 100% rename from packages/powersync/lib/src/schema_logic.dart rename to packages/powersync_core/lib/src/schema_logic.dart diff --git a/packages/powersync/lib/src/stream_utils.dart b/packages/powersync_core/lib/src/stream_utils.dart similarity index 100% rename from packages/powersync/lib/src/stream_utils.dart rename to packages/powersync_core/lib/src/stream_utils.dart diff --git a/packages/powersync/lib/src/streaming_sync.dart b/packages/powersync_core/lib/src/streaming_sync.dart similarity index 98% rename from packages/powersync/lib/src/streaming_sync.dart rename to packages/powersync_core/lib/src/streaming_sync.dart index 27c1bd62..6f4191ff 100644 --- a/packages/powersync/lib/src/streaming_sync.dart +++ b/packages/powersync_core/lib/src/streaming_sync.dart @@ -2,10 +2,10 @@ import 'dart:async'; import 'dart:convert' as convert; import 'package:http/http.dart' as http; -import 'package:powersync/src/abort_controller.dart'; -import 'package:powersync/src/exceptions.dart'; -import 'package:powersync/src/log_internal.dart'; -import 'package:powersync/src/user_agent/user_agent.dart'; +import 'package:powersync_core/src/abort_controller.dart'; +import 'package:powersync_core/src/exceptions.dart'; +import 'package:powersync_core/src/log_internal.dart'; +import 'package:powersync_core/src/user_agent/user_agent.dart'; import 'package:sqlite_async/mutex.dart'; import 'bucket_storage.dart'; diff --git a/packages/powersync/lib/src/sync_status.dart b/packages/powersync_core/lib/src/sync_status.dart similarity index 100% rename from packages/powersync/lib/src/sync_status.dart rename to packages/powersync_core/lib/src/sync_status.dart diff --git a/packages/powersync/lib/src/sync_types.dart b/packages/powersync_core/lib/src/sync_types.dart similarity index 100% rename from packages/powersync/lib/src/sync_types.dart rename to packages/powersync_core/lib/src/sync_types.dart diff --git a/packages/powersync/lib/src/user_agent/user_agent.dart b/packages/powersync_core/lib/src/user_agent/user_agent.dart similarity index 100% rename from packages/powersync/lib/src/user_agent/user_agent.dart rename to packages/powersync_core/lib/src/user_agent/user_agent.dart diff --git a/packages/powersync/lib/src/user_agent/user_agent_native.dart b/packages/powersync_core/lib/src/user_agent/user_agent_native.dart similarity index 76% rename from packages/powersync/lib/src/user_agent/user_agent_native.dart rename to packages/powersync_core/lib/src/user_agent/user_agent_native.dart index 018ddf87..ab1638c5 100644 --- a/packages/powersync/lib/src/user_agent/user_agent_native.dart +++ b/packages/powersync_core/lib/src/user_agent/user_agent_native.dart @@ -1,6 +1,6 @@ import 'dart:io'; -import 'package:powersync/src/version.dart'; +import 'package:powersync_core/src/version.dart'; String powerSyncUserAgent() { var dartVersion = RegExp(r'[\w.]+').stringMatch(Platform.version); @@ -10,7 +10,7 @@ String powerSyncUserAgent() { } // Ideally we'd get an OS version as well, but that's a little complex. // Platform.operatingSystemVersion is very verbose. - return 'powersync-dart/$libraryVersion $dart ${Platform.operatingSystem}'; + return 'powersync-dart-core/$libraryVersion $dart ${Platform.operatingSystem}'; } Map userAgentHeaders() { diff --git a/packages/powersync/lib/src/user_agent/user_agent_stub.dart b/packages/powersync_core/lib/src/user_agent/user_agent_stub.dart similarity index 100% rename from packages/powersync/lib/src/user_agent/user_agent_stub.dart rename to packages/powersync_core/lib/src/user_agent/user_agent_stub.dart diff --git a/packages/powersync/lib/src/user_agent/user_agent_web.dart b/packages/powersync_core/lib/src/user_agent/user_agent_web.dart similarity index 68% rename from packages/powersync/lib/src/user_agent/user_agent_web.dart rename to packages/powersync_core/lib/src/user_agent/user_agent_web.dart index fb9a9d6c..8475d63c 100644 --- a/packages/powersync/lib/src/user_agent/user_agent_web.dart +++ b/packages/powersync_core/lib/src/user_agent/user_agent_web.dart @@ -1,7 +1,7 @@ -import 'package:powersync/src/version.dart'; +import 'package:powersync_core/src/version.dart'; String powerSyncUserAgent() { - return 'powersync-dart/$libraryVersion Dart (flutter-web)'; + return 'powersync-dart-core/$libraryVersion Dart (flutter-web)'; } Map userAgentHeaders() { diff --git a/packages/powersync/lib/src/uuid.dart b/packages/powersync_core/lib/src/uuid.dart similarity index 100% rename from packages/powersync/lib/src/uuid.dart rename to packages/powersync_core/lib/src/uuid.dart diff --git a/packages/powersync_core/lib/src/version.dart b/packages/powersync_core/lib/src/version.dart new file mode 100644 index 00000000..bd2b438f --- /dev/null +++ b/packages/powersync_core/lib/src/version.dart @@ -0,0 +1 @@ +const String libraryVersion = '1.0.0'; diff --git a/packages/powersync/lib/src/web/powersync_db.worker.dart b/packages/powersync_core/lib/src/web/powersync_db.worker.dart similarity index 100% rename from packages/powersync/lib/src/web/powersync_db.worker.dart rename to packages/powersync_core/lib/src/web/powersync_db.worker.dart diff --git a/packages/powersync/lib/src/web/sync_controller.dart b/packages/powersync_core/lib/src/web/sync_controller.dart similarity index 98% rename from packages/powersync/lib/src/web/sync_controller.dart rename to packages/powersync_core/lib/src/web/sync_controller.dart index 8231e7ce..a24ba578 100644 --- a/packages/powersync/lib/src/web/sync_controller.dart +++ b/packages/powersync_core/lib/src/web/sync_controller.dart @@ -1,7 +1,7 @@ import 'dart:async'; import 'dart:js_interop'; -import 'package:powersync/powersync.dart'; +import 'package:powersync_core/powersync_core.dart'; import 'package:sqlite_async/web.dart'; import 'package:web/web.dart'; diff --git a/packages/powersync/lib/src/web/sync_worker.dart b/packages/powersync_core/lib/src/web/sync_worker.dart similarity index 97% rename from packages/powersync/lib/src/web/sync_worker.dart rename to packages/powersync_core/lib/src/web/sync_worker.dart index 0b405bb1..59c0d9a9 100644 --- a/packages/powersync/lib/src/web/sync_worker.dart +++ b/packages/powersync_core/lib/src/web/sync_worker.dart @@ -9,10 +9,10 @@ import 'dart:js_interop'; import 'package:async/async.dart'; import 'package:fetch_client/fetch_client.dart'; -import 'package:powersync/powersync.dart'; -import 'package:powersync/sqlite_async.dart'; -import 'package:powersync/src/database/powersync_db_mixin.dart'; -import 'package:powersync/src/streaming_sync.dart'; +import 'package:powersync_core/powersync_core.dart'; +import 'package:powersync_core/sqlite_async.dart'; +import 'package:powersync_core/src/database/powersync_db_mixin.dart'; +import 'package:powersync_core/src/streaming_sync.dart'; import 'package:sqlite_async/web.dart'; import 'package:web/web.dart' hide RequestMode; diff --git a/packages/powersync/lib/src/web/sync_worker_protocol.dart b/packages/powersync_core/lib/src/web/sync_worker_protocol.dart similarity index 100% rename from packages/powersync/lib/src/web/sync_worker_protocol.dart rename to packages/powersync_core/lib/src/web/sync_worker_protocol.dart diff --git a/packages/powersync/lib/src/web/web_bucket_storage.dart b/packages/powersync_core/lib/src/web/web_bucket_storage.dart similarity index 82% rename from packages/powersync/lib/src/web/web_bucket_storage.dart rename to packages/powersync_core/lib/src/web/web_bucket_storage.dart index ba106b26..c2f276e8 100644 --- a/packages/powersync/lib/src/web/web_bucket_storage.dart +++ b/packages/powersync_core/lib/src/web/web_bucket_storage.dart @@ -1,5 +1,5 @@ -import 'package:powersync/sqlite_async.dart'; -import 'package:powersync/src/bucket_storage.dart'; +import 'package:powersync_core/sqlite_async.dart'; +import 'package:powersync_core/src/bucket_storage.dart'; import 'package:sqlite_async/web.dart'; class WebBucketStorage extends BucketStorage { diff --git a/packages/powersync/lib/src/web/worker_utils.dart b/packages/powersync_core/lib/src/web/worker_utils.dart similarity index 88% rename from packages/powersync/lib/src/web/worker_utils.dart rename to packages/powersync_core/lib/src/web/worker_utils.dart index 9f15547f..da14808d 100644 --- a/packages/powersync/lib/src/web/worker_utils.dart +++ b/packages/powersync_core/lib/src/web/worker_utils.dart @@ -1,5 +1,5 @@ -import 'package:powersync/sqlite3_common.dart'; -import 'package:powersync/src/open_factory/common_db_functions.dart'; +import 'package:powersync_core/sqlite3_common.dart'; +import 'package:powersync_core/src/open_factory/common_db_functions.dart'; import 'package:uuid/uuid.dart'; // Registers custom SQLite functions for the SQLite connection diff --git a/packages/powersync_core/pubspec.yaml b/packages/powersync_core/pubspec.yaml new file mode 100644 index 00000000..eb7a02fa --- /dev/null +++ b/packages/powersync_core/pubspec.yaml @@ -0,0 +1,43 @@ +name: powersync_core +version: 1.0.0 +homepage: https://powersync.com +repository: https://github.com/powersync-ja/powersync.dart +description: PowerSync Dart SDK - sync engine for building local-first apps. + +environment: + sdk: ^3.4.3 + +dependencies: + sqlite_async: ^0.11.0 + # We only use sqlite3 as a transitive dependency, + # but right now we need a minimum of v2.4.6. + sqlite3: ^2.4.6 + universal_io: ^2.0.0 + meta: ^1.0.0 + http: ^1.1.0 + uuid: ^4.2.0 + async: ^2.10.0 + logging: ^1.1.1 + collection: ^1.17.0 + fetch_client: ^1.1.2 + js: ^0.7.0 + web: ^1.0.0 +dev_dependencies: + dcli: ^4.0.0 + lints: ^3.0.0 + test: ^1.25.0 + test_api: ^0.7.0 + path_provider: ^2.0.13 + shelf: ^1.4.1 + shelf_router: ^1.1.4 + shelf_static: ^1.1.2 + stream_channel: ^2.1.2 + path: ^1.8.3 + +platforms: + android: + ios: + linux: + macos: + windows: + web: diff --git a/packages/powersync/test/bucket_storage_test.dart b/packages/powersync_core/test/bucket_storage_test.dart similarity index 99% rename from packages/powersync/test/bucket_storage_test.dart rename to packages/powersync_core/test/bucket_storage_test.dart index 8b3cac41..beb05d16 100644 --- a/packages/powersync/test/bucket_storage_test.dart +++ b/packages/powersync_core/test/bucket_storage_test.dart @@ -1,6 +1,6 @@ -import 'package:powersync/powersync.dart'; -import 'package:powersync/src/bucket_storage.dart'; -import 'package:powersync/src/sync_types.dart'; +import 'package:powersync_core/powersync_core.dart'; +import 'package:powersync_core/src/bucket_storage.dart'; +import 'package:powersync_core/src/sync_types.dart'; import 'package:sqlite_async/sqlite3_common.dart'; import 'package:test/test.dart'; diff --git a/packages/powersync/test/connected_test.dart b/packages/powersync_core/test/connected_test.dart similarity index 98% rename from packages/powersync/test/connected_test.dart rename to packages/powersync_core/test/connected_test.dart index 0f6d3b71..90218cb8 100644 --- a/packages/powersync/test/connected_test.dart +++ b/packages/powersync_core/test/connected_test.dart @@ -3,7 +3,7 @@ // but this makes the test significantly more complex. import 'dart:async'; -import 'package:powersync/powersync.dart'; +import 'package:powersync_core/powersync_core.dart'; import 'package:test/test.dart'; import 'server/sync_server/mock_sync_server.dart'; diff --git a/packages/powersync/test/credentials_test.dart b/packages/powersync_core/test/credentials_test.dart similarity index 90% rename from packages/powersync/test/credentials_test.dart rename to packages/powersync_core/test/credentials_test.dart index fcdb2551..013b5efe 100644 --- a/packages/powersync/test/credentials_test.dart +++ b/packages/powersync_core/test/credentials_test.dart @@ -1,4 +1,4 @@ -import 'package:powersync/powersync.dart'; +import 'package:powersync_core/powersync_core.dart'; import 'package:test/test.dart'; void main() { diff --git a/packages/powersync/test/crud_test.dart b/packages/powersync_core/test/crud_test.dart similarity index 99% rename from packages/powersync/test/crud_test.dart rename to packages/powersync_core/test/crud_test.dart index ba7de5c7..3a4ab635 100644 --- a/packages/powersync/test/crud_test.dart +++ b/packages/powersync_core/test/crud_test.dart @@ -1,4 +1,4 @@ -import 'package:powersync/powersync.dart'; +import 'package:powersync_core/powersync_core.dart'; import 'package:sqlite_async/sqlite3_common.dart'; import 'package:test/test.dart'; diff --git a/packages/powersync/test/disconnect_test.dart b/packages/powersync_core/test/disconnect_test.dart similarity index 95% rename from packages/powersync/test/disconnect_test.dart rename to packages/powersync_core/test/disconnect_test.dart index 80cb52ed..489928ef 100644 --- a/packages/powersync/test/disconnect_test.dart +++ b/packages/powersync_core/test/disconnect_test.dart @@ -1,5 +1,5 @@ -import 'package:powersync/powersync.dart'; -import 'package:powersync/sqlite_async.dart'; +import 'package:powersync_core/powersync_core.dart'; +import 'package:powersync_core/sqlite_async.dart'; import 'package:test/test.dart'; import 'streaming_sync_test.dart'; import 'utils/test_utils_impl.dart'; diff --git a/packages/powersync/test/offline_online_test.dart b/packages/powersync_core/test/offline_online_test.dart similarity index 98% rename from packages/powersync/test/offline_online_test.dart rename to packages/powersync_core/test/offline_online_test.dart index 8c831806..2fb1ed6d 100644 --- a/packages/powersync/test/offline_online_test.dart +++ b/packages/powersync_core/test/offline_online_test.dart @@ -1,6 +1,6 @@ import 'dart:convert'; -import 'package:powersync/powersync.dart'; +import 'package:powersync_core/powersync_core.dart'; import 'package:sqlite_async/src/utils/shared_utils.dart'; import 'package:test/test.dart'; diff --git a/packages/powersync/test/performance_native_test.dart b/packages/powersync_core/test/performance_native_test.dart similarity index 98% rename from packages/powersync/test/performance_native_test.dart rename to packages/powersync_core/test/performance_native_test.dart index 9def5945..b36236de 100644 --- a/packages/powersync/test/performance_native_test.dart +++ b/packages/powersync_core/test/performance_native_test.dart @@ -1,5 +1,5 @@ @TestOn('!browser') -import 'package:powersync/powersync.dart'; +import 'package:powersync_core/powersync_core.dart'; import 'package:test/test.dart'; import 'performance_shared_test.dart'; diff --git a/packages/powersync/test/performance_shared_test.dart b/packages/powersync_core/test/performance_shared_test.dart similarity index 98% rename from packages/powersync/test/performance_shared_test.dart rename to packages/powersync_core/test/performance_shared_test.dart index 5044c099..f4a20431 100644 --- a/packages/powersync/test/performance_shared_test.dart +++ b/packages/powersync_core/test/performance_shared_test.dart @@ -1,4 +1,4 @@ -import 'package:powersync/powersync.dart'; +import 'package:powersync_core/powersync_core.dart'; import 'package:test/test.dart'; import 'utils/test_utils_impl.dart'; diff --git a/packages/powersync/test/powersync_native_test.dart b/packages/powersync_core/test/powersync_native_test.dart similarity index 98% rename from packages/powersync/test/powersync_native_test.dart rename to packages/powersync_core/test/powersync_native_test.dart index aeda23d8..1a338e3d 100644 --- a/packages/powersync/test/powersync_native_test.dart +++ b/packages/powersync_core/test/powersync_native_test.dart @@ -2,7 +2,7 @@ import 'dart:async'; import 'dart:math'; -import 'package:powersync/powersync.dart'; +import 'package:powersync_core/powersync_core.dart'; import 'package:sqlite_async/sqlite3_common.dart'; import 'package:test/test.dart'; import 'utils/abstract_test_utils.dart'; diff --git a/packages/powersync/test/powersync_shared_test.dart b/packages/powersync_core/test/powersync_shared_test.dart similarity index 100% rename from packages/powersync/test/powersync_shared_test.dart rename to packages/powersync_core/test/powersync_shared_test.dart diff --git a/packages/powersync/test/schema_test.dart b/packages/powersync_core/test/schema_test.dart similarity index 99% rename from packages/powersync/test/schema_test.dart rename to packages/powersync_core/test/schema_test.dart index 7dfda31c..82cfac06 100644 --- a/packages/powersync/test/schema_test.dart +++ b/packages/powersync_core/test/schema_test.dart @@ -1,4 +1,4 @@ -import 'package:powersync/powersync.dart'; +import 'package:powersync_core/powersync_core.dart'; import 'package:test/test.dart'; import 'utils/test_utils_impl.dart'; diff --git a/packages/powersync/test/server/asset_server.dart b/packages/powersync_core/test/server/asset_server.dart similarity index 100% rename from packages/powersync/test/server/asset_server.dart rename to packages/powersync_core/test/server/asset_server.dart diff --git a/packages/powersync/test/server/sync_server/mock_sync_server.dart b/packages/powersync_core/test/server/sync_server/mock_sync_server.dart similarity index 100% rename from packages/powersync/test/server/sync_server/mock_sync_server.dart rename to packages/powersync_core/test/server/sync_server/mock_sync_server.dart diff --git a/packages/powersync/test/server/worker_server.dart b/packages/powersync_core/test/server/worker_server.dart similarity index 91% rename from packages/powersync/test/server/worker_server.dart rename to packages/powersync_core/test/server/worker_server.dart index 2889b1d5..47c5e407 100644 --- a/packages/powersync/test/server/worker_server.dart +++ b/packages/powersync_core/test/server/worker_server.dart @@ -17,14 +17,14 @@ Future hybridMain(StreamChannel channel) async { if (!(await File(sqliteOutputPath).exists())) { throw AssertionError( - 'sqlite3.wasm file should be present in the powersync/assets folder'); + 'sqlite3.wasm file should be present in the powersync_core/assets folder'); } final workerOutputPath = p.join(assetsDirectory, 'powersync_db.worker.js'); if (!(await File(workerOutputPath).exists())) { throw AssertionError( - 'powersync_db.worker.js file should be present in the powersync/assets folder'); + 'powersync_db.worker.js file should be present in the powersync_core/assets folder'); } final server = await HttpServer.bind('localhost', 0); diff --git a/packages/powersync/test/stream_test.dart b/packages/powersync_core/test/stream_test.dart similarity index 99% rename from packages/powersync/test/stream_test.dart rename to packages/powersync_core/test/stream_test.dart index 412711f4..437fdc92 100644 --- a/packages/powersync/test/stream_test.dart +++ b/packages/powersync_core/test/stream_test.dart @@ -4,7 +4,7 @@ import 'dart:convert'; import 'dart:io'; import 'package:http/http.dart'; -import 'package:powersync/src/stream_utils.dart'; +import 'package:powersync_core/src/stream_utils.dart'; import 'package:test/test.dart'; void main() { diff --git a/packages/powersync/test/streaming_sync_test.dart b/packages/powersync_core/test/streaming_sync_test.dart similarity index 98% rename from packages/powersync/test/streaming_sync_test.dart rename to packages/powersync_core/test/streaming_sync_test.dart index 92b03dd3..6c0ff066 100644 --- a/packages/powersync/test/streaming_sync_test.dart +++ b/packages/powersync_core/test/streaming_sync_test.dart @@ -3,7 +3,7 @@ import 'dart:async'; import 'dart:math'; -import 'package:powersync/powersync.dart'; +import 'package:powersync_core/powersync_core.dart'; import 'package:test/test.dart'; import 'test_server.dart'; diff --git a/packages/powersync/test/test_server.dart b/packages/powersync_core/test/test_server.dart similarity index 100% rename from packages/powersync/test/test_server.dart rename to packages/powersync_core/test/test_server.dart diff --git a/packages/powersync/test/upload_test.dart b/packages/powersync_core/test/upload_test.dart similarity index 98% rename from packages/powersync/test/upload_test.dart rename to packages/powersync_core/test/upload_test.dart index c3fa603e..8a4df2ea 100644 --- a/packages/powersync/test/upload_test.dart +++ b/packages/powersync_core/test/upload_test.dart @@ -1,6 +1,6 @@ @TestOn('!browser') -import 'package:powersync/powersync.dart'; +import 'package:powersync_core/powersync_core.dart'; import 'package:test/test.dart'; import 'test_server.dart'; diff --git a/packages/powersync/test/utils/abstract_test_utils.dart b/packages/powersync_core/test/utils/abstract_test_utils.dart similarity index 98% rename from packages/powersync/test/utils/abstract_test_utils.dart rename to packages/powersync_core/test/utils/abstract_test_utils.dart index 773dafb6..561e5c3b 100644 --- a/packages/powersync/test/utils/abstract_test_utils.dart +++ b/packages/powersync_core/test/utils/abstract_test_utils.dart @@ -1,5 +1,5 @@ import 'package:logging/logging.dart'; -import 'package:powersync/powersync.dart'; +import 'package:powersync_core/powersync_core.dart'; import 'package:sqlite_async/sqlite3_common.dart'; import 'package:sqlite_async/sqlite_async.dart'; import 'package:test_api/src/backend/invoker.dart'; diff --git a/packages/powersync/test/utils/native_test_utils.dart b/packages/powersync_core/test/utils/native_test_utils.dart similarity index 97% rename from packages/powersync/test/utils/native_test_utils.dart rename to packages/powersync_core/test/utils/native_test_utils.dart index 8be005e9..ab8cfd6a 100644 --- a/packages/powersync/test/utils/native_test_utils.dart +++ b/packages/powersync_core/test/utils/native_test_utils.dart @@ -1,7 +1,7 @@ import 'dart:async'; import 'dart:ffi'; import 'dart:io'; -import 'package:powersync/powersync.dart'; +import 'package:powersync_core/powersync_core.dart'; import 'package:sqlite_async/sqlite3_common.dart'; import 'package:sqlite_async/sqlite_async.dart'; import 'package:sqlite3/open.dart' as sqlite_open; diff --git a/packages/powersync/test/utils/stub_test_utils.dart b/packages/powersync_core/test/utils/stub_test_utils.dart similarity index 100% rename from packages/powersync/test/utils/stub_test_utils.dart rename to packages/powersync_core/test/utils/stub_test_utils.dart diff --git a/packages/powersync/test/utils/test_utils_impl.dart b/packages/powersync_core/test/utils/test_utils_impl.dart similarity index 100% rename from packages/powersync/test/utils/test_utils_impl.dart rename to packages/powersync_core/test/utils/test_utils_impl.dart diff --git a/packages/powersync/test/utils/web_test_utils.dart b/packages/powersync_core/test/utils/web_test_utils.dart similarity index 97% rename from packages/powersync/test/utils/web_test_utils.dart rename to packages/powersync_core/test/utils/web_test_utils.dart index a358d0ff..cb00a9c9 100644 --- a/packages/powersync/test/utils/web_test_utils.dart +++ b/packages/powersync_core/test/utils/web_test_utils.dart @@ -3,7 +3,7 @@ import 'dart:html'; import 'package:js/js.dart'; import 'package:logging/logging.dart'; -import 'package:powersync/powersync.dart'; +import 'package:powersync_core/powersync_core.dart'; import 'package:sqlite_async/sqlite3_common.dart'; import 'package:sqlite_async/sqlite_async.dart'; import 'package:test/test.dart'; diff --git a/packages/powersync/test/watch_test.dart b/packages/powersync_core/test/watch_test.dart similarity index 98% rename from packages/powersync/test/watch_test.dart rename to packages/powersync_core/test/watch_test.dart index 493f1aa7..6408b4fc 100644 --- a/packages/powersync/test/watch_test.dart +++ b/packages/powersync_core/test/watch_test.dart @@ -3,7 +3,7 @@ library; import 'dart:async'; import 'dart:math'; -import 'package:powersync/powersync.dart'; +import 'package:powersync_core/powersync_core.dart'; import 'package:sqlite_async/sqlite_async.dart'; import 'package:test/test.dart'; diff --git a/packages/powersync_flutter_libs/README.md b/packages/powersync_flutter_libs/README.md index 19eba4ac..f009332c 100644 --- a/packages/powersync_flutter_libs/README.md +++ b/packages/powersync_flutter_libs/README.md @@ -1,5 +1,5 @@ # powersync_flutter_libs -### Flutter binaries for [PowerSync](https://pub.dev/packages/powersync) please go there for documentation. +### Flutter binaries for [PowerSync](https://pub.dev/packages/powersync). Please go there for documentation. #### The core PowerSync binaries are built and released in [powersync-sqlite-core](https://github.com/powersync-ja/powersync-sqlite-core). diff --git a/packages/powersync_sqlcipher/.gitignore b/packages/powersync_sqlcipher/.gitignore new file mode 100644 index 00000000..28f173cc --- /dev/null +++ b/packages/powersync_sqlcipher/.gitignore @@ -0,0 +1,30 @@ +# Miscellaneous +*.class +*.log +*.pyc +*.swp +.DS_Store +.atom/ +.buildlog/ +.history +.svn/ +migrate_working_dir/ + +# IntelliJ related +*.iml +*.ipr +*.iws +.idea/ + +# The .vscode folder contains launch configuration and tasks you configure in +# VS Code which you may wish to be included in version control, so this line +# is commented out by default. +#.vscode/ + +# Flutter/Dart/Pub related +# Libraries should not include pubspec.lock, per https://dart.dev/guides/libraries/private-files#pubspeclock. +/pubspec.lock +**/doc/api/ +.dart_tool/ +build/ +/test-db \ No newline at end of file diff --git a/packages/powersync_sqlcipher/.metadata b/packages/powersync_sqlcipher/.metadata new file mode 100644 index 00000000..8f7b6ac1 --- /dev/null +++ b/packages/powersync_sqlcipher/.metadata @@ -0,0 +1,10 @@ +# This file tracks properties of this Flutter project. +# Used by Flutter tool to assess capabilities and perform upgrades etc. +# +# This file should be version controlled and should not be manually edited. + +version: + revision: "761747bfc538b5af34aa0d3fac380f1bc331ec49" + channel: "stable" + +project_type: package diff --git a/packages/powersync_sqlcipher/CHANGELOG.md b/packages/powersync_sqlcipher/CHANGELOG.md new file mode 100644 index 00000000..5235ea73 --- /dev/null +++ b/packages/powersync_sqlcipher/CHANGELOG.md @@ -0,0 +1,3 @@ +## 0.1.0 + + - PowerSync client SDK for Flutter with encryption enabled using SQLCipher initial release diff --git a/packages/powersync_sqlcipher/LICENSE b/packages/powersync_sqlcipher/LICENSE new file mode 100644 index 00000000..f433b1a5 --- /dev/null +++ b/packages/powersync_sqlcipher/LICENSE @@ -0,0 +1,177 @@ + + 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 diff --git a/packages/powersync_sqlcipher/NOTICE b/packages/powersync_sqlcipher/NOTICE new file mode 100644 index 00000000..da0d4ce5 --- /dev/null +++ b/packages/powersync_sqlcipher/NOTICE @@ -0,0 +1 @@ +Copyright 2024 Journey Mobile, Inc. diff --git a/packages/powersync_sqlcipher/README.md b/packages/powersync_sqlcipher/README.md new file mode 100644 index 00000000..c9020679 --- /dev/null +++ b/packages/powersync_sqlcipher/README.md @@ -0,0 +1,59 @@ +

+ +

+ +# PowerSync with SQLCipher SDK for Flutter + +_[PowerSync](https://www.powersync.com) is a sync engine for building local-first apps with instantly-responsive UI/UX and simplified state transfer. Syncs between SQLite on the client-side and Postgres, MongoDB or MySQL on the server-side._ + +This package (`powersync_sqlcipher`) is the PowerSync client SDK for Flutter with encryption enabled using SQLCipher. It is currently in a **beta** release. This means it is safe to use in production, provided that you've tested your use cases. + +If you do not require encryption in your Flutter application, we recommend using the [`powersync`](https://pub.dev/packages/powersync) SDK. + +### Installing PowerSync with SQLCipher encryption in your own project + +Install the latest version of the package, for example: + +```bash +flutter pub add powersync_sqlcipher +``` + +Version history can be found [here](https://pub.dev/packages/powersync_sqlcipher/versions). + +### Usage + +This SDK requires a slightly different setup to the `powersync` package in order to encrypt the local database: + +```Dart +import 'package/powersync_sqlcipher/powersync.dart'; + +/// Global reference to the database +late final PowerSyncDatabase db; + +final cipherFactory = PowerSyncSQLCipherOpenFactory( + path: path, key: "sqlcipher-encryption-key"); // https://www.zetetic.net/sqlcipher/sqlcipher-api/#key + +db = PowerSyncDatabase.withFactory(cipherFactory, schema: schema); +``` + +# Getting Started + +Our [full SDK reference](https://docs.powersync.com/client-sdk-references/flutter) contains everything you need to know to get started implementing PowerSync in your project. + +# Changelog + +A changelog for this SDK is available [here](https://pub.dev/packages/powersync_sqlcipher/changelog). + +# API Reference + +The full API reference for this SDK can be found [here](https://pub.dev/documentation/powersync_sqlcipher/latest/powersync_sqlcipher/powersync_sqlcipher-library.html). + +# Examples + +For example projects built with PowerSync and Flutter, see our [Demo Apps / Example Projects](https://docs.powersync.com/resources/demo-apps-example-projects#flutter) gallery. Most of these projects can also be found in the [`demos/`](../demos/) directory. + +# Found a bug or need help? + +- Join our [Discord server](https://discord.gg/powersync) where you can browse topics from our community, ask questions, share feedback, or just say hello :) +- Please open a [GitHub issue](https://github.com/powersync-ja/powersync.dart/issues) when you come across a bug. +- Have feedback or an idea? [Submit an idea](https://roadmap.powersync.com/tabs/5-roadmap/submit-idea) via our public roadmap or [schedule a chat](https://calendly.com/powersync/powersync-chat) with someone from our product team. diff --git a/packages/powersync_sqlcipher/analysis_options.yaml b/packages/powersync_sqlcipher/analysis_options.yaml new file mode 100644 index 00000000..a5744c1c --- /dev/null +++ b/packages/powersync_sqlcipher/analysis_options.yaml @@ -0,0 +1,4 @@ +include: package:flutter_lints/flutter.yaml + +# Additional information about this file can be found at +# https://dart.dev/guides/language/analysis-options diff --git a/packages/powersync_sqlcipher/example/main.dart b/packages/powersync_sqlcipher/example/main.dart new file mode 100644 index 00000000..f6ba21d2 --- /dev/null +++ b/packages/powersync_sqlcipher/example/main.dart @@ -0,0 +1,51 @@ +import 'package:flutter/foundation.dart'; +import 'package:powersync_sqlcipher/powersync.dart'; +import 'package:path_provider/path_provider.dart'; +import 'package:path/path.dart'; + +const schema = Schema([ + Table('customers', [Column.text('name'), Column.text('email')]) +]); + +late PowerSyncDatabase db; + +// Setup connector to backend if you would like to sync data. +class BackendConnector extends PowerSyncBackendConnector { + PowerSyncDatabase db; + + BackendConnector(this.db); + @override + // ignore: body_might_complete_normally_nullable + Future fetchCredentials() async { + // implement fetchCredentials + } + @override + Future uploadData(PowerSyncDatabase database) async { + // implement uploadData + } +} + +openDatabase() async { + var path = 'powersync-demo.db'; + // getApplicationSupportDirectory is not supported on Web + if (!kIsWeb) { + final dir = await getApplicationSupportDirectory(); + path = join(dir.path, 'powersync-dart.db'); + } + + // Setup the database. + final cipherFactory = PowerSyncSQLCipherOpenFactory( + path: path, key: "sqlcipher-encryption-key"); + + db = PowerSyncDatabase.withFactory(cipherFactory, schema: schema); + + await db.initialize(); + + // Run local statements. + await db.execute( + 'INSERT INTO customers(id, name, email) VALUES(uuid(), ?, ?)', + ['Fred', 'fred@example.org']); + + // Connect to backend + db.connect(connector: BackendConnector(db)); +} diff --git a/packages/powersync_sqlcipher/lib/powersync.dart b/packages/powersync_sqlcipher/lib/powersync.dart new file mode 100644 index 00000000..edb605f2 --- /dev/null +++ b/packages/powersync_sqlcipher/lib/powersync.dart @@ -0,0 +1,7 @@ +/// PowerSync with Encryption for Flutter. +/// +/// Use [PowerSyncSQLCipherOpenFactory] to open an encrypted database. +library; + +export 'src/sqlcipher.dart'; +export 'package:powersync_core/powersync_core.dart'; diff --git a/packages/powersync_sqlcipher/lib/sqlite3.dart b/packages/powersync_sqlcipher/lib/sqlite3.dart new file mode 100644 index 00000000..2941247e --- /dev/null +++ b/packages/powersync_sqlcipher/lib/sqlite3.dart @@ -0,0 +1,5 @@ +/// Re-exports [sqlite3](https://pub.dev/packages/sqlite3) to expose sqlite3 without +/// adding it as a direct dependency. +library; + +export 'package:powersync_core/sqlite3.dart'; diff --git a/packages/powersync_sqlcipher/lib/sqlite3_common.dart b/packages/powersync_sqlcipher/lib/sqlite3_common.dart new file mode 100644 index 00000000..52887937 --- /dev/null +++ b/packages/powersync_sqlcipher/lib/sqlite3_common.dart @@ -0,0 +1,5 @@ +/// Re-exports [sqlite3_common](https://pub.dev/packages/sqlite3) to expose sqlite3_common without +/// adding it as a direct dependency. +library; + +export 'package:powersync_core/sqlite3_common.dart'; diff --git a/packages/powersync_sqlcipher/lib/sqlite3_open.dart b/packages/powersync_sqlcipher/lib/sqlite3_open.dart new file mode 100644 index 00000000..fd364dc4 --- /dev/null +++ b/packages/powersync_sqlcipher/lib/sqlite3_open.dart @@ -0,0 +1,5 @@ +/// Re-exports [sqlite3_open](https://pub.dev/packages/sqlite3) to expose sqlite3_open without +/// adding it as a direct dependency. +library; + +export 'package:powersync_core/sqlite3_open.dart'; diff --git a/packages/powersync_sqlcipher/lib/sqlite_async.dart b/packages/powersync_sqlcipher/lib/sqlite_async.dart new file mode 100644 index 00000000..6deed835 --- /dev/null +++ b/packages/powersync_sqlcipher/lib/sqlite_async.dart @@ -0,0 +1,5 @@ +/// Re-exports [sqlite_async](https://pub.dev/packages/sqlite_async) to expose sqlite_async without +/// adding it as a direct dependency. +library; + +export 'package:powersync_core/sqlite_async.dart'; diff --git a/packages/powersync_sqlcipher/lib/src/sqlcipher.dart b/packages/powersync_sqlcipher/lib/src/sqlcipher.dart new file mode 100644 index 00000000..b4bc8af0 --- /dev/null +++ b/packages/powersync_sqlcipher/lib/src/sqlcipher.dart @@ -0,0 +1,39 @@ +import 'package:powersync_core/powersync_core.dart'; +import 'package:powersync_core/sqlite3_common.dart'; +import 'package:powersync_core/sqlite3_open.dart' as sqlite3_open; +import 'package:powersync_core/sqlite_async.dart'; +import 'package:sqlcipher_flutter_libs/sqlcipher_flutter_libs.dart'; + +/// A factory for opening a database with SQLCipher encryption. +/// An encryption [key] is required to open the database. +class PowerSyncSQLCipherOpenFactory extends PowerSyncOpenFactory { + PowerSyncSQLCipherOpenFactory( + {required super.path, required this.key, super.sqliteOptions}); + + final String key; + + @override + List pragmaStatements(SqliteOpenOptions options) { + final basePragmaStatements = super.pragmaStatements(options); + return [ + // Set the encryption key as the first statement + "PRAGMA KEY = ${quoteString(key)}", + // Include the default statements afterwards + for (var statement in basePragmaStatements) statement + ]; + } + + @override + CommonDatabase open(SqliteOpenOptions options) { + sqlite3_open.open + .overrideFor(sqlite3_open.OperatingSystem.android, openCipherOnAndroid); + + var db = super.open(options); + final versionRows = db.select('PRAGMA cipher_version'); + if (versionRows.isEmpty) { + throw StateError( + "SQLCipher was not initialized correctly. 'PRAGMA cipher_version' returned no rows."); + } + return db; + } +} diff --git a/packages/powersync_sqlcipher/pubspec.yaml b/packages/powersync_sqlcipher/pubspec.yaml new file mode 100644 index 00000000..bc1e7445 --- /dev/null +++ b/packages/powersync_sqlcipher/pubspec.yaml @@ -0,0 +1,31 @@ +name: powersync_sqlcipher +version: 0.1.0 +homepage: https://powersync.com +repository: https://github.com/powersync-ja/powersync.dart +description: PowerSync Flutter SDK - sync engine for building local-first apps. + +environment: + sdk: ">=3.4.3 <4.0.0" + flutter: ">=1.17.0" + +dependencies: + flutter: + sdk: flutter + + powersync_core: ^1.0.0 + powersync_flutter_libs: ^0.4.0 + sqlcipher_flutter_libs: ^0.6.4 +dev_dependencies: + flutter_test: + sdk: flutter + flutter_lints: ^3.0.0 + test_api: ^0.7.0 + path: ^1.8.3 + path_provider: ^2.0.13 + +platforms: + android: + ios: + linux: + macos: + windows: diff --git a/scripts/compile_webworker.dart b/scripts/compile_webworker.dart index 3e85f8a9..c40f7746 100644 --- a/scripts/compile_webworker.dart +++ b/scripts/compile_webworker.dart @@ -12,8 +12,8 @@ Future main() async { final dbWorkerOutputPath = path.join(repoRoot, 'packages/powersync/assets/$workerFilename'); - final workerSourcePath = path.join( - repoRoot, './packages/powersync/lib/src/web/powersync_db.worker.dart'); + final workerSourcePath = path.join(repoRoot, + './packages/powersync_core/lib/src/web/powersync_db.worker.dart'); // And compile worker code final dbWorkerProcess = await Process.run( @@ -37,8 +37,8 @@ Future main() async { final syncWorkerOutputPath = path.join(repoRoot, 'packages/powersync/assets/$syncWorkerFilename'); - final syncWorkerSourcePath = - path.join(repoRoot, './packages/powersync/lib/src/web/sync_worker.dart'); + final syncWorkerSourcePath = path.join( + repoRoot, './packages/powersync_core/lib/src/web/sync_worker.dart'); final syncWorkerProcess = await Process.run( Platform.executable, @@ -57,6 +57,15 @@ Future main() async { 'Could not compile sync worker:\nstdout: ${syncWorkerProcess.stdout.toString()}\nstderr: ${syncWorkerProcess.stderr.toString()}'); } + final workerFile = File(dbWorkerOutputPath); + final syncWorkerFile = File(syncWorkerOutputPath); + + //Copy workers to powersync_core + final powersyncCoreAssetsPath = + path.join(repoRoot, 'packages/powersync_core/assets'); + workerFile.copySync('$powersyncCoreAssetsPath/$workerFilename'); + syncWorkerFile.copySync('$powersyncCoreAssetsPath/$syncWorkerFilename'); + // Copy this to all demo apps web folders final demosRoot = path.join(repoRoot, 'demos'); final demoDirectories = diff --git a/scripts/init_powersync_core_binary.dart b/scripts/init_powersync_core_binary.dart index 05b06380..ddc60ff6 100644 --- a/scripts/init_powersync_core_binary.dart +++ b/scripts/init_powersync_core_binary.dart @@ -1,5 +1,5 @@ -/// Downloads the powersync dynamic library and copies it to the powersync package directory -/// This is only necessary for running unit tests in the powersync package +/// Downloads the powersync dynamic library and copies it to the powersync_core package directory +/// This is only necessary for running unit tests in the powersync_core package import 'dart:ffi'; import 'dart:io'; @@ -10,7 +10,8 @@ final sqliteUrl = void main() async { final sqliteCoreFilename = getLibraryForPlatform(); - final powersyncPath = "packages/powersync"; + final powersyncPath = "packages/powersync_core"; + final powersyncCipherPath = "packages/powersync_sqlcipher"; final sqliteCorePath = '$powersyncPath/$sqliteCoreFilename'; // Download dynamic library diff --git a/tool/update_version.dart b/tool/update_version.dart index 7d7e8ee7..a6db98b0 100644 --- a/tool/update_version.dart +++ b/tool/update_version.dart @@ -2,11 +2,11 @@ import 'dart:io'; import 'package:yaml/yaml.dart'; void main() { - final pubspecFile = File('packages/powersync/pubspec.yaml'); + final pubspecFile = File('packages/powersync_core/pubspec.yaml'); final pubspecContent = pubspecFile.readAsStringSync(); final yaml = loadYaml(pubspecContent); final version = yaml['version']; - final versionFile = File('packages/powersync/lib/src/version.dart'); + final versionFile = File('packages/powersync_core/lib/src/version.dart'); versionFile.writeAsStringSync("const String libraryVersion = '$version';\n"); }