@_nazmiforreal/flutter-ota 0.1.12 → 0.1.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/bin/flutter-ota-linux-x64 +0 -0
- package/dart-src/packages/cli-tools/.dart_tool/package_config.json +46 -76
- package/dart-src/packages/cli-tools/.dart_tool/package_graph.json +140 -166
- package/dart-src/packages/cli-tools/README.md +1 -1
- package/dart-src/packages/cli-tools/lib/flutter_ota_kit_cli.dart +30 -17
- package/dart-src/packages/cli-tools/lib/src/backend.dart +30 -31
- package/dart-src/packages/cli-tools/lib/src/cli_base.dart +3 -1
- package/dart-src/packages/cli-tools/lib/src/commands/build.dart +44 -43
- package/dart-src/packages/cli-tools/lib/src/commands/bundle.dart +265 -239
- package/dart-src/packages/cli-tools/lib/src/commands/channel.dart +75 -66
- package/dart-src/packages/cli-tools/lib/src/commands/config_command.dart +39 -35
- package/dart-src/packages/cli-tools/lib/src/commands/console.dart +30 -27
- package/dart-src/packages/cli-tools/lib/src/commands/deploy.dart +88 -72
- package/dart-src/packages/cli-tools/lib/src/commands/doctor.dart +66 -29
- package/dart-src/packages/cli-tools/lib/src/commands/fingerprint.dart +10 -6
- package/dart-src/packages/cli-tools/lib/src/commands/init.dart +290 -181
- package/dart-src/packages/cli-tools/lib/src/commands/keys.dart +24 -23
- package/dart-src/packages/cli-tools/lib/src/commands/migrate.dart +111 -97
- package/dart-src/packages/cli-tools/lib/src/commands/pocketbase.dart +237 -0
- package/dart-src/packages/cli-tools/lib/src/commands/rollback.dart +43 -34
- package/dart-src/packages/cli-tools/lib/src/commands/storage.dart +57 -53
- package/dart-src/packages/cli-tools/lib/src/config.dart +227 -93
- package/dart-src/packages/cli-tools/lib/src/operations.dart +9 -8
- package/dart-src/packages/cli-tools/lib/src/pack.dart +26 -25
- package/dart-src/packages/cli-tools/lib/src/pocketbase/data_bootstrap.dart +39 -0
- package/dart-src/packages/cli-tools/lib/src/pocketbase/hooks/bundles.pb.js +56 -0
- package/dart-src/packages/cli-tools/lib/src/pocketbase/installer.dart +189 -0
- package/dart-src/packages/cli-tools/lib/src/pocketbase/process_manager.dart +123 -0
- package/dart-src/packages/cli-tools/lib/src/pocketbase/schema_installer.dart +237 -0
- package/dart-src/packages/cli-tools/lib/src/runner.dart +36 -15
- package/dart-src/packages/cli-tools/lib/src/sign.dart +13 -5
- package/dart-src/packages/cli-tools/lib/src/ui/ui.dart +10 -13
- package/dart-src/packages/cli-tools/lib/src/util.dart +3 -1
- package/dart-src/packages/cli-tools/pubspec.lock +69 -116
- package/dart-src/packages/cli-tools/pubspec.yaml +25 -7
- package/dart-src/packages/cli-tools/test/backends_test.dart +62 -32
- package/dart-src/packages/cli-tools/test/build_pack_test.dart +4 -4
- package/dart-src/packages/cli-tools/test/cli_test.dart +89 -42
- package/dart-src/packages/cli-tools/test/mocks/mock_aws_s3_client.dart +8 -13
- package/dart-src/packages/cli-tools/test/mocks/mock_d1_client.dart +23 -18
- package/dart-src/packages/cli-tools/test/mocks/mock_pocketbase_client.dart +197 -0
- package/dart-src/packages/cli-tools/test/mocks/mock_postgres_client.dart +70 -46
- package/dart-src/packages/cli-tools/test/pocketbase_installer_test.dart +72 -0
- package/dart-src/packages/cli-tools/test/pocketbase_schema_test.dart +107 -0
- package/dart-src/packages/cli-tools/test/pocketbase_smoke_test.dart +59 -0
- package/dart-src/packages/core/README.md +2 -2
- package/dart-src/packages/core/example/lib/main.dart +69 -0
- package/dart-src/packages/core/lib/flutter_ota_kit_core.dart +1 -1
- package/dart-src/packages/core/lib/src/app_update_info.dart +17 -15
- package/dart-src/packages/core/lib/src/bundle.dart +102 -94
- package/dart-src/packages/core/lib/src/bundle_artifacts.dart +1 -2
- package/dart-src/packages/core/lib/src/bundle_patch_artifact.dart +15 -16
- package/dart-src/packages/core/lib/src/changed_asset.dart +24 -22
- package/dart-src/packages/core/lib/src/get_bundles_args.dart +13 -13
- package/dart-src/packages/core/lib/src/metadata.dart +9 -7
- package/dart-src/packages/core/lib/src/patch_info.dart +8 -7
- package/dart-src/packages/core/lib/src/platform.dart +4 -3
- package/dart-src/packages/core/lib/src/rollout.dart +14 -11
- package/dart-src/packages/core/lib/src/semver_range.dart +49 -39
- package/dart-src/packages/core/lib/src/semver_version.dart +8 -7
- package/dart-src/packages/core/lib/src/status.dart +4 -3
- package/dart-src/packages/core/lib/src/update_bundle_params.dart +7 -7
- package/dart-src/packages/core/lib/src/uuid.dart +1 -2
- package/dart-src/packages/core/pubspec.yaml +6 -7
- package/dart-src/packages/core/test/rollout_test.dart +15 -8
- package/dart-src/packages/core/test/semver_test.dart +5 -2
- package/dart-src/packages/core/test/types_test.dart +26 -24
- package/dart-src/packages/core/test/uuid_test.dart +3 -1
- package/dart-src/packages/core/tool/dbg.dart +1 -0
- package/dart-src/plugins/aws/CHANGELOG.md +6 -0
- package/dart-src/plugins/aws/example/lib/main.dart +60 -0
- package/dart-src/plugins/aws/lib/flutter_ota_kit_aws.dart +5 -1
- package/dart-src/plugins/aws/lib/src/aws_cloudfront_client.dart +11 -16
- package/dart-src/plugins/aws/lib/src/aws_cloudfront_signer.dart +7 -2
- package/dart-src/plugins/aws/lib/src/aws_database.dart +14 -18
- package/dart-src/plugins/aws/lib/src/aws_s3_client.dart +23 -18
- package/dart-src/plugins/aws/lib/src/aws_ssm_client.dart +5 -4
- package/dart-src/plugins/aws/lib/src/aws_storage.dart +2 -3
- package/dart-src/plugins/aws/lib/src/aws_storage_profile.dart +10 -16
- package/dart-src/plugins/aws/lib/src/with_cloudfront_signed_url.dart +6 -9
- package/dart-src/plugins/aws/pubspec.yaml +15 -10
- package/dart-src/plugins/aws/test/aws_database_test.dart +51 -57
- package/dart-src/plugins/aws/test/mock_aws_s3_client.dart +8 -13
- package/dart-src/plugins/cloudflare/CHANGELOG.md +7 -0
- package/dart-src/plugins/cloudflare/example/lib/main.dart +62 -0
- package/dart-src/plugins/cloudflare/lib/flutter_ota_kit_cloudflare.dart +4 -2
- package/dart-src/plugins/cloudflare/lib/src/cloudflare_worker_database.dart +3 -3
- package/dart-src/plugins/cloudflare/lib/src/d1_build_where.dart +3 -2
- package/dart-src/plugins/cloudflare/lib/src/d1_bundle_mapper.dart +24 -27
- package/dart-src/plugins/cloudflare/lib/src/d1_database_plugin.dart +22 -30
- package/dart-src/plugins/cloudflare/lib/src/r2_config.dart +1 -1
- package/dart-src/plugins/cloudflare/lib/src/r2_s3_client.dart +21 -29
- package/dart-src/plugins/cloudflare/lib/src/r2_storage.dart +7 -7
- package/dart-src/plugins/cloudflare/lib/src/r2_storage_profile.dart +7 -15
- package/dart-src/plugins/cloudflare/pubspec.yaml +14 -9
- package/dart-src/plugins/cloudflare/test/cloudflare_worker_database_test.dart +46 -42
- package/dart-src/plugins/cloudflare/test/d1_database_test.dart +100 -90
- package/dart-src/plugins/cloudflare/test/mock_d1_client.dart +23 -18
- package/dart-src/plugins/cloudflare/test/mock_r2_client.dart +8 -13
- package/dart-src/plugins/cloudflare/test/r2_storage_test.dart +1 -4
- package/dart-src/plugins/plugin-core/CHANGELOG.md +16 -0
- package/dart-src/plugins/plugin-core/example/lib/main.dart +61 -0
- package/dart-src/plugins/plugin-core/lib/flutter_ota_kit_plugin_core.dart +3 -7
- package/dart-src/plugins/plugin-core/lib/src/asset_storage_layout.dart +5 -5
- package/dart-src/plugins/plugin-core/lib/src/bundle_helpers.dart +23 -0
- package/dart-src/plugins/plugin-core/lib/src/bundle_storage_layout.dart +16 -10
- package/dart-src/plugins/plugin-core/lib/src/bundle_unit_of_work.dart +31 -26
- package/dart-src/plugins/plugin-core/lib/src/calculate_pagination.dart +5 -1
- package/dart-src/plugins/plugin-core/lib/src/content_addressed_assets.dart +1 -1
- package/dart-src/plugins/plugin-core/lib/src/create_blob_database_plugin.dart +78 -71
- package/dart-src/plugins/plugin-core/lib/src/create_database_plugin.dart +56 -35
- package/dart-src/plugins/plugin-core/lib/src/create_storage_plugin.dart +10 -13
- package/dart-src/plugins/plugin-core/lib/src/paginate_bundles.dart +30 -17
- package/dart-src/plugins/plugin-core/lib/src/parse_storage_uri.dart +3 -1
- package/dart-src/plugins/plugin-core/lib/src/query_bundles.dart +5 -3
- package/dart-src/plugins/plugin-core/lib/src/request_update_bundle_state.dart +2 -4
- package/dart-src/plugins/plugin-core/lib/src/storage_helpers.dart +18 -0
- package/dart-src/plugins/plugin-core/lib/src/types.dart +7 -6
- package/dart-src/plugins/plugin-core/pubspec.yaml +12 -9
- package/dart-src/plugins/plugin-core/test/asset_storage_layout_test.dart +13 -9
- package/dart-src/plugins/plugin-core/test/bundle_unit_of_work_test.dart +28 -15
- package/dart-src/plugins/plugin-core/test/create_blob_database_plugin_test.dart +254 -122
- package/dart-src/plugins/plugin-core/test/create_database_plugin_test.dart +36 -32
- package/dart-src/plugins/plugin-core/test/create_storage_plugin_test.dart +18 -15
- package/dart-src/plugins/plugin-core/test/generate_min_bundle_id_test.dart +8 -3
- package/dart-src/plugins/plugin-core/test/get_update_info_test.dart +682 -693
- package/dart-src/plugins/plugin-core/test/helpers_test.dart +45 -21
- package/dart-src/plugins/plugin-core/test/query_bundles_test.dart +76 -13
- package/dart-src/plugins/plugin-core/test/uuidv7_test.dart +20 -9
- package/dart-src/plugins/pocketbase/CHANGELOG.md +8 -0
- package/dart-src/plugins/pocketbase/LICENSE +21 -0
- package/dart-src/plugins/pocketbase/README.md +54 -0
- package/dart-src/plugins/pocketbase/example/lib/main.dart +62 -0
- package/dart-src/plugins/pocketbase/lib/flutter_ota_kit_pocketbase.dart +28 -0
- package/dart-src/plugins/pocketbase/lib/src/pocketbase_bundle_mapper.dart +121 -0
- package/dart-src/plugins/pocketbase/lib/src/pocketbase_client.dart +349 -0
- package/dart-src/plugins/pocketbase/lib/src/pocketbase_config.dart +61 -0
- package/dart-src/plugins/pocketbase/lib/src/pocketbase_database.dart +278 -0
- package/dart-src/plugins/pocketbase/lib/src/pocketbase_storage.dart +255 -0
- package/dart-src/plugins/pocketbase/pubspec.yaml +26 -0
- package/dart-src/plugins/pocketbase/test/pb_uri_test.dart +12 -0
- package/dart-src/plugins/postgres/CHANGELOG.md +6 -0
- package/dart-src/plugins/postgres/example/lib/main.dart +67 -0
- package/dart-src/plugins/postgres/lib/flutter_ota_kit_postgres.dart +3 -6
- package/dart-src/plugins/postgres/lib/src/postgres_bundle_mapper.dart +32 -52
- package/dart-src/plugins/postgres/lib/src/postgres_config.dart +3 -1
- package/dart-src/plugins/postgres/lib/src/postgres_database.dart +28 -38
- package/dart-src/plugins/postgres/lib/src/postgres_get_update_info.dart +16 -14
- package/dart-src/plugins/postgres/lib/src/postgres_storage.dart +26 -14
- package/dart-src/plugins/postgres/lib/src/postgres_types.dart +27 -28
- package/dart-src/plugins/postgres/pubspec.yaml +14 -9
- package/dart-src/plugins/postgres/test/mock_postgres_client.dart +62 -39
- package/dart-src/plugins/postgres/test/postgres_bundle_mapper_test.dart +3 -4
- package/dart-src/plugins/postgres/test/postgres_database_test.dart +102 -73
- package/dart-src/plugins/postgres/test/postgres_storage_runtime_test.dart +60 -0
- package/dart-src/plugins/supabase/CHANGELOG.md +17 -0
- package/dart-src/plugins/supabase/README.md +2 -2
- package/dart-src/plugins/supabase/example/lib/main.dart +63 -0
- package/dart-src/plugins/supabase/lib/flutter_ota_kit_supabase.dart +2 -0
- package/dart-src/plugins/supabase/lib/src/error_message.dart +11 -0
- package/dart-src/plugins/supabase/lib/src/supabase_bundle_mapper.dart +34 -58
- package/dart-src/plugins/supabase/lib/src/supabase_client_adapter.dart +3 -13
- package/dart-src/plugins/supabase/lib/src/supabase_client_http.dart +34 -52
- package/dart-src/plugins/supabase/lib/src/supabase_database.dart +38 -30
- package/dart-src/plugins/supabase/lib/src/supabase_edge_function_storage.dart +21 -29
- package/dart-src/plugins/supabase/lib/src/supabase_signed_url_batcher.dart +7 -19
- package/dart-src/plugins/supabase/lib/src/supabase_storage.dart +18 -29
- package/dart-src/plugins/supabase/lib/src/types.dart +26 -26
- package/dart-src/plugins/supabase/pubspec.yaml +14 -9
- package/dart-src/plugins/supabase/test/mock_supabase_client.dart +57 -57
- package/dart-src/plugins/supabase/test/supabase_bundle_mapper_test.dart +30 -27
- package/dart-src/plugins/supabase/test/supabase_database_test.dart +26 -35
- package/dart-src/plugins/supabase/test/supabase_storage_test.dart +27 -34
- package/package.json +3 -3
- package/scripts/vendor.sh +1 -1
|
@@ -20,7 +20,7 @@ class Bundle {
|
|
|
20
20
|
/// (carried in the update-check `signature` field), not here.
|
|
21
21
|
final String fileHash;
|
|
22
22
|
|
|
23
|
-
/// Protocol URI, e.g. supabase-storage://bucket/bundles
|
|
23
|
+
/// Protocol URI, e.g. `supabase-storage://bucket/bundles/{id}/patch.zip`.
|
|
24
24
|
final String storageUri;
|
|
25
25
|
final String? gitCommitHash;
|
|
26
26
|
final String? message;
|
|
@@ -82,105 +82,113 @@ class Bundle {
|
|
|
82
82
|
}
|
|
83
83
|
|
|
84
84
|
factory Bundle.fromJson(Map<String, dynamic> j) => Bundle(
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
85
|
+
id: (j['id'] ?? nilUuid) as String,
|
|
86
|
+
platform: Platform.fromValue(j['platform'] as String),
|
|
87
|
+
shouldForceUpdate:
|
|
88
|
+
(j['shouldForceUpdate'] ?? j['should_force_update'] ?? false) as bool,
|
|
89
|
+
enabled: (j['enabled'] ?? false) as bool,
|
|
90
|
+
fileHash: (j['fileHash'] ?? j['file_hash']) as String,
|
|
91
|
+
storageUri: (j['storageUri'] ?? j['storage_uri']) as String,
|
|
92
|
+
gitCommitHash: _s<String>(j, 'gitCommitHash', 'git_commit_hash'),
|
|
93
|
+
message: j['message'] == null ? null : j['message'] as String,
|
|
94
|
+
channel: (j['channel'] ?? 'production') as String,
|
|
95
|
+
targetAppVersion: _s<String>(j, 'targetAppVersion', 'target_app_version'),
|
|
96
|
+
fingerprintHash: _s<String>(j, 'fingerprintHash', 'fingerprint_hash'),
|
|
97
|
+
metadata: j['metadata'] is Map
|
|
98
|
+
? BundleMetadata.fromJson(
|
|
99
|
+
(j['metadata'] as Map).cast<String, dynamic>(),
|
|
100
|
+
)
|
|
101
|
+
: null,
|
|
102
|
+
manifestStorageUri: _s<String>(
|
|
103
|
+
j,
|
|
104
|
+
'manifestStorageUri',
|
|
105
|
+
'manifest_storage_uri',
|
|
106
|
+
),
|
|
107
|
+
manifestFileHash: _s<String>(j, 'manifestFileHash', 'manifest_file_hash'),
|
|
108
|
+
assetBaseStorageUri: _s<String>(
|
|
109
|
+
j,
|
|
110
|
+
'assetBaseStorageUri',
|
|
111
|
+
'asset_base_storage_uri',
|
|
112
|
+
),
|
|
113
|
+
patches: (j['patches'] as List?)
|
|
114
|
+
?.map(
|
|
115
|
+
(e) =>
|
|
116
|
+
BundlePatchArtifact.fromJson((e as Map).cast<String, dynamic>()),
|
|
117
|
+
)
|
|
118
|
+
.toList(),
|
|
119
|
+
patchBaseBundleId: _s<String>(
|
|
120
|
+
j,
|
|
121
|
+
'patchBaseBundleId',
|
|
122
|
+
'patch_base_bundle_id',
|
|
123
|
+
),
|
|
124
|
+
patchBaseFileHash: _s<String>(
|
|
125
|
+
j,
|
|
126
|
+
'patchBaseFileHash',
|
|
127
|
+
'patch_base_file_hash',
|
|
128
|
+
),
|
|
129
|
+
patchFileHash: _s(j, 'patchFileHash', 'patch_file_hash'),
|
|
130
|
+
patchStorageUri: _s<String>(j, 'patchStorageUri', 'patch_storage_uri'),
|
|
131
|
+
rolloutCohortCount: _s<int>(
|
|
132
|
+
j,
|
|
133
|
+
'rolloutCohortCount',
|
|
134
|
+
'rollout_cohort_count',
|
|
135
|
+
),
|
|
136
|
+
targetCohorts: (j['targetCohorts'] as List? ?? j['target_cohorts'] as List?)
|
|
137
|
+
?.map((e) => e as String)
|
|
138
|
+
.toList(),
|
|
139
|
+
);
|
|
126
140
|
|
|
127
141
|
/// camelCase wire format (server API payloads).
|
|
128
142
|
Map<String, dynamic> toJson() => {
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
'patchFileHash': patchFileHashLegacy,
|
|
153
|
-
if (patchStorageUri != null) 'patchStorageUri': patchStorageUri,
|
|
154
|
-
if (rolloutCohortCount != null)
|
|
155
|
-
'rolloutCohortCount': rolloutCohortCount,
|
|
156
|
-
if (targetCohorts != null) 'targetCohorts': targetCohorts,
|
|
157
|
-
};
|
|
143
|
+
'id': id,
|
|
144
|
+
'platform': platform.value,
|
|
145
|
+
'shouldForceUpdate': shouldForceUpdate,
|
|
146
|
+
'enabled': enabled,
|
|
147
|
+
'fileHash': fileHash,
|
|
148
|
+
'storageUri': storageUri,
|
|
149
|
+
if (gitCommitHash != null) 'gitCommitHash': gitCommitHash,
|
|
150
|
+
if (message != null) 'message': message,
|
|
151
|
+
'channel': channel,
|
|
152
|
+
if (targetAppVersion != null) 'targetAppVersion': targetAppVersion,
|
|
153
|
+
if (fingerprintHash != null) 'fingerprintHash': fingerprintHash,
|
|
154
|
+
if (metadata != null) 'metadata': metadata!.toJson(),
|
|
155
|
+
if (manifestStorageUri != null) 'manifestStorageUri': manifestStorageUri,
|
|
156
|
+
if (manifestFileHash != null) 'manifestFileHash': manifestFileHash,
|
|
157
|
+
if (assetBaseStorageUri != null) 'assetBaseStorageUri': assetBaseStorageUri,
|
|
158
|
+
if (patches != null) 'patches': patches!.map((p) => p.toJson()).toList(),
|
|
159
|
+
if (patchBaseBundleId != null) 'patchBaseBundleId': patchBaseBundleId,
|
|
160
|
+
if (patchBaseFileHash != null) 'patchBaseFileHash': patchBaseFileHash,
|
|
161
|
+
if (patchFileHashLegacy != null) 'patchFileHash': patchFileHashLegacy,
|
|
162
|
+
if (patchStorageUri != null) 'patchStorageUri': patchStorageUri,
|
|
163
|
+
if (rolloutCohortCount != null) 'rolloutCohortCount': rolloutCohortCount,
|
|
164
|
+
if (targetCohorts != null) 'targetCohorts': targetCohorts,
|
|
165
|
+
};
|
|
158
166
|
|
|
159
167
|
/// snake_case row format (Postgres/Supabase columns).
|
|
160
168
|
Map<String, dynamic> toSqlJson() => {
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
169
|
+
'id': id,
|
|
170
|
+
'platform': platform.value,
|
|
171
|
+
'should_force_update': shouldForceUpdate,
|
|
172
|
+
'enabled': enabled,
|
|
173
|
+
'file_hash': fileHash,
|
|
174
|
+
'storage_uri': storageUri,
|
|
175
|
+
'git_commit_hash': gitCommitHash,
|
|
176
|
+
'message': message,
|
|
177
|
+
'channel': channel,
|
|
178
|
+
'target_app_version': targetAppVersion,
|
|
179
|
+
'fingerprint_hash': fingerprintHash,
|
|
180
|
+
'metadata': metadata?.toJson() ?? <String, dynamic>{},
|
|
181
|
+
'manifest_storage_uri': manifestStorageUri,
|
|
182
|
+
'manifest_file_hash': manifestFileHash,
|
|
183
|
+
'asset_base_storage_uri': assetBaseStorageUri,
|
|
184
|
+
'patches': patches?.map((p) => p.toJson()).toList(),
|
|
185
|
+
'patch_base_bundle_id': patchBaseBundleId,
|
|
186
|
+
'patch_base_file_hash': patchBaseFileHash,
|
|
187
|
+
'patch_file_hash': patchFileHashLegacy,
|
|
188
|
+
'patch_storage_uri': patchStorageUri,
|
|
189
|
+
'rollout_cohort_count': rolloutCohortCount,
|
|
190
|
+
'target_cohorts': targetCohorts,
|
|
191
|
+
};
|
|
184
192
|
|
|
185
193
|
@override
|
|
186
194
|
bool operator ==(Object o) =>
|
|
@@ -12,8 +12,7 @@ import 'bundle_patch_artifact.dart';
|
|
|
12
12
|
/// there is nothing to strip.)
|
|
13
13
|
Map<String, Object?>? stripBundleArtifactMetadata(
|
|
14
14
|
Map<String, Object?>? metadata,
|
|
15
|
-
) =>
|
|
16
|
-
metadata;
|
|
15
|
+
) => metadata;
|
|
17
16
|
|
|
18
17
|
/// Extract `manifestStorageUri` from a bundle, defaulting to null.
|
|
19
18
|
String? getManifestStorageUri(Bundle bundle) => bundle.manifestStorageUri;
|
|
@@ -14,24 +14,23 @@ class BundlePatchArtifact {
|
|
|
14
14
|
required this.patchStorageUri,
|
|
15
15
|
});
|
|
16
16
|
|
|
17
|
-
factory BundlePatchArtifact.fromJson(
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
patchFileHash
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
);
|
|
17
|
+
factory BundlePatchArtifact.fromJson(
|
|
18
|
+
Map<String, dynamic> j,
|
|
19
|
+
) => BundlePatchArtifact(
|
|
20
|
+
baseBundleId: j['baseBundleId'] as String? ?? j['base_bundle_id'] as String,
|
|
21
|
+
baseFileHash: j['baseFileHash'] as String? ?? j['base_file_hash'] as String,
|
|
22
|
+
patchFileHash:
|
|
23
|
+
j['patchFileHash'] as String? ?? j['patch_file_hash'] as String,
|
|
24
|
+
patchStorageUri:
|
|
25
|
+
j['patchStorageUri'] as String? ?? j['patch_storage_uri'] as String,
|
|
26
|
+
);
|
|
28
27
|
|
|
29
28
|
Map<String, dynamic> toJson() => {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
29
|
+
'baseBundleId': baseBundleId,
|
|
30
|
+
'baseFileHash': baseFileHash,
|
|
31
|
+
'patchFileHash': patchFileHash,
|
|
32
|
+
'patchStorageUri': patchStorageUri,
|
|
33
|
+
};
|
|
35
34
|
|
|
36
35
|
@override
|
|
37
36
|
bool operator ==(Object o) =>
|
|
@@ -8,8 +8,10 @@ class ChangedAssetFile {
|
|
|
8
8
|
|
|
9
9
|
const ChangedAssetFile({required this.url, this.compression});
|
|
10
10
|
|
|
11
|
-
factory ChangedAssetFile.fromJson(Map<String, dynamic> j) =>
|
|
12
|
-
|
|
11
|
+
factory ChangedAssetFile.fromJson(Map<String, dynamic> j) => ChangedAssetFile(
|
|
12
|
+
url: j['url'] as String,
|
|
13
|
+
compression: j['compression'] as String?,
|
|
14
|
+
);
|
|
13
15
|
|
|
14
16
|
Map<String, dynamic> toJson() => {'url': url, 'compression': compression};
|
|
15
17
|
}
|
|
@@ -41,12 +43,12 @@ class ChangedAssetPatch {
|
|
|
41
43
|
);
|
|
42
44
|
|
|
43
45
|
Map<String, dynamic> toJson() => {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
46
|
+
'algorithm': algorithm,
|
|
47
|
+
'baseBundleId': baseBundleId,
|
|
48
|
+
'baseFileHash': baseFileHash,
|
|
49
|
+
'patchFileHash': patchFileHash,
|
|
50
|
+
'patchUrl': patchUrl,
|
|
51
|
+
};
|
|
50
52
|
}
|
|
51
53
|
|
|
52
54
|
class ChangedAsset {
|
|
@@ -58,20 +60,20 @@ class ChangedAsset {
|
|
|
58
60
|
const ChangedAsset({required this.fileHash, this.file, this.patch});
|
|
59
61
|
|
|
60
62
|
factory ChangedAsset.fromJson(Map<String, dynamic> j) => ChangedAsset(
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
63
|
+
fileHash: j['fileHash'] as String,
|
|
64
|
+
file: j['file'] == null
|
|
65
|
+
? null
|
|
66
|
+
: ChangedAssetFile.fromJson((j['file'] as Map).cast<String, dynamic>()),
|
|
67
|
+
patch: j['patch'] == null
|
|
68
|
+
? null
|
|
69
|
+
: ChangedAssetPatch.fromJson(
|
|
70
|
+
(j['patch'] as Map).cast<String, dynamic>(),
|
|
71
|
+
),
|
|
72
|
+
);
|
|
71
73
|
|
|
72
74
|
Map<String, dynamic> toJson() => {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
75
|
+
'fileHash': fileHash,
|
|
76
|
+
'file': file?.toJson(),
|
|
77
|
+
'patch': patch?.toJson(),
|
|
78
|
+
};
|
|
77
79
|
}
|
|
@@ -29,13 +29,13 @@ sealed class GetBundlesArgs {
|
|
|
29
29
|
UpdateStrategy get updateStrategy => _updateStrategy;
|
|
30
30
|
|
|
31
31
|
Map<String, dynamic> toJson() => {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
32
|
+
'_updateStrategy': _updateStrategy.value,
|
|
33
|
+
'platform': platform.value,
|
|
34
|
+
'bundleId': bundleId,
|
|
35
|
+
if (minBundleId != nilUuid) 'minBundleId': minBundleId,
|
|
36
|
+
if (channel != 'production') 'channel': channel,
|
|
37
|
+
if (cohort != null) 'cohort': cohort,
|
|
38
|
+
};
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
class FingerprintGetBundlesArgs extends GetBundlesArgs {
|
|
@@ -52,9 +52,9 @@ class FingerprintGetBundlesArgs extends GetBundlesArgs {
|
|
|
52
52
|
|
|
53
53
|
@override
|
|
54
54
|
Map<String, dynamic> toJson() => {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
55
|
+
...super.toJson(),
|
|
56
|
+
'fingerprintHash': fingerprintHash,
|
|
57
|
+
};
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
class AppVersionGetBundlesArgs extends GetBundlesArgs {
|
|
@@ -72,7 +72,7 @@ class AppVersionGetBundlesArgs extends GetBundlesArgs {
|
|
|
72
72
|
|
|
73
73
|
@override
|
|
74
74
|
Map<String, dynamic> toJson() => {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
75
|
+
...super.toJson(),
|
|
76
|
+
'appVersion': appVersion,
|
|
77
|
+
};
|
|
78
78
|
}
|
|
@@ -13,18 +13,20 @@ class BundleMetadata {
|
|
|
13
13
|
const BundleMetadata({this.appVersion, this.signature});
|
|
14
14
|
|
|
15
15
|
factory BundleMetadata.fromJson(Map<String, dynamic> j) => BundleMetadata(
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
appVersion: j['app_version'] as String?,
|
|
17
|
+
signature: j['signature'] as String?,
|
|
18
|
+
);
|
|
19
19
|
|
|
20
20
|
Map<String, dynamic> toJson() => {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
'app_version': appVersion,
|
|
22
|
+
if (signature != null) 'signature': signature,
|
|
23
|
+
};
|
|
24
24
|
|
|
25
25
|
@override
|
|
26
26
|
bool operator ==(Object o) =>
|
|
27
|
-
o is BundleMetadata &&
|
|
27
|
+
o is BundleMetadata &&
|
|
28
|
+
o.appVersion == appVersion &&
|
|
29
|
+
o.signature == signature;
|
|
28
30
|
|
|
29
31
|
@override
|
|
30
32
|
int get hashCode => Object.hash(appVersion, signature);
|
|
@@ -72,15 +72,16 @@ class PatchInfo {
|
|
|
72
72
|
|
|
73
73
|
/// Serializes this patch for the native MethodChannel call.
|
|
74
74
|
Map<String, dynamic> toJson() => {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
75
|
+
'version': version,
|
|
76
|
+
'patchUrl': patchUrl,
|
|
77
|
+
if (md5.isNotEmpty) 'md5': md5,
|
|
78
|
+
'signature': signature,
|
|
79
|
+
if (targetVersionCode != null) 'targetVersionCode': targetVersionCode,
|
|
80
|
+
};
|
|
81
81
|
|
|
82
82
|
@override
|
|
83
|
-
String toString() =>
|
|
83
|
+
String toString() =>
|
|
84
|
+
'PatchInfo('
|
|
84
85
|
'version=$version, url=$patchUrl, '
|
|
85
86
|
'md5=${md5.isEmpty ? 'none' : md5}, '
|
|
86
87
|
'sig=${signature.isEmpty ? 'none' : '***'})';
|
|
@@ -9,7 +9,8 @@ enum Platform {
|
|
|
9
9
|
final String value;
|
|
10
10
|
const Platform(this.value);
|
|
11
11
|
|
|
12
|
-
static Platform fromValue(String v) =>
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
static Platform fromValue(String v) => Platform.values.firstWhere(
|
|
13
|
+
(p) => p.value == v,
|
|
14
|
+
orElse: () => throw ArgumentError('unknown platform: $v'),
|
|
15
|
+
);
|
|
15
16
|
}
|
|
@@ -26,7 +26,8 @@ int? _parseNumericCohortValue(String cohort) {
|
|
|
26
26
|
return parsed;
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
int _positiveMod(int value, int modulus) =>
|
|
29
|
+
int _positiveMod(int value, int modulus) =>
|
|
30
|
+
((value % modulus) + modulus) % modulus;
|
|
30
31
|
|
|
31
32
|
/// Java-style 32-bit signed rolling string hash (`(h<<5) - h + c`, truncated).
|
|
32
33
|
int _hashString(String value) {
|
|
@@ -75,7 +76,8 @@ int _modularInverse(int value, int modulus) {
|
|
|
75
76
|
}
|
|
76
77
|
|
|
77
78
|
({int multiplier, int offset, int inverseMultiplier}) _rolloutShuffleParameters(
|
|
78
|
-
|
|
79
|
+
String bundleId,
|
|
80
|
+
) {
|
|
79
81
|
var multiplier = _positiveMod(_hashString('$bundleId:multiplier'), 997);
|
|
80
82
|
if (multiplier == 0) {
|
|
81
83
|
multiplier = 1;
|
|
@@ -140,7 +142,8 @@ bool isValidCohort(String cohort) {
|
|
|
140
142
|
|
|
141
143
|
/// Default cohort derived from a device identifier (ANDROID_ID etc.).
|
|
142
144
|
String getDefaultNumericCohort(String identifier) {
|
|
143
|
-
final cohortValue =
|
|
145
|
+
final cohortValue =
|
|
146
|
+
_positiveMod(_hashString(identifier), numericCohortSize) + 1;
|
|
144
147
|
return '$cohortValue';
|
|
145
148
|
}
|
|
146
149
|
|
|
@@ -156,18 +159,17 @@ int getNumericCohortRolloutPosition(String bundleId, int cohortValue) {
|
|
|
156
159
|
);
|
|
157
160
|
}
|
|
158
161
|
|
|
159
|
-
List<int> getRolledOutNumericCohorts(
|
|
160
|
-
String bundleId,
|
|
161
|
-
int? rolloutCohortCount,
|
|
162
|
-
) {
|
|
162
|
+
List<int> getRolledOutNumericCohorts(String bundleId, int? rolloutCohortCount) {
|
|
163
163
|
final normalized = normalizeRolloutCohortCount(rolloutCohortCount);
|
|
164
164
|
if (normalized <= 0) {
|
|
165
165
|
return [];
|
|
166
166
|
}
|
|
167
167
|
return List.generate(numericCohortSize, (index) => index + 1)
|
|
168
|
-
.where(
|
|
169
|
-
|
|
170
|
-
|
|
168
|
+
.where(
|
|
169
|
+
(cohortValue) =>
|
|
170
|
+
normalized >= numericCohortSize ||
|
|
171
|
+
getNumericCohortRolloutPosition(bundleId, cohortValue) < normalized,
|
|
172
|
+
)
|
|
171
173
|
.toList();
|
|
172
174
|
}
|
|
173
175
|
|
|
@@ -185,7 +187,8 @@ bool isCohortEligibleForUpdate(
|
|
|
185
187
|
final normalizedTargets =
|
|
186
188
|
targetCohorts?.map(normalizeCohortValue).toList() ?? <String>[];
|
|
187
189
|
|
|
188
|
-
if (normalizedCohort != null &&
|
|
190
|
+
if (normalizedCohort != null &&
|
|
191
|
+
normalizedTargets.contains(normalizedCohort)) {
|
|
189
192
|
return true;
|
|
190
193
|
}
|
|
191
194
|
|