@livestore/adapter-node 0.0.0-snapshot-412a36a7e6c9b0e9e237b553fd0522aed285228f.4 → 0.0.0-snapshot-c1f0b46f049c5a40eb57f52e232999b7f810cd93

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.
@@ -15,8 +15,8 @@ export type WorkerOptions = {
15
15
  testing?: TestingOverrides;
16
16
  };
17
17
  export declare const getWorkerArgs: () => {
18
- readonly storeId: string;
19
18
  readonly clientId: string;
19
+ readonly storeId: string;
20
20
  readonly sessionId: string;
21
21
  };
22
22
  export declare const makeWorker: (options: WorkerOptions) => void;
@@ -1,2 +1,2 @@
1
- export declare const makeShutdownChannel: (storeId: string) => import("effect/Effect").Effect<import("@livestore/utils/dist/effect/WebChannel/common.js").WebChannel<import("@livestore/common/dist/adapter-types.js").UnexpectedError | import("@livestore/common/dist/adapter-types.js").IntentionalShutdownCause, import("@livestore/common/dist/adapter-types.js").UnexpectedError | import("@livestore/common/dist/adapter-types.js").IntentionalShutdownCause, never>, never, import("effect/Scope").Scope>;
1
+ export declare const makeShutdownChannel: (storeId: string) => import("effect/Effect").Effect<import("@livestore/utils/dist/effect/WebChannel/common.js").WebChannel<import("@livestore/common/dist/adapter-types.js").IntentionalShutdownCause | import("@livestore/common/dist/adapter-types.js").UnexpectedError, import("@livestore/common/dist/adapter-types.js").IntentionalShutdownCause | import("@livestore/common/dist/adapter-types.js").UnexpectedError, never>, never, import("effect/Scope").Scope>;
2
2
  //# sourceMappingURL=shutdown-channel.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"webchannel.d.ts","sourceRoot":"","sources":["../src/webchannel.ts"],"names":[],"mappings":"AAIA,OAAO,EAAY,MAAM,EAAQ,MAAM,EAAE,KAAK,EAAU,UAAU,EAAE,MAAM,yBAAyB,CAAA;AAEnG,eAAO,MAAM,oBAAoB,GAAI,GAAG,EAAE,UAAU,EAAE,0BAGnD;IACD,WAAW,EAAE,MAAM,CAAA;IACnB,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,UAAU,CAAC,CAAA;CACvC,KAAG,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,UAAU,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,CAyDlE,CAAA"}
1
+ {"version":3,"file":"webchannel.d.ts","sourceRoot":"","sources":["../src/webchannel.ts"],"names":[],"mappings":"AAGA,OAAO,EAAY,MAAM,EAAQ,MAAM,EAAE,KAAK,EAAU,UAAU,EAAE,MAAM,yBAAyB,CAAA;AAEnG,eAAO,MAAM,oBAAoB,GAAI,GAAG,EAAE,UAAU,EAAE,0BAGnD;IACD,WAAW,EAAE,MAAM,CAAA;IACnB,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,UAAU,CAAC,CAAA;CACvC,KAAG,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,UAAU,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,CA0DlE,CAAA"}
@@ -1,8 +1,8 @@
1
- import { shouldNeverHappen } from '@livestore/utils';
2
1
  import { Deferred, Effect, Exit, Schema, Scope, Stream, WebChannel } from '@livestore/utils/effect';
3
2
  export const makeBroadcastChannel = ({ channelName, schema, }) => Effect.scopeWithCloseable((scope) => Effect.gen(function* () {
4
3
  if (globalThis.BroadcastChannel === undefined) {
5
- return shouldNeverHappen('BroadcastChannel is not supported in this environment');
4
+ yield* Effect.logWarning('BroadcastChannel is not supported in this environment. Using a NoopChannel instead.');
5
+ return (yield* WebChannel.noopChannel());
6
6
  }
7
7
  // NOTE we're using `globalThis.BroadcastChannel` here because `BroadcastChannel`
8
8
  // from `node:worker_threads` is not yet stable in Deno
@@ -1 +1 @@
1
- {"version":3,"file":"webchannel.js","sourceRoot":"","sources":["../src/webchannel.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,C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U,EAAE,EAAE;YACjC,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAA;QAC7D,CAAC,CAAA;QAED,OAAO,OAAO,CAAA;IAChB,CAAC,CAAC,EACF,CAAC,OAAO,EAAE,EAAE,CACV,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE;QACf,wEAAwE;QACxE,IAAI,OAAO,OAAO,CAAC,KAAK,KAAK,UAAU,EAAE,CAAC;YACxC,OAAO,CAAC,KAAK,EAAE,CAAA;QACjB,CAAC;IACH,CAAC,CAAC,CACL,CACF,CAAA;IAED,MAAM,cAAc,GAAG,KAAK,CAAC,CAAC,QAAQ,CAAC,IAAI,EAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;IACzG,MAAM,qBAAqB,GAAG,KAAK,CAAA;IAEnC,OAAO;QACL,CAAC,UAAU,CAAC,gBAAgB,CAAC,EAAE,UAAU,CAAC,gBAAgB;QAC1D,IAAI;QACJ,MAAM;QACN,cAAc;QACd,MAAM,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE;QACxC,qBAAqB;QACrB,QAAQ,EAAE,KAAK,CAAC,KAAK,CAAC,KAAK,EAAE,IAAI,CAAC,IAAI,CAAC;KACxC,CAAA;AACH,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,+BAA+B,WAAW,GAAG,CAAC,CAAC,CACxE,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@livestore/adapter-node",
3
- "version": "0.0.0-snapshot-412a36a7e6c9b0e9e237b553fd0522aed285228f.4",
3
+ "version": "0.0.0-snapshot-c1f0b46f049c5a40eb57f52e232999b7f810cd93",
4
4
  "type": "module",
5
5
  "sideEffects": false,
6
6
  "exports": {
@@ -26,14 +26,14 @@
26
26
  }
27
27
  },
28
28
  "dependencies": {
29
- "@livestore/devtools-vite": "0.3.0-dev.33",
29
+ "@livestore/devtools-vite": "0.3.0-dev.34",
30
30
  "@opentelemetry/api": "1.9.0",
31
31
  "vite": "6.2.1",
32
- "@livestore/common": "0.0.0-snapshot-412a36a7e6c9b0e9e237b553fd0522aed285228f.4",
33
- "@livestore/utils": "0.0.0-snapshot-412a36a7e6c9b0e9e237b553fd0522aed285228f.4",
34
- "@livestore/devtools-node-common": "0.0.0-snapshot-412a36a7e6c9b0e9e237b553fd0522aed285228f.4",
35
- "@livestore/sqlite-wasm": "0.0.0-snapshot-412a36a7e6c9b0e9e237b553fd0522aed285228f.4",
36
- "@livestore/webmesh": "0.0.0-snapshot-412a36a7e6c9b0e9e237b553fd0522aed285228f.4"
32
+ "@livestore/common": "0.0.0-snapshot-c1f0b46f049c5a40eb57f52e232999b7f810cd93",
33
+ "@livestore/devtools-node-common": "0.0.0-snapshot-c1f0b46f049c5a40eb57f52e232999b7f810cd93",
34
+ "@livestore/utils": "0.0.0-snapshot-c1f0b46f049c5a40eb57f52e232999b7f810cd93",
35
+ "@livestore/webmesh": "0.0.0-snapshot-c1f0b46f049c5a40eb57f52e232999b7f810cd93",
36
+ "@livestore/sqlite-wasm": "0.0.0-snapshot-c1f0b46f049c5a40eb57f52e232999b7f810cd93"
37
37
  },
38
38
  "devDependencies": {
39
39
  "@rollup/plugin-commonjs": "^28.0.3",
package/src/webchannel.ts CHANGED
@@ -1,6 +1,5 @@
1
1
  import { type BroadcastChannel as NodeBroadcastChannel } from 'node:worker_threads'
2
2
 
3
- import { shouldNeverHappen } from '@livestore/utils'
4
3
  import type { Either, ParseResult } from '@livestore/utils/effect'
5
4
  import { Deferred, Effect, Exit, Schema, Scope, Stream, WebChannel } from '@livestore/utils/effect'
6
5
 
@@ -14,7 +13,8 @@ export const makeBroadcastChannel = <Msg, MsgEncoded>({
14
13
  Effect.scopeWithCloseable((scope) =>
15
14
  Effect.gen(function* () {
16
15
  if (globalThis.BroadcastChannel === undefined) {
17
- return shouldNeverHappen('BroadcastChannel is not supported in this environment')
16
+ yield* Effect.logWarning('BroadcastChannel is not supported in this environment. Using a NoopChannel instead.')
17
+ return (yield* WebChannel.noopChannel()) as any as WebChannel.WebChannel<Msg, Msg>
18
18
  }
19
19
 
20
20
  // NOTE we're using `globalThis.BroadcastChannel` here because `BroadcastChannel`
@@ -1,164 +0,0 @@
1
- import type { Adapter, MakeSqliteDb, SyncOptions } from '@livestore/common';
2
- import { UnexpectedError } from '@livestore/common';
3
- import type { LiveStoreSchema } from '@livestore/common/schema';
4
- import { LiveStoreEvent } from '@livestore/common/schema';
5
- import type { Schema } from '@livestore/utils/effect';
6
- import { Effect, Stream } from '@livestore/utils/effect';
7
- import type { TestingOverrides } from '../leader-shared.js';
8
- export interface InMemoryAdapterOptions {
9
- sync?: SyncOptions;
10
- /**
11
- * @default 'in-memory'
12
- */
13
- clientId?: string;
14
- /**
15
- * @default nanoid(6)
16
- */
17
- sessionId?: string;
18
- /** Only used internally for testing */
19
- testing?: {
20
- overrides?: TestingOverrides;
21
- };
22
- }
23
- export declare const makeInMemoryAdapter: ({ sync: syncOptions, clientId, sessionId, testing }: InMemoryAdapterOptions) => Adapter;
24
- export declare const makeInMemoryLeaderThread: ({ storeId, clientId, schema, makeSqliteDb, syncOptions, syncPayload, testing, }: {
25
- storeId: string;
26
- clientId: string;
27
- schema: LiveStoreSchema;
28
- makeSqliteDb: MakeSqliteDb;
29
- syncOptions: SyncOptions | undefined;
30
- syncPayload: Schema.JsonValue | undefined;
31
- testing?: {
32
- overrides?: TestingOverrides;
33
- };
34
- }) => Effect.Effect<{
35
- leaderThread: {
36
- events: {
37
- pull: (args: {
38
- cursor: import("@livestore/common").LeaderPullCursor;
39
- }) => Stream.Stream<{
40
- payload: {
41
- readonly _tag: "upstream-rebase";
42
- readonly rollbackEvents: readonly LiveStoreEvent.EncodedWithMeta[];
43
- readonly newEvents: readonly LiveStoreEvent.EncodedWithMeta[];
44
- } | {
45
- readonly _tag: "upstream-advance";
46
- readonly newEvents: readonly LiveStoreEvent.EncodedWithMeta[];
47
- };
48
- mergeCounter: number;
49
- }, UnexpectedError>;
50
- push: (batch: readonly LiveStoreEvent.AnyEncoded[]) => Effect.Effect<void, import("@livestore/common").LeaderAheadError, never>;
51
- };
52
- initialState: {
53
- leaderHead: import("@livestore/common/dist/schema/EventId.js").EventId;
54
- migrationsReport: {
55
- readonly migrations: readonly {
56
- readonly tableName: string;
57
- readonly hashes: {
58
- readonly expected: number;
59
- readonly actual?: number | undefined;
60
- };
61
- }[];
62
- };
63
- };
64
- export: Effect.Effect<Uint8Array<ArrayBufferLike>, never, never>;
65
- getEventlogData: Effect.Effect<Uint8Array<ArrayBufferLike>, never, never>;
66
- getSyncState: import("@livestore/utils/dist/effect/Subscribable.js").Subscribable<import("@livestore/common/dist/sync/syncstate.js").SyncState, never, never>;
67
- sendDevtoolsMessage: (message: {
68
- readonly clientId: string;
69
- readonly _tag: "LSD.Leader.SnapshotReq";
70
- readonly liveStoreVersion: "0.3.0-dev.33";
71
- readonly requestId: string;
72
- } | {
73
- readonly clientId: string;
74
- readonly _tag: "LSD.Leader.EventlogReq";
75
- readonly liveStoreVersion: "0.3.0-dev.33";
76
- readonly requestId: string;
77
- } | {
78
- readonly clientId: string;
79
- readonly _tag: "LSD.Leader.NetworkStatusSubscribe";
80
- readonly liveStoreVersion: "0.3.0-dev.33";
81
- readonly requestId: string;
82
- readonly subscriptionId: string;
83
- } | {
84
- readonly clientId: string;
85
- readonly _tag: "LSD.Leader.NetworkStatusUnsubscribe";
86
- readonly liveStoreVersion: "0.3.0-dev.33";
87
- readonly requestId: string;
88
- readonly subscriptionId: string;
89
- } | {
90
- readonly clientId: string;
91
- readonly _tag: "LSD.Leader.Disconnect";
92
- readonly liveStoreVersion: "0.3.0-dev.33";
93
- readonly requestId: string;
94
- } | {
95
- readonly clientId: string;
96
- readonly _tag: "LSD.Leader.CommitEventReq";
97
- readonly liveStoreVersion: "0.3.0-dev.33";
98
- readonly requestId: string;
99
- readonly eventEncoded: {
100
- readonly name: string;
101
- readonly args: any;
102
- };
103
- } | {
104
- readonly clientId: string;
105
- readonly _tag: "LSD.Leader.Ping";
106
- readonly liveStoreVersion: "0.3.0-dev.33";
107
- readonly requestId: string;
108
- } | {
109
- readonly clientId: string;
110
- readonly _tag: "LSD.Leader.DatabaseFileInfoReq";
111
- readonly liveStoreVersion: "0.3.0-dev.33";
112
- readonly requestId: string;
113
- } | {
114
- readonly clientId: string;
115
- readonly _tag: "LSD.Leader.SyncHistorySubscribe";
116
- readonly liveStoreVersion: "0.3.0-dev.33";
117
- readonly requestId: string;
118
- readonly subscriptionId: string;
119
- } | {
120
- readonly clientId: string;
121
- readonly _tag: "LSD.Leader.SyncHistoryUnsubscribe";
122
- readonly liveStoreVersion: "0.3.0-dev.33";
123
- readonly requestId: string;
124
- readonly subscriptionId: string;
125
- } | {
126
- readonly clientId: string;
127
- readonly _tag: "LSD.Leader.SyncingInfoReq";
128
- readonly liveStoreVersion: "0.3.0-dev.33";
129
- readonly requestId: string;
130
- } | {
131
- readonly clientId: string;
132
- readonly _tag: "LSD.Leader.SyncHeadSubscribe";
133
- readonly liveStoreVersion: "0.3.0-dev.33";
134
- readonly requestId: string;
135
- readonly subscriptionId: string;
136
- } | {
137
- readonly clientId: string;
138
- readonly _tag: "LSD.Leader.SyncHeadUnsubscribe";
139
- readonly liveStoreVersion: "0.3.0-dev.33";
140
- readonly requestId: string;
141
- readonly subscriptionId: string;
142
- } | {
143
- readonly clientId: string;
144
- readonly _tag: "LSD.Leader.LoadDatabaseFile.Request";
145
- readonly liveStoreVersion: "0.3.0-dev.33";
146
- readonly requestId: string;
147
- readonly data: Uint8Array<ArrayBufferLike>;
148
- } | {
149
- readonly clientId: string;
150
- readonly _tag: "LSD.Leader.ResetAllData.Request";
151
- readonly mode: "all-data" | "only-app-db";
152
- readonly liveStoreVersion: "0.3.0-dev.33";
153
- readonly requestId: string;
154
- } | {
155
- readonly clientId: string;
156
- readonly _tag: "LSD.Leader.SetSyncLatch.Request";
157
- readonly liveStoreVersion: "0.3.0-dev.33";
158
- readonly requestId: string;
159
- readonly closeLatch: boolean;
160
- }) => Effect.Effect<boolean, never, never>;
161
- };
162
- initialSnapshot: Uint8Array<ArrayBufferLike>;
163
- }, UnexpectedError | import("@livestore/common").SqliteError, import("effect/Scope").Scope>;
164
- //# sourceMappingURL=in-memory-adapter.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"in-memory-adapter.d.ts","sourceRoot":"","sources":["../../src/client-session/in-memory-adapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,OAAO,EAIP,YAAY,EAEZ,WAAW,EACZ,MAAM,mBAAmB,CAAA;AAC1B,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AAEnD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAA;AAC/D,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAA;AAGzD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAA;AACrD,OAAO,EAAS,MAAM,EAA0B,MAAM,EAAmB,MAAM,yBAAyB,CAAA;AAGxG,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAA;AAK3D,MAAM,WAAW,sBAAsB;IACrC,IAAI,CAAC,EAAE,WAAW,CAAA;IAClB;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;IAElB,uCAAuC;IACvC,OAAO,CAAC,EAAE;QACR,SAAS,CAAC,EAAE,gBAAgB,CAAA;KAC7B,CAAA;CACF;AAED,eAAO,MAAM,mBAAmB,GAC7B,qDAA+E,sBAAsB,KAAG,OAkD1D,CAAA;AAEjD,eAAO,MAAM,wBAAwB,GAAI,iFAQtC;IACD,OAAO,EAAE,MAAM,CAAA;IACf,QAAQ,EAAE,MAAM,CAAA;IAChB,MAAM,EAAE,eAAe,CAAA;IACvB,YAAY,EAAE,YAAY,CAAA;IAC1B,WAAW,EAAE,WAAW,GAAG,SAAS,CAAA;IACpC,WAAW,EAAE,MAAM,CAAC,SAAS,GAAG,SAAS,CAAA;IACzC,OAAO,CAAC,EAAE;QACR,SAAS,CAAC,EAAE,gBAAgB,CAAA;KAC7B,CAAA;CACF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2FA+CG,CAAA"}
@@ -1,74 +0,0 @@
1
- import { UnexpectedError } from '@livestore/common';
2
- import { Eventlog, LeaderThreadCtx, makeLeaderThreadLayer } from '@livestore/common/leader-thread';
3
- import { LiveStoreEvent } from '@livestore/common/schema';
4
- import { sqliteDbFactory } from '@livestore/sqlite-wasm/browser';
5
- import { loadSqlite3Wasm } from '@livestore/sqlite-wasm/load-wasm';
6
- import { Cause, Effect, FetchHttpClient, Layer, Stream, SubscriptionRef } from '@livestore/utils/effect';
7
- import { nanoid } from '@livestore/utils/nanoid';
8
- import { makeShutdownChannel } from '../shutdown-channel.js';
9
- export const makeInMemoryAdapter = ({ sync: syncOptions, clientId = 'in-memory', sessionId = nanoid(6), testing }) => ({ schema, storeId, shutdown, syncPayload,
10
- // devtoolsEnabled, bootStatusQueue, shutdown, connectDevtoolsToStore
11
- }) => Effect.gen(function* () {
12
- const sqlite3 = yield* Effect.promise(() => loadSqlite3Wasm());
13
- const makeSqliteDb = sqliteDbFactory({ sqlite3 });
14
- const sqliteDb = yield* makeSqliteDb({ _tag: 'in-memory' });
15
- const lockStatus = yield* SubscriptionRef.make('has-lock');
16
- const shutdownChannel = yield* makeShutdownChannel(storeId);
17
- yield* shutdownChannel.listen.pipe(Stream.flatten(), Stream.tap((error) => Effect.sync(() => shutdown(Cause.fail(error)))), Stream.runDrain, Effect.interruptible, Effect.tapCauseLogPretty, Effect.forkScoped);
18
- const { leaderThread, initialSnapshot } = yield* makeInMemoryLeaderThread({
19
- storeId,
20
- clientId,
21
- schema,
22
- makeSqliteDb,
23
- syncOptions,
24
- syncPayload,
25
- testing,
26
- });
27
- sqliteDb.import(initialSnapshot);
28
- const clientSession = {
29
- sqliteDb,
30
- devtools: { enabled: false },
31
- clientId,
32
- sessionId,
33
- lockStatus,
34
- leaderThread,
35
- shutdown,
36
- };
37
- return clientSession;
38
- }).pipe(UnexpectedError.mapToUnexpectedError);
39
- export const makeInMemoryLeaderThread = ({ storeId, clientId, schema, makeSqliteDb, syncOptions, syncPayload, testing, }) => Effect.gen(function* () {
40
- const layer = yield* Layer.memoize(makeLeaderThreadLayer({
41
- clientId,
42
- dbState: yield* makeSqliteDb({ _tag: 'in-memory' }),
43
- dbEventlog: testing?.overrides?.makeLeaderThread?.dbEventlog
44
- ? yield* testing.overrides.makeLeaderThread.dbEventlog(makeSqliteDb)
45
- : yield* makeSqliteDb({ _tag: 'in-memory' }),
46
- devtoolsOptions: { enabled: false },
47
- makeSqliteDb,
48
- schema,
49
- // NOTE we're creating a separate channel here since you can't listen to your own channel messages
50
- shutdownChannel: yield* makeShutdownChannel(storeId),
51
- storeId,
52
- syncOptions,
53
- syncPayload,
54
- }).pipe(Layer.provideMerge(FetchHttpClient.layer)));
55
- return yield* Effect.gen(function* () {
56
- const { dbState, dbEventlog, syncProcessor, extraIncomingMessagesQueue, initialState } = yield* LeaderThreadCtx;
57
- const initialLeaderHead = Eventlog.getClientHeadFromDb(dbEventlog);
58
- const leaderThread = {
59
- events: {
60
- pull: testing?.overrides?.clientSession?.leaderThreadProxy?.events?.pull ??
61
- (({ cursor }) => syncProcessor.pull({ cursor })),
62
- push: (batch) => syncProcessor.push(batch.map((item) => new LiveStoreEvent.EncodedWithMeta(item)), { waitForProcessing: true }),
63
- },
64
- initialState: { leaderHead: initialLeaderHead, migrationsReport: initialState.migrationsReport },
65
- export: Effect.sync(() => dbState.export()),
66
- getEventlogData: Effect.sync(() => dbEventlog.export()),
67
- getSyncState: syncProcessor.syncState,
68
- sendDevtoolsMessage: (message) => extraIncomingMessagesQueue.offer(message),
69
- };
70
- const initialSnapshot = dbState.export();
71
- return { leaderThread, initialSnapshot };
72
- }).pipe(Effect.provide(layer));
73
- });
74
- //# sourceMappingURL=in-memory-adapter.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"in-memory-adapter.js","sourceRoot":"","sources":["../../src/client-session/in-memory-adapter.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AACnD,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAA;AAElG,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAA;AACzD,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAA;AAChE,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAA;AAElE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,eAAe,EAAE,KAAK,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAA;AACxG,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAA;AAGhD,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAA;AAqB5D,MAAM,CAAC,MAAM,mBAAmB,GAC9B,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,QAAQ,GAAG,WAAW,EAAE,SAAS,GAAG,MAAM,CAAC,CAAC,CAAC,EAAE,OAAO,EAA0B,EAAW,EAAE,CACnH,CAAC,EACC,MAAM,EACN,OAAO,EACP,QAAQ,EACR,WAAW;AACX,qEAAqE;EACtE,EAAE,EAAE,CACH,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;IAClB,MAAM,OAAO,GAAG,KAAK,CAAC,CAAC,MAAM,CAAC,O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AiB,EAAE,MAAM,EAAE,IAAI;oBAClE,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,aAAa,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC;gBAClD,IAAI,EAAE,CAAC,KAAK,EAAE,EAAE,CACd,aAAa,CAAC,IAAI,CAChB,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,cAAc,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC,EAC7D,EAAE,iBAAiB,EAAE,IAAI,EAAE,CAC5B;aACJ;YACD,YAAY,EAAE,EAAE,UAAU,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,YAAY,CAAC,gBAAgB,EAAE;YAChG,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC;YAC3C,eAAe,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,UAAU,CAAC,MAAM,EAAE,CAAC;YACvD,YAAY,EAAE,aAAa,CAAC,SAAS;YACrC,mBAAmB,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,0BAA0B,CAAC,KAAK,CAAC,OAAO,CAAC;SACnC,CAAA;QAE1C,MAAM,eAAe,GAAG,OAAO,CAAC,MAAM,EAAE,CAAA;QAExC,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,CAAA;IAC1C,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAA;AAChC,CAAC,CAAC,CAAA"}
@@ -1,44 +0,0 @@
1
- import type { Adapter, SyncOptions } from '@livestore/common';
2
- import type { TestingOverrides } from '../leader-shared.js';
3
- import * as WorkerSchema from '../worker-schema.js';
4
- export interface NodeAdapterOptions {
5
- storage: WorkerSchema.StorageType;
6
- /** The default is the hostname of the current machine */
7
- clientId?: string;
8
- /**
9
- * Warning: This adapter doesn't currently support multiple client sessions for the same client (i.e. same storeId + clientId)
10
- * @default 'static'
11
- */
12
- sessionId?: string;
13
- devtools?: {
14
- schemaPath: string;
15
- /**
16
- * Where to run the devtools server (via Vite)
17
- *
18
- * @default 4242
19
- */
20
- port?: number;
21
- /**
22
- * @default 'localhost'
23
- */
24
- host?: string;
25
- };
26
- /** Only used internally for testing */
27
- testing?: {
28
- overrides?: TestingOverrides;
29
- };
30
- }
31
- /** Runs everything in the same thread. Use `makeWorkerAdapter` for multi-threaded implementation. */
32
- export declare const makeAdapter: ({ sync, ...options }: NodeAdapterOptions & {
33
- sync?: SyncOptions;
34
- }) => Adapter;
35
- /**
36
- * Runs persistence and syncing in a worker thread.
37
- */
38
- export declare const makeWorkerAdapter: ({ workerUrl, ...options }: NodeAdapterOptions & {
39
- /**
40
- * Example: `new URL('./livestore.worker.js', import.meta.url)`
41
- */
42
- workerUrl: URL;
43
- }) => Adapter;
44
- //# sourceMappingURL=persisted-adapter.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"persisted-adapter.d.ts","sourceRoot":"","sources":["../../src/client-session/persisted-adapter.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,OAAO,EAOP,WAAW,EACZ,MAAM,mBAAmB,CAAA;AAwB1B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAA;AAG3D,OAAO,KAAK,YAAY,MAAM,qBAAqB,CAAA;AAEnD,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,YAAY,CAAC,WAAW,CAAA;IACjC,yDAAyD;IACzD,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;IAElB,QAAQ,CAAC,EAAE;QACT,UAAU,EAAE,MAAM,CAAA;QAClB;;;;WAIG;QACH,IAAI,CAAC,EAAE,MAAM,CAAA;QACb;;WAEG;QACH,IAAI,CAAC,EAAE,MAAM,CAAA;KACd,CAAA;IAED,uCAAuC;IACvC,OAAO,CAAC,EAAE;QACR,SAAS,CAAC,EAAE,gBAAgB,CAAA;KAC7B,CAAA;CACF;AAED,qGAAqG;AACrG,eAAO,MAAM,WAAW,GAAI,sBAGzB,kBAAkB,GAAG;IACtB,IAAI,CAAC,EAAE,WAAW,CAAA;CACnB,KAAG,OAA2F,CAAA;AAE/F;;GAEG;AACH,eAAO,MAAM,iBAAiB,GAAI,2BAG/B,kBAAkB,GAAG;IACtB;;OAEG;IACH,SAAS,EAAE,GAAG,CAAA;CACf,KAAG,OAA+F,CAAA"}
@@ -1,199 +0,0 @@
1
- import { hostname } from 'node:os';
2
- import * as WT from 'node:worker_threads';
3
- import { Devtools, UnexpectedError } from '@livestore/common';
4
- import { Eventlog, LeaderThreadCtx } from '@livestore/common/leader-thread';
5
- import { LiveStoreEvent } from '@livestore/common/schema';
6
- import * as DevtoolsNode from '@livestore/devtools-node-common/web-channel';
7
- import { loadSqlite3Wasm } from '@livestore/sqlite-wasm/load-wasm';
8
- import { sqliteDbFactory } from '@livestore/sqlite-wasm/node';
9
- import { Cause, Effect, FetchHttpClient, Fiber, Layer, ParseResult, Queue, Schema, Stream, SubscriptionRef, Worker, WorkerError, } from '@livestore/utils/effect';
10
- import { PlatformNode } from '@livestore/utils/node';
11
- import { makeLeaderThread } from '../leader-shared.js';
12
- import { makeShutdownChannel } from '../shutdown-channel.js';
13
- import * as WorkerSchema from '../worker-schema.js';
14
- /** Runs everything in the same thread. Use `makeWorkerAdapter` for multi-threaded implementation. */
15
- export const makeAdapter = ({ sync, ...options }) => makeAdapterImpl({ ...options, leaderThread: { _tag: 'single-threaded', sync } });
16
- /**
17
- * Runs persistence and syncing in a worker thread.
18
- */
19
- export const makeWorkerAdapter = ({ workerUrl, ...options }) => makeAdapterImpl({ ...options, leaderThread: { _tag: 'multi-threaded', workerUrl } });
20
- const makeAdapterImpl = ({ storage, devtools: devtoolsOptionsInput, clientId = hostname(),
21
- // TODO make this dynamic and actually support multiple sessions
22
- sessionId = 'static', testing, leaderThread: leaderThreadInput, }) => (({ storeId, devtoolsEnabled, shutdown, connectDevtoolsToStore, bootStatusQueue, syncPayload, schema }) => Effect.gen(function* () {
23
- yield* Queue.offer(bootStatusQueue, { stage: 'loading' });
24
- const sqlite3 = yield* Effect.promise(() => loadSqlite3Wasm());
25
- const makeSqliteDb = yield* sqliteDbFactory({ sqlite3 });
26
- // TODO consider bringing back happy-path initialisation boost
27
- // const fileData = yield* fs.readFile(dbFilePath).pipe(Effect.either)
28
- // if (fileData._tag === 'Right') {
29
- // syncInMemoryDb.import(fileData.right)
30
- // } else {
31
- // yield* Effect.logWarning('Failed to load database file', fileData.left)
32
- // }
33
- if (leaderThreadInput._tag === 'multi-threaded') {
34
- const shutdownChannel = yield* makeShutdownChannel(storeId);
35
- yield* shutdownChannel.listen.pipe(Stream.flatten(), Stream.tap((error) => Effect.sync(() => shutdown(Cause.fail(error)))), Stream.runDrain, Effect.interruptible, Effect.tapCauseLogPretty, Effect.forkScoped);
36
- }
37
- const syncInMemoryDb = yield* makeSqliteDb({ _tag: 'in-memory' }).pipe(Effect.orDie);
38
- // TODO actually implement this multi-session support
39
- const lockStatus = yield* SubscriptionRef.make('has-lock');
40
- const devtoolsOptions = devtoolsEnabled && devtoolsOptionsInput !== undefined
41
- ? {
42
- enabled: true,
43
- schemaPath: devtoolsOptionsInput.schemaPath,
44
- port: devtoolsOptionsInput.port ?? 4242,
45
- host: devtoolsOptionsInput.host ?? 'localhost',
46
- }
47
- : { enabled: false };
48
- const { leaderThread, initialSnapshot } = leaderThreadInput._tag === 'single-threaded'
49
- ? yield* makeLocalLeaderThread({
50
- storeId,
51
- clientId,
52
- schema,
53
- makeSqliteDb,
54
- syncOptions: leaderThreadInput.sync,
55
- syncPayload,
56
- devtools: devtoolsOptions,
57
- storage,
58
- testing,
59
- }).pipe(UnexpectedError.mapToUnexpectedError)
60
- : yield* makeWorkerLeaderThread({
61
- shutdown,
62
- storeId,
63
- clientId,
64
- sessionId,
65
- workerUrl: leaderThreadInput.workerUrl,
66
- storage,
67
- devtools: devtoolsOptions,
68
- bootStatusQueue,
69
- syncPayload,
70
- });
71
- syncInMemoryDb.import(initialSnapshot);
72
- if (devtoolsOptions.enabled) {
73
- yield* Effect.gen(function* () {
74
- const webmeshNode = yield* DevtoolsNode.makeNodeDevtoolsConnectedMeshNode({
75
- url: `ws://${devtoolsOptions.host}:${devtoolsOptions.port}`,
76
- nodeName: `client-session-${storeId}-${clientId}-${sessionId}`,
77
- });
78
- const sessionsChannel = yield* webmeshNode.makeBroadcastChannel({
79
- channelName: 'session-info',
80
- schema: Devtools.SessionInfo.Message,
81
- });
82
- yield* Devtools.SessionInfo.provideSessionInfo({
83
- webChannel: sessionsChannel,
84
- sessionInfo: Devtools.SessionInfo.SessionInfo.make({ storeId, clientId, sessionId }),
85
- }).pipe(Effect.tapCauseLogPretty, Effect.forkScoped);
86
- const storeDevtoolsChannel = yield* DevtoolsNode.makeChannelForConnectedMeshNode({
87
- node: webmeshNode,
88
- target: `devtools-${storeId}-${clientId}-${sessionId}`,
89
- schema: { listen: Devtools.ClientSession.MessageToApp, send: Devtools.ClientSession.MessageFromApp },
90
- });
91
- yield* connectDevtoolsToStore(storeDevtoolsChannel);
92
- }).pipe(Effect.tapCauseLogPretty, Effect.forkScoped);
93
- }
94
- const devtools = devtoolsEnabled
95
- ? { enabled: true, pullLatch: yield* Effect.makeLatch(true), pushLatch: yield* Effect.makeLatch(true) }
96
- : { enabled: false };
97
- const clientSession = {
98
- sqliteDb: syncInMemoryDb,
99
- leaderThread,
100
- devtools,
101
- lockStatus,
102
- clientId,
103
- sessionId,
104
- shutdown,
105
- };
106
- return clientSession;
107
- }).pipe(Effect.withSpan('@livestore/adapter-node:adapter'), Effect.parallelFinalizers, Effect.provide(PlatformNode.NodeFileSystem.layer), Effect.provide(FetchHttpClient.layer)));
108
- const makeLocalLeaderThread = ({ storeId, clientId, schema, makeSqliteDb, syncOptions, syncPayload, storage, devtools, testing, }) => Effect.gen(function* () {
109
- const layer = yield* Layer.build(makeLeaderThread({
110
- storeId,
111
- clientId,
112
- schema,
113
- syncOptions,
114
- storage,
115
- syncPayload,
116
- devtools,
117
- makeSqliteDb,
118
- testing: testing?.overrides,
119
- }).pipe(Layer.unwrapScoped));
120
- return yield* Effect.gen(function* () {
121
- const { dbState, dbEventlog, syncProcessor, extraIncomingMessagesQueue, initialState } = yield* LeaderThreadCtx;
122
- const initialLeaderHead = Eventlog.getClientHeadFromDb(dbEventlog);
123
- const leaderThread = {
124
- events: {
125
- pull: testing?.overrides?.clientSession?.leaderThreadProxy?.events?.pull ??
126
- (({ cursor }) => syncProcessor.pull({ cursor })),
127
- push: (batch) => syncProcessor.push(batch.map((item) => new LiveStoreEvent.EncodedWithMeta(item)), { waitForProcessing: true }),
128
- },
129
- initialState: { leaderHead: initialLeaderHead, migrationsReport: initialState.migrationsReport },
130
- export: Effect.sync(() => dbState.export()),
131
- getEventlogData: Effect.sync(() => dbEventlog.export()),
132
- getSyncState: syncProcessor.syncState,
133
- sendDevtoolsMessage: (message) => extraIncomingMessagesQueue.offer(message),
134
- };
135
- const initialSnapshot = dbState.export();
136
- return { leaderThread, initialSnapshot };
137
- }).pipe(Effect.provide(layer));
138
- });
139
- const makeWorkerLeaderThread = ({ shutdown, storeId, clientId, sessionId, workerUrl, storage, devtools, bootStatusQueue, syncPayload, testing, }) => Effect.gen(function* () {
140
- const nodeWorker = new WT.Worker(workerUrl, {
141
- execArgv: process.env.DEBUG_WORKER ? ['--inspect --enable-source-maps'] : ['--enable-source-maps'],
142
- argv: [Schema.encodeSync(WorkerSchema.WorkerArgv)({ storeId, clientId, sessionId })],
143
- });
144
- const nodeWorkerLayer = yield* Layer.build(PlatformNode.NodeWorker.layer(() => nodeWorker));
145
- const worker = yield* Worker.makePoolSerialized({
146
- size: 1,
147
- concurrency: 100,
148
- initialMessage: () => new WorkerSchema.LeaderWorkerInner.InitialMessage({
149
- storeId,
150
- clientId,
151
- storage,
152
- devtools,
153
- syncPayload,
154
- }),
155
- }).pipe(Effect.provide(nodeWorkerLayer), UnexpectedError.mapToUnexpectedError, Effect.tapErrorCause((cause) => Effect.sync(() => shutdown(cause))), Effect.withSpan('@livestore/adapter-node:adapter:setupLeaderThread'));
156
- yield* Effect.addFinalizer(() => Effect.gen(function* () {
157
- // We first try to gracefully shutdown the leader worker and then forcefully terminate it
158
- yield* Effect.raceFirst(runInWorker(new WorkerSchema.LeaderWorkerInner.Shutdown()).pipe(Effect.andThen(() => nodeWorker.terminate())), Effect.sync(() => {
159
- console.warn('[@livestore/adapter-node:adapter] Worker did not gracefully shutdown in time, terminating it');
160
- nodeWorker.terminate();
161
- }).pipe(Effect.delay(1000))).pipe(Effect.exit); // The disconnect is to prevent the interrupt to bubble out
162
- }).pipe(Effect.withSpan('@livestore/adapter-node:adapter:shutdown'), Effect.tapCauseLogPretty, Effect.orDie));
163
- const runInWorker = (req) => worker.executeEffect(req).pipe(Effect.logWarnIfTakesLongerThan({
164
- label: `@livestore/adapter-node:client-session:runInWorker:${req._tag}`,
165
- duration: 2000,
166
- }), Effect.withSpan(`@livestore/adapter-node:client-session:runInWorker:${req._tag}`), Effect.mapError((cause) => Schema.is(UnexpectedError)(cause)
167
- ? cause
168
- : ParseResult.isParseError(cause) || Schema.is(WorkerError.WorkerError)(cause)
169
- ? new UnexpectedError({ cause })
170
- : cause), Effect.catchAllDefect((cause) => new UnexpectedError({ cause })));
171
- const runInWorkerStream = (req) => worker.execute(req).pipe(Stream.mapError((cause) => Schema.is(UnexpectedError)(cause)
172
- ? cause
173
- : ParseResult.isParseError(cause) || Schema.is(WorkerError.WorkerError)(cause)
174
- ? new UnexpectedError({ cause })
175
- : cause), Stream.withSpan(`@livestore/adapter-node:client-session:runInWorkerStream:${req._tag}`));
176
- const bootStatusFiber = yield* runInWorkerStream(new WorkerSchema.LeaderWorkerInner.BootStatusStream()).pipe(Stream.tap((bootStatus) => Queue.offer(bootStatusQueue, bootStatus)), Stream.runDrain, Effect.tapErrorCause((cause) => Cause.isInterruptedOnly(cause) ? Effect.void : Effect.sync(() => shutdown(cause))), Effect.interruptible, Effect.tapCauseLogPretty, Effect.forkScoped);
177
- yield* Queue.awaitShutdown(bootStatusQueue).pipe(Effect.andThen(Fiber.interrupt(bootStatusFiber)), Effect.tapCauseLogPretty, Effect.forkScoped);
178
- const initialLeaderHead = yield* runInWorker(new WorkerSchema.LeaderWorkerInner.GetLeaderHead());
179
- const bootResult = yield* runInWorker(new WorkerSchema.LeaderWorkerInner.GetRecreateSnapshot()).pipe(Effect.timeout(10_000), UnexpectedError.mapToUnexpectedError, Effect.withSpan('@livestore/adapter-node:client-session:export'));
180
- const leaderThread = {
181
- events: {
182
- pull: testing?.overrides?.clientSession?.leaderThreadProxy?.events?.pull ??
183
- (({ cursor }) => runInWorkerStream(new WorkerSchema.LeaderWorkerInner.PullStream({ cursor })).pipe(Stream.orDie)),
184
- push: (batch) => runInWorker(new WorkerSchema.LeaderWorkerInner.PushToLeader({ batch })).pipe(Effect.withSpan('@livestore/adapter-node:client-session:pushToLeader', {
185
- attributes: { batchSize: batch.length },
186
- })),
187
- },
188
- initialState: {
189
- leaderHead: initialLeaderHead,
190
- migrationsReport: bootResult.migrationsReport,
191
- },
192
- export: runInWorker(new WorkerSchema.LeaderWorkerInner.Export()).pipe(Effect.timeout(10_000), UnexpectedError.mapToUnexpectedError, Effect.withSpan('@livestore/adapter-node:client-session:export')),
193
- getEventlogData: Effect.dieMessage('Not implemented'),
194
- getSyncState: runInWorker(new WorkerSchema.LeaderWorkerInner.GetLeaderSyncState()).pipe(UnexpectedError.mapToUnexpectedError, Effect.withSpan('@livestore/adapter-node:client-session:getLeaderSyncState')),
195
- sendDevtoolsMessage: (message) => runInWorker(new WorkerSchema.LeaderWorkerInner.ExtraDevtoolsMessage({ message })).pipe(UnexpectedError.mapToUnexpectedError, Effect.withSpan('@livestore/adapter-node:client-session:devtoolsMessageForLeader')),
196
- };
197
- return { leaderThread, initialSnapshot: bootResult.snapshot };
198
- });
199
- //# sourceMappingURL=persisted-adapter.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"persisted-adapter.js","sourceRoot":"","sources":["../../src/client-session/persisted-adapter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AAClC,OAAO,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAYzC,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AAC7D,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAA;AAE3E,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAA;AACzD,OAAO,KAAK,YAAY,MAAM,6CAA6C,CAAA;AAC3E,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAA;AAClE,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAA;AAC7D,OAAO,EACL,KAAK,EACL,MAAM,EACN,eAAe,EACf,KAAK,EACL,KAAK,EACL,WAAW,EACX,KAAK,EACL,MAAM,EACN,MAAM,EACN,eAAe,EACf,MAAM,EACN,WAAW,GACZ,MAAM,yBAAyB,CAAA;AAChC,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAA;AAGpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAA;AACtD,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAA;AAC5D,OAAO,KAAK,YAAY,MAAM,qBAAqB,CAAA;AAgCnD,qGAAqG;AACrG,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,EAC1B,IAAI,EACJ,GAAG,OAAO,EAGX,EAAW,EAAE,CAAC,eAAe,CAAC,EAAE,GAAG,OAAO,EAAE,YAAY,EAAE,EAAE,IAAI,EAAE,iBAAiB,EAAE,IAAI,EAAE,EAAE,CAAC,CAAA;AAE/F;;GAEG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,EAChC,SAAS,EACT,GAAG,OAAO,EAMX,EAAW,EAAE,C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