@livestore/adapter-node 0.3.1-dev.0 → 0.3.2-dev.0
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/client-session/adapter.d.ts +1 -1
- package/dist/client-session/adapter.d.ts.map +1 -1
- package/dist/client-session/adapter.js +12 -15
- package/dist/client-session/adapter.js.map +1 -1
- package/dist/devtools/vite-dev-server.d.ts.map +1 -1
- package/dist/devtools/vite-dev-server.js +0 -3
- package/dist/devtools/vite-dev-server.js.map +1 -1
- package/dist/leader-thread-shared.d.ts +5 -4
- package/dist/leader-thread-shared.d.ts.map +1 -1
- package/dist/leader-thread-shared.js +4 -2
- package/dist/leader-thread-shared.js.map +1 -1
- package/dist/make-leader-worker.js +1 -1
- package/dist/make-leader-worker.js.map +1 -1
- package/dist/shutdown-channel.d.ts +1 -1
- package/dist/shutdown-channel.d.ts.map +1 -1
- package/dist/worker-schema.d.ts +6 -6
- package/dist/worker-schema.d.ts.map +1 -1
- package/dist/worker-schema.js +2 -3
- package/dist/worker-schema.js.map +1 -1
- package/package.json +7 -7
- package/src/client-session/adapter.ts +68 -68
- package/src/devtools/vite-dev-server.ts +0 -4
- package/src/leader-thread-shared.ts +14 -6
- package/src/make-leader-worker.ts +1 -1
- package/src/webchannel.ts +1 -1
- package/src/worker-schema.ts +2 -11
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import path from 'node:path'
|
|
2
|
-
import { fileURLToPath } from 'node:url'
|
|
3
2
|
|
|
4
3
|
import type { Devtools } from '@livestore/common'
|
|
5
4
|
import { UnexpectedError } from '@livestore/common'
|
|
@@ -25,8 +24,6 @@ export type ViteDevtoolsOptions = {
|
|
|
25
24
|
mode: Extract<Devtools.DevtoolsMode, { _tag: 'node' }>
|
|
26
25
|
}
|
|
27
26
|
|
|
28
|
-
const __dirname = path.dirname(fileURLToPath(import.meta.url))
|
|
29
|
-
|
|
30
27
|
// NOTE this is currently also used in @livestore/devtools-expo
|
|
31
28
|
export const makeViteMiddleware = (options: ViteDevtoolsOptions): Effect.Effect<Vite.ViteDevServer, UnexpectedError> =>
|
|
32
29
|
Effect.gen(function* () {
|
|
@@ -44,7 +41,6 @@ export const makeViteMiddleware = (options: ViteDevtoolsOptions): Effect.Effect<
|
|
|
44
41
|
fs: { strict: process.env.LS_DEV ? false : true },
|
|
45
42
|
},
|
|
46
43
|
appType: 'spa',
|
|
47
|
-
root: __dirname,
|
|
48
44
|
base: '/_livestore/',
|
|
49
45
|
plugins: [
|
|
50
46
|
livestoreDevtoolsPlugin({
|
|
@@ -21,11 +21,17 @@ import type * as WorkerSchema from './worker-schema.js'
|
|
|
21
21
|
|
|
22
22
|
export type TestingOverrides = {
|
|
23
23
|
clientSession?: {
|
|
24
|
-
leaderThreadProxy?:
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
dbEventlog?: (makeSqliteDb: MakeSqliteDb) => Effect.Effect<SqliteDb, UnexpectedError>
|
|
24
|
+
leaderThreadProxy?: (
|
|
25
|
+
original: ClientSessionLeaderThreadProxy.ClientSessionLeaderThreadProxy,
|
|
26
|
+
) => Partial<ClientSessionLeaderThreadProxy.ClientSessionLeaderThreadProxy>
|
|
28
27
|
}
|
|
28
|
+
makeLeaderThread?: (makeSqliteDb: MakeSqliteDb) => Effect.Effect<
|
|
29
|
+
{
|
|
30
|
+
dbEventlog: SqliteDb
|
|
31
|
+
dbState: SqliteDb
|
|
32
|
+
},
|
|
33
|
+
UnexpectedError
|
|
34
|
+
>
|
|
29
35
|
}
|
|
30
36
|
|
|
31
37
|
export interface MakeLeaderThreadArgs {
|
|
@@ -62,8 +68,10 @@ export const makeLeaderThread = ({
|
|
|
62
68
|
schema.state.sqlite.migrations.strategy === 'manual' ? 'fixed' : schema.state.sqlite.hash.toString()
|
|
63
69
|
|
|
64
70
|
const makeDb = (kind: 'state' | 'eventlog') => {
|
|
65
|
-
if (testing?.makeLeaderThread
|
|
66
|
-
return testing
|
|
71
|
+
if (testing?.makeLeaderThread) {
|
|
72
|
+
return testing
|
|
73
|
+
.makeLeaderThread(makeSqliteDb)
|
|
74
|
+
.pipe(Effect.map(({ dbEventlog, dbState }) => (kind === 'state' ? dbState : dbEventlog)))
|
|
67
75
|
}
|
|
68
76
|
|
|
69
77
|
return storage.type === 'in-memory'
|
|
@@ -47,7 +47,7 @@ export type WorkerOptions = {
|
|
|
47
47
|
export const getWorkerArgs = () => Schema.decodeSync(WorkerSchema.WorkerArgv)(process.argv[2]!)
|
|
48
48
|
|
|
49
49
|
export const makeWorker = (options: WorkerOptions) => {
|
|
50
|
-
makeWorkerEffect(options).pipe(
|
|
50
|
+
makeWorkerEffect(options).pipe(PlatformNode.NodeRuntime.runMain)
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
export const makeWorkerEffect = (options: WorkerOptions) => {
|
package/src/webchannel.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { BroadcastChannel as NodeBroadcastChannel } from 'node:worker_threads'
|
|
2
2
|
|
|
3
3
|
import type { Either, ParseResult } from '@livestore/utils/effect'
|
|
4
4
|
import { Deferred, Effect, Exit, Schema, Scope, Stream, WebChannel } from '@livestore/utils/effect'
|
package/src/worker-schema.ts
CHANGED
|
@@ -1,12 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
BootStatus,
|
|
3
|
-
Devtools,
|
|
4
|
-
LeaderAheadError,
|
|
5
|
-
LeaderPullCursor,
|
|
6
|
-
MigrationsReport,
|
|
7
|
-
SyncState,
|
|
8
|
-
UnexpectedError,
|
|
9
|
-
} from '@livestore/common'
|
|
1
|
+
import { BootStatus, Devtools, LeaderAheadError, MigrationsReport, SyncState, UnexpectedError } from '@livestore/common'
|
|
10
2
|
import { EventSequenceNumber, LiveStoreEvent } from '@livestore/common/schema'
|
|
11
3
|
import { Schema, Transferable } from '@livestore/utils/effect'
|
|
12
4
|
|
|
@@ -91,11 +83,10 @@ export namespace LeaderWorkerInner {
|
|
|
91
83
|
|
|
92
84
|
export class PullStream extends Schema.TaggedRequest<PullStream>()('PullStream', {
|
|
93
85
|
payload: {
|
|
94
|
-
cursor:
|
|
86
|
+
cursor: EventSequenceNumber.EventSequenceNumber,
|
|
95
87
|
},
|
|
96
88
|
success: Schema.Struct({
|
|
97
89
|
payload: SyncState.PayloadUpstream,
|
|
98
|
-
mergeCounter: Schema.Number,
|
|
99
90
|
}),
|
|
100
91
|
failure: UnexpectedError,
|
|
101
92
|
}) {}
|