@livestore/livestore 0.3.1 → 0.3.2-dev.1
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 +10 -6
- 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 +96 -6
- 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 +12 -11
- package/dist/store/store.d.ts.map +1 -1
- package/dist/store/store.js +23 -15
- 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/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 +7 -7
- package/src/QueryCache.ts +14 -11
- 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 +389 -0
- 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 +149 -6
- 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 +28 -21
- 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/mod.ts +3 -3
- package/src/utils/tests/otel.ts +2 -1
@@ -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
|
}
|
package/src/store/store.ts
CHANGED
@@ -1,12 +1,7 @@
|
|
1
1
|
import {
|
2
|
+
type Bindable,
|
2
3
|
type ClientSession,
|
3
4
|
type ClientSessionSyncProcessor,
|
4
|
-
type ParamsObject,
|
5
|
-
type PreparedBindValues,
|
6
|
-
type QueryBuilder,
|
7
|
-
UnexpectedError,
|
8
|
-
} from '@livestore/common'
|
9
|
-
import {
|
10
5
|
Devtools,
|
11
6
|
getDurationMsFromSpan,
|
12
7
|
getExecStatementsFromMaterializer,
|
@@ -16,9 +11,12 @@ import {
|
|
16
11
|
isQueryBuilder,
|
17
12
|
liveStoreVersion,
|
18
13
|
makeClientSessionSyncProcessor,
|
14
|
+
type PreparedBindValues,
|
19
15
|
prepareBindValues,
|
16
|
+
type QueryBuilder,
|
20
17
|
QueryBuilderAstSymbol,
|
21
18
|
replaceSessionIdSymbol,
|
19
|
+
UnexpectedError,
|
22
20
|
} from '@livestore/common'
|
23
21
|
import type { LiveStoreSchema } from '@livestore/common/schema'
|
24
22
|
import { getEventDef, LiveStoreEvent, SystemTables } from '@livestore/common/schema'
|
@@ -34,14 +32,15 @@ import type {
|
|
34
32
|
ReactivityGraph,
|
35
33
|
ReactivityGraphContext,
|
36
34
|
SignalDef,
|
37
|
-
} from '../live-queries/base-class.
|
38
|
-
import { makeReactivityGraph } from '../live-queries/base-class.
|
39
|
-
import { makeExecBeforeFirstRun } from '../live-queries/client-document-get-query.
|
40
|
-
import
|
41
|
-
import {
|
42
|
-
import {
|
43
|
-
import {
|
44
|
-
import
|
35
|
+
} from '../live-queries/base-class.ts'
|
36
|
+
import { makeReactivityGraph } from '../live-queries/base-class.ts'
|
37
|
+
import { makeExecBeforeFirstRun } from '../live-queries/client-document-get-query.ts'
|
38
|
+
import { queryDb } from '../live-queries/db-query.ts'
|
39
|
+
import type { Ref } from '../reactive.ts'
|
40
|
+
import { SqliteDbWrapper } from '../SqliteDbWrapper.ts'
|
41
|
+
import { ReferenceCountedSet } from '../utils/data-structures.ts'
|
42
|
+
import { downloadBlob, exposeDebugUtils } from '../utils/dev.ts'
|
43
|
+
import type { StackInfo } from '../utils/stack-info.ts'
|
45
44
|
import type {
|
46
45
|
RefreshReason,
|
47
46
|
StoreCommitOptions,
|
@@ -49,7 +48,7 @@ import type {
|
|
49
48
|
StoreOptions,
|
50
49
|
StoreOtel,
|
51
50
|
Unsubscribe,
|
52
|
-
} from './store-types.
|
51
|
+
} from './store-types.ts'
|
53
52
|
|
54
53
|
if (isDevEnv()) {
|
55
54
|
exposeDebugUtils()
|
@@ -163,6 +162,8 @@ export class Store<TSchema extends LiveStoreSchema = LiveStoreSchema, TContext =
|
|
163
162
|
for (const table of writeTables) {
|
164
163
|
writeTablesForEvent.add(table)
|
165
164
|
}
|
165
|
+
|
166
|
+
this.sqliteDbWrapper.debug.head = eventDecoded.seqNum
|
166
167
|
}
|
167
168
|
}
|
168
169
|
|
@@ -194,6 +195,7 @@ export class Store<TSchema extends LiveStoreSchema = LiveStoreSchema, TContext =
|
|
194
195
|
span: syncSpan,
|
195
196
|
params: {
|
196
197
|
leaderPushBatchSize: params.leaderPushBatchSize,
|
198
|
+
simulation: params.simulation?.clientSessionSyncProcessor,
|
197
199
|
},
|
198
200
|
confirmUnsavedChanges,
|
199
201
|
})
|
@@ -290,7 +292,7 @@ export class Store<TSchema extends LiveStoreSchema = LiveStoreSchema, TContext =
|
|
290
292
|
* ```
|
291
293
|
*/
|
292
294
|
subscribe = <TResult>(
|
293
|
-
query: LiveQueryDef<TResult, 'def' | 'signal-def'> | LiveQuery<TResult>,
|
295
|
+
query: LiveQueryDef<TResult, 'def' | 'signal-def'> | LiveQuery<TResult> | QueryBuilder<TResult, any, any>,
|
294
296
|
options: {
|
295
297
|
/** Called when the query result has changed */
|
296
298
|
onUpdate: (value: TResult) => void
|
@@ -310,14 +312,15 @@ export class Store<TSchema extends LiveStoreSchema = LiveStoreSchema, TContext =
|
|
310
312
|
): Unsubscribe =>
|
311
313
|
this.otel.tracer.startActiveSpan(
|
312
314
|
`LiveStore.subscribe`,
|
313
|
-
{ attributes: { label: options?.label, queryLabel: query.label } },
|
315
|
+
{ attributes: { label: options?.label, queryLabel: isQueryBuilder(query) ? query.toString() : query.label } },
|
314
316
|
options?.otelContext ?? this.otel.queriesSpanContext,
|
315
317
|
(span) => {
|
316
318
|
// console.debug('store sub', query$.id, query$.label)
|
317
319
|
const otelContext = otel.trace.setSpan(otel.context.active(), span)
|
318
320
|
|
319
|
-
const queryRcRef =
|
320
|
-
|
321
|
+
const queryRcRef = isQueryBuilder(query)
|
322
|
+
? queryDb(query).make(this.reactivityGraph.context!)
|
323
|
+
: query._tag === 'def' || query._tag === 'signal-def'
|
321
324
|
? query.make(this.reactivityGraph.context!)
|
322
325
|
: {
|
323
326
|
value: query as LiveQuery<TResult>,
|
@@ -411,13 +414,17 @@ export class Store<TSchema extends LiveStoreSchema = LiveStoreSchema, TContext =
|
|
411
414
|
| LiveQuery<TResult>
|
412
415
|
| LiveQueryDef<TResult>
|
413
416
|
| SignalDef<TResult>
|
414
|
-
| { query: string; bindValues:
|
417
|
+
| { query: string; bindValues: Bindable; schema?: Schema.Schema<TResult> },
|
415
418
|
options?: { otelContext?: otel.Context; debugRefreshReason?: RefreshReason },
|
416
419
|
): TResult => {
|
417
420
|
if (typeof query === 'object' && 'query' in query && 'bindValues' in query) {
|
418
|
-
|
421
|
+
const res = this.sqliteDbWrapper.cachedSelect(query.query, prepareBindValues(query.bindValues, query.query), {
|
419
422
|
otelContext: options?.otelContext,
|
420
423
|
}) as any
|
424
|
+
if (query.schema) {
|
425
|
+
return Schema.decodeSync(query.schema)(res)
|
426
|
+
}
|
427
|
+
return res
|
421
428
|
} else if (isQueryBuilder(query)) {
|
422
429
|
const ast = query[QueryBuilderAstSymbol]
|
423
430
|
if (ast._tag === 'RowQuery') {
|
package/src/utils/dev.ts
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
import { expect, it } from 'vitest'
|
2
2
|
|
3
|
-
import { extractStackInfoFromStackTrace } from './stack-info.
|
3
|
+
import { extractStackInfoFromStackTrace } from './stack-info.ts'
|
4
4
|
|
5
5
|
it('RouteLink stacktrace', async () => {
|
6
6
|
const stackTrace = `\
|
@@ -19,7 +19,9 @@ Error
|
|
19
19
|
|
20
20
|
const stackInfo = extractStackInfoFromStackTrace(stackTrace)
|
21
21
|
// Replacing file paths for snapshot testing as they are not stable
|
22
|
-
stackInfo.frames.forEach((_) =>
|
22
|
+
stackInfo.frames.forEach((_) => {
|
23
|
+
_.filePath = '__REPLACED_FOR_SNAPSHOT__'
|
24
|
+
})
|
23
25
|
expect(stackInfo).toMatchInlineSnapshot(`
|
24
26
|
{
|
25
27
|
"frames": [
|
@@ -61,7 +63,9 @@ Error
|
|
61
63
|
|
62
64
|
const stackInfo = extractStackInfoFromStackTrace(stackTrace)
|
63
65
|
// Replacing file paths for snapshot testing as they are not stable
|
64
|
-
stackInfo.frames.forEach((_) =>
|
66
|
+
stackInfo.frames.forEach((_) => {
|
67
|
+
_.filePath = '__REPLACED_FOR_SNAPSHOT__'
|
68
|
+
})
|
65
69
|
expect(stackInfo).toMatchInlineSnapshot(`
|
66
70
|
{
|
67
71
|
"frames": [
|
package/src/utils/stack-info.ts
CHANGED
@@ -32,7 +32,11 @@ export const extractStackInfoFromStackTrace = (stackTrace: string): StackInfo =>
|
|
32
32
|
const frames: StackFrame[] = []
|
33
33
|
let hasReachedStart = false
|
34
34
|
|
35
|
-
while (
|
35
|
+
while (true) {
|
36
|
+
match = namePattern.exec(stackTrace)
|
37
|
+
if (match === null) {
|
38
|
+
break
|
39
|
+
}
|
36
40
|
const [, name, filePath] = match as any as [string, string, string]
|
37
41
|
// console.debug(name, filePath)
|
38
42
|
|
package/src/utils/tests/mod.ts
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
export * from '
|
2
|
-
export * from './
|
3
|
-
export *
|
1
|
+
export * as RG from '../../reactive.ts'
|
2
|
+
export * from './fixture.ts'
|
3
|
+
export * from './otel.ts'
|
package/src/utils/tests/otel.ts
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
import { identity } from '@livestore/utils/effect'
|
2
2
|
import type { Attributes } from '@opentelemetry/api'
|
3
3
|
import type { InMemorySpanExporter, ReadableSpan } from '@opentelemetry/sdk-trace-base'
|
4
|
+
|
4
5
|
type SimplifiedNestedSpan = { _name: string; attributes: any; children: SimplifiedNestedSpan[] }
|
5
6
|
|
6
7
|
export const getSimplifiedRootSpan = (
|
@@ -24,7 +25,7 @@ export const getSimplifiedRootSpan = (
|
|
24
25
|
const createStoreSpanData = spans.find((_) => _.name === 'createStore')
|
25
26
|
if (createStoreSpanData === undefined) {
|
26
27
|
throw new Error(
|
27
|
-
|
28
|
+
`Could not find the root span named 'createStore'. Available spans: ${spans.map((s) => s.name).join(', ')}`,
|
28
29
|
)
|
29
30
|
}
|
30
31
|
const rootSpan = spansMap.get(createStoreSpanData.spanContext().spanId)!
|