Publicētais avots
Lejupielādēt avota ZIP
CH-J SM Mobile
Pārlūkot mapes un failus konkrētai lietojumprogrammas izdošanai.
CH-J / SM Mobile
134 faili
sm-mobile-20261016T050549Z-3678f2a05fa9
Pievienots: · Būvēts:
1
import 'dart:convert';2
import '../core/failure.dart';3
import '../models/server_profile.dart';5
class ProfileTransfer {6
static const maxBytes = 5 * 1024 * 1024;7
static List<ServerProfile> decode(List<int> bytes) {8
if (bytes.length > maxBytes) throw const Failure('invalidImport');9
try {10
final text = utf8.decode(bytes).replaceFirst(RegExp(r'^\uFEFF'), '');11
final data = jsonDecode(text);12
if (data is! Map ||13
data['format'] != 'chj-server-profiles' ||14
data['version'] != 1 ||15
data['servers'] is! List ||16
data['servers'].isEmpty ||17
data['servers'].length > 10000) {18
throw const Failure('invalidImport');19
}20
return (data['servers'] as List)21
.map(22
(e) => ServerProfile.fromJson(23
Map<String, dynamic>.from(e),24
portable: true,25
),26
)27
.toList();28
} catch (_) {29
throw const Failure('invalidImport');30
}31
}33
static List<int> encode(List<ServerProfile> profiles) => utf8.encode(34
const JsonEncoder.withIndent(' ').convert({35
'format': 'chj-server-profiles',36
'version': 1,37
'servers': profiles.map((p) => p.portable()).toList(),38
}),39
);40
}SHA-256
9d6b8526a0dabf2e6524e9ddf9a0ed29048131d73d927d0e3262a5e596f93b9aCH-J Proprietary Software License 1.14 · Avots ir sniegts saskaņā ar CH-J Proprietary Software License 1.14. Tā pieejamība nemaina licences noteikumus un nepiešķir papildu tiesības.
Arhīvs SHA-256
c486a807e4828998b9c57ab0f2e760f7980b31965fe118e89d3e1a5a2b65be65