@livestore/livestore 0.0.0-snapshot-8fd59846e2580d37bdd37ae607e9db2a458a8b63 → 0.0.0-snapshot-9d9745f6fc391ab1a695b44e8fad6c460c7b3b77
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/QueryCache.d.ts +4 -6
- package/dist/QueryCache.d.ts.map +1 -1
- package/dist/QueryCache.js +3 -4
- package/dist/QueryCache.js.map +1 -1
- package/dist/SqliteDbWrapper.d.ts +3 -2
- package/dist/SqliteDbWrapper.d.ts.map +1 -1
- package/dist/SqliteDbWrapper.js +9 -6
- package/dist/SqliteDbWrapper.js.map +1 -1
- package/dist/SqliteDbWrapper.test.js +1 -1
- package/dist/effect/LiveStore.d.ts +2 -2
- package/dist/effect/LiveStore.js +2 -2
- package/dist/effect/LiveStore.js.map +1 -1
- package/dist/effect/mod.d.ts +2 -2
- package/dist/effect/mod.d.ts.map +1 -1
- package/dist/effect/mod.js +2 -2
- package/dist/effect/mod.js.map +1 -1
- package/dist/internal/mod.d.ts +2 -2
- package/dist/internal/mod.js +2 -2
- package/dist/live-queries/base-class.d.ts +4 -4
- package/dist/live-queries/base-class.d.ts.map +1 -1
- package/dist/live-queries/base-class.js +1 -1
- package/dist/live-queries/base-class.js.map +1 -1
- package/dist/live-queries/client-document-get-query.d.ts +1 -1
- package/dist/live-queries/computed.d.ts +4 -4
- package/dist/live-queries/computed.js +2 -2
- package/dist/live-queries/db-query.d.ts +4 -4
- package/dist/live-queries/db-query.js +4 -4
- package/dist/live-queries/db-query.test.js +19 -17
- package/dist/live-queries/db-query.test.js.map +1 -1
- package/dist/live-queries/mod.d.ts +4 -4
- package/dist/live-queries/mod.js +4 -4
- package/dist/live-queries/signal.d.ts +4 -4
- package/dist/live-queries/signal.js +1 -1
- package/dist/live-queries/signal.test.js +3 -3
- package/dist/mod.d.ts +10 -10
- package/dist/mod.d.ts.map +1 -1
- package/dist/mod.js +9 -9
- package/dist/mod.js.map +1 -1
- package/dist/reactive.d.ts.map +1 -1
- package/dist/reactive.js +2 -3
- package/dist/reactive.js.map +1 -1
- package/dist/reactive.test.js +1 -1
- package/dist/store/create-store.d.ts +6 -3
- package/dist/store/create-store.d.ts.map +1 -1
- package/dist/store/create-store.js +3 -2
- package/dist/store/create-store.js.map +1 -1
- package/dist/store/devtools.d.ts +3 -3
- package/dist/store/devtools.js +2 -2
- package/dist/store/store-types.d.ts +7 -4
- package/dist/store/store-types.d.ts.map +1 -1
- package/dist/store/store-types.js.map +1 -1
- package/dist/store/store.d.ts +11 -10
- package/dist/store/store.d.ts.map +1 -1
- package/dist/store/store.js +18 -9
- package/dist/store/store.js.map +1 -1
- package/dist/utils/dev.d.ts.map +1 -1
- package/dist/utils/dev.js +0 -1
- package/dist/utils/dev.js.map +1 -1
- package/dist/utils/stack-info.d.ts.map +1 -1
- package/dist/utils/stack-info.js +5 -1
- package/dist/utils/stack-info.js.map +1 -1
- package/dist/utils/stack-info.test.js +7 -3
- package/dist/utils/stack-info.test.js.map +1 -1
- package/dist/utils/tests/fixture.d.ts +33 -2
- package/dist/utils/tests/fixture.d.ts.map +1 -1
- package/dist/utils/tests/fixture.js +16 -3
- package/dist/utils/tests/fixture.js.map +1 -1
- package/dist/utils/tests/mod.d.ts +3 -3
- package/dist/utils/tests/mod.d.ts.map +1 -1
- package/dist/utils/tests/mod.js +3 -3
- package/dist/utils/tests/mod.js.map +1 -1
- package/dist/utils/tests/otel.d.ts.map +1 -1
- package/dist/utils/tests/otel.js +1 -1
- package/dist/utils/tests/otel.js.map +1 -1
- package/package.json +12 -38
- package/src/QueryCache.ts +6 -8
- package/src/SqliteDbWrapper.test.ts +1 -1
- package/src/SqliteDbWrapper.ts +13 -12
- package/src/ambient.d.ts +0 -2
- package/src/effect/LiveStore.ts +3 -3
- package/src/effect/mod.ts +4 -4
- package/src/internal/mod.ts +2 -2
- package/src/live-queries/__snapshots__/db-query.test.ts.snap +14 -14
- package/src/live-queries/base-class.ts +11 -10
- package/src/live-queries/client-document-get-query.ts +1 -1
- package/src/live-queries/computed.ts +5 -5
- package/src/live-queries/db-query.test.ts +21 -17
- package/src/live-queries/db-query.ts +7 -7
- package/src/live-queries/mod.ts +4 -4
- package/src/live-queries/signal.test.ts +3 -3
- package/src/live-queries/signal.ts +4 -4
- package/src/mod.ts +33 -39
- package/src/reactive.test.ts +1 -1
- package/src/reactive.ts +2 -4
- package/src/store/create-store.ts +8 -3
- package/src/store/devtools.ts +5 -5
- package/src/store/store-types.ts +13 -4
- package/src/store/store.ts +29 -18
- package/src/utils/dev.ts +0 -1
- package/src/utils/stack-info.test.ts +7 -3
- package/src/utils/stack-info.ts +5 -1
- package/src/utils/tests/fixture.ts +18 -3
- package/src/utils/tests/mod.ts +3 -3
- package/src/utils/tests/otel.ts +2 -1
|
@@ -45,7 +45,7 @@ exports[`otel > QueryBuilder subscription - basic functionality 1`] = `
|
|
|
45
45
|
"_name": "LiveStore:commit",
|
|
46
46
|
"attributes": {
|
|
47
47
|
"livestore.eventTags": [
|
|
48
|
-
"
|
|
48
|
+
"todo.created",
|
|
49
49
|
],
|
|
50
50
|
"livestore.eventsCount": 1,
|
|
51
51
|
},
|
|
@@ -53,7 +53,7 @@ exports[`otel > QueryBuilder subscription - basic functionality 1`] = `
|
|
|
53
53
|
{
|
|
54
54
|
"_name": "livestore.in-memory-db:execute",
|
|
55
55
|
"attributes": {
|
|
56
|
-
"sql.query": "INSERT INTO todos (id, text, completed) VALUES (
|
|
56
|
+
"sql.query": "INSERT INTO 'todos' (id, text, completed) VALUES (?, ?, ?)",
|
|
57
57
|
},
|
|
58
58
|
},
|
|
59
59
|
],
|
|
@@ -158,7 +158,7 @@ exports[`otel > QueryBuilder subscription - direct table subscription 1`] = `
|
|
|
158
158
|
"_name": "LiveStore:commit",
|
|
159
159
|
"attributes": {
|
|
160
160
|
"livestore.eventTags": [
|
|
161
|
-
"
|
|
161
|
+
"todo.created",
|
|
162
162
|
],
|
|
163
163
|
"livestore.eventsCount": 1,
|
|
164
164
|
},
|
|
@@ -166,7 +166,7 @@ exports[`otel > QueryBuilder subscription - direct table subscription 1`] = `
|
|
|
166
166
|
{
|
|
167
167
|
"_name": "livestore.in-memory-db:execute",
|
|
168
168
|
"attributes": {
|
|
169
|
-
"sql.query": "INSERT INTO todos (id, text, completed) VALUES (
|
|
169
|
+
"sql.query": "INSERT INTO 'todos' (id, text, completed) VALUES (?, ?, ?)",
|
|
170
170
|
},
|
|
171
171
|
},
|
|
172
172
|
],
|
|
@@ -278,7 +278,7 @@ exports[`otel > QueryBuilder subscription - unsubscribe functionality 1`] = `
|
|
|
278
278
|
"_name": "LiveStore:commit",
|
|
279
279
|
"attributes": {
|
|
280
280
|
"livestore.eventTags": [
|
|
281
|
-
"
|
|
281
|
+
"todo.created",
|
|
282
282
|
],
|
|
283
283
|
"livestore.eventsCount": 1,
|
|
284
284
|
},
|
|
@@ -286,7 +286,7 @@ exports[`otel > QueryBuilder subscription - unsubscribe functionality 1`] = `
|
|
|
286
286
|
{
|
|
287
287
|
"_name": "livestore.in-memory-db:execute",
|
|
288
288
|
"attributes": {
|
|
289
|
-
"sql.query": "INSERT INTO todos (id, text, completed) VALUES (
|
|
289
|
+
"sql.query": "INSERT INTO 'todos' (id, text, completed) VALUES (?, ?, ?)",
|
|
290
290
|
},
|
|
291
291
|
},
|
|
292
292
|
],
|
|
@@ -295,7 +295,7 @@ exports[`otel > QueryBuilder subscription - unsubscribe functionality 1`] = `
|
|
|
295
295
|
"_name": "LiveStore:commit",
|
|
296
296
|
"attributes": {
|
|
297
297
|
"livestore.eventTags": [
|
|
298
|
-
"
|
|
298
|
+
"todo.created",
|
|
299
299
|
],
|
|
300
300
|
"livestore.eventsCount": 1,
|
|
301
301
|
},
|
|
@@ -303,7 +303,7 @@ exports[`otel > QueryBuilder subscription - unsubscribe functionality 1`] = `
|
|
|
303
303
|
{
|
|
304
304
|
"_name": "livestore.in-memory-db:execute",
|
|
305
305
|
"attributes": {
|
|
306
|
-
"sql.query": "INSERT INTO todos (id, text, completed) VALUES (
|
|
306
|
+
"sql.query": "INSERT INTO 'todos' (id, text, completed) VALUES (?, ?, ?)",
|
|
307
307
|
},
|
|
308
308
|
},
|
|
309
309
|
],
|
|
@@ -434,7 +434,7 @@ exports[`otel > otel 3`] = `
|
|
|
434
434
|
"_name": "LiveStore:commit",
|
|
435
435
|
"attributes": {
|
|
436
436
|
"livestore.eventTags": [
|
|
437
|
-
"
|
|
437
|
+
"todo.created",
|
|
438
438
|
],
|
|
439
439
|
"livestore.eventsCount": 1,
|
|
440
440
|
},
|
|
@@ -442,7 +442,7 @@ exports[`otel > otel 3`] = `
|
|
|
442
442
|
{
|
|
443
443
|
"_name": "livestore.in-memory-db:execute",
|
|
444
444
|
"attributes": {
|
|
445
|
-
"sql.query": "INSERT INTO todos (id, text, completed) VALUES (
|
|
445
|
+
"sql.query": "INSERT INTO 'todos' (id, text, completed) VALUES (?, ?, ?)",
|
|
446
446
|
},
|
|
447
447
|
},
|
|
448
448
|
],
|
|
@@ -709,7 +709,7 @@ exports[`otel > with thunks 7`] = `
|
|
|
709
709
|
"_name": "LiveStore:commit",
|
|
710
710
|
"attributes": {
|
|
711
711
|
"livestore.eventTags": [
|
|
712
|
-
"
|
|
712
|
+
"todo.created",
|
|
713
713
|
],
|
|
714
714
|
"livestore.eventsCount": 1,
|
|
715
715
|
},
|
|
@@ -717,7 +717,7 @@ exports[`otel > with thunks 7`] = `
|
|
|
717
717
|
{
|
|
718
718
|
"_name": "livestore.in-memory-db:execute",
|
|
719
719
|
"attributes": {
|
|
720
|
-
"sql.query": "INSERT INTO todos (id, text, completed) VALUES (
|
|
720
|
+
"sql.query": "INSERT INTO 'todos' (id, text, completed) VALUES (?, ?, ?)",
|
|
721
721
|
},
|
|
722
722
|
},
|
|
723
723
|
],
|
|
@@ -818,7 +818,7 @@ exports[`otel > with thunks with query builder and without labels 3`] = `
|
|
|
818
818
|
"_name": "LiveStore:commit",
|
|
819
819
|
"attributes": {
|
|
820
820
|
"livestore.eventTags": [
|
|
821
|
-
"
|
|
821
|
+
"todo.created",
|
|
822
822
|
],
|
|
823
823
|
"livestore.eventsCount": 1,
|
|
824
824
|
},
|
|
@@ -826,7 +826,7 @@ exports[`otel > with thunks with query builder and without labels 3`] = `
|
|
|
826
826
|
{
|
|
827
827
|
"_name": "livestore.in-memory-db:execute",
|
|
828
828
|
"attributes": {
|
|
829
|
-
"sql.query": "INSERT INTO todos (id, text, completed) VALUES (
|
|
829
|
+
"sql.query": "INSERT INTO 'todos' (id, text, completed) VALUES (?, ?, ?)",
|
|
830
830
|
},
|
|
831
831
|
},
|
|
832
832
|
],
|
|
@@ -2,10 +2,10 @@ import { isNotNil } from '@livestore/utils'
|
|
|
2
2
|
import { Predicate } from '@livestore/utils/effect'
|
|
3
3
|
import type * as otel from '@opentelemetry/api'
|
|
4
4
|
|
|
5
|
-
import * as RG from '../reactive.
|
|
6
|
-
import type { Store } from '../store/store.
|
|
7
|
-
import type { QueryDebugInfo, RefreshReason } from '../store/store-types.
|
|
8
|
-
import type { StackInfo } from '../utils/stack-info.
|
|
5
|
+
import * as RG from '../reactive.ts'
|
|
6
|
+
import type { Store } from '../store/store.ts'
|
|
7
|
+
import type { QueryDebugInfo, RefreshReason } from '../store/store-types.ts'
|
|
8
|
+
import type { StackInfo } from '../utils/stack-info.ts'
|
|
9
9
|
|
|
10
10
|
export type ReactivityGraph = RG.ReactiveGraph<RefreshReason, QueryDebugInfo, ReactivityGraphContext>
|
|
11
11
|
|
|
@@ -23,14 +23,15 @@ export type ReactivityGraphContext = {
|
|
|
23
23
|
effectsWrapper: (run: () => void) => void
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
export type GetResult<TQuery extends LiveQueryDef.Any | LiveQuery.Any | SignalDef<any>> =
|
|
27
|
-
|
|
26
|
+
export type GetResult<TQuery extends LiveQueryDef.Any | LiveQuery.Any | SignalDef<any>> = TQuery extends LiveQuery<
|
|
27
|
+
infer TResult
|
|
28
|
+
>
|
|
29
|
+
? TResult
|
|
30
|
+
: TQuery extends LiveQueryDef<infer TResult>
|
|
28
31
|
? TResult
|
|
29
|
-
: TQuery extends
|
|
32
|
+
: TQuery extends SignalDef<infer TResult>
|
|
30
33
|
? TResult
|
|
31
|
-
:
|
|
32
|
-
? TResult
|
|
33
|
-
: unknown
|
|
34
|
+
: unknown
|
|
34
35
|
|
|
35
36
|
let queryIdCounter = 0
|
|
36
37
|
|
|
@@ -4,7 +4,7 @@ import { State } from '@livestore/common/schema'
|
|
|
4
4
|
import { shouldNeverHappen } from '@livestore/utils'
|
|
5
5
|
import type * as otel from '@opentelemetry/api'
|
|
6
6
|
|
|
7
|
-
import type { ReactivityGraphContext } from './base-class.
|
|
7
|
+
import type { ReactivityGraphContext } from './base-class.ts'
|
|
8
8
|
|
|
9
9
|
export const rowQueryLabel = (
|
|
10
10
|
table: State.SQLite.ClientDocumentTableDef.Any,
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { getDurationMsFromSpan } from '@livestore/common'
|
|
2
2
|
import * as otel from '@opentelemetry/api'
|
|
3
3
|
|
|
4
|
-
import type { Thunk } from '../reactive.
|
|
5
|
-
import type { RefreshReason } from '../store/store-types.
|
|
6
|
-
import { isValidFunctionString } from '../utils/function-string.
|
|
7
|
-
import type { DepKey, GetAtomResult, LiveQueryDef, ReactivityGraph, ReactivityGraphContext } from './base-class.
|
|
8
|
-
import { depsToString, LiveStoreQueryBase, makeGetAtomResult, withRCMap } from './base-class.
|
|
4
|
+
import type { Thunk } from '../reactive.ts'
|
|
5
|
+
import type { RefreshReason } from '../store/store-types.ts'
|
|
6
|
+
import { isValidFunctionString } from '../utils/function-string.ts'
|
|
7
|
+
import type { DepKey, GetAtomResult, LiveQueryDef, ReactivityGraph, ReactivityGraphContext } from './base-class.ts'
|
|
8
|
+
import { depsToString, LiveStoreQueryBase, makeGetAtomResult, withRCMap } from './base-class.ts'
|
|
9
9
|
|
|
10
10
|
export const computed = <TResult>(
|
|
11
11
|
fn: (get: GetAtomResult) => TResult,
|
|
@@ -1,16 +1,14 @@
|
|
|
1
|
-
import { sql } from '@livestore/common'
|
|
2
|
-
import { rawSqlEvent } from '@livestore/common/schema'
|
|
3
1
|
import { Effect, ReadonlyRecord, Schema } from '@livestore/utils/effect'
|
|
4
2
|
import { Vitest } from '@livestore/utils-dev/node-vitest'
|
|
5
3
|
import * as otel from '@opentelemetry/api'
|
|
6
4
|
import { BasicTracerProvider, InMemorySpanExporter, SimpleSpanProcessor } from '@opentelemetry/sdk-trace-base'
|
|
7
5
|
import { expect } from 'vitest'
|
|
8
6
|
|
|
9
|
-
import * as RG from '../reactive.
|
|
10
|
-
import { makeTodoMvc, tables } from '../utils/tests/fixture.
|
|
11
|
-
import { getSimplifiedRootSpan } from '../utils/tests/otel.
|
|
12
|
-
import { computed } from './computed.
|
|
13
|
-
import { queryDb } from './db-query.
|
|
7
|
+
import * as RG from '../reactive.ts'
|
|
8
|
+
import { events, makeTodoMvc, tables } from '../utils/tests/fixture.ts'
|
|
9
|
+
import { getSimplifiedRootSpan } from '../utils/tests/otel.ts'
|
|
10
|
+
import { computed } from './computed.ts'
|
|
11
|
+
import { queryDb } from './db-query.ts'
|
|
14
12
|
|
|
15
13
|
/*
|
|
16
14
|
TODO write tests for:
|
|
@@ -65,7 +63,7 @@ Vitest.describe('otel', () => {
|
|
|
65
63
|
})
|
|
66
64
|
expect(store.query(query$)).toMatchInlineSnapshot('[]')
|
|
67
65
|
|
|
68
|
-
store.commit(
|
|
66
|
+
store.commit(events.todoCreated({ id: 't1', text: 'buy milk', completed: false }))
|
|
69
67
|
|
|
70
68
|
expect(store.query(query$)).toMatchInlineSnapshot(`
|
|
71
69
|
[
|
|
@@ -119,7 +117,7 @@ Vitest.describe('otel', () => {
|
|
|
119
117
|
|
|
120
118
|
expect(store.reactivityGraph.getSnapshot({ includeResults: true })).toMatchSnapshot()
|
|
121
119
|
|
|
122
|
-
store.commit(
|
|
120
|
+
store.commit(events.todoCreated({ id: 't1', text: 'buy milk', completed: false }))
|
|
123
121
|
|
|
124
122
|
expect(store.reactivityGraph.getSnapshot({ includeResults: true })).toMatchSnapshot()
|
|
125
123
|
|
|
@@ -155,7 +153,9 @@ Vitest.describe('otel', () => {
|
|
|
155
153
|
const defaultTodo = { id: '', text: '', completed: false }
|
|
156
154
|
|
|
157
155
|
const filter = computed(() => ({ completed: false }))
|
|
158
|
-
const query$ = queryDb((get) =>
|
|
156
|
+
const query$ = queryDb((get) =>
|
|
157
|
+
tables.todos.where(get(filter)).first({ behaviour: 'fallback', fallback: () => defaultTodo }),
|
|
158
|
+
)
|
|
159
159
|
|
|
160
160
|
expect(store.query(query$)).toMatchInlineSnapshot(`
|
|
161
161
|
{
|
|
@@ -165,7 +165,7 @@ Vitest.describe('otel', () => {
|
|
|
165
165
|
}
|
|
166
166
|
`)
|
|
167
167
|
|
|
168
|
-
store.commit(
|
|
168
|
+
store.commit(events.todoCreated({ id: 't1', text: 'buy milk', completed: false }))
|
|
169
169
|
|
|
170
170
|
expect(store.query(query$)).toMatchInlineSnapshot(`
|
|
171
171
|
{
|
|
@@ -197,7 +197,9 @@ Vitest.describe('otel', () => {
|
|
|
197
197
|
const callbackResults: any[] = []
|
|
198
198
|
const defaultTodo = { id: '', text: '', completed: false }
|
|
199
199
|
|
|
200
|
-
const queryBuilder = tables.todos
|
|
200
|
+
const queryBuilder = tables.todos
|
|
201
|
+
.where({ completed: false })
|
|
202
|
+
.first({ behaviour: 'fallback', fallback: () => defaultTodo })
|
|
201
203
|
|
|
202
204
|
const unsubscribe = store.subscribe(queryBuilder, {
|
|
203
205
|
onUpdate: (result) => {
|
|
@@ -208,7 +210,7 @@ Vitest.describe('otel', () => {
|
|
|
208
210
|
expect(callbackResults).toHaveLength(1)
|
|
209
211
|
expect(callbackResults[0]).toMatchObject(defaultTodo)
|
|
210
212
|
|
|
211
|
-
store.commit(
|
|
213
|
+
store.commit(events.todoCreated({ id: 't1', text: 'buy milk', completed: false }))
|
|
212
214
|
|
|
213
215
|
expect(callbackResults).toHaveLength(2)
|
|
214
216
|
expect(callbackResults[1]).toMatchObject({
|
|
@@ -241,7 +243,9 @@ Vitest.describe('otel', () => {
|
|
|
241
243
|
const callbackResults2: any[] = []
|
|
242
244
|
const defaultTodo = { id: '', text: '', completed: false }
|
|
243
245
|
|
|
244
|
-
const queryBuilder = tables.todos
|
|
246
|
+
const queryBuilder = tables.todos
|
|
247
|
+
.where({ completed: false })
|
|
248
|
+
.first({ behaviour: 'fallback', fallback: () => defaultTodo })
|
|
245
249
|
|
|
246
250
|
const unsubscribe1 = store.subscribe(queryBuilder, {
|
|
247
251
|
onUpdate: (result) => {
|
|
@@ -258,14 +262,14 @@ Vitest.describe('otel', () => {
|
|
|
258
262
|
expect(callbackResults1).toHaveLength(1)
|
|
259
263
|
expect(callbackResults2).toHaveLength(1)
|
|
260
264
|
|
|
261
|
-
store.commit(
|
|
265
|
+
store.commit(events.todoCreated({ id: 't3', text: 'read book', completed: false }))
|
|
262
266
|
|
|
263
267
|
expect(callbackResults1).toHaveLength(2)
|
|
264
268
|
expect(callbackResults2).toHaveLength(2)
|
|
265
269
|
|
|
266
270
|
unsubscribe1()
|
|
267
271
|
|
|
268
|
-
store.commit(
|
|
272
|
+
store.commit(events.todoCreated({ id: 't4', text: 'cook dinner', completed: false }))
|
|
269
273
|
|
|
270
274
|
expect(callbackResults1).toHaveLength(2)
|
|
271
275
|
expect(callbackResults2).toHaveLength(3)
|
|
@@ -301,7 +305,7 @@ Vitest.describe('otel', () => {
|
|
|
301
305
|
expect(callbackResults).toHaveLength(1)
|
|
302
306
|
expect(callbackResults[0]).toEqual([])
|
|
303
307
|
|
|
304
|
-
store.commit(
|
|
308
|
+
store.commit(events.todoCreated({ id: 't5', text: 'clean house', completed: true }))
|
|
305
309
|
|
|
306
310
|
expect(callbackResults).toHaveLength(2)
|
|
307
311
|
expect(callbackResults[1]).toHaveLength(1)
|
|
@@ -13,13 +13,13 @@ import { deepEqual, shouldNeverHappen } from '@livestore/utils'
|
|
|
13
13
|
import { Predicate, Schema, TreeFormatter } from '@livestore/utils/effect'
|
|
14
14
|
import * as otel from '@opentelemetry/api'
|
|
15
15
|
|
|
16
|
-
import type { Thunk } from '../reactive.
|
|
17
|
-
import { isThunk, NOT_REFRESHED_YET } from '../reactive.
|
|
18
|
-
import type { RefreshReason } from '../store/store-types.
|
|
19
|
-
import { isValidFunctionString } from '../utils/function-string.
|
|
20
|
-
import type { DepKey, GetAtomResult, LiveQueryDef, ReactivityGraph, ReactivityGraphContext } from './base-class.
|
|
21
|
-
import { depsToString, LiveStoreQueryBase, makeGetAtomResult, withRCMap } from './base-class.
|
|
22
|
-
import { makeExecBeforeFirstRun, rowQueryLabel } from './client-document-get-query.
|
|
16
|
+
import type { Thunk } from '../reactive.ts'
|
|
17
|
+
import { isThunk, NOT_REFRESHED_YET } from '../reactive.ts'
|
|
18
|
+
import type { RefreshReason } from '../store/store-types.ts'
|
|
19
|
+
import { isValidFunctionString } from '../utils/function-string.ts'
|
|
20
|
+
import type { DepKey, GetAtomResult, LiveQueryDef, ReactivityGraph, ReactivityGraphContext } from './base-class.ts'
|
|
21
|
+
import { depsToString, LiveStoreQueryBase, makeGetAtomResult, withRCMap } from './base-class.ts'
|
|
22
|
+
import { makeExecBeforeFirstRun, rowQueryLabel } from './client-document-get-query.ts'
|
|
23
23
|
|
|
24
24
|
export type QueryInputRaw<TDecoded, TEncoded> = {
|
|
25
25
|
query: string
|
package/src/live-queries/mod.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export * from './base-class.
|
|
2
|
-
export * from './computed.
|
|
3
|
-
export * from './db-query.
|
|
4
|
-
export * from './signal.
|
|
1
|
+
export * from './base-class.ts'
|
|
2
|
+
export * from './computed.ts'
|
|
3
|
+
export * from './db-query.ts'
|
|
4
|
+
export * from './signal.ts'
|
|
@@ -2,9 +2,9 @@ import { Effect } from '@livestore/utils/effect'
|
|
|
2
2
|
import { Vitest } from '@livestore/utils-dev/node-vitest'
|
|
3
3
|
import { expect } from 'vitest'
|
|
4
4
|
|
|
5
|
-
import { makeTodoMvc } from '../utils/tests/fixture.
|
|
6
|
-
import { computed } from './computed.
|
|
7
|
-
import { signal } from './signal.
|
|
5
|
+
import { makeTodoMvc } from '../utils/tests/fixture.ts'
|
|
6
|
+
import { computed } from './computed.ts'
|
|
7
|
+
import { signal } from './signal.ts'
|
|
8
8
|
|
|
9
9
|
Vitest.describe('signal', () => {
|
|
10
10
|
Vitest.scopedLive('should be able to create a signal', () =>
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { nanoid } from '@livestore/utils/nanoid'
|
|
2
2
|
|
|
3
|
-
import type * as RG from '../reactive.
|
|
4
|
-
import type { RefreshReason } from '../store/store-types.
|
|
5
|
-
import type { ISignal, ReactivityGraph, ReactivityGraphContext, SignalDef } from './base-class.
|
|
6
|
-
import { LiveStoreQueryBase, withRCMap } from './base-class.
|
|
3
|
+
import type * as RG from '../reactive.ts'
|
|
4
|
+
import type { RefreshReason } from '../store/store-types.ts'
|
|
5
|
+
import type { ISignal, ReactivityGraph, ReactivityGraphContext, SignalDef } from './base-class.ts'
|
|
6
|
+
import { LiveStoreQueryBase, withRCMap } from './base-class.ts'
|
|
7
7
|
|
|
8
8
|
export const signal = <T>(
|
|
9
9
|
defaultValue: T,
|
package/src/mod.ts
CHANGED
|
@@ -1,51 +1,45 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export { createStore, createStorePromise, type CreateStoreOptions } from './store/create-store.js'
|
|
3
|
-
export type { QueryDebugInfo, RefreshReason, OtelOptions } from './store/store-types.js'
|
|
4
|
-
// We're re-exporting `Schema` from `effect` for convenience
|
|
5
|
-
export { Schema } from '@livestore/utils/effect'
|
|
6
|
-
|
|
7
|
-
export {
|
|
8
|
-
type LiveStoreContext,
|
|
9
|
-
type LiveStoreContextRunning,
|
|
10
|
-
type ShutdownDeferred,
|
|
11
|
-
makeShutdownDeferred,
|
|
12
|
-
} from './store/store-types.js'
|
|
13
|
-
|
|
14
|
-
export { SqliteDbWrapper, emptyDebugInfo } from './SqliteDbWrapper.js'
|
|
15
|
-
|
|
16
|
-
export {
|
|
17
|
-
queryDb,
|
|
18
|
-
computed,
|
|
19
|
-
signal,
|
|
20
|
-
type LiveQuery,
|
|
21
|
-
type LiveQueryDef,
|
|
22
|
-
type Signal,
|
|
23
|
-
type SignalDef,
|
|
24
|
-
type RcRef,
|
|
25
|
-
} from './live-queries/mod.js'
|
|
26
|
-
|
|
27
|
-
export * from '@livestore/common/schema'
|
|
1
|
+
export type { Adapter, ClientSession, PreparedStatement } from '@livestore/common'
|
|
28
2
|
export {
|
|
29
|
-
|
|
30
|
-
SessionIdSymbol,
|
|
3
|
+
type Bindable,
|
|
31
4
|
type BootStatus,
|
|
32
|
-
type SqliteDb,
|
|
33
5
|
type DebugInfo,
|
|
6
|
+
IntentionalShutdownCause,
|
|
34
7
|
type MutableDebugInfo,
|
|
35
|
-
prepareBindValues,
|
|
36
|
-
type Bindable,
|
|
37
8
|
type PreparedBindValues,
|
|
38
|
-
|
|
9
|
+
prepareBindValues,
|
|
10
|
+
provideOtel,
|
|
39
11
|
type QueryBuilder,
|
|
12
|
+
type QueryBuilderAst,
|
|
40
13
|
type RowQuery,
|
|
14
|
+
SessionIdSymbol,
|
|
15
|
+
type SqliteDb,
|
|
41
16
|
StoreInterrupted,
|
|
42
|
-
|
|
43
|
-
provideOtel,
|
|
17
|
+
sql,
|
|
44
18
|
} from '@livestore/common'
|
|
45
|
-
|
|
19
|
+
export * from '@livestore/common/schema'
|
|
46
20
|
export { deepEqual } from '@livestore/utils'
|
|
21
|
+
// We're re-exporting `Schema` from `effect` for convenience
|
|
22
|
+
export { Schema } from '@livestore/utils/effect'
|
|
47
23
|
export { nanoid } from '@livestore/utils/nanoid'
|
|
48
24
|
|
|
49
|
-
export
|
|
50
|
-
|
|
51
|
-
|
|
25
|
+
export {
|
|
26
|
+
computed,
|
|
27
|
+
type LiveQuery,
|
|
28
|
+
type LiveQueryDef,
|
|
29
|
+
queryDb,
|
|
30
|
+
type RcRef,
|
|
31
|
+
type Signal,
|
|
32
|
+
type SignalDef,
|
|
33
|
+
signal,
|
|
34
|
+
} from './live-queries/mod.ts'
|
|
35
|
+
export { emptyDebugInfo, SqliteDbWrapper } from './SqliteDbWrapper.ts'
|
|
36
|
+
export { type CreateStoreOptions, createStore, createStorePromise } from './store/create-store.ts'
|
|
37
|
+
export { Store } from './store/store.ts'
|
|
38
|
+
export type { OtelOptions, QueryDebugInfo, RefreshReason } from './store/store-types.ts'
|
|
39
|
+
export {
|
|
40
|
+
type LiveStoreContext,
|
|
41
|
+
type LiveStoreContextRunning,
|
|
42
|
+
makeShutdownDeferred,
|
|
43
|
+
type ShutdownDeferred,
|
|
44
|
+
} from './store/store-types.ts'
|
|
45
|
+
export * from './utils/stack-info.ts'
|
package/src/reactive.test.ts
CHANGED
package/src/reactive.ts
CHANGED
|
@@ -21,13 +21,11 @@
|
|
|
21
21
|
// is maintained eagerly as edges are added and removed.)
|
|
22
22
|
// - At every thunk we check value equality with the previous value and cutoff propagation if possible.
|
|
23
23
|
|
|
24
|
-
/* eslint-disable prefer-arrow/prefer-arrow-functions */
|
|
25
|
-
|
|
26
24
|
import { BoundArray } from '@livestore/common'
|
|
27
25
|
import { deepEqual, shouldNeverHappen } from '@livestore/utils'
|
|
28
26
|
import type { Types } from '@livestore/utils/effect'
|
|
29
27
|
import type * as otel from '@opentelemetry/api'
|
|
30
|
-
// import { getDurationMsFromSpan } from './otel.
|
|
28
|
+
// import { getDurationMsFromSpan } from './otel.ts'
|
|
31
29
|
|
|
32
30
|
export const NOT_REFRESHED_YET = Symbol.for('NOT_REFRESHED_YET')
|
|
33
31
|
export type NOT_REFRESHED_YET = typeof NOT_REFRESHED_YET
|
|
@@ -279,7 +277,7 @@ export class ReactiveGraph<
|
|
|
279
277
|
return compute(atom, otelContext, debugRefreshReason)
|
|
280
278
|
}
|
|
281
279
|
|
|
282
|
-
let debugInfo: TDebugThunkInfo | undefined
|
|
280
|
+
let debugInfo: TDebugThunkInfo | undefined
|
|
283
281
|
const setDebugInfo = (debugInfo_: TDebugThunkInfo) => {
|
|
284
282
|
debugInfo = debugInfo_
|
|
285
283
|
}
|
|
@@ -3,6 +3,7 @@ import type {
|
|
|
3
3
|
BootStatus,
|
|
4
4
|
ClientSession,
|
|
5
5
|
ClientSessionDevtoolsChannel,
|
|
6
|
+
ClientSessionSyncProcessorSimulationParams,
|
|
6
7
|
IntentionalShutdownCause,
|
|
7
8
|
MigrationsReport,
|
|
8
9
|
} from '@livestore/common'
|
|
@@ -29,13 +30,13 @@ import {
|
|
|
29
30
|
import { nanoid } from '@livestore/utils/nanoid'
|
|
30
31
|
import * as otel from '@opentelemetry/api'
|
|
31
32
|
|
|
32
|
-
import { connectDevtoolsToStore } from './devtools.
|
|
33
|
-
import { Store } from './store.
|
|
33
|
+
import { connectDevtoolsToStore } from './devtools.ts'
|
|
34
|
+
import { Store } from './store.ts'
|
|
34
35
|
import type {
|
|
35
36
|
LiveStoreContextRunning as LiveStoreContextRunning_,
|
|
36
37
|
OtelOptions,
|
|
37
38
|
ShutdownDeferred,
|
|
38
|
-
} from './store-types.
|
|
39
|
+
} from './store-types.ts'
|
|
39
40
|
|
|
40
41
|
export const DEFAULT_PARAMS = {
|
|
41
42
|
leaderPushBatchSize: 100,
|
|
@@ -120,6 +121,9 @@ export interface CreateStoreOptions<TSchema extends LiveStoreSchema, TContext =
|
|
|
120
121
|
syncPayload?: Schema.JsonValue
|
|
121
122
|
params?: {
|
|
122
123
|
leaderPushBatchSize?: number
|
|
124
|
+
simulation?: {
|
|
125
|
+
clientSessionSyncProcessor: typeof ClientSessionSyncProcessorSimulationParams.Type
|
|
126
|
+
}
|
|
123
127
|
}
|
|
124
128
|
debug?: {
|
|
125
129
|
instanceId?: string
|
|
@@ -274,6 +278,7 @@ export const createStore = <TSchema extends LiveStoreSchema = LiveStoreSchema, T
|
|
|
274
278
|
storeId,
|
|
275
279
|
params: {
|
|
276
280
|
leaderPushBatchSize: params?.leaderPushBatchSize ?? DEFAULT_PARAMS.leaderPushBatchSize,
|
|
281
|
+
simulation: params?.simulation,
|
|
277
282
|
},
|
|
278
283
|
})
|
|
279
284
|
|
package/src/store/devtools.ts
CHANGED
|
@@ -5,11 +5,11 @@ import type { WebChannel } from '@livestore/utils/effect'
|
|
|
5
5
|
import { Effect, Stream } from '@livestore/utils/effect'
|
|
6
6
|
import { nanoid } from '@livestore/utils/nanoid'
|
|
7
7
|
|
|
8
|
-
import type { LiveQuery, ReactivityGraph } from '../live-queries/base-class.
|
|
9
|
-
import { NOT_REFRESHED_YET } from '../reactive.
|
|
10
|
-
import type { SqliteDbWrapper } from '../SqliteDbWrapper.
|
|
11
|
-
import { emptyDebugInfo as makeEmptyDebugInfo } from '../SqliteDbWrapper.
|
|
12
|
-
import type { ReferenceCountedSet } from '../utils/data-structures.
|
|
8
|
+
import type { LiveQuery, ReactivityGraph } from '../live-queries/base-class.ts'
|
|
9
|
+
import { NOT_REFRESHED_YET } from '../reactive.ts'
|
|
10
|
+
import type { SqliteDbWrapper } from '../SqliteDbWrapper.ts'
|
|
11
|
+
import { emptyDebugInfo as makeEmptyDebugInfo } from '../SqliteDbWrapper.ts'
|
|
12
|
+
import type { ReferenceCountedSet } from '../utils/data-structures.ts'
|
|
13
13
|
|
|
14
14
|
type IStore = {
|
|
15
15
|
clientSession: ClientSession
|
package/src/store/store-types.ts
CHANGED
|
@@ -1,12 +1,18 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type {
|
|
2
|
+
ClientSession,
|
|
3
|
+
ClientSessionSyncProcessorSimulationParams,
|
|
4
|
+
IntentionalShutdownCause,
|
|
5
|
+
StoreInterrupted,
|
|
6
|
+
UnexpectedError,
|
|
7
|
+
} from '@livestore/common'
|
|
2
8
|
import type { EventSequenceNumber, LiveStoreEvent, LiveStoreSchema } from '@livestore/common/schema'
|
|
3
9
|
import type { Effect, Runtime, Scope } from '@livestore/utils/effect'
|
|
4
10
|
import { Deferred } from '@livestore/utils/effect'
|
|
5
11
|
import type * as otel from '@opentelemetry/api'
|
|
6
12
|
|
|
7
|
-
import type { DebugRefreshReasonBase } from '../reactive.
|
|
8
|
-
import type { StackInfo } from '../utils/stack-info.
|
|
9
|
-
import type { Store } from './store.
|
|
13
|
+
import type { DebugRefreshReasonBase } from '../reactive.ts'
|
|
14
|
+
import type { StackInfo } from '../utils/stack-info.ts'
|
|
15
|
+
import type { Store } from './store.ts'
|
|
10
16
|
|
|
11
17
|
export type LiveStoreContext =
|
|
12
18
|
| LiveStoreContextRunning
|
|
@@ -49,6 +55,9 @@ export type StoreOptions<TSchema extends LiveStoreSchema = LiveStoreSchema, TCon
|
|
|
49
55
|
batchUpdates: (runUpdates: () => void) => void
|
|
50
56
|
params: {
|
|
51
57
|
leaderPushBatchSize: number
|
|
58
|
+
simulation?: {
|
|
59
|
+
clientSessionSyncProcessor: typeof ClientSessionSyncProcessorSimulationParams.Type
|
|
60
|
+
}
|
|
52
61
|
}
|
|
53
62
|
__runningInDevtools: boolean
|
|
54
63
|
}
|