@evolu/react 6.0.2 → 8.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/index.d.ts CHANGED
@@ -1,33 +1,35 @@
1
1
  export { parseMnemonic } from "@evolu/common-web";
2
2
  export * from "@evolu/common/public";
3
+ export declare const
3
4
  /**
4
- * Create Evolu for React.
5
+ * Create Evolu from the database schema.
5
6
  *
6
7
  * Tables with a name prefixed with `_` are local-only, which means they are
7
8
  * never synced. It's useful for device-specific or temporal data.
8
9
  *
9
10
  * @example
10
11
  * import * as S from "@effect/schema/Schema";
11
- * import { NonEmptyString1000, createEvolu, id } from "@evolu/react";
12
+ * import * as E from "@evolu/react";
12
13
  *
13
- * const TodoId = id("Todo");
14
+ * const TodoId = E.id("Todo");
14
15
  * type TodoId = S.Schema.Type<typeof TodoId>;
15
16
  *
16
- * const TodoTable = table({
17
+ * const TodoTable = E.table({
17
18
  * id: TodoId,
18
- * title: NonEmptyString1000,
19
+ * title: E.NonEmptyString1000,
19
20
  * });
20
21
  * type TodoTable = S.Schema.Type<typeof TodoTable>;
21
22
  *
22
- * const Database = database({
23
- * // _todo is local-only table
24
- * _todo: TodoTable,
23
+ * const Database = E.database({
25
24
  * todo: TodoTable,
25
+ *
26
+ * // Prefix `_` makes the table local-only (it will not sync)
27
+ * _todo: TodoTable,
26
28
  * });
27
29
  * type Database = S.Schema.Type<typeof Database>;
28
30
  *
29
- * const evolu = createEvolu(Database);
31
+ * const evolu = E.createEvolu(Database);
30
32
  */
31
- export declare const createEvolu: <From, To extends import("@evolu/common").DatabaseSchema>(schema: import("@effect/schema/Schema").Schema<To, From, never>, config?: Partial<import("@evolu/common").Config> | undefined) => import("@evolu/common").Evolu<To>;
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>;
32
34
  export * from "@evolu/common-react";
33
35
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,cAAc,sBAAsB,CAAC;AAIrC;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,eAAO,MAAM,WAAW,+NAEvB,CAAC;AAEF,cAAc,qBAAqB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,cAAc,sBAAsB,CAAC;AASrC,eAAO;AACL;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,WAAW,2NAC8D,CAAC;AAE5E,cAAc,qBAAqB,CAAC"}
package/dist/index.js CHANGED
@@ -1,37 +1,43 @@
1
- import { FlushSync, makeCreateEvolu } from "@evolu/common";
2
- import { EvoluWebLive } from "@evolu/common-web";
1
+ import { EvoluFactory, FlushSync } from "@evolu/common";
2
+ import { EvoluFactoryWeb } from "@evolu/common-web";
3
+ import * as Effect from "effect/Effect";
3
4
  import * as Layer from "effect/Layer";
4
5
  import { flushSync } from "react-dom";
5
6
  export { parseMnemonic } from "@evolu/common-web";
6
7
  export * from "@evolu/common/public";
7
- const FlushSyncLive = Layer.succeed(FlushSync, flushSync);
8
+ const EvoluFactoryWebReact = EvoluFactoryWeb.pipe(Layer.provide(Layer.succeed(FlushSync, flushSync)));
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 {
8
13
  /**
9
- * Create Evolu for React.
14
+ * Create Evolu from the database schema.
10
15
  *
11
16
  * Tables with a name prefixed with `_` are local-only, which means they are
12
17
  * never synced. It's useful for device-specific or temporal data.
13
18
  *
14
19
  * @example
15
20
  * import * as S from "@effect/schema/Schema";
16
- * import { NonEmptyString1000, createEvolu, id } from "@evolu/react";
21
+ * import * as E from "@evolu/react";
17
22
  *
18
- * const TodoId = id("Todo");
23
+ * const TodoId = E.id("Todo");
19
24
  * type TodoId = S.Schema.Type<typeof TodoId>;
20
25
  *
21
- * const TodoTable = table({
26
+ * const TodoTable = E.table({
22
27
  * id: TodoId,
23
- * title: NonEmptyString1000,
28
+ * title: E.NonEmptyString1000,
24
29
  * });
25
30
  * type TodoTable = S.Schema.Type<typeof TodoTable>;
26
31
  *
27
- * const Database = database({
28
- * // _todo is local-only table
29
- * _todo: TodoTable,
32
+ * const Database = E.database({
30
33
  * todo: TodoTable,
34
+ *
35
+ * // Prefix `_` makes the table local-only (it will not sync)
36
+ * _todo: TodoTable,
31
37
  * });
32
38
  * type Database = S.Schema.Type<typeof Database>;
33
39
  *
34
- * const evolu = createEvolu(Database);
40
+ * const evolu = E.createEvolu(Database);
35
41
  */
36
- export const createEvolu = makeCreateEvolu(EvoluWebLive.pipe(Layer.provide(FlushSyncLive)));
42
+ createEvolu, } = EvoluFactory.pipe(Effect.provide(EvoluFactoryWebReact), Effect.runSync);
37
43
  export * from "@evolu/common-react";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@evolu/react",
3
- "version": "6.0.2",
3
+ "version": "8.0.0",
4
4
  "description": "Evolu for React",
5
5
  "keywords": [
6
6
  "evolu",
@@ -29,21 +29,21 @@
29
29
  "README.md"
30
30
  ],
31
31
  "devDependencies": {
32
- "@types/react-dom": "^18.2.22",
32
+ "@types/react-dom": "~18.3.0",
33
33
  "eslint": "^8.57.0",
34
- "react-dom": "^18.2.0",
35
- "typescript": "^5.4.2",
36
- "vitest": "^1.4.0",
37
- "@evolu/common": "4.0.5",
38
- "@evolu/common-react": "6.0.3",
39
- "@evolu/common-web": "6.0.4",
34
+ "react-dom": "^18.3.1",
35
+ "typescript": "^5.4.5",
36
+ "vitest": "^1.5.2",
37
+ "@evolu/common": "5.0.0",
38
+ "@evolu/common-react": "8.0.0",
40
39
  "@evolu/tsconfig": "0.0.2",
40
+ "@evolu/common-web": "8.0.0",
41
41
  "eslint-config-evolu": "1.0.0"
42
42
  },
43
43
  "peerDependencies": {
44
- "@evolu/common": "^4.0.5",
45
- "@evolu/common-react": "^6.0.3",
46
- "@evolu/common-web": "^6.0.4",
44
+ "@evolu/common": "^5.0.0",
45
+ "@evolu/common-react": "^8.0.0",
46
+ "@evolu/common-web": "^8.0.0",
47
47
  "react-dom": "^18.2.0"
48
48
  },
49
49
  "publishConfig": {
package/src/index.ts CHANGED
@@ -1,43 +1,50 @@
1
- import { FlushSync, makeCreateEvolu } from "@evolu/common";
2
- import { EvoluWebLive } from "@evolu/common-web";
1
+ import { EvoluFactory, FlushSync } from "@evolu/common";
2
+ import { EvoluFactoryWeb } from "@evolu/common-web";
3
+ import * as Effect from "effect/Effect";
3
4
  import * as Layer from "effect/Layer";
4
5
  import { flushSync } from "react-dom";
5
6
 
6
7
  export { parseMnemonic } from "@evolu/common-web";
7
8
  export * from "@evolu/common/public";
8
9
 
9
- const FlushSyncLive = Layer.succeed(FlushSync, flushSync);
10
-
11
- /**
12
- * Create Evolu for React.
13
- *
14
- * Tables with a name prefixed with `_` are local-only, which means they are
15
- * never synced. It's useful for device-specific or temporal data.
16
- *
17
- * @example
18
- * import * as S from "@effect/schema/Schema";
19
- * import { NonEmptyString1000, createEvolu, id } from "@evolu/react";
20
- *
21
- * const TodoId = id("Todo");
22
- * type TodoId = S.Schema.Type<typeof TodoId>;
23
- *
24
- * const TodoTable = table({
25
- * id: TodoId,
26
- * title: NonEmptyString1000,
27
- * });
28
- * type TodoTable = S.Schema.Type<typeof TodoTable>;
29
- *
30
- * const Database = database({
31
- * // _todo is local-only table
32
- * _todo: TodoTable,
33
- * todo: TodoTable,
34
- * });
35
- * type Database = S.Schema.Type<typeof Database>;
36
- *
37
- * const evolu = createEvolu(Database);
38
- */
39
- export const createEvolu = makeCreateEvolu(
40
- EvoluWebLive.pipe(Layer.provide(FlushSyncLive)),
10
+ const EvoluFactoryWebReact = EvoluFactoryWeb.pipe(
11
+ Layer.provide(Layer.succeed(FlushSync, flushSync)),
41
12
  );
42
13
 
14
+ // JSDoc doesn't support destructured parameters, so we must copy-paste
15
+ // createEvolu docs from `evolu-common/src/Evolu.ts`.
16
+ // https://github.com/microsoft/TypeScript/issues/11859
17
+ export const {
18
+ /**
19
+ * Create Evolu from the database schema.
20
+ *
21
+ * Tables with a name prefixed with `_` are local-only, which means they are
22
+ * never synced. It's useful for device-specific or temporal data.
23
+ *
24
+ * @example
25
+ * import * as S from "@effect/schema/Schema";
26
+ * import * as E from "@evolu/react";
27
+ *
28
+ * const TodoId = E.id("Todo");
29
+ * type TodoId = S.Schema.Type<typeof TodoId>;
30
+ *
31
+ * const TodoTable = E.table({
32
+ * id: TodoId,
33
+ * title: E.NonEmptyString1000,
34
+ * });
35
+ * type TodoTable = S.Schema.Type<typeof TodoTable>;
36
+ *
37
+ * const Database = E.database({
38
+ * todo: TodoTable,
39
+ *
40
+ * // Prefix `_` makes the table local-only (it will not sync)
41
+ * _todo: TodoTable,
42
+ * });
43
+ * type Database = S.Schema.Type<typeof Database>;
44
+ *
45
+ * const evolu = E.createEvolu(Database);
46
+ */
47
+ createEvolu,
48
+ } = EvoluFactory.pipe(Effect.provide(EvoluFactoryWebReact), Effect.runSync);
49
+
43
50
  export * from "@evolu/common-react";