@livestore/livestore 0.4.0 → 0.5.0-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.map +1 -1
- package/dist/SqliteDbWrapper.d.ts +1 -1
- package/dist/SqliteDbWrapper.d.ts.map +1 -1
- package/dist/SqliteDbWrapper.js +9 -7
- package/dist/SqliteDbWrapper.js.map +1 -1
- package/dist/SqliteDbWrapper.test.js +22 -5
- package/dist/SqliteDbWrapper.test.js.map +1 -1
- package/dist/effect/LiveStore.d.ts +68 -16
- package/dist/effect/LiveStore.d.ts.map +1 -1
- package/dist/effect/LiveStore.js +22 -20
- package/dist/effect/LiveStore.js.map +1 -1
- package/dist/effect/LiveStore.test.js +7 -8
- package/dist/effect/LiveStore.test.js.map +1 -1
- package/dist/effect/mod.js +2 -2
- package/dist/internal/mod.js +2 -2
- package/dist/live-queries/base-class.d.ts +20 -3
- package/dist/live-queries/base-class.d.ts.map +1 -1
- package/dist/live-queries/base-class.js +30 -4
- package/dist/live-queries/base-class.js.map +1 -1
- package/dist/live-queries/client-document-get-query.d.ts.map +1 -1
- package/dist/live-queries/client-document-get-query.js +1 -1
- package/dist/live-queries/computed.d.ts +1 -1
- package/dist/live-queries/computed.d.ts.map +1 -1
- package/dist/live-queries/computed.js +5 -5
- package/dist/live-queries/computed.js.map +1 -1
- package/dist/live-queries/db-query.d.ts +3 -3
- package/dist/live-queries/db-query.d.ts.map +1 -1
- package/dist/live-queries/db-query.js +30 -21
- package/dist/live-queries/db-query.js.map +1 -1
- package/dist/live-queries/db-query.test.js +15 -15
- package/dist/live-queries/db-query.test.js.map +1 -1
- package/dist/live-queries/mod.js +4 -4
- package/dist/live-queries/signal.d.ts +1 -1
- package/dist/live-queries/signal.d.ts.map +1 -1
- package/dist/live-queries/signal.js +2 -2
- package/dist/live-queries/signal.js.map +1 -1
- package/dist/live-queries/signal.test.js +5 -5
- package/dist/live-queries/signal.test.js.map +1 -1
- package/dist/mod.js +8 -8
- package/dist/reactive.d.ts +1 -1
- package/dist/reactive.d.ts.map +1 -1
- package/dist/reactive.js +20 -1
- package/dist/reactive.js.map +1 -1
- package/dist/reactive.test.js +1 -1
- package/dist/store/StoreRegistry.d.ts +12 -12
- package/dist/store/StoreRegistry.d.ts.map +1 -1
- package/dist/store/StoreRegistry.js +25 -25
- package/dist/store/StoreRegistry.js.map +1 -1
- package/dist/store/StoreRegistry.test.js +65 -62
- package/dist/store/StoreRegistry.test.js.map +1 -1
- package/dist/store/create-store.d.ts +27 -16
- package/dist/store/create-store.d.ts.map +1 -1
- package/dist/store/create-store.js +55 -27
- package/dist/store/create-store.js.map +1 -1
- package/dist/store/create-store.test.d.ts +2 -0
- package/dist/store/create-store.test.d.ts.map +1 -0
- package/dist/store/create-store.test.js +28 -0
- package/dist/store/create-store.test.js.map +1 -0
- package/dist/store/devtools.d.ts +1 -2
- package/dist/store/devtools.d.ts.map +1 -1
- package/dist/store/devtools.js +6 -5
- package/dist/store/devtools.js.map +1 -1
- package/dist/store/store-commit.test.d.ts +2 -0
- package/dist/store/store-commit.test.d.ts.map +1 -0
- package/dist/store/store-commit.test.js +85 -0
- package/dist/store/store-commit.test.js.map +1 -0
- package/dist/store/store-eventstream.test.js +6 -6
- package/dist/store/store-eventstream.test.js.map +1 -1
- package/dist/store/store-types.d.ts +10 -28
- package/dist/store/store-types.d.ts.map +1 -1
- package/dist/store/store-types.js +2 -38
- package/dist/store/store-types.js.map +1 -1
- package/dist/store/store-types.test.js +4 -4
- package/dist/store/store.d.ts +15 -16
- package/dist/store/store.d.ts.map +1 -1
- package/dist/store/store.js +149 -91
- package/dist/store/store.js.map +1 -1
- package/dist/utils/data-structures.d.ts.map +1 -1
- package/dist/utils/dev.d.ts.map +1 -1
- package/dist/utils/dev.js +1 -1
- package/dist/utils/dev.js.map +1 -1
- package/dist/utils/function-string.d.ts +3 -3
- package/dist/utils/function-string.d.ts.map +1 -1
- package/dist/utils/stack-info.d.ts.map +1 -1
- package/dist/utils/stack-info.js +2 -1
- package/dist/utils/stack-info.js.map +1 -1
- package/dist/utils/stack-info.test.js +1 -1
- package/dist/utils/tests/fixture.d.ts +26 -34
- package/dist/utils/tests/fixture.d.ts.map +1 -1
- package/dist/utils/tests/fixture.js.map +1 -1
- package/dist/utils/tests/mod.js +3 -3
- package/dist/utils/tests/otel.d.ts +6 -6
- package/dist/utils/tests/otel.d.ts.map +1 -1
- package/package.json +40 -50
- package/src/SqliteDbWrapper.test.ts +25 -3
- package/src/SqliteDbWrapper.ts +13 -10
- package/src/effect/LiveStore.test.ts +16 -16
- package/src/effect/LiveStore.ts +83 -51
- package/src/live-queries/__snapshots__/db-query.test.ts.snap +303 -97
- package/src/live-queries/base-class.ts +39 -7
- package/src/live-queries/computed.ts +5 -5
- package/src/live-queries/db-query.test.ts +9 -9
- package/src/live-queries/db-query.ts +42 -30
- package/src/live-queries/signal.test.ts +2 -2
- package/src/live-queries/signal.ts +3 -3
- package/src/reactive.ts +45 -35
- package/src/store/StoreRegistry.test.ts +62 -59
- package/src/store/StoreRegistry.ts +49 -38
- package/src/store/create-store.test.ts +35 -0
- package/src/store/create-store.ts +110 -55
- package/src/store/devtools.ts +283 -283
- package/src/store/store-commit.test.ts +137 -0
- package/src/store/store-eventstream.test.ts +16 -7
- package/src/store/store-types.test.ts +1 -1
- package/src/store/store-types.ts +10 -56
- package/src/store/store.ts +184 -110
- package/src/utils/dev.ts +1 -1
- package/src/utils/stack-info.ts +4 -1
package/src/effect/LiveStore.ts
CHANGED
|
@@ -1,15 +1,29 @@
|
|
|
1
1
|
import type { UnknownError } from '@livestore/common'
|
|
2
2
|
import type { LiveStoreEvent, LiveStoreSchema } from '@livestore/common/schema'
|
|
3
3
|
import { omitUndefineds } from '@livestore/utils'
|
|
4
|
-
import type {
|
|
5
|
-
import {
|
|
4
|
+
import type { Schema } from '@livestore/utils/effect'
|
|
5
|
+
import {
|
|
6
|
+
type Cause,
|
|
7
|
+
type OtelTracer,
|
|
8
|
+
type Scope,
|
|
9
|
+
Context,
|
|
10
|
+
Deferred,
|
|
11
|
+
Duration,
|
|
12
|
+
Effect,
|
|
13
|
+
Layer,
|
|
14
|
+
pipe,
|
|
15
|
+
} from '@livestore/utils/effect'
|
|
6
16
|
|
|
7
17
|
import type { LiveStoreContextProps } from '../store/create-store.ts'
|
|
8
18
|
import { createStore, DeferredStoreContext, LiveStoreContextRunning } from '../store/create-store.ts'
|
|
9
19
|
import type { LiveStoreContextRunning as LiveStoreContextRunningType, Queryable } from '../store/store-types.ts'
|
|
10
20
|
import type { Store as StoreClass } from '../store/store.ts'
|
|
11
21
|
|
|
12
|
-
export const makeLiveStoreContext = <
|
|
22
|
+
export const makeLiveStoreContext = <
|
|
23
|
+
TSchema extends LiveStoreSchema,
|
|
24
|
+
TContext = {},
|
|
25
|
+
TSyncPayloadSchema extends Schema.Codec<Schema.Json, Schema.Json> = typeof Schema.Json,
|
|
26
|
+
>({
|
|
13
27
|
schema,
|
|
14
28
|
storeId = 'default',
|
|
15
29
|
context,
|
|
@@ -20,9 +34,10 @@ export const makeLiveStoreContext = <TSchema extends LiveStoreSchema, TContext =
|
|
|
20
34
|
batchUpdates,
|
|
21
35
|
syncPayload,
|
|
22
36
|
syncPayloadSchema,
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
37
|
+
params,
|
|
38
|
+
}: LiveStoreContextProps<TSchema, TContext, TSyncPayloadSchema>): Effect.Effect<
|
|
39
|
+
LiveStoreContextRunning['Service'],
|
|
40
|
+
UnknownError | Cause.TimeoutError,
|
|
26
41
|
DeferredStoreContext | Scope.Scope | OtelTracer.OtelTracer
|
|
27
42
|
> =>
|
|
28
43
|
pipe(
|
|
@@ -32,12 +47,12 @@ export const makeLiveStoreContext = <TSchema extends LiveStoreSchema, TContext =
|
|
|
32
47
|
storeId,
|
|
33
48
|
adapter,
|
|
34
49
|
batchUpdates,
|
|
35
|
-
...omitUndefineds({ context, boot, disableDevtools, onBootStatus, syncPayload, syncPayloadSchema }),
|
|
50
|
+
...omitUndefineds({ context, boot, disableDevtools, onBootStatus, syncPayload, syncPayloadSchema, params }),
|
|
36
51
|
})
|
|
37
52
|
|
|
38
|
-
return { stage: 'running', store } as any as LiveStoreContextRunning['
|
|
53
|
+
return LiveStoreContextRunning.of({ stage: 'running', store } as any as LiveStoreContextRunning['Service'])
|
|
39
54
|
}),
|
|
40
|
-
Effect.
|
|
55
|
+
Effect.tapCause((cause) => Effect.flatMap(DeferredStoreContext, (def) => Deferred.failCause(def, cause))),
|
|
41
56
|
Effect.tap((storeCtx) => Effect.flatMap(DeferredStoreContext, (def) => Deferred.succeed(def, storeCtx))),
|
|
42
57
|
// This can take quite a while.
|
|
43
58
|
// TODO make this configurable
|
|
@@ -58,10 +73,14 @@ export const makeLiveStoreContext = <TSchema extends LiveStoreSchema, TContext =
|
|
|
58
73
|
* const layer = MainStore.layer({ adapter, ... })
|
|
59
74
|
* ```
|
|
60
75
|
*/
|
|
61
|
-
export const LiveStoreContextLayer = <
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
76
|
+
export const LiveStoreContextLayer = <
|
|
77
|
+
TSchema extends LiveStoreSchema,
|
|
78
|
+
TContext = {},
|
|
79
|
+
TSyncPayloadSchema extends Schema.Codec<Schema.Json, Schema.Json> = typeof Schema.Json,
|
|
80
|
+
>(
|
|
81
|
+
props: LiveStoreContextProps<TSchema, TContext, TSyncPayloadSchema>,
|
|
82
|
+
): Layer.Layer<LiveStoreContextRunning, UnknownError | Cause.TimeoutError, OtelTracer.OtelTracer> =>
|
|
83
|
+
Layer.effect(LiveStoreContextRunning, makeLiveStoreContext(props)).pipe(
|
|
65
84
|
Layer.withSpan('LiveStore'),
|
|
66
85
|
Layer.provide(LiveStoreContextDeferred),
|
|
67
86
|
)
|
|
@@ -71,7 +90,7 @@ export const LiveStoreContextLayer = <TSchema extends LiveStoreSchema, TContext
|
|
|
71
90
|
*/
|
|
72
91
|
export const LiveStoreContextDeferred = Layer.effect(
|
|
73
92
|
DeferredStoreContext,
|
|
74
|
-
Deferred.make<LiveStoreContextRunning['
|
|
93
|
+
Deferred.make<LiveStoreContextRunning['Service'], UnknownError>(),
|
|
75
94
|
)
|
|
76
95
|
|
|
77
96
|
// =============================================================================
|
|
@@ -99,10 +118,11 @@ export interface DeferredContextId<TStoreId extends string> {
|
|
|
99
118
|
}
|
|
100
119
|
|
|
101
120
|
/** Props for creating a store layer (schema and storeId are already provided) */
|
|
102
|
-
export type StoreLayerProps<
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
>
|
|
121
|
+
export type StoreLayerProps<
|
|
122
|
+
TSchema extends LiveStoreSchema,
|
|
123
|
+
TContext = {},
|
|
124
|
+
TSyncPayloadSchema extends Schema.Codec<Schema.Json, Schema.Json> = typeof Schema.Json,
|
|
125
|
+
> = Omit<LiveStoreContextProps<TSchema, TContext, TSyncPayloadSchema>, 'storeId' | 'schema'>
|
|
106
126
|
|
|
107
127
|
/**
|
|
108
128
|
* Type for a Store.Tag class. This is the return type of `Store.Tag(schema, storeId)`.
|
|
@@ -117,16 +137,18 @@ export type StoreLayerProps<TSchema extends LiveStoreSchema, TContext = {}> = Om
|
|
|
117
137
|
* Uses `interface` (not `type`) to allow the self-referential identifier without
|
|
118
138
|
* triggering TS2456 (circular type alias).
|
|
119
139
|
*/
|
|
120
|
-
export interface StoreTagClass<TSchema extends LiveStoreSchema, TStoreId extends string>
|
|
121
|
-
|
|
140
|
+
export interface StoreTagClass<TSchema extends LiveStoreSchema, TStoreId extends string> extends Context.Key<
|
|
141
|
+
StoreTagClass<TSchema, TStoreId>,
|
|
142
|
+
LiveStoreContextRunningType<TSchema>
|
|
143
|
+
> {
|
|
122
144
|
/** Constructor signature (makes the type extendable as a class) */
|
|
123
|
-
new (): Context.
|
|
145
|
+
new (): Context.Key<StoreTagClass<TSchema, TStoreId>, LiveStoreContextRunningType<TSchema>>
|
|
124
146
|
|
|
125
|
-
/**
|
|
147
|
+
/** Key identity type (from Context.Key) */
|
|
126
148
|
readonly Id: StoreTagClass<TSchema, TStoreId>
|
|
127
149
|
|
|
128
|
-
/** Service type (from Context.
|
|
129
|
-
readonly
|
|
150
|
+
/** Service type (from Context.Key) */
|
|
151
|
+
readonly Service: LiveStoreContextRunningType<TSchema>
|
|
130
152
|
|
|
131
153
|
/** The LiveStore schema for this store */
|
|
132
154
|
readonly schema: TSchema
|
|
@@ -135,12 +157,12 @@ export interface StoreTagClass<TSchema extends LiveStoreSchema, TStoreId extends
|
|
|
135
157
|
readonly storeId: TStoreId
|
|
136
158
|
|
|
137
159
|
/** Creates a layer that initializes the store */
|
|
138
|
-
layer<TContext>(
|
|
139
|
-
props: StoreLayerProps<TSchema, TContext>,
|
|
140
|
-
): Layer.Layer<StoreTagClass<TSchema, TStoreId>, UnknownError | Cause.
|
|
160
|
+
layer<TContext, TSyncPayloadSchema extends Schema.Codec<Schema.Json, Schema.Json> = typeof Schema.Json>(
|
|
161
|
+
props: StoreLayerProps<TSchema, TContext, TSyncPayloadSchema>,
|
|
162
|
+
): Layer.Layer<StoreTagClass<TSchema, TStoreId>, UnknownError | Cause.TimeoutError, OtelTracer.OtelTracer>
|
|
141
163
|
|
|
142
164
|
/** Deferred store tag for async initialization patterns */
|
|
143
|
-
readonly Deferred: Context.
|
|
165
|
+
readonly Deferred: Context.Key<
|
|
144
166
|
DeferredContextId<TStoreId>,
|
|
145
167
|
Deferred.Deferred<LiveStoreContextRunningType<TSchema>, UnknownError>
|
|
146
168
|
>
|
|
@@ -168,7 +190,7 @@ export interface StoreTagClass<TSchema extends LiveStoreSchema, TStoreId extends
|
|
|
168
190
|
/**
|
|
169
191
|
* Create a typed store context class for use with Effect.
|
|
170
192
|
*
|
|
171
|
-
* Returns a class that extends `Context.
|
|
193
|
+
* Returns a class that extends `Context.Service`, making it directly yieldable in Effect code.
|
|
172
194
|
* The class includes static methods for creating layers and accessors for common operations.
|
|
173
195
|
*
|
|
174
196
|
* @param schema - The LiveStore schema (used for type inference and runtime)
|
|
@@ -224,17 +246,19 @@ const makeStoreTag = <TSchema extends LiveStoreSchema, TStoreId extends string>(
|
|
|
224
246
|
type DeferredType = Deferred.Deferred<RunningType, UnknownError>
|
|
225
247
|
|
|
226
248
|
// Create the deferred tag and layers upfront
|
|
227
|
-
const _DeferredTag = Context.
|
|
249
|
+
const _DeferredTag = Context.Service<DeferredContextId<TStoreId>, DeferredType>(
|
|
228
250
|
`@livestore/store-deferred/${storeId}`,
|
|
229
251
|
)
|
|
230
252
|
|
|
231
253
|
const _DeferredLayer = Layer.effect(_DeferredTag, Deferred.make<RunningType, UnknownError>())
|
|
232
254
|
|
|
233
|
-
class Tag extends Context.Tag(`@livestore/store/${storeId}`)
|
|
255
|
+
class Tag extends Context.Service<Tag, RunningType>()(`@livestore/store/${storeId}`) {
|
|
234
256
|
static readonly schema: TSchema = schema
|
|
235
257
|
static readonly storeId: TStoreId = storeId
|
|
236
258
|
|
|
237
|
-
static layer<TContext = {}
|
|
259
|
+
static layer<TContext = {}, TSyncPayloadSchema extends Schema.Codec<Schema.Json, Schema.Json> = typeof Schema.Json>(
|
|
260
|
+
props: StoreLayerProps<TSchema, TContext, TSyncPayloadSchema>,
|
|
261
|
+
) {
|
|
238
262
|
return pipe(
|
|
239
263
|
Effect.gen(function* () {
|
|
240
264
|
const store = yield* createStore({
|
|
@@ -249,6 +273,7 @@ const makeStoreTag = <TSchema extends LiveStoreSchema, TStoreId extends string>(
|
|
|
249
273
|
onBootStatus: props.onBootStatus,
|
|
250
274
|
syncPayload: props.syncPayload,
|
|
251
275
|
syncPayloadSchema: props.syncPayloadSchema,
|
|
276
|
+
params: props.params,
|
|
252
277
|
}),
|
|
253
278
|
})
|
|
254
279
|
|
|
@@ -259,11 +284,11 @@ const makeStoreTag = <TSchema extends LiveStoreSchema, TStoreId extends string>(
|
|
|
259
284
|
optDeferred._tag === 'Some' ? Deferred.succeed(optDeferred.value, ctx) : Effect.void,
|
|
260
285
|
)
|
|
261
286
|
|
|
262
|
-
return ctx
|
|
287
|
+
return Tag.of(ctx)
|
|
263
288
|
}),
|
|
264
289
|
Effect.timeout(Duration.minutes(5)),
|
|
265
290
|
Effect.withSpan(`@livestore/effect:Store.Tag:${storeId}`),
|
|
266
|
-
Layer.
|
|
291
|
+
Layer.effect(Tag),
|
|
267
292
|
Layer.withSpan(`LiveStore:${storeId}`),
|
|
268
293
|
Layer.provide(_DeferredLayer),
|
|
269
294
|
)
|
|
@@ -275,10 +300,10 @@ const makeStoreTag = <TSchema extends LiveStoreSchema, TStoreId extends string>(
|
|
|
275
300
|
static readonly fromDeferred = pipe(
|
|
276
301
|
Effect.gen(function* () {
|
|
277
302
|
const deferred = yield* _DeferredTag
|
|
278
|
-
const ctx = yield* deferred
|
|
279
|
-
return Layer.succeed(Tag, ctx)
|
|
303
|
+
const ctx = yield* Deferred.await(deferred)
|
|
304
|
+
return Layer.succeed(Tag, Tag.of(ctx))
|
|
280
305
|
}),
|
|
281
|
-
Layer.
|
|
306
|
+
Layer.unwrap,
|
|
282
307
|
)
|
|
283
308
|
|
|
284
309
|
static query<TResult>(query: Queryable<TResult>) {
|
|
@@ -291,7 +316,7 @@ const makeStoreTag = <TSchema extends LiveStoreSchema, TStoreId extends string>(
|
|
|
291
316
|
})
|
|
292
317
|
}
|
|
293
318
|
|
|
294
|
-
static use<A, E, R>(f: (ctx: RunningType) => Effect.Effect<A, E, R>) {
|
|
319
|
+
static override use<A, E, R>(f: (ctx: RunningType) => Effect.Effect<A, E, R>) {
|
|
295
320
|
return Effect.flatMap(Tag, f)
|
|
296
321
|
}
|
|
297
322
|
}
|
|
@@ -338,14 +363,17 @@ export const Store = {
|
|
|
338
363
|
*/
|
|
339
364
|
export interface StoreContext<TSchema extends LiveStoreSchema, TStoreId extends string> {
|
|
340
365
|
readonly storeId: TStoreId
|
|
341
|
-
readonly Tag: Context.
|
|
342
|
-
readonly DeferredTag: Context.
|
|
366
|
+
readonly Tag: Context.Key<StoreContextId<TSchema, TStoreId>, LiveStoreContextRunningType<TSchema>>
|
|
367
|
+
readonly DeferredTag: Context.Key<
|
|
343
368
|
DeferredContextId<TStoreId>,
|
|
344
369
|
Deferred.Deferred<LiveStoreContextRunningType<TSchema>, UnknownError>
|
|
345
370
|
>
|
|
346
|
-
readonly Layer: <
|
|
347
|
-
|
|
348
|
-
|
|
371
|
+
readonly Layer: <
|
|
372
|
+
TContext = {},
|
|
373
|
+
TSyncPayloadSchema extends Schema.Codec<Schema.Json, Schema.Json> = typeof Schema.Json,
|
|
374
|
+
>(
|
|
375
|
+
props: Omit<LiveStoreContextProps<TSchema, TContext, TSyncPayloadSchema>, 'storeId'>,
|
|
376
|
+
) => Layer.Layer<StoreContextId<TSchema, TStoreId>, UnknownError | Cause.TimeoutError, OtelTracer.OtelTracer>
|
|
349
377
|
readonly DeferredLayer: Layer.Layer<DeferredContextId<TStoreId>>
|
|
350
378
|
readonly fromDeferred: Layer.Layer<StoreContextId<TSchema, TStoreId>, UnknownError, DeferredContextId<TStoreId>>
|
|
351
379
|
}
|
|
@@ -368,17 +396,20 @@ export const makeStoreContext =
|
|
|
368
396
|
type RunningType = LiveStoreContextRunningType<TSchema>
|
|
369
397
|
type DeferredType = Deferred.Deferred<RunningType, UnknownError>
|
|
370
398
|
|
|
371
|
-
const Tag = Context.
|
|
399
|
+
const Tag = Context.Service<StoreContextId<TSchema, TStoreId>, RunningType>(`@livestore/store/${storeId}`)
|
|
372
400
|
|
|
373
|
-
const DeferredTag = Context.
|
|
401
|
+
const DeferredTag = Context.Service<DeferredContextId<TStoreId>, DeferredType>(
|
|
374
402
|
`@livestore/store-deferred/${storeId}`,
|
|
375
403
|
)
|
|
376
404
|
|
|
377
405
|
const DeferredLayer = Layer.effect(DeferredTag, Deferred.make<RunningType, UnknownError>())
|
|
378
406
|
|
|
379
|
-
const makeLayer = <
|
|
380
|
-
|
|
381
|
-
|
|
407
|
+
const makeLayer = <
|
|
408
|
+
TContext = {},
|
|
409
|
+
TSyncPayloadSchema extends Schema.Codec<Schema.Json, Schema.Json> = typeof Schema.Json,
|
|
410
|
+
>(
|
|
411
|
+
props: Omit<LiveStoreContextProps<TSchema, TContext, TSyncPayloadSchema>, 'storeId'>,
|
|
412
|
+
): Layer.Layer<StoreContextId<TSchema, TStoreId>, UnknownError | Cause.TimeoutError, OtelTracer.OtelTracer> =>
|
|
382
413
|
pipe(
|
|
383
414
|
Effect.gen(function* () {
|
|
384
415
|
const store = yield* createStore({
|
|
@@ -393,6 +424,7 @@ export const makeStoreContext =
|
|
|
393
424
|
onBootStatus: props.onBootStatus,
|
|
394
425
|
syncPayload: props.syncPayload,
|
|
395
426
|
syncPayloadSchema: props.syncPayloadSchema,
|
|
427
|
+
params: props.params,
|
|
396
428
|
}),
|
|
397
429
|
})
|
|
398
430
|
|
|
@@ -407,7 +439,7 @@ export const makeStoreContext =
|
|
|
407
439
|
}),
|
|
408
440
|
Effect.timeout(Duration.minutes(5)),
|
|
409
441
|
Effect.withSpan(`@livestore/effect:makeStoreContext:${storeId}`),
|
|
410
|
-
Layer.
|
|
442
|
+
Layer.effect(Tag),
|
|
411
443
|
Layer.withSpan(`LiveStore:${storeId}`),
|
|
412
444
|
Layer.provide(DeferredLayer),
|
|
413
445
|
)
|
|
@@ -419,10 +451,10 @@ export const makeStoreContext =
|
|
|
419
451
|
> = pipe(
|
|
420
452
|
Effect.gen(function* () {
|
|
421
453
|
const deferred = yield* DeferredTag
|
|
422
|
-
const ctx = yield* deferred
|
|
454
|
+
const ctx = yield* Deferred.await(deferred)
|
|
423
455
|
return Layer.succeed(Tag, ctx)
|
|
424
456
|
}),
|
|
425
|
-
Layer.
|
|
457
|
+
Layer.unwrap,
|
|
426
458
|
)
|
|
427
459
|
|
|
428
460
|
return {
|