@livestore/react 0.3.0-dev.23 → 0.3.0-dev.24
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/.tsbuildinfo +1 -1
- package/dist/LiveStoreProvider.d.ts.map +1 -1
- package/dist/LiveStoreProvider.js +2 -2
- package/dist/LiveStoreProvider.js.map +1 -1
- package/dist/LiveStoreProvider.test.js +2 -2
- package/dist/useAtom.js +5 -5
- package/dist/useQuery.test.js +5 -5
- package/dist/useRow.js +7 -7
- package/dist/useRow.test.js +7 -7
- package/package.json +5 -5
- package/src/LiveStoreProvider.test.tsx +2 -2
- package/src/LiveStoreProvider.tsx +2 -5
- package/src/__snapshots__/useRow.test.tsx.snap +8 -8
- package/src/useAtom.ts +5 -5
- package/src/useQuery.test.tsx +5 -5
- package/src/useRow.test.tsx +7 -7
- package/src/useRow.ts +7 -7
- package/tmp/pack.tgz +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LiveStoreProvider.d.ts","sourceRoot":"","sources":["../src/LiveStoreProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,UAAU,EAAE,wBAAwB,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAA;AACxG,OAAO,EAAe,eAAe,EAAE,MAAM,mBAAmB,CAAA;AAChE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAA;AAC/D,OAAO,KAAK,EAGV,WAAW,EAEX,KAAK,EACN,MAAM,sBAAsB,CAAA;AAC7B,OAAO,
|
|
1
|
+
{"version":3,"file":"LiveStoreProvider.d.ts","sourceRoot":"","sources":["../src/LiveStoreProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,UAAU,EAAE,wBAAwB,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAA;AACxG,OAAO,EAAe,eAAe,EAAE,MAAM,mBAAmB,CAAA;AAChE,OAAO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AK,IAAI,CAAA;IACvC,eAAe,CAAC,EAAE,OAAO,CAAA;IACzB,MAAM,CAAC,EAAE,WAAW,CAAA;IACpB;;;;;OAKG;IACH,qBAAqB,CAAC,EAAE,OAAO,CAAA;IAC/B;;;;OAIG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC,SAAS,CAAA;CAC/B;AAoBD,eAAO,MAAM,iBAAiB,GAAI,mLAe/B,sBAAsB,GAAG;IAAE,QAAQ,CAAC,EAAE,SAAS,CAAA;CAAE,KAAG,KAAK,CAAC,YAiC5D,CAAA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { provideOtel, UnexpectedError } from '@livestore/common';
|
|
2
|
-
import { createStore, StoreInterrupted } from '@livestore/livestore';
|
|
2
|
+
import { createStore, makeShutdownDeferred, StoreInterrupted } from '@livestore/livestore';
|
|
3
3
|
import { errorToString, LS_DEV } from '@livestore/utils';
|
|
4
4
|
import { Cause, Deferred, Effect, Exit, identity, Logger, LogLevel, Schema, Scope, TaskTracing, } from '@livestore/utils/effect';
|
|
5
5
|
import React from 'react';
|
|
@@ -139,7 +139,7 @@ const useCreateStore = ({ schema, storeId, otelOptions, boot, adapter, batchUpda
|
|
|
139
139
|
});
|
|
140
140
|
Effect.gen(function* () {
|
|
141
141
|
const componentScope = yield* Scope.make();
|
|
142
|
-
const shutdownDeferred = yield*
|
|
142
|
+
const shutdownDeferred = yield* makeShutdownDeferred;
|
|
143
143
|
ctxValueRef.current.componentScope = componentScope;
|
|
144
144
|
ctxValueRef.current.shutdownDeferred = shutdownDeferred;
|
|
145
145
|
yield* Effect.gen(function* () {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LiveStoreProvider.js","sourceRoot":"","sources":["../src/LiveStoreProvider.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AAShE,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CA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,CAAA;IAEF,OAAO,WAAW,CAAC,OAAO,CAAC,KAAK,CAAA;AAClC,CAAC,CAAA"}
|
|
@@ -21,7 +21,7 @@ describe('LiveStoreProvider', () => {
|
|
|
21
21
|
};
|
|
22
22
|
const abortController = new AbortController();
|
|
23
23
|
const Root = ({ forceUpdate }) => {
|
|
24
|
-
const bootCb = React.useCallback((store) => store.
|
|
24
|
+
const bootCb = React.useCallback((store) => store.commit(rawSqlMutation({
|
|
25
25
|
sql: sql `INSERT OR IGNORE INTO todos (id, text, completed) VALUES ('t1', 'buy milk', 0)`,
|
|
26
26
|
})), []);
|
|
27
27
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
@@ -50,7 +50,7 @@ describe('LiveStoreProvider', () => {
|
|
|
50
50
|
return React.createElement("div", null, "hello world");
|
|
51
51
|
};
|
|
52
52
|
const Root = ({ forceUpdate }) => {
|
|
53
|
-
const bootCb = React.useCallback((store) => store.
|
|
53
|
+
const bootCb = React.useCallback((store) => store.commit(rawSqlMutation({
|
|
54
54
|
sql: sql `INSERT OR IGNORE INTO todos_missing_table (id, text, completed) VALUES ('t1', 'buy milk', 0)`,
|
|
55
55
|
})), []);
|
|
56
56
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
package/dist/useAtom.js
CHANGED
|
@@ -16,21 +16,21 @@ export const useAtom = (queryDef, options) => {
|
|
|
16
16
|
const table = query$.queryInfo.table;
|
|
17
17
|
if (query$.queryInfo._tag === 'Row') {
|
|
18
18
|
if (table.options.isSingleton && table.options.isSingleColumn) {
|
|
19
|
-
store.
|
|
19
|
+
store.commit(table.update(newValue));
|
|
20
20
|
}
|
|
21
21
|
else if (table.options.isSingleColumn) {
|
|
22
|
-
store.
|
|
22
|
+
store.commit(table.update({ where: { id: query$.queryInfo.id }, values: { value: newValue } }));
|
|
23
23
|
}
|
|
24
24
|
else {
|
|
25
|
-
store.
|
|
25
|
+
store.commit(table.update({ where: { id: query$.queryInfo.id }, values: newValue }));
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
28
|
else {
|
|
29
29
|
if (table.options.isSingleton && table.options.isSingleColumn) {
|
|
30
|
-
store.
|
|
30
|
+
store.commit(table.update({ [query$.queryInfo.column]: newValue }));
|
|
31
31
|
}
|
|
32
32
|
else {
|
|
33
|
-
store.
|
|
33
|
+
store.commit(table.update({
|
|
34
34
|
where: { id: query$.queryInfo.id },
|
|
35
35
|
values: { [query$.queryInfo.column]: newValue },
|
|
36
36
|
}));
|
package/dist/useQuery.test.js
CHANGED
|
@@ -27,7 +27,7 @@ Vitest.describe.each([{ strictMode: true }, { strictMode: false }])('useQuery (s
|
|
|
27
27
|
expect(renderCount.val).toBe(1);
|
|
28
28
|
expect(store.reactivityGraph.getSnapshot({ includeResults: true })).toMatchSnapshot();
|
|
29
29
|
console.log('before mutation');
|
|
30
|
-
ReactTesting.act(() => store.
|
|
30
|
+
ReactTesting.act(() => store.commit(todos.insert({ id: 't1', text: 'buy milk', completed: false })));
|
|
31
31
|
console.log('after mutation');
|
|
32
32
|
expect(result.current.length).toBe(1);
|
|
33
33
|
expect(result.current[0].text).toBe('buy milk');
|
|
@@ -38,7 +38,7 @@ Vitest.describe.each([{ strictMode: true }, { strictMode: false }])('useQuery (s
|
|
|
38
38
|
const { wrapper, store, renderCount } = yield* makeTodoMvcReact({ strictMode });
|
|
39
39
|
const todo1$ = queryDb({ query: `select * from todos where id = 't1'`, schema: Schema.Array(tables.todos.schema) }, { label: 'libraryTracksView1' });
|
|
40
40
|
const todo2$ = queryDb({ query: `select * from todos where id = 't2'`, schema: Schema.Array(tables.todos.schema) }, { label: 'libraryTracksView2' });
|
|
41
|
-
store.
|
|
41
|
+
store.commit(todos.insert({ id: 't1', text: 'buy milk', completed: false }), todos.insert({ id: 't2', text: 'buy eggs', completed: false }));
|
|
42
42
|
const { result, rerender } = ReactTesting.renderHook((todoId) => {
|
|
43
43
|
renderCount.inc();
|
|
44
44
|
const query$ = React.useMemo(() => (todoId === 't1' ? todo1$ : todo2$), [todoId]);
|
|
@@ -47,7 +47,7 @@ Vitest.describe.each([{ strictMode: true }, { strictMode: false }])('useQuery (s
|
|
|
47
47
|
expect(result.current).toBe('buy milk');
|
|
48
48
|
expect(renderCount.val).toBe(1);
|
|
49
49
|
expect(store.reactivityGraph.getSnapshot({ includeResults: true })).toMatchSnapshot('1: after first render');
|
|
50
|
-
ReactTesting.act(() => store.
|
|
50
|
+
ReactTesting.act(() => store.commit(todos.update({ where: { id: 't1' }, values: { text: 'buy soy milk' } })));
|
|
51
51
|
expect(result.current).toBe('buy soy milk');
|
|
52
52
|
expect(renderCount.val).toBe(2);
|
|
53
53
|
expect(store.reactivityGraph.getSnapshot({ includeResults: true })).toMatchSnapshot('2: after first mutation');
|
|
@@ -60,7 +60,7 @@ Vitest.describe.each([{ strictMode: true }, { strictMode: false }])('useQuery (s
|
|
|
60
60
|
const { wrapper, store, renderCount } = yield* makeTodoMvcReact({ strictMode });
|
|
61
61
|
const filter$ = makeRef('t1', { label: 'id-filter' });
|
|
62
62
|
const todo$ = queryDb((get) => tables.todos.query.where('id', get(filter$)), { label: 'todo' });
|
|
63
|
-
store.
|
|
63
|
+
store.commit(todos.insert({ id: 't1', text: 'buy milk', completed: false }), todos.insert({ id: 't2', text: 'buy eggs', completed: false }));
|
|
64
64
|
const { result } = ReactTesting.renderHook(() => {
|
|
65
65
|
renderCount.inc();
|
|
66
66
|
return LiveStoreReact.useQuery(todo$)[0].text;
|
|
@@ -68,7 +68,7 @@ Vitest.describe.each([{ strictMode: true }, { strictMode: false }])('useQuery (s
|
|
|
68
68
|
expect(result.current).toBe('buy milk');
|
|
69
69
|
expect(renderCount.val).toBe(1);
|
|
70
70
|
expect(store.reactivityGraph.getSnapshot({ includeResults: true })).toMatchSnapshot();
|
|
71
|
-
ReactTesting.act(() => store.
|
|
71
|
+
ReactTesting.act(() => store.commit(todos.update({ where: { id: 't1' }, values: { text: 'buy soy milk' } })));
|
|
72
72
|
expect(result.current).toBe('buy soy milk');
|
|
73
73
|
expect(renderCount.val).toBe(2);
|
|
74
74
|
expect(store.reactivityGraph.getSnapshot({ includeResults: true })).toMatchSnapshot();
|
package/dist/useRow.js
CHANGED
|
@@ -57,12 +57,12 @@ export const useRow = (table, idOrOptions, options_) => {
|
|
|
57
57
|
return;
|
|
58
58
|
// NOTE we need to account for the short-hand syntax for single-column+singleton tables
|
|
59
59
|
if (table.options.isSingleton) {
|
|
60
|
-
store.
|
|
60
|
+
store.commit(table.update(newValue));
|
|
61
61
|
}
|
|
62
62
|
else {
|
|
63
|
-
store.
|
|
63
|
+
store.commit(table.update({ where: { id }, values: { value: newValue } }));
|
|
64
64
|
}
|
|
65
|
-
// store.
|
|
65
|
+
// store.commit(updateMutationForQueryInfo(query$.queryInfo!, { value: newValue }))
|
|
66
66
|
};
|
|
67
67
|
}
|
|
68
68
|
else {
|
|
@@ -75,8 +75,8 @@ export const useRow = (table, idOrOptions, options_) => {
|
|
|
75
75
|
// @ts-expect-error TODO fix typing
|
|
76
76
|
if (queryRef.valueRef.current[columnName] === newValue)
|
|
77
77
|
return;
|
|
78
|
-
store.
|
|
79
|
-
// store.
|
|
78
|
+
store.commit(table.update({ where: { id: id ?? 'singleton' }, values: { [columnName]: newValue } }));
|
|
79
|
+
// store.commit(updateMutationForQueryInfo(query$.queryInfo!, { [columnName]: newValue }))
|
|
80
80
|
});
|
|
81
81
|
setState.setMany = (columnValuesOrFn) => {
|
|
82
82
|
const columnValues =
|
|
@@ -89,8 +89,8 @@ export const useRow = (table, idOrOptions, options_) => {
|
|
|
89
89
|
Object.entries(columnValues).every(([columnName, value]) => queryRef.valueRef.current[columnName] === value)) {
|
|
90
90
|
return;
|
|
91
91
|
}
|
|
92
|
-
store.
|
|
93
|
-
// store.
|
|
92
|
+
store.commit(table.update({ where: { id: id ?? 'singleton' }, values: columnValues }));
|
|
93
|
+
// store.commit(updateMutationForQueryInfo(query$.queryInfo!, columnValues))
|
|
94
94
|
};
|
|
95
95
|
return setState;
|
|
96
96
|
}
|
package/dist/useRow.test.js
CHANGED
|
@@ -27,7 +27,7 @@ Vitest.describe('useRow', () => {
|
|
|
27
27
|
expect(result.current.state.username).toBe('');
|
|
28
28
|
expect(renderCount.val).toBe(1);
|
|
29
29
|
expect(store.reactivityGraph.getSnapshot({ includeResults: true })).toMatchSnapshot();
|
|
30
|
-
store.
|
|
30
|
+
store.commit(tables.userInfo.insert({ id: 'u2', username: 'username_u2' }));
|
|
31
31
|
rerender('u2');
|
|
32
32
|
expect(store.reactivityGraph.getSnapshot({ includeResults: true })).toMatchSnapshot();
|
|
33
33
|
expect(result.current.state.id).toBe('u2');
|
|
@@ -60,7 +60,7 @@ Vitest.describe('useRow', () => {
|
|
|
60
60
|
expect(result.current.state.id).toBe('u1');
|
|
61
61
|
expect(result.current.state.username).toBe('');
|
|
62
62
|
expect(renderCount.val).toBe(1);
|
|
63
|
-
ReactTesting.act(() => store.
|
|
63
|
+
ReactTesting.act(() => store.commit(tables.userInfo.update({ where: { id: 'u1' }, values: { username: 'username_u1_hello' } })));
|
|
64
64
|
expect(result.current.state.id).toBe('u1');
|
|
65
65
|
expect(result.current.state.username).toBe('username_u1_hello');
|
|
66
66
|
expect(renderCount.val).toBe(2);
|
|
@@ -90,7 +90,7 @@ Vitest.describe('useRow', () => {
|
|
|
90
90
|
};
|
|
91
91
|
const renderResult = ReactTesting.render(React.createElement(AppRouter, null), { wrapper });
|
|
92
92
|
expect(renderCount.val).toBe(1);
|
|
93
|
-
ReactTesting.act(() => store.
|
|
93
|
+
ReactTesting.act(() => store.commit(LiveStore.rawSqlMutation({
|
|
94
94
|
sql: LiveStore.sql `INSERT INTO todos (id, text, completed) VALUES ('t1', 'buy milk', 0)`,
|
|
95
95
|
})));
|
|
96
96
|
expect(renderCount.val).toBe(1);
|
|
@@ -99,7 +99,7 @@ Vitest.describe('useRow', () => {
|
|
|
99
99
|
expect(renderCount.val).toBe(2);
|
|
100
100
|
expect(renderResult.getByRole('content').innerHTML).toMatchInlineSnapshot(`"{"id":"t1","text":"buy milk","completed":false}"`);
|
|
101
101
|
expect(renderResult.getByRole('current-id').innerHTML).toMatchInlineSnapshot('"Current Task Id: t1"');
|
|
102
|
-
ReactTesting.act(() => store.
|
|
102
|
+
ReactTesting.act(() => store.commit(LiveStore.rawSqlMutation({
|
|
103
103
|
sql: LiveStore.sql `INSERT INTO todos (id, text, completed) VALUES ('t2', 'buy eggs', 0)`,
|
|
104
104
|
}), AppRouterSchema.update({ where: { id: 'singleton' }, values: { currentTaskId: 't2' } }), LiveStore.rawSqlMutation({
|
|
105
105
|
sql: LiveStore.sql `INSERT INTO todos (id, text, completed) VALUES ('t3', 'buy bread', 0)`,
|
|
@@ -109,7 +109,7 @@ Vitest.describe('useRow', () => {
|
|
|
109
109
|
}));
|
|
110
110
|
Vitest.scopedLive('should work for a useRow query chained with a useTemporary query', () => Effect.gen(function* () {
|
|
111
111
|
const { store, wrapper, renderCount } = yield* makeTodoMvcReact({});
|
|
112
|
-
store.
|
|
112
|
+
store.commit(todos.insert({ id: 't1', text: 'buy milk', completed: false }), todos.insert({ id: 't2', text: 'buy bread', completed: false }));
|
|
113
113
|
const { result, unmount, rerender } = ReactTesting.renderHook((userId) => {
|
|
114
114
|
renderCount.inc();
|
|
115
115
|
const [_row, _setRow, rowState$] = LiveStoreReact.useRow(tables.userInfo, userId);
|
|
@@ -119,7 +119,7 @@ Vitest.describe('useRow', () => {
|
|
|
119
119
|
{ label: 'todosFiltered', deps: userId }));
|
|
120
120
|
return { todos };
|
|
121
121
|
}, { wrapper, initialProps: 'u1' });
|
|
122
|
-
ReactTesting.act(() => store.
|
|
122
|
+
ReactTesting.act(() => store.commit(tables.userInfo.insert({ id: 'u2', username: 'username_u2', text: 'milk' })));
|
|
123
123
|
expect(result.current.todos.length).toBe(2);
|
|
124
124
|
expect(renderCount.val).toBe(1);
|
|
125
125
|
rerender('u2');
|
|
@@ -153,7 +153,7 @@ Vitest.describe('useRow', () => {
|
|
|
153
153
|
expect(renderCount.val).toBe(1);
|
|
154
154
|
// For u2 we'll make sure that the row already exists,
|
|
155
155
|
// so the lazy `insert` will be skipped
|
|
156
|
-
ReactTesting.act(() => store.
|
|
156
|
+
ReactTesting.act(() => store.commit(tables.userInfo.insert({ id: 'u2', username: 'username_u2' })));
|
|
157
157
|
rerender('u2');
|
|
158
158
|
expect(result.current.state.id).toBe('u2');
|
|
159
159
|
expect(result.current.state.username).toBe('username_u2');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@livestore/react",
|
|
3
|
-
"version": "0.3.0-dev.
|
|
3
|
+
"version": "0.3.0-dev.24",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"exports": {
|
|
@@ -23,9 +23,9 @@
|
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"@opentelemetry/api": "1.9.0",
|
|
26
|
-
"@livestore/common": "0.3.0-dev.
|
|
27
|
-
"@livestore/
|
|
28
|
-
"@livestore/
|
|
26
|
+
"@livestore/common": "0.3.0-dev.24",
|
|
27
|
+
"@livestore/livestore": "0.3.0-dev.24",
|
|
28
|
+
"@livestore/utils": "0.3.0-dev.24"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@opentelemetry/sdk-trace-base": "^1.30.1",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"typescript": "^5.8.2",
|
|
41
41
|
"vite": "^6.2.1",
|
|
42
42
|
"vitest": "^3.0.8",
|
|
43
|
-
"@livestore/adapter-web": "0.3.0-dev.
|
|
43
|
+
"@livestore/adapter-web": "0.3.0-dev.24"
|
|
44
44
|
},
|
|
45
45
|
"peerDependencies": {
|
|
46
46
|
"react": "~19.0.0"
|
|
@@ -31,7 +31,7 @@ describe('LiveStoreProvider', () => {
|
|
|
31
31
|
const Root = ({ forceUpdate }: { forceUpdate: number }) => {
|
|
32
32
|
const bootCb = React.useCallback(
|
|
33
33
|
(store: Store) =>
|
|
34
|
-
store.
|
|
34
|
+
store.commit(
|
|
35
35
|
rawSqlMutation({
|
|
36
36
|
sql: sql`INSERT OR IGNORE INTO todos (id, text, completed) VALUES ('t1', 'buy milk', 0)`,
|
|
37
37
|
}),
|
|
@@ -88,7 +88,7 @@ describe('LiveStoreProvider', () => {
|
|
|
88
88
|
const Root = ({ forceUpdate }: { forceUpdate: number }) => {
|
|
89
89
|
const bootCb = React.useCallback(
|
|
90
90
|
(store: Store) =>
|
|
91
|
-
store.
|
|
91
|
+
store.commit(
|
|
92
92
|
rawSqlMutation({
|
|
93
93
|
sql: sql`INSERT OR IGNORE INTO todos_missing_table (id, text, completed) VALUES ('t1', 'buy milk', 0)`,
|
|
94
94
|
}),
|
|
@@ -8,7 +8,7 @@ import type {
|
|
|
8
8
|
ShutdownDeferred,
|
|
9
9
|
Store,
|
|
10
10
|
} from '@livestore/livestore'
|
|
11
|
-
import { createStore, StoreInterrupted } from '@livestore/livestore'
|
|
11
|
+
import { createStore, makeShutdownDeferred, StoreInterrupted } from '@livestore/livestore'
|
|
12
12
|
import { errorToString, LS_DEV } from '@livestore/utils'
|
|
13
13
|
import type { OtelTracer } from '@livestore/utils/effect'
|
|
14
14
|
import {
|
|
@@ -291,10 +291,7 @@ const useCreateStore = ({
|
|
|
291
291
|
|
|
292
292
|
Effect.gen(function* () {
|
|
293
293
|
const componentScope = yield* Scope.make()
|
|
294
|
-
const shutdownDeferred = yield*
|
|
295
|
-
void,
|
|
296
|
-
UnexpectedError | IntentionalShutdownCause | StoreInterrupted
|
|
297
|
-
>()
|
|
294
|
+
const shutdownDeferred = yield* makeShutdownDeferred
|
|
298
295
|
|
|
299
296
|
ctxValueRef.current.componentScope = componentScope
|
|
300
297
|
ctxValueRef.current.shutdownDeferred = shutdownDeferred
|
|
@@ -27,7 +27,7 @@ exports[`useRow > otel > should update the data based on component key strictMod
|
|
|
27
27
|
"_name": "LiveStore:mutations",
|
|
28
28
|
"children": [
|
|
29
29
|
{
|
|
30
|
-
"_name": "LiveStore:
|
|
30
|
+
"_name": "LiveStore:commit",
|
|
31
31
|
"attributes": {
|
|
32
32
|
"livestore.mutationEventTags": [
|
|
33
33
|
"_Derived_Create_UserInfo",
|
|
@@ -64,9 +64,9 @@ exports[`useRow > otel > should update the data based on component key strictMod
|
|
|
64
64
|
},
|
|
65
65
|
},
|
|
66
66
|
{
|
|
67
|
-
"_name": "LiveStore:
|
|
67
|
+
"_name": "LiveStore:commit",
|
|
68
68
|
"attributes": {
|
|
69
|
-
"livestore.
|
|
69
|
+
"livestore.commitLabel": "rowQuery:UserInfo:u1",
|
|
70
70
|
"livestore.mutationEventTags": [
|
|
71
71
|
"_Derived_Create_UserInfo",
|
|
72
72
|
],
|
|
@@ -109,7 +109,7 @@ exports[`useRow > otel > should update the data based on component key strictMod
|
|
|
109
109
|
{
|
|
110
110
|
"_name": "db:SELECT * FROM 'UserInfo' WHERE id = ?",
|
|
111
111
|
"attributes": {
|
|
112
|
-
"livestore.debugRefreshReason": "
|
|
112
|
+
"livestore.debugRefreshReason": "commit",
|
|
113
113
|
"sql.query": "SELECT * FROM 'UserInfo' WHERE id = ?",
|
|
114
114
|
"sql.rowsCount": 1,
|
|
115
115
|
},
|
|
@@ -223,7 +223,7 @@ exports[`useRow > otel > should update the data based on component key strictMod
|
|
|
223
223
|
"_name": "LiveStore:mutations",
|
|
224
224
|
"children": [
|
|
225
225
|
{
|
|
226
|
-
"_name": "LiveStore:
|
|
226
|
+
"_name": "LiveStore:commit",
|
|
227
227
|
"attributes": {
|
|
228
228
|
"livestore.mutationEventTags": [
|
|
229
229
|
"_Derived_Create_UserInfo",
|
|
@@ -260,9 +260,9 @@ exports[`useRow > otel > should update the data based on component key strictMod
|
|
|
260
260
|
},
|
|
261
261
|
},
|
|
262
262
|
{
|
|
263
|
-
"_name": "LiveStore:
|
|
263
|
+
"_name": "LiveStore:commit",
|
|
264
264
|
"attributes": {
|
|
265
|
-
"livestore.
|
|
265
|
+
"livestore.commitLabel": "rowQuery:UserInfo:u1",
|
|
266
266
|
"livestore.mutationEventTags": [
|
|
267
267
|
"_Derived_Create_UserInfo",
|
|
268
268
|
],
|
|
@@ -305,7 +305,7 @@ exports[`useRow > otel > should update the data based on component key strictMod
|
|
|
305
305
|
{
|
|
306
306
|
"_name": "db:SELECT * FROM 'UserInfo' WHERE id = ?",
|
|
307
307
|
"attributes": {
|
|
308
|
-
"livestore.debugRefreshReason": "
|
|
308
|
+
"livestore.debugRefreshReason": "commit",
|
|
309
309
|
"sql.query": "SELECT * FROM 'UserInfo' WHERE id = ?",
|
|
310
310
|
"sql.rowsCount": 1,
|
|
311
311
|
},
|
package/src/useAtom.ts
CHANGED
|
@@ -40,17 +40,17 @@ export const useAtom = <
|
|
|
40
40
|
|
|
41
41
|
if (query$.queryInfo._tag === 'Row') {
|
|
42
42
|
if (table.options.isSingleton && table.options.isSingleColumn) {
|
|
43
|
-
store.
|
|
43
|
+
store.commit(table.update(newValue))
|
|
44
44
|
} else if (table.options.isSingleColumn) {
|
|
45
|
-
store.
|
|
45
|
+
store.commit(table.update({ where: { id: query$.queryInfo.id }, values: { value: newValue } }))
|
|
46
46
|
} else {
|
|
47
|
-
store.
|
|
47
|
+
store.commit(table.update({ where: { id: query$.queryInfo.id }, values: newValue }))
|
|
48
48
|
}
|
|
49
49
|
} else {
|
|
50
50
|
if (table.options.isSingleton && table.options.isSingleColumn) {
|
|
51
|
-
store.
|
|
51
|
+
store.commit(table.update({ [query$.queryInfo.column]: newValue }))
|
|
52
52
|
} else {
|
|
53
|
-
store.
|
|
53
|
+
store.commit(
|
|
54
54
|
table.update({
|
|
55
55
|
where: { id: query$.queryInfo.id },
|
|
56
56
|
values: { [query$.queryInfo.column]: newValue },
|
package/src/useQuery.test.tsx
CHANGED
|
@@ -42,7 +42,7 @@ Vitest.describe.each([{ strictMode: true }, { strictMode: false }] as const)(
|
|
|
42
42
|
|
|
43
43
|
console.log('before mutation')
|
|
44
44
|
|
|
45
|
-
ReactTesting.act(() => store.
|
|
45
|
+
ReactTesting.act(() => store.commit(todos.insert({ id: 't1', text: 'buy milk', completed: false })))
|
|
46
46
|
|
|
47
47
|
console.log('after mutation')
|
|
48
48
|
|
|
@@ -66,7 +66,7 @@ Vitest.describe.each([{ strictMode: true }, { strictMode: false }] as const)(
|
|
|
66
66
|
{ label: 'libraryTracksView2' },
|
|
67
67
|
)
|
|
68
68
|
|
|
69
|
-
store.
|
|
69
|
+
store.commit(
|
|
70
70
|
todos.insert({ id: 't1', text: 'buy milk', completed: false }),
|
|
71
71
|
todos.insert({ id: 't2', text: 'buy eggs', completed: false }),
|
|
72
72
|
)
|
|
@@ -86,7 +86,7 @@ Vitest.describe.each([{ strictMode: true }, { strictMode: false }] as const)(
|
|
|
86
86
|
expect(renderCount.val).toBe(1)
|
|
87
87
|
expect(store.reactivityGraph.getSnapshot({ includeResults: true })).toMatchSnapshot('1: after first render')
|
|
88
88
|
|
|
89
|
-
ReactTesting.act(() => store.
|
|
89
|
+
ReactTesting.act(() => store.commit(todos.update({ where: { id: 't1' }, values: { text: 'buy soy milk' } })))
|
|
90
90
|
|
|
91
91
|
expect(result.current).toBe('buy soy milk')
|
|
92
92
|
expect(renderCount.val).toBe(2)
|
|
@@ -108,7 +108,7 @@ Vitest.describe.each([{ strictMode: true }, { strictMode: false }] as const)(
|
|
|
108
108
|
|
|
109
109
|
const todo$ = queryDb((get) => tables.todos.query.where('id', get(filter$)), { label: 'todo' })
|
|
110
110
|
|
|
111
|
-
store.
|
|
111
|
+
store.commit(
|
|
112
112
|
todos.insert({ id: 't1', text: 'buy milk', completed: false }),
|
|
113
113
|
todos.insert({ id: 't2', text: 'buy eggs', completed: false }),
|
|
114
114
|
)
|
|
@@ -126,7 +126,7 @@ Vitest.describe.each([{ strictMode: true }, { strictMode: false }] as const)(
|
|
|
126
126
|
expect(renderCount.val).toBe(1)
|
|
127
127
|
expect(store.reactivityGraph.getSnapshot({ includeResults: true })).toMatchSnapshot()
|
|
128
128
|
|
|
129
|
-
ReactTesting.act(() => store.
|
|
129
|
+
ReactTesting.act(() => store.commit(todos.update({ where: { id: 't1' }, values: { text: 'buy soy milk' } })))
|
|
130
130
|
|
|
131
131
|
expect(result.current).toBe('buy soy milk')
|
|
132
132
|
expect(renderCount.val).toBe(2)
|
package/src/useRow.test.tsx
CHANGED
|
@@ -38,7 +38,7 @@ Vitest.describe('useRow', () => {
|
|
|
38
38
|
expect(result.current.state.username).toBe('')
|
|
39
39
|
expect(renderCount.val).toBe(1)
|
|
40
40
|
expect(store.reactivityGraph.getSnapshot({ includeResults: true })).toMatchSnapshot()
|
|
41
|
-
store.
|
|
41
|
+
store.commit(tables.userInfo.insert({ id: 'u2', username: 'username_u2' }))
|
|
42
42
|
|
|
43
43
|
rerender('u2')
|
|
44
44
|
|
|
@@ -96,7 +96,7 @@ Vitest.describe('useRow', () => {
|
|
|
96
96
|
expect(renderCount.val).toBe(1)
|
|
97
97
|
|
|
98
98
|
ReactTesting.act(() =>
|
|
99
|
-
store.
|
|
99
|
+
store.commit(tables.userInfo.update({ where: { id: 'u1' }, values: { username: 'username_u1_hello' } })),
|
|
100
100
|
)
|
|
101
101
|
|
|
102
102
|
expect(result.current.state.id).toBe('u1')
|
|
@@ -155,7 +155,7 @@ Vitest.describe('useRow', () => {
|
|
|
155
155
|
expect(renderCount.val).toBe(1)
|
|
156
156
|
|
|
157
157
|
ReactTesting.act(() =>
|
|
158
|
-
store.
|
|
158
|
+
store.commit(
|
|
159
159
|
LiveStore.rawSqlMutation({
|
|
160
160
|
sql: LiveStore.sql`INSERT INTO todos (id, text, completed) VALUES ('t1', 'buy milk', 0)`,
|
|
161
161
|
}),
|
|
@@ -175,7 +175,7 @@ Vitest.describe('useRow', () => {
|
|
|
175
175
|
expect(renderResult.getByRole('current-id').innerHTML).toMatchInlineSnapshot('"Current Task Id: t1"')
|
|
176
176
|
|
|
177
177
|
ReactTesting.act(() =>
|
|
178
|
-
store.
|
|
178
|
+
store.commit(
|
|
179
179
|
LiveStore.rawSqlMutation({
|
|
180
180
|
sql: LiveStore.sql`INSERT INTO todos (id, text, completed) VALUES ('t2', 'buy eggs', 0)`,
|
|
181
181
|
}),
|
|
@@ -195,7 +195,7 @@ Vitest.describe('useRow', () => {
|
|
|
195
195
|
Effect.gen(function* () {
|
|
196
196
|
const { store, wrapper, renderCount } = yield* makeTodoMvcReact({})
|
|
197
197
|
|
|
198
|
-
store.
|
|
198
|
+
store.commit(
|
|
199
199
|
todos.insert({ id: 't1', text: 'buy milk', completed: false }),
|
|
200
200
|
todos.insert({ id: 't2', text: 'buy bread', completed: false }),
|
|
201
201
|
)
|
|
@@ -220,7 +220,7 @@ Vitest.describe('useRow', () => {
|
|
|
220
220
|
{ wrapper, initialProps: 'u1' },
|
|
221
221
|
)
|
|
222
222
|
|
|
223
|
-
ReactTesting.act(() => store.
|
|
223
|
+
ReactTesting.act(() => store.commit(tables.userInfo.insert({ id: 'u2', username: 'username_u2', text: 'milk' })))
|
|
224
224
|
|
|
225
225
|
expect(result.current.todos.length).toBe(2)
|
|
226
226
|
expect(renderCount.val).toBe(1)
|
|
@@ -274,7 +274,7 @@ Vitest.describe('useRow', () => {
|
|
|
274
274
|
|
|
275
275
|
// For u2 we'll make sure that the row already exists,
|
|
276
276
|
// so the lazy `insert` will be skipped
|
|
277
|
-
ReactTesting.act(() => store.
|
|
277
|
+
ReactTesting.act(() => store.commit(tables.userInfo.insert({ id: 'u2', username: 'username_u2' })))
|
|
278
278
|
|
|
279
279
|
rerender('u2')
|
|
280
280
|
|
package/src/useRow.ts
CHANGED
|
@@ -138,11 +138,11 @@ export const useRow: {
|
|
|
138
138
|
|
|
139
139
|
// NOTE we need to account for the short-hand syntax for single-column+singleton tables
|
|
140
140
|
if (table.options.isSingleton) {
|
|
141
|
-
store.
|
|
141
|
+
store.commit(table.update(newValue))
|
|
142
142
|
} else {
|
|
143
|
-
store.
|
|
143
|
+
store.commit(table.update({ where: { id }, values: { value: newValue } }))
|
|
144
144
|
}
|
|
145
|
-
// store.
|
|
145
|
+
// store.commit(updateMutationForQueryInfo(query$.queryInfo!, { value: newValue }))
|
|
146
146
|
}
|
|
147
147
|
} else {
|
|
148
148
|
const setState = // TODO: do we have a better type for the values that can go in SQLite?
|
|
@@ -155,8 +155,8 @@ export const useRow: {
|
|
|
155
155
|
// @ts-expect-error TODO fix typing
|
|
156
156
|
if (queryRef.valueRef.current[columnName] === newValue) return
|
|
157
157
|
|
|
158
|
-
store.
|
|
159
|
-
// store.
|
|
158
|
+
store.commit(table.update({ where: { id: id ?? 'singleton' }, values: { [columnName]: newValue } }))
|
|
159
|
+
// store.commit(updateMutationForQueryInfo(query$.queryInfo!, { [columnName]: newValue }))
|
|
160
160
|
})
|
|
161
161
|
|
|
162
162
|
setState.setMany = (columnValuesOrFn: Partial<TComponentState>) => {
|
|
@@ -173,8 +173,8 @@ export const useRow: {
|
|
|
173
173
|
return
|
|
174
174
|
}
|
|
175
175
|
|
|
176
|
-
store.
|
|
177
|
-
// store.
|
|
176
|
+
store.commit(table.update({ where: { id: id ?? 'singleton' }, values: columnValues }))
|
|
177
|
+
// store.commit(updateMutationForQueryInfo(query$.queryInfo!, columnValues))
|
|
178
178
|
}
|
|
179
179
|
|
|
180
180
|
return setState as any
|
package/tmp/pack.tgz
CHANGED
|
Binary file
|