@livestore/react 0.4.0-dev.3 → 0.4.0-dev.6

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.
@@ -3,6 +3,7 @@ import { provideOtel, type UnexpectedError } from '@livestore/common'
3
3
  import { Events, makeSchema, State } from '@livestore/common/schema'
4
4
  import type { LiveStoreSchema, SqliteDsl, Store } from '@livestore/livestore'
5
5
  import { createStore } from '@livestore/livestore'
6
+ import { omitUndefineds } from '@livestore/utils'
6
7
  import { Effect, Schema, type Scope } from '@livestore/utils/effect'
7
8
  import type * as otel from '@opentelemetry/api'
8
9
  import React from 'react'
@@ -86,7 +87,7 @@ export const events = {
86
87
 
87
88
  const materializers = State.SQLite.materializers(events, {
88
89
  todoCreated: ({ id, text, completed }) => todos.insert({ id, text, completed }),
89
- todoUpdated: ({ id, text, completed }) => todos.update({ completed, text }).where({ id }),
90
+ todoUpdated: ({ id, text, completed }) => todos.update({ ...omitUndefineds({ completed, text }) }).where({ id }),
90
91
  })
91
92
 
92
93
  export const tables = { todos, app, userInfo, AppRouterSchema, kv }
@@ -163,4 +164,4 @@ export const makeTodoMvcReact: ({
163
164
  const renderCount = makeRenderCount()
164
165
 
165
166
  return { wrapper, store: storeWithReactApi, renderCount }
166
- }).pipe(provideOtel({ parentSpanContext: otelContext, otelTracer }))
167
+ }).pipe(provideOtel(omitUndefineds({ parentSpanContext: otelContext, otelTracer })))
@@ -1,7 +1,7 @@
1
1
  /** biome-ignore-all lint/a11y/useValidAriaRole: not needed for testing */
2
2
  /** biome-ignore-all lint/a11y/noStaticElementInteractions: not needed for testing */
3
3
  import * as LiveStore from '@livestore/livestore'
4
- import { getSimplifiedRootSpan } from '@livestore/livestore/internal/testing-utils'
4
+ import { getAllSimplifiedRootSpans, getSimplifiedRootSpan } from '@livestore/livestore/internal/testing-utils'
5
5
  import { Effect, ReadonlyRecord, Schema } from '@livestore/utils/effect'
6
6
  import { Vitest } from '@livestore/utils-dev/node-vitest'
7
7
  import * as otel from '@opentelemetry/api'
@@ -323,7 +323,8 @@ Vitest.describe('useClientDocument', () => {
323
323
  })
324
324
  }
325
325
 
326
- expect(getSimplifiedRootSpan(exporter, mapAttributes)).toMatchSnapshot()
326
+ expect(getSimplifiedRootSpan(exporter, 'createStore', mapAttributes)).toMatchSnapshot()
327
+ expect(getAllSimplifiedRootSpans(exporter, 'LiveStore:commit', mapAttributes)).toMatchSnapshot()
327
328
 
328
329
  await provider.shutdown()
329
330
  },
@@ -3,7 +3,7 @@ import { SessionIdSymbol } from '@livestore/common'
3
3
  import { State } from '@livestore/common/schema'
4
4
  import type { LiveQuery, LiveQueryDef, Store } from '@livestore/livestore'
5
5
  import { queryDb } from '@livestore/livestore'
6
- import { shouldNeverHappen } from '@livestore/utils'
6
+ import { omitUndefineds, shouldNeverHappen } from '@livestore/utils'
7
7
  import React from 'react'
8
8
 
9
9
  import { LiveStoreContext } from './LiveStoreContext.ts'
@@ -105,8 +105,7 @@ export const useClientDocument: {
105
105
  const tableName = table.sqliteDef.name
106
106
 
107
107
  const store =
108
- storeArg?.store ??
109
- // biome-ignore lint/correctness/useHookAtTopLevel: store is stable
108
+ storeArg?.store ?? // biome-ignore lint/correctness/useHookAtTopLevel: store is stable
110
109
  React.useContext(LiveStoreContext)?.store ??
111
110
  shouldNeverHappen(`No store provided to useClientDocument`)
112
111
 
@@ -125,7 +124,7 @@ export const useClientDocument: {
125
124
 
126
125
  const queryRef = useQueryRef(queryDef, {
127
126
  otelSpanName: `LiveStore:useClientDocument:${tableName}:${idStr}`,
128
- store: storeArg?.store,
127
+ ...omitUndefineds({ store: storeArg?.store }),
129
128
  })
130
129
 
131
130
  const setState = React.useMemo<StateSetters<TTableDef>>(
package/src/useQuery.ts CHANGED
@@ -42,8 +42,7 @@ export const useQueryRef = <TQuery extends LiveQueryDef.Any>(
42
42
  queryRcRef: LiveQueries.RcRef<LiveQuery<LiveQueries.GetResult<TQuery>>>
43
43
  } => {
44
44
  const store =
45
- options?.store ??
46
- // biome-ignore lint/correctness/useHookAtTopLevel: store is stable
45
+ options?.store ?? // biome-ignore lint/correctness/useHookAtTopLevel: store is stable
47
46
  React.useContext(LiveStoreContext)?.store ??
48
47
  shouldNeverHappen(`No store provided to useQuery`)
49
48