@evolu/react-native 10.0.2 → 10.1.1
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 +1 -2
- package/dist/PlatformLive.d.ts.map +1 -1
- package/dist/PlatformLive.js +1 -8
- package/dist/dbFactory.d.ts +7 -0
- package/dist/dbFactory.d.ts.map +1 -0
- package/dist/dbFactory.js +18 -0
- package/dist/{index.d.ts → index.native.d.ts} +2 -8
- package/dist/index.native.d.ts.map +1 -0
- package/dist/index.native.js +39 -0
- package/dist/index.web.d.ts +2 -0
- package/dist/index.web.d.ts.map +1 -0
- package/dist/index.web.js +1 -0
- package/package.json +6 -10
- package/src/PlatformLive.ts +0 -21
- package/src/dbFactory.ts +57 -0
- package/src/index.native.ts +43 -0
- package/src/index.web.ts +1 -0
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -56
- package/src/index.ts +0 -105
package/dist/PlatformLive.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { AppState,
|
|
1
|
+
import { AppState, SyncLock } from "@evolu/common";
|
|
2
2
|
import * as Layer from "effect/Layer";
|
|
3
3
|
export declare const AppStateLive: Layer.Layer<AppState, never, never>;
|
|
4
4
|
export declare const SyncLockLive: Layer.Layer<SyncLock, never, never>;
|
|
5
|
-
export declare const Bip39Live: Layer.Layer<Bip39, never, never>;
|
|
6
5
|
//# 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,
|
|
1
|
+
{"version":3,"file":"PlatformLive.d.ts","sourceRoot":"","sources":["../src/PlatformLive.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EACR,QAAQ,EAGT,MAAM,eAAe,CAAC;AAGvB,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AAItC,eAAO,MAAM,YAAY,qCAmCxB,CAAC;AAEF,eAAO,MAAM,YAAY,qCA2BxB,CAAC"}
|
package/dist/PlatformLive.js
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import { AppState,
|
|
1
|
+
import { AppState, SyncLock, SyncLockAlreadySyncingError, } from "@evolu/common";
|
|
2
2
|
import NetInfo from "@react-native-community/netinfo";
|
|
3
|
-
import { generateMnemonic, mnemonicToSeed, validateMnemonic, } from "@scure/bip39";
|
|
4
|
-
import { wordlist } from "@scure/bip39/wordlists/english";
|
|
5
3
|
import * as Effect from "effect/Effect";
|
|
6
4
|
import * as Layer from "effect/Layer";
|
|
7
5
|
import { reloadAsync } from "expo-updates";
|
|
@@ -56,8 +54,3 @@ export const SyncLockLive = Layer.effect(SyncLock, Effect.sync(() => {
|
|
|
56
54
|
}),
|
|
57
55
|
});
|
|
58
56
|
}));
|
|
59
|
-
export const Bip39Live = Layer.succeed(Bip39, Bip39.of({
|
|
60
|
-
make: Effect.sync(() => generateMnemonic(wordlist, 128)),
|
|
61
|
-
toSeed: (mnemonic) => Effect.promise(() => mnemonicToSeed(mnemonic)),
|
|
62
|
-
parse: (mnemonic) => validateMnemonicToEffect(validateMnemonic)(mnemonic, wordlist),
|
|
63
|
-
}));
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { EvoluFactory, SqliteFactory, SyncFactory } from "@evolu/common";
|
|
2
|
+
import * as Layer from "effect/Layer";
|
|
3
|
+
export declare const NanoIdGeneratorLive: Layer.Layer<import("@evolu/common").NanoIdGenerator, never, never>;
|
|
4
|
+
export declare const SyncFactoryLive: Layer.Layer<SyncFactory, never, never>;
|
|
5
|
+
export declare const SqliteFactoryLive: Layer.Layer<SqliteFactory, never, never>;
|
|
6
|
+
export declare const EvoluFactoryReactNative: Layer.Layer<EvoluFactory, never, never>;
|
|
7
|
+
//# sourceMappingURL=dbFactory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dbFactory.d.ts","sourceRoot":"","sources":["../src/dbFactory.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,YAAY,EAGZ,aAAa,EACb,WAAW,EAKZ,MAAM,eAAe,CAAC;AAGvB,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AAOtC,eAAO,MAAM,mBAAmB,oEAG/B,CAAC;AAEF,eAAO,MAAM,eAAe,wCAE1B,CAAC;AAEH,eAAO,MAAM,iBAAiB,0CAE5B,CAAC;AAEH,eAAO,MAAM,uBAAuB,yCAsBnC,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { DbFactory, EvoluFactory, SecretBox, Sqlite, SqliteFactory, SyncFactory, Time, createDb, createNanoIdGeneratorLive, createSync, } from "@evolu/common";
|
|
2
|
+
import * as Effect from "effect/Effect";
|
|
3
|
+
import * as Layer from "effect/Layer";
|
|
4
|
+
// @ts-expect-error https://github.com/ai/nanoid/issues/468
|
|
5
|
+
import { customAlphabet, nanoid } from "nanoid/index.browser.js";
|
|
6
|
+
import { AppStateLive, SyncLockLive } from "./PlatformLive.js";
|
|
7
|
+
import { SqliteLive } from "./SqliteLive.js";
|
|
8
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
9
|
+
export const NanoIdGeneratorLive = createNanoIdGeneratorLive(customAlphabet, nanoid);
|
|
10
|
+
export const SyncFactoryLive = Layer.succeed(SyncFactory, {
|
|
11
|
+
createSync: Effect.provide(createSync, SecretBox.Live),
|
|
12
|
+
});
|
|
13
|
+
export const SqliteFactoryLive = Layer.succeed(SqliteFactory, {
|
|
14
|
+
createSqlite: Sqlite.pipe(Effect.provide(SqliteLive)),
|
|
15
|
+
});
|
|
16
|
+
export const EvoluFactoryReactNative = Layer.provide(EvoluFactory.Common, Layer.mergeAll(Layer.succeed(DbFactory, {
|
|
17
|
+
createDb: createDb.pipe(Effect.provide(Layer.mergeAll(SqliteFactory.Common.pipe(Layer.provide(SqliteFactoryLive), Layer.provide(NanoIdGeneratorLive)), NanoIdGeneratorLive, Time.Live, SyncFactoryLive, SyncLockLive))),
|
|
18
|
+
}), NanoIdGeneratorLive, AppStateLive));
|
|
@@ -1,10 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
import * as Effect from "effect/Effect";
|
|
3
|
-
import * as Layer from "effect/Layer";
|
|
1
|
+
export * from "@evolu/common-react";
|
|
4
2
|
export * from "@evolu/common/public";
|
|
5
|
-
/** Parse a string to {@link Mnemonic}. */
|
|
6
|
-
export declare const parseMnemonic: (mnemonic: string) => Effect.Effect<Mnemonic, InvalidMnemonicError>;
|
|
7
|
-
export declare const EvoluFactoryReactNative: Layer.Layer<EvoluFactory, never, never>;
|
|
8
3
|
export declare const
|
|
9
4
|
/**
|
|
10
5
|
* Create Evolu from the database schema.
|
|
@@ -36,5 +31,4 @@ export declare const
|
|
|
36
31
|
* const evolu = E.createEvolu(Database);
|
|
37
32
|
*/
|
|
38
33
|
createEvolu: <T extends import("@evolu/common").EvoluSchema, I>(schema: import("@effect/schema/Schema").Schema<T, I, never>, config?: Partial<import("@evolu/common").EvoluConfig<T>> | undefined) => import("@evolu/common").Evolu<T>;
|
|
39
|
-
|
|
40
|
-
//# sourceMappingURL=index.d.ts.map
|
|
34
|
+
//# sourceMappingURL=index.native.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.native.d.ts","sourceRoot":"","sources":["../src/index.native.ts"],"names":[],"mappings":"AAEA,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AAQrC,eAAO;AACL;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,WAAW,2NACiE,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { EvoluFactory } from "@evolu/common";
|
|
2
|
+
export * from "@evolu/common-react";
|
|
3
|
+
export * from "@evolu/common/public";
|
|
4
|
+
import * as Effect from "effect/Effect";
|
|
5
|
+
import { EvoluFactoryReactNative } from "./dbFactory.js";
|
|
6
|
+
// JSDoc doesn't support destructured parameters, so we must copy-paste
|
|
7
|
+
// createEvolu docs from `evolu-common/src/Evolu.ts`.
|
|
8
|
+
// https://github.com/microsoft/TypeScript/issues/11859
|
|
9
|
+
export const {
|
|
10
|
+
/**
|
|
11
|
+
* Create Evolu from the database schema.
|
|
12
|
+
*
|
|
13
|
+
* Tables with a name prefixed with `_` are local-only, which means they are
|
|
14
|
+
* never synced. It's useful for device-specific or temporal data.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* import * as S from "@effect/schema/Schema";
|
|
18
|
+
* import * as E from "@evolu/react-native";
|
|
19
|
+
*
|
|
20
|
+
* const TodoId = E.id("Todo");
|
|
21
|
+
* type TodoId = typeof TodoId.Type;
|
|
22
|
+
*
|
|
23
|
+
* const TodoTable = E.table({
|
|
24
|
+
* id: TodoId,
|
|
25
|
+
* title: E.NonEmptyString1000,
|
|
26
|
+
* });
|
|
27
|
+
* type TodoTable = typeof TodoTable.Type;
|
|
28
|
+
*
|
|
29
|
+
* const Database = E.database({
|
|
30
|
+
* todo: TodoTable,
|
|
31
|
+
*
|
|
32
|
+
* // Prefix `_` makes the table local-only (it will not sync)
|
|
33
|
+
* _todo: TodoTable,
|
|
34
|
+
* });
|
|
35
|
+
* type Database = typeof Database.Type;
|
|
36
|
+
*
|
|
37
|
+
* const evolu = E.createEvolu(Database);
|
|
38
|
+
*/
|
|
39
|
+
createEvolu, } = EvoluFactory.pipe(Effect.provide(EvoluFactoryReactNative), Effect.runSync);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.web.d.ts","sourceRoot":"","sources":["../src/index.web.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "@evolu/react";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@evolu/react-native",
|
|
3
|
-
"version": "10.
|
|
3
|
+
"version": "10.1.1",
|
|
4
4
|
"description": "Evolu for React Native",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"evolu",
|
|
@@ -15,15 +15,10 @@
|
|
|
15
15
|
},
|
|
16
16
|
"homepage": "https://evolu.dev",
|
|
17
17
|
"type": "module",
|
|
18
|
-
"types": "./dist/index.d.ts",
|
|
18
|
+
"types": "./dist/index.native.d.ts",
|
|
19
19
|
"exports": {
|
|
20
|
-
"
|
|
21
|
-
|
|
22
|
-
"import": "./dist/index.js"
|
|
23
|
-
}
|
|
24
|
-
},
|
|
25
|
-
"react-native": {
|
|
26
|
-
"./index.js": "./dist/index.js"
|
|
20
|
+
"react-native": "./dist/index.native.js",
|
|
21
|
+
"default": "./dist/index.web.js"
|
|
27
22
|
},
|
|
28
23
|
"files": [
|
|
29
24
|
"dist/**",
|
|
@@ -40,9 +35,10 @@
|
|
|
40
35
|
"react-native": "^0.74.1",
|
|
41
36
|
"typescript": "^5.4.5",
|
|
42
37
|
"vitest": "^1.6.0",
|
|
43
|
-
"@evolu/common": "5.
|
|
38
|
+
"@evolu/common": "5.2.2",
|
|
44
39
|
"@evolu/common-react": "8.0.5",
|
|
45
40
|
"@evolu/tsconfig": "0.0.2",
|
|
41
|
+
"@evolu/react": "8.1.0",
|
|
46
42
|
"eslint-config-evolu": "1.0.0"
|
|
47
43
|
},
|
|
48
44
|
"peerDependencies": {
|
package/src/PlatformLive.ts
CHANGED
|
@@ -1,19 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
AppState,
|
|
3
|
-
Bip39,
|
|
4
|
-
Mnemonic,
|
|
5
3
|
SyncLock,
|
|
6
4
|
SyncLockAlreadySyncingError,
|
|
7
5
|
SyncLockRelease,
|
|
8
|
-
validateMnemonicToEffect,
|
|
9
6
|
} from "@evolu/common";
|
|
10
7
|
import NetInfo, { NetInfoState } from "@react-native-community/netinfo";
|
|
11
|
-
import {
|
|
12
|
-
generateMnemonic,
|
|
13
|
-
mnemonicToSeed,
|
|
14
|
-
validateMnemonic,
|
|
15
|
-
} from "@scure/bip39";
|
|
16
|
-
import { wordlist } from "@scure/bip39/wordlists/english";
|
|
17
8
|
import * as Effect from "effect/Effect";
|
|
18
9
|
import * as Layer from "effect/Layer";
|
|
19
10
|
import { reloadAsync } from "expo-updates";
|
|
@@ -84,15 +75,3 @@ export const SyncLockLive = Layer.effect(
|
|
|
84
75
|
});
|
|
85
76
|
}),
|
|
86
77
|
);
|
|
87
|
-
|
|
88
|
-
export const Bip39Live = Layer.succeed(
|
|
89
|
-
Bip39,
|
|
90
|
-
Bip39.of({
|
|
91
|
-
make: Effect.sync(() => generateMnemonic(wordlist, 128) as Mnemonic),
|
|
92
|
-
|
|
93
|
-
toSeed: (mnemonic) => Effect.promise(() => mnemonicToSeed(mnemonic)),
|
|
94
|
-
|
|
95
|
-
parse: (mnemonic) =>
|
|
96
|
-
validateMnemonicToEffect(validateMnemonic)(mnemonic, wordlist),
|
|
97
|
-
}),
|
|
98
|
-
);
|
package/src/dbFactory.ts
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import {
|
|
2
|
+
DbFactory,
|
|
3
|
+
EvoluFactory,
|
|
4
|
+
SecretBox,
|
|
5
|
+
Sqlite,
|
|
6
|
+
SqliteFactory,
|
|
7
|
+
SyncFactory,
|
|
8
|
+
Time,
|
|
9
|
+
createDb,
|
|
10
|
+
createNanoIdGeneratorLive,
|
|
11
|
+
createSync,
|
|
12
|
+
} from "@evolu/common";
|
|
13
|
+
|
|
14
|
+
import * as Effect from "effect/Effect";
|
|
15
|
+
import * as Layer from "effect/Layer";
|
|
16
|
+
// @ts-expect-error https://github.com/ai/nanoid/issues/468
|
|
17
|
+
import { customAlphabet, nanoid } from "nanoid/index.browser.js";
|
|
18
|
+
import { AppStateLive, SyncLockLive } from "./PlatformLive.js";
|
|
19
|
+
import { SqliteLive } from "./SqliteLive.js";
|
|
20
|
+
|
|
21
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
22
|
+
export const NanoIdGeneratorLive = createNanoIdGeneratorLive(
|
|
23
|
+
customAlphabet,
|
|
24
|
+
nanoid,
|
|
25
|
+
);
|
|
26
|
+
|
|
27
|
+
export const SyncFactoryLive = Layer.succeed(SyncFactory, {
|
|
28
|
+
createSync: Effect.provide(createSync, SecretBox.Live),
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
export const SqliteFactoryLive = Layer.succeed(SqliteFactory, {
|
|
32
|
+
createSqlite: Sqlite.pipe(Effect.provide(SqliteLive)),
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
export const EvoluFactoryReactNative = Layer.provide(
|
|
36
|
+
EvoluFactory.Common,
|
|
37
|
+
Layer.mergeAll(
|
|
38
|
+
Layer.succeed(DbFactory, {
|
|
39
|
+
createDb: createDb.pipe(
|
|
40
|
+
Effect.provide(
|
|
41
|
+
Layer.mergeAll(
|
|
42
|
+
SqliteFactory.Common.pipe(
|
|
43
|
+
Layer.provide(SqliteFactoryLive),
|
|
44
|
+
Layer.provide(NanoIdGeneratorLive),
|
|
45
|
+
),
|
|
46
|
+
NanoIdGeneratorLive,
|
|
47
|
+
Time.Live,
|
|
48
|
+
SyncFactoryLive,
|
|
49
|
+
SyncLockLive,
|
|
50
|
+
),
|
|
51
|
+
),
|
|
52
|
+
),
|
|
53
|
+
}),
|
|
54
|
+
NanoIdGeneratorLive,
|
|
55
|
+
AppStateLive,
|
|
56
|
+
),
|
|
57
|
+
);
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { EvoluFactory } from "@evolu/common";
|
|
2
|
+
|
|
3
|
+
export * from "@evolu/common-react";
|
|
4
|
+
export * from "@evolu/common/public";
|
|
5
|
+
|
|
6
|
+
import * as Effect from "effect/Effect";
|
|
7
|
+
import { EvoluFactoryReactNative } from "./dbFactory.js";
|
|
8
|
+
|
|
9
|
+
// JSDoc doesn't support destructured parameters, so we must copy-paste
|
|
10
|
+
// createEvolu docs from `evolu-common/src/Evolu.ts`.
|
|
11
|
+
// https://github.com/microsoft/TypeScript/issues/11859
|
|
12
|
+
export const {
|
|
13
|
+
/**
|
|
14
|
+
* Create Evolu from the database schema.
|
|
15
|
+
*
|
|
16
|
+
* Tables with a name prefixed with `_` are local-only, which means they are
|
|
17
|
+
* never synced. It's useful for device-specific or temporal data.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* import * as S from "@effect/schema/Schema";
|
|
21
|
+
* import * as E from "@evolu/react-native";
|
|
22
|
+
*
|
|
23
|
+
* const TodoId = E.id("Todo");
|
|
24
|
+
* type TodoId = typeof TodoId.Type;
|
|
25
|
+
*
|
|
26
|
+
* const TodoTable = E.table({
|
|
27
|
+
* id: TodoId,
|
|
28
|
+
* title: E.NonEmptyString1000,
|
|
29
|
+
* });
|
|
30
|
+
* type TodoTable = typeof TodoTable.Type;
|
|
31
|
+
*
|
|
32
|
+
* const Database = E.database({
|
|
33
|
+
* todo: TodoTable,
|
|
34
|
+
*
|
|
35
|
+
* // Prefix `_` makes the table local-only (it will not sync)
|
|
36
|
+
* _todo: TodoTable,
|
|
37
|
+
* });
|
|
38
|
+
* type Database = typeof Database.Type;
|
|
39
|
+
*
|
|
40
|
+
* const evolu = E.createEvolu(Database);
|
|
41
|
+
*/
|
|
42
|
+
createEvolu,
|
|
43
|
+
} = EvoluFactory.pipe(Effect.provide(EvoluFactoryReactNative), Effect.runSync);
|
package/src/index.web.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "@evolu/react";
|
package/dist/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,YAAY,EACZ,oBAAoB,EACpB,QAAQ,EAST,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AAStC,cAAc,sBAAsB,CAAC;AAErC,0CAA0C;AAC1C,eAAO,MAAM,aAAa,EAAE,CAC1B,QAAQ,EAAE,MAAM,KACb,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE,oBAAoB,CAG1C,CAAC;AAUR,eAAO,MAAM,uBAAuB,yCAuBnC,CAAC;AAKF,eAAO;AACL;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,WAAW,2NACiE,CAAC;AAE/E,cAAc,qBAAqB,CAAC"}
|
package/dist/index.js
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { Bip39, DbFactory, EvoluFactory, SecretBox, Sqlite, SqliteFactory, SyncFactory, Time, createDb, createNanoIdGeneratorLive, createSync, } from "@evolu/common";
|
|
2
|
-
import * as Effect from "effect/Effect";
|
|
3
|
-
import * as Layer from "effect/Layer";
|
|
4
|
-
// @ts-expect-error https://github.com/ai/nanoid/issues/468
|
|
5
|
-
import { customAlphabet, nanoid } from "nanoid/index.browser.js";
|
|
6
|
-
import { AppStateLive, Bip39Live, SyncLockLive } from "./PlatformLive.js";
|
|
7
|
-
import { SqliteLive } from "./SqliteLive.js";
|
|
8
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
9
|
-
const NanoIdGeneratorLive = createNanoIdGeneratorLive(customAlphabet, nanoid);
|
|
10
|
-
export * from "@evolu/common/public";
|
|
11
|
-
/** Parse a string to {@link Mnemonic}. */
|
|
12
|
-
export const parseMnemonic = Bip39.pipe(Effect.provide(Bip39Live), Effect.runSync).parse;
|
|
13
|
-
const SyncFactoryLive = Layer.succeed(SyncFactory, {
|
|
14
|
-
createSync: Effect.provide(createSync, SecretBox.Live),
|
|
15
|
-
});
|
|
16
|
-
const SqliteFactoryLive = Layer.succeed(SqliteFactory, {
|
|
17
|
-
createSqlite: Sqlite.pipe(Effect.provide(SqliteLive)),
|
|
18
|
-
});
|
|
19
|
-
export const EvoluFactoryReactNative = Layer.provide(EvoluFactory.Common, Layer.mergeAll(Layer.succeed(DbFactory, {
|
|
20
|
-
createDb: createDb.pipe(Effect.provide(Layer.mergeAll(Bip39Live, SqliteFactory.Common.pipe(Layer.provide(SqliteFactoryLive), Layer.provide(NanoIdGeneratorLive)), NanoIdGeneratorLive, Time.Live, SyncFactoryLive, SyncLockLive))),
|
|
21
|
-
}), NanoIdGeneratorLive, AppStateLive));
|
|
22
|
-
// JSDoc doesn't support destructured parameters, so we must copy-paste
|
|
23
|
-
// createEvolu docs from `evolu-common/src/Evolu.ts`.
|
|
24
|
-
// https://github.com/microsoft/TypeScript/issues/11859
|
|
25
|
-
export const {
|
|
26
|
-
/**
|
|
27
|
-
* Create Evolu from the database schema.
|
|
28
|
-
*
|
|
29
|
-
* Tables with a name prefixed with `_` are local-only, which means they are
|
|
30
|
-
* never synced. It's useful for device-specific or temporal data.
|
|
31
|
-
*
|
|
32
|
-
* @example
|
|
33
|
-
* import * as S from "@effect/schema/Schema";
|
|
34
|
-
* import * as E from "@evolu/react-native";
|
|
35
|
-
*
|
|
36
|
-
* const TodoId = E.id("Todo");
|
|
37
|
-
* type TodoId = typeof TodoId.Type;
|
|
38
|
-
*
|
|
39
|
-
* const TodoTable = E.table({
|
|
40
|
-
* id: TodoId,
|
|
41
|
-
* title: E.NonEmptyString1000,
|
|
42
|
-
* });
|
|
43
|
-
* type TodoTable = typeof TodoTable.Type;
|
|
44
|
-
*
|
|
45
|
-
* const Database = E.database({
|
|
46
|
-
* todo: TodoTable,
|
|
47
|
-
*
|
|
48
|
-
* // Prefix `_` makes the table local-only (it will not sync)
|
|
49
|
-
* _todo: TodoTable,
|
|
50
|
-
* });
|
|
51
|
-
* type Database = typeof Database.Type;
|
|
52
|
-
*
|
|
53
|
-
* const evolu = E.createEvolu(Database);
|
|
54
|
-
*/
|
|
55
|
-
createEvolu, } = EvoluFactory.pipe(Effect.provide(EvoluFactoryReactNative), Effect.runSync);
|
|
56
|
-
export * from "@evolu/common-react";
|
package/src/index.ts
DELETED
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Bip39,
|
|
3
|
-
DbFactory,
|
|
4
|
-
EvoluFactory,
|
|
5
|
-
InvalidMnemonicError,
|
|
6
|
-
Mnemonic,
|
|
7
|
-
SecretBox,
|
|
8
|
-
Sqlite,
|
|
9
|
-
SqliteFactory,
|
|
10
|
-
SyncFactory,
|
|
11
|
-
Time,
|
|
12
|
-
createDb,
|
|
13
|
-
createNanoIdGeneratorLive,
|
|
14
|
-
createSync,
|
|
15
|
-
} from "@evolu/common";
|
|
16
|
-
import * as Effect from "effect/Effect";
|
|
17
|
-
import * as Layer from "effect/Layer";
|
|
18
|
-
// @ts-expect-error https://github.com/ai/nanoid/issues/468
|
|
19
|
-
import { customAlphabet, nanoid } from "nanoid/index.browser.js";
|
|
20
|
-
import { AppStateLive, Bip39Live, SyncLockLive } from "./PlatformLive.js";
|
|
21
|
-
import { SqliteLive } from "./SqliteLive.js";
|
|
22
|
-
|
|
23
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
24
|
-
const NanoIdGeneratorLive = createNanoIdGeneratorLive(customAlphabet, nanoid);
|
|
25
|
-
|
|
26
|
-
export * from "@evolu/common/public";
|
|
27
|
-
|
|
28
|
-
/** Parse a string to {@link Mnemonic}. */
|
|
29
|
-
export const parseMnemonic: (
|
|
30
|
-
mnemonic: string,
|
|
31
|
-
) => Effect.Effect<Mnemonic, InvalidMnemonicError> = Bip39.pipe(
|
|
32
|
-
Effect.provide(Bip39Live),
|
|
33
|
-
Effect.runSync,
|
|
34
|
-
).parse;
|
|
35
|
-
|
|
36
|
-
const SyncFactoryLive = Layer.succeed(SyncFactory, {
|
|
37
|
-
createSync: Effect.provide(createSync, SecretBox.Live),
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
const SqliteFactoryLive = Layer.succeed(SqliteFactory, {
|
|
41
|
-
createSqlite: Sqlite.pipe(Effect.provide(SqliteLive)),
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
export const EvoluFactoryReactNative = Layer.provide(
|
|
45
|
-
EvoluFactory.Common,
|
|
46
|
-
Layer.mergeAll(
|
|
47
|
-
Layer.succeed(DbFactory, {
|
|
48
|
-
createDb: createDb.pipe(
|
|
49
|
-
Effect.provide(
|
|
50
|
-
Layer.mergeAll(
|
|
51
|
-
Bip39Live,
|
|
52
|
-
SqliteFactory.Common.pipe(
|
|
53
|
-
Layer.provide(SqliteFactoryLive),
|
|
54
|
-
Layer.provide(NanoIdGeneratorLive),
|
|
55
|
-
),
|
|
56
|
-
NanoIdGeneratorLive,
|
|
57
|
-
Time.Live,
|
|
58
|
-
SyncFactoryLive,
|
|
59
|
-
SyncLockLive,
|
|
60
|
-
),
|
|
61
|
-
),
|
|
62
|
-
),
|
|
63
|
-
}),
|
|
64
|
-
NanoIdGeneratorLive,
|
|
65
|
-
AppStateLive,
|
|
66
|
-
),
|
|
67
|
-
);
|
|
68
|
-
|
|
69
|
-
// JSDoc doesn't support destructured parameters, so we must copy-paste
|
|
70
|
-
// createEvolu docs from `evolu-common/src/Evolu.ts`.
|
|
71
|
-
// https://github.com/microsoft/TypeScript/issues/11859
|
|
72
|
-
export const {
|
|
73
|
-
/**
|
|
74
|
-
* Create Evolu from the database schema.
|
|
75
|
-
*
|
|
76
|
-
* Tables with a name prefixed with `_` are local-only, which means they are
|
|
77
|
-
* never synced. It's useful for device-specific or temporal data.
|
|
78
|
-
*
|
|
79
|
-
* @example
|
|
80
|
-
* import * as S from "@effect/schema/Schema";
|
|
81
|
-
* import * as E from "@evolu/react-native";
|
|
82
|
-
*
|
|
83
|
-
* const TodoId = E.id("Todo");
|
|
84
|
-
* type TodoId = typeof TodoId.Type;
|
|
85
|
-
*
|
|
86
|
-
* const TodoTable = E.table({
|
|
87
|
-
* id: TodoId,
|
|
88
|
-
* title: E.NonEmptyString1000,
|
|
89
|
-
* });
|
|
90
|
-
* type TodoTable = typeof TodoTable.Type;
|
|
91
|
-
*
|
|
92
|
-
* const Database = E.database({
|
|
93
|
-
* todo: TodoTable,
|
|
94
|
-
*
|
|
95
|
-
* // Prefix `_` makes the table local-only (it will not sync)
|
|
96
|
-
* _todo: TodoTable,
|
|
97
|
-
* });
|
|
98
|
-
* type Database = typeof Database.Type;
|
|
99
|
-
*
|
|
100
|
-
* const evolu = E.createEvolu(Database);
|
|
101
|
-
*/
|
|
102
|
-
createEvolu,
|
|
103
|
-
} = EvoluFactory.pipe(Effect.provide(EvoluFactoryReactNative), Effect.runSync);
|
|
104
|
-
|
|
105
|
-
export * from "@evolu/common-react";
|