@evolu/react-native 6.0.2 → 7.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/PlatformLive.d.ts +2 -1
- package/dist/PlatformLive.d.ts.map +1 -1
- package/dist/PlatformLive.js +7 -1
- package/dist/SqliteLive.d.ts +2 -2
- package/dist/SqliteLive.d.ts.map +1 -1
- package/dist/SqliteLive.js +26 -22
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -3
- package/package.json +4 -4
- package/src/PlatformLive.ts +11 -0
- package/src/SqliteLive.ts +34 -27
- package/src/index.ts +12 -5
package/dist/PlatformLive.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { AppState, Bip39, PlatformName, SyncLock } from "@evolu/common";
|
|
1
|
+
import { AppState, Bip39, DbWorkerLock, PlatformName, SyncLock } from "@evolu/common";
|
|
2
2
|
import * as Layer from "effect/Layer";
|
|
3
3
|
export declare const PlatformNameLive: Layer.Layer<PlatformName, never, never>;
|
|
4
4
|
export declare const SyncLockLive: Layer.Layer<SyncLock, never, never>;
|
|
5
|
+
export declare const DbWorkerLockLive: Layer.Layer<DbWorkerLock, never, never>;
|
|
5
6
|
export declare const AppStateLive: Layer.Layer<AppState, never, never>;
|
|
6
7
|
export declare const Bip39Live: Layer.Layer<Bip39, never, never>;
|
|
7
8
|
//# sourceMappingURL=PlatformLive.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PlatformLive.d.ts","sourceRoot":"","sources":["../src/PlatformLive.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EACR,KAAK,
|
|
1
|
+
{"version":3,"file":"PlatformLive.d.ts","sourceRoot":"","sources":["../src/PlatformLive.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EACR,KAAK,EACL,YAAY,EAGZ,YAAY,EACZ,QAAQ,EACT,MAAM,eAAe,CAAC;AASvB,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AAItC,eAAO,MAAM,gBAAgB,yCAA8C,CAAC;AAE5E,eAAO,MAAM,YAAY,qCAexB,CAAC;AAEF,eAAO,MAAM,gBAAgB,yCAQ5B,CAAC;AAEF,eAAO,MAAM,YAAY,qCA4BxB,CAAC;AAEF,eAAO,MAAM,SAAS,kCAYrB,CAAC"}
|
package/dist/PlatformLive.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AppState, Bip39, PlatformName, SyncLock, } from "@evolu/common";
|
|
1
|
+
import { AppState, Bip39, DbWorkerLock, PlatformName, SyncLock, } from "@evolu/common";
|
|
2
2
|
import NetInfo from "@react-native-community/netinfo";
|
|
3
3
|
import { generateMnemonic, mnemonicToSeed, validateMnemonic, } from "@scure/bip39";
|
|
4
4
|
import { wordlist } from "@scure/bip39/wordlists/english";
|
|
@@ -21,6 +21,12 @@ export const SyncLockLive = Layer.effect(SyncLock, Effect.sync(() => {
|
|
|
21
21
|
}),
|
|
22
22
|
});
|
|
23
23
|
}));
|
|
24
|
+
export const DbWorkerLockLive = Layer.effect(DbWorkerLock, Effect.sync(() => {
|
|
25
|
+
let queue = Promise.resolve(undefined);
|
|
26
|
+
return DbWorkerLock.of((callback) => {
|
|
27
|
+
queue = queue.then(callback);
|
|
28
|
+
});
|
|
29
|
+
}));
|
|
24
30
|
export const AppStateLive = Layer.succeed(AppState, AppState.of({
|
|
25
31
|
init: ({ onRequestSync }) => {
|
|
26
32
|
let appStateStatus = ReactNativeAppState.currentState;
|
package/dist/SqliteLive.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Sqlite } from "@evolu/common";
|
|
1
|
+
import { Config, Sqlite } from "@evolu/common";
|
|
2
2
|
import * as Layer from "effect/Layer";
|
|
3
|
-
export declare const SqliteLive: Layer.Layer<Sqlite, never,
|
|
3
|
+
export declare const SqliteLive: Layer.Layer<Sqlite, never, Config>;
|
|
4
4
|
//# sourceMappingURL=SqliteLive.d.ts.map
|
package/dist/SqliteLive.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SqliteLive.d.ts","sourceRoot":"","sources":["../src/SqliteLive.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,MAAM,EAKP,MAAM,eAAe,CAAC;AAEvB,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"SqliteLive.d.ts","sourceRoot":"","sources":["../src/SqliteLive.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,MAAM,EACN,MAAM,EAKP,MAAM,eAAe,CAAC;AAEvB,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AAGtC,eAAO,MAAM,UAAU,oCAmCtB,CAAC"}
|
package/dist/SqliteLive.js
CHANGED
|
@@ -1,24 +1,28 @@
|
|
|
1
|
-
import { Sqlite, ensureSqliteQuery, maybeParseJson, valuesToSqliteValues, } from "@evolu/common";
|
|
1
|
+
import { Config, Sqlite, ensureSqliteQuery, maybeParseJson, valuesToSqliteValues, } from "@evolu/common";
|
|
2
2
|
import * as Effect from "effect/Effect";
|
|
3
3
|
import * as Layer from "effect/Layer";
|
|
4
|
-
import * as
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}
|
|
24
|
-
|
|
4
|
+
import * as ExpoSQLite from "expo-sqlite/next.js";
|
|
5
|
+
export const SqliteLive = Layer.effect(Sqlite, Effect.gen(function* (_) {
|
|
6
|
+
const config = yield* _(Config);
|
|
7
|
+
const db = ExpoSQLite.openDatabaseSync(`evolu1-${config.name}.db`);
|
|
8
|
+
return Sqlite.of({
|
|
9
|
+
exec: (arg) => Effect.gen(function* (_) {
|
|
10
|
+
const sqliteQuery = ensureSqliteQuery(arg);
|
|
11
|
+
const query = {
|
|
12
|
+
sql: sqliteQuery.sql,
|
|
13
|
+
args: valuesToSqliteValues(sqliteQuery.parameters),
|
|
14
|
+
};
|
|
15
|
+
const isSelectOrPragma = query.sql.trimStart().toLowerCase().startsWith("select") ||
|
|
16
|
+
query.sql.trimStart().toLowerCase().startsWith("pragma");
|
|
17
|
+
// Expo can log only strings.
|
|
18
|
+
// console.log(JSON.stringify(isSelect), sql);
|
|
19
|
+
if (isSelectOrPragma) {
|
|
20
|
+
const rows = (yield* _(Effect.promise(() => db.getAllAsync(query.sql, query.args))));
|
|
21
|
+
maybeParseJson(rows);
|
|
22
|
+
return { rows, changes: 0 };
|
|
23
|
+
}
|
|
24
|
+
const { changes } = yield* _(Effect.promise(() => db.runAsync(query.sql, query.args)));
|
|
25
|
+
return { rows: [], changes };
|
|
26
|
+
}),
|
|
27
|
+
});
|
|
28
|
+
}));
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAML,oBAAoB,EACpB,QAAQ,EAKT,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAML,oBAAoB,EACpB,QAAQ,EAKT,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAWxC,cAAc,sBAAsB,CAAC;AAErC,0CAA0C;AAC1C,eAAO,MAAM,aAAa,EAAE,CAC1B,QAAQ,EAAE,MAAM,KACb,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE,oBAAoB,CAG1C,CAAC;AAER;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,eAAO,MAAM,WAAW,+NAqBvB,CAAC;AAEF,cAAc,qBAAqB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { Bip39,
|
|
1
|
+
import { Bip39, DbWorkerCommonLive, EvoluCommonLive, FetchLive, FlushSyncDefaultLive, NanoIdGeneratorLive, SecretBoxLive, SyncWorkerCommonLive, makeCreateEvolu, } from "@evolu/common";
|
|
2
2
|
import * as Effect from "effect/Effect";
|
|
3
3
|
import * as Layer from "effect/Layer";
|
|
4
|
-
import { AppStateLive, Bip39Live, PlatformNameLive, SyncLockLive, } from "./PlatformLive.js";
|
|
4
|
+
import { AppStateLive, Bip39Live, DbWorkerLockLive, PlatformNameLive, SyncLockLive, } from "./PlatformLive.js";
|
|
5
5
|
import { SqliteLive } from "./SqliteLive.js";
|
|
6
6
|
export * from "@evolu/common/public";
|
|
7
7
|
/** Parse a string to {@link Mnemonic}. */
|
|
@@ -37,5 +37,5 @@ export const parseMnemonic = Bip39.pipe(Effect.provide(Bip39Live), Effect.runSyn
|
|
|
37
37
|
*
|
|
38
38
|
* const evolu = createEvolu(Database);
|
|
39
39
|
*/
|
|
40
|
-
export const createEvolu = makeCreateEvolu(EvoluCommonLive.pipe(Layer.provide(Layer.mergeAll(FlushSyncDefaultLive, AppStateLive,
|
|
40
|
+
export const createEvolu = makeCreateEvolu(EvoluCommonLive.pipe(Layer.provide(Layer.mergeAll(FlushSyncDefaultLive, AppStateLive, DbWorkerCommonLive, PlatformNameLive)), Layer.provide(Layer.mergeAll(Bip39Live, NanoIdGeneratorLive, SqliteLive, SyncWorkerCommonLive, DbWorkerLockLive)), Layer.provide(Layer.mergeAll(SecretBoxLive, SyncLockLive, FetchLive))));
|
|
41
41
|
export * from "@evolu/common-react";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@evolu/react-native",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "7.0.0",
|
|
4
4
|
"description": "Evolu for React Native",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"evolu",
|
|
@@ -40,13 +40,13 @@
|
|
|
40
40
|
"react-native": "0.73.4",
|
|
41
41
|
"typescript": "^5.3.3",
|
|
42
42
|
"vitest": "^1.3.1",
|
|
43
|
-
"@evolu/common": "
|
|
44
|
-
"@evolu/common-react": "
|
|
43
|
+
"@evolu/common": "4.0.0",
|
|
44
|
+
"@evolu/common-react": "6.0.0",
|
|
45
45
|
"@evolu/tsconfig": "0.0.2",
|
|
46
46
|
"eslint-config-evolu": "1.0.0"
|
|
47
47
|
},
|
|
48
48
|
"peerDependencies": {
|
|
49
|
-
"@evolu/common-react": "^
|
|
49
|
+
"@evolu/common-react": "^6.0.0",
|
|
50
50
|
"expo": "^50.0.7",
|
|
51
51
|
"expo-sqlite": "~13.2.2",
|
|
52
52
|
"react-native": "0.73.4"
|
package/src/PlatformLive.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
AppState,
|
|
3
3
|
Bip39,
|
|
4
|
+
DbWorkerLock,
|
|
4
5
|
InvalidMnemonicError,
|
|
5
6
|
Mnemonic,
|
|
6
7
|
PlatformName,
|
|
@@ -37,6 +38,16 @@ export const SyncLockLive = Layer.effect(
|
|
|
37
38
|
}),
|
|
38
39
|
);
|
|
39
40
|
|
|
41
|
+
export const DbWorkerLockLive = Layer.effect(
|
|
42
|
+
DbWorkerLock,
|
|
43
|
+
Effect.sync(() => {
|
|
44
|
+
let queue: Promise<void> = Promise.resolve(undefined);
|
|
45
|
+
return DbWorkerLock.of((callback) => {
|
|
46
|
+
queue = queue.then(callback);
|
|
47
|
+
});
|
|
48
|
+
}),
|
|
49
|
+
);
|
|
50
|
+
|
|
40
51
|
export const AppStateLive = Layer.succeed(
|
|
41
52
|
AppState,
|
|
42
53
|
AppState.of({
|
package/src/SqliteLive.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
+
Config,
|
|
2
3
|
Sqlite,
|
|
3
4
|
SqliteRow,
|
|
4
5
|
ensureSqliteQuery,
|
|
@@ -7,35 +8,41 @@ import {
|
|
|
7
8
|
} from "@evolu/common";
|
|
8
9
|
import * as Effect from "effect/Effect";
|
|
9
10
|
import * as Layer from "effect/Layer";
|
|
10
|
-
import * as
|
|
11
|
+
import * as ExpoSQLite from "expo-sqlite/next.js";
|
|
11
12
|
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
const exec: Sqlite["exec"] = (arg) =>
|
|
13
|
+
export const SqliteLive = Layer.effect(
|
|
14
|
+
Sqlite,
|
|
15
15
|
Effect.gen(function* (_) {
|
|
16
|
-
const
|
|
17
|
-
const
|
|
18
|
-
sql: sqliteQuery.sql,
|
|
19
|
-
args: valuesToSqliteValues(sqliteQuery.parameters),
|
|
20
|
-
};
|
|
16
|
+
const config = yield* _(Config);
|
|
17
|
+
const db = ExpoSQLite.openDatabaseSync(`evolu1-${config.name}.db`);
|
|
21
18
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
19
|
+
return Sqlite.of({
|
|
20
|
+
exec: (arg) =>
|
|
21
|
+
Effect.gen(function* (_) {
|
|
22
|
+
const sqliteQuery = ensureSqliteQuery(arg);
|
|
23
|
+
const query = {
|
|
24
|
+
sql: sqliteQuery.sql,
|
|
25
|
+
args: valuesToSqliteValues(sqliteQuery.parameters),
|
|
26
|
+
};
|
|
27
27
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
return { rows, changes: 0 };
|
|
34
|
-
}
|
|
35
|
-
const { changes } = yield* _(
|
|
36
|
-
Effect.promise(() => db.runAsync(query.sql, query.args)),
|
|
37
|
-
);
|
|
38
|
-
return { rows: [], changes };
|
|
39
|
-
});
|
|
28
|
+
const isSelectOrPragma =
|
|
29
|
+
query.sql.trimStart().toLowerCase().startsWith("select") ||
|
|
30
|
+
query.sql.trimStart().toLowerCase().startsWith("pragma");
|
|
31
|
+
// Expo can log only strings.
|
|
32
|
+
// console.log(JSON.stringify(isSelect), sql);
|
|
40
33
|
|
|
41
|
-
|
|
34
|
+
if (isSelectOrPragma) {
|
|
35
|
+
const rows = (yield* _(
|
|
36
|
+
Effect.promise(() => db.getAllAsync(query.sql, query.args)),
|
|
37
|
+
)) as SqliteRow[];
|
|
38
|
+
maybeParseJson(rows);
|
|
39
|
+
return { rows, changes: 0 };
|
|
40
|
+
}
|
|
41
|
+
const { changes } = yield* _(
|
|
42
|
+
Effect.promise(() => db.runAsync(query.sql, query.args)),
|
|
43
|
+
);
|
|
44
|
+
return { rows: [], changes };
|
|
45
|
+
}),
|
|
46
|
+
});
|
|
47
|
+
}),
|
|
48
|
+
);
|
package/src/index.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Bip39,
|
|
3
|
-
|
|
3
|
+
DbWorkerCommonLive,
|
|
4
4
|
EvoluCommonLive,
|
|
5
5
|
FetchLive,
|
|
6
6
|
FlushSyncDefaultLive,
|
|
7
7
|
InvalidMnemonicError,
|
|
8
8
|
Mnemonic,
|
|
9
|
-
|
|
9
|
+
NanoIdGeneratorLive,
|
|
10
10
|
SecretBoxLive,
|
|
11
|
-
|
|
11
|
+
SyncWorkerCommonLive,
|
|
12
12
|
makeCreateEvolu,
|
|
13
13
|
} from "@evolu/common";
|
|
14
14
|
import * as Effect from "effect/Effect";
|
|
@@ -16,6 +16,7 @@ import * as Layer from "effect/Layer";
|
|
|
16
16
|
import {
|
|
17
17
|
AppStateLive,
|
|
18
18
|
Bip39Live,
|
|
19
|
+
DbWorkerLockLive,
|
|
19
20
|
PlatformNameLive,
|
|
20
21
|
SyncLockLive,
|
|
21
22
|
} from "./PlatformLive.js";
|
|
@@ -68,12 +69,18 @@ export const createEvolu = makeCreateEvolu(
|
|
|
68
69
|
Layer.mergeAll(
|
|
69
70
|
FlushSyncDefaultLive,
|
|
70
71
|
AppStateLive,
|
|
71
|
-
|
|
72
|
+
DbWorkerCommonLive,
|
|
72
73
|
PlatformNameLive,
|
|
73
74
|
),
|
|
74
75
|
),
|
|
75
76
|
Layer.provide(
|
|
76
|
-
Layer.mergeAll(
|
|
77
|
+
Layer.mergeAll(
|
|
78
|
+
Bip39Live,
|
|
79
|
+
NanoIdGeneratorLive,
|
|
80
|
+
SqliteLive,
|
|
81
|
+
SyncWorkerCommonLive,
|
|
82
|
+
DbWorkerLockLive,
|
|
83
|
+
),
|
|
77
84
|
),
|
|
78
85
|
Layer.provide(Layer.mergeAll(SecretBoxLive, SyncLockLive, FetchLive)),
|
|
79
86
|
),
|