@evolu/react-native 15.0.1 → 16.0.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/dist/src/Task.d.ts +12 -2
- package/dist/src/Task.d.ts.map +1 -1
- package/dist/src/exports/expo-sqlite.d.ts +2 -1
- package/dist/src/exports/expo-sqlite.d.ts.map +1 -1
- package/dist/src/exports/expo-sqlite.js +2 -8
- package/dist/src/shared.js +0 -47
- package/package.json +5 -39
- package/src/Task.ts +13 -2
- package/src/exports/expo-sqlite.ts +2 -9
- package/src/shared.ts +0 -49
- package/dist/src/createExpoDeps.d.ts +0 -1
- package/dist/src/createExpoDeps.d.ts.map +0 -1
- package/dist/src/createExpoDeps.js +0 -163
- package/dist/src/exports/bare-op-sqlite.d.ts +0 -1
- package/dist/src/exports/bare-op-sqlite.d.ts.map +0 -1
- package/dist/src/exports/bare-op-sqlite.js +0 -31
- package/dist/src/exports/expo-op-sqlite.d.ts +0 -1
- package/dist/src/exports/expo-op-sqlite.d.ts.map +0 -1
- package/dist/src/exports/expo-op-sqlite.js +0 -16
- package/dist/src/sqlite-drivers/createOpSqliteDriver.d.ts +0 -3
- package/dist/src/sqlite-drivers/createOpSqliteDriver.d.ts.map +0 -1
- package/dist/src/sqlite-drivers/createOpSqliteDriver.js +0 -119
- package/src/createExpoDeps.ts +0 -164
- package/src/exports/bare-op-sqlite.ts +0 -30
- package/src/exports/expo-op-sqlite.ts +0 -15
- package/src/sqlite-drivers/createOpSqliteDriver.ts +0 -76
package/dist/src/Task.d.ts
CHANGED
|
@@ -14,16 +14,26 @@ import { type DisposableRun, type RunCustomDeps } from "@evolu/common";
|
|
|
14
14
|
* ### Example
|
|
15
15
|
*
|
|
16
16
|
* ```ts
|
|
17
|
+
* import {
|
|
18
|
+
* createConsole,
|
|
19
|
+
* createConsoleFormatter,
|
|
20
|
+
* ok,
|
|
21
|
+
* } from "@evolu/common";
|
|
22
|
+
* import { createRun } from "@evolu/react-native";
|
|
23
|
+
*
|
|
17
24
|
* const console = createConsole({
|
|
18
25
|
* formatter: createConsoleFormatter()({
|
|
19
26
|
* timestampFormat: "relative",
|
|
20
27
|
* }),
|
|
21
28
|
* });
|
|
22
29
|
*
|
|
23
|
-
*
|
|
24
|
-
* const appPromise = run.ok(
|
|
30
|
+
* await using run = createRun({ console });
|
|
31
|
+
* const appPromise = run.ok(() => ok("started"));
|
|
32
|
+
*
|
|
33
|
+
* expect(await appPromise).toBe("started");
|
|
25
34
|
* ```
|
|
26
35
|
*/
|
|
27
36
|
export declare function createRun(): DisposableRun;
|
|
37
|
+
/** Creates a root {@link Run} for React Native with custom dependencies. */
|
|
28
38
|
export declare function createRun<D extends object>(deps: RunCustomDeps<D>): DisposableRun<D>;
|
|
29
39
|
//# sourceMappingURL=Task.d.ts.map
|
package/dist/src/Task.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Task.d.ts","sourceRoot":"","sources":["../../src/Task.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAGL,KAAK,aAAa,EAElB,KAAK,aAAa,EACnB,MAAM,eAAe,CAAC;AAEvB
|
|
1
|
+
{"version":3,"file":"Task.d.ts","sourceRoot":"","sources":["../../src/Task.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAGL,KAAK,aAAa,EAElB,KAAK,aAAa,EACnB,MAAM,eAAe,CAAC;AAEvB;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAgB,SAAS,IAAI,aAAa,CAAC;AAE3C,4EAA4E;AAC5E,wBAAgB,SAAS,CAAC,CAAC,SAAS,MAAM,EACxC,IAAI,EAAE,aAAa,CAAC,CAAC,CAAC,GACrB,aAAa,CAAC,CAAC,CAAC,CAAC"}
|
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
* Public entry point for Expo SQLite. Exported as
|
|
3
3
|
* "@evolu/react-native/expo-sqlite" in package.json.
|
|
4
4
|
*
|
|
5
|
-
* Use this with Expo projects
|
|
5
|
+
* Use this with Expo projects and existing React Native projects configured
|
|
6
|
+
* with Expo modules.
|
|
6
7
|
*/
|
|
7
8
|
import type { ConsoleDep } from "@evolu/common";
|
|
8
9
|
import type { EvoluDeps } from "@evolu/common/local-first";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"expo-sqlite.d.ts","sourceRoot":"","sources":["../../../src/exports/expo-sqlite.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"expo-sqlite.d.ts","sourceRoot":"","sources":["../../../src/exports/expo-sqlite.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAK3D,2CAA2C;AAC3C,eAAO,MAAM,eAAe,UAAU,OAAO,CAAC,UAAU,CAAC,KAAQ,SAO7D,CAAC"}
|
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
* Public entry point for Expo SQLite. Exported as
|
|
3
3
|
* "@evolu/react-native/expo-sqlite" in package.json.
|
|
4
4
|
*
|
|
5
|
-
* Use this with Expo projects
|
|
5
|
+
* Use this with Expo projects and existing React Native projects configured
|
|
6
|
+
* with Expo modules.
|
|
6
7
|
*/
|
|
7
8
|
import * as Expo from "expo";
|
|
8
9
|
import { createEvoluDeps as createSharedEvoluDeps } from "../shared.js";
|
|
@@ -15,10 +16,3 @@ export const createEvoluDeps = (deps = {}) => createSharedEvoluDeps({
|
|
|
15
16
|
void Expo.reloadAppAsync();
|
|
16
17
|
},
|
|
17
18
|
});
|
|
18
|
-
// import { createExpoDeps } from "../createExpoDeps.ts";
|
|
19
|
-
// import { createExpoSqliteDriver } from "../sqlite-drivers/createExpoSqliteDriver.ts";
|
|
20
|
-
//
|
|
21
|
-
// // eslint-disable-next-line evolu/require-pure-annotation
|
|
22
|
-
// export const { evoluReactNativeDeps, localAuth } = createExpoDeps({
|
|
23
|
-
// createSqliteDriver: createExpoSqliteDriver,
|
|
24
|
-
// });
|
package/dist/src/shared.js
CHANGED
|
@@ -108,50 +108,3 @@ export const createEvoluDeps = (deps) => {
|
|
|
108
108
|
sharedWorker,
|
|
109
109
|
});
|
|
110
110
|
};
|
|
111
|
-
// TODO: Reimplement local auth for React Native from scratch.
|
|
112
|
-
// export const createSharedLocalAuth = (
|
|
113
|
-
// secureStorage: SecureStorage,
|
|
114
|
-
// ): LocalAuth =>
|
|
115
|
-
// createLocalAuth({
|
|
116
|
-
// randomBytes,
|
|
117
|
-
// secureStorage,
|
|
118
|
-
// });
|
|
119
|
-
// import {
|
|
120
|
-
// createConsole,
|
|
121
|
-
// createLocalAuth,
|
|
122
|
-
// createRandomBytes,
|
|
123
|
-
// type CreateSqliteDriverDep,
|
|
124
|
-
// type LocalAuth,
|
|
125
|
-
// type ReloadAppDep,
|
|
126
|
-
// type SecureStorage,
|
|
127
|
-
// } from "@evolu/common";
|
|
128
|
-
// import type {
|
|
129
|
-
// // createDbWorkerForPlatform,
|
|
130
|
-
// // createDbWorkerForPlatform,
|
|
131
|
-
// EvoluDeps,
|
|
132
|
-
// } from "@evolu/common/local-first";
|
|
133
|
-
//
|
|
134
|
-
// const _console = createConsole();
|
|
135
|
-
// const randomBytes = createRandomBytes();
|
|
136
|
-
//
|
|
137
|
-
// export const createSharedEvoluDeps = (
|
|
138
|
-
// _deps: CreateSqliteDriverDep & ReloadAppDep,
|
|
139
|
-
// ): EvoluDeps => {
|
|
140
|
-
// throw new Error("todo");
|
|
141
|
-
// };
|
|
142
|
-
//
|
|
143
|
-
// ({
|
|
144
|
-
// ...deps,
|
|
145
|
-
// console,
|
|
146
|
-
// sharedWorker: "TODO" as never,
|
|
147
|
-
// // createDbWorker: () =>
|
|
148
|
-
// // createDbWorkerForPlatform({
|
|
149
|
-
// // ...deps,
|
|
150
|
-
// // console,
|
|
151
|
-
// // createWebSocket,
|
|
152
|
-
// // random: createRandom(),
|
|
153
|
-
// // randomBytes,
|
|
154
|
-
// // time: createTime(),
|
|
155
|
-
// // }),
|
|
156
|
-
// randomBytes,
|
|
157
|
-
// });
|
package/package.json
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@evolu/react-native",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "16.0.0",
|
|
4
4
|
"description": "Evolu for React Native and Expo",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"evolu",
|
|
7
7
|
"expo",
|
|
8
8
|
"expo-sqlite",
|
|
9
|
-
"op-sqlite",
|
|
10
9
|
"react-native",
|
|
11
10
|
"react-hooks"
|
|
12
11
|
],
|
|
@@ -37,18 +36,6 @@
|
|
|
37
36
|
"react-native": "./dist/src/exports/expo-sqlite.js",
|
|
38
37
|
"browser": "./dist/src/web.js",
|
|
39
38
|
"default": "./dist/src/exports/expo-sqlite.js"
|
|
40
|
-
},
|
|
41
|
-
"./expo-op-sqlite": {
|
|
42
|
-
"types": "./dist/src/exports/expo-op-sqlite.d.ts",
|
|
43
|
-
"react-native": "./dist/src/exports/expo-op-sqlite.js",
|
|
44
|
-
"browser": "./dist/src/web.js",
|
|
45
|
-
"default": "./dist/src/exports/expo-op-sqlite.js"
|
|
46
|
-
},
|
|
47
|
-
"./bare-op-sqlite": {
|
|
48
|
-
"types": "./dist/src/exports/bare-op-sqlite.d.ts",
|
|
49
|
-
"react-native": "./dist/src/exports/bare-op-sqlite.js",
|
|
50
|
-
"browser": "./dist/src/web.js",
|
|
51
|
-
"default": "./dist/src/exports/bare-op-sqlite.js"
|
|
52
39
|
}
|
|
53
40
|
},
|
|
54
41
|
"typesVersions": {
|
|
@@ -61,12 +48,6 @@
|
|
|
61
48
|
],
|
|
62
49
|
"expo-sqlite": [
|
|
63
50
|
"./dist/src/exports/expo-sqlite.d.ts"
|
|
64
|
-
],
|
|
65
|
-
"expo-op-sqlite": [
|
|
66
|
-
"./dist/src/exports/expo-op-sqlite.d.ts"
|
|
67
|
-
],
|
|
68
|
-
"bare-op-sqlite": [
|
|
69
|
-
"./dist/src/exports/bare-op-sqlite.d.ts"
|
|
70
51
|
]
|
|
71
52
|
}
|
|
72
53
|
},
|
|
@@ -89,58 +70,43 @@
|
|
|
89
70
|
"set.prototype.union": "^1.1.3"
|
|
90
71
|
},
|
|
91
72
|
"devDependencies": {
|
|
92
|
-
"@expo/dom-webview": "
|
|
93
|
-
"@op-engineering/op-sqlite": "^17.1.3",
|
|
73
|
+
"@expo/dom-webview": "57.0.1",
|
|
94
74
|
"@react-native/metro-config": "0.86.2",
|
|
95
75
|
"@types/react": "^19.2.18",
|
|
96
76
|
"@typescript/native": "npm:typescript@^7.0.2",
|
|
97
|
-
"expo": "
|
|
98
|
-
"expo-
|
|
99
|
-
"expo-sqlite": "~57.0.0",
|
|
77
|
+
"expo": "57.0.15",
|
|
78
|
+
"expo-sqlite": "57.0.1",
|
|
100
79
|
"react": "19.2.3",
|
|
101
80
|
"react-native": "0.86.2",
|
|
102
81
|
"react-native-nitro-modules": "0.36.5",
|
|
103
82
|
"react-native-reanimated": "4.5.1",
|
|
104
|
-
"react-native-sensitive-info": "6.1.5",
|
|
105
83
|
"react-native-svg": "15.15.4",
|
|
106
84
|
"react-native-worklets": "0.10.1",
|
|
107
85
|
"typescript": "npm:@typescript/typescript6@^6.0.2",
|
|
108
|
-
"@evolu/common": "8.
|
|
86
|
+
"@evolu/common": "8.3.3",
|
|
109
87
|
"@evolu/react": "11.0.1",
|
|
110
88
|
"@evolu/typescript-config": "0.0.2"
|
|
111
89
|
},
|
|
112
90
|
"peerDependencies": {
|
|
113
91
|
"@evolu/common": "^8.0.0",
|
|
114
92
|
"@evolu/react": "^11.0.0",
|
|
115
|
-
"@op-engineering/op-sqlite": ">=12",
|
|
116
93
|
"expo": ">=55",
|
|
117
|
-
"expo-secure-store": ">=55",
|
|
118
94
|
"expo-sqlite": ">=55",
|
|
119
95
|
"react": ">=19",
|
|
120
96
|
"react-native": ">=0.83",
|
|
121
97
|
"react-native-nitro-modules": ">=0.34",
|
|
122
|
-
"react-native-sensitive-info": ">=6",
|
|
123
98
|
"react-native-svg": ">=15.15"
|
|
124
99
|
},
|
|
125
100
|
"peerDependenciesMeta": {
|
|
126
|
-
"@op-engineering/op-sqlite": {
|
|
127
|
-
"optional": true
|
|
128
|
-
},
|
|
129
101
|
"expo": {
|
|
130
102
|
"optional": true
|
|
131
103
|
},
|
|
132
104
|
"expo-sqlite": {
|
|
133
105
|
"optional": true
|
|
134
106
|
},
|
|
135
|
-
"expo-secure-store": {
|
|
136
|
-
"optional": true
|
|
137
|
-
},
|
|
138
107
|
"react-native-nitro-modules": {
|
|
139
108
|
"optional": true
|
|
140
109
|
},
|
|
141
|
-
"react-native-sensitive-info": {
|
|
142
|
-
"optional": true
|
|
143
|
-
},
|
|
144
110
|
"react-native-svg": {
|
|
145
111
|
"optional": true
|
|
146
112
|
}
|
package/src/Task.ts
CHANGED
|
@@ -22,17 +22,28 @@ import {
|
|
|
22
22
|
* ### Example
|
|
23
23
|
*
|
|
24
24
|
* ```ts
|
|
25
|
+
* import {
|
|
26
|
+
* createConsole,
|
|
27
|
+
* createConsoleFormatter,
|
|
28
|
+
* ok,
|
|
29
|
+
* } from "@evolu/common";
|
|
30
|
+
* import { createRun } from "@evolu/react-native";
|
|
31
|
+
*
|
|
25
32
|
* const console = createConsole({
|
|
26
33
|
* formatter: createConsoleFormatter()({
|
|
27
34
|
* timestampFormat: "relative",
|
|
28
35
|
* }),
|
|
29
36
|
* });
|
|
30
37
|
*
|
|
31
|
-
*
|
|
32
|
-
* const appPromise = run.ok(
|
|
38
|
+
* await using run = createRun({ console });
|
|
39
|
+
* const appPromise = run.ok(() => ok("started"));
|
|
40
|
+
*
|
|
41
|
+
* expect(await appPromise).toBe("started");
|
|
33
42
|
* ```
|
|
34
43
|
*/
|
|
35
44
|
export function createRun(): DisposableRun;
|
|
45
|
+
|
|
46
|
+
/** Creates a root {@link Run} for React Native with custom dependencies. */
|
|
36
47
|
export function createRun<D extends object>(
|
|
37
48
|
deps: RunCustomDeps<D>,
|
|
38
49
|
): DisposableRun<D>;
|
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
* Public entry point for Expo SQLite. Exported as
|
|
3
3
|
* "@evolu/react-native/expo-sqlite" in package.json.
|
|
4
4
|
*
|
|
5
|
-
* Use this with Expo projects
|
|
5
|
+
* Use this with Expo projects and existing React Native projects configured
|
|
6
|
+
* with Expo modules.
|
|
6
7
|
*/
|
|
7
8
|
|
|
8
9
|
import type { ConsoleDep } from "@evolu/common";
|
|
@@ -20,11 +21,3 @@ export const createEvoluDeps = (deps: Partial<ConsoleDep> = {}): EvoluDeps =>
|
|
|
20
21
|
void Expo.reloadAppAsync();
|
|
21
22
|
},
|
|
22
23
|
});
|
|
23
|
-
|
|
24
|
-
// import { createExpoDeps } from "../createExpoDeps.ts";
|
|
25
|
-
// import { createExpoSqliteDriver } from "../sqlite-drivers/createExpoSqliteDriver.ts";
|
|
26
|
-
//
|
|
27
|
-
// // eslint-disable-next-line evolu/require-pure-annotation
|
|
28
|
-
// export const { evoluReactNativeDeps, localAuth } = createExpoDeps({
|
|
29
|
-
// createSqliteDriver: createExpoSqliteDriver,
|
|
30
|
-
// });
|
package/src/shared.ts
CHANGED
|
@@ -82,52 +82,3 @@ export const createEvoluDeps = (
|
|
|
82
82
|
sharedWorker,
|
|
83
83
|
});
|
|
84
84
|
};
|
|
85
|
-
|
|
86
|
-
// TODO: Reimplement local auth for React Native from scratch.
|
|
87
|
-
// export const createSharedLocalAuth = (
|
|
88
|
-
// secureStorage: SecureStorage,
|
|
89
|
-
// ): LocalAuth =>
|
|
90
|
-
// createLocalAuth({
|
|
91
|
-
// randomBytes,
|
|
92
|
-
// secureStorage,
|
|
93
|
-
// });
|
|
94
|
-
|
|
95
|
-
// import {
|
|
96
|
-
// createConsole,
|
|
97
|
-
// createLocalAuth,
|
|
98
|
-
// createRandomBytes,
|
|
99
|
-
// type CreateSqliteDriverDep,
|
|
100
|
-
// type LocalAuth,
|
|
101
|
-
// type ReloadAppDep,
|
|
102
|
-
// type SecureStorage,
|
|
103
|
-
// } from "@evolu/common";
|
|
104
|
-
// import type {
|
|
105
|
-
// // createDbWorkerForPlatform,
|
|
106
|
-
// // createDbWorkerForPlatform,
|
|
107
|
-
// EvoluDeps,
|
|
108
|
-
// } from "@evolu/common/local-first";
|
|
109
|
-
//
|
|
110
|
-
// const _console = createConsole();
|
|
111
|
-
// const randomBytes = createRandomBytes();
|
|
112
|
-
//
|
|
113
|
-
// export const createSharedEvoluDeps = (
|
|
114
|
-
// _deps: CreateSqliteDriverDep & ReloadAppDep,
|
|
115
|
-
// ): EvoluDeps => {
|
|
116
|
-
// throw new Error("todo");
|
|
117
|
-
// };
|
|
118
|
-
//
|
|
119
|
-
// ({
|
|
120
|
-
// ...deps,
|
|
121
|
-
// console,
|
|
122
|
-
// sharedWorker: "TODO" as never,
|
|
123
|
-
// // createDbWorker: () =>
|
|
124
|
-
// // createDbWorkerForPlatform({
|
|
125
|
-
// // ...deps,
|
|
126
|
-
// // console,
|
|
127
|
-
// // createWebSocket,
|
|
128
|
-
// // random: createRandom(),
|
|
129
|
-
// // randomBytes,
|
|
130
|
-
// // time: createTime(),
|
|
131
|
-
// // }),
|
|
132
|
-
// randomBytes,
|
|
133
|
-
// });
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
//# sourceMappingURL=createExpoDeps.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"createExpoDeps.d.ts","sourceRoot":"","sources":["../../src/createExpoDeps.ts"],"names":[],"mappings":""}
|
|
@@ -1,163 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// import type {
|
|
3
|
-
// AccessControl,
|
|
4
|
-
// LocalAuthOptions,
|
|
5
|
-
// SecureStorage,
|
|
6
|
-
// SensitiveInfoItem,
|
|
7
|
-
// StorageMetadata,
|
|
8
|
-
// } from "@evolu/common";
|
|
9
|
-
// import {
|
|
10
|
-
// type CreateSqliteDriverDep,
|
|
11
|
-
// type LocalAuth,
|
|
12
|
-
// localAuthDefaultOptions,
|
|
13
|
-
// type ReloadApp,
|
|
14
|
-
// } from "@evolu/common";
|
|
15
|
-
// import type { EvoluDeps } from "@evolu/common/local-first";
|
|
16
|
-
// import * as Expo from "expo";
|
|
17
|
-
// import * as SecureStore from "expo-secure-store";
|
|
18
|
-
// import KVStore from "expo-sqlite/kv-store";
|
|
19
|
-
// import { createSharedEvoluDeps, createSharedLocalAuth } from "./shared.ts";
|
|
20
|
-
// const reloadApp: ReloadApp = () => {
|
|
21
|
-
// void Expo.reloadAppAsync();
|
|
22
|
-
// };
|
|
23
|
-
//
|
|
24
|
-
// const createSecureStore = (): SecureStorage => {
|
|
25
|
-
// const store: SecureStorage = {
|
|
26
|
-
// setItem: async (key, value, options) => {
|
|
27
|
-
// const rnsiOpts = convertOptions(options);
|
|
28
|
-
// const service = options?.service ?? "default";
|
|
29
|
-
// const metadata = createMetadata(options?.accessControl === "none");
|
|
30
|
-
// await KVStore.setItem(`${service}-${key}`, "1");
|
|
31
|
-
// await SecureStore.setItemAsync(
|
|
32
|
-
// key,
|
|
33
|
-
// JSON.stringify({ value, metadata }),
|
|
34
|
-
// rnsiOpts,
|
|
35
|
-
// );
|
|
36
|
-
// return { metadata };
|
|
37
|
-
// },
|
|
38
|
-
//
|
|
39
|
-
// getItem: async (key, options) => {
|
|
40
|
-
// const rnsiOpts = convertOptions(options);
|
|
41
|
-
// const service = options?.service ?? "default";
|
|
42
|
-
// let data: { value: string; metadata: StorageMetadata };
|
|
43
|
-
// try {
|
|
44
|
-
// const result = await SecureStore.getItemAsync(key, rnsiOpts);
|
|
45
|
-
// if (!result) return null;
|
|
46
|
-
// data = JSON.parse(result) as {
|
|
47
|
-
// value: string;
|
|
48
|
-
// metadata: StorageMetadata;
|
|
49
|
-
// };
|
|
50
|
-
// } catch (_error) {
|
|
51
|
-
// return null;
|
|
52
|
-
// }
|
|
53
|
-
// return { key, service, ...data };
|
|
54
|
-
// },
|
|
55
|
-
//
|
|
56
|
-
// deleteItem: async (key, options) => {
|
|
57
|
-
// const rnsiOpts = convertOptions(options);
|
|
58
|
-
// const service = options?.service ?? "default";
|
|
59
|
-
// await Promise.all([
|
|
60
|
-
// KVStore.removeItemAsync(`${service}-${key}`),
|
|
61
|
-
// SecureStore.deleteItemAsync(key, rnsiOpts),
|
|
62
|
-
// ]);
|
|
63
|
-
// return true;
|
|
64
|
-
// },
|
|
65
|
-
//
|
|
66
|
-
// getAllItems: async (options) => {
|
|
67
|
-
// const keys = await KVStore.getAllKeysAsync();
|
|
68
|
-
// const service = options?.service ?? "default";
|
|
69
|
-
// const metadata = createMetadata(options?.accessControl === "none");
|
|
70
|
-
// return keys
|
|
71
|
-
// .filter((key) => key.startsWith(`${service}-`))
|
|
72
|
-
// .map((key) => ({
|
|
73
|
-
// key: key.slice(service.length + 1),
|
|
74
|
-
// service,
|
|
75
|
-
// metadata,
|
|
76
|
-
// }));
|
|
77
|
-
// },
|
|
78
|
-
//
|
|
79
|
-
// clearService: async (options) => {
|
|
80
|
-
// const rnsiOpts = convertOptions(options);
|
|
81
|
-
// const service = options?.service ?? "default";
|
|
82
|
-
// const items = await store.getAllItems(options);
|
|
83
|
-
// await KVStore.multiRemove(items.map((item) => `${service}-${item.key}`));
|
|
84
|
-
// await Promise.all(
|
|
85
|
-
// items.map(async (item) => {
|
|
86
|
-
// await SecureStore.deleteItemAsync(item.key, rnsiOpts);
|
|
87
|
-
// }),
|
|
88
|
-
// );
|
|
89
|
-
// },
|
|
90
|
-
// };
|
|
91
|
-
//
|
|
92
|
-
// return store;
|
|
93
|
-
// };
|
|
94
|
-
// /**
|
|
95
|
-
// * Create default metadata for backwards compatibility with items that don't
|
|
96
|
-
// * have stored metadata.
|
|
97
|
-
// */
|
|
98
|
-
// const createMetadata = (isSecure = true): SensitiveInfoItem["metadata"] => ({
|
|
99
|
-
// backend: "keychain",
|
|
100
|
-
// accessControl: isSecure ? "biometryCurrentSet" : "none",
|
|
101
|
-
// securityLevel: isSecure ? "biometry" : "software",
|
|
102
|
-
// timestamp: Date.now(),
|
|
103
|
-
// });
|
|
104
|
-
//
|
|
105
|
-
// const convertOptions = (
|
|
106
|
-
// options?: LocalAuthOptions,
|
|
107
|
-
// ): SecureStore.SecureStoreOptions => {
|
|
108
|
-
// const accessGroup =
|
|
109
|
-
// options?.keychainGroup ?? localAuthDefaultOptions.keychainGroup ?? "";
|
|
110
|
-
// const keychainService =
|
|
111
|
-
// options?.service ?? localAuthDefaultOptions.service ?? "";
|
|
112
|
-
// const keychainAccessible = convertKeychainAccessible(
|
|
113
|
-
// options?.accessControl ??
|
|
114
|
-
// localAuthDefaultOptions.accessControl ??
|
|
115
|
-
// "biometryCurrentSet",
|
|
116
|
-
// );
|
|
117
|
-
// const authenticationPrompt =
|
|
118
|
-
// options?.authenticationPrompt?.title ??
|
|
119
|
-
// localAuthDefaultOptions.authenticationPrompt?.title ??
|
|
120
|
-
// "";
|
|
121
|
-
// return {
|
|
122
|
-
// accessGroup,
|
|
123
|
-
// keychainService,
|
|
124
|
-
// keychainAccessible,
|
|
125
|
-
// authenticationPrompt,
|
|
126
|
-
// requireAuthentication: options?.accessControl !== "none",
|
|
127
|
-
// };
|
|
128
|
-
// };
|
|
129
|
-
//
|
|
130
|
-
// const convertKeychainAccessible = (
|
|
131
|
-
// accessControl: AccessControl,
|
|
132
|
-
// ): SecureStore.KeychainAccessibilityConstant => {
|
|
133
|
-
// switch (accessControl) {
|
|
134
|
-
// case "none":
|
|
135
|
-
// // eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
136
|
-
// return SecureStore.ALWAYS;
|
|
137
|
-
// case "biometryCurrentSet":
|
|
138
|
-
// return SecureStore.AFTER_FIRST_UNLOCK;
|
|
139
|
-
// case "biometryAny":
|
|
140
|
-
// return SecureStore.AFTER_FIRST_UNLOCK;
|
|
141
|
-
// case "devicePasscode":
|
|
142
|
-
// return SecureStore.AFTER_FIRST_UNLOCK;
|
|
143
|
-
// case "secureEnclaveBiometry":
|
|
144
|
-
// return SecureStore.AFTER_FIRST_UNLOCK;
|
|
145
|
-
// // Exhaustive check
|
|
146
|
-
// default:
|
|
147
|
-
// accessControl satisfies never;
|
|
148
|
-
// // Default (for typescript, should never hit)
|
|
149
|
-
// return SecureStore.AFTER_FIRST_UNLOCK;
|
|
150
|
-
// }
|
|
151
|
-
// };
|
|
152
|
-
//
|
|
153
|
-
// const localAuth = createSharedLocalAuth(createSecureStore());
|
|
154
|
-
//
|
|
155
|
-
// export const createExpoDeps = (
|
|
156
|
-
// deps: CreateSqliteDriverDep,
|
|
157
|
-
// ): { evoluReactNativeDeps: EvoluDeps; localAuth: LocalAuth } => ({
|
|
158
|
-
// evoluReactNativeDeps: createSharedEvoluDeps({
|
|
159
|
-
// ...deps,
|
|
160
|
-
// reloadApp,
|
|
161
|
-
// }),
|
|
162
|
-
// localAuth,
|
|
163
|
-
// });
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
//# sourceMappingURL=bare-op-sqlite.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"bare-op-sqlite.d.ts","sourceRoot":"","sources":["../../../src/exports/bare-op-sqlite.ts"],"names":[],"mappings":""}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// /**
|
|
3
|
-
// * Public entry point for bare React Native with OP-SQLite. Exported as
|
|
4
|
-
// * "@evolu/react-native/bare-op-sqlite" in package.json.
|
|
5
|
-
// *
|
|
6
|
-
// * Use this with bare React Native projects (not Expo) that use
|
|
7
|
-
// * `@op-engineering/op-sqlite`.
|
|
8
|
-
// */
|
|
9
|
-
//
|
|
10
|
-
// import { type ReloadApp } from "@evolu/common";
|
|
11
|
-
// import { DevSettings } from "react-native";
|
|
12
|
-
// import { SensitiveInfo } from "react-native-sensitive-info";
|
|
13
|
-
// import { createSharedEvoluDeps, createSharedLocalAuth } from "../shared.ts";
|
|
14
|
-
// import { createOpSqliteDriver } from "../sqlite-drivers/createOpSqliteDriver.ts";
|
|
15
|
-
//
|
|
16
|
-
// const reloadApp: ReloadApp = () => {
|
|
17
|
-
// if (process.env.NODE_ENV === "development") {
|
|
18
|
-
// DevSettings.reload();
|
|
19
|
-
// } else {
|
|
20
|
-
// // TODO: reload not implemented for bare rn
|
|
21
|
-
// }
|
|
22
|
-
// };
|
|
23
|
-
//
|
|
24
|
-
// // eslint-disable-next-line evolu/require-pure-annotation
|
|
25
|
-
// export const evoluReactNativeDeps = createSharedEvoluDeps({
|
|
26
|
-
// createSqliteDriver: createOpSqliteDriver,
|
|
27
|
-
// reloadApp,
|
|
28
|
-
// });
|
|
29
|
-
//
|
|
30
|
-
// // eslint-disable-next-line evolu/require-pure-annotation
|
|
31
|
-
// export const localAuth = createSharedLocalAuth(SensitiveInfo);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
//# sourceMappingURL=expo-op-sqlite.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"expo-op-sqlite.d.ts","sourceRoot":"","sources":["../../../src/exports/expo-op-sqlite.ts"],"names":[],"mappings":""}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// /**
|
|
3
|
-
// * Public entry point for Expo with OP-SQLite. Exported as
|
|
4
|
-
// * "@evolu/react-native/expo-op-sqlite" in package.json.
|
|
5
|
-
// *
|
|
6
|
-
// * Use this with Expo projects that use `@op-engineering/op-sqlite` for better
|
|
7
|
-
// * performance.
|
|
8
|
-
// */
|
|
9
|
-
//
|
|
10
|
-
// import { createExpoDeps } from "../createExpoDeps.ts";
|
|
11
|
-
// import { createOpSqliteDriver } from "../sqlite-drivers/createOpSqliteDriver.ts";
|
|
12
|
-
//
|
|
13
|
-
// // eslint-disable-next-line evolu/require-pure-annotation
|
|
14
|
-
// export const { evoluReactNativeDeps, localAuth } = createExpoDeps({
|
|
15
|
-
// createSqliteDriver: createOpSqliteDriver,
|
|
16
|
-
// });
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"createOpSqliteDriver.d.ts","sourceRoot":"","sources":["../../../src/sqlite-drivers/createOpSqliteDriver.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,kBAAkB,EAGxB,MAAM,eAAe,CAAC;AAGvB,eAAO,MAAM,oBAAoB,EAAE,kBAiEhC,CAAC"}
|
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
var __addDisposableResource = (this && this.__addDisposableResource) || function (env, value, async) {
|
|
2
|
-
if (value !== null && value !== void 0) {
|
|
3
|
-
if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
|
|
4
|
-
var dispose, inner;
|
|
5
|
-
if (async) {
|
|
6
|
-
if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined.");
|
|
7
|
-
dispose = value[Symbol.asyncDispose];
|
|
8
|
-
}
|
|
9
|
-
if (dispose === void 0) {
|
|
10
|
-
if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined.");
|
|
11
|
-
dispose = value[Symbol.dispose];
|
|
12
|
-
if (async) inner = dispose;
|
|
13
|
-
}
|
|
14
|
-
if (typeof dispose !== "function") throw new TypeError("Object not disposable.");
|
|
15
|
-
if (inner) dispose = function() { try { inner.call(this); } catch (e) { return Promise.reject(e); } };
|
|
16
|
-
env.stack.push({ value: value, dispose: dispose, async: async });
|
|
17
|
-
}
|
|
18
|
-
else if (async) {
|
|
19
|
-
env.stack.push({ async: true });
|
|
20
|
-
}
|
|
21
|
-
return value;
|
|
22
|
-
};
|
|
23
|
-
var __disposeResources = (this && this.__disposeResources) || (function (SuppressedError) {
|
|
24
|
-
return function (env) {
|
|
25
|
-
function fail(e) {
|
|
26
|
-
env.error = env.hasError ? new SuppressedError(e, env.error, "An error was suppressed during disposal.") : e;
|
|
27
|
-
env.hasError = true;
|
|
28
|
-
}
|
|
29
|
-
var r, s = 0;
|
|
30
|
-
function next() {
|
|
31
|
-
while (r = env.stack.pop()) {
|
|
32
|
-
try {
|
|
33
|
-
if (!r.async && s === 1) return s = 0, env.stack.push(r), Promise.resolve().then(next);
|
|
34
|
-
if (r.dispose) {
|
|
35
|
-
var result = r.dispose.call(r.value);
|
|
36
|
-
if (r.async) return s |= 2, Promise.resolve(result).then(next, function(e) { fail(e); return next(); });
|
|
37
|
-
}
|
|
38
|
-
else s |= 1;
|
|
39
|
-
}
|
|
40
|
-
catch (e) {
|
|
41
|
-
fail(e);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
if (s === 1) return env.hasError ? Promise.reject(env.error) : Promise.resolve();
|
|
45
|
-
if (env.hasError) throw env.error;
|
|
46
|
-
}
|
|
47
|
-
return next();
|
|
48
|
-
};
|
|
49
|
-
})(typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
50
|
-
var e = new Error(message);
|
|
51
|
-
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
52
|
-
});
|
|
53
|
-
import { constVoid, bytesToHex, createPreparedStatementsCache, ok, } from "@evolu/common";
|
|
54
|
-
import { open } from "@op-engineering/op-sqlite";
|
|
55
|
-
export const createOpSqliteDriver = (name, options) => () => {
|
|
56
|
-
const env_1 = { stack: [], error: void 0, hasError: false };
|
|
57
|
-
try {
|
|
58
|
-
// https://op-engineering.github.io/op-sqlite/docs/configuration#in-memory
|
|
59
|
-
const disposer = __addDisposableResource(env_1, new DisposableStack(), false);
|
|
60
|
-
const db = disposer.adopt(open(options?.mode === "memory"
|
|
61
|
-
? { name: `inMemoryDb`, location: ":memory:" }
|
|
62
|
-
: {
|
|
63
|
-
name: `evolu1-${name}.db`,
|
|
64
|
-
...(options?.mode === "encrypted" && {
|
|
65
|
-
encryptionKey: `x'${bytesToHex(options.encryptionKey)}'`,
|
|
66
|
-
}),
|
|
67
|
-
}), (db) => {
|
|
68
|
-
db.close();
|
|
69
|
-
});
|
|
70
|
-
const cache = disposer.use(createPreparedStatementsCache((sql) => db.prepareStatement(sql),
|
|
71
|
-
// op-sqlite doesn't have API for that
|
|
72
|
-
constVoid));
|
|
73
|
-
const disposables = disposer.move();
|
|
74
|
-
return ok({
|
|
75
|
-
exec: (query) => {
|
|
76
|
-
const prepared = cache.get(query);
|
|
77
|
-
if (prepared) {
|
|
78
|
-
prepared.bindSync(query.parameters);
|
|
79
|
-
}
|
|
80
|
-
const { rows, rowsAffected } = db.executeSync(query.sql, query.parameters);
|
|
81
|
-
return { rows: rows, changes: rowsAffected };
|
|
82
|
-
},
|
|
83
|
-
// FIXME: op-sqlite does not expose binary, but a path to the database file
|
|
84
|
-
// another react native dependency would be needed to implement this
|
|
85
|
-
export: () => {
|
|
86
|
-
throw new Error("TODO: Not implemented yet");
|
|
87
|
-
},
|
|
88
|
-
deleteDatabase: () => {
|
|
89
|
-
const env_2 = { stack: [], error: void 0, hasError: false };
|
|
90
|
-
try {
|
|
91
|
-
const deleteDisposer = __addDisposableResource(env_2, new DisposableStack(), false);
|
|
92
|
-
if (options?.mode !== "memory") {
|
|
93
|
-
deleteDisposer.defer(() => {
|
|
94
|
-
db.delete();
|
|
95
|
-
});
|
|
96
|
-
}
|
|
97
|
-
deleteDisposer.use(disposables);
|
|
98
|
-
}
|
|
99
|
-
catch (e_2) {
|
|
100
|
-
env_2.error = e_2;
|
|
101
|
-
env_2.hasError = true;
|
|
102
|
-
}
|
|
103
|
-
finally {
|
|
104
|
-
__disposeResources(env_2);
|
|
105
|
-
}
|
|
106
|
-
},
|
|
107
|
-
[Symbol.dispose]: () => {
|
|
108
|
-
disposables.dispose();
|
|
109
|
-
},
|
|
110
|
-
});
|
|
111
|
-
}
|
|
112
|
-
catch (e_1) {
|
|
113
|
-
env_1.error = e_1;
|
|
114
|
-
env_1.hasError = true;
|
|
115
|
-
}
|
|
116
|
-
finally {
|
|
117
|
-
__disposeResources(env_1);
|
|
118
|
-
}
|
|
119
|
-
};
|
package/src/createExpoDeps.ts
DELETED
|
@@ -1,164 +0,0 @@
|
|
|
1
|
-
// import type {
|
|
2
|
-
// AccessControl,
|
|
3
|
-
// LocalAuthOptions,
|
|
4
|
-
// SecureStorage,
|
|
5
|
-
// SensitiveInfoItem,
|
|
6
|
-
// StorageMetadata,
|
|
7
|
-
// } from "@evolu/common";
|
|
8
|
-
// import {
|
|
9
|
-
// type CreateSqliteDriverDep,
|
|
10
|
-
// type LocalAuth,
|
|
11
|
-
// localAuthDefaultOptions,
|
|
12
|
-
// type ReloadApp,
|
|
13
|
-
// } from "@evolu/common";
|
|
14
|
-
// import type { EvoluDeps } from "@evolu/common/local-first";
|
|
15
|
-
// import * as Expo from "expo";
|
|
16
|
-
// import * as SecureStore from "expo-secure-store";
|
|
17
|
-
// import KVStore from "expo-sqlite/kv-store";
|
|
18
|
-
// import { createSharedEvoluDeps, createSharedLocalAuth } from "./shared.ts";
|
|
19
|
-
|
|
20
|
-
// const reloadApp: ReloadApp = () => {
|
|
21
|
-
// void Expo.reloadAppAsync();
|
|
22
|
-
// };
|
|
23
|
-
//
|
|
24
|
-
// const createSecureStore = (): SecureStorage => {
|
|
25
|
-
// const store: SecureStorage = {
|
|
26
|
-
// setItem: async (key, value, options) => {
|
|
27
|
-
// const rnsiOpts = convertOptions(options);
|
|
28
|
-
// const service = options?.service ?? "default";
|
|
29
|
-
// const metadata = createMetadata(options?.accessControl === "none");
|
|
30
|
-
// await KVStore.setItem(`${service}-${key}`, "1");
|
|
31
|
-
// await SecureStore.setItemAsync(
|
|
32
|
-
// key,
|
|
33
|
-
// JSON.stringify({ value, metadata }),
|
|
34
|
-
// rnsiOpts,
|
|
35
|
-
// );
|
|
36
|
-
// return { metadata };
|
|
37
|
-
// },
|
|
38
|
-
//
|
|
39
|
-
// getItem: async (key, options) => {
|
|
40
|
-
// const rnsiOpts = convertOptions(options);
|
|
41
|
-
// const service = options?.service ?? "default";
|
|
42
|
-
// let data: { value: string; metadata: StorageMetadata };
|
|
43
|
-
// try {
|
|
44
|
-
// const result = await SecureStore.getItemAsync(key, rnsiOpts);
|
|
45
|
-
// if (!result) return null;
|
|
46
|
-
// data = JSON.parse(result) as {
|
|
47
|
-
// value: string;
|
|
48
|
-
// metadata: StorageMetadata;
|
|
49
|
-
// };
|
|
50
|
-
// } catch (_error) {
|
|
51
|
-
// return null;
|
|
52
|
-
// }
|
|
53
|
-
// return { key, service, ...data };
|
|
54
|
-
// },
|
|
55
|
-
//
|
|
56
|
-
// deleteItem: async (key, options) => {
|
|
57
|
-
// const rnsiOpts = convertOptions(options);
|
|
58
|
-
// const service = options?.service ?? "default";
|
|
59
|
-
// await Promise.all([
|
|
60
|
-
// KVStore.removeItemAsync(`${service}-${key}`),
|
|
61
|
-
// SecureStore.deleteItemAsync(key, rnsiOpts),
|
|
62
|
-
// ]);
|
|
63
|
-
// return true;
|
|
64
|
-
// },
|
|
65
|
-
//
|
|
66
|
-
// getAllItems: async (options) => {
|
|
67
|
-
// const keys = await KVStore.getAllKeysAsync();
|
|
68
|
-
// const service = options?.service ?? "default";
|
|
69
|
-
// const metadata = createMetadata(options?.accessControl === "none");
|
|
70
|
-
// return keys
|
|
71
|
-
// .filter((key) => key.startsWith(`${service}-`))
|
|
72
|
-
// .map((key) => ({
|
|
73
|
-
// key: key.slice(service.length + 1),
|
|
74
|
-
// service,
|
|
75
|
-
// metadata,
|
|
76
|
-
// }));
|
|
77
|
-
// },
|
|
78
|
-
//
|
|
79
|
-
// clearService: async (options) => {
|
|
80
|
-
// const rnsiOpts = convertOptions(options);
|
|
81
|
-
// const service = options?.service ?? "default";
|
|
82
|
-
// const items = await store.getAllItems(options);
|
|
83
|
-
// await KVStore.multiRemove(items.map((item) => `${service}-${item.key}`));
|
|
84
|
-
// await Promise.all(
|
|
85
|
-
// items.map(async (item) => {
|
|
86
|
-
// await SecureStore.deleteItemAsync(item.key, rnsiOpts);
|
|
87
|
-
// }),
|
|
88
|
-
// );
|
|
89
|
-
// },
|
|
90
|
-
// };
|
|
91
|
-
//
|
|
92
|
-
// return store;
|
|
93
|
-
// };
|
|
94
|
-
|
|
95
|
-
// /**
|
|
96
|
-
// * Create default metadata for backwards compatibility with items that don't
|
|
97
|
-
// * have stored metadata.
|
|
98
|
-
// */
|
|
99
|
-
// const createMetadata = (isSecure = true): SensitiveInfoItem["metadata"] => ({
|
|
100
|
-
// backend: "keychain",
|
|
101
|
-
// accessControl: isSecure ? "biometryCurrentSet" : "none",
|
|
102
|
-
// securityLevel: isSecure ? "biometry" : "software",
|
|
103
|
-
// timestamp: Date.now(),
|
|
104
|
-
// });
|
|
105
|
-
//
|
|
106
|
-
// const convertOptions = (
|
|
107
|
-
// options?: LocalAuthOptions,
|
|
108
|
-
// ): SecureStore.SecureStoreOptions => {
|
|
109
|
-
// const accessGroup =
|
|
110
|
-
// options?.keychainGroup ?? localAuthDefaultOptions.keychainGroup ?? "";
|
|
111
|
-
// const keychainService =
|
|
112
|
-
// options?.service ?? localAuthDefaultOptions.service ?? "";
|
|
113
|
-
// const keychainAccessible = convertKeychainAccessible(
|
|
114
|
-
// options?.accessControl ??
|
|
115
|
-
// localAuthDefaultOptions.accessControl ??
|
|
116
|
-
// "biometryCurrentSet",
|
|
117
|
-
// );
|
|
118
|
-
// const authenticationPrompt =
|
|
119
|
-
// options?.authenticationPrompt?.title ??
|
|
120
|
-
// localAuthDefaultOptions.authenticationPrompt?.title ??
|
|
121
|
-
// "";
|
|
122
|
-
// return {
|
|
123
|
-
// accessGroup,
|
|
124
|
-
// keychainService,
|
|
125
|
-
// keychainAccessible,
|
|
126
|
-
// authenticationPrompt,
|
|
127
|
-
// requireAuthentication: options?.accessControl !== "none",
|
|
128
|
-
// };
|
|
129
|
-
// };
|
|
130
|
-
//
|
|
131
|
-
// const convertKeychainAccessible = (
|
|
132
|
-
// accessControl: AccessControl,
|
|
133
|
-
// ): SecureStore.KeychainAccessibilityConstant => {
|
|
134
|
-
// switch (accessControl) {
|
|
135
|
-
// case "none":
|
|
136
|
-
// // eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
137
|
-
// return SecureStore.ALWAYS;
|
|
138
|
-
// case "biometryCurrentSet":
|
|
139
|
-
// return SecureStore.AFTER_FIRST_UNLOCK;
|
|
140
|
-
// case "biometryAny":
|
|
141
|
-
// return SecureStore.AFTER_FIRST_UNLOCK;
|
|
142
|
-
// case "devicePasscode":
|
|
143
|
-
// return SecureStore.AFTER_FIRST_UNLOCK;
|
|
144
|
-
// case "secureEnclaveBiometry":
|
|
145
|
-
// return SecureStore.AFTER_FIRST_UNLOCK;
|
|
146
|
-
// // Exhaustive check
|
|
147
|
-
// default:
|
|
148
|
-
// accessControl satisfies never;
|
|
149
|
-
// // Default (for typescript, should never hit)
|
|
150
|
-
// return SecureStore.AFTER_FIRST_UNLOCK;
|
|
151
|
-
// }
|
|
152
|
-
// };
|
|
153
|
-
//
|
|
154
|
-
// const localAuth = createSharedLocalAuth(createSecureStore());
|
|
155
|
-
//
|
|
156
|
-
// export const createExpoDeps = (
|
|
157
|
-
// deps: CreateSqliteDriverDep,
|
|
158
|
-
// ): { evoluReactNativeDeps: EvoluDeps; localAuth: LocalAuth } => ({
|
|
159
|
-
// evoluReactNativeDeps: createSharedEvoluDeps({
|
|
160
|
-
// ...deps,
|
|
161
|
-
// reloadApp,
|
|
162
|
-
// }),
|
|
163
|
-
// localAuth,
|
|
164
|
-
// });
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
// /**
|
|
2
|
-
// * Public entry point for bare React Native with OP-SQLite. Exported as
|
|
3
|
-
// * "@evolu/react-native/bare-op-sqlite" in package.json.
|
|
4
|
-
// *
|
|
5
|
-
// * Use this with bare React Native projects (not Expo) that use
|
|
6
|
-
// * `@op-engineering/op-sqlite`.
|
|
7
|
-
// */
|
|
8
|
-
//
|
|
9
|
-
// import { type ReloadApp } from "@evolu/common";
|
|
10
|
-
// import { DevSettings } from "react-native";
|
|
11
|
-
// import { SensitiveInfo } from "react-native-sensitive-info";
|
|
12
|
-
// import { createSharedEvoluDeps, createSharedLocalAuth } from "../shared.ts";
|
|
13
|
-
// import { createOpSqliteDriver } from "../sqlite-drivers/createOpSqliteDriver.ts";
|
|
14
|
-
//
|
|
15
|
-
// const reloadApp: ReloadApp = () => {
|
|
16
|
-
// if (process.env.NODE_ENV === "development") {
|
|
17
|
-
// DevSettings.reload();
|
|
18
|
-
// } else {
|
|
19
|
-
// // TODO: reload not implemented for bare rn
|
|
20
|
-
// }
|
|
21
|
-
// };
|
|
22
|
-
//
|
|
23
|
-
// // eslint-disable-next-line evolu/require-pure-annotation
|
|
24
|
-
// export const evoluReactNativeDeps = createSharedEvoluDeps({
|
|
25
|
-
// createSqliteDriver: createOpSqliteDriver,
|
|
26
|
-
// reloadApp,
|
|
27
|
-
// });
|
|
28
|
-
//
|
|
29
|
-
// // eslint-disable-next-line evolu/require-pure-annotation
|
|
30
|
-
// export const localAuth = createSharedLocalAuth(SensitiveInfo);
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
// /**
|
|
2
|
-
// * Public entry point for Expo with OP-SQLite. Exported as
|
|
3
|
-
// * "@evolu/react-native/expo-op-sqlite" in package.json.
|
|
4
|
-
// *
|
|
5
|
-
// * Use this with Expo projects that use `@op-engineering/op-sqlite` for better
|
|
6
|
-
// * performance.
|
|
7
|
-
// */
|
|
8
|
-
//
|
|
9
|
-
// import { createExpoDeps } from "../createExpoDeps.ts";
|
|
10
|
-
// import { createOpSqliteDriver } from "../sqlite-drivers/createOpSqliteDriver.ts";
|
|
11
|
-
//
|
|
12
|
-
// // eslint-disable-next-line evolu/require-pure-annotation
|
|
13
|
-
// export const { evoluReactNativeDeps, localAuth } = createExpoDeps({
|
|
14
|
-
// createSqliteDriver: createOpSqliteDriver,
|
|
15
|
-
// });
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
constVoid,
|
|
3
|
-
bytesToHex,
|
|
4
|
-
createPreparedStatementsCache,
|
|
5
|
-
type CreateSqliteDriver,
|
|
6
|
-
ok,
|
|
7
|
-
type SqliteRow,
|
|
8
|
-
} from "@evolu/common";
|
|
9
|
-
import { open, type PreparedStatement } from "@op-engineering/op-sqlite";
|
|
10
|
-
|
|
11
|
-
export const createOpSqliteDriver: CreateSqliteDriver =
|
|
12
|
-
(name, options) => () => {
|
|
13
|
-
// https://op-engineering.github.io/op-sqlite/docs/configuration#in-memory
|
|
14
|
-
using disposer = new DisposableStack();
|
|
15
|
-
const db = disposer.adopt(
|
|
16
|
-
open(
|
|
17
|
-
options?.mode === "memory"
|
|
18
|
-
? { name: `inMemoryDb`, location: ":memory:" }
|
|
19
|
-
: {
|
|
20
|
-
name: `evolu1-${name}.db`,
|
|
21
|
-
...(options?.mode === "encrypted" && {
|
|
22
|
-
encryptionKey: `x'${bytesToHex(options.encryptionKey)}'`,
|
|
23
|
-
}),
|
|
24
|
-
},
|
|
25
|
-
),
|
|
26
|
-
(db) => {
|
|
27
|
-
db.close();
|
|
28
|
-
},
|
|
29
|
-
);
|
|
30
|
-
|
|
31
|
-
const cache = disposer.use(
|
|
32
|
-
createPreparedStatementsCache<PreparedStatement>(
|
|
33
|
-
(sql) => db.prepareStatement(sql),
|
|
34
|
-
// op-sqlite doesn't have API for that
|
|
35
|
-
constVoid,
|
|
36
|
-
),
|
|
37
|
-
);
|
|
38
|
-
|
|
39
|
-
const disposables = disposer.move();
|
|
40
|
-
|
|
41
|
-
return ok({
|
|
42
|
-
exec: (query) => {
|
|
43
|
-
const prepared = cache.get(query);
|
|
44
|
-
|
|
45
|
-
if (prepared) {
|
|
46
|
-
prepared.bindSync(query.parameters);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
const { rows, rowsAffected } = db.executeSync(
|
|
50
|
-
query.sql,
|
|
51
|
-
query.parameters,
|
|
52
|
-
);
|
|
53
|
-
return { rows: rows as Array<SqliteRow>, changes: rowsAffected };
|
|
54
|
-
},
|
|
55
|
-
|
|
56
|
-
// FIXME: op-sqlite does not expose binary, but a path to the database file
|
|
57
|
-
// another react native dependency would be needed to implement this
|
|
58
|
-
export: () => {
|
|
59
|
-
throw new Error("TODO: Not implemented yet");
|
|
60
|
-
},
|
|
61
|
-
|
|
62
|
-
deleteDatabase: () => {
|
|
63
|
-
using deleteDisposer = new DisposableStack();
|
|
64
|
-
if (options?.mode !== "memory") {
|
|
65
|
-
deleteDisposer.defer(() => {
|
|
66
|
-
db.delete();
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
deleteDisposer.use(disposables);
|
|
70
|
-
},
|
|
71
|
-
|
|
72
|
-
[Symbol.dispose]: () => {
|
|
73
|
-
disposables.dispose();
|
|
74
|
-
},
|
|
75
|
-
});
|
|
76
|
-
};
|