react-native-cloud-sync 0.1.0
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/LICENSE +21 -0
- package/README.md +360 -0
- package/app.plugin.js +3 -0
- package/ios/CloudSyncError.swift +144 -0
- package/ios/CloudSyncImpl.swift +1263 -0
- package/ios/RNCloudSync.h +25 -0
- package/ios/RNCloudSync.mm +477 -0
- package/jest-mock.js +136 -0
- package/lib/commonjs/config.js +85 -0
- package/lib/commonjs/config.js.map +1 -0
- package/lib/commonjs/errors.js +244 -0
- package/lib/commonjs/errors.js.map +1 -0
- package/lib/commonjs/hooks.js +257 -0
- package/lib/commonjs/hooks.js.map +1 -0
- package/lib/commonjs/index.js +244 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/internal/autoFlush.js +65 -0
- package/lib/commonjs/internal/autoFlush.js.map +1 -0
- package/lib/commonjs/internal/base64.js +58 -0
- package/lib/commonjs/internal/base64.js.map +1 -0
- package/lib/commonjs/internal/bytes.js +32 -0
- package/lib/commonjs/internal/bytes.js.map +1 -0
- package/lib/commonjs/internal/cloudKitRest.js +527 -0
- package/lib/commonjs/internal/cloudKitRest.js.map +1 -0
- package/lib/commonjs/internal/enums.js +23 -0
- package/lib/commonjs/internal/enums.js.map +1 -0
- package/lib/commonjs/internal/googleDriveRest.js +624 -0
- package/lib/commonjs/internal/googleDriveRest.js.map +1 -0
- package/lib/commonjs/internal/keys.js +139 -0
- package/lib/commonjs/internal/keys.js.map +1 -0
- package/lib/commonjs/internal/logger.js +29 -0
- package/lib/commonjs/internal/logger.js.map +1 -0
- package/lib/commonjs/internal/nativeModule.js +125 -0
- package/lib/commonjs/internal/nativeModule.js.map +1 -0
- package/lib/commonjs/internal/timeout.js +72 -0
- package/lib/commonjs/internal/timeout.js.map +1 -0
- package/lib/commonjs/package.json +1 -0
- package/lib/commonjs/providers/cloudKit.js +398 -0
- package/lib/commonjs/providers/cloudKit.js.map +1 -0
- package/lib/commonjs/providers/cloudKitBackup.js +86 -0
- package/lib/commonjs/providers/cloudKitBackup.js.map +1 -0
- package/lib/commonjs/providers/cloudKitEncrypted.js +150 -0
- package/lib/commonjs/providers/cloudKitEncrypted.js.map +1 -0
- package/lib/commonjs/providers/googleDrive.js +219 -0
- package/lib/commonjs/providers/googleDrive.js.map +1 -0
- package/lib/commonjs/providers/googleDriveFiles.js +68 -0
- package/lib/commonjs/providers/googleDriveFiles.js.map +1 -0
- package/lib/commonjs/providers/icloudDocuments.js +121 -0
- package/lib/commonjs/providers/icloudDocuments.js.map +1 -0
- package/lib/commonjs/providers/icloudKV.js +171 -0
- package/lib/commonjs/providers/icloudKV.js.map +1 -0
- package/lib/commonjs/providers/icloudKV.web.js +42 -0
- package/lib/commonjs/providers/icloudKV.web.js.map +1 -0
- package/lib/commonjs/providers/memory.js +201 -0
- package/lib/commonjs/providers/memory.js.map +1 -0
- package/lib/commonjs/resolvers.js +128 -0
- package/lib/commonjs/resolvers.js.map +1 -0
- package/lib/commonjs/specs/NativeRNCloudSync.js +14 -0
- package/lib/commonjs/specs/NativeRNCloudSync.js.map +1 -0
- package/lib/commonjs/store.js +1064 -0
- package/lib/commonjs/store.js.map +1 -0
- package/lib/commonjs/testing.js +32 -0
- package/lib/commonjs/testing.js.map +1 -0
- package/lib/commonjs/types.js +86 -0
- package/lib/commonjs/types.js.map +1 -0
- package/lib/module/config.js +72 -0
- package/lib/module/config.js.map +1 -0
- package/lib/module/errors.js +231 -0
- package/lib/module/errors.js.map +1 -0
- package/lib/module/hooks.js +250 -0
- package/lib/module/hooks.js.map +1 -0
- package/lib/module/index.js +46 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/internal/autoFlush.js +62 -0
- package/lib/module/internal/autoFlush.js.map +1 -0
- package/lib/module/internal/base64.js +53 -0
- package/lib/module/internal/base64.js.map +1 -0
- package/lib/module/internal/bytes.js +28 -0
- package/lib/module/internal/bytes.js.map +1 -0
- package/lib/module/internal/cloudKitRest.js +518 -0
- package/lib/module/internal/cloudKitRest.js.map +1 -0
- package/lib/module/internal/enums.js +18 -0
- package/lib/module/internal/enums.js.map +1 -0
- package/lib/module/internal/googleDriveRest.js +620 -0
- package/lib/module/internal/googleDriveRest.js.map +1 -0
- package/lib/module/internal/keys.js +134 -0
- package/lib/module/internal/keys.js.map +1 -0
- package/lib/module/internal/logger.js +23 -0
- package/lib/module/internal/logger.js.map +1 -0
- package/lib/module/internal/nativeModule.js +117 -0
- package/lib/module/internal/nativeModule.js.map +1 -0
- package/lib/module/internal/timeout.js +67 -0
- package/lib/module/internal/timeout.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/module/providers/cloudKit.js +392 -0
- package/lib/module/providers/cloudKit.js.map +1 -0
- package/lib/module/providers/cloudKitBackup.js +82 -0
- package/lib/module/providers/cloudKitBackup.js.map +1 -0
- package/lib/module/providers/cloudKitEncrypted.js +146 -0
- package/lib/module/providers/cloudKitEncrypted.js.map +1 -0
- package/lib/module/providers/googleDrive.js +214 -0
- package/lib/module/providers/googleDrive.js.map +1 -0
- package/lib/module/providers/googleDriveFiles.js +64 -0
- package/lib/module/providers/googleDriveFiles.js.map +1 -0
- package/lib/module/providers/icloudDocuments.js +117 -0
- package/lib/module/providers/icloudDocuments.js.map +1 -0
- package/lib/module/providers/icloudKV.js +165 -0
- package/lib/module/providers/icloudKV.js.map +1 -0
- package/lib/module/providers/icloudKV.web.js +36 -0
- package/lib/module/providers/icloudKV.web.js.map +1 -0
- package/lib/module/providers/memory.js +197 -0
- package/lib/module/providers/memory.js.map +1 -0
- package/lib/module/resolvers.js +120 -0
- package/lib/module/resolvers.js.map +1 -0
- package/lib/module/specs/NativeRNCloudSync.js +12 -0
- package/lib/module/specs/NativeRNCloudSync.js.map +1 -0
- package/lib/module/store.js +1061 -0
- package/lib/module/store.js.map +1 -0
- package/lib/module/testing.js +17 -0
- package/lib/module/testing.js.map +1 -0
- package/lib/module/types.js +82 -0
- package/lib/module/types.js.map +1 -0
- package/lib/typescript/commonjs/config.d.ts +33 -0
- package/lib/typescript/commonjs/config.d.ts.map +1 -0
- package/lib/typescript/commonjs/errors.d.ts +140 -0
- package/lib/typescript/commonjs/errors.d.ts.map +1 -0
- package/lib/typescript/commonjs/hooks.d.ts +109 -0
- package/lib/typescript/commonjs/hooks.d.ts.map +1 -0
- package/lib/typescript/commonjs/index.d.ts +37 -0
- package/lib/typescript/commonjs/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/internal/autoFlush.d.ts +45 -0
- package/lib/typescript/commonjs/internal/autoFlush.d.ts.map +1 -0
- package/lib/typescript/commonjs/internal/base64.d.ts +12 -0
- package/lib/typescript/commonjs/internal/base64.d.ts.map +1 -0
- package/lib/typescript/commonjs/internal/bytes.d.ts +12 -0
- package/lib/typescript/commonjs/internal/bytes.d.ts.map +1 -0
- package/lib/typescript/commonjs/internal/cloudKitRest.d.ts +149 -0
- package/lib/typescript/commonjs/internal/cloudKitRest.d.ts.map +1 -0
- package/lib/typescript/commonjs/internal/enums.d.ts +10 -0
- package/lib/typescript/commonjs/internal/enums.d.ts.map +1 -0
- package/lib/typescript/commonjs/internal/googleDriveRest.d.ts +232 -0
- package/lib/typescript/commonjs/internal/googleDriveRest.d.ts.map +1 -0
- package/lib/typescript/commonjs/internal/keys.d.ts +28 -0
- package/lib/typescript/commonjs/internal/keys.d.ts.map +1 -0
- package/lib/typescript/commonjs/internal/logger.d.ts +10 -0
- package/lib/typescript/commonjs/internal/logger.d.ts.map +1 -0
- package/lib/typescript/commonjs/internal/nativeModule.d.ts +29 -0
- package/lib/typescript/commonjs/internal/nativeModule.d.ts.map +1 -0
- package/lib/typescript/commonjs/internal/timeout.d.ts +36 -0
- package/lib/typescript/commonjs/internal/timeout.d.ts.map +1 -0
- package/lib/typescript/commonjs/package.json +1 -0
- package/lib/typescript/commonjs/providers/cloudKit.d.ts +86 -0
- package/lib/typescript/commonjs/providers/cloudKit.d.ts.map +1 -0
- package/lib/typescript/commonjs/providers/cloudKitBackup.d.ts +65 -0
- package/lib/typescript/commonjs/providers/cloudKitBackup.d.ts.map +1 -0
- package/lib/typescript/commonjs/providers/cloudKitEncrypted.d.ts +37 -0
- package/lib/typescript/commonjs/providers/cloudKitEncrypted.d.ts.map +1 -0
- package/lib/typescript/commonjs/providers/googleDrive.d.ts +35 -0
- package/lib/typescript/commonjs/providers/googleDrive.d.ts.map +1 -0
- package/lib/typescript/commonjs/providers/googleDriveFiles.d.ts +59 -0
- package/lib/typescript/commonjs/providers/googleDriveFiles.d.ts.map +1 -0
- package/lib/typescript/commonjs/providers/icloudDocuments.d.ts +101 -0
- package/lib/typescript/commonjs/providers/icloudDocuments.d.ts.map +1 -0
- package/lib/typescript/commonjs/providers/icloudKV.d.ts +26 -0
- package/lib/typescript/commonjs/providers/icloudKV.d.ts.map +1 -0
- package/lib/typescript/commonjs/providers/icloudKV.web.d.ts +12 -0
- package/lib/typescript/commonjs/providers/icloudKV.web.d.ts.map +1 -0
- package/lib/typescript/commonjs/providers/memory.d.ts +90 -0
- package/lib/typescript/commonjs/providers/memory.d.ts.map +1 -0
- package/lib/typescript/commonjs/resolvers.d.ts +60 -0
- package/lib/typescript/commonjs/resolvers.d.ts.map +1 -0
- package/lib/typescript/commonjs/specs/NativeRNCloudSync.d.ts +133 -0
- package/lib/typescript/commonjs/specs/NativeRNCloudSync.d.ts.map +1 -0
- package/lib/typescript/commonjs/store.d.ts +118 -0
- package/lib/typescript/commonjs/store.d.ts.map +1 -0
- package/lib/typescript/commonjs/testing.d.ts +16 -0
- package/lib/typescript/commonjs/testing.d.ts.map +1 -0
- package/lib/typescript/commonjs/types.d.ts +367 -0
- package/lib/typescript/commonjs/types.d.ts.map +1 -0
- package/lib/typescript/module/config.d.ts +33 -0
- package/lib/typescript/module/config.d.ts.map +1 -0
- package/lib/typescript/module/errors.d.ts +140 -0
- package/lib/typescript/module/errors.d.ts.map +1 -0
- package/lib/typescript/module/hooks.d.ts +109 -0
- package/lib/typescript/module/hooks.d.ts.map +1 -0
- package/lib/typescript/module/index.d.ts +37 -0
- package/lib/typescript/module/index.d.ts.map +1 -0
- package/lib/typescript/module/internal/autoFlush.d.ts +45 -0
- package/lib/typescript/module/internal/autoFlush.d.ts.map +1 -0
- package/lib/typescript/module/internal/base64.d.ts +12 -0
- package/lib/typescript/module/internal/base64.d.ts.map +1 -0
- package/lib/typescript/module/internal/bytes.d.ts +12 -0
- package/lib/typescript/module/internal/bytes.d.ts.map +1 -0
- package/lib/typescript/module/internal/cloudKitRest.d.ts +149 -0
- package/lib/typescript/module/internal/cloudKitRest.d.ts.map +1 -0
- package/lib/typescript/module/internal/enums.d.ts +10 -0
- package/lib/typescript/module/internal/enums.d.ts.map +1 -0
- package/lib/typescript/module/internal/googleDriveRest.d.ts +232 -0
- package/lib/typescript/module/internal/googleDriveRest.d.ts.map +1 -0
- package/lib/typescript/module/internal/keys.d.ts +28 -0
- package/lib/typescript/module/internal/keys.d.ts.map +1 -0
- package/lib/typescript/module/internal/logger.d.ts +10 -0
- package/lib/typescript/module/internal/logger.d.ts.map +1 -0
- package/lib/typescript/module/internal/nativeModule.d.ts +29 -0
- package/lib/typescript/module/internal/nativeModule.d.ts.map +1 -0
- package/lib/typescript/module/internal/timeout.d.ts +36 -0
- package/lib/typescript/module/internal/timeout.d.ts.map +1 -0
- package/lib/typescript/module/package.json +1 -0
- package/lib/typescript/module/providers/cloudKit.d.ts +86 -0
- package/lib/typescript/module/providers/cloudKit.d.ts.map +1 -0
- package/lib/typescript/module/providers/cloudKitBackup.d.ts +65 -0
- package/lib/typescript/module/providers/cloudKitBackup.d.ts.map +1 -0
- package/lib/typescript/module/providers/cloudKitEncrypted.d.ts +37 -0
- package/lib/typescript/module/providers/cloudKitEncrypted.d.ts.map +1 -0
- package/lib/typescript/module/providers/googleDrive.d.ts +35 -0
- package/lib/typescript/module/providers/googleDrive.d.ts.map +1 -0
- package/lib/typescript/module/providers/googleDriveFiles.d.ts +59 -0
- package/lib/typescript/module/providers/googleDriveFiles.d.ts.map +1 -0
- package/lib/typescript/module/providers/icloudDocuments.d.ts +101 -0
- package/lib/typescript/module/providers/icloudDocuments.d.ts.map +1 -0
- package/lib/typescript/module/providers/icloudKV.d.ts +26 -0
- package/lib/typescript/module/providers/icloudKV.d.ts.map +1 -0
- package/lib/typescript/module/providers/icloudKV.web.d.ts +12 -0
- package/lib/typescript/module/providers/icloudKV.web.d.ts.map +1 -0
- package/lib/typescript/module/providers/memory.d.ts +90 -0
- package/lib/typescript/module/providers/memory.d.ts.map +1 -0
- package/lib/typescript/module/resolvers.d.ts +60 -0
- package/lib/typescript/module/resolvers.d.ts.map +1 -0
- package/lib/typescript/module/specs/NativeRNCloudSync.d.ts +133 -0
- package/lib/typescript/module/specs/NativeRNCloudSync.d.ts.map +1 -0
- package/lib/typescript/module/store.d.ts +118 -0
- package/lib/typescript/module/store.d.ts.map +1 -0
- package/lib/typescript/module/testing.d.ts +16 -0
- package/lib/typescript/module/testing.d.ts.map +1 -0
- package/lib/typescript/module/types.d.ts +367 -0
- package/lib/typescript/module/types.d.ts.map +1 -0
- package/package.json +186 -0
- package/plugin/build/index.d.ts +45 -0
- package/plugin/build/index.js +93 -0
- package/react-native-cloud-sync.podspec +48 -0
- package/src/config.ts +94 -0
- package/src/errors.ts +263 -0
- package/src/hooks.ts +337 -0
- package/src/index.ts +113 -0
- package/src/internal/autoFlush.ts +87 -0
- package/src/internal/base64.ts +63 -0
- package/src/internal/bytes.ts +28 -0
- package/src/internal/cloudKitRest.ts +654 -0
- package/src/internal/enums.ts +35 -0
- package/src/internal/googleDriveRest.ts +765 -0
- package/src/internal/keys.ts +160 -0
- package/src/internal/logger.ts +23 -0
- package/src/internal/nativeModule.ts +149 -0
- package/src/internal/timeout.ts +83 -0
- package/src/providers/cloudKit.ts +510 -0
- package/src/providers/cloudKitBackup.ts +124 -0
- package/src/providers/cloudKitEncrypted.ts +175 -0
- package/src/providers/googleDrive.ts +251 -0
- package/src/providers/googleDriveFiles.ts +117 -0
- package/src/providers/icloudDocuments.ts +175 -0
- package/src/providers/icloudKV.ts +206 -0
- package/src/providers/icloudKV.web.ts +41 -0
- package/src/providers/memory.ts +302 -0
- package/src/resolvers.ts +133 -0
- package/src/specs/NativeRNCloudSync.ts +184 -0
- package/src/store.ts +1288 -0
- package/src/testing.ts +22 -0
- package/src/types.ts +426 -0
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.__resetConfig = __resetConfig;
|
|
7
|
+
exports.configureCloudKit = configureCloudKit;
|
|
8
|
+
exports.configureGoogleDrive = configureGoogleDrive;
|
|
9
|
+
exports.configureGoogleDriveFiles = configureGoogleDriveFiles;
|
|
10
|
+
exports.getCloudKitClient = getCloudKitClient;
|
|
11
|
+
exports.getGoogleDriveClient = getGoogleDriveClient;
|
|
12
|
+
exports.getGoogleDriveFileAdapter = getGoogleDriveFileAdapter;
|
|
13
|
+
exports.isCloudKitConfigured = isCloudKitConfigured;
|
|
14
|
+
exports.isGoogleDriveConfigured = isGoogleDriveConfigured;
|
|
15
|
+
exports.isGoogleDriveFilesConfigured = isGoogleDriveFilesConfigured;
|
|
16
|
+
var _cloudKitRest = require("./internal/cloudKitRest.js");
|
|
17
|
+
var _googleDriveRest = require("./internal/googleDriveRest.js");
|
|
18
|
+
var _errors = require("./errors.js");
|
|
19
|
+
let cloudKitClient = null;
|
|
20
|
+
let driveClient = null;
|
|
21
|
+
let driveFileAdapter = null;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Supplies the credentials the CloudKit REST path needs.
|
|
25
|
+
*
|
|
26
|
+
* Only required on Android and web. On iOS the native provider authenticates
|
|
27
|
+
* implicitly through the device's signed-in iCloud account and needs none of
|
|
28
|
+
* this.
|
|
29
|
+
*/
|
|
30
|
+
function configureCloudKit(config) {
|
|
31
|
+
cloudKitClient = new _cloudKitRest.CloudKitRestClient(config);
|
|
32
|
+
}
|
|
33
|
+
function getCloudKitClient() {
|
|
34
|
+
if (cloudKitClient == null) throw new _errors.CloudSyncError(_errors.ErrorCode.CONTAINER_MISCONFIGURED, '[RNCloudSync] CloudKit is not configured on this platform. Call configureCloudKit({ ' + 'containerIdentifier, apiToken, environment, getAuthToken }) before using the cloudKit ' + 'provider on Android or web.', {
|
|
35
|
+
provider: 'cloudKit'
|
|
36
|
+
});
|
|
37
|
+
return cloudKitClient;
|
|
38
|
+
}
|
|
39
|
+
function isCloudKitConfigured() {
|
|
40
|
+
return cloudKitClient != null;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/** Supplies the OAuth token the Drive provider uses. Required on every platform. */
|
|
44
|
+
function configureGoogleDrive(config) {
|
|
45
|
+
driveClient = new _googleDriveRest.GoogleDriveClient(config);
|
|
46
|
+
}
|
|
47
|
+
function getGoogleDriveClient() {
|
|
48
|
+
if (driveClient == null) throw new _errors.CloudSyncError(_errors.ErrorCode.CONTAINER_MISCONFIGURED, '[RNCloudSync] Google Drive is not configured. Call configureGoogleDrive({ ' + 'getAccessToken }) before using the googleDrive provider.', {
|
|
49
|
+
provider: 'googleDrive'
|
|
50
|
+
});
|
|
51
|
+
return driveClient;
|
|
52
|
+
}
|
|
53
|
+
function isGoogleDriveConfigured() {
|
|
54
|
+
return driveClient != null;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Supplies local file I/O for `googleDriveFiles` - large binaries that go
|
|
59
|
+
* through Drive's resumable upload/download rather than `googleDrive`'s
|
|
60
|
+
* whole-value-as-a-string path.
|
|
61
|
+
*
|
|
62
|
+
* Separate from `configureGoogleDrive` because most apps never touch a file
|
|
63
|
+
* that large and shouldn't need to think about filesystem access to use
|
|
64
|
+
* `googleDrive`/the store facade. Only required for `googleDriveFiles`.
|
|
65
|
+
*/
|
|
66
|
+
function configureGoogleDriveFiles(adapter) {
|
|
67
|
+
driveFileAdapter = adapter;
|
|
68
|
+
}
|
|
69
|
+
function getGoogleDriveFileAdapter() {
|
|
70
|
+
if (driveFileAdapter == null) throw new _errors.CloudSyncError(_errors.ErrorCode.CONTAINER_MISCONFIGURED, '[RNCloudSync] googleDriveFiles needs a file adapter. Call configureGoogleDriveFiles({ ' + 'statSize, readChunk, writeChunk, appendChunk }) before saving or fetching a file.', {
|
|
71
|
+
provider: 'googleDrive'
|
|
72
|
+
});
|
|
73
|
+
return driveFileAdapter;
|
|
74
|
+
}
|
|
75
|
+
function isGoogleDriveFilesConfigured() {
|
|
76
|
+
return driveFileAdapter != null;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/** Test seam - drops all configured clients. */
|
|
80
|
+
function __resetConfig() {
|
|
81
|
+
cloudKitClient = null;
|
|
82
|
+
driveClient = null;
|
|
83
|
+
driveFileAdapter = null;
|
|
84
|
+
}
|
|
85
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_cloudKitRest","require","_googleDriveRest","_errors","cloudKitClient","driveClient","driveFileAdapter","configureCloudKit","config","CloudKitRestClient","getCloudKitClient","CloudSyncError","ErrorCode","CONTAINER_MISCONFIGURED","provider","isCloudKitConfigured","configureGoogleDrive","GoogleDriveClient","getGoogleDriveClient","isGoogleDriveConfigured","configureGoogleDriveFiles","adapter","getGoogleDriveFileAdapter","isGoogleDriveFilesConfigured","__resetConfig"],"sourceRoot":"../../src","sources":["config.ts"],"mappings":";;;;;;;;;;;;;;;AACA,IAAAA,aAAA,GAAAC,OAAA;AAEA,IAAAC,gBAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AAEA,IAAIG,cAAyC,GAAG,IAAI;AACpD,IAAIC,WAAqC,GAAG,IAAI;AAChD,IAAIC,gBAA+C,GAAG,IAAI;;AAE1D;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,iBAAiBA,CAACC,MAA0B,EAAQ;EAClEJ,cAAc,GAAG,IAAIK,gCAAkB,CAACD,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,WAAW,GAAG,IAAI;EAClBC,gBAAgB,GAAG,IAAI;AACzB","ignoreList":[]}
|
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.ErrorCode = exports.CloudSyncError = void 0;
|
|
7
|
+
exports.cancelled = cancelled;
|
|
8
|
+
exports.isCancelled = isCancelled;
|
|
9
|
+
exports.isCloudSyncError = isCloudSyncError;
|
|
10
|
+
exports.isRetryable = isRetryable;
|
|
11
|
+
exports.normalizeError = normalizeError;
|
|
12
|
+
exports.requiresUserAction = requiresUserAction;
|
|
13
|
+
exports.timedOut = timedOut;
|
|
14
|
+
exports.unsupportedPlatform = unsupportedPlatform;
|
|
15
|
+
/**
|
|
16
|
+
* The error vocabulary shared verbatim by iOS (Swift), Android (Kotlin), the
|
|
17
|
+
* REST clients and the web build.
|
|
18
|
+
*
|
|
19
|
+
* Why this exists at all: every React Native cloud library surveyed before this
|
|
20
|
+
* one collapses distinct failures into `null` or into a bare `false`, and two of
|
|
21
|
+
* them go further and report a *failed write as a success*. That is not a
|
|
22
|
+
* hypothetical - it is the single most repeated defect in this problem space:
|
|
23
|
+
*
|
|
24
|
+
* - jacobp100/react-native-cloudkit-storage's `setItem` checks the enclosing
|
|
25
|
+
* `error` variable instead of the operation's own `operationError`, so a
|
|
26
|
+
* quota-exceeded or not-signed-in write resolves successfully.
|
|
27
|
+
* - cryptoc's in-app CloudKit module discarded the `Result` handed to
|
|
28
|
+
* `modifyRecordsResultBlock` entirely, with the same outcome.
|
|
29
|
+
*
|
|
30
|
+
* The rule that prevents both, and that every provider in this package obeys:
|
|
31
|
+
*
|
|
32
|
+
* `null` is returned for exactly one condition - the key genuinely does not
|
|
33
|
+
* exist. Every other outcome rejects with a `CloudSyncError` carrying a
|
|
34
|
+
* stable `code`.
|
|
35
|
+
*/
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Stable, cross-platform failure codes.
|
|
39
|
+
*
|
|
40
|
+
* These strings are duplicated in `ios/CloudSyncError.swift` - the only other
|
|
41
|
+
* place that raises them, since Android and web reach CloudKit and Drive over
|
|
42
|
+
* REST from this same TypeScript. They are part of the public API: apps branch
|
|
43
|
+
* on them, so treat a change here as a breaking change.
|
|
44
|
+
*/
|
|
45
|
+
const ErrorCode = exports.ErrorCode = {
|
|
46
|
+
/** No iCloud/Drive account is signed in on the device. */
|
|
47
|
+
NOT_SIGNED_IN: 'ERR_NOT_SIGNED_IN',
|
|
48
|
+
/** An account exists but is restricted (parental controls, MDM). */
|
|
49
|
+
ACCOUNT_RESTRICTED: 'ERR_ACCOUNT_RESTRICTED',
|
|
50
|
+
/** CloudKit reported `.temporarilyUnavailable` - retry later. */
|
|
51
|
+
ACCOUNT_UNAVAILABLE: 'ERR_ACCOUNT_UNAVAILABLE',
|
|
52
|
+
/** CloudKit could not determine account status. Not the same as signed out. */
|
|
53
|
+
ACCOUNT_UNDETERMINED: 'ERR_ACCOUNT_UNDETERMINED',
|
|
54
|
+
/** A previously valid credential expired. On Android CloudKit this is routine: */
|
|
55
|
+
/** a `ckWebAuthToken` lives 30 minutes, or 2 weeks if the user ticked */
|
|
56
|
+
/** "Keep me signed in". There is no documented refresh - re-auth is required. */
|
|
57
|
+
AUTH_EXPIRED: 'ERR_AUTH_EXPIRED',
|
|
58
|
+
/** Device is offline, or the request could not reach the server. */
|
|
59
|
+
NETWORK_UNAVAILABLE: 'ERR_NETWORK_UNAVAILABLE',
|
|
60
|
+
/** The user's iCloud/Drive storage is full. */
|
|
61
|
+
QUOTA_EXCEEDED: 'ERR_QUOTA_EXCEEDED',
|
|
62
|
+
/** Server asked us to back off. Carries `retryAfterMs` when the server said so. */
|
|
63
|
+
RATE_LIMITED: 'ERR_RATE_LIMITED',
|
|
64
|
+
/** Value exceeds the backing store's limit. Carries `limitBytes`/`actualBytes`. */
|
|
65
|
+
PAYLOAD_TOO_LARGE: 'ERR_PAYLOAD_TOO_LARGE',
|
|
66
|
+
/**
|
|
67
|
+
* The key cannot round-trip through the configured providers - illegal
|
|
68
|
+
* characters, too long, or a reserved prefix. Raised before the request, so
|
|
69
|
+
* it never reaches the server as a confusing `BAD_REQUEST`.
|
|
70
|
+
*/
|
|
71
|
+
INVALID_KEY: 'ERR_INVALID_KEY',
|
|
72
|
+
/** The operation ran longer than the configured timeout. */
|
|
73
|
+
TIMEOUT: 'ERR_TIMEOUT',
|
|
74
|
+
/** A concurrent write won. Carries `serverValue` so the app can merge. */
|
|
75
|
+
CONFLICT: 'ERR_CONFLICT',
|
|
76
|
+
/** Entitlements, container identifier or API token are missing or wrong. */
|
|
77
|
+
CONTAINER_MISCONFIGURED: 'ERR_CONTAINER_MISCONFIGURED',
|
|
78
|
+
/** This provider has no implementation on the current platform. */
|
|
79
|
+
UNSUPPORTED_PLATFORM: 'ERR_UNSUPPORTED_PLATFORM',
|
|
80
|
+
/** The operation was cancelled by the caller. */
|
|
81
|
+
CANCELLED: 'ERR_CANCELLED',
|
|
82
|
+
/** Anything the native layer could not classify. `cause` holds the original. */
|
|
83
|
+
UNKNOWN: 'ERR_UNKNOWN'
|
|
84
|
+
};
|
|
85
|
+
const ALL_CODES = Object.values(ErrorCode);
|
|
86
|
+
/**
|
|
87
|
+
* The single error type every operation in this package rejects with.
|
|
88
|
+
*
|
|
89
|
+
* `instanceof` is deliberately not the recommended check - a rejected promise
|
|
90
|
+
* crossing the React Native bridge arrives as a plain object on some paths, so
|
|
91
|
+
* {@link isCloudSyncError} tests the shape instead.
|
|
92
|
+
*/
|
|
93
|
+
class CloudSyncError extends Error {
|
|
94
|
+
constructor(code, message, info = {}) {
|
|
95
|
+
super(message);
|
|
96
|
+
this.name = 'CloudSyncError';
|
|
97
|
+
this.code = code;
|
|
98
|
+
this.retryAfterMs = info.retryAfterMs;
|
|
99
|
+
this.limitBytes = info.limitBytes;
|
|
100
|
+
this.actualBytes = info.actualBytes;
|
|
101
|
+
this.serverValue = info.serverValue;
|
|
102
|
+
this.provider = info.provider;
|
|
103
|
+
this.serverErrorCode = info.serverErrorCode;
|
|
104
|
+
this.cause = info.cause;
|
|
105
|
+
|
|
106
|
+
// Restore the prototype chain: TypeScript's ES5 downlevel of `extends Error`
|
|
107
|
+
// otherwise leaves `instanceof CloudSyncError` false.
|
|
108
|
+
Object.setPrototypeOf(this, CloudSyncError.prototype);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/** Narrowing guard that works on both real instances and bridged plain objects. */
|
|
113
|
+
exports.CloudSyncError = CloudSyncError;
|
|
114
|
+
function isCloudSyncError(e) {
|
|
115
|
+
if (e == null || typeof e !== 'object') return false;
|
|
116
|
+
const code = e.code;
|
|
117
|
+
return typeof code === 'string' && ALL_CODES.includes(code);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* True when retrying the same call later could plausibly succeed.
|
|
122
|
+
*
|
|
123
|
+
* TIMEOUT is in this set because running out of time says nothing about whether
|
|
124
|
+
* the operation is possible - only that this attempt took too long.
|
|
125
|
+
*/
|
|
126
|
+
function isRetryable(e) {
|
|
127
|
+
if (!isCloudSyncError(e)) return false;
|
|
128
|
+
switch (e.code) {
|
|
129
|
+
case ErrorCode.NETWORK_UNAVAILABLE:
|
|
130
|
+
case ErrorCode.RATE_LIMITED:
|
|
131
|
+
case ErrorCode.ACCOUNT_UNAVAILABLE:
|
|
132
|
+
case ErrorCode.ACCOUNT_UNDETERMINED:
|
|
133
|
+
case ErrorCode.TIMEOUT:
|
|
134
|
+
return true;
|
|
135
|
+
default:
|
|
136
|
+
return false;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/** True when the user must take an action (sign in, free up space) to proceed. */
|
|
141
|
+
function requiresUserAction(e) {
|
|
142
|
+
if (!isCloudSyncError(e)) return false;
|
|
143
|
+
switch (e.code) {
|
|
144
|
+
case ErrorCode.NOT_SIGNED_IN:
|
|
145
|
+
case ErrorCode.AUTH_EXPIRED:
|
|
146
|
+
case ErrorCode.QUOTA_EXCEEDED:
|
|
147
|
+
case ErrorCode.ACCOUNT_RESTRICTED:
|
|
148
|
+
return true;
|
|
149
|
+
default:
|
|
150
|
+
return false;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* Normalises whatever the native layer rejected with into a `CloudSyncError`.
|
|
156
|
+
*
|
|
157
|
+
* React Native's bridge turns `reject(code, message, nativeError)` into an Error
|
|
158
|
+
* whose `code` is the string we chose natively, so the common path is a simple
|
|
159
|
+
* re-wrap. Anything unrecognised becomes {@link ErrorCode.UNKNOWN} rather than
|
|
160
|
+
* being swallowed.
|
|
161
|
+
*/
|
|
162
|
+
function normalizeError(e, provider) {
|
|
163
|
+
if (e instanceof CloudSyncError) return e;
|
|
164
|
+
if (isCloudSyncError(e)) {
|
|
165
|
+
const raw = e;
|
|
166
|
+
const nested = nestedInfo(raw.userInfo);
|
|
167
|
+
return new CloudSyncError(e.code, raw.message ?? e.code, {
|
|
168
|
+
retryAfterMs: numeric(raw.retryAfterMs ?? nested.retryAfterMs),
|
|
169
|
+
limitBytes: numeric(raw.limitBytes ?? nested.limitBytes),
|
|
170
|
+
actualBytes: numeric(raw.actualBytes ?? nested.actualBytes),
|
|
171
|
+
serverValue: raw.serverValue ?? nested.serverValue,
|
|
172
|
+
provider: raw.provider ?? nested.provider ?? provider,
|
|
173
|
+
serverErrorCode: raw.serverErrorCode ?? nested.serverErrorCode,
|
|
174
|
+
cause: e
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
const message = e instanceof Error ? e.message : String(e);
|
|
178
|
+
return new CloudSyncError(ErrorCode.UNKNOWN, message, {
|
|
179
|
+
provider,
|
|
180
|
+
cause: e
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* The extra fields a native rejection carries, which live one level down.
|
|
186
|
+
*
|
|
187
|
+
* React Native builds the JS error from `reject(code, message, nsError)` with
|
|
188
|
+
* `Object.assign(new Error(message), errorData)`, and `errorData` keeps the
|
|
189
|
+
* `NSError`'s dictionary intact under a nested `userInfo` key rather than
|
|
190
|
+
* spreading it. So everything `CloudSyncError.asNSError` attaches on iOS -
|
|
191
|
+
* `retryAfterMs`, `limitBytes`, `actualBytes`, `serverValue` - arrives as
|
|
192
|
+
* `e.userInfo.limitBytes`, never as `e.limitBytes`.
|
|
193
|
+
*
|
|
194
|
+
* Reading only the top level is why CloudKit's `retryAfter` hint never reached
|
|
195
|
+
* the outbox's backoff, and why a CONFLICT's `serverValue` - documented as the
|
|
196
|
+
* thing that lets an app merge - was always undefined on iOS.
|
|
197
|
+
*/
|
|
198
|
+
function nestedInfo(userInfo) {
|
|
199
|
+
if (userInfo == null || typeof userInfo !== 'object') return {};
|
|
200
|
+
return userInfo;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* The bridge stringifies numbers on some paths (`userInfo` dictionaries on iOS
|
|
205
|
+
* arrive as strings), so coerce rather than trusting the declared type.
|
|
206
|
+
*/
|
|
207
|
+
function numeric(v) {
|
|
208
|
+
if (typeof v === 'number' && Number.isFinite(v)) return v;
|
|
209
|
+
if (typeof v === 'string') {
|
|
210
|
+
const n = Number(v);
|
|
211
|
+
if (Number.isFinite(n)) return n;
|
|
212
|
+
}
|
|
213
|
+
return undefined;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* True when the caller asked for this - a cancelled operation is not a fault to
|
|
218
|
+
* report, and a UI that shows an error toast for one is wrong.
|
|
219
|
+
*/
|
|
220
|
+
function isCancelled(e) {
|
|
221
|
+
return isCloudSyncError(e) && e.code === ErrorCode.CANCELLED;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
/** The rejection an aborted operation produces. */
|
|
225
|
+
function cancelled(provider, detail = 'The operation was cancelled.') {
|
|
226
|
+
return new CloudSyncError(ErrorCode.CANCELLED, `[RNCloudSync] ${detail}`, {
|
|
227
|
+
provider
|
|
228
|
+
});
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
/** The rejection a timed-out operation produces. */
|
|
232
|
+
function timedOut(ms, provider) {
|
|
233
|
+
return new CloudSyncError(ErrorCode.TIMEOUT, `[RNCloudSync] The request did not complete within ${ms}ms.`, {
|
|
234
|
+
provider
|
|
235
|
+
});
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
/** Convenience constructor for the platform-capability guards. */
|
|
239
|
+
function unsupportedPlatform(provider, detail) {
|
|
240
|
+
return new CloudSyncError(ErrorCode.UNSUPPORTED_PLATFORM, `[RNCloudSync] ${provider} is not available on this platform: ${detail}`, {
|
|
241
|
+
provider
|
|
242
|
+
});
|
|
243
|
+
}
|
|
244
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["ErrorCode","exports","NOT_SIGNED_IN","ACCOUNT_RESTRICTED","ACCOUNT_UNAVAILABLE","ACCOUNT_UNDETERMINED","AUTH_EXPIRED","NETWORK_UNAVAILABLE","QUOTA_EXCEEDED","RATE_LIMITED","PAYLOAD_TOO_LARGE","INVALID_KEY","TIMEOUT","CONFLICT","CONTAINER_MISCONFIGURED","UNSUPPORTED_PLATFORM","CANCELLED","UNKNOWN","ALL_CODES","Object","values","CloudSyncError","Error","constructor","code","message","info","name","retryAfterMs","limitBytes","actualBytes","serverValue","provider","serverErrorCode","cause","setPrototypeOf","prototype","isCloudSyncError","e","includes","isRetryable","requiresUserAction","normalizeError","raw","nested","nestedInfo","userInfo","numeric","String","v","Number","isFinite","n","undefined","isCancelled","cancelled","detail","timedOut","ms","unsupportedPlatform"],"sourceRoot":"../../src","sources":["errors.ts"],"mappings":";;;;;;;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;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oreList":[]}
|
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useAccountStatus = useAccountStatus;
|
|
7
|
+
exports.useCloudItem = useCloudItem;
|
|
8
|
+
exports.usePendingWrites = usePendingWrites;
|
|
9
|
+
exports.useQuota = useQuota;
|
|
10
|
+
exports.useRemoteChange = useRemoteChange;
|
|
11
|
+
var _react = require("react");
|
|
12
|
+
var _errors = require("./errors.js");
|
|
13
|
+
/**
|
|
14
|
+
* React bindings.
|
|
15
|
+
*
|
|
16
|
+
* A separate entry point (`react-native-cloud-sync/hooks`) so the main one
|
|
17
|
+
* stays free of a React import - the store is usable from a saga, a background
|
|
18
|
+
* task or a plain module, and none of those should pull in a renderer.
|
|
19
|
+
*
|
|
20
|
+
* These exist because every app was writing the same three of them, and each
|
|
21
|
+
* one has the same two bugs: a response that arrives after the key changed
|
|
22
|
+
* overwrites the newer one, and a `setState` after unmount. Both are handled
|
|
23
|
+
* here once.
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Binds one key to component state.
|
|
28
|
+
*
|
|
29
|
+
* ```tsx
|
|
30
|
+
* const { value, setValue, loading } = useCloudItem<Settings>(store, 'settings')
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
function useCloudItem(store, key, options = {}) {
|
|
34
|
+
const {
|
|
35
|
+
initialValue = null,
|
|
36
|
+
parse = JSON.parse,
|
|
37
|
+
serialize = JSON.stringify,
|
|
38
|
+
watch = true
|
|
39
|
+
} = options;
|
|
40
|
+
const [value, setLocalValue] = (0, _react.useState)(initialValue);
|
|
41
|
+
const [loading, setLoading] = (0, _react.useState)(true);
|
|
42
|
+
const [error, setError] = (0, _react.useState)(null);
|
|
43
|
+
const mounted = (0, _react.useRef)(true);
|
|
44
|
+
(0, _react.useEffect)(() => {
|
|
45
|
+
mounted.current = true;
|
|
46
|
+
return () => {
|
|
47
|
+
mounted.current = false;
|
|
48
|
+
};
|
|
49
|
+
}, []);
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Increments on every read. A response whose ticket is stale - because the
|
|
53
|
+
* key changed, or a refresh overtook it - is dropped instead of being written
|
|
54
|
+
* into state, which is how these hooks usually end up showing another key's
|
|
55
|
+
* value.
|
|
56
|
+
*/
|
|
57
|
+
const ticket = (0, _react.useRef)(0);
|
|
58
|
+
|
|
59
|
+
// Held in a ref so `read` does not change identity every render and restart
|
|
60
|
+
// the effect below on each one.
|
|
61
|
+
const parseRef = (0, _react.useRef)(parse);
|
|
62
|
+
parseRef.current = parse;
|
|
63
|
+
const read = (0, _react.useCallback)(async () => {
|
|
64
|
+
const mine = ticket.current + 1;
|
|
65
|
+
ticket.current = mine;
|
|
66
|
+
setLoading(true);
|
|
67
|
+
try {
|
|
68
|
+
const raw = await store.getItem(key);
|
|
69
|
+
if (!mounted.current || ticket.current !== mine) return;
|
|
70
|
+
setLocalValue(raw == null ? null : parseRef.current(raw));
|
|
71
|
+
setError(null);
|
|
72
|
+
} catch (e) {
|
|
73
|
+
if (!mounted.current || ticket.current !== mine) return;
|
|
74
|
+
// The value is deliberately left as-is rather than cleared: a failed read
|
|
75
|
+
// is not evidence the key is gone, and blanking the screen on a network
|
|
76
|
+
// blip is worse than showing what was last known alongside the error.
|
|
77
|
+
setError((0, _errors.normalizeError)(e));
|
|
78
|
+
} finally {
|
|
79
|
+
if (mounted.current && ticket.current === mine) setLoading(false);
|
|
80
|
+
}
|
|
81
|
+
}, [store, key]);
|
|
82
|
+
(0, _react.useEffect)(() => {
|
|
83
|
+
void read();
|
|
84
|
+
}, [read]);
|
|
85
|
+
(0, _react.useEffect)(() => {
|
|
86
|
+
if (!watch) return;
|
|
87
|
+
return store.onRemoteChange(e => {
|
|
88
|
+
// An empty `keys` list means "something changed but the provider could
|
|
89
|
+
// not say what" - an account or quota event. Re-read rather than assume
|
|
90
|
+
// it was not us.
|
|
91
|
+
if (e.keys.length > 0 && !e.keys.includes(key)) return;
|
|
92
|
+
void read();
|
|
93
|
+
});
|
|
94
|
+
}, [store, key, watch, read]);
|
|
95
|
+
const setValue = (0, _react.useCallback)(async next => {
|
|
96
|
+
// Optimistic: the store queues retryable failures, so the write usually
|
|
97
|
+
// lands eventually even when this call rejects. Reverting on error would
|
|
98
|
+
// discard a value the outbox is still going to deliver.
|
|
99
|
+
setLocalValue(next);
|
|
100
|
+
// Invalidate any read in flight, so its older answer cannot land on top.
|
|
101
|
+
ticket.current += 1;
|
|
102
|
+
try {
|
|
103
|
+
await store.setItem(key, serialize(next));
|
|
104
|
+
if (mounted.current) setError(null);
|
|
105
|
+
} catch (e) {
|
|
106
|
+
if (mounted.current) setError((0, _errors.normalizeError)(e));
|
|
107
|
+
throw e;
|
|
108
|
+
}
|
|
109
|
+
}, [store, key, serialize]);
|
|
110
|
+
const remove = (0, _react.useCallback)(async () => {
|
|
111
|
+
setLocalValue(null);
|
|
112
|
+
ticket.current += 1;
|
|
113
|
+
try {
|
|
114
|
+
await store.removeItem(key);
|
|
115
|
+
if (mounted.current) setError(null);
|
|
116
|
+
} catch (e) {
|
|
117
|
+
if (mounted.current) setError((0, _errors.normalizeError)(e));
|
|
118
|
+
throw e;
|
|
119
|
+
}
|
|
120
|
+
}, [store, key]);
|
|
121
|
+
return {
|
|
122
|
+
value,
|
|
123
|
+
loading,
|
|
124
|
+
error,
|
|
125
|
+
setValue,
|
|
126
|
+
remove,
|
|
127
|
+
refresh: read
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Tracks a provider's account state, including the identity-switch event.
|
|
132
|
+
*
|
|
133
|
+
* ```tsx
|
|
134
|
+
* const { status, identityChanged } = useAccountStatus(icloudKV)
|
|
135
|
+
* if (status === 'noAccount') return <SignInPrompt />
|
|
136
|
+
* ```
|
|
137
|
+
*/
|
|
138
|
+
function useAccountStatus(provider) {
|
|
139
|
+
const [status, setStatus] = (0, _react.useState)(null);
|
|
140
|
+
const [identityChanged, setIdentityChanged] = (0, _react.useState)(false);
|
|
141
|
+
const [error, setError] = (0, _react.useState)(null);
|
|
142
|
+
const mounted = (0, _react.useRef)(true);
|
|
143
|
+
(0, _react.useEffect)(() => {
|
|
144
|
+
mounted.current = true;
|
|
145
|
+
return () => {
|
|
146
|
+
mounted.current = false;
|
|
147
|
+
};
|
|
148
|
+
}, []);
|
|
149
|
+
const refresh = (0, _react.useCallback)(async () => {
|
|
150
|
+
try {
|
|
151
|
+
const next = await provider.getAccountStatus();
|
|
152
|
+
if (!mounted.current) return;
|
|
153
|
+
setStatus(next);
|
|
154
|
+
setError(null);
|
|
155
|
+
} catch (e) {
|
|
156
|
+
if (mounted.current) setError((0, _errors.normalizeError)(e));
|
|
157
|
+
}
|
|
158
|
+
}, [provider]);
|
|
159
|
+
(0, _react.useEffect)(() => {
|
|
160
|
+
void refresh();
|
|
161
|
+
}, [refresh]);
|
|
162
|
+
(0, _react.useEffect)(() => {
|
|
163
|
+
if (provider.onAccountChange == null) return;
|
|
164
|
+
return provider.onAccountChange(e => {
|
|
165
|
+
setStatus(e.status);
|
|
166
|
+
if (e.identityChanged) setIdentityChanged(true);
|
|
167
|
+
});
|
|
168
|
+
}, [provider]);
|
|
169
|
+
return {
|
|
170
|
+
status,
|
|
171
|
+
identityChanged,
|
|
172
|
+
error,
|
|
173
|
+
refresh
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Drives a "pending sync" indicator.
|
|
178
|
+
*
|
|
179
|
+
* `pendingWrites()` is a synchronous read of a small JSON blob, so polling it
|
|
180
|
+
* is cheap - and there is no event to subscribe to, because entries are added
|
|
181
|
+
* from whichever call site failed rather than from one place that could emit.
|
|
182
|
+
*/
|
|
183
|
+
function usePendingWrites(store, pollIntervalMs = 2000) {
|
|
184
|
+
const [pending, setPending] = (0, _react.useState)(() => store.pendingWrites());
|
|
185
|
+
const sync = (0, _react.useCallback)(() => {
|
|
186
|
+
setPending(store.pendingWrites());
|
|
187
|
+
}, [store]);
|
|
188
|
+
(0, _react.useEffect)(() => {
|
|
189
|
+
sync();
|
|
190
|
+
if (pollIntervalMs <= 0) return;
|
|
191
|
+
const timer = setInterval(sync, pollIntervalMs);
|
|
192
|
+
return () => clearInterval(timer);
|
|
193
|
+
}, [sync, pollIntervalMs]);
|
|
194
|
+
const flush = (0, _react.useCallback)(async () => {
|
|
195
|
+
try {
|
|
196
|
+
await store.flushOutbox();
|
|
197
|
+
} finally {
|
|
198
|
+
// Refresh either way: a flush that partially failed still changed the
|
|
199
|
+
// queue, and the indicator should show what is actually left.
|
|
200
|
+
sync();
|
|
201
|
+
}
|
|
202
|
+
}, [store, sync]);
|
|
203
|
+
const discard = (0, _react.useCallback)(filter => {
|
|
204
|
+
store.discardPendingWrites(filter);
|
|
205
|
+
sync();
|
|
206
|
+
}, [store, sync]);
|
|
207
|
+
return {
|
|
208
|
+
pending,
|
|
209
|
+
flush,
|
|
210
|
+
discard
|
|
211
|
+
};
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* Subscribes to remote-change events for the life of the component.
|
|
216
|
+
*
|
|
217
|
+
* The listener is held in a ref, so passing an inline arrow function does not
|
|
218
|
+
* tear down and rebuild the subscription on every render.
|
|
219
|
+
*/
|
|
220
|
+
function useRemoteChange(store, listener) {
|
|
221
|
+
const ref = (0, _react.useRef)(listener);
|
|
222
|
+
ref.current = listener;
|
|
223
|
+
(0, _react.useEffect)(() => store.onRemoteChange(e => ref.current(e)), [store]);
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
/**
|
|
227
|
+
* Per-provider storage usage, refreshed on demand.
|
|
228
|
+
*
|
|
229
|
+
* Not polled: `getQuota` is a network round trip per provider, and a number
|
|
230
|
+
* that moves this slowly does not need watching.
|
|
231
|
+
*/
|
|
232
|
+
function useQuota(store) {
|
|
233
|
+
const [quota, setQuota] = (0, _react.useState)([]);
|
|
234
|
+
const [loading, setLoading] = (0, _react.useState)(false);
|
|
235
|
+
const mounted = (0, _react.useRef)(true);
|
|
236
|
+
(0, _react.useEffect)(() => {
|
|
237
|
+
mounted.current = true;
|
|
238
|
+
return () => {
|
|
239
|
+
mounted.current = false;
|
|
240
|
+
};
|
|
241
|
+
}, []);
|
|
242
|
+
const refresh = (0, _react.useCallback)(async () => {
|
|
243
|
+
setLoading(true);
|
|
244
|
+
try {
|
|
245
|
+
const next = await store.getQuota();
|
|
246
|
+
if (mounted.current) setQuota(next);
|
|
247
|
+
} finally {
|
|
248
|
+
if (mounted.current) setLoading(false);
|
|
249
|
+
}
|
|
250
|
+
}, [store]);
|
|
251
|
+
return (0, _react.useMemo)(() => ({
|
|
252
|
+
quota,
|
|
253
|
+
loading,
|
|
254
|
+
refresh
|
|
255
|
+
}), [quota, loading, refresh]);
|
|
256
|
+
}
|
|
257
|
+
//# sourceMappingURL=hooks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_react","require","_errors","useCloudItem","store","key","options","initialValue","parse","JSON","serialize","stringify","watch","value","setLocalValue","useState","loading","setLoading","error","setError","mounted","useRef","useEffect","current","ticket","parseRef","read","useCallback","mine","raw","getItem","e","normalizeError","onRemoteChange","keys","length","includes","setValue","next","setItem","remove","removeItem","refresh","useAccountStatus","provider","status","setStatus","identityChanged","setIdentityChanged","getAccountStatus","onAccountChange","usePendingWrites","pollIntervalMs","pending","setPending","pendingWrites","sync","timer","setInterval","clearInterval","flush","flushOutbox","discard","filter","discardPendingWrites","useRemoteChange","listener","ref","useQuota","quota","setQuota","getQuota","useMemo"],"sourceRoot":"../../src","sources":["hooks.ts"],"mappings":";;;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAGA,IAAAC,OAAA,GAAAD,OAAA;AASA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAmCA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,S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