Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,38 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## 2025-03-11

### Changes

---

Packages with breaking changes:

- There are no breaking changes in this release.

Packages with other changes:

- [`powersync_core` - `v1.2.2`](#powersync_core---v122)
- [`powersync_attachments_helper` - `v0.6.18+4`](#powersync_attachments_helper---v06184)
- [`powersync_sqlcipher` - `v0.1.5+2`](#powersync_sqlcipher---v0152)
- [`powersync` - `v1.12.2`](#powersync---v1122)

Packages with dependency updates only:

> Packages listed below depend on other packages in this workspace that have had changes. Their versions have been incremented to bump the minimum dependency versions of the packages they depend upon in this project.

- `powersync_attachments_helper` - `v0.6.18+4`
- `powersync_sqlcipher` - `v0.1.5+2`
- `powersync` - `v1.12.2`

---

#### `powersync_core` - `v1.2.2`

- Fix handling token invalidation on the web.


## 2025-03-06

### Changes
Expand Down
2 changes: 1 addition & 1 deletion demos/benchmarks/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ environment:
dependencies:
flutter:
sdk: flutter
powersync: ^1.12.1
powersync: ^1.12.2
path_provider: ^2.1.1
path: ^1.8.3
logging: ^1.2.0
Expand Down
2 changes: 1 addition & 1 deletion demos/django-todolist/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ environment:
dependencies:
flutter:
sdk: flutter
powersync: ^1.12.1
powersync: ^1.12.2
path_provider: ^2.1.1
path: ^1.8.3
logging: ^1.2.0
Expand Down
2 changes: 1 addition & 1 deletion demos/firebase-nodejs-todolist/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ dependencies:
flutter:
sdk: flutter

powersync: ^1.12.1
powersync: ^1.12.2
path_provider: ^2.1.1
supabase_flutter: ^2.0.1
path: ^1.8.3
Expand Down
2 changes: 1 addition & 1 deletion demos/supabase-anonymous-auth/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ dependencies:
flutter:
sdk: flutter

powersync: ^1.12.1
powersync: ^1.12.2
path_provider: ^2.1.1
supabase_flutter: ^2.0.2
path: ^1.8.3
Expand Down
2 changes: 1 addition & 1 deletion demos/supabase-edge-function-auth/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ dependencies:
flutter:
sdk: flutter

powersync: ^1.12.1
powersync: ^1.12.2
path_provider: ^2.1.1
supabase_flutter: ^2.0.2
path: ^1.8.3
Expand Down
2 changes: 1 addition & 1 deletion demos/supabase-simple-chat/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ dependencies:

supabase_flutter: ^2.0.2
timeago: ^3.6.0
powersync: ^1.12.1
powersync: ^1.12.2
path_provider: ^2.1.1
path: ^1.8.3
logging: ^1.2.0
Expand Down
4 changes: 2 additions & 2 deletions demos/supabase-todolist-drift/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ environment:
dependencies:
flutter:
sdk: flutter
powersync_attachments_helper: ^0.6.18+3
powersync: ^1.12.1
powersync_attachments_helper: ^0.6.18+4
powersync: ^1.12.2
path_provider: ^2.1.1
supabase_flutter: ^2.0.1
path: ^1.8.3
Expand Down
2 changes: 1 addition & 1 deletion demos/supabase-todolist-optional-sync/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ environment:
dependencies:
flutter:
sdk: flutter
powersync: ^1.12.1
powersync: ^1.12.2
path_provider: ^2.1.1
supabase_flutter: ^2.0.1
path: ^1.8.3
Expand Down
4 changes: 2 additions & 2 deletions demos/supabase-todolist/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ environment:
dependencies:
flutter:
sdk: flutter
powersync_attachments_helper: ^0.6.18+3
powersync: ^1.12.1
powersync_attachments_helper: ^0.6.18+4
powersync: ^1.12.2
path_provider: ^2.1.1
supabase_flutter: ^2.0.1
path: ^1.8.3
Expand Down
2 changes: 1 addition & 1 deletion demos/supabase-trello/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ dependencies:
random_name_generator: ^1.5.0
flutter_dotenv: ^5.2.1
logging: ^1.3.0
powersync: ^1.12.1
powersync: ^1.12.2
sqlite_async: ^0.11.0
path_provider: ^2.1.5
supabase_flutter: ^2.8.3
Expand Down
4 changes: 4 additions & 0 deletions packages/powersync/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 1.12.2

- Update a dependency to the latest release.

## 1.12.1

- Update a dependency to the latest release.
Expand Down
4 changes: 2 additions & 2 deletions packages/powersync/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: powersync
version: 1.12.1
version: 1.12.2
homepage: https://powersync.com
repository: https://github.com/powersync-ja/powersync.dart
description: PowerSync Flutter SDK - sync engine for building local-first apps.
Expand All @@ -12,7 +12,7 @@ dependencies:
sdk: flutter

sqlite3_flutter_libs: ^0.5.23
powersync_core: ^1.2.1
powersync_core: ^1.2.2
powersync_flutter_libs: ^0.4.7
collection: ^1.17.0

Expand Down
4 changes: 4 additions & 0 deletions packages/powersync_attachments_helper/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.6.18+4

- Update a dependency to the latest release.

## 0.6.18+3

- Update a dependency to the latest release.
Expand Down
4 changes: 2 additions & 2 deletions packages/powersync_attachments_helper/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: powersync_attachments_helper
description: A helper library for handling attachments when using PowerSync.
version: 0.6.18+3
version: 0.6.18+4
repository: https://github.com/powersync-ja/powersync.dart
homepage: https://www.powersync.com/
environment:
Expand All @@ -10,7 +10,7 @@ dependencies:
flutter:
sdk: flutter

powersync_core: ^1.2.1
powersync_core: ^1.2.2
logging: ^1.2.0
sqlite_async: ^0.11.0
path_provider: ^2.0.13
Expand Down
4 changes: 4 additions & 0 deletions packages/powersync_core/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 1.2.2

- Fix handling token invalidation on the web.

## 1.2.1

- Raise minimum version of core extension to 0.3.11.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ class PowerSyncDatabaseImpl
sync = StreamingSyncImplementation(
adapter: storage,
credentialsCallback: connector.getCredentialsCached,
invalidCredentialsCallback: connector.fetchCredentials,
invalidCredentialsCallback: connector.prefetchCredentials,
uploadCrud: () => connector.uploadData(this),
crudUpdateTriggerStream: crudStream,
retryDelay: Duration(seconds: 3),
Expand Down
2 changes: 1 addition & 1 deletion packages/powersync_core/lib/src/version.dart
Original file line number Diff line number Diff line change
@@ -1 +1 @@
const String libraryVersion = '1.2.1';
const String libraryVersion = '1.2.2';
2 changes: 1 addition & 1 deletion packages/powersync_core/lib/src/web/sync_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class SyncWorkerHandle implements StreamingSync {
await connector.uploadData(database);
return (JSObject(), null);
case SyncWorkerMessageType.invalidCredentialsCallback:
final credentials = await connector.fetchCredentials();
final credentials = await connector.prefetchCredentials();
return (
credentials != null
? SerializedCredentials.from(credentials)
Expand Down
4 changes: 2 additions & 2 deletions packages/powersync_core/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: powersync_core
version: 1.2.1
version: 1.2.2
homepage: https://powersync.com
repository: https://github.com/powersync-ja/powersync.dart
description: PowerSync Dart SDK - sync engine for building local-first apps.
Expand All @@ -13,7 +13,7 @@ dependencies:
# but right now we need a minimum of v2.4.6.
sqlite3: ^2.4.6
# We implement a database controller, which is an interface of sqlite3_web.
sqlite3_web: ^0.3.0
sqlite3_web: ^0.3.1
universal_io: ^2.0.0
meta: ^1.0.0
http: ^1.1.0
Expand Down
29 changes: 26 additions & 3 deletions packages/powersync_core/test/in_memory_sync_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,26 @@ void main() {
late CommonDatabase raw;
late PowerSyncDatabase database;
late MockSyncService syncService;
late StreamingSyncImplementation syncClient;
late StreamingSync syncClient;
var credentialsCallbackCount = 0;

setUp(() async {
credentialsCallbackCount = 0;
final (client, server) = inMemoryServer();
syncService = MockSyncService();
server.mount(syncService.router.call);

factory = await testUtils.testFactory();
(raw, database) = await factory.openInMemoryDatabase();
await database.initialize();

syncClient = database.connectWithMockService(
client,
TestConnector(() async {
credentialsCallbackCount++;
return PowerSyncCredentials(
endpoint: server.url.toString(),
token: 'token not used here',
token: 'token$credentialsCallbackCount',
expiresAt: DateTime.now(),
);
}),
Expand Down Expand Up @@ -312,18 +316,37 @@ void main() {
},
);
});

test('reconnects when token expires', () async {
await waitForConnection();
expect(credentialsCallbackCount, 1);
// When the sync service says the token has expired
syncService
..addLine({'token_expires_in': 0})
..endCurrentListener();

final nextRequest = await syncService.waitForListener;
expect(nextRequest.headers['Authorization'], 'Token token2');
expect(credentialsCallbackCount, 2);
});
});
}

TypeMatcher<SyncStatus> isSyncStatus(
{Object? downloading, Object? connected, Object? hasSynced}) {
{Object? downloading,
Object? connected,
Object? connecting,
Object? hasSynced}) {
var matcher = isA<SyncStatus>();
if (downloading != null) {
matcher = matcher.having((e) => e.downloading, 'downloading', downloading);
}
if (connected != null) {
matcher = matcher.having((e) => e.connected, 'connected', connected);
}
if (connecting != null) {
matcher = matcher.having((e) => e.connecting, 'connecting', connecting);
}
if (hasSynced != null) {
matcher = matcher.having((e) => e.hasSynced, 'hasSynced', hasSynced);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ import 'package:shelf_router/shelf_router.dart';

final class MockSyncService {
// Use a queued stream to make tests easier.
StreamController<String> _controller = StreamController<String>();
Completer<void> _listener = Completer();
StreamController<String> _controller = StreamController();
Completer<Request> _listener = Completer();

final router = Router();

MockSyncService() {
router
..post('/sync/stream', (Request request) async {
_listener.complete();
_listener.complete(request);
// Respond immediately with a stream
return Response.ok(_controller.stream.transform(utf8.encoder),
headers: {
Expand All @@ -33,7 +33,7 @@ final class MockSyncService {
});
}

Future<void> get waitForListener => _listener.future;
Future<Request> get waitForListener => _listener.future;

// Queue events which will be sent to connected clients.
void addRawEvent(String data) {
Expand All @@ -48,6 +48,12 @@ final class MockSyncService {
addLine({'token_expires_in': tokenExpiresIn});
}

void endCurrentListener() {
_controller.close();
_controller = StreamController();
_listener = Completer();
}

// Clear events. We rely on a buffered controller here. Create a new controller
// in order to clear the buffer.
Future<void> clearEvents() async {
Expand Down
4 changes: 4 additions & 0 deletions packages/powersync_sqlcipher/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.1.5+2

- Update a dependency to the latest release.

## 0.1.5+1

- Update a dependency to the latest release.
Expand Down
4 changes: 2 additions & 2 deletions packages/powersync_sqlcipher/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: powersync_sqlcipher
version: 0.1.5+1
version: 0.1.5+2
homepage: https://powersync.com
repository: https://github.com/powersync-ja/powersync.dart
description: PowerSync Flutter SDK - sync engine for building local-first apps.
Expand All @@ -12,7 +12,7 @@ dependencies:
flutter:
sdk: flutter

powersync_core: ^1.2.1
powersync_core: ^1.2.2
powersync_flutter_libs: ^0.4.7
sqlcipher_flutter_libs: ^0.6.4
sqlite3_web: ^0.3.0
Expand Down