@capgo/capacitor-updater 9.0.0 → 9.0.2

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.
Files changed (109) hide show
  1. package/CapgoCapacitorUpdater.podspec +3 -6
  2. package/Package.swift +30 -0
  3. package/README.md +2406 -291
  4. package/android/build.gradle +37 -17
  5. package/android/consumer-rules.pro +48 -0
  6. package/android/proguard-rules.pro +23 -0
  7. package/android/src/main/AndroidManifest.xml +0 -1
  8. package/android/src/main/java/ee/forgr/capacitor_updater/AndroidAppExitReporter.java +92 -0
  9. package/android/src/main/java/ee/forgr/capacitor_updater/AppLifecycleObserver.java +115 -0
  10. package/android/src/main/java/ee/forgr/capacitor_updater/BundleInfo.java +227 -195
  11. package/android/src/main/java/ee/forgr/capacitor_updater/BundleStatus.java +24 -23
  12. package/android/src/main/java/ee/forgr/capacitor_updater/Callback.java +13 -0
  13. package/android/src/main/java/ee/forgr/capacitor_updater/CapacitorUpdaterPlugin.java +7927 -1243
  14. package/android/src/main/java/ee/forgr/capacitor_updater/CapgoUpdater.java +5785 -0
  15. package/android/src/main/java/ee/forgr/capacitor_updater/CryptoCipher.java +564 -121
  16. package/android/src/main/java/ee/forgr/capacitor_updater/DataManager.java +44 -0
  17. package/android/src/main/java/ee/forgr/capacitor_updater/DelayCondition.java +43 -49
  18. package/android/src/main/java/ee/forgr/capacitor_updater/DelayUntilNext.java +4 -4
  19. package/android/src/main/java/ee/forgr/capacitor_updater/DelayUpdateUtils.java +427 -0
  20. package/android/src/main/java/ee/forgr/capacitor_updater/DeviceIdHelper.java +230 -0
  21. package/android/src/main/java/ee/forgr/capacitor_updater/DownloadService.java +2041 -118
  22. package/android/src/main/java/ee/forgr/capacitor_updater/DownloadWorkerManager.java +301 -0
  23. package/android/src/main/java/ee/forgr/capacitor_updater/HeadlessUpdateWorker.java +569 -0
  24. package/android/src/main/java/ee/forgr/capacitor_updater/Http3.java +436 -0
  25. package/android/src/main/java/ee/forgr/capacitor_updater/HttpEngineTransport.java +604 -0
  26. package/android/src/main/java/ee/forgr/capacitor_updater/InternalUtils.java +79 -0
  27. package/android/src/main/java/ee/forgr/capacitor_updater/Logger.java +419 -0
  28. package/android/src/main/java/ee/forgr/capacitor_updater/NativeUpdatePrompt.java +303 -0
  29. package/android/src/main/java/ee/forgr/capacitor_updater/ShakeDetector.java +72 -0
  30. package/android/src/main/java/ee/forgr/capacitor_updater/ShakeMenu.java +963 -0
  31. package/android/src/main/java/ee/forgr/capacitor_updater/StatsBatchFailureDiagnostics.java +40 -0
  32. package/android/src/main/java/ee/forgr/capacitor_updater/ThreeFingerPinchDetector.java +323 -0
  33. package/android/src/main/java/ee/forgr/capacitor_updater/Version.java +306 -0
  34. package/dist/docs.json +4431 -840
  35. package/dist/esm/definitions.d.ts +2641 -225
  36. package/dist/esm/definitions.js +103 -1
  37. package/dist/esm/definitions.js.map +1 -1
  38. package/dist/esm/history.d.ts +1 -0
  39. package/dist/esm/history.js +283 -0
  40. package/dist/esm/history.js.map +1 -0
  41. package/dist/esm/index.d.ts +3 -2
  42. package/dist/esm/index.js +5 -4
  43. package/dist/esm/index.js.map +1 -1
  44. package/dist/esm/web.d.ts +53 -42
  45. package/dist/esm/web.js +180 -37
  46. package/dist/esm/web.js.map +1 -1
  47. package/dist/plugin.cjs.js +570 -37
  48. package/dist/plugin.cjs.js.map +1 -1
  49. package/dist/plugin.js +570 -37
  50. package/dist/plugin.js.map +1 -1
  51. package/ios/Sources/CapacitorUpdaterPlugin/AES.swift +262 -0
  52. package/ios/Sources/CapacitorUpdaterPlugin/AppHealthTracker.swift +82 -0
  53. package/ios/Sources/CapacitorUpdaterPlugin/BundleInfo.swift +185 -0
  54. package/ios/Sources/CapacitorUpdaterPlugin/BundleStatus.swift +127 -0
  55. package/ios/Sources/CapacitorUpdaterPlugin/CapacitorUpdaterPlugin.swift +6813 -0
  56. package/ios/Sources/CapacitorUpdaterPlugin/CapgoRawRsa.swift +36 -0
  57. package/ios/Sources/CapacitorUpdaterPlugin/CapgoSemanticVersion.swift +200 -0
  58. package/ios/Sources/CapacitorUpdaterPlugin/CapgoUpdater.swift +5099 -0
  59. package/ios/Sources/CapacitorUpdaterPlugin/CryptoCipher.swift +387 -0
  60. package/ios/Sources/CapacitorUpdaterPlugin/DelayUpdateUtils.swift +343 -0
  61. package/ios/Sources/CapacitorUpdaterPlugin/DeviceIdHelper.swift +120 -0
  62. package/ios/Sources/CapacitorUpdaterPlugin/InternalUtils.swift +452 -0
  63. package/ios/Sources/CapacitorUpdaterPlugin/Logger.swift +380 -0
  64. package/ios/Sources/CapacitorUpdaterPlugin/NativeUpdatePrompt.swift +183 -0
  65. package/ios/Sources/CapacitorUpdaterPlugin/RSA.swift +96 -0
  66. package/ios/Sources/CapacitorUpdaterPlugin/RedirectPolicyDelegate.swift +97 -0
  67. package/ios/Sources/CapacitorUpdaterPlugin/ShakeMenu.swift +876 -0
  68. package/ios/{Plugin → Sources/CapacitorUpdaterPlugin}/UserDefaultsExtension.swift +0 -2
  69. package/ios/Sources/CapacitorUpdaterPlugin/WKWebView+CapgoObjcBridge.swift +20 -0
  70. package/ios/Sources/CapacitorUpdaterPlugin/WebViewStatsReporter.swift +304 -0
  71. package/ios/Sources/CapacitorUpdaterPlugin/ZipArchiveReader.swift +247 -0
  72. package/ios/Sources/CapacitorUpdaterPlugin/ZipCentralDirectory.swift +280 -0
  73. package/ios/Tests/CapacitorUpdaterPluginTests/BuiltinHashesTests.swift +210 -0
  74. package/ios/Tests/CapacitorUpdaterPluginTests/BundleHardeningTests.swift +292 -0
  75. package/ios/Tests/CapacitorUpdaterPluginTests/CapacitorUpdaterPluginTests.swift +6533 -0
  76. package/ios/Tests/CapacitorUpdaterPluginTests/CapgoSemanticVersionTests.swift +64 -0
  77. package/ios/Tests/CapacitorUpdaterPluginTests/ChecksumRequiredTests.swift +156 -0
  78. package/ios/Tests/CapacitorUpdaterPluginTests/CliCryptoFixtureTests.swift +314 -0
  79. package/ios/Tests/CapacitorUpdaterPluginTests/HttpsOnlyBuiltinMinimumTests.swift +653 -0
  80. package/ios/Tests/CapacitorUpdaterPluginTests/InstallPerfTests.swift +174 -0
  81. package/ios/Tests/CapacitorUpdaterPluginTests/ListChannelsTests.swift +74 -0
  82. package/ios/Tests/CapacitorUpdaterPluginTests/LoggerSecurityTests.swift +149 -0
  83. package/ios/Tests/CapacitorUpdaterPluginTests/NativeContractTests.swift +160 -0
  84. package/ios/Tests/CapacitorUpdaterPluginTests/NetworkTransportTests.swift +1109 -0
  85. package/ios/Tests/CapacitorUpdaterPluginTests/PopulateDeltaCacheTests.swift +573 -0
  86. package/ios/Tests/CapacitorUpdaterPluginTests/RedirectPolicyTests.swift +63 -0
  87. package/ios/Tests/CapacitorUpdaterPluginTests/RsaContractTests.swift +281 -0
  88. package/ios/Tests/CapacitorUpdaterPluginTests/SessionKeyRequiredTests.swift +196 -0
  89. package/ios/Tests/CapacitorUpdaterPluginTests/TestZipWriter.swift +235 -0
  90. package/ios/Tests/CapacitorUpdaterPluginTests/UpdateLifecycleTests.swift +470 -0
  91. package/ios/Tests/CapacitorUpdaterPluginTests/WebKitOverlayGuardTests.swift +32 -0
  92. package/ios/Tests/CapacitorUpdaterPluginTests/ZipArchiveReaderTests.swift +302 -0
  93. package/ios/Tests/CapacitorUpdaterPluginTests/ZipBundleExtractionTests.swift +122 -0
  94. package/package.json +80 -43
  95. package/scripts/builtin-hashes-lib.mjs +148 -0
  96. package/scripts/capacitor-builtin-hashes-hook.mjs +65 -0
  97. package/scripts/resolve-real-path.mjs +25 -0
  98. package/android/src/main/java/ee/forgr/capacitor_updater/CapacitorUpdater.java +0 -1130
  99. package/ios/Plugin/BundleInfo.swift +0 -113
  100. package/ios/Plugin/BundleStatus.swift +0 -48
  101. package/ios/Plugin/CapacitorUpdater.swift +0 -858
  102. package/ios/Plugin/CapacitorUpdaterPlugin.h +0 -10
  103. package/ios/Plugin/CapacitorUpdaterPlugin.m +0 -27
  104. package/ios/Plugin/CapacitorUpdaterPlugin.swift +0 -677
  105. package/ios/Plugin/CryptoCipher.swift +0 -240
  106. /package/{LICENCE → LICENSE} +0 -0
  107. /package/ios/{Plugin → Sources/CapacitorUpdaterPlugin}/DelayCondition.swift +0 -0
  108. /package/ios/{Plugin → Sources/CapacitorUpdaterPlugin}/DelayUntilNext.swift +0 -0
  109. /package/ios/{Plugin → Sources/CapacitorUpdaterPlugin}/Info.plist +0 -0
@@ -0,0 +1,452 @@
1
+ /*
2
+ * This Source Code Form is subject to the terms of the Mozilla Public
3
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
4
+ * file, You can obtain one at https://mozilla.org/MPL/2.0/.
5
+ */
6
+
7
+ import Foundation
8
+
9
+ extension Collection {
10
+ subscript(safe index: Index) -> Element? {
11
+ return indices.contains(index) ? self[index] : nil
12
+ }
13
+ }
14
+ extension URL {
15
+ var isDirectory: Bool {
16
+ (try? resourceValues(forKeys: [.isDirectoryKey]))?.isDirectory == true
17
+ }
18
+ var exist: Bool {
19
+ return FileManager().fileExists(atPath: self.path)
20
+ }
21
+ }
22
+ struct SetChannelDec: Decodable {
23
+ let status: String?
24
+ let error: String?
25
+ let message: String?
26
+ let unset: Bool?
27
+ }
28
+ public class SetChannel: NSObject {
29
+ var status: String = ""
30
+ var error: String = ""
31
+ var message: String = ""
32
+ }
33
+ extension SetChannel {
34
+ func toDict() -> [String: Any] {
35
+ var dict: [String: Any] = [String: Any]()
36
+ let otherSelf: Mirror = Mirror(reflecting: self)
37
+ for child: Mirror.Child in otherSelf.children {
38
+ if let key: String = child.label {
39
+ dict[key] = child.value
40
+ }
41
+ }
42
+ return dict
43
+ }
44
+ }
45
+ struct GetChannelDec: Decodable {
46
+ let channel: String?
47
+ let status: String?
48
+ let error: String?
49
+ let message: String?
50
+ let allowSet: Bool?
51
+ }
52
+ public class GetChannel: NSObject {
53
+ var channel: String = ""
54
+ var status: String = ""
55
+ var error: String = ""
56
+ var message: String = ""
57
+ var allowSet: Bool = true
58
+ }
59
+ extension GetChannel {
60
+ func toDict() -> [String: Any] {
61
+ var dict: [String: Any] = [String: Any]()
62
+ let otherSelf: Mirror = Mirror(reflecting: self)
63
+ for child: Mirror.Child in otherSelf.children {
64
+ if let key: String = child.label {
65
+ dict[key] = child.value
66
+ }
67
+ }
68
+ return dict
69
+ }
70
+ }
71
+ // swiftlint:disable identifier_name
72
+ struct ChannelInfo: Codable {
73
+ let id: Int
74
+ let name: String?
75
+ let `public`: Bool?
76
+ let allow_self_set: Bool?
77
+ }
78
+ // swiftlint:enable identifier_name
79
+ struct ListChannelsDec: Decodable {
80
+ let channels: [ChannelInfo]?
81
+ let error: String?
82
+
83
+ init(from decoder: Decoder) throws {
84
+ let container = try decoder.singleValueContainer()
85
+
86
+ if let channelsArray = try? container.decode([ChannelInfo].self) {
87
+ // Backend returns direct array
88
+ self.channels = channelsArray
89
+ self.error = nil
90
+ } else {
91
+ // Handle error response
92
+ let errorContainer = try decoder.container(keyedBy: CodingKeys.self)
93
+ self.channels = nil
94
+ self.error = try? errorContainer.decode(String.self, forKey: .error)
95
+ }
96
+ }
97
+
98
+ private enum CodingKeys: String, CodingKey {
99
+ case error
100
+ }
101
+ }
102
+ public class ListChannels: NSObject {
103
+ var channels: [[String: Any]] = []
104
+ var error: String = ""
105
+ }
106
+ extension ListChannels {
107
+ func toDict() -> [String: Any] {
108
+ var dict: [String: Any] = [String: Any]()
109
+ let otherSelf: Mirror = Mirror(reflecting: self)
110
+ for child: Mirror.Child in otherSelf.children {
111
+ if let key: String = child.label {
112
+ dict[key] = child.value
113
+ }
114
+ }
115
+ return dict
116
+ }
117
+ }
118
+ // swiftlint:disable identifier_name
119
+ struct InfoObject: Codable {
120
+ let platform: String?
121
+ let device_id: String?
122
+ let app_id: String?
123
+ let custom_id: String?
124
+ let version_build: String?
125
+ let version_code: String?
126
+ let version_os: String?
127
+ var version_name: String?
128
+ var old_version_name: String?
129
+ let plugin_version: String?
130
+ let is_emulator: Bool?
131
+ let is_prod: Bool?
132
+ let installSource: String?
133
+ var action: String?
134
+ var channel: String?
135
+ var defaultChannel: String?
136
+ var key_id: String?
137
+
138
+ enum CodingKeys: String, CodingKey {
139
+ case platform
140
+ case device_id
141
+ case app_id
142
+ case custom_id
143
+ case version_build
144
+ case version_code
145
+ case version_os
146
+ case version_name
147
+ case old_version_name
148
+ case plugin_version
149
+ case is_emulator
150
+ case is_prod
151
+ case installSource = "install_source"
152
+ case action
153
+ case channel
154
+ case defaultChannel
155
+ case key_id
156
+ }
157
+ }
158
+
159
+ extension InfoObject {
160
+ func toParameters() -> [String: Any] {
161
+ var parameters: [String: Any] = [:]
162
+ func set(_ key: String, _ value: Any?) {
163
+ guard let value = value else {
164
+ return
165
+ }
166
+ parameters[key] = value
167
+ }
168
+ set("platform", platform)
169
+ set("device_id", device_id)
170
+ set("app_id", app_id)
171
+ set("custom_id", custom_id)
172
+ set("version_build", version_build)
173
+ set("version_code", version_code)
174
+ set("version_os", version_os)
175
+ set("version_name", version_name)
176
+ set("old_version_name", old_version_name)
177
+ set("plugin_version", plugin_version)
178
+ set("is_emulator", is_emulator)
179
+ set("is_prod", is_prod)
180
+ set("install_source", installSource)
181
+ set("action", action)
182
+ set("channel", channel)
183
+ set("defaultChannel", defaultChannel)
184
+ set("key_id", key_id)
185
+ return parameters
186
+ }
187
+ }
188
+ // swiftlint:enable identifier_name
189
+
190
+ // swiftlint:disable identifier_name
191
+ struct StatsEvent: Codable {
192
+ let platform: String?
193
+ let device_id: String?
194
+ let app_id: String?
195
+ let custom_id: String?
196
+ let version_build: String?
197
+ let version_code: String?
198
+ let version_os: String?
199
+ let version_name: String?
200
+ let old_version_name: String?
201
+ let plugin_version: String?
202
+ let is_emulator: Bool?
203
+ let is_prod: Bool?
204
+ let installSource: String?
205
+ let action: String?
206
+ let channel: String?
207
+ let defaultChannel: String?
208
+ let key_id: String?
209
+ let metadata: [String: String]?
210
+ let timestamp: Int64
211
+
212
+ enum CodingKeys: String, CodingKey {
213
+ case platform
214
+ case device_id
215
+ case app_id
216
+ case custom_id
217
+ case version_build
218
+ case version_code
219
+ case version_os
220
+ case version_name
221
+ case old_version_name
222
+ case plugin_version
223
+ case is_emulator
224
+ case is_prod
225
+ case installSource = "install_source"
226
+ case action
227
+ case channel
228
+ case defaultChannel
229
+ case key_id
230
+ case metadata
231
+ case timestamp
232
+ }
233
+ }
234
+ // swiftlint:enable identifier_name
235
+
236
+ // swiftlint:disable identifier_name
237
+ public struct ManifestEntry: Codable {
238
+ let file_name: String?
239
+ let file_hash: String?
240
+ let download_url: String?
241
+ }
242
+ // swiftlint:enable identifier_name
243
+
244
+ extension ManifestEntry {
245
+ func toDict() -> [String: Any] {
246
+ var dict: [String: Any] = [String: Any]()
247
+ let mirror = Mirror(reflecting: self)
248
+ for child in mirror.children {
249
+ if let key = child.label {
250
+ dict[key] = child.value
251
+ }
252
+ }
253
+ return dict
254
+ }
255
+ }
256
+
257
+ // swiftlint:disable identifier_name
258
+ struct AppVersionDec: Decodable {
259
+ let version: String?
260
+ let checksum: String?
261
+ let url: String?
262
+ let message: String?
263
+ let error: String?
264
+ let kind: String?
265
+ let session_key: String?
266
+ let major: Bool?
267
+ let breaking: Bool?
268
+ let data: [String: String]?
269
+ let manifest: [ManifestEntry]?
270
+ let link: String?
271
+ let comment: String?
272
+ // The HTTP status code is captured separately in CapgoUpdater; this struct only mirrors JSON.
273
+ }
274
+ // swiftlint:enable identifier_name
275
+
276
+ public class AppVersion: NSObject {
277
+ var version: String = ""
278
+ var checksum: String = ""
279
+ var url: String = ""
280
+ var message: String?
281
+ var error: String?
282
+ var kind: String?
283
+ var sessionKey: String?
284
+ var major: Bool?
285
+ var breaking: Bool?
286
+ var data: [String: String]?
287
+ var manifest: [ManifestEntry]?
288
+ var missing: [String: Any]?
289
+ var downloadSize: [String: Any]?
290
+ var link: String?
291
+ var comment: String?
292
+ var statusCode: Int = 0
293
+ }
294
+
295
+ extension AppVersion {
296
+ func toDict() -> [String: Any] {
297
+ var dict: [String: Any] = [String: Any]()
298
+ let otherSelf: Mirror = Mirror(reflecting: self)
299
+ for child: Mirror.Child in otherSelf.children {
300
+ if let key: String = child.label {
301
+ if key == "manifest", let manifestEntries = child.value as? [ManifestEntry] {
302
+ dict[key] = manifestEntries.map { $0.toDict() }
303
+ } else {
304
+ dict[key] = child.value
305
+ }
306
+ }
307
+ }
308
+ return dict
309
+ }
310
+ }
311
+
312
+ extension OperatingSystemVersion {
313
+ func getFullVersion(separator: String = ".") -> String {
314
+ return "\(majorVersion)\(separator)\(minorVersion)\(separator)\(patchVersion)"
315
+ }
316
+ }
317
+ extension Bundle {
318
+ var versionName: String? {
319
+ return infoDictionary?["CFBundleShortVersionString"] as? String
320
+ }
321
+ var versionCode: String? {
322
+ return infoDictionary?["CFBundleVersion"] as? String
323
+ }
324
+ }
325
+
326
+ extension ISO8601DateFormatter {
327
+ convenience init(_ formatOptions: Options) {
328
+ self.init()
329
+ self.formatOptions = formatOptions
330
+ }
331
+ }
332
+ extension Formatter {
333
+ static let iso8601withFractionalSeconds: ISO8601DateFormatter = ISO8601DateFormatter(
334
+ [.withInternetDateTime, .withFractionalSeconds])
335
+ }
336
+ extension Date {
337
+ var iso8601withFractionalSeconds: String { return Formatter.iso8601withFractionalSeconds.string(from: self) }
338
+ }
339
+ extension String {
340
+
341
+ var fileURL: URL {
342
+ return URL(fileURLWithPath: self)
343
+ }
344
+
345
+ var lastPathComponent: String {
346
+ get {
347
+ return fileURL.lastPathComponent
348
+ }
349
+ }
350
+ var iso8601withFractionalSeconds: Date? {
351
+ return Formatter.iso8601withFractionalSeconds.date(from: self)
352
+ }
353
+ func trim(using characterSet: CharacterSet = .whitespacesAndNewlines) -> String {
354
+ return trimmingCharacters(in: characterSet)
355
+ }
356
+ }
357
+
358
+ enum CustomError: Error {
359
+ // Throw when an unzip fail
360
+ case cannotUnzip
361
+ case cannotWrite
362
+ case cannotDecode
363
+ case cannotUnflat
364
+ case cannotCreateDirectory
365
+ case cannotDeleteDirectory
366
+ case cannotDecryptSessionKey
367
+ case invalidBase64
368
+ case insufficientDiskSpace
369
+
370
+ // Throw in all other cases
371
+ case unexpected(code: Int)
372
+ }
373
+
374
+ extension CustomError: LocalizedError {
375
+ public var errorDescription: String? {
376
+ switch self {
377
+ case .cannotUnzip:
378
+ return NSLocalizedString(
379
+ "The file cannot be unzip",
380
+ comment: "Invalid zip"
381
+ )
382
+ case .cannotCreateDirectory:
383
+ return NSLocalizedString(
384
+ "The folder cannot be created",
385
+ comment: "Invalid folder"
386
+ )
387
+ case .cannotDeleteDirectory:
388
+ return NSLocalizedString(
389
+ "The folder cannot be deleted",
390
+ comment: "Invalid folder"
391
+ )
392
+ case .cannotUnflat:
393
+ return NSLocalizedString(
394
+ "The file cannot be unflat",
395
+ comment: "Invalid folder"
396
+ )
397
+ case .unexpected:
398
+ return NSLocalizedString(
399
+ "An unexpected error occurred.",
400
+ comment: "Unexpected Error"
401
+ )
402
+ case .cannotDecode:
403
+ return NSLocalizedString(
404
+ "Decoding the zip failed with this key",
405
+ comment: "Invalid public key"
406
+ )
407
+ case .cannotWrite:
408
+ return NSLocalizedString(
409
+ "Cannot write to the destination",
410
+ comment: "Invalid destination"
411
+ )
412
+ case .cannotDecryptSessionKey:
413
+ return NSLocalizedString(
414
+ "Decrypting the session key failed",
415
+ comment: "Invalid session key"
416
+ )
417
+ case .invalidBase64:
418
+ return NSLocalizedString(
419
+ "Decrypting the base64 failed",
420
+ comment: "Invalid checksum key"
421
+ )
422
+ case .insufficientDiskSpace:
423
+ return NSLocalizedString(
424
+ "Insufficient disk space for download",
425
+ comment: "Not enough storage"
426
+ )
427
+ }
428
+ }
429
+ }
430
+
431
+ /// Thread-safe atomic boolean for concurrent operations
432
+ final class AtomicBool {
433
+ private var _value: Bool
434
+ private let lock = NSLock()
435
+
436
+ init(initialValue: Bool = false) {
437
+ _value = initialValue
438
+ }
439
+
440
+ var value: Bool {
441
+ get {
442
+ lock.lock()
443
+ defer { lock.unlock() }
444
+ return _value
445
+ }
446
+ set {
447
+ lock.lock()
448
+ defer { lock.unlock() }
449
+ _value = newValue
450
+ }
451
+ }
452
+ }