@livestore/adapter-web 0.0.0-snapshot-12c4570d047bcfaefc85bc6243c1b61f57580913 → 0.0.0-snapshot-b12fe44662a4a2f917d402ea2562edb3c404f26a
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/web-worker/client-session/client-session-devtools.d.ts +1 -1
- package/dist/web-worker/client-session/client-session-devtools.d.ts.map +1 -1
- package/dist/web-worker/client-session/client-session-devtools.js +7 -97
- package/dist/web-worker/client-session/client-session-devtools.js.map +1 -1
- package/dist/web-worker/client-session/index.d.ts +10 -0
- package/dist/web-worker/client-session/index.d.ts.map +1 -1
- package/dist/web-worker/client-session/index.js +51 -17
- package/dist/web-worker/client-session/index.js.map +1 -1
- package/dist/web-worker/common/worker-schema.d.ts.map +1 -1
- package/package.json +6 -13
- package/src/web-worker/client-session/client-session-devtools.ts +8 -155
- package/src/web-worker/client-session/index.ts +79 -16
- package/dist/devtools-bridge/background-browser-channel.d.ts +0 -9
- package/dist/devtools-bridge/background-browser-channel.d.ts.map +0 -1
- package/dist/devtools-bridge/background-browser-channel.js +0 -31
- package/dist/devtools-bridge/background-browser-channel.js.map +0 -1
- package/dist/devtools-bridge/background-message.d.ts +0 -93
- package/dist/devtools-bridge/background-message.d.ts.map +0 -1
- package/dist/devtools-bridge/background-message.js +0 -53
- package/dist/devtools-bridge/background-message.js.map +0 -1
- package/dist/devtools-bridge/bridge-shared.d.ts +0 -14
- package/dist/devtools-bridge/bridge-shared.d.ts.map +0 -1
- package/dist/devtools-bridge/bridge-shared.js +0 -67
- package/dist/devtools-bridge/bridge-shared.js.map +0 -1
- package/dist/devtools-bridge/browser-extension-bridge.d.ts +0 -3
- package/dist/devtools-bridge/browser-extension-bridge.d.ts.map +0 -1
- package/dist/devtools-bridge/browser-extension-bridge.js +0 -59
- package/dist/devtools-bridge/browser-extension-bridge.js.map +0 -1
- package/dist/devtools-bridge/iframe-message.d.ts +0 -16
- package/dist/devtools-bridge/iframe-message.d.ts.map +0 -1
- package/dist/devtools-bridge/iframe-message.js +0 -11
- package/dist/devtools-bridge/iframe-message.js.map +0 -1
- package/dist/devtools-bridge/index.d.ts +0 -6
- package/dist/devtools-bridge/index.d.ts.map +0 -1
- package/dist/devtools-bridge/index.js +0 -5
- package/dist/devtools-bridge/index.js.map +0 -1
- package/dist/devtools-bridge/web-bridge.d.ts +0 -31
- package/dist/devtools-bridge/web-bridge.d.ts.map +0 -1
- package/dist/devtools-bridge/web-bridge.js +0 -131
- package/dist/devtools-bridge/web-bridge.js.map +0 -1
- package/src/devtools-bridge/background-browser-channel.ts +0 -57
- package/src/devtools-bridge/background-message.ts +0 -42
- package/src/devtools-bridge/bridge-shared.ts +0 -97
- package/src/devtools-bridge/browser-extension-bridge.ts +0 -64
- package/src/devtools-bridge/iframe-message.ts +0 -9
- package/src/devtools-bridge/index.ts +0 -9
- package/src/devtools-bridge/web-bridge.ts +0 -169
|
@@ -4,7 +4,12 @@ import { Devtools, IntentionalShutdownCause, StoreInterrupted, UnexpectedError }
|
|
|
4
4
|
// NOTE We're using a non-relative import here for Vite to properly resolve the import during app builds
|
|
5
5
|
// import LiveStoreSharedWorker from '@livestore/adapter-web/internal-shared-worker?sharedworker'
|
|
6
6
|
import { EventId, SESSION_CHANGESET_META_TABLE } from '@livestore/common/schema'
|
|
7
|
-
import {
|
|
7
|
+
import {
|
|
8
|
+
ClientSessionRequestContentscriptMain,
|
|
9
|
+
connectViaWorker,
|
|
10
|
+
makeChannelForConnectedMeshNode,
|
|
11
|
+
makeSessionsChannel,
|
|
12
|
+
} from '@livestore/devtools-web-common/web-channel'
|
|
8
13
|
import { sqliteDbFactory } from '@livestore/sqlite-wasm/browser'
|
|
9
14
|
import { loadSqlite3Wasm } from '@livestore/sqlite-wasm/load-wasm'
|
|
10
15
|
import { isDevEnv, shouldNeverHappen, tryAsFunctionAndNew } from '@livestore/utils'
|
|
@@ -20,18 +25,20 @@ import {
|
|
|
20
25
|
Schema,
|
|
21
26
|
Stream,
|
|
22
27
|
SubscriptionRef,
|
|
28
|
+
WebChannel,
|
|
23
29
|
WebLock,
|
|
24
30
|
Worker,
|
|
25
31
|
WorkerError,
|
|
26
32
|
} from '@livestore/utils/effect'
|
|
27
33
|
import { nanoid } from '@livestore/utils/nanoid'
|
|
34
|
+
import * as Webmesh from '@livestore/webmesh'
|
|
28
35
|
|
|
29
36
|
import * as OpfsUtils from '../../opfs-utils.js'
|
|
30
37
|
import { readPersistedAppDbFromClientSession, resetPersistedDataFromClientSession } from '../common/persisted-sqlite.js'
|
|
31
38
|
import { makeShutdownChannel } from '../common/shutdown-channel.js'
|
|
32
39
|
import { DedicatedWorkerDisconnectBroadcast, makeWorkerDisconnectChannel } from '../common/worker-disconnect-channel.js'
|
|
33
40
|
import * as WorkerSchema from '../common/worker-schema.js'
|
|
34
|
-
import {
|
|
41
|
+
import { logDevtoolsUrl } from './client-session-devtools.js'
|
|
35
42
|
|
|
36
43
|
// NOTE we're starting to initialize the sqlite wasm binary here to speed things up
|
|
37
44
|
const sqlite3Promise = loadSqlite3Wasm()
|
|
@@ -74,6 +81,16 @@ export type WebAdapterOptions = {
|
|
|
74
81
|
* @default false
|
|
75
82
|
*/
|
|
76
83
|
resetPersistence?: boolean
|
|
84
|
+
/**
|
|
85
|
+
* By default the adapter will initially generate a random clientId (via `nanoid(5)`),
|
|
86
|
+
* store it in `localStorage` and restore it for subsequent client sessions. It's the same across all tabs/windows.
|
|
87
|
+
*/
|
|
88
|
+
clientId?: string
|
|
89
|
+
/**
|
|
90
|
+
* By default the adapter will initially generate a random sessionId (via `nanoid(5)`),
|
|
91
|
+
* store it in `sessionStorage` and restore it for subsequent client sessions in the same tab/window.
|
|
92
|
+
*/
|
|
93
|
+
sessionId?: string
|
|
77
94
|
}
|
|
78
95
|
|
|
79
96
|
export const makeAdapter =
|
|
@@ -103,9 +120,9 @@ export const makeAdapter =
|
|
|
103
120
|
const dataFromFile = yield* readPersistedAppDbFromClientSession({ storageOptions, storeId, schema })
|
|
104
121
|
|
|
105
122
|
// The same across all client sessions (i.e. tabs, windows)
|
|
106
|
-
const clientId = getPersistedId(`clientId:${storeId}`, 'local')
|
|
123
|
+
const clientId = options.clientId ?? getPersistedId(`clientId:${storeId}`, 'local')
|
|
107
124
|
// Unique per client session (i.e. tab, window)
|
|
108
|
-
const sessionId = getPersistedId(`sessionId:${storeId}`, 'session')
|
|
125
|
+
const sessionId = options.sessionId ?? getPersistedId(`sessionId:${storeId}`, 'session')
|
|
109
126
|
|
|
110
127
|
const shutdownChannel = yield* makeShutdownChannel(storeId)
|
|
111
128
|
const workerDisconnectChannel = yield* makeWorkerDisconnectChannel(storeId)
|
|
@@ -163,7 +180,7 @@ export const makeAdapter =
|
|
|
163
180
|
|
|
164
181
|
const runLocked = Effect.gen(function* () {
|
|
165
182
|
yield* Effect.logDebug(
|
|
166
|
-
`[@livestore/adapter-web:client-session] ✅ Got lock '${LIVESTORE_TAB_LOCK}' (sessionId: ${sessionId})`,
|
|
183
|
+
`[@livestore/adapter-web:client-session] ✅ Got lock '${LIVESTORE_TAB_LOCK}' (clientId: ${clientId}, sessionId: ${sessionId})`,
|
|
167
184
|
)
|
|
168
185
|
|
|
169
186
|
yield* Effect.addFinalizer(() =>
|
|
@@ -445,22 +462,68 @@ export const makeAdapter =
|
|
|
445
462
|
} satisfies ClientSession
|
|
446
463
|
|
|
447
464
|
if (devtoolsEnabled) {
|
|
448
|
-
// yield* bootDevtools({ client-session, waitForDevtoolsWebBridgePort, connectToDevtools, storeId })
|
|
449
465
|
yield* Effect.gen(function* () {
|
|
450
466
|
const sharedWorker = yield* Fiber.join(sharedWorkerFiber)
|
|
451
467
|
|
|
452
|
-
yield*
|
|
468
|
+
const webmeshNode = yield* Webmesh.makeMeshNode(`client-session-${storeId}-${clientId}-${sessionId}`)
|
|
469
|
+
globalThis.__debugWebmeshNode = webmeshNode
|
|
470
|
+
|
|
471
|
+
yield* logDevtoolsUrl({ clientSession, storeId })
|
|
472
|
+
|
|
473
|
+
const sessionsChannel = yield* makeSessionsChannel
|
|
474
|
+
const sessionInfoMessage = Devtools.SessionInfo.SessionInfo.make({ storeId, clientId, sessionId })
|
|
475
|
+
|
|
476
|
+
yield* Devtools.SessionInfo.provideSessionInfo({
|
|
477
|
+
webChannel: sessionsChannel,
|
|
478
|
+
sessionInfo: sessionInfoMessage,
|
|
479
|
+
}).pipe(Effect.tapCauseLogPretty, Effect.forkScoped)
|
|
480
|
+
|
|
481
|
+
yield* Effect.gen(function* () {
|
|
482
|
+
const clientSessionStaticChannel = yield* WebChannel.windowChannel2({
|
|
483
|
+
listenWindow: window,
|
|
484
|
+
sendWindow: window,
|
|
485
|
+
schema: { listen: Schema.Void, send: ClientSessionRequestContentscriptMain },
|
|
486
|
+
ids: { own: 'client-session-static', other: 'contentscript-main-static' },
|
|
487
|
+
})
|
|
453
488
|
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
489
|
+
yield* clientSessionStaticChannel.send(
|
|
490
|
+
ClientSessionRequestContentscriptMain.make({ clientId, sessionId, storeId }),
|
|
491
|
+
)
|
|
492
|
+
|
|
493
|
+
const contentscriptMainNodeName = `contentscript-main-${storeId}-${clientId}-${sessionId}`
|
|
494
|
+
|
|
495
|
+
const contentscriptMainChannel = yield* WebChannel.windowChannel2({
|
|
496
|
+
listenWindow: window,
|
|
497
|
+
sendWindow: window,
|
|
498
|
+
schema: Webmesh.WebmeshSchema.Packet,
|
|
499
|
+
ids: { own: webmeshNode.nodeName, other: contentscriptMainNodeName },
|
|
500
|
+
})
|
|
501
|
+
|
|
502
|
+
yield* webmeshNode.addConnection({
|
|
503
|
+
target: contentscriptMainNodeName,
|
|
504
|
+
connectionChannel: contentscriptMainChannel,
|
|
505
|
+
})
|
|
506
|
+
// yield* Effect.logDebug(
|
|
507
|
+
// `[@livestore/adapter-web:client-session] initiated connection: ${webmeshNode.nodeName} → contentscript-main`,
|
|
508
|
+
// )
|
|
509
|
+
|
|
510
|
+
const extensionWorkerChannel = yield* webmeshNode.makeBroadcastChannel({
|
|
511
|
+
channelName: 'session-info',
|
|
512
|
+
schema: Devtools.SessionInfo.Message,
|
|
513
|
+
})
|
|
514
|
+
|
|
515
|
+
yield* Devtools.SessionInfo.provideSessionInfo({
|
|
516
|
+
webChannel: extensionWorkerChannel,
|
|
517
|
+
sessionInfo: sessionInfoMessage,
|
|
518
|
+
})
|
|
519
|
+
}).pipe(Effect.tapCauseLogPretty, Effect.forkScoped)
|
|
520
|
+
|
|
521
|
+
yield* connectViaWorker({ node: webmeshNode, target: 'shared-worker', worker: sharedWorker })
|
|
522
|
+
|
|
523
|
+
const storeDevtoolsChannel = yield* makeChannelForConnectedMeshNode({
|
|
524
|
+
node: webmeshNode,
|
|
457
525
|
target: `devtools`,
|
|
458
|
-
schema: {
|
|
459
|
-
listen: Devtools.ClientSession.MessageToApp,
|
|
460
|
-
send: Devtools.ClientSession.MessageFromApp,
|
|
461
|
-
},
|
|
462
|
-
worker: sharedWorker,
|
|
463
|
-
workerTargetName: 'shared-worker',
|
|
526
|
+
schema: { listen: Devtools.ClientSession.MessageToApp, send: Devtools.ClientSession.MessageFromApp },
|
|
464
527
|
})
|
|
465
528
|
|
|
466
529
|
yield* connectDevtoolsToStore(storeDevtoolsChannel)
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { Effect, Schema, Scope, WebChannel } from '@livestore/utils/effect';
|
|
2
|
-
export declare const backgroundChannel: <MsgIn, MsgOut, MsgInEncoded, MsgOutEncoded>({ schema: inputSchema, port, }: {
|
|
3
|
-
schema: Schema.Schema<MsgIn | MsgOut, MsgInEncoded | MsgOutEncoded> | {
|
|
4
|
-
listen: Schema.Schema<MsgIn, MsgInEncoded>;
|
|
5
|
-
send: Schema.Schema<MsgOut, MsgOutEncoded>;
|
|
6
|
-
};
|
|
7
|
-
port: chrome.runtime.Port;
|
|
8
|
-
}) => Effect.Effect<WebChannel.WebChannel<MsgIn, MsgOut>, never, Scope.Scope>;
|
|
9
|
-
//# sourceMappingURL=background-browser-channel.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"background-browser-channel.d.ts","sourceRoot":"","sources":["../../src/devtools-bridge/background-browser-channel.ts"],"names":[],"mappings":"AACA,OAAO,EAAmB,MAAM,EAAiB,MAAM,EAAE,KAAK,EAAU,UAAU,EAAE,MAAM,yBAAyB,CAAA;AAEnH,eAAO,MAAM,iBAAiB,GAAI,KAAK,EAAE,MAAM,EAAE,YAAY,EAAE,aAAa,EAAE,gCAG3E;IACD,MAAM,EACF,MAAM,CAAC,MAAM,CAAC,KAAK,GAAG,MAAM,EAAE,YAAY,GAAG,aAAa,CAAC,GAC3D;QAAE,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,YAAY,CAAC,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAA;KAAE,CAAA;IAC9F,IAAI,EAAE,MAAM,CAAC,OAAO,CAAC,IAAI,CAAA;CAC1B,KAAG,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,UAAU,CAAC,KAAK,EAAE,MAAM,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,CA6CvE,CAAA"}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { Chunk, Deferred, Effect, Exit, Runtime, Schema, Scope, Stream, WebChannel } from '@livestore/utils/effect';
|
|
2
|
-
export const backgroundChannel = ({ schema: inputSchema, port, }) => Effect.scopeWithCloseable((scope) => Effect.gen(function* () {
|
|
3
|
-
const schema = WebChannel.mapSchema(inputSchema);
|
|
4
|
-
const send = (msg) => Effect.gen(function* () {
|
|
5
|
-
const encoded = yield* Schema.encode(schema.send)(msg);
|
|
6
|
-
port.postMessage(encoded);
|
|
7
|
-
});
|
|
8
|
-
const runtime = yield* Effect.runtime();
|
|
9
|
-
const listen = Stream.async((emit) => {
|
|
10
|
-
const onMessage = (message) => Effect.gen(function* () {
|
|
11
|
-
const result = yield* Schema.decode(schema.listen)(message).pipe(Effect.either);
|
|
12
|
-
emit(Effect.succeed(Chunk.make(result)));
|
|
13
|
-
}).pipe(Effect.withSpan(`WebChannel:backgroundChannel:listen`), Effect.tapCauseLogPretty, Runtime.runFork(runtime));
|
|
14
|
-
port.onMessage.addListener(onMessage);
|
|
15
|
-
return Effect.sync(() => {
|
|
16
|
-
port.onMessage.removeListener(onMessage);
|
|
17
|
-
});
|
|
18
|
-
});
|
|
19
|
-
const closedDeferred = yield* Deferred.make().pipe(Effect.acquireRelease(Deferred.done(Exit.void)));
|
|
20
|
-
const supportsTransferables = false;
|
|
21
|
-
return {
|
|
22
|
-
[WebChannel.WebChannelSymbol]: WebChannel.WebChannelSymbol,
|
|
23
|
-
listen,
|
|
24
|
-
send,
|
|
25
|
-
closedDeferred,
|
|
26
|
-
schema,
|
|
27
|
-
supportsTransferables,
|
|
28
|
-
shutdown: Scope.close(scope, Exit.void),
|
|
29
|
-
};
|
|
30
|
-
}).pipe(Effect.withSpan(`WebChannel:backgroundChannel`)));
|
|
31
|
-
//# sourceMappingURL=background-browser-channel.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"background-browser-channel.js","sourceRoot":"","sources":["../../src/devtools-bridge/background-browser-channel.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAA;AAEnH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAA6C,EAC5E,MAAM,EAAE,WAAW,EACnB,IAAI,GAML,EAA2E,EAAE,CAC5E,MAAM,CAAC,kBAAkB,CAAC,CAAC,KAAK,EAAE,EAAE,CAClC,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;IAClB,MAAM,MAAM,GAAG,UAAU,CAAC,SAAS,CAAC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AQ,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,MAAM;QACN,IAAI;QACJ,cAAc;QACd,MAAM;QACN,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,8BAA8B,CAAC,CAAC,CACzD,CAAA"}
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
import { Devtools } from '@livestore/common';
|
|
2
|
-
import { Schema } from '@livestore/utils/effect';
|
|
3
|
-
export declare namespace BackgroundMessage {
|
|
4
|
-
const CopyToClipboard_base: Schema.TaggedStruct<"Background.CopyToClipboard", {
|
|
5
|
-
text: typeof Schema.String;
|
|
6
|
-
}>;
|
|
7
|
-
export class CopyToClipboard extends CopyToClipboard_base {
|
|
8
|
-
}
|
|
9
|
-
const MessageFromAppHost_base: Schema.TaggedStruct<"Background.MessageFromAppHost", {
|
|
10
|
-
msg: Schema.Union<[typeof Devtools.Leader.SnapshotRes, Schema.TaggedStruct<"LSD.Leader.LoadDatabaseFile.Response.Success", {
|
|
11
|
-
readonly requestId: typeof Schema.String;
|
|
12
|
-
readonly liveStoreVersion: typeof import("@livestore/common/dist/devtools/devtools-messages-common.js").liveStoreVersion;
|
|
13
|
-
readonly clientId: typeof Schema.String;
|
|
14
|
-
}> | Schema.TaggedStruct<"LSD.Leader.LoadDatabaseFile.Response.Error", {
|
|
15
|
-
cause: Schema.Union<[Schema.TaggedStruct<"unsupported-file", {}>, Schema.TaggedStruct<"unsupported-database", {}>, Schema.TaggedStruct<"unexpected-error", {
|
|
16
|
-
cause: typeof Schema.Defect;
|
|
17
|
-
}>]>;
|
|
18
|
-
} & {
|
|
19
|
-
readonly requestId: typeof Schema.String;
|
|
20
|
-
readonly liveStoreVersion: typeof import("@livestore/common/dist/devtools/devtools-messages-common.js").liveStoreVersion;
|
|
21
|
-
readonly clientId: typeof Schema.String;
|
|
22
|
-
}>, typeof Devtools.Leader.MutationLogRes, typeof Devtools.Leader.Disconnect, typeof Devtools.Leader.SyncPull, typeof Devtools.Leader.NetworkStatusRes, typeof Devtools.Leader.RunMutationRes, typeof Devtools.Leader.Pong, typeof Devtools.Leader.DatabaseFileInfoRes, typeof Devtools.Leader.SyncHistoryRes, typeof Devtools.Leader.SyncingInfoRes, typeof Devtools.Leader.SyncHeadRes, Schema.TaggedStruct<"LSD.Leader.ResetAllData.Response.Success", {
|
|
23
|
-
readonly requestId: typeof Schema.String;
|
|
24
|
-
readonly liveStoreVersion: typeof import("@livestore/common/dist/devtools/devtools-messages-common.js").liveStoreVersion;
|
|
25
|
-
readonly clientId: typeof Schema.String;
|
|
26
|
-
}>, Schema.TaggedStruct<"LSD.Leader.SetSyncLatch.Response.Success", {
|
|
27
|
-
readonly requestId: typeof Schema.String;
|
|
28
|
-
readonly liveStoreVersion: typeof import("@livestore/common/dist/devtools/devtools-messages-common.js").liveStoreVersion;
|
|
29
|
-
readonly clientId: typeof Schema.String;
|
|
30
|
-
}>]>;
|
|
31
|
-
}>;
|
|
32
|
-
export class MessageFromAppHost extends MessageFromAppHost_base {
|
|
33
|
-
}
|
|
34
|
-
const MessageToAppHost_base: Schema.TaggedStruct<"Background.MessageToAppHost", {
|
|
35
|
-
msg: Schema.Union<[typeof Devtools.Leader.SnapshotReq, Schema.TaggedStruct<"LSD.Leader.LoadDatabaseFile.Request", {
|
|
36
|
-
data: Schema.Schema<Uint8Array<ArrayBufferLike>, Uint8Array<ArrayBufferLike>, never>;
|
|
37
|
-
} & {
|
|
38
|
-
readonly requestId: typeof Schema.String;
|
|
39
|
-
readonly liveStoreVersion: typeof import("@livestore/common/dist/devtools/devtools-messages-common.js").liveStoreVersion;
|
|
40
|
-
readonly clientId: typeof Schema.String;
|
|
41
|
-
}>, typeof Devtools.Leader.MutationLogReq, Schema.TaggedStruct<"LSD.Leader.ResetAllData.Request", {
|
|
42
|
-
mode: Schema.Literal<["all-data", "only-app-db"]>;
|
|
43
|
-
} & {
|
|
44
|
-
readonly requestId: typeof Schema.String;
|
|
45
|
-
readonly liveStoreVersion: typeof import("@livestore/common/dist/devtools/devtools-messages-common.js").liveStoreVersion;
|
|
46
|
-
readonly clientId: typeof Schema.String;
|
|
47
|
-
}>, typeof Devtools.Leader.NetworkStatusSubscribe, typeof Devtools.Leader.NetworkStatusUnsubscribe, typeof Devtools.Leader.Disconnect, typeof Devtools.Leader.RunMutationReq, typeof Devtools.Leader.Ping, typeof Devtools.Leader.DatabaseFileInfoReq, typeof Devtools.Leader.SyncHistorySubscribe, typeof Devtools.Leader.SyncHistoryUnsubscribe, typeof Devtools.Leader.SyncingInfoReq, typeof Devtools.Leader.SyncHeadSubscribe, typeof Devtools.Leader.SyncHeadUnsubscribe, Schema.TaggedStruct<"LSD.Leader.SetSyncLatch.Request", {
|
|
48
|
-
closeLatch: typeof Schema.Boolean;
|
|
49
|
-
} & {
|
|
50
|
-
readonly requestId: typeof Schema.String;
|
|
51
|
-
readonly liveStoreVersion: typeof import("@livestore/common/dist/devtools/devtools-messages-common.js").liveStoreVersion;
|
|
52
|
-
readonly clientId: typeof Schema.String;
|
|
53
|
-
}>]>;
|
|
54
|
-
}>;
|
|
55
|
-
export class MessageToAppHost extends MessageToAppHost_base {
|
|
56
|
-
}
|
|
57
|
-
const RequestPortForDevtools_base: Schema.TaggedStruct<"Background.RequestPortForDevtools", {
|
|
58
|
-
tabId: typeof Schema.Number;
|
|
59
|
-
}>;
|
|
60
|
-
export class RequestPortForDevtools extends RequestPortForDevtools_base {
|
|
61
|
-
}
|
|
62
|
-
const RequestOneTimePortFromDevtools_base: Schema.TaggedStruct<"Background.RequestOneTimePortFromDevtools", {
|
|
63
|
-
tabId: typeof Schema.Number;
|
|
64
|
-
}>;
|
|
65
|
-
export class RequestOneTimePortFromDevtools extends RequestOneTimePortFromDevtools_base {
|
|
66
|
-
}
|
|
67
|
-
const Disconnect_base: Schema.TaggedStruct<"Background.Disconnect", {
|
|
68
|
-
appHostId: typeof Schema.String;
|
|
69
|
-
}>;
|
|
70
|
-
export class Disconnect extends Disconnect_base {
|
|
71
|
-
}
|
|
72
|
-
export {};
|
|
73
|
-
}
|
|
74
|
-
export declare namespace MessagePortInit {
|
|
75
|
-
const PortForDevtools_base: Schema.TaggedStruct<"MessagePortInit.PortForDevtools", {
|
|
76
|
-
port: Schema.Schema<MessagePort, MessagePort, never>;
|
|
77
|
-
tabId: typeof Schema.Number;
|
|
78
|
-
appHostId: typeof Schema.String;
|
|
79
|
-
}>;
|
|
80
|
-
/**
|
|
81
|
-
* Message is first sent from contentscript-iframe to background and then posted to the devtools.
|
|
82
|
-
*/
|
|
83
|
-
export class PortForDevtools extends PortForDevtools_base {
|
|
84
|
-
}
|
|
85
|
-
const OneTimePortFromDevtools_base: Schema.TaggedStruct<"MessagePortInit.OneTimePortFromDevtools", {
|
|
86
|
-
port: Schema.Schema<MessagePort, MessagePort, never>;
|
|
87
|
-
tabId: typeof Schema.Number;
|
|
88
|
-
}>;
|
|
89
|
-
export class OneTimePortFromDevtools extends OneTimePortFromDevtools_base {
|
|
90
|
-
}
|
|
91
|
-
export {};
|
|
92
|
-
}
|
|
93
|
-
//# sourceMappingURL=background-message.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"background-message.d.ts","sourceRoot":"","sources":["../../src/devtools-bridge/background-message.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAC5C,OAAO,EAAE,MAAM,EAAgB,MAAM,yBAAyB,CAAA;AAE9D,yBAAiB,iBAAiB,CAAC;;;;IACjC,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5
|
-
class CopyToClipboard extends Schema.TaggedStruct('Background.CopyToClipboard', {
|
|
6
|
-
text: Schema.String,
|
|
7
|
-
}) {
|
|
8
|
-
}
|
|
9
|
-
BackgroundMessage.CopyToClipboard = CopyToClipboard;
|
|
10
|
-
class MessageFromAppHost extends Schema.TaggedStruct('Background.MessageFromAppHost', {
|
|
11
|
-
msg: Devtools.Leader.MessageFromApp,
|
|
12
|
-
}) {
|
|
13
|
-
}
|
|
14
|
-
BackgroundMessage.MessageFromAppHost = MessageFromAppHost;
|
|
15
|
-
class MessageToAppHost extends Schema.TaggedStruct('Background.MessageToAppHost', {
|
|
16
|
-
msg: Devtools.Leader.MessageToApp,
|
|
17
|
-
}) {
|
|
18
|
-
}
|
|
19
|
-
BackgroundMessage.MessageToAppHost = MessageToAppHost;
|
|
20
|
-
class RequestPortForDevtools extends Schema.TaggedStruct('Background.RequestPortForDevtools', {
|
|
21
|
-
tabId: Schema.Number,
|
|
22
|
-
}) {
|
|
23
|
-
}
|
|
24
|
-
BackgroundMessage.RequestPortForDevtools = RequestPortForDevtools;
|
|
25
|
-
class RequestOneTimePortFromDevtools extends Schema.TaggedStruct('Background.RequestOneTimePortFromDevtools', {
|
|
26
|
-
tabId: Schema.Number,
|
|
27
|
-
}) {
|
|
28
|
-
}
|
|
29
|
-
BackgroundMessage.RequestOneTimePortFromDevtools = RequestOneTimePortFromDevtools;
|
|
30
|
-
class Disconnect extends Schema.TaggedStruct('Background.Disconnect', { appHostId: Schema.String }) {
|
|
31
|
-
}
|
|
32
|
-
BackgroundMessage.Disconnect = Disconnect;
|
|
33
|
-
})(BackgroundMessage || (BackgroundMessage = {}));
|
|
34
|
-
export var MessagePortInit;
|
|
35
|
-
(function (MessagePortInit) {
|
|
36
|
-
/**
|
|
37
|
-
* Message is first sent from contentscript-iframe to background and then posted to the devtools.
|
|
38
|
-
*/
|
|
39
|
-
class PortForDevtools extends Schema.TaggedStruct('MessagePortInit.PortForDevtools', {
|
|
40
|
-
port: Transferable.MessagePort,
|
|
41
|
-
tabId: Schema.Number,
|
|
42
|
-
appHostId: Schema.String,
|
|
43
|
-
}) {
|
|
44
|
-
}
|
|
45
|
-
MessagePortInit.PortForDevtools = PortForDevtools;
|
|
46
|
-
class OneTimePortFromDevtools extends Schema.TaggedStruct('MessagePortInit.OneTimePortFromDevtools', {
|
|
47
|
-
port: Transferable.MessagePort,
|
|
48
|
-
tabId: Schema.Number,
|
|
49
|
-
}) {
|
|
50
|
-
}
|
|
51
|
-
MessagePortInit.OneTimePortFromDevtools = OneTimePortFromDevtools;
|
|
52
|
-
})(MessagePortInit || (MessagePortInit = {}));
|
|
53
|
-
//# sourceMappingURL=background-message.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"background-message.js","sourceRoot":"","sources":["../../src/devtools-bridge/background-message.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAC5C,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAA;AAE9D,MAAM,KAAW,iBAAiB,CAsBjC;AAtBD,WAAiB,iBAAiB;IAChC,MAAa,eAAgB,SAAQ,MAAM,CAAC,YAAY,CAAC,4BAA4B,EAAE;QACrF,IAAI,EAAE,MAAM,CAAC,MAAM;KACpB,CAAC;KAAG;IAFQ,iCAAe,kBAEvB,CAAA;IAEL,MAAa,kBAAmB,SAAQ,MAAM,CAAC,YAAY,CAAC,+BAA+B,EAAE;QAC3F,GAAG,EAAE,QAAQ,CAAC,MAAM,CAAC,cAAc;KACpC,CAAC;KAAG;IAFQ,oCAAkB,qBAE1B,CAAA;IAEL,MAAa,gBAAiB,SAAQ,MAAM,CAAC,YAAY,CAAC,6BAA6B,EAAE;QACvF,GAAG,EAAE,QAAQ,CAAC,MAAM,CAAC,YAAY;KAClC,CAAC;KAAG;IAFQ,kCAAgB,mBAExB,CAAA;IAEL,MAAa,sBAAuB,SAAQ,MAAM,CAAC,YAAY,CAAC,mCAAmC,EAAE;QACnG,KAAK,EAAE,MAAM,CAAC,MAAM;KACrB,CAAC;KAAG;IAFQ,wCAAsB,yBAE9B,CAAA;IAEL,MAAa,8BAA+B,SAAQ,MAAM,CAAC,YAAY,CAAC,2CAA2C,EAAE;QACnH,KAAK,EAAE,MAAM,CAAC,MAAM;KACrB,CAAC;KAAG;IAFQ,gDAA8B,iCAEtC,CAAA;IAEL,MAAa,UAAW,SAAQ,MAAM,CAAC,YAAY,CAAC,uBAAuB,EAAE,EAAE,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC;KAAG;IAAhG,4BAAU,aAAsF,CAAA;AAC/G,CAAC,EAtBgB,iBAAiB,KAAjB,iBAAiB,QAsBjC;AAED,MAAM,KAAW,eAAe,CAc/B;AAdD,WAAiB,eAAe;IAC9B;;OAEG;IACH,MAAa,eAAgB,SAAQ,MAAM,CAAC,YAAY,CAAC,iCAAiC,EAAE;QAC1F,IAAI,EAAE,YAAY,CAAC,WAAW;QAC9B,KAAK,EAAE,MAAM,CAAC,MAAM;QACpB,SAAS,EAAE,MAAM,CAAC,MAAM;KACzB,CAAC;KAAG;IAJQ,+BAAe,kBAIvB,CAAA;IAEL,MAAa,uBAAwB,SAAQ,MAAM,CAAC,YAAY,CAAC,yCAAyC,EAAE;QAC1G,IAAI,EAAE,YAAY,CAAC,WAAW;QAC9B,KAAK,EAAE,MAAM,CAAC,MAAM;KACrB,CAAC;KAAG;IAHQ,uCAAuB,0BAG/B,CAAA;AACP,CAAC,EAdgB,eAAe,KAAf,eAAe,QAc/B"}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { Devtools } from '@livestore/common';
|
|
2
|
-
import { Deferred, Effect, PubSub } from '@livestore/utils/effect';
|
|
3
|
-
/**
|
|
4
|
-
* This code is running in the devtools window where it's assumed that message ports
|
|
5
|
-
* can be transferred over the bridge.
|
|
6
|
-
*/
|
|
7
|
-
export declare const makeShared: ({ portForDevtoolsDeferred, responsePubSub, }: {
|
|
8
|
-
portForDevtoolsDeferred: Deferred.Deferred<MessagePort>;
|
|
9
|
-
responsePubSub: PubSub.PubSub<Devtools.MessageFromApp | Devtools.MessageFromApp>;
|
|
10
|
-
}) => Effect.Effect<{
|
|
11
|
-
appHostId: string;
|
|
12
|
-
isLeader: boolean;
|
|
13
|
-
}, never, import("effect/Scope").Scope>;
|
|
14
|
-
//# sourceMappingURL=bridge-shared.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"bridge-shared.d.ts","sourceRoot":"","sources":["../../src/devtools-bridge/bridge-shared.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAoB,MAAM,mBAAmB,CAAA;AAC9D,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAA8B,MAAM,yBAAyB,CAAA;AAE9F;;;GAGG;AACH,eAAO,MAAM,UAAU,GAAI,8CAGxB;IACD,uBAAuB,EAAE,QAAQ,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAA;IACvD,cAAc,EAAE,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,cAAc,GAAG,QAAQ,CAAC,cAAc,CAAC,CAAA;CACjF;;;uCAkFG,CAAA"}
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
// @ts-nocheck
|
|
2
|
-
import { Devtools } from '@livestore/common';
|
|
3
|
-
import { Deferred, Effect, PubSub, Stream, WebChannel } from '@livestore/utils/effect';
|
|
4
|
-
/**
|
|
5
|
-
* This code is running in the devtools window where it's assumed that message ports
|
|
6
|
-
* can be transferred over the bridge.
|
|
7
|
-
*/
|
|
8
|
-
export const makeShared = ({ portForDevtoolsDeferred, responsePubSub, }) => Effect.gen(function* () {
|
|
9
|
-
const appHostInfoDeferred = yield* Deferred.make();
|
|
10
|
-
const appHostStoreChannelDeferred = yield* Deferred.make();
|
|
11
|
-
const portForDevtools = yield* Deferred.await(portForDevtoolsDeferred);
|
|
12
|
-
const appHostCoordinatorChannel = yield* WebChannel.messagePortChannel({
|
|
13
|
-
port: portForDevtools,
|
|
14
|
-
schema: { listen: Devtools.MessageFromApp, send: Devtools.MessageToApp },
|
|
15
|
-
});
|
|
16
|
-
yield* appHostCoordinatorChannel.listen.pipe(Stream.flatten(),
|
|
17
|
-
// Stream.tapLogWithLabel('appHostCoordinatorChannel.listen'),
|
|
18
|
-
Stream.tap((msg) => Effect.gen(function* () {
|
|
19
|
-
// if (msg._tag === 'LSD.AppHostReady') {
|
|
20
|
-
// const { appHostId, isLeader } = msg
|
|
21
|
-
// yield* Deferred.succeed(appHostInfoDeferred, { appHostId, isLeader })
|
|
22
|
-
// } else if (msg._tag === 'LSD.MessagePortForStoreReq') {
|
|
23
|
-
// Here we're "duplicating" the message port since we need one for the coordinator
|
|
24
|
-
// and one for the store
|
|
25
|
-
const storeMessageChannel = new MessageChannel();
|
|
26
|
-
// yield* sendToAppHost(
|
|
27
|
-
// Devtools.MessagePortForStoreRes.make({
|
|
28
|
-
// // appHostId: msg.appHostId,
|
|
29
|
-
// liveStoreVersion: msg.liveStoreVersion,
|
|
30
|
-
// port: storeMessageChannel.port1,
|
|
31
|
-
// requestId: msg.requestId,
|
|
32
|
-
// }),
|
|
33
|
-
// )
|
|
34
|
-
// const portForAppHostStoreChannel = yield* WebChannel.messagePortChannel({
|
|
35
|
-
// port: storeMessageChannel.port2,
|
|
36
|
-
// schema: { listen: Devtools.MessageFromApp, send: Devtools.MessageToApp },
|
|
37
|
-
// })
|
|
38
|
-
// yield* portForAppHostStoreChannel.listen.pipe(
|
|
39
|
-
// Stream.flatten(),
|
|
40
|
-
// Stream.tap((msg) => PubSub.publish(responsePubSub, msg)),
|
|
41
|
-
// Stream.runDrain,
|
|
42
|
-
// Effect.withSpan('portForStoreChannel.listen'),
|
|
43
|
-
// Effect.tapCauseLogPretty,
|
|
44
|
-
// Effect.forkScoped,
|
|
45
|
-
// )
|
|
46
|
-
// yield* Deferred.succeed(appHostStoreChannelDeferred, portForAppHostStoreChannel)
|
|
47
|
-
// } else {
|
|
48
|
-
yield* PubSub.publish(responsePubSub, msg);
|
|
49
|
-
// }
|
|
50
|
-
})), Stream.runDrain, Effect.withSpan('portForDevtoolsChannel.listen'), Effect.tapCauseLogPretty, Effect.forkScoped);
|
|
51
|
-
// Sends the message to the app host (i.e. contentscript) via the devtools panel window and the background script
|
|
52
|
-
// const sendToAppHost: Devtools.PrepareDevtoolsBridge['sendToAppHost'] = (msg) =>
|
|
53
|
-
// Effect.gen(function* () {
|
|
54
|
-
// // console.log('bridge-shared: sendToAppHost', msg)
|
|
55
|
-
// if (Schema.is(Devtools.MessageToApp)(msg)) {
|
|
56
|
-
// yield* appHostCoordinatorChannel.send(msg)
|
|
57
|
-
// } else {
|
|
58
|
-
// // console.log('bridge-shared: sendToAppHostStore', msg)
|
|
59
|
-
// const appHostStoreChannel = yield* Deferred.await(appHostStoreChannelDeferred)
|
|
60
|
-
// yield* appHostStoreChannel.send(msg)
|
|
61
|
-
// }
|
|
62
|
-
// }).pipe(Effect.withSpan('sendToAppHost'), Effect.orDie)
|
|
63
|
-
// yield* sendToAppHost(Devtools.DevtoolsReady.make({ liveStoreVersion }))
|
|
64
|
-
const { appHostId, isLeader } = yield* Deferred.await(appHostInfoDeferred);
|
|
65
|
-
return { appHostId, isLeader };
|
|
66
|
-
});
|
|
67
|
-
//# sourceMappingURL=bridge-shared.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"bridge-shared.js","sourceRoot":"","sources":["../../src/devtools-bridge/bridge-shared.ts"],"names":[],"mappings":"AAAA,cAAc;AACd,OAAO,EAAE,QAAQ,EAAoB,MAAM,mBAAmB,CAAA;AAC9D,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAU,MAAM,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAA;AAE9F;;;GAGG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,EACzB,uBAAuB,EACvB,cAAc,GAIf,EAAE,EAAE,CACH,MA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;IACN,CAAC,CAAC,CACH,EACD,MAAM,CAAC,QAAQ,EACf,MAAM,CAAC,QAAQ,CAAC,+BAA+B,CAAC,EAChD,MAAM,CAAC,iBAAiB,EACxB,MAAM,CAAC,UAAU,CAClB,CAAA;IAED,iHAAiH;IACjH,kFAAkF;IAClF,8BAA8B;IAC9B,0DAA0D;IAC1D,mDAAmD;IACnD,mDAAmD;IACnD,eAAe;IACf,iEAAiE;IACjE,uFAAuF;IACvF,6CAA6C;IAC7C,QAAQ;IACR,4DAA4D;IAE5D,0EAA0E;IAE1E,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,GAAG,KAAK,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,mBAAmB,CAAC,CAAA;IAE1E,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,CAAA;AAChC,CAAC,CAAC,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"browser-extension-bridge.d.ts","sourceRoot":"","sources":["../../src/devtools-bridge/browser-extension-bridge.ts"],"names":[],"mappings":"AACA,OAAO,EAAY,MAAM,EAAsC,MAAM,yBAAyB,CAAA;AAQ9F,eAAO,MAAM,qCAAqC,mCAsDhD,CAAA"}
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import { Effect } from '@livestore/utils/effect';
|
|
2
|
-
// NOTE this code is running inside the devtools iframe, so will be re-running from scratch if the iframe is reloaded
|
|
3
|
-
// TODO make sure this also works reliably for HMR
|
|
4
|
-
export const prepareBrowserExtensionDevtoolsBridge = Effect.gen(function* () {
|
|
5
|
-
// const iframeWindow = window
|
|
6
|
-
// const iframeChannel = yield* WebChannel.windowChannel({
|
|
7
|
-
// window: iframeWindow,
|
|
8
|
-
// schema: {
|
|
9
|
-
// listen: Schema.Union(MessagePortInit.PortForDevtools, BackgroundMessage.Disconnect),
|
|
10
|
-
// send: Schema.Never,
|
|
11
|
-
// },
|
|
12
|
-
// })
|
|
13
|
-
// const panelChannel = yield* WebChannel.windowChannel({
|
|
14
|
-
// window: iframeWindow.parent,
|
|
15
|
-
// schema: { listen: Schema.Never, send: MessageToPanel },
|
|
16
|
-
// })
|
|
17
|
-
// const responsePubSub = yield* PubSub.unbounded<
|
|
18
|
-
// Devtools.MessageFromApp | Devtools.MessageFromApp
|
|
19
|
-
// >().pipe(Effect.acquireRelease(PubSub.shutdown))
|
|
20
|
-
// const portForDevtoolsDeferred = yield* Deferred.make<MessagePort>()
|
|
21
|
-
// // Messages coming from the app host (i.e. contentscript) via the background script and the devtools panel window
|
|
22
|
-
// yield* iframeChannel.listen.pipe(
|
|
23
|
-
// Stream.flatten(),
|
|
24
|
-
// Stream.tap((msg) =>
|
|
25
|
-
// Effect.gen(function* () {
|
|
26
|
-
// if (msg._tag === 'MessagePortInit.PortForDevtools') {
|
|
27
|
-
// yield* Deferred.succeed(portForDevtoolsDeferred, msg.port)
|
|
28
|
-
// } else {
|
|
29
|
-
// // yield* PubSub.publish(
|
|
30
|
-
// // responsePubSub,
|
|
31
|
-
// // Devtools.Disconnect.make({ clientId: msg.clientId, sessionId: msg.sessionId, liveStoreVersion }),
|
|
32
|
-
// // )
|
|
33
|
-
// }
|
|
34
|
-
// }),
|
|
35
|
-
// ),
|
|
36
|
-
// Stream.runDrain,
|
|
37
|
-
// Effect.withSpan('iframeChannel.listen'),
|
|
38
|
-
// Effect.tapCauseLogPretty,
|
|
39
|
-
// Effect.forkScoped,
|
|
40
|
-
// )
|
|
41
|
-
// yield* panelChannel.send(IframeReady.make({})).pipe(Effect.ignoreLogged)
|
|
42
|
-
// // NOTE When using the web bridge and browser extension bridge at the same time, both will show `isLeader: true`
|
|
43
|
-
// // even though the page origin is the same, given the browser extension app is running in an iframe
|
|
44
|
-
// // this will cause the origin to be "sandboxed" and thus the locks be isolated
|
|
45
|
-
// const { sendToAppHost, appHostId, isLeader } = yield* makeShared({ portForDevtoolsDeferred, responsePubSub })
|
|
46
|
-
// const copyToClipboard = (text: string) =>
|
|
47
|
-
// panelChannel.send(BackgroundMessage.CopyToClipboard.make({ text })).pipe(Effect.ignoreLogged)
|
|
48
|
-
// const sendEscapeKey = panelChannel.send(EscapeKey.make({})).pipe(Effect.ignoreLogged)
|
|
49
|
-
// return {
|
|
50
|
-
// responsePubSub,
|
|
51
|
-
// sendToAppHost,
|
|
52
|
-
// clientId,
|
|
53
|
-
// sessionId,
|
|
54
|
-
// copyToClipboard,
|
|
55
|
-
// sendEscapeKey,
|
|
56
|
-
// isLeader,
|
|
57
|
-
// } satisfies Devtools.PrepareDevtoolsBridge
|
|
58
|
-
});
|
|
59
|
-
//# sourceMappingURL=browser-extension-bridge.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"browser-extension-bridge.js","sourceRoot":"","sources":["../../src/devtools-bridge/browser-extension-bridge.ts"],"names":[],"mappings":"AACA,OAAO,EAAY,MAAM,EAAsC,MAAM,yBAAyB,CAAA;AAM9F,qHAAqH;AACrH,kDAAkD;AAClD,MAAM,CAAC,MAAM,qCAAqC,GAAG,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;IACvE,8BAA8B;IAC9B,0DAA0D;IAC1D,0BAA0B;IAC1B,cAAc;IACd,2FAA2F;IAC3F,0BAA0B;IAC1B,OAAO;IACP,KAAK;IACL,yDAAyD;IACzD,iCAAiC;IACjC,4DAA4D;IAC5D,KAAK;IACL,kDAAkD;IAClD,sDAAsD;IACtD,mDAAmD;IACnD,sEAAsE;IACtE,oHAAoH;IACpH,oCAAoC;IACpC,sBAAsB;IACtB,wBAAwB;IACxB,gCAAgC;IAChC,8DAA8D;IAC9D,qEAAqE;IACrE,iBAAiB;IACjB,oCAAoC;IACpC,+BAA+B;IAC/B,iHAAiH;IACjH,eAAe;IACf,UAAU;IACV,UAAU;IACV,OAAO;IACP,qBAAqB;IACrB,6CAA6C;IAC7C,8BAA8B;IAC9B,uBAAuB;IACvB,IAAI;IACJ,2EAA2E;IAC3E,mHAAmH;IACnH,sGAAsG;IACtG,iFAAiF;IACjF,gHAAgH;IAChH,4CAA4C;IAC5C,kGAAkG;IAClG,wFAAwF;IACxF,WAAW;IACX,oBAAoB;IACpB,mBAAmB;IACnB,cAAc;IACd,eAAe;IACf,qBAAqB;IACrB,mBAAmB;IACnB,cAAc;IACd,6CAA6C;AAC/C,CAAC,CAAC,CAAA"}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { Schema } from '@livestore/utils/effect';
|
|
2
|
-
import { BackgroundMessage } from './background-message.js';
|
|
3
|
-
declare const IframeReady_base: Schema.TaggedStruct<"IframeReady", {}>;
|
|
4
|
-
export declare class IframeReady extends IframeReady_base {
|
|
5
|
-
}
|
|
6
|
-
declare const EscapeKey_base: Schema.TaggedStruct<"EscapeKey", {}>;
|
|
7
|
-
export declare class EscapeKey extends EscapeKey_base {
|
|
8
|
-
}
|
|
9
|
-
declare const MessageToIframeWindow_base: typeof Schema.Never;
|
|
10
|
-
export declare class MessageToIframeWindow extends MessageToIframeWindow_base {
|
|
11
|
-
}
|
|
12
|
-
declare const MessageToPanel_base: Schema.Union<[typeof IframeReady, typeof EscapeKey, typeof BackgroundMessage.CopyToClipboard]>;
|
|
13
|
-
export declare class MessageToPanel extends MessageToPanel_base {
|
|
14
|
-
}
|
|
15
|
-
export {};
|
|
16
|
-
//# sourceMappingURL=iframe-message.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"iframe-message.d.ts","sourceRoot":"","sources":["../../src/devtools-bridge/iframe-message.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAA;AAEhD,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAA;;AAE3D,qBAAa,WAAY,SAAQ,gBAAsC;CAAG;;AAC1E,qBAAa,SAAU,SAAQ,cAAoC;CAAG;;AAEtE,qBAAa,qBAAsB,SAAQ,0BAAc;CAAG;;AAC5D,qBAAa,cAAe,SAAQ,mBAAuE;CAAG"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { Schema } from '@livestore/utils/effect';
|
|
2
|
-
import { BackgroundMessage } from './background-message.js';
|
|
3
|
-
export class IframeReady extends Schema.TaggedStruct('IframeReady', {}) {
|
|
4
|
-
}
|
|
5
|
-
export class EscapeKey extends Schema.TaggedStruct('EscapeKey', {}) {
|
|
6
|
-
}
|
|
7
|
-
export class MessageToIframeWindow extends Schema.Union() {
|
|
8
|
-
}
|
|
9
|
-
export class MessageToPanel extends Schema.Union(IframeReady, EscapeKey, BackgroundMessage.CopyToClipboard) {
|
|
10
|
-
}
|
|
11
|
-
//# sourceMappingURL=iframe-message.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"iframe-message.js","sourceRoot":"","sources":["../../src/devtools-bridge/iframe-message.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAA;AAEhD,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAA;AAE3D,MAAM,OAAO,WAAY,SAAQ,MAAM,CAAC,YAAY,CAAC,aAAa,EAAE,EAAE,CAAC;CAAG;AAC1E,MAAM,OAAO,SAAU,SAAQ,MAAM,CAAC,YAAY,CAAC,WAAW,EAAE,EAAE,CAAC;CAAG;AAEtE,MAAM,OAAO,qBAAsB,SAAQ,MAAM,CAAC,KAAK,EAAE;CAAG;AAC5D,MAAM,OAAO,cAAe,SAAQ,MAAM,CAAC,KAAK,CAAC,WAAW,EAAE,SAAS,EAAE,iBAAiB,CAAC,eAAe,CAAC;CAAG"}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export { prepareBrowserExtensionDevtoolsBridge } from './browser-extension-bridge.js';
|
|
2
|
-
export { type WebBridgeOptions, type WebBridgeInfo as WebBridgeChannelInfo, } from './web-bridge.js';
|
|
3
|
-
export { BackgroundMessage, MessagePortInit } from './background-message.js';
|
|
4
|
-
export { backgroundChannel } from './background-browser-channel.js';
|
|
5
|
-
export * as IframeMessage from './iframe-message.js';
|
|
6
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/devtools-bridge/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qCAAqC,EAAE,MAAM,+BAA+B,CAAA;AACrF,OAAO,EAEL,KAAK,gBAAgB,EACrB,KAAK,aAAa,IAAI,oBAAoB,GAC3C,MAAM,iBAAiB,CAAA;AACxB,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAA;AAC5E,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAA;AACnE,OAAO,KAAK,aAAa,MAAM,qBAAqB,CAAA"}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
export { prepareBrowserExtensionDevtoolsBridge } from './browser-extension-bridge.js';
|
|
2
|
-
export { BackgroundMessage, MessagePortInit } from './background-message.js';
|
|
3
|
-
export { backgroundChannel } from './background-browser-channel.js';
|
|
4
|
-
export * as IframeMessage from './iframe-message.js';
|
|
5
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/devtools-bridge/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qCAAqC,EAAE,MAAM,+BAA+B,CAAA;AAMrF,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAA;AAC5E,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAA;AACnE,OAAO,KAAK,aAAa,MAAM,qBAAqB,CAAA"}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import type { Deferred, HashSet, SubscriptionRef } from '@livestore/utils/effect';
|
|
2
|
-
import { Equal, Hash, Schema } from '@livestore/utils/effect';
|
|
3
|
-
declare const WebBridgeInfo_base: Schema.Class<WebBridgeInfo, {
|
|
4
|
-
appHostId: typeof Schema.String;
|
|
5
|
-
storeId: typeof Schema.String;
|
|
6
|
-
webBridgeId: typeof Schema.String;
|
|
7
|
-
isLeader: typeof Schema.Boolean;
|
|
8
|
-
}, Schema.Struct.Encoded<{
|
|
9
|
-
appHostId: typeof Schema.String;
|
|
10
|
-
storeId: typeof Schema.String;
|
|
11
|
-
webBridgeId: typeof Schema.String;
|
|
12
|
-
isLeader: typeof Schema.Boolean;
|
|
13
|
-
}>, never, {
|
|
14
|
-
readonly storeId: string;
|
|
15
|
-
} & {
|
|
16
|
-
readonly appHostId: string;
|
|
17
|
-
} & {
|
|
18
|
-
readonly isLeader: boolean;
|
|
19
|
-
} & {
|
|
20
|
-
readonly webBridgeId: string;
|
|
21
|
-
}, {}, {}>;
|
|
22
|
-
export declare class WebBridgeInfo extends WebBridgeInfo_base {
|
|
23
|
-
[Hash.symbol](): number;
|
|
24
|
-
[Equal.symbol](that: Equal.Equal): boolean;
|
|
25
|
-
}
|
|
26
|
-
export type WebBridgeOptions = {
|
|
27
|
-
selectedChannelInfoDeferred: Deferred.Deferred<WebBridgeInfo>;
|
|
28
|
-
bridgeInfos: SubscriptionRef.SubscriptionRef<HashSet.HashSet<WebBridgeInfo>>;
|
|
29
|
-
};
|
|
30
|
-
export {};
|
|
31
|
-
//# sourceMappingURL=web-bridge.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"web-bridge.d.ts","sourceRoot":"","sources":["../../src/devtools-bridge/web-bridge.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAS,eAAe,EAAE,MAAM,yBAAyB,CAAA;AACxF,OAAO,EAAyB,KAAK,EAAY,IAAI,EAAU,MAAM,EAAkB,MAAM,yBAAyB,CAAA;;;;;;;;;;;;;;;;;;;;AAKtH,qBAAa,aAAc,SAAQ,kBAKjC;IAEA,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,MAAM;IAKvB,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,KAAK,CAAC,KAAK,GAAG,OAAO;CAG3C;AAED,MAAM,MAAM,gBAAgB,GAAG;IAC7B,2BAA2B,EAAE,QAAQ,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAA;IAC7D,WAAW,EAAE,eAAe,CAAC,eAAe,CAAC,OAAO,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC,CAAA;CAC7E,CAAA"}
|