@evolu/react-native 2.0.0 → 3.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/README.md CHANGED
@@ -1,3 +1,15 @@
1
1
  # Evolu for React Native
2
2
 
3
3
  [Evolu](https://github.com/evoluhq/evolu) for [React Native](https://reactnative.dev/).
4
+
5
+ ## Documentation
6
+
7
+ For detailed information and usage examples, please visit [evolu.dev](https://www.evolu.dev).
8
+
9
+ ## Community
10
+
11
+ The Evolu community is on [GitHub Discussions](https://github.com/evoluhq/evolu/discussions), where you can ask questions and voice ideas.
12
+
13
+ To chat with other community members, you can join the [Evolu Discord](https://discord.gg/2J8yyyyxtZ).
14
+
15
+ [![Twitter URL](https://img.shields.io/twitter/url/https/twitter.com/evoluhq.svg?style=social&label=Follow%20%40evoluhq)](https://twitter.com/evoluhq)
package/dist/index.d.ts CHANGED
@@ -1,35 +1,33 @@
1
- import { Config, InvalidMnemonicError, Mnemonic, Schema } from "@evolu/common";
1
+ import { Config, Evolu, InvalidMnemonicError, Mnemonic, Schema } from "@evolu/common";
2
2
  import { Effect } from "effect";
3
3
  export { Id, NonEmptyString1000, PositiveInt, SqliteBoolean, SqliteDate, String, String1000, canUseDom, cast, id, } from "@evolu/common";
4
4
  export type { EvoluError, InvalidMnemonicError, Mnemonic, Owner, OwnerId, SyncState, Timestamp, TimestampError, UnexpectedError, } from "@evolu/common";
5
5
  export { jsonArrayFrom, jsonObjectFrom } from "kysely/helpers/sqlite";
6
+ export * from "@evolu/common-react";
6
7
  /**
7
- * Create Evolu for React Native.
8
+ * Create Evolu for web.
8
9
  *
9
- * ### Example
10
+ * @example
11
+ * import * as S from "@effect/schema/Schema";
12
+ * import { NonEmptyString1000, createEvolu, id } from "@evolu/react";
10
13
  *
11
- * ```ts
12
- * import * as S from "@effect/schema/Schema";
13
- * import * as Evolu from "@evolu/react-native";
14
+ * const TodoId = id("Todo");
15
+ * type TodoId = S.Schema.To<typeof TodoId>;
14
16
  *
15
- * const TodoId = Evolu.id("Todo");
16
- * type TodoId = S.Schema.To<typeof TodoId>;
17
+ * const TodoTable = S.struct({
18
+ * id: TodoId,
19
+ * title: NonEmptyString1000,
20
+ * });
21
+ * type TodoTable = S.Schema.To<typeof TodoTable>;
17
22
  *
18
- * const TodoTable = S.struct({
19
- * id: TodoId,
20
- * title: Evolu.NonEmptyString1000,
21
- * });
22
- * type TodoTable = S.Schema.To<typeof TodoTable>;
23
+ * const Database = S.struct({
24
+ * todo: TodoTable,
25
+ * });
26
+ * type Database = S.Schema.To<typeof Database>;
23
27
  *
24
- * const Database = S.struct({
25
- * todo: TodoTable,
26
- * });
27
- *
28
- * const { useEvolu, useEvoluError, useQuery, useOwner } =
29
- * Evolu.create(Database);
30
- * ```
28
+ * const evolu = createEvolu(Database);
31
29
  */
32
- export declare const create: <From, To extends Schema>(schema: import("@effect/schema/Schema").Schema<From, To>, config?: Partial<Config> | undefined) => import("@evolu/common-react").EvoluReact<To>;
30
+ export declare const createEvolu: <From, To extends Schema>(schema: import("@effect/schema/Schema").Schema<From, To>, config?: Partial<Config> | undefined) => Evolu<To>;
33
31
  /** Parse a string to {@link Mnemonic}. */
34
32
  export declare const parseMnemonic: (mnemonic: string) => Effect.Effect<never, InvalidMnemonicError, Mnemonic>;
35
33
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,MAAM,EAKN,oBAAoB,EACpB,QAAQ,EAER,MAAM,EAGP,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,MAAM,EAAS,MAAM,QAAQ,CAAC;AAYvC,OAAO,EACL,EAAE,EACF,kBAAkB,EAClB,WAAW,EACX,aAAa,EACb,UAAU,EACV,MAAM,EACN,UAAU,EACV,SAAS,EACT,IAAI,EACJ,EAAE,GACH,MAAM,eAAe,CAAC;AACvB,YAAY,EACV,UAAU,EACV,oBAAo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@ -1,41 +1,39 @@
1
- import { Bip39, DbWorkerLive, EvoluCommonLive, FetchLive, NanoIdLive, SecretBoxLive, SyncWorkerLive, } from "@evolu/common";
2
- import { EvoluReactLive, makeCreateEvoluReact } from "@evolu/common-react";
1
+ import { Bip39, DbWorkerLive, EvoluCommonLive, FetchLive, NanoIdLive, SecretBoxLive, SyncWorkerLive, makeCreateEvolu, } from "@evolu/common";
3
2
  import { Effect, Layer } from "effect";
4
3
  import { AppStateLive, Bip39Live, FlushSyncLive, SyncLockLive, } from "./PlatformLive.js";
5
4
  import { SqliteLive } from "./SqliteLive.js";
6
- // export * from "@evolu/common/public" isn't working in RN for some reason,
7
- // so we have to export manually.
5
+ // export * from "@evolu/common/public"
6
+ // https://github.com/facebook/metro/issues/1128
7
+ // So we have to export manually.
8
8
  // TODO: Recheck after RN 0.73 release.
9
9
  export { Id, NonEmptyString1000, PositiveInt, SqliteBoolean, SqliteDate, String, String1000, canUseDom, cast, id, } from "@evolu/common";
10
10
  export { jsonArrayFrom, jsonObjectFrom } from "kysely/helpers/sqlite";
11
+ export * from "@evolu/common-react";
11
12
  /** Evolu for native platform. */
12
- const EvoluNativeLive = EvoluCommonLive.pipe(Layer.use(Layer.mergeAll(FlushSyncLive, AppStateLive, DbWorkerLive)), Layer.use(Layer.mergeAll(Bip39Live, NanoIdLive, SqliteLive, SyncWorkerLive)), Layer.use(Layer.mergeAll(SecretBoxLive, SyncLockLive, FetchLive)));
13
+ const EvoluNativeLive = EvoluCommonLive.pipe(Layer.provide(Layer.mergeAll(FlushSyncLive, AppStateLive, DbWorkerLive)), Layer.provide(Layer.mergeAll(Bip39Live, NanoIdLive, SqliteLive, SyncWorkerLive)), Layer.provide(Layer.mergeAll(SecretBoxLive, SyncLockLive, FetchLive)));
13
14
  /**
14
- * Create Evolu for React Native.
15
+ * Create Evolu for web.
15
16
  *
16
- * ### Example
17
+ * @example
18
+ * import * as S from "@effect/schema/Schema";
19
+ * import { NonEmptyString1000, createEvolu, id } from "@evolu/react";
17
20
  *
18
- * ```ts
19
- * import * as S from "@effect/schema/Schema";
20
- * import * as Evolu from "@evolu/react-native";
21
+ * const TodoId = id("Todo");
22
+ * type TodoId = S.Schema.To<typeof TodoId>;
21
23
  *
22
- * const TodoId = Evolu.id("Todo");
23
- * type TodoId = S.Schema.To<typeof TodoId>;
24
+ * const TodoTable = S.struct({
25
+ * id: TodoId,
26
+ * title: NonEmptyString1000,
27
+ * });
28
+ * type TodoTable = S.Schema.To<typeof TodoTable>;
24
29
  *
25
- * const TodoTable = S.struct({
26
- * id: TodoId,
27
- * title: Evolu.NonEmptyString1000,
28
- * });
29
- * type TodoTable = S.Schema.To<typeof TodoTable>;
30
+ * const Database = S.struct({
31
+ * todo: TodoTable,
32
+ * });
33
+ * type Database = S.Schema.To<typeof Database>;
30
34
  *
31
- * const Database = S.struct({
32
- * todo: TodoTable,
33
- * });
34
- *
35
- * const { useEvolu, useEvoluError, useQuery, useOwner } =
36
- * Evolu.create(Database);
37
- * ```
35
+ * const evolu = createEvolu(Database);
38
36
  */
39
- export const create = EvoluReactLive.pipe(Layer.use(EvoluNativeLive), makeCreateEvoluReact);
37
+ export const createEvolu = makeCreateEvolu(EvoluNativeLive);
40
38
  /** Parse a string to {@link Mnemonic}. */
41
39
  export const parseMnemonic = Bip39.pipe(Effect.provide(Bip39Live), Effect.runSync).parse;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@evolu/react-native",
3
- "version": "2.0.0",
3
+ "version": "3.0.0",
4
4
  "description": "Evolu for React Native",
5
5
  "keywords": [
6
6
  "evolu",
@@ -40,13 +40,13 @@
40
40
  "react-native": "^0.72.6",
41
41
  "typescript": "^5.3.2",
42
42
  "vitest": "^0.34.6",
43
- "@evolu/common": "2.0.0",
44
- "@evolu/common-react": "2.0.0",
43
+ "@evolu/common": "2.1.0",
44
+ "@evolu/common-react": "3.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": "^2.0.0",
49
+ "@evolu/common-react": "^3.0.0",
50
50
  "expo": "^49.0.20",
51
51
  "expo-sqlite": "~11.3.3",
52
52
  "react-native": "^0.72.4"
package/src/index.ts CHANGED
@@ -11,8 +11,8 @@ import {
11
11
  Schema,
12
12
  SecretBoxLive,
13
13
  SyncWorkerLive,
14
+ makeCreateEvolu,
14
15
  } from "@evolu/common";
15
- import { EvoluReactLive, makeCreateEvoluReact } from "@evolu/common-react";
16
16
  import { Effect, Layer } from "effect";
17
17
  import {
18
18
  AppStateLive,
@@ -22,8 +22,9 @@ import {
22
22
  } from "./PlatformLive.js";
23
23
  import { SqliteLive } from "./SqliteLive.js";
24
24
 
25
- // export * from "@evolu/common/public" isn't working in RN for some reason,
26
- // so we have to export manually.
25
+ // export * from "@evolu/common/public"
26
+ // https://github.com/facebook/metro/issues/1128
27
+ // So we have to export manually.
27
28
  // TODO: Recheck after RN 0.73 release.
28
29
  export {
29
30
  Id,
@@ -50,47 +51,45 @@ export type {
50
51
  } from "@evolu/common";
51
52
  export { jsonArrayFrom, jsonObjectFrom } from "kysely/helpers/sqlite";
52
53
 
54
+ export * from "@evolu/common-react";
55
+
53
56
  /** Evolu for native platform. */
54
57
  const EvoluNativeLive: Layer.Layer<
55
58
  Config,
56
59
  never,
57
60
  Evolu<Schema>
58
61
  > = EvoluCommonLive.pipe(
59
- Layer.use(Layer.mergeAll(FlushSyncLive, AppStateLive, DbWorkerLive)),
60
- Layer.use(Layer.mergeAll(Bip39Live, NanoIdLive, SqliteLive, SyncWorkerLive)),
61
- Layer.use(Layer.mergeAll(SecretBoxLive, SyncLockLive, FetchLive)),
62
+ Layer.provide(Layer.mergeAll(FlushSyncLive, AppStateLive, DbWorkerLive)),
63
+ Layer.provide(
64
+ Layer.mergeAll(Bip39Live, NanoIdLive, SqliteLive, SyncWorkerLive),
65
+ ),
66
+ Layer.provide(Layer.mergeAll(SecretBoxLive, SyncLockLive, FetchLive)),
62
67
  );
63
68
 
64
69
  /**
65
- * Create Evolu for React Native.
66
- *
67
- * ### Example
70
+ * Create Evolu for web.
68
71
  *
69
- * ```ts
70
- * import * as S from "@effect/schema/Schema";
71
- * import * as Evolu from "@evolu/react-native";
72
+ * @example
73
+ * import * as S from "@effect/schema/Schema";
74
+ * import { NonEmptyString1000, createEvolu, id } from "@evolu/react";
72
75
  *
73
- * const TodoId = Evolu.id("Todo");
74
- * type TodoId = S.Schema.To<typeof TodoId>;
76
+ * const TodoId = id("Todo");
77
+ * type TodoId = S.Schema.To<typeof TodoId>;
75
78
  *
76
- * const TodoTable = S.struct({
77
- * id: TodoId,
78
- * title: Evolu.NonEmptyString1000,
79
- * });
80
- * type TodoTable = S.Schema.To<typeof TodoTable>;
79
+ * const TodoTable = S.struct({
80
+ * id: TodoId,
81
+ * title: NonEmptyString1000,
82
+ * });
83
+ * type TodoTable = S.Schema.To<typeof TodoTable>;
81
84
  *
82
- * const Database = S.struct({
83
- * todo: TodoTable,
84
- * });
85
+ * const Database = S.struct({
86
+ * todo: TodoTable,
87
+ * });
88
+ * type Database = S.Schema.To<typeof Database>;
85
89
  *
86
- * const { useEvolu, useEvoluError, useQuery, useOwner } =
87
- * Evolu.create(Database);
88
- * ```
90
+ * const evolu = createEvolu(Database);
89
91
  */
90
- export const create = EvoluReactLive.pipe(
91
- Layer.use(EvoluNativeLive),
92
- makeCreateEvoluReact,
93
- );
92
+ export const createEvolu = makeCreateEvolu(EvoluNativeLive);
94
93
 
95
94
  /** Parse a string to {@link Mnemonic}. */
96
95
  export const parseMnemonic: (