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,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Test utilities.
|
|
3
|
+
*
|
|
4
|
+
* Deliberately a real package entry point:
|
|
5
|
+
*
|
|
6
|
+
* import { createMemoryProvider } from 'react-native-cloud-sync/testing'
|
|
7
|
+
*
|
|
8
|
+
* expo-cloudkit ships a comparable mock factory but never exports it from the
|
|
9
|
+
* package (its own source says "Import them directly from 'expo-cloudkit/src/testing'
|
|
10
|
+
* in test environments only") and never mentions it in the README - so in
|
|
11
|
+
* practice nobody finds it. An untested testing helper is not a testing story.
|
|
12
|
+
*/
|
|
13
|
+
export { createMemoryProvider, type Fault, type FaultOp, type MemoryProvider, type MemoryProviderOptions } from './providers/memory.js';
|
|
14
|
+
export { ErrorCode, CloudSyncError, isCloudSyncError } from './errors.js';
|
|
15
|
+
export type { AccountStatus, ChangeReason, CloudProvider } from './types.js';
|
|
16
|
+
//# sourceMappingURL=testing.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"testing.d.ts","sourceRoot":"","sources":["../../../src/testing.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EACL,oBAAoB,EACpB,KAAK,KAAK,EACV,KAAK,OAAO,EACZ,KAAK,cAAc,EACnB,KAAK,qBAAqB,EAC3B,MAAM,uBAAoB,CAAA;AAE3B,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,aAAU,CAAA;AACtE,YAAY,EAAE,aAAa,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,YAAS,CAAA"}
|
|
@@ -0,0 +1,367 @@
|
|
|
1
|
+
import type { CloudSyncError } from './errors.js';
|
|
2
|
+
import type { AutoFlushConfig } from './internal/autoFlush.js';
|
|
3
|
+
/**
|
|
4
|
+
* Full account state.
|
|
5
|
+
*
|
|
6
|
+
* Deliberately not a boolean. `react-native-icloud-kit` exposes
|
|
7
|
+
* `isAvailable(): Bool`, which flattens CloudKit's five `CKAccountStatus`
|
|
8
|
+
* values into one bit - so an app cannot tell "signed out" (ask the user to
|
|
9
|
+
* sign in) from "temporarily unavailable" (retry silently) from "could not
|
|
10
|
+
* determine" (do nothing yet). Those three demand different product behaviour.
|
|
11
|
+
*/
|
|
12
|
+
export type AccountStatus = 'available' | 'noAccount' | 'restricted' | 'temporarilyUnavailable' | 'couldNotDetermine';
|
|
13
|
+
/** Why a remote-change event fired. Mirrors NSUbiquitousKeyValueStore's reasons. */
|
|
14
|
+
export type ChangeReason = 'serverChange' | 'initialSync' | 'quotaViolation' | 'accountChange' | 'unknown';
|
|
15
|
+
export interface RemoteChangeEvent {
|
|
16
|
+
/** Keys whose values changed. May be empty for `accountChange`/`quotaViolation`. */
|
|
17
|
+
keys: string[];
|
|
18
|
+
reason: ChangeReason;
|
|
19
|
+
provider: ProviderName;
|
|
20
|
+
}
|
|
21
|
+
export interface AccountChangeEvent {
|
|
22
|
+
status: AccountStatus;
|
|
23
|
+
/**
|
|
24
|
+
* True when the signed-in identity itself changed (a different Apple ID), as
|
|
25
|
+
* opposed to the same account merely becoming available or unavailable.
|
|
26
|
+
*
|
|
27
|
+
* This is the event nobody handles. MagisteriaApp stores an anonymous user id
|
|
28
|
+
* in iCloud and never observes `NSUbiquityIdentityDidChange`, so switching
|
|
29
|
+
* Apple ID silently keeps the previous user's identity - its own TODO records
|
|
30
|
+
* this as "sign out does not always give you a clean guest". Apps should treat
|
|
31
|
+
* `identityChanged: true` as "drop all cached user-scoped state".
|
|
32
|
+
*/
|
|
33
|
+
identityChanged: boolean;
|
|
34
|
+
provider: ProviderName;
|
|
35
|
+
}
|
|
36
|
+
export interface AssetProgressEvent {
|
|
37
|
+
recordName: string;
|
|
38
|
+
fieldName: string;
|
|
39
|
+
bytesTransferred: number;
|
|
40
|
+
bytesTotal: number;
|
|
41
|
+
}
|
|
42
|
+
/** The providers this package ships. */
|
|
43
|
+
export type { AutoFlushConfig };
|
|
44
|
+
export type BuiltInProviderName = 'icloudKV' | 'cloudKit' | 'cloudKitEncrypted' | 'googleDrive' | 'memory';
|
|
45
|
+
/**
|
|
46
|
+
* A provider's name.
|
|
47
|
+
*
|
|
48
|
+
* Open on purpose. `registerProvider` is documented as the way to plug in a
|
|
49
|
+
* provider you wrote yourself, but while this was a closed union of the four
|
|
50
|
+
* built-ins that was impossible to express in types - a `'dropbox'` provider
|
|
51
|
+
* needed a cast at every call site, including in `CloudStoreOptions.providers`.
|
|
52
|
+
* The `string & {}` arm keeps editor autocomplete for the built-in names while
|
|
53
|
+
* still accepting any other string.
|
|
54
|
+
*/
|
|
55
|
+
export type ProviderName = BuiltInProviderName | (string & {});
|
|
56
|
+
export type Unsubscribe = () => void;
|
|
57
|
+
/**
|
|
58
|
+
* The contract every provider implements. The facade in `store.ts` is written
|
|
59
|
+
* against this and nothing else, which is what makes providers swappable and
|
|
60
|
+
* makes the in-memory test double a first-class provider rather than a mock.
|
|
61
|
+
*/
|
|
62
|
+
export interface CloudProvider {
|
|
63
|
+
readonly name: ProviderName;
|
|
64
|
+
/**
|
|
65
|
+
* Whether this provider can currently be used. Cheap and non-throwing, so it
|
|
66
|
+
* is safe to call on a render path.
|
|
67
|
+
*/
|
|
68
|
+
isAvailable: () => Promise<boolean>;
|
|
69
|
+
getAccountStatus: () => Promise<AccountStatus>;
|
|
70
|
+
/**
|
|
71
|
+
* Resolves `null` if and only if the key does not exist. Every other failure
|
|
72
|
+
* rejects with a {@link CloudSyncError}. See `errors.ts` for why.
|
|
73
|
+
*/
|
|
74
|
+
getItem: (key: string) => Promise<string | null>;
|
|
75
|
+
/**
|
|
76
|
+
* Like {@link getItem}, but also reports the server's own last-modified time.
|
|
77
|
+
*
|
|
78
|
+
* Optional because not every backing store knows one - `NSUbiquitousKeyValueStore`
|
|
79
|
+
* exposes no per-key timestamp at all. Where a provider *does* know (CloudKit's
|
|
80
|
+
* `modified.timestamp`, Drive's `modifiedTime`, both one query parameter away),
|
|
81
|
+
* implementing this lets {@link resolveByModifiedAt} order candidates without
|
|
82
|
+
* the app having to embed a timestamp inside its own payload.
|
|
83
|
+
*/
|
|
84
|
+
getItemWithMeta?: (key: string) => Promise<ItemWithMeta | null>;
|
|
85
|
+
setItem: (key: string, value: string) => Promise<void>;
|
|
86
|
+
removeItem: (key: string) => Promise<void>;
|
|
87
|
+
getAllKeys: () => Promise<string[]>;
|
|
88
|
+
/**
|
|
89
|
+
* Reads many keys in one go. Optional: the store falls back to sequential
|
|
90
|
+
* {@link getItem} calls when a provider does not implement it.
|
|
91
|
+
*
|
|
92
|
+
* Worth implementing whenever the backend has a batch endpoint - CloudKit Web
|
|
93
|
+
* Services' `/records/lookup` and `/records/modify` both take arrays, so the
|
|
94
|
+
* difference between this and a loop is one request against N.
|
|
95
|
+
*/
|
|
96
|
+
multiGet?: (keys: string[]) => Promise<(string | null)[]>;
|
|
97
|
+
/** Writes many key/value pairs in one go. Optional, same fallback rule. */
|
|
98
|
+
multiSet?: (entries: [string, string][]) => Promise<void>;
|
|
99
|
+
/** Removes many keys in one go. Optional, same fallback rule. */
|
|
100
|
+
multiRemove?: (keys: string[]) => Promise<void>;
|
|
101
|
+
/**
|
|
102
|
+
* Total and used bytes for this account, when the backend reports them.
|
|
103
|
+
* Optional - `NSUbiquitousKeyValueStore` has no usage API.
|
|
104
|
+
*/
|
|
105
|
+
getQuota?: () => Promise<QuotaInfo | null>;
|
|
106
|
+
/**
|
|
107
|
+
* Drops any state cached for the *previous* account.
|
|
108
|
+
*
|
|
109
|
+
* Called by the store when an `identityChanged` account event arrives.
|
|
110
|
+
* Memoised Drive file ids and CloudKit reachability answers belong to whoever
|
|
111
|
+
* was signed in when they were recorded; serving them to the next user is a
|
|
112
|
+
* cross-account data leak.
|
|
113
|
+
*/
|
|
114
|
+
clearCaches?: () => void;
|
|
115
|
+
onRemoteChange?: (listener: (e: RemoteChangeEvent) => void) => Unsubscribe;
|
|
116
|
+
onAccountChange?: (listener: (e: AccountChangeEvent) => void) => Unsubscribe;
|
|
117
|
+
}
|
|
118
|
+
/** A value plus whatever metadata the provider could report alongside it. */
|
|
119
|
+
export interface ItemWithMeta {
|
|
120
|
+
value: string;
|
|
121
|
+
/** Server-reported last modification, epoch millis, when the provider knows one. */
|
|
122
|
+
modifiedAt?: number;
|
|
123
|
+
}
|
|
124
|
+
/** Account storage usage, for providers that report it. */
|
|
125
|
+
export interface QuotaInfo {
|
|
126
|
+
/** Bytes currently used, or undefined when the backend does not say. */
|
|
127
|
+
usedBytes?: number;
|
|
128
|
+
/** Total bytes available, or undefined for an unlimited/unreported quota. */
|
|
129
|
+
totalBytes?: number;
|
|
130
|
+
provider: ProviderName;
|
|
131
|
+
}
|
|
132
|
+
/** Byte thresholds that decide which backing store a value lands in. */
|
|
133
|
+
export interface TieringConfig {
|
|
134
|
+
/**
|
|
135
|
+
* At or below this, values go to the iCloud key-value store.
|
|
136
|
+
*
|
|
137
|
+
* Apple's hard limits are 1 MB total / 1 MB per key / 1024 keys, but the
|
|
138
|
+
* *total* is the one that bites - a handful of large values silently starves
|
|
139
|
+
* every other key. 64 KB keeps the KV store for what it is good at (settings,
|
|
140
|
+
* small identifiers) and pushes real payloads to CloudKit records.
|
|
141
|
+
*/
|
|
142
|
+
kvMaxBytes: number;
|
|
143
|
+
/**
|
|
144
|
+
* At or below this, values go in a CKRecord field. CloudKit's documented
|
|
145
|
+
* record ceiling is 1 MB excluding assets; 900 KB leaves room for the record's
|
|
146
|
+
* own metadata.
|
|
147
|
+
*/
|
|
148
|
+
recordMaxBytes: number;
|
|
149
|
+
}
|
|
150
|
+
export declare const DEFAULT_TIERING: TieringConfig;
|
|
151
|
+
export interface OutboxEntry {
|
|
152
|
+
key: string;
|
|
153
|
+
value: string | null;
|
|
154
|
+
provider: ProviderName;
|
|
155
|
+
attempts: number;
|
|
156
|
+
/** Epoch millis of the next attempt. */
|
|
157
|
+
nextAttemptAt: number;
|
|
158
|
+
enqueuedAt: number;
|
|
159
|
+
/**
|
|
160
|
+
* The error code of the most recent failed attempt, so a "pending sync" UI
|
|
161
|
+
* can say *why* something is still queued rather than only that it is.
|
|
162
|
+
*/
|
|
163
|
+
lastErrorCode?: string;
|
|
164
|
+
}
|
|
165
|
+
/** Why the store gave up on a queued write. Reported through {@link CloudStoreOptions.onDropped}. */
|
|
166
|
+
/**
|
|
167
|
+
* - `notRetryable` - the failure stopped being retryable; the user has to act on it.
|
|
168
|
+
* - `tooManyAttempts` - {@link CloudStoreOptions.outboxMaxAttempts} was reached.
|
|
169
|
+
* - `expired` - it sat in the queue longer than {@link CloudStoreOptions.outboxMaxAgeMs}.
|
|
170
|
+
* - `queueFull` - the queue hit its cap and this was the oldest entry.
|
|
171
|
+
* - `accountChanged` - a different account signed in, so it belongs to nobody now.
|
|
172
|
+
* - `discarded` - `discardPendingWrites` removed it.
|
|
173
|
+
*/
|
|
174
|
+
export type DropReason = 'notRetryable' | 'tooManyAttempts' | 'expired' | 'queueFull' | 'accountChanged' | 'discarded';
|
|
175
|
+
export interface DroppedWrite {
|
|
176
|
+
entry: OutboxEntry;
|
|
177
|
+
reason: DropReason;
|
|
178
|
+
/** The failure that caused it, when there was one. */
|
|
179
|
+
error?: CloudSyncError;
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* How a write is distributed across the configured providers.
|
|
183
|
+
*
|
|
184
|
+
* - `failover` - write to the first available provider only. The rest are read
|
|
185
|
+
* fallbacks. Cheapest, and right when the providers are alternatives.
|
|
186
|
+
* - `mirror` - write to every available provider. Costs one request per
|
|
187
|
+
* provider, and is what makes a value written on an iPhone readable on
|
|
188
|
+
* Android: the Apple-only providers cannot be reached from there, so unless
|
|
189
|
+
* something also wrote to Drive, there is nothing for Android to find.
|
|
190
|
+
*
|
|
191
|
+
* Reads fall through the list in both modes.
|
|
192
|
+
*/
|
|
193
|
+
export type WriteMode = 'failover' | 'mirror';
|
|
194
|
+
/** One provider's copy of a key, as seen during a resolving read. */
|
|
195
|
+
export interface ResolveCandidate {
|
|
196
|
+
provider: ProviderName;
|
|
197
|
+
value: string;
|
|
198
|
+
/**
|
|
199
|
+
* The server's own last-modified time in epoch millis, when the provider
|
|
200
|
+
* reported one (see {@link CloudProvider.getItemWithMeta}).
|
|
201
|
+
*
|
|
202
|
+
* This is what {@link resolveByModifiedAt} orders on, and it is why that
|
|
203
|
+
* resolver works on payloads the app never had to instrument.
|
|
204
|
+
*/
|
|
205
|
+
modifiedAt?: number;
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* Picks the winner when providers disagree.
|
|
209
|
+
*
|
|
210
|
+
* The store holds opaque strings, so it cannot know which copy is newer - only
|
|
211
|
+
* the app knows what its values mean. Returning `null` means "none of these",
|
|
212
|
+
* which reads as absent.
|
|
213
|
+
*/
|
|
214
|
+
export type ResolveFn = (candidates: ResolveCandidate[]) => string | null;
|
|
215
|
+
export interface CloudStoreOptions {
|
|
216
|
+
/**
|
|
217
|
+
* Providers in preference order.
|
|
218
|
+
*
|
|
219
|
+
* Reads fall through this list until a value is found. Writes go to the first
|
|
220
|
+
* available provider, or to all of them - see {@link writeMode}.
|
|
221
|
+
*/
|
|
222
|
+
providers: ProviderName[];
|
|
223
|
+
/**
|
|
224
|
+
* Default `failover`.
|
|
225
|
+
*
|
|
226
|
+
* Use `mirror` when the same data has to be reachable from a platform where
|
|
227
|
+
* the preferred provider does not exist.
|
|
228
|
+
*/
|
|
229
|
+
writeMode?: WriteMode;
|
|
230
|
+
/**
|
|
231
|
+
* How a read picks a value when more than one provider holds the key.
|
|
232
|
+
*
|
|
233
|
+
* Without this, `getItem` returns the first non-null value in provider order
|
|
234
|
+
* and stops. That is cheap and correct when only one device population
|
|
235
|
+
* writes - but it silently serves stale data as soon as writes come from
|
|
236
|
+
* both sides. An Apple device reading `['icloudKV', 'googleDrive']` always
|
|
237
|
+
* finds *something* in iCloud, so a newer value written from Android via
|
|
238
|
+
* Drive is never even looked at.
|
|
239
|
+
*
|
|
240
|
+
* Supplying this makes a read consult every available provider and hand you
|
|
241
|
+
* the candidates. {@link resolveByTimestamp} covers the usual case.
|
|
242
|
+
*/
|
|
243
|
+
resolve?: ResolveFn;
|
|
244
|
+
/**
|
|
245
|
+
* After a resolving read, write the winner back to providers that disagreed.
|
|
246
|
+
*
|
|
247
|
+
* Default true when {@link resolve} is set. This is what actually makes two
|
|
248
|
+
* populations converge: without it, the losing store keeps its old value and
|
|
249
|
+
* every read pays to resolve again forever.
|
|
250
|
+
*
|
|
251
|
+
* Best-effort - a failed repair never fails the read.
|
|
252
|
+
*/
|
|
253
|
+
repairOnRead?: boolean;
|
|
254
|
+
tiering?: TieringConfig | 'auto' | 'off';
|
|
255
|
+
/**
|
|
256
|
+
* Persist failed writes and retry them with backoff.
|
|
257
|
+
*
|
|
258
|
+
* Default true. With it off, a write made while offline is lost - which is
|
|
259
|
+
* exactly the documented behaviour of react-native-cloud-storage today
|
|
260
|
+
* ("the OS will not throw an error ... you'll need to check for an internet
|
|
261
|
+
* connection before handing data to" it).
|
|
262
|
+
*/
|
|
263
|
+
outbox?: boolean;
|
|
264
|
+
/**
|
|
265
|
+
* Hard cap on queued writes. Default 1000.
|
|
266
|
+
*
|
|
267
|
+
* An unbounded queue is a slow memory and storage leak: every `enqueue`
|
|
268
|
+
* rewrites the whole JSON blob, so an app that stays offline long enough
|
|
269
|
+
* degrades its own write path. When the cap is hit the oldest entry is
|
|
270
|
+
* dropped and reported through {@link onDropped}, so the loss is visible
|
|
271
|
+
* rather than silent.
|
|
272
|
+
*/
|
|
273
|
+
outboxMaxEntries?: number;
|
|
274
|
+
/**
|
|
275
|
+
* Give up on a queued write after this many failed attempts. Default 12,
|
|
276
|
+
* which with the capped exponential backoff is roughly an hour of retrying.
|
|
277
|
+
*/
|
|
278
|
+
outboxMaxAttempts?: number;
|
|
279
|
+
/**
|
|
280
|
+
* Give up on a queued write older than this. Default 7 days.
|
|
281
|
+
*
|
|
282
|
+
* Time matters independently of attempt count: an app opened twice in a month
|
|
283
|
+
* accrues almost no attempts, and re-sending a fortnight-old value over
|
|
284
|
+
* whatever the user has done since is rarely what they want.
|
|
285
|
+
*/
|
|
286
|
+
outboxMaxAgeMs?: number;
|
|
287
|
+
/** Called whenever a queued write is abandoned, with the reason. */
|
|
288
|
+
onDropped?: (dropped: DroppedWrite) => void;
|
|
289
|
+
/**
|
|
290
|
+
* Drain the outbox automatically, instead of leaving `flushOutbox()` entirely
|
|
291
|
+
* to the caller. Off by default; pass `true` for the defaults.
|
|
292
|
+
*
|
|
293
|
+
* A durable queue with no trigger is only half a feature - every retryable
|
|
294
|
+
* failure is captured correctly and then waits for someone to remember. This
|
|
295
|
+
* flushes on app foreground and on a slow timer, which is where nearly every
|
|
296
|
+
* app was calling it by hand.
|
|
297
|
+
*
|
|
298
|
+
* Not network-aware, on purpose: that needs NetInfo, and adding a dependency
|
|
299
|
+
* every consumer must install to save one line in the ones that want it is a
|
|
300
|
+
* bad trade. Call `flushOutbox()` from your own reconnect listener too if you
|
|
301
|
+
* have one.
|
|
302
|
+
*/
|
|
303
|
+
autoFlush?: boolean | AutoFlushConfig;
|
|
304
|
+
/**
|
|
305
|
+
* How long an `isAvailable()` answer is reused across operations. Default 3000.
|
|
306
|
+
*
|
|
307
|
+
* The store asks every provider before every operation, and for `icloudKV`
|
|
308
|
+
* that is a bridge hop while for `googleDrive` it invokes the host's
|
|
309
|
+
* `getAccessToken`. Unmemoised, a loop over 100 keys cost 100+ probes on top
|
|
310
|
+
* of the actual work. Set to 0 to probe every time.
|
|
311
|
+
*/
|
|
312
|
+
availabilityTtlMs?: number;
|
|
313
|
+
/**
|
|
314
|
+
* Transforms values on the way out and back on the way in - the seam for
|
|
315
|
+
* encrypting at rest.
|
|
316
|
+
*
|
|
317
|
+
* Drive's `appDataFolder` is plaintext to anything holding the account's OAuth
|
|
318
|
+
* token, and this package deliberately ships no crypto of its own (key
|
|
319
|
+
* management is the app's problem, and bundling a cipher would make it look
|
|
320
|
+
* solved). Supplying a codec is how you close that gap with a library you
|
|
321
|
+
* chose.
|
|
322
|
+
*
|
|
323
|
+
* Applied to values only, never to keys - `getAllKeys()`, tiering and read
|
|
324
|
+
* repair all need cleartext keys to work.
|
|
325
|
+
*
|
|
326
|
+
* Encoding runs *before* tiering picks a destination, so a value is routed by
|
|
327
|
+
* the size it will actually occupy rather than by its plaintext size. That is
|
|
328
|
+
* the correct behaviour, and it means a codec that inflates its input makes
|
|
329
|
+
* your effective {@link TieringConfig.kvMaxBytes} smaller than the number
|
|
330
|
+
* says.
|
|
331
|
+
*/
|
|
332
|
+
codec?: ValueCodec;
|
|
333
|
+
/**
|
|
334
|
+
* Reject keys that cannot round-trip through every configured provider.
|
|
335
|
+
* Default true.
|
|
336
|
+
*
|
|
337
|
+
* One key string has to be a `NSUbiquitousKeyValueStore` key, a CloudKit
|
|
338
|
+
* `recordName` and a Drive filename at once, and those three disagree about
|
|
339
|
+
* what is legal. Without this check an invalid `recordName` comes back from
|
|
340
|
+
* CloudKit as `BAD_REQUEST`, which maps to `ERR_CONTAINER_MISCONFIGURED` and
|
|
341
|
+
* sends you looking at your entitlements instead of at your key.
|
|
342
|
+
*/
|
|
343
|
+
validateKeys?: boolean;
|
|
344
|
+
/**
|
|
345
|
+
* Abandon a single provider operation that has not settled in this long,
|
|
346
|
+
* with {@link ErrorCode.TIMEOUT}. Off by default.
|
|
347
|
+
*
|
|
348
|
+
* React Native's `fetch` has no default timeout and neither does CloudKit's
|
|
349
|
+
* native stack, so a socket that never answers hangs the operation forever -
|
|
350
|
+
* including `isAvailable()`, which the store calls before everything else.
|
|
351
|
+
* A timeout is classified as retryable, so with the outbox on, a hung write
|
|
352
|
+
* is queued rather than lost.
|
|
353
|
+
*/
|
|
354
|
+
timeoutMs?: number;
|
|
355
|
+
onError?: (e: CloudSyncError) => void;
|
|
356
|
+
}
|
|
357
|
+
/**
|
|
358
|
+
* A two-way value transform, applied at the boundary between the store and its
|
|
359
|
+
* providers. See {@link CloudStoreOptions.codec}.
|
|
360
|
+
*/
|
|
361
|
+
export interface ValueCodec {
|
|
362
|
+
/** Called with the app's value; the result is what the provider stores. */
|
|
363
|
+
encode: (value: string, key: string) => Promise<string> | string;
|
|
364
|
+
/** Called with what the provider returned; the result is what the app sees. */
|
|
365
|
+
decode: (value: string, key: string) => Promise<string> | string;
|
|
366
|
+
}
|
|
367
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAU,CAAA;AAC9C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAsB,CAAA;AAE3D;;;;;;;;GAQG;AACH,MAAM,MAAM,aAAa,GACnB,WAAW,GACX,WAAW,GACX,YAAY,GACZ,wBAAwB,GACxB,mBAAmB,CAAA;AAEzB,oFAAoF;AACpF,MAAM,MAAM,YAAY,GAClB,cAAc,GACd,aAAa,GACb,gBAAgB,GAChB,eAAe,GACf,SAAS,CAAA;AAEf,MAAM,WAAW,iBAAiB;IAChC,oFAAoF;IACpF,IAAI,EAAE,MAAM,EAAE,CAAA;IACd,MAAM,EAAE,YAAY,CAAA;IACpB,QAAQ,EAAE,YAAY,CAAA;CACvB;AAED,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,aAAa,CAAA;IACrB;;;;;;;;;OASG;IACH,eAAe,EAAE,OAAO,CAAA;IACxB,QAAQ,EAAE,YAAY,CAAA;CACvB;AAED,MAAM,WAAW,kBAAkB;IACjC,UAAU,EAAE,MAAM,CAAA;IAClB,SAAS,EAAE,MAAM,CAAA;IACjB,gBAAgB,EAAE,MAAM,CAAA;IACxB,UAAU,EAAE,MAAM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AAY,KAAK,IAAI,CAAA;IAC3C;;;;;;;;;;;;;OAaG;IACH,SAAS,CAAC,EAAE,OAAO,GAAG,eAAe,CAAA;IACrC;;;;;;;OAOG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAC1B;;;;;;;;;;;;;;;;;;OAkBG;IACH,KAAK,CAAC,EAAE,UAAU,CAAA;IAClB;;;;;;;;;OASG;IACH,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB;;;;;;;;;OASG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,OAAO,CAAC,EAAE,CAAC,CAAC,EAAE,cAAc,KAAK,IAAI,CAAA;CACtC;AAED;;;GAGG;AACH,MAAM,WAAW,UAAU;IACzB,2EAA2E;IAC3E,MAAM,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,GAAG,MAAM,CAAA;IAChE,+EAA+E;IAC/E,MAAM,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,GAAG,MAAM,CAAA;CACjE"}
|
package/package.json
ADDED
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "react-native-cloud-sync",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "iCloud key-value store, CloudKit and Google Drive under one API - iOS, Android and Web, old and new architecture",
|
|
5
|
+
"workspaces": [
|
|
6
|
+
"example"
|
|
7
|
+
],
|
|
8
|
+
"keywords": [
|
|
9
|
+
"react-native",
|
|
10
|
+
"expo",
|
|
11
|
+
"icloud",
|
|
12
|
+
"cloudkit",
|
|
13
|
+
"ckrecord",
|
|
14
|
+
"nsubiquitouskeyvaluestore",
|
|
15
|
+
"google-drive",
|
|
16
|
+
"cloud",
|
|
17
|
+
"cloud-storage",
|
|
18
|
+
"sync",
|
|
19
|
+
"backup",
|
|
20
|
+
"restore",
|
|
21
|
+
"key-value",
|
|
22
|
+
"offline",
|
|
23
|
+
"new-architecture",
|
|
24
|
+
"turbomodule",
|
|
25
|
+
"typescript",
|
|
26
|
+
"ios",
|
|
27
|
+
"android",
|
|
28
|
+
"web",
|
|
29
|
+
"macos",
|
|
30
|
+
"mac-catalyst"
|
|
31
|
+
],
|
|
32
|
+
"homepage": "https://github.com/kesha-antonov/react-native-cloud-sync",
|
|
33
|
+
"repository": {
|
|
34
|
+
"type": "git",
|
|
35
|
+
"url": "git+https://github.com/kesha-antonov/react-native-cloud-sync.git"
|
|
36
|
+
},
|
|
37
|
+
"bugs": {
|
|
38
|
+
"url": "https://github.com/kesha-antonov/react-native-cloud-sync/issues"
|
|
39
|
+
},
|
|
40
|
+
"license": "MIT",
|
|
41
|
+
"author": "Kesha Antonov <innokenty.longway@gmail.com>",
|
|
42
|
+
"packageManager": "yarn@4.18.0",
|
|
43
|
+
"source": "./src/index.ts",
|
|
44
|
+
"main": "./lib/commonjs/index.js",
|
|
45
|
+
"module": "./lib/module/index.js",
|
|
46
|
+
"types": "./lib/typescript/commonjs/index.d.ts",
|
|
47
|
+
"react-native": "./src/index.ts",
|
|
48
|
+
"exports": {
|
|
49
|
+
".": {
|
|
50
|
+
"source": "./src/index.ts",
|
|
51
|
+
"import": {
|
|
52
|
+
"types": "./lib/typescript/module/index.d.ts",
|
|
53
|
+
"default": "./lib/module/index.js"
|
|
54
|
+
},
|
|
55
|
+
"require": {
|
|
56
|
+
"types": "./lib/typescript/commonjs/index.d.ts",
|
|
57
|
+
"default": "./lib/commonjs/index.js"
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
"./testing": {
|
|
61
|
+
"source": "./src/testing.ts",
|
|
62
|
+
"import": {
|
|
63
|
+
"types": "./lib/typescript/module/testing.d.ts",
|
|
64
|
+
"default": "./lib/module/testing.js"
|
|
65
|
+
},
|
|
66
|
+
"require": {
|
|
67
|
+
"types": "./lib/typescript/commonjs/testing.d.ts",
|
|
68
|
+
"default": "./lib/commonjs/testing.js"
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
"./hooks": {
|
|
72
|
+
"source": "./src/hooks.ts",
|
|
73
|
+
"import": {
|
|
74
|
+
"types": "./lib/typescript/module/hooks.d.ts",
|
|
75
|
+
"default": "./lib/module/hooks.js"
|
|
76
|
+
},
|
|
77
|
+
"require": {
|
|
78
|
+
"types": "./lib/typescript/commonjs/hooks.d.ts",
|
|
79
|
+
"default": "./lib/commonjs/hooks.js"
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
"./jest-mock": {
|
|
83
|
+
"source": "./jest-mock.js",
|
|
84
|
+
"default": "./jest-mock.js"
|
|
85
|
+
},
|
|
86
|
+
"./package.json": "./package.json"
|
|
87
|
+
},
|
|
88
|
+
"sideEffects": false,
|
|
89
|
+
"files": [
|
|
90
|
+
"README.md",
|
|
91
|
+
"LICENSE",
|
|
92
|
+
"package.json",
|
|
93
|
+
"app.plugin.js",
|
|
94
|
+
"jest-mock.js",
|
|
95
|
+
"src/",
|
|
96
|
+
"lib/",
|
|
97
|
+
"ios/",
|
|
98
|
+
"plugin/build/",
|
|
99
|
+
"react-native-cloud-sync.podspec",
|
|
100
|
+
"!**/__tests__",
|
|
101
|
+
"!**/__fixtures__",
|
|
102
|
+
"!**/.*"
|
|
103
|
+
],
|
|
104
|
+
"scripts": {
|
|
105
|
+
"autofix": "eslint --fix .",
|
|
106
|
+
"bump": "npm version patch",
|
|
107
|
+
"clean": "del-cli lib plugin/build",
|
|
108
|
+
"build": "bob build",
|
|
109
|
+
"build-plugin": "tsc --project plugin/tsconfig.json",
|
|
110
|
+
"typecheck": "tsc --noEmit",
|
|
111
|
+
"validate:podspec": "ruby scripts/validate-podspec.rb",
|
|
112
|
+
"check:objc": "bash scripts/check-objc-surface.sh",
|
|
113
|
+
"check:catalyst": "bash scripts/check-catalyst.sh",
|
|
114
|
+
"check:docs": "node scripts/check-docs-style.mjs && node scripts/check-docs-links.mjs",
|
|
115
|
+
"check:links": "node scripts/check-docs-links.mjs",
|
|
116
|
+
"lint": "eslint .",
|
|
117
|
+
"test": "jest",
|
|
118
|
+
"test:watch": "jest --watch",
|
|
119
|
+
"test:coverage": "jest --coverage",
|
|
120
|
+
"release": "npm publish",
|
|
121
|
+
"prepublishOnly": "yarn lint && yarn typecheck && yarn test && yarn build-plugin",
|
|
122
|
+
"prepare": "husky && bob build && yarn build-plugin"
|
|
123
|
+
},
|
|
124
|
+
"devDependencies": {
|
|
125
|
+
"@babel/core": "^7.29.7",
|
|
126
|
+
"@eslint/js": "^10.0.1",
|
|
127
|
+
"@expo/config-plugins": "^10.0.2",
|
|
128
|
+
"@react-native/babel-preset": "^0.86.2",
|
|
129
|
+
"@react-native/eslint-config": "^0.86.2",
|
|
130
|
+
"@react-native/jest-preset": "^0.86.2",
|
|
131
|
+
"@react-native/metro-config": "^0.86.2",
|
|
132
|
+
"@stylistic/eslint-plugin": "^5.10.0",
|
|
133
|
+
"@types/jest": "^29.5.14",
|
|
134
|
+
"@types/node": "^26.2.0",
|
|
135
|
+
"@types/react": "^19.2.18",
|
|
136
|
+
"babel-jest": "^29.7.0",
|
|
137
|
+
"del-cli": "^7.0.0",
|
|
138
|
+
"eslint": "^10.8.0",
|
|
139
|
+
"eslint-plugin-import": "^2.32.0",
|
|
140
|
+
"husky": "^9.1.7",
|
|
141
|
+
"jest": "^29.7.0",
|
|
142
|
+
"lint-staged": "^17.3.0",
|
|
143
|
+
"react": "19.2.3",
|
|
144
|
+
"react-native": "0.86.2",
|
|
145
|
+
"react-native-builder-bob": "^0.43.0",
|
|
146
|
+
"typescript": "^6.0.3",
|
|
147
|
+
"typescript-eslint": "^8.66.0"
|
|
148
|
+
},
|
|
149
|
+
"engines": {
|
|
150
|
+
"node": ">=20"
|
|
151
|
+
},
|
|
152
|
+
"peerDependencies": {
|
|
153
|
+
"react": "*",
|
|
154
|
+
"react-native": ">=0.71"
|
|
155
|
+
},
|
|
156
|
+
"codegenConfig": {
|
|
157
|
+
"name": "RNCloudSyncSpec",
|
|
158
|
+
"type": "modules",
|
|
159
|
+
"jsSrcsDir": "src/specs"
|
|
160
|
+
},
|
|
161
|
+
"expo": {
|
|
162
|
+
"plugin": "./app.plugin.js"
|
|
163
|
+
},
|
|
164
|
+
"react-native-builder-bob": {
|
|
165
|
+
"source": "src",
|
|
166
|
+
"output": "lib",
|
|
167
|
+
"targets": [
|
|
168
|
+
[
|
|
169
|
+
"module",
|
|
170
|
+
{
|
|
171
|
+
"esm": true
|
|
172
|
+
}
|
|
173
|
+
],
|
|
174
|
+
[
|
|
175
|
+
"commonjs",
|
|
176
|
+
{
|
|
177
|
+
"esm": true
|
|
178
|
+
}
|
|
179
|
+
],
|
|
180
|
+
"typescript"
|
|
181
|
+
]
|
|
182
|
+
},
|
|
183
|
+
"lint-staged": {
|
|
184
|
+
"*.{ts,tsx}": "eslint --fix"
|
|
185
|
+
}
|
|
186
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { type ConfigPlugin } from '@expo/config-plugins';
|
|
2
|
+
export interface CloudSyncPluginOptions {
|
|
3
|
+
/**
|
|
4
|
+
* The iCloud container identifier, e.g. `iCloud.com.example.app`.
|
|
5
|
+
* Defaults to `iCloud.<your bundle identifier>`, which is the convention
|
|
6
|
+
* Xcode itself proposes when you add the capability.
|
|
7
|
+
*/
|
|
8
|
+
containerIdentifier?: string;
|
|
9
|
+
/**
|
|
10
|
+
* Add the key-value store entitlement. Needed for the `icloudKV` provider.
|
|
11
|
+
* Defaults to true.
|
|
12
|
+
*/
|
|
13
|
+
keyValueStore?: boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Add the CloudKit service entitlement. Needed for the `cloudKit` provider.
|
|
16
|
+
* Defaults to true.
|
|
17
|
+
*/
|
|
18
|
+
cloudKit?: boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Add the iCloud Documents service, for the `icloudDocuments` provider.
|
|
21
|
+
* Defaults to false.
|
|
22
|
+
*
|
|
23
|
+
* Off by default because it is the one capability here with a user-visible
|
|
24
|
+
* consequence: enabling it puts a folder for this app in the user's iCloud
|
|
25
|
+
* Drive and in Files.app. That should be a deliberate choice, not something
|
|
26
|
+
* installing a package does to somebody's Files.app.
|
|
27
|
+
*/
|
|
28
|
+
iCloudDocuments?: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* The folder name shown in Files.app when {@link iCloudDocuments} is on.
|
|
31
|
+
* Defaults to the app's display name.
|
|
32
|
+
*/
|
|
33
|
+
documentsFolderName?: string;
|
|
34
|
+
/**
|
|
35
|
+
* Whether that folder is visible to the user at all. Defaults to true.
|
|
36
|
+
*
|
|
37
|
+
* Set false to sync documents between the user's own devices without showing
|
|
38
|
+
* them in Files.app - the folder still exists, the user just cannot browse
|
|
39
|
+
* it. Rarely what you want; if the files are not for the user, a `CKAsset`
|
|
40
|
+
* is the better home.
|
|
41
|
+
*/
|
|
42
|
+
documentsVisibleInFiles?: boolean;
|
|
43
|
+
}
|
|
44
|
+
declare const _default: ConfigPlugin<void | CloudSyncPluginOptions>;
|
|
45
|
+
export default _default;
|