@livestore/livestore 0.0.0-snapshot-c70175cc471a448781cfe8f01001b0034e29a384 → 0.0.0-snapshot-057a9e3a18ca69a310d4eb8cf35a34e94fa1841e

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.
Files changed (60) hide show
  1. package/dist/.tsbuildinfo +1 -1
  2. package/dist/QueryCache.js +1 -1
  3. package/dist/QueryCache.js.map +1 -1
  4. package/dist/SqliteDbWrapper.d.ts +3 -2
  5. package/dist/SqliteDbWrapper.d.ts.map +1 -1
  6. package/dist/SqliteDbWrapper.js +8 -5
  7. package/dist/SqliteDbWrapper.js.map +1 -1
  8. package/dist/effect/LiveStore.js +1 -1
  9. package/dist/effect/LiveStore.js.map +1 -1
  10. package/dist/effect/mod.d.ts +2 -2
  11. package/dist/effect/mod.d.ts.map +1 -1
  12. package/dist/effect/mod.js +2 -2
  13. package/dist/effect/mod.js.map +1 -1
  14. package/dist/live-queries/base-class.d.ts.map +1 -1
  15. package/dist/live-queries/base-class.js.map +1 -1
  16. package/dist/live-queries/db-query.test.js +7 -3
  17. package/dist/live-queries/db-query.test.js.map +1 -1
  18. package/dist/mod.d.ts +9 -9
  19. package/dist/mod.d.ts.map +1 -1
  20. package/dist/mod.js +8 -8
  21. package/dist/mod.js.map +1 -1
  22. package/dist/reactive.d.ts.map +1 -1
  23. package/dist/reactive.js +1 -2
  24. package/dist/reactive.js.map +1 -1
  25. package/dist/store/store.d.ts +4 -3
  26. package/dist/store/store.d.ts.map +1 -1
  27. package/dist/store/store.js +8 -6
  28. package/dist/store/store.js.map +1 -1
  29. package/dist/utils/dev.d.ts.map +1 -1
  30. package/dist/utils/dev.js +0 -1
  31. package/dist/utils/dev.js.map +1 -1
  32. package/dist/utils/stack-info.d.ts.map +1 -1
  33. package/dist/utils/stack-info.js +5 -1
  34. package/dist/utils/stack-info.js.map +1 -1
  35. package/dist/utils/stack-info.test.js +6 -2
  36. package/dist/utils/stack-info.test.js.map +1 -1
  37. package/dist/utils/tests/mod.d.ts +1 -1
  38. package/dist/utils/tests/mod.d.ts.map +1 -1
  39. package/dist/utils/tests/mod.js +1 -1
  40. package/dist/utils/tests/mod.js.map +1 -1
  41. package/dist/utils/tests/otel.d.ts.map +1 -1
  42. package/dist/utils/tests/otel.js +1 -1
  43. package/dist/utils/tests/otel.js.map +1 -1
  44. package/package.json +7 -7
  45. package/src/QueryCache.ts +1 -1
  46. package/src/SqliteDbWrapper.ts +12 -11
  47. package/src/ambient.d.ts +0 -2
  48. package/src/effect/LiveStore.ts +1 -1
  49. package/src/effect/mod.ts +3 -3
  50. package/src/live-queries/__snapshots__/db-query.test.ts.snap +0 -42
  51. package/src/live-queries/base-class.ts +7 -6
  52. package/src/live-queries/db-query.test.ts +9 -3
  53. package/src/mod.ts +32 -38
  54. package/src/reactive.ts +1 -3
  55. package/src/store/store.ts +13 -11
  56. package/src/utils/dev.ts +0 -1
  57. package/src/utils/stack-info.test.ts +6 -2
  58. package/src/utils/stack-info.ts +5 -1
  59. package/src/utils/tests/mod.ts +1 -1
  60. package/src/utils/tests/otel.ts +2 -1
@@ -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'
@@ -164,6 +162,8 @@ export class Store<TSchema extends LiveStoreSchema = LiveStoreSchema, TContext =
164
162
  for (const table of writeTables) {
165
163
  writeTablesForEvent.add(table)
166
164
  }
165
+
166
+ this.sqliteDbWrapper.debug.head = eventDecoded.seqNum
167
167
  }
168
168
  }
169
169
 
@@ -413,13 +413,17 @@ export class Store<TSchema extends LiveStoreSchema = LiveStoreSchema, TContext =
413
413
  | LiveQuery<TResult>
414
414
  | LiveQueryDef<TResult>
415
415
  | SignalDef<TResult>
416
- | { query: string; bindValues: ParamsObject },
416
+ | { query: string; bindValues: Bindable; schema?: Schema.Schema<TResult> },
417
417
  options?: { otelContext?: otel.Context; debugRefreshReason?: RefreshReason },
418
418
  ): TResult => {
419
419
  if (typeof query === 'object' && 'query' in query && 'bindValues' in query) {
420
- return this.sqliteDbWrapper.cachedSelect(query.query, prepareBindValues(query.bindValues, query.query), {
420
+ const res = this.sqliteDbWrapper.cachedSelect(query.query, prepareBindValues(query.bindValues, query.query), {
421
421
  otelContext: options?.otelContext,
422
422
  }) as any
423
+ if (query.schema) {
424
+ return Schema.decodeSync(query.schema)(res)
425
+ }
426
+ return res
423
427
  } else if (isQueryBuilder(query)) {
424
428
  const ast = query[QueryBuilderAstSymbol]
425
429
  if (ast._tag === 'RowQuery') {
@@ -589,9 +593,7 @@ export class Store<TSchema extends LiveStoreSchema = LiveStoreSchema, TContext =
589
593
  // Materialize events to state
590
594
  const { writeTables } = (() => {
591
595
  try {
592
- const materializeEvents = () => {
593
- return Runtime.runSync(this.effectContext.runtime, this.syncProcessor.push(events, { otelContext }))
594
- }
596
+ const materializeEvents = () => this.syncProcessor.push(events, { otelContext })
595
597
 
596
598
  if (events.length > 1) {
597
599
  return this.sqliteDbWrapper.txn(materializeEvents)
package/src/utils/dev.ts CHANGED
@@ -1,7 +1,6 @@
1
1
  import { isDevEnv } from '@livestore/utils'
2
2
  import { Effect } from '@livestore/utils/effect'
3
3
 
4
- /* eslint-disable unicorn/prefer-global-this */
5
4
  export const downloadBlob = (
6
5
  data: Uint8Array | Blob | string,
7
6
  fileName: string,
@@ -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((_) => (_.filePath = '__REPLACED_FOR_SNAPSHOT__'))
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((_) => (_.filePath = '__REPLACED_FOR_SNAPSHOT__'))
66
+ stackInfo.frames.forEach((_) => {
67
+ _.filePath = '__REPLACED_FOR_SNAPSHOT__'
68
+ })
65
69
  expect(stackInfo).toMatchInlineSnapshot(`
66
70
  {
67
71
  "frames": [
@@ -32,7 +32,11 @@ export const extractStackInfoFromStackTrace = (stackTrace: string): StackInfo =>
32
32
  const frames: StackFrame[] = []
33
33
  let hasReachedStart = false
34
34
 
35
- while ((match = namePattern.exec(stackTrace)) !== null) {
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
 
@@ -1,3 +1,3 @@
1
+ export * as RG from '../../reactive.js'
1
2
  export * from './fixture.js'
2
3
  export * from './otel.js'
3
- export * as RG from '../../reactive.js'
@@ -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
- "Could not find the root span named 'createStore'. Available spans: " + spans.map((s) => s.name).join(', '),
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)!