@evolu/react 11.0.1 → 11.0.3
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 +1 -1
- package/dist/src/Task.d.ts.map +1 -1
- package/dist/src/index.d.ts +2 -2
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/local-first/createEvoluBinding.d.ts.map +1 -1
- package/dist/src/local-first/createEvoluBinding.js +6 -6
- package/dist/src/local-first/useIsSsr.d.ts.map +1 -1
- package/dist/src/local-first/useIsSsr.js +0 -1
- package/package.json +8 -6
- package/src/Task.test.ts +20 -0
- package/src/{Task.tsx → Task.ts} +1 -1
- package/src/index.ts +2 -2
- package/src/local-first/createEvoluBinding.test.ts +18 -0
- package/src/local-first/{createEvoluBinding.tsx → createEvoluBinding.ts} +6 -5
- package/src/local-first/useIsSsr.ts +0 -1
package/dist/src/Task.d.ts
CHANGED
|
@@ -33,7 +33,7 @@ import { type ReactNode } from "react";
|
|
|
33
33
|
* </RunContext>;
|
|
34
34
|
* ```
|
|
35
35
|
*/
|
|
36
|
-
export declare const createRunBinding: <R extends DisposableRun<any> = DisposableRun
|
|
36
|
+
export declare const createRunBinding: <R extends DisposableRun<any> = DisposableRun>() => {
|
|
37
37
|
readonly RunContext: React.FC<{
|
|
38
38
|
readonly value: Run<R extends DisposableRun<infer D> ? D : never>;
|
|
39
39
|
readonly children?: ReactNode;
|
package/dist/src/Task.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Task.d.ts","sourceRoot":"","sources":["../../src/Task.
|
|
1
|
+
{"version":3,"file":"Task.d.ts","sourceRoot":"","sources":["../../src/Task.ts"],"names":[],"mappings":"AAEA,OAAO,EAAU,KAAK,aAAa,EAAE,KAAK,GAAG,EAAE,MAAM,eAAe,CAAC;AACrE,OAAO,EAAsB,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAE3D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,eAAO,MAAM,gBAAgB,GAC3B,CAAC,SAAS,aAAa,CAAC,GAAG,CAAC,GAAG,aAAa,OACzC;IACH,QAAQ,CAAC,UAAU,EAAE,KAAK,CAAC,EAAE,CAAC;QAC5B,QAAQ,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,SAAS,aAAa,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC,CAAC;QAClE,QAAQ,CAAC,QAAQ,CAAC,EAAE,SAAS,CAAC;KAC/B,CAAC,CAAC;IACH,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,CAAC,CAAC,SAAS,aAAa,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC,CAAC;CAc1E,CAAC"}
|
package/dist/src/index.d.ts
CHANGED
package/dist/src/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,qCAAqC,CAAC;AACpD,cAAc,2BAA2B,CAAC;AAC1C,cAAc,WAAW,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createEvoluBinding.d.ts","sourceRoot":"","sources":["../../../src/local-first/createEvoluBinding.
|
|
1
|
+
{"version":3,"file":"createEvoluBinding.d.ts","sourceRoot":"","sources":["../../../src/local-first/createEvoluBinding.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,KAAK,EACL,WAAW,EACX,OAAO,EACP,kBAAkB,EAClB,0BAA0B,EAC1B,KAAK,EACL,SAAS,EACT,GAAG,EACJ,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAOL,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AAGf,MAAM,WAAW,YAAY,CAAC,CAAC,SAA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QAAQ,CAAC,oBAAoB,EAAE,CAAC,CAAC,SAAS,GAAG,EAC3C,KAAK,EAAE,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,EAClB,OAAO,CAAC,EAAE,OAAO,CAAC;QAChB;;;WAGG;QACH,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;KACxB,CAAC,KACC,SAAS,CAAC,CAAC,CAAC,CAAC;IAElB,0EAA0E;IAC1E,QAAQ,CAAC,QAAQ,EAAE,CACjB,KAAK,EAAE,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,EAC1C,UAAU,CAAC,EAAE,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,KAC7C,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC;CACvC;AAED;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,kBAAkB,GAC7B,CAAC,SAAS,WAAW,GAAG,WAAW,OAChC,YAAY,CAAC,CAAC,CAkGlB,CAAC"}
|
|
@@ -29,7 +29,7 @@ export const createEvoluBinding = () => {
|
|
|
29
29
|
const evolu = useEvolu();
|
|
30
30
|
const { once } = useRef(options).current;
|
|
31
31
|
if (once) {
|
|
32
|
-
/*
|
|
32
|
+
/* oxlint-disable react/rules-of-hooks -- The once branch remains stable for the lifetime of this subscription. */
|
|
33
33
|
useEffect(() => evolu.subscribeQuery(query)(constVoid), [evolu, query]);
|
|
34
34
|
return evolu.getQueryRows(query);
|
|
35
35
|
}
|
|
@@ -56,15 +56,15 @@ export const createEvoluBinding = () => {
|
|
|
56
56
|
if (!options.promises)
|
|
57
57
|
void evolu.loadQueries(allQueries);
|
|
58
58
|
}
|
|
59
|
+
else if (options.promises) {
|
|
60
|
+
options.promises.map(use);
|
|
61
|
+
}
|
|
59
62
|
else {
|
|
60
|
-
|
|
61
|
-
options.promises.map(use);
|
|
62
|
-
else
|
|
63
|
-
evolu.loadQueries(allQueries).map(use);
|
|
63
|
+
evolu.loadQueries(allQueries).map(use);
|
|
64
64
|
}
|
|
65
65
|
return allQueries.map((query, index) =>
|
|
66
66
|
// Safe until the number of queries is stable.
|
|
67
|
-
//
|
|
67
|
+
// oxlint-disable-next-line react/rules-of-hooks -- The number and order of queries must remain stable.
|
|
68
68
|
useQuerySubscription(query, { once: index > queries.length - 1 }));
|
|
69
69
|
};
|
|
70
70
|
const useOwner = (owner, transports) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useIsSsr.d.ts","sourceRoot":"","sources":["../../../src/local-first/useIsSsr.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useIsSsr.d.ts","sourceRoot":"","sources":["../../../src/local-first/useIsSsr.ts"],"names":[],"mappings":"AAKA;;;;GAIG;AACH,eAAO,MAAM,QAAQ,QAAO,OAEiC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@evolu/react",
|
|
3
|
-
"version": "11.0.
|
|
3
|
+
"version": "11.0.3",
|
|
4
4
|
"description": "Evolu for React",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"evolu",
|
|
@@ -29,26 +29,28 @@
|
|
|
29
29
|
},
|
|
30
30
|
"files": [
|
|
31
31
|
"dist/src/**",
|
|
32
|
+
"!dist/**/*.test.*",
|
|
32
33
|
"src/**",
|
|
33
34
|
"README.md"
|
|
34
35
|
],
|
|
35
36
|
"devDependencies": {
|
|
37
|
+
"@evolu/common": "8.10.0",
|
|
38
|
+
"@evolu/typescript-config": "0.1.1",
|
|
39
|
+
"@types/node": "^24.10.9",
|
|
36
40
|
"@types/react": "^19.2.18",
|
|
37
41
|
"@types/react-dom": "^19.2.4",
|
|
38
42
|
"@typescript/native": "npm:typescript@^7.0.2",
|
|
39
|
-
"react": "19.2.3"
|
|
40
|
-
"@evolu/common": "8.1.0",
|
|
41
|
-
"@evolu/typescript-config": "0.0.2"
|
|
43
|
+
"react": "19.2.3"
|
|
42
44
|
},
|
|
43
45
|
"peerDependencies": {
|
|
44
|
-
"@evolu/common": "^8.
|
|
46
|
+
"@evolu/common": "^8.10.0",
|
|
45
47
|
"react": ">=19"
|
|
46
48
|
},
|
|
47
49
|
"publishConfig": {
|
|
48
50
|
"access": "public"
|
|
49
51
|
},
|
|
50
52
|
"engines": {
|
|
51
|
-
"node": ">=24.
|
|
53
|
+
"node": ">=24.20.0"
|
|
52
54
|
},
|
|
53
55
|
"sideEffects": false,
|
|
54
56
|
"scripts": {
|
package/src/Task.test.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { assertType, type DisposableRun, type Run } from "@evolu/common";
|
|
2
|
+
import { test } from "node:test";
|
|
3
|
+
import { createRunBinding } from "./Task.ts";
|
|
4
|
+
|
|
5
|
+
interface TestDeps {
|
|
6
|
+
readonly value: string;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
declare const _disposableRun: DisposableRun<TestDeps>;
|
|
10
|
+
|
|
11
|
+
// @ts-expect-error createRunBinding requires a DisposableRun type witness.
|
|
12
|
+
const _invalidBinding = createRunBinding<Run<TestDeps>>();
|
|
13
|
+
|
|
14
|
+
test("infers deps from DisposableRun and exposes Run", () => {
|
|
15
|
+
const { RunContext: _RunContext, useRun } =
|
|
16
|
+
createRunBinding<typeof _disposableRun>();
|
|
17
|
+
|
|
18
|
+
assertType<ReturnType<typeof useRun>, Run<TestDeps>>();
|
|
19
|
+
assertType<Parameters<typeof _RunContext>[0]["value"], Run<TestDeps>>();
|
|
20
|
+
});
|
package/src/{Task.tsx → Task.ts}
RENAMED
|
@@ -37,7 +37,7 @@ import { createContext, use, type ReactNode } from "react";
|
|
|
37
37
|
* ```
|
|
38
38
|
*/
|
|
39
39
|
export const createRunBinding = <
|
|
40
|
-
R extends DisposableRun<any> = DisposableRun
|
|
40
|
+
R extends DisposableRun<any> = DisposableRun,
|
|
41
41
|
>(): {
|
|
42
42
|
readonly RunContext: React.FC<{
|
|
43
43
|
readonly value: Run<R extends DisposableRun<infer D> ? D : never>;
|
package/src/index.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from "./local-first/createEvoluBinding.
|
|
1
|
+
export * from "./local-first/createEvoluBinding.ts";
|
|
2
2
|
export * from "./local-first/useIsSsr.ts";
|
|
3
|
-
export * from "./Task.
|
|
3
|
+
export * from "./Task.ts";
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { assertType, id, type Evolu } from "@evolu/common";
|
|
2
|
+
import { test } from "node:test";
|
|
3
|
+
import { createEvoluBinding } from "./createEvoluBinding.ts";
|
|
4
|
+
|
|
5
|
+
const TestSchema = {
|
|
6
|
+
test: {
|
|
7
|
+
id: id("Test"),
|
|
8
|
+
},
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
// @ts-expect-error createEvoluBinding accepts the schema as a type argument.
|
|
12
|
+
const _invalidBinding = createEvoluBinding(TestSchema);
|
|
13
|
+
|
|
14
|
+
test("creates a binding from an EvoluSchema type", () => {
|
|
15
|
+
const { useEvolu } = createEvoluBinding<typeof TestSchema>();
|
|
16
|
+
|
|
17
|
+
assertType<ReturnType<typeof useEvolu>, Evolu<typeof TestSchema>>();
|
|
18
|
+
});
|
|
@@ -131,7 +131,7 @@ export const createEvoluBinding = <
|
|
|
131
131
|
const { once } = useRef(options).current;
|
|
132
132
|
|
|
133
133
|
if (once) {
|
|
134
|
-
/*
|
|
134
|
+
/* oxlint-disable react/rules-of-hooks -- The once branch remains stable for the lifetime of this subscription. */
|
|
135
135
|
useEffect(() => evolu.subscribeQuery(query)(constVoid), [evolu, query]);
|
|
136
136
|
return evolu.getQueryRows(query);
|
|
137
137
|
}
|
|
@@ -140,7 +140,7 @@ export const createEvoluBinding = <
|
|
|
140
140
|
useMemo(() => evolu.subscribeQuery(query), [evolu, query]),
|
|
141
141
|
useMemo(() => () => evolu.getQueryRows(query), [evolu, query]),
|
|
142
142
|
() => emptyArray as QueryRows<R>,
|
|
143
|
-
/*
|
|
143
|
+
/* oxlint-enable react/rules-of-hooks */
|
|
144
144
|
);
|
|
145
145
|
};
|
|
146
146
|
|
|
@@ -180,14 +180,15 @@ export const createEvoluBinding = <
|
|
|
180
180
|
const wasSSR = useIsSsr();
|
|
181
181
|
if (wasSSR) {
|
|
182
182
|
if (!options.promises) void evolu.loadQueries(allQueries);
|
|
183
|
+
} else if (options.promises) {
|
|
184
|
+
options.promises.map(use);
|
|
183
185
|
} else {
|
|
184
|
-
|
|
185
|
-
else evolu.loadQueries(allQueries).map(use);
|
|
186
|
+
evolu.loadQueries(allQueries).map(use);
|
|
186
187
|
}
|
|
187
188
|
|
|
188
189
|
return allQueries.map((query, index) =>
|
|
189
190
|
// Safe until the number of queries is stable.
|
|
190
|
-
//
|
|
191
|
+
// oxlint-disable-next-line react/rules-of-hooks -- The number and order of queries must remain stable.
|
|
191
192
|
useQuerySubscription(query, { once: index > queries.length - 1 }),
|
|
192
193
|
) as never;
|
|
193
194
|
};
|