@livestore/solid 0.4.0-dev.2 → 0.4.0-dev.21

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/query.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { LiveQueries } from '@livestore/livestore/internal';
1
+ import type { Queryable } from '@livestore/livestore';
2
2
  import * as Solid from 'solid-js';
3
- export declare const query: <TQuery extends LiveQueries.LiveQueryDef.Any>(queryDef: TQuery, initialValue: LiveQueries.GetResult<TQuery>) => Solid.Accessor<LiveQueries.GetResult<TQuery>>;
3
+ export declare const query: <TResult>(queryDef: Queryable<TResult>, initialValue: TResult) => Solid.Accessor<TResult>;
4
4
  //# sourceMappingURL=query.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../src/query.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAA;AAChE,OAAO,KAAK,KAAK,MAAM,UAAU,CAAA;AAIjC,eAAO,MAAM,KAAK,GAAI,MAAM,SAAS,WAAW,CAAC,YAAY,CAAC,GAAG,EAC/D,UAAU,MAAM,EAEhB,cAAc,WAAW,CAAC,SAAS,CAAC,MAAM,CAAC,KAC1C,KAAK,CAAC,QAAQ,CAAC,WAAW,CAAC,SAAS,CAAC,MAAM,CAAC,CAa9C,CAAA"}
1
+ {"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../src/query.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAA;AACrD,OAAO,KAAK,KAAK,MAAM,UAAU,CAAA;AAGjC,eAAO,MAAM,KAAK,GAAI,OAAO,EAC3B,UAAU,SAAS,CAAC,OAAO,CAAC,EAE5B,cAAc,OAAO,KACpB,KAAK,CAAC,QAAQ,CAAC,OAAO,CAaxB,CAAA"}
package/dist/query.js CHANGED
@@ -6,7 +6,7 @@ initialValue) => {
6
6
  const [value, setValue] = Solid.createSignal(initialValue);
7
7
  const store = storeToExport();
8
8
  // TODO avoid null-optionality branching
9
- const unsubscribe = store?.subscribe(queryDef, { onUpdate: setValue });
9
+ const unsubscribe = store?.subscribe(queryDef, (value) => setValue(value));
10
10
  Solid.onCleanup(() => {
11
11
  unsubscribe?.();
12
12
  });
package/dist/query.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"query.js","sourceRoot":"","sources":["../src/query.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,UAAU,CAAA;AAEjC,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAE1C,MAAM,CAAC,MAAM,KAAK,GAAG,CACnB,QAAgB;AAChB,qDAAqD;AACrD,YAA2C,EACI,EAAE;IACjD,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,KAAK,CAAC,YAAY,CAAC,YAAY,CAAC,CAAA;IAE1D,MAAM,KAAK,GAAG,aAAa,EAAE,CAAA;IAE7B,wCAAwC;IACxC,MAAM,WAAW,GAAG,KAAK,EAAE,SAAS,CAAC,QAAQ,EAAE,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC,CAAA;IAEtE,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACnB,WAAW,EAAE,EAAE,CAAA;IACjB,CAAC,CAAC,CAAA;IAEF,OAAO,KAAK,CAAA;AACd,CAAC,CAAA"}
1
+ {"version":3,"file":"query.js","sourceRoot":"","sources":["../src/query.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,UAAU,CAAA;AACjC,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAE1C,MAAM,CAAC,MAAM,KAAK,GAAG,CACnB,QAA4B;AAC5B,qDAAqD;AACrD,YAAqB,EACI,EAAE;IAC3B,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,KAAK,CAAC,YAAY,CAAC,YAAY,CAAC,CAAA;IAE1D,MAAM,KAAK,GAAG,aAAa,EAAE,CAAA;IAE7B,wCAAwC;IACxC,MAAM,WAAW,GAAG,KAAK,EAAE,SAAS,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,QAAQ,CAAC,KAAY,CAAC,CAAC,CAAA;IAEjF,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACnB,WAAW,EAAE,EAAE,CAAA;IACjB,CAAC,CAAC,CAAA;IAEF,OAAO,KAAK,CAAA;AACd,CAAC,CAAA"}
package/dist/store.d.ts CHANGED
@@ -1,5 +1,6 @@
1
+ import { LogConfig } from '@livestore/common';
1
2
  import type { CreateStoreOptions, LiveStoreSchema, Store } from '@livestore/livestore';
2
3
  import * as Solid from 'solid-js';
3
4
  export declare const storeToExport: Solid.Accessor<Store<any, {}> | undefined>, setStoreToExport: Solid.Setter<Store<any, {}> | undefined>;
4
- export declare const getStore: <Schema extends LiveStoreSchema>({ adapter, schema, storeId, }: Pick<CreateStoreOptions<Schema>, "schema" | "adapter" | "storeId">) => Promise<Solid.Accessor<Store<Schema> | undefined>>;
5
+ export declare const getStore: <Schema extends LiveStoreSchema>({ adapter, schema, storeId, logger, logLevel, }: Pick<CreateStoreOptions<Schema>, "schema" | "adapter" | "storeId"> & LogConfig.WithLoggerOptions) => Promise<Solid.Accessor<Store<Schema> | undefined>>;
5
6
  //# sourceMappingURL=store.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../src/store.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAEV,kBAAkB,EAClB,eAAe,EAEf,KAAK,EAEN,MAAM,sBAAsB,CAAA;AAI7B,OAAO,KAAK,KAAK,MAAM,UAAU,CAAA;AA4CjC,eAAO,MAAO,aAAa,8CAAE,gBAAgB,0CAGe,CAAA;AA0G5D,eAAO,MAAM,QAAQ,GAAU,MAAM,SAAS,eAAe,EAAE,+BAI5D,IAAI,CAAC,kBAAkB,CAAC,MAAM,CAAC,EAAE,QAAQ,GAAG,SAAS,GAAG,SAAS,CAAC,KAAG,OAAO,CAC7E,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,SAAS,CAAC,CAc1C,CAAA"}
1
+ {"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../src/store.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,SAAS,EAIV,MAAM,mBAAmB,CAAA;AAC1B,OAAO,KAAK,EAEV,kBAAkB,EAClB,eAAe,EAEf,KAAK,EAEN,MAAM,sBAAsB,CAAA;AAI7B,OAAO,KAAK,KAAK,MAAM,UAAU,CAAA;AA4CjC,eAAO,MAAO,aAAa,8CAAE,gBAAgB,0CAGe,CAAA;AA2G5D,eAAO,MAAM,QAAQ,GAAU,MAAM,SAAS,eAAe,EAAE,iDAM5D,IAAI,CAAC,kBAAkB,CAAC,MAAM,CAAC,EAAE,QAAQ,GAAG,SAAS,GAAG,SAAS,CAAC,GAAG,SAAS,CAAC,iBAAiB,KAAG,OAAO,CAC3G,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,SAAS,CAAC,CAgB1C,CAAA"}
package/dist/store.js CHANGED
@@ -1,7 +1,7 @@
1
- import { provideOtel, StoreInterrupted } from '@livestore/common';
1
+ import { LogConfig, provideOtel, StoreInterrupted, } from '@livestore/common';
2
2
  import { createStore, makeShutdownDeferred } from '@livestore/livestore';
3
- import { LS_DEV } from '@livestore/utils';
4
- import { Cause, Deferred, Effect, Exit, identity, Logger, LogLevel, Scope, TaskTracing } from '@livestore/utils/effect';
3
+ import { LS_DEV, omitUndefineds } from '@livestore/utils';
4
+ import { Cause, Deferred, Effect, Exit, identity, Scope, TaskTracing } from '@livestore/utils/effect';
5
5
  import * as Solid from 'solid-js';
6
6
  const interrupt = (componentScope, shutdownDeferred, error) => Effect.gen(function* () {
7
7
  // console.log('[@livestore/livestore/solid] interupting', error)
@@ -27,7 +27,7 @@ const [, setInternalStore] = Solid.createSignal(storeValue);
27
27
  // TODO remove `any` store type
28
28
  // this will require fixing: error TS2742: The inferred type of 'storeToExport' cannot be named without a reference to '../node_modules/@livestore/common/src/schema/state/sqlite/db-schema/dsl/mod.ts'. This is likely not portable. A type annotation is necessary.
29
29
  export const [storeToExport, setStoreToExport] = Solid.createSignal();
30
- const setupStore = async ({ schema, storeId, boot, adapter, batchUpdates, disableDevtools, signal, setupDone, }) => {
30
+ const setupStore = async ({ schema, storeId, boot, adapter, batchUpdates, disableDevtools, signal, setupDone, logger, logLevel, }) => {
31
31
  Solid.createEffect(() => {
32
32
  const counter = storeValue.counter;
33
33
  const setContextValue = (value) => {
@@ -60,10 +60,8 @@ const setupStore = async ({ schema, storeId, boot, adapter, batchUpdates, disabl
60
60
  const store = yield* createStore({
61
61
  schema,
62
62
  storeId,
63
- boot,
64
63
  adapter,
65
- batchUpdates,
66
- disableDevtools,
64
+ ...omitUndefineds({ boot, batchUpdates, disableDevtools }),
67
65
  onBootStatus: (status) => {
68
66
  if (storeValue.value.stage === 'running' || storeValue.value.stage === 'error')
69
67
  return;
@@ -74,8 +72,8 @@ const setupStore = async ({ schema, storeId, boot, adapter, batchUpdates, disabl
74
72
  setupDone();
75
73
  }).pipe(Scope.extend(componentScope), Effect.forkIn(componentScope));
76
74
  const shutdownContext = (cause) => Effect.sync(() => setContextValue({ stage: 'shutdown', cause }));
77
- yield* Deferred.await(shutdownDeferred).pipe(Effect.tapErrorCause((cause) => Effect.logDebug('[@livestore/livestore/solid] shutdown', Cause.pretty(cause))), Effect.tap((intentionalShutdown) => shutdownContext(intentionalShutdown)), Effect.catchTag('LiveStore.SyncError', (cause) => shutdownContext(cause)), Effect.catchTag('LiveStore.StoreInterrupted', (cause) => shutdownContext(cause)), Effect.tapError((error) => Effect.sync(() => setContextValue({ stage: 'error', error }))), Effect.tapDefect((defect) => Effect.sync(() => setContextValue({ stage: 'error', error: defect }))), Effect.exit);
78
- }).pipe(Effect.scoped, withSemaphore(storeId), Effect.withSpan('@livestore/solid:setupStore'), LS_DEV ? TaskTracing.withAsyncTaggingTracing((name) => console.createTask(name)) : identity, provideOtel({}), Effect.tapCauseLogPretty, Effect.annotateLogs({ thread: 'window' }), Effect.provide(Logger.prettyWithThread('window')), Logger.withMinimumLogLevel(LogLevel.Debug), Effect.runFork);
75
+ yield* Deferred.await(shutdownDeferred).pipe(Effect.tapErrorCause((cause) => Effect.logDebug('[@livestore/livestore/solid] shutdown', Cause.pretty(cause))), Effect.tap((intentionalShutdown) => shutdownContext(intentionalShutdown)), Effect.catchTag('InvalidPullError', (cause) => shutdownContext(cause)), Effect.catchTag('InvalidPushError', (cause) => shutdownContext(cause)), Effect.catchTag('LiveStore.StoreInterrupted', (cause) => shutdownContext(cause)), Effect.tapError((error) => Effect.sync(() => setContextValue({ stage: 'error', error }))), Effect.tapDefect((defect) => Effect.sync(() => setContextValue({ stage: 'error', error: defect }))), Effect.exit);
76
+ }).pipe(Effect.scoped, withSemaphore(storeId), Effect.withSpan('@livestore/solid:setupStore'), LS_DEV ? TaskTracing.withAsyncTaggingTracing((name) => console.createTask(name)) : identity, provideOtel({}), Effect.tapCauseLogPretty, Effect.annotateLogs({ thread: 'window' }), LogConfig.withLoggerConfig({ logger, logLevel }, { threadName: 'window' }), Effect.runFork);
79
77
  Solid.onCleanup(() => {
80
78
  if (storeValue.componentScope !== undefined && storeValue.shutdownDeferred !== undefined) {
81
79
  interrupt(storeValue.componentScope, storeValue.shutdownDeferred, new StoreInterrupted({ reason: 'unmounting component' }));
@@ -85,12 +83,14 @@ const setupStore = async ({ schema, storeId, boot, adapter, batchUpdates, disabl
85
83
  });
86
84
  });
87
85
  };
88
- export const getStore = async ({ adapter, schema, storeId, }) => {
86
+ export const getStore = async ({ adapter, schema, storeId, logger, logLevel, }) => {
89
87
  const setupDone = Promise.withResolvers();
90
88
  await setupStore({
91
89
  adapter,
92
90
  schema,
93
91
  storeId,
92
+ logger,
93
+ logLevel,
94
94
  setupDone: setupDone.resolve,
95
95
  });
96
96
  await setupDone.promise;
package/dist/store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AM,EAAE,sBAAsB,EAAE,CAAC,CACzD,CAAA;gBACD,UAAU,CAAC,cAAc,GAAG,SAAS,CAAA;gBACrC,UAAU,CAAC,gBAAgB,GAAG,SAAS,CAAA;YACzC,CAAC;QACH,CAAC,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;AACJ,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,QAAQ,GAAG,KAAK,EAAkC,EAC7D,OAAO,EACP,MAAM,EACN,OAAO,EACP,MAAM,EACN,QAAQ,GACyF,EAEjG,EAAE;IACF,MAAM,SAAS,GAAG,OAAO,CAAC,aAAa,EAAQ,CAAA;IAE/C,MAAM,UAAU,CAAC;QACf,OAAO;QACP,MAAM;QACN,OAAO;QACP,MAAM;QACN,QAAQ;QACR,SAAS,EAAE,SAAS,CAAC,OAAO;KAC7B,CAAC,CAAA;IAEF,MAAM,SAAS,CAAC,OAAO,CAAA;IAEvB,OAAO,aAAyD,CAAA;AAClE,CAAC,CAAA"}
package/package.json CHANGED
@@ -1,22 +1,22 @@
1
1
  {
2
2
  "name": "@livestore/solid",
3
- "version": "0.4.0-dev.2",
3
+ "version": "0.4.0-dev.21",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": "./dist/mod.js"
7
7
  },
8
8
  "dependencies": {
9
9
  "@opentelemetry/api": "1.9.0",
10
- "@livestore/common": "0.4.0-dev.2",
11
- "@livestore/utils": "0.4.0-dev.2",
12
- "@livestore/livestore": "0.4.0-dev.2"
10
+ "@livestore/utils": "0.4.0-dev.21",
11
+ "@livestore/livestore": "0.4.0-dev.21",
12
+ "@livestore/common": "0.4.0-dev.21"
13
13
  },
14
14
  "devDependencies": {
15
- "@opentelemetry/sdk-trace-base": "^2.0.1",
15
+ "@opentelemetry/sdk-trace-base": "2.0.1",
16
16
  "jsdom": "^26.1.0",
17
- "solid-js": "^1.9.8",
18
- "typescript": "^5.9.2",
19
- "vite": "^7.0.6",
17
+ "solid-js": "1.9.10",
18
+ "typescript": "5.9.2",
19
+ "vite": "7.2.4",
20
20
  "vitest": "3.2.4"
21
21
  },
22
22
  "files": [
@@ -26,7 +26,7 @@
26
26
  ],
27
27
  "license": "Apache-2.0",
28
28
  "peerDependencies": {
29
- "solid-js": "^1.9.8"
29
+ "solid-js": "^1.9.10"
30
30
  },
31
31
  "publishConfig": {
32
32
  "access": "public"
package/src/query.ts CHANGED
@@ -1,19 +1,18 @@
1
- import type { LiveQueries } from '@livestore/livestore/internal'
1
+ import type { Queryable } from '@livestore/livestore'
2
2
  import * as Solid from 'solid-js'
3
-
4
3
  import { storeToExport } from './store.ts'
5
4
 
6
- export const query = <TQuery extends LiveQueries.LiveQueryDef.Any>(
7
- queryDef: TQuery,
5
+ export const query = <TResult>(
6
+ queryDef: Queryable<TResult>,
8
7
  // TODO do we actually need an `initialValue` at all?
9
- initialValue: LiveQueries.GetResult<TQuery>,
10
- ): Solid.Accessor<LiveQueries.GetResult<TQuery>> => {
8
+ initialValue: TResult,
9
+ ): Solid.Accessor<TResult> => {
11
10
  const [value, setValue] = Solid.createSignal(initialValue)
12
11
 
13
12
  const store = storeToExport()
14
13
 
15
14
  // TODO avoid null-optionality branching
16
- const unsubscribe = store?.subscribe(queryDef, { onUpdate: setValue })
15
+ const unsubscribe = store?.subscribe(queryDef, (value) => setValue(value as any))
17
16
 
18
17
  Solid.onCleanup(() => {
19
18
  unsubscribe?.()
package/src/store.ts CHANGED
@@ -1,4 +1,10 @@
1
- import { type IntentionalShutdownCause, provideOtel, StoreInterrupted, type SyncError } from '@livestore/common'
1
+ import {
2
+ type IntentionalShutdownCause,
3
+ LogConfig,
4
+ provideOtel,
5
+ StoreInterrupted,
6
+ type SyncError,
7
+ } from '@livestore/common'
2
8
  import type {
3
9
  BootStatus,
4
10
  CreateStoreOptions,
@@ -8,8 +14,8 @@ import type {
8
14
  LiveStoreContext as StoreContext_,
9
15
  } from '@livestore/livestore'
10
16
  import { createStore, makeShutdownDeferred } from '@livestore/livestore'
11
- import { LS_DEV } from '@livestore/utils'
12
- import { Cause, Deferred, Effect, Exit, identity, Logger, LogLevel, Scope, TaskTracing } from '@livestore/utils/effect'
17
+ import { LS_DEV, omitUndefineds } from '@livestore/utils'
18
+ import { Cause, Deferred, Effect, Exit, identity, Scope, TaskTracing } from '@livestore/utils/effect'
13
19
  import * as Solid from 'solid-js'
14
20
 
15
21
  const interrupt = (componentScope: Scope.CloseableScope, shutdownDeferred: ShutdownDeferred, error: StoreInterrupted) =>
@@ -68,7 +74,10 @@ const setupStore = async ({
68
74
  disableDevtools,
69
75
  signal,
70
76
  setupDone,
71
- }: CreateStoreOptions<LiveStoreSchema> & { signal?: AbortSignal; setupDone: () => void }) => {
77
+ logger,
78
+ logLevel,
79
+ }: CreateStoreOptions<LiveStoreSchema> &
80
+ LogConfig.WithLoggerOptions & { signal?: AbortSignal; setupDone: () => void }) => {
72
81
  Solid.createEffect(() => {
73
82
  const counter = storeValue.counter
74
83
 
@@ -110,10 +119,8 @@ const setupStore = async ({
110
119
  const store = yield* createStore({
111
120
  schema,
112
121
  storeId,
113
- boot,
114
122
  adapter,
115
- batchUpdates,
116
- disableDevtools,
123
+ ...omitUndefineds({ boot, batchUpdates, disableDevtools }),
117
124
  onBootStatus: (status) => {
118
125
  if (storeValue.value.stage === 'running' || storeValue.value.stage === 'error') return
119
126
  setContextValue(status)
@@ -130,7 +137,8 @@ const setupStore = async ({
130
137
  yield* Deferred.await(shutdownDeferred).pipe(
131
138
  Effect.tapErrorCause((cause) => Effect.logDebug('[@livestore/livestore/solid] shutdown', Cause.pretty(cause))),
132
139
  Effect.tap((intentionalShutdown) => shutdownContext(intentionalShutdown)),
133
- Effect.catchTag('LiveStore.SyncError', (cause) => shutdownContext(cause)),
140
+ Effect.catchTag('InvalidPullError', (cause) => shutdownContext(cause)),
141
+ Effect.catchTag('InvalidPushError', (cause) => shutdownContext(cause)),
134
142
  Effect.catchTag('LiveStore.StoreInterrupted', (cause) => shutdownContext(cause)),
135
143
  Effect.tapError((error) => Effect.sync(() => setContextValue({ stage: 'error', error }))),
136
144
  Effect.tapDefect((defect) => Effect.sync(() => setContextValue({ stage: 'error', error: defect }))),
@@ -144,8 +152,7 @@ const setupStore = async ({
144
152
  provideOtel({}),
145
153
  Effect.tapCauseLogPretty,
146
154
  Effect.annotateLogs({ thread: 'window' }),
147
- Effect.provide(Logger.prettyWithThread('window')),
148
- Logger.withMinimumLogLevel(LogLevel.Debug),
155
+ LogConfig.withLoggerConfig({ logger, logLevel }, { threadName: 'window' }),
149
156
  Effect.runFork,
150
157
  )
151
158
 
@@ -167,7 +174,9 @@ export const getStore = async <Schema extends LiveStoreSchema>({
167
174
  adapter,
168
175
  schema,
169
176
  storeId,
170
- }: Pick<CreateStoreOptions<Schema>, 'schema' | 'adapter' | 'storeId'>): Promise<
177
+ logger,
178
+ logLevel,
179
+ }: Pick<CreateStoreOptions<Schema>, 'schema' | 'adapter' | 'storeId'> & LogConfig.WithLoggerOptions): Promise<
171
180
  Solid.Accessor<Store<Schema> | undefined>
172
181
  > => {
173
182
  const setupDone = Promise.withResolvers<void>()
@@ -176,6 +185,8 @@ export const getStore = async <Schema extends LiveStoreSchema>({
176
185
  adapter,
177
186
  schema,
178
187
  storeId,
188
+ logger,
189
+ logLevel,
179
190
  setupDone: setupDone.resolve,
180
191
  })
181
192