Skip to content

Commit

Permalink
build: bump up dependencies
Browse files Browse the repository at this point in the history
Closes 154
  • Loading branch information
rafamizes authored Aug 19, 2024
1 parent fd4586c commit 003accb
Show file tree
Hide file tree
Showing 7 changed files with 230 additions and 113 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Changed

- Bump up dependencies —
[154](https://github.com/dartoos-dev/json_cache/issues/154).

### Fixed

- Removed code warnings and upgraded dart SDK range and each dependency to latest resolvable version available - [148](https://github.com/dartoos-dev/json_cache/issues/148).
Expand Down
50 changes: 26 additions & 24 deletions lib/src/json_cache_local_storage.dart
Original file line number Diff line number Diff line change
@@ -1,45 +1,47 @@
import 'dart:convert';

import 'package:json_cache/json_cache.dart';
import 'package:localstorage/localstorage.dart';

/// {@template json_cache_local_storage}
///
/// Implementation on top of the LocalStorage package.
///
/// Before using it, don't forget to call:
///
/// ```dart
/// WidgetsFlutterBinding.ensureInitialized();
/// await initLocalStorage();
/// ```
///
/// See: [local storage](https://pub.dev/packages/localstorage)
class JsonCacheLocalStorage implements JsonCache {
/// Encapsulates a [LocalStorage] instance.
const JsonCacheLocalStorage(this._storage);
///
/// {@endtemplate}
final class JsonCacheLocalStorage implements JsonCache {
/// {@macro json_cache_local_storage}
JsonCacheLocalStorage([LocalStorage? customLocalStorage])
: _storage = customLocalStorage ?? localStorage;

final LocalStorage _storage;

@override
Future<void> clear() async {
await _getReady;
await _storage.clear();
}
Future<void> clear() async => _storage.clear();

@override
Future<void> refresh(String key, Map<String, dynamic> value) async {
await _getReady;
await _storage.setItem(key, value);
}
Future<void> refresh(String key, Map<String, dynamic> value) async =>
_storage.setItem(key, json.encode(value));

@override
Future<void> remove(String key) async {
await _getReady;
await _storage.deleteItem(key);
}
Future<void> remove(String key) async => _storage.removeItem(key);

@override
Future<Map<String, dynamic>?> value(String key) async {
await _getReady;
return await _storage.getItem(key) as Map<String, dynamic>?;
final strJson = _storage.getItem(key);
return strJson == null
? null
: json.decode(strJson) as Map<String, dynamic>;
}

@override
Future<bool> contains(String key) async {
await _getReady;
final Object? item = _storage.getItem(key);
return item != null;
}

Future<bool> get _getReady => _storage.ready;
Future<bool> contains(String key) async => _storage.getItem(key) != null;
}
66 changes: 33 additions & 33 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -122,50 +122,50 @@ packages:
dependency: "direct main"
description:
name: flutter_secure_storage
sha256: ffdbb60130e4665d2af814a0267c481bcf522c41ae2e43caf69fa0146876d685
sha256: "165164745e6afb5c0e3e3fcc72a012fb9e58496fb26ffb92cf22e16a821e85d0"
url: "https://pub.dev"
source: hosted
version: "9.0.0"
version: "9.2.2"
flutter_secure_storage_linux:
dependency: transitive
description:
name: flutter_secure_storage_linux
sha256: "3d5032e314774ee0e1a7d0a9f5e2793486f0dff2dd9ef5a23f4e3fb2a0ae6a9e"
sha256: "4d91bfc23047422cbcd73ac684bc169859ee766482517c22172c86596bf1464b"
url: "https://pub.dev"
source: hosted
version: "1.2.0"
version: "1.2.1"
flutter_secure_storage_macos:
dependency: transitive
description:
name: flutter_secure_storage_macos
sha256: bd33935b4b628abd0b86c8ca20655c5b36275c3a3f5194769a7b3f37c905369c
sha256: "1693ab11121a5f925bbea0be725abfcfbbcf36c1e29e571f84a0c0f436147a81"
url: "https://pub.dev"
source: hosted
version: "3.0.1"
version: "3.1.2"
flutter_secure_storage_platform_interface:
dependency: transitive
description:
name: flutter_secure_storage_platform_interface
sha256: "0d4d3a5dd4db28c96ae414d7ba3b8422fd735a8255642774803b2532c9a61d7e"
sha256: cf91ad32ce5adef6fba4d736a542baca9daf3beac4db2d04be350b87f69ac4a8
url: "https://pub.dev"
source: hosted
version: "1.0.2"
version: "1.1.2"
flutter_secure_storage_web:
dependency: transitive
description:
name: flutter_secure_storage_web
sha256: "30f84f102df9dcdaa2241866a958c2ec976902ebdaa8883fbfe525f1f2f3cf20"
sha256: f4ebff989b4f07b2656fb16b47852c0aab9fed9b4ec1c70103368337bc1886a9
url: "https://pub.dev"
source: hosted
version: "1.1.2"
version: "1.2.1"
flutter_secure_storage_windows:
dependency: transitive
description:
name: flutter_secure_storage_windows
sha256: "5809c66f9dd3b4b93b0a6e2e8561539405322ee767ac2f64d084e2ab5429d108"
sha256: b20b07cb5ed4ed74fc567b78a72936203f587eba460af1df11281c9326cd3709
url: "https://pub.dev"
source: hosted
version: "3.0.0"
version: "3.1.2"
flutter_test:
dependency: "direct dev"
description: flutter
Expand Down Expand Up @@ -276,10 +276,10 @@ packages:
dependency: "direct main"
description:
name: localstorage
sha256: fdff4f717114e992acfd4045dc4a9ab9b987ca57f020965d63e3eb34089c60d8
sha256: "6340acefdd3a969cceb044a69cde2dc5877c5b861b2e02d0803930ed483dbe91"
url: "https://pub.dev"
source: hosted
version: "4.0.1+4"
version: "5.0.0"
logging:
dependency: transitive
description:
Expand Down Expand Up @@ -364,10 +364,10 @@ packages:
dependency: transitive
description:
name: path_provider
sha256: b27217933eeeba8ff24845c34003b003b2b22151de3c908d0e679e8fe1aa078b
sha256: fec0d61223fba3154d87759e3cc27fe2c8dc498f6386c6d6fc80d1afdd1bf378
url: "https://pub.dev"
source: hosted
version: "2.1.2"
version: "2.1.4"
path_provider_android:
dependency: transitive
description:
Expand Down Expand Up @@ -452,58 +452,58 @@ packages:
dependency: "direct main"
description:
name: shared_preferences
sha256: "81429e4481e1ccfb51ede496e916348668fd0921627779233bd24cc3ff6abd02"
sha256: "746e5369a43170c25816cc472ee016d3a66bc13fcf430c0bc41ad7b4b2922051"
url: "https://pub.dev"
source: hosted
version: "2.2.2"
version: "2.3.2"
shared_preferences_android:
dependency: transitive
description:
name: shared_preferences_android
sha256: "8568a389334b6e83415b6aae55378e158fbc2314e074983362d20c562780fb06"
sha256: a7e8467e9181cef109f601e3f65765685786c1a738a83d7fbbde377589c0d974
url: "https://pub.dev"
source: hosted
version: "2.2.1"
version: "2.3.1"
shared_preferences_foundation:
dependency: transitive
description:
name: shared_preferences_foundation
sha256: "7708d83064f38060c7b39db12aefe449cb8cdc031d6062280087bc4cdb988f5c"
sha256: c4b35f6cb8f63c147312c054ce7c2254c8066745125264f0c88739c417fc9d9f
url: "https://pub.dev"
source: hosted
version: "2.3.5"
version: "2.5.2"
shared_preferences_linux:
dependency: transitive
description:
name: shared_preferences_linux
sha256: "9f2cbcf46d4270ea8be39fa156d86379077c8a5228d9dfdb1164ae0bb93f1faa"
sha256: "580abfd40f415611503cae30adf626e6656dfb2f0cee8f465ece7b6defb40f2f"
url: "https://pub.dev"
source: hosted
version: "2.3.2"
version: "2.4.1"
shared_preferences_platform_interface:
dependency: transitive
description:
name: shared_preferences_platform_interface
sha256: "22e2ecac9419b4246d7c22bfbbda589e3acf5c0351137d87dd2939d984d37c3b"
sha256: "57cbf196c486bc2cf1f02b85784932c6094376284b3ad5779d1b1c6c6a816b80"
url: "https://pub.dev"
source: hosted
version: "2.3.2"
version: "2.4.1"
shared_preferences_web:
dependency: transitive
description:
name: shared_preferences_web
sha256: "7b15ffb9387ea3e237bb7a66b8a23d2147663d391cafc5c8f37b2e7b4bde5d21"
sha256: d2ca4132d3946fec2184261726b355836a82c33d7d5b67af32692aff18a4684e
url: "https://pub.dev"
source: hosted
version: "2.2.2"
version: "2.4.2"
shared_preferences_windows:
dependency: transitive
description:
name: shared_preferences_windows
sha256: "841ad54f3c8381c480d0c9b508b89a34036f512482c407e6df7a9c4aa2ef8f59"
sha256: "94ef0f72b2d71bc3e700e025db3710911bd51a71cefb65cc609dd0d9a982e3c1"
url: "https://pub.dev"
source: hosted
version: "2.3.2"
version: "2.4.1"
shelf:
dependency: transitive
description:
Expand Down Expand Up @@ -665,10 +665,10 @@ packages:
dependency: transitive
description:
name: web
sha256: afe077240a270dcfd2aafe77602b4113645af95d0ad31128cc02bce5ac5d5152
sha256: d43c1d6b787bf0afad444700ae7f4db8827f701bc61c255ac8d328c6f4d52062
url: "https://pub.dev"
source: hosted
version: "0.3.0"
version: "1.0.0"
web_socket_channel:
dependency: transitive
description:
Expand Down Expand Up @@ -711,4 +711,4 @@ packages:
version: "3.1.2"
sdks:
dart: ">=3.5.0 <4.0.0"
flutter: ">=3.18.0-18.0.pre.54"
flutter: ">=3.22.0"
6 changes: 3 additions & 3 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ environment:
dependencies:
flutter:
sdk: flutter
flutter_secure_storage: ^9.0.0
flutter_secure_storage: ^9.2.2
hive: ^2.2.3
localstorage: ^4.0.1+4
localstorage: ^5.0.0
mutex: ^3.1.0
safe_local_storage: ^1.0.2
shared_preferences: ^2.2.2
shared_preferences: ^2.3.2

dev_dependencies:
flutter_test:
Expand Down
71 changes: 71 additions & 0 deletions test/fake_local_storage.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import 'package:localstorage/localstorage.dart';

typedef IndexValue = ({int index, String value});

/// {@template fake_local_storage}
///
/// Unit-testing purposes implementation of the [LocalStorage] interface.
///
/// {@endtemplate}
final class FakeLocalStorage implements LocalStorage {
/// {@macro fake_local_storage}
FakeLocalStorage();

final Map<String, IndexValue> _data = {};
final List<String> _keys = [];

@override
void clear() {
_data.clear();
_keys.clear();
}

@override
String? getItem(String key) => _data[key]?.value;

@override
String? key(int index) {
if (index >= 0 && index < _keys.length) {
return _keys[index];
}
return null;
}

@override
int get length => _data.keys.length;

@override
void removeItem(String key) {
final pair = _data[key];
if (pair != null) {
_removeItemAndDecreaseIndexes(key, pair);
}
}

@override
void setItem(String key, String value) {
final pair = _data[key];
if (pair != null) {
final currIndex = pair.index;
_data[key] = (index: currIndex, value: value);
} else {
_keys.add(key);
final newIndex = _keys.length - 1;
_data[key] = (index: newIndex, value: value);
}
}

void _removeItemAndDecreaseIndexes(
String key,
({int index, String value}) pair,
) {
_keys.removeAt(pair.index);
_data.remove(key);
_data.keys.forEach(_decreaseIndexAt);
}

void _decreaseIndexAt(String key) {
final pair = _data[key]!;
_data[key] = (index: pair.index - 1, value: pair.value);
}
}
Loading

1 comment on commit 003accb

@0pdd
Copy link
Collaborator

@0pdd 0pdd commented on 003accb Aug 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wasn't able to retrieve PDD puzzles from the code base and submit them to github. If you think that it's a bug on our side, please submit it to yegor256/0pdd:

set -x && set -e && set -o pipefail && cd /tmp/0pdd20240819-2-9wtvwf/Z2l0QGdpdGh1Yi5jb206ZGFydG9vcy1kZXYvanNvbl9jYWNoZS5naXQ && pdd -v -f /tmp/20240819-9390-m4i2oz [1]: + set -e + set -o pipefail + cd /tmp/0pdd20240819-2-9wtvwf/Z2l0QGdpdGh1Yi5jb206ZGFydG9vcy1kZXYvanNvbl9jYWNoZS5naXQ + pdd -v -f...

Please, copy and paste this stack trace to GitHub:

UserError
set -x && set -e && set -o pipefail && cd /tmp/0pdd20240819-2-9wtvwf/Z2l0QGdpdGh1Yi5jb206ZGFydG9vcy1kZXYvanNvbl9jYWNoZS5naXQ && pdd -v -f /tmp/20240819-9390-m4i2oz [1]:
+ set -e
+ set -o pipefail
+ cd /tmp/0pdd20240819-2-9wtvwf/Z2l0QGdpdGh1Yi5jb206ZGFydG9vcy1kZXYvanNvbl9jYWNoZS5naXQ
+ pdd -v -f /tmp/20240819-9390-m4i2oz

My version is 0.24.0
Ruby version is 3.1.4 at x86_64-linux
Reading from root dir /tmp/0pdd20240819-2-9wtvwf/Z2l0QGdpdGh1Yi5jb206ZGFydG9vcy1kZXYvanNvbl9jYWNoZS5naXQ
Reading .gitattributes ...
Reading .github/workflows/build.yml ...
Reading .gitignore ...
Reading .metadata ...
Reading .rultor.yml ...
Reading CHANGELOG.md ...
Reading LICENSE ...
Reading README.md ...
Reading analysis_options.yaml ...
Reading example/main.dart ...
Reading lib/json_cache.dart ...
Reading lib/src/json_cache.dart ...
Reading lib/src/json_cache_exception.dart ...
Reading lib/src/json_cache_fake.dart ...
Reading lib/src/json_cache_flutter_secure_storage.dart ...
Reading lib/src/json_cache_hive.dart ...
Reading lib/src/json_cache_hollow.dart ...
Reading lib/src/json_cache_local_storage.dart ...
Reading lib/src/json_cache_mem.dart ...
Reading lib/src/json_cache_safe_local_storage.dart ...
Reading lib/src/json_cache_shared_preferences.dart ...
Reading lib/src/json_cache_try.dart ...
Reading lib/src/json_cache_wrap.dart ...
Reading pubspec.lock ...
Reading pubspec.yaml ...
Reading test/fake_local_storage.dart ...
Reading test/flutter_secure_storage_mock.dart ...
ERROR: ERROR: test/flutter_secure_storage_mock.dart; PDD::Error at test/flutter_secure_storage_mock.dart:94: TODO found, but puzzle can't be parsed, most probably because TODO is not followed by a puzzle marker, as this page explains: https://github.com/cqfn/pdd#how-to-format
If you can't understand the cause of this issue or you don't know how to fix it, please submit a GitHub issue, we will try to help you: https://github.com/cqfn/pdd/issues. This tool is still in its beta version and we will appreciate your feedback. Here is where you can find more documentation: https://github.com/cqfn/pdd/blob/master/README.md.
Exit code is 1

/app/objects/git_repo.rb:74:in `rescue in block in xml'
/app/objects/git_repo.rb:71:in `block in xml'
/app/vendor/ruby-3.1.4/lib/ruby/3.1.0/tempfile.rb:317:in `open'
/app/objects/git_repo.rb:70:in `xml'
/app/objects/puzzles.rb:46:in `deploy'
/app/objects/jobs/job.rb:38:in `proceed'
/app/objects/jobs/job_starred.rb:32:in `proceed'
/app/objects/jobs/job_recorded.rb:31:in `proceed'
/app/objects/jobs/job_emailed.rb:33:in `proceed'
/app/objects/jobs/job_commiterrors.rb:33:in `proceed'
/app/objects/jobs/job_detached.rb:48:in `exclusive'
/app/objects/jobs/job_detached.rb:36:in `block in proceed'
/app/objects/jobs/job_detached.rb:36:in `fork'
/app/objects/jobs/job_detached.rb:36:in `proceed'
/app/0pdd.rb:549:in `process_request'
/app/0pdd.rb:380:in `block in <top (required)>'
/app/vendor/bundle/ruby/3.1.0/gems/sinatra-4.0.0/lib/sinatra/base.rb:1804:in `call'
/app/vendor/bundle/ruby/3.1.0/gems/sinatra-4.0.0/lib/sinatra/base.rb:1804:in `block in compile!'
/app/vendor/bundle/ruby/3.1.0/gems/sinatra-4.0.0/lib/sinatra/base.rb:1071:in `block (3 levels) in route!'
/app/vendor/bundle/ruby/3.1.0/gems/sinatra-4.0.0/lib/sinatra/base.rb:1089:in `route_eval'
/app/vendor/bundle/ruby/3.1.0/gems/sinatra-4.0.0/lib/sinatra/base.rb:1071:in `block (2 levels) in route!'
/app/vendor/bundle/ruby/3.1.0/gems/sinatra-4.0.0/lib/sinatra/base.rb:1120:in `block in process_route'
/app/vendor/bundle/ruby/3.1.0/gems/sinatra-4.0.0/lib/sinatra/base.rb:1118:in `catch'
/app/vendor/bundle/ruby/3.1.0/gems/sinatra-4.0.0/lib/sinatra/base.rb:1118:in `process_route'
/app/vendor/bundle/ruby/3.1.0/gems/sinatra-4.0.0/lib/sinatra/base.rb:1069:in `block in route!'
/app/vendor/bundle/ruby/3.1.0/gems/sinatra-4.0.0/lib/sinatra/base.rb:1066:in `each'
/app/vendor/bundle/ruby/3.1.0/gems/sinatra-4.0.0/lib/sinatra/base.rb:1066:in `route!'
/app/vendor/bundle/ruby/3.1.0/gems/sinatra-4.0.0/lib/sinatra/base.rb:1190:in `block in dispatch!'
/app/vendor/bundle/ruby/3.1.0/gems/sinatra-4.0.0/lib/sinatra/base.rb:1161:in `catch'
/app/vendor/bundle/ruby/3.1.0/gems/sinatra-4.0.0/lib/sinatra/base.rb:1161:in `invoke'
/app/vendor/bundle/ruby/3.1.0/gems/sinatra-4.0.0/lib/sinatra/base.rb:1185:in `dispatch!'
/app/vendor/bundle/ruby/3.1.0/gems/sinatra-4.0.0/lib/sinatra/base.rb:1001:in `block in call!'
/app/vendor/bundle/ruby/3.1.0/gems/sinatra-4.0.0/lib/sinatra/base.rb:1161:in `catch'
/app/vendor/bundle/ruby/3.1.0/gems/sinatra-4.0.0/lib/sinatra/base.rb:1161:in `invoke'
/app/vendor/bundle/ruby/3.1.0/gems/sinatra-4.0.0/lib/sinatra/base.rb:1001:in `call!'
/app/vendor/bundle/ruby/3.1.0/gems/sinatra-4.0.0/lib/sinatra/base.rb:990:in `call'
/app/vendor/bundle/ruby/3.1.0/gems/rack-3.0.9/lib/rack/rewindable_input.rb:25:in `call'
/app/vendor/bundle/ruby/3.1.0/gems/rack-3.0.9/lib/rack/deflater.rb:47:in `call'
/app/vendor/bundle/ruby/3.1.0/gems/rack-protection-4.0.0/lib/rack/protection/xss_header.rb:20:in `call'
/app/vendor/bundle/ruby/3.1.0/gems/rack-protection-4.0.0/lib/rack/protection/path_traversal.rb:18:in `call'
/app/vendor/bundle/ruby/3.1.0/gems/rack-protection-4.0.0/lib/rack/protection/json_csrf.rb:28:in `call'
/app/vendor/bundle/ruby/3.1.0/gems/rack-protection-4.0.0/lib/rack/protection/base.rb:53:in `call'
/app/vendor/bundle/ruby/3.1.0/gems/rack-protection-4.0.0/lib/rack/protection/base.rb:53:in `call'
/app/vendor/bundle/ruby/3.1.0/gems/rack-protection-4.0.0/lib/rack/protection/frame_options.rb:33:in `call'
/app/vendor/bundle/ruby/3.1.0/gems/rack-3.0.9/lib/rack/logger.rb:19:in `call'
/app/vendor/bundle/ruby/3.1.0/gems/rack-3.0.9/lib/rack/common_logger.rb:43:in `call'
/app/vendor/bundle/ruby/3.1.0/gems/sinatra-4.0.0/lib/sinatra/base.rb:266:in `call'
/app/vendor/bundle/ruby/3.1.0/gems/sinatra-4.0.0/lib/sinatra/base.rb:259:in `call'
/app/vendor/bundle/ruby/3.1.0/gems/rack-3.0.9/lib/rack/head.rb:15:in `call'
/app/vendor/bundle/ruby/3.1.0/gems/rack-3.0.9/lib/rack/method_override.rb:28:in `call'
/app/vendor/bundle/ruby/3.1.0/gems/sinatra-4.0.0/lib/sinatra/base.rb:224:in `call'
/app/vendor/bundle/ruby/3.1.0/gems/sinatra-4.0.0/lib/sinatra/base.rb:2115:in `call'
/app/vendor/bundle/ruby/3.1.0/gems/sinatra-4.0.0/lib/sinatra/base.rb:1674:in `block in call'
/app/vendor/bundle/ruby/3.1.0/gems/sinatra-4.0.0/lib/sinatra/base.rb:1890:in `synchronize'
/app/vendor/bundle/ruby/3.1.0/gems/sinatra-4.0.0/lib/sinatra/base.rb:1674:in `call'
/app/vendor/bundle/ruby/3.1.0/gems/rackup-2.1.0/lib/rackup/handler/webrick.rb:111:in `service'
/app/vendor/bundle/ruby/3.1.0/gems/webrick-1.8.1/lib/webrick/httpserver.rb:140:in `service'
/app/vendor/bundle/ruby/3.1.0/gems/webrick-1.8.1/lib/webrick/httpserver.rb:96:in `run'
/app/vendor/bundle/ruby/3.1.0/gems/webrick-1.8.1/lib/webrick/server.rb:310:in `block in start_thread'

Please sign in to comment.