@livestore/adapter-web 0.0.0-snapshot-cd10782385ab8ba5d2bc26a16801628ac813d5f9 → 0.0.0-snapshot-ee8e0fc3b894cf3159269c9c8969a8fc4b398dca
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 +3 -88
- 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 +29 -17
- package/dist/web-worker/client-session/index.js.map +1 -1
- package/package.json +6 -13
- package/src/web-worker/client-session/client-session-devtools.ts +4 -146
- package/src/web-worker/client-session/index.ts +43 -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
|
@@ -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,WAAW,CAAC,CAAA;IAEhD,MAAM,IAAI,GAAG,CAAC,GAAW,EAAE,EAAE,CAC3B,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;QAClB,MAAM,OAAO,GAAG,KAAK,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAA;QACtD,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,CAAA;IAC3B,CAAC,CAAC,CAAA;IAEJ,MAAM,OAAO,GAAG,KAAK,CAAC,CAAC,MAAM,CAAC,OAAO,EAAE,CAAA;IAEvC,MAAM,MAAM,GAAG,MAAM,CAAC,KAAK,CAA+C,CAAC,IAAI,EAAE,EAAE;QACjF,MAAM,SAAS,GAAG,CAAC,OAAY,EAAE,EAAE,CACjC,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;YAClB,MAAM,MAAM,GAAG,KAAK,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAA;YAE/E,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAA;QAC1C,CAAC,CAAC,CAAC,IAAI,CACL,MAAM,CAAC,QAAQ,CAAC,qCAAqC,CAAC,EACtD,MAAM,CAAC,iBAAiB,EACxB,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,CACzB,CAAA;QAEH,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,SAAS,CAAC,CAAA;QAErC,OAAO,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE;YACtB,IAAI,CAAC,SAAS,CAAC,cAAc,CAAC,SAAS,CAAC,CAAA;QAC1C,CAAC,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;IAEF,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,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,MAAM,OAAO,eAAgB,SAAQ,oBAEnC;KAAG;;;uCAoCqwV,OAAQ,MAAM;qDAA+C,6DAA+B;sCAAiD,OAAQ,MAAM;;mBAAqF,OAAQ,KAAK,EAAE,OAAO,YAAY,0BAAyB,OAAQ,YAAY,8BAA6B,OAAQ,YAAY;8BAA4C,OAAQ,MAAM;;;uCAAgD,OAAQ,MAAM;qDAA+C,6DAA+B;sCAAiD,OAAQ,MAAM;;uCAA4T,OAAQ,MAAM;qDAA+C,6DAA+B;sCAAiD,OAAQ,MAAM;;uCAAsG,OAAQ,MAAM;qDAA+C,6DAA+B;sCAAiD,OAAQ,MAAM;;;IAlCvlY,MAAM,OAAO,kBAAmB,SAAQ,uBAEtC;KAAG;;;kBAgCg4S,OAAQ,MAAM;;uCAAuG,OAAQ,MAAM;qDAA+C,6DAA+B;sCAAiD,OAAQ,MAAM;;kBAA+F,OAAQ,OAAO;;uCAAmE,OAAQ,MAAM;qDAA+C,6DAA+B;sCAAiD,OAAQ,MAAM;;+BAAiX,OAAQ,OAAO;;uCAAsC,OAAQ,MAAM;qDAA+C,6DAA+B;sCAAiD,OAAQ,MAAM;;;IA9BliV,MAAM,OAAO,gBAAiB,SAAQ,qBAEpC;KAAG;;;;IAEL,MAAM,OAAO,sBAAuB,SAAQ,2BAE1C;KAAG;;;;IAEL,MAAM,OAAO,8BAA+B,SAAQ,mCAElD;KAAG;;;;IAEL,MAAM,OAAO,UAAW,SAAQ,eAA0E;KAAG;;CAC9G;AAED,yBAAiB,eAAe,CAAC;;;;;;IAC/B;;OAEG;IACH,MAAM,OAAO,eAAgB,SAAQ,oBAInC;KAAG;;;;;IAEL,MAAM,OAAO,uBAAwB,SAAQ,4BAG3C;KAAG;;CACN"}
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { Devtools } from '@livestore/common';
|
|
2
|
-
import { Schema, Transferable } from '@livestore/utils/effect';
|
|
3
|
-
export var BackgroundMessage;
|
|
4
|
-
(function (BackgroundMessage) {
|
|
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,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;IAClB,MAAM,mBAAmB,GAAG,KAAK,CAAC,CAAC,QAAQ,CAAC,IAAI,EAA4C,CAAA;IAE5F,MAAM,2BAA2B,GAC/B,KAAK,CAAC,CAAC,QAAQ,CAAC,IAAI,EAEjB,CAAA;IAEL,MAAM,eAAe,GAAG,KAAK,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,uBAAuB,CAAC,CAAA;IAEtE,MAAM,yBAAyB,GAAG,KAAK,CAAC,CAAC,UAAU,CAAC,kBAAkB,CAAC;QACrE,IAAI,EAAE,eAAe;QACrB,MAAM,EAAE,EAAE,MAAM,EAAE,QAAQ,CAAC,cAAc,EAAE,IAAI,EAAE,QAAQ,CAAC,YAAY,EAAE;KACzE,CAAC,CAAA;IAEF,KAAK,CAAC,CAAC,yBAAyB,CAAC,MAAM,CAAC,IAAI,CAC1C,MAAM,CAAC,OAAO,EAAE;IAChB,8DAA8D;IAC9D,MAAM,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CACjB,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;QAClB,yCAAyC;QACzC,sCAAsC;QACtC,wEAAwE;QACxE,0DAA0D;QAC1D,kFAAkF;QAClF,wBAAwB;QACxB,MAAM,mBAAmB,GAAG,IAAI,cAAc,EAAE,CAAA;QAEhD,wBAAwB;QACxB,2CAA2C;QAC3C,mCAAmC;QACnC,8CAA8C;QAC9C,uCAAuC;QACvC,gCAAgC;QAChC,QAAQ;QACR,IAAI;QAEJ,8EAA8E;QAC9E,uCAAuC;QACvC,gFAAgF;QAChF,OAAO;QAEP,mDAAmD;QACnD,wBAAwB;QACxB,gEAAgE;QAChE,uBAAuB;QACvB,qDAAqD;QACrD,gCAAgC;QAChC,yBAAyB;QACzB,MAAM;QAEN,qFAAqF;QACrF,WAAW;QACX,KAAK,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,cAAc,EAAE,GAAG,CAAC,CAAA;QAC1C,IAAI;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"}
|
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
import { Equal, Hash, Schema } from '@livestore/utils/effect';
|
|
2
|
-
export class WebBridgeInfo extends Schema.Class('WebBridgeChannelInfo')({
|
|
3
|
-
appHostId: Schema.String,
|
|
4
|
-
storeId: Schema.String,
|
|
5
|
-
webBridgeId: Schema.String,
|
|
6
|
-
isLeader: Schema.Boolean,
|
|
7
|
-
}) {
|
|
8
|
-
// eslint-disable-next-line prefer-arrow/prefer-arrow-functions
|
|
9
|
-
[Hash.symbol]() {
|
|
10
|
-
return Hash.string(this.appHostId);
|
|
11
|
-
}
|
|
12
|
-
// eslint-disable-next-line prefer-arrow/prefer-arrow-functions
|
|
13
|
-
[Equal.symbol](that) {
|
|
14
|
-
return this.appHostId === that.appHostId;
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
// const prepareWebDevtoolsBridge = (
|
|
18
|
-
// options: {
|
|
19
|
-
// sharedWorker: WebAdapterOptions['sharedWorker']
|
|
20
|
-
// appSchema: LiveStoreSchema
|
|
21
|
-
// } & WebBridgeOptions,
|
|
22
|
-
// ): Effect.Effect<Devtools.PrepareDevtoolsBridge, never, Scope.Scope> =>
|
|
23
|
-
// Effect.gen(function* () {
|
|
24
|
-
// const responsePubSub = yield* PubSub.unbounded<
|
|
25
|
-
// Devtools.MessageFromApp | Devtools.MessageFromApp
|
|
26
|
-
// >().pipe(Effect.acquireRelease(PubSub.shutdown))
|
|
27
|
-
// const devtoolsId = nanoid()
|
|
28
|
-
// const portForDevtoolsDeferred = yield* Deferred.make<MessagePort>()
|
|
29
|
-
// const webBridgeBroadcastChannel = yield* Devtools.WebBridge.makeBroadcastChannel()
|
|
30
|
-
// yield* webBridgeBroadcastChannel.listen.pipe(
|
|
31
|
-
// Stream.flatten(),
|
|
32
|
-
// Stream.filter(Schema.is(Devtools.WebBridge.AppHostReady)),
|
|
33
|
-
// Stream.tap(() => webBridgeBroadcastChannel.send(Devtools.WebBridge.DevtoolsReady.make({ devtoolsId }))),
|
|
34
|
-
// Stream.runDrain,
|
|
35
|
-
// Effect.withSpan(`@livestore/adapter-web:devtools:webBridgeChannel:listen`),
|
|
36
|
-
// Effect.ignoreLogged,
|
|
37
|
-
// Effect.forkScoped,
|
|
38
|
-
// )
|
|
39
|
-
// yield* webBridgeBroadcastChannel.send(Devtools.WebBridge.DevtoolsReady.make({ devtoolsId }))
|
|
40
|
-
// const connectionFiberSet = yield* FiberSet.make()
|
|
41
|
-
// yield* webBridgeBroadcastChannel.listen.pipe(
|
|
42
|
-
// Stream.flatten(),
|
|
43
|
-
// Stream.filter(Schema.is(Devtools.WebBridge.ConnectToDevtools)),
|
|
44
|
-
// Stream.tap((msg) =>
|
|
45
|
-
// Effect.gen(function* () {
|
|
46
|
-
// if (devtoolsId !== msg.devtoolsId) return
|
|
47
|
-
// const bridgeInfo = new WebBridgeInfo({
|
|
48
|
-
// appHostId: msg.appHostId,
|
|
49
|
-
// webBridgeId: msg.webBridgeId,
|
|
50
|
-
// isLeader: msg.isLeader,
|
|
51
|
-
// storeId: msg.storeId,
|
|
52
|
-
// })
|
|
53
|
-
// // Propagate disconnect event while connecting.
|
|
54
|
-
// // There's another disconnect handler below after the connection is established.
|
|
55
|
-
// yield* webBridgeBroadcastChannel.listen.pipe(
|
|
56
|
-
// Stream.flatten(),
|
|
57
|
-
// Stream.filter(Schema.is(Devtools.WebBridge.AppHostWillDisconnect)),
|
|
58
|
-
// Stream.filter((msg) => msg.appHostId === bridgeInfo.appHostId),
|
|
59
|
-
// Stream.tap(() => SubscriptionRef.getAndUpdate(options.bridgeInfos, HashSet.remove(bridgeInfo))),
|
|
60
|
-
// Stream.runDrain,
|
|
61
|
-
// Effect.withSpan(`@livestore/adapter-web:devtools:webBridgeChannel:listenForAppHostWillDisconnect`),
|
|
62
|
-
// Effect.tapCauseLogPretty,
|
|
63
|
-
// FiberSet.run(connectionFiberSet),
|
|
64
|
-
// )
|
|
65
|
-
// yield* SubscriptionRef.getAndUpdate(options.bridgeInfos, HashSet.add(bridgeInfo))
|
|
66
|
-
// }),
|
|
67
|
-
// ),
|
|
68
|
-
// Stream.runDrain,
|
|
69
|
-
// Effect.withSpan(`@livestore/adapter-web:devtools:webBridgeChannel:listen`),
|
|
70
|
-
// Effect.tapCauseLogPretty,
|
|
71
|
-
// FiberSet.run(connectionFiberSet),
|
|
72
|
-
// )
|
|
73
|
-
// const selectedChannelInfo = yield* Deferred.await(options.selectedChannelInfoDeferred)
|
|
74
|
-
// const sharedWorker = tryAsFunctionAndNew(options.sharedWorker, {
|
|
75
|
-
// name: `livestore-shared-worker-${selectedChannelInfo.storeId}`,
|
|
76
|
-
// })
|
|
77
|
-
// const sharedWorkerDeferred = yield* Worker.makeSerialized<typeof WorkerSchema.SharedWorker.Request.Type>({
|
|
78
|
-
// initialMessage: () => new WorkerSchema.SharedWorker.InitialMessage({ payload: { _tag: 'FromWebBridge' } }),
|
|
79
|
-
// }).pipe(
|
|
80
|
-
// Effect.provide(BrowserWorker.layer(() => sharedWorker)),
|
|
81
|
-
// Effect.tapCauseLogPretty,
|
|
82
|
-
// Effect.withSpan('@livestore/adapter-web:coordinator:setupSharedWorker'),
|
|
83
|
-
// Effect.toForkedDeferred,
|
|
84
|
-
// )
|
|
85
|
-
// yield* Effect.gen(function* () {
|
|
86
|
-
// const mc = new MessageChannel()
|
|
87
|
-
// const worker = yield* Deferred.await(sharedWorkerDeferred)
|
|
88
|
-
// yield* worker.executeEffect(
|
|
89
|
-
// new WorkerSchema.SharedWorker.DevtoolsWebBridgeOfferPort({
|
|
90
|
-
// port: mc.port1,
|
|
91
|
-
// webBridgeId: selectedChannelInfo.webBridgeId,
|
|
92
|
-
// }),
|
|
93
|
-
// )
|
|
94
|
-
// yield* Deferred.succeed(portForDevtoolsDeferred, mc.port2)
|
|
95
|
-
// // Stop listening for new connections and close `AppHostWillDisconnect` listeners
|
|
96
|
-
// yield* FiberSet.clear(connectionFiberSet)
|
|
97
|
-
// }).pipe(Effect.tapCauseLogPretty, Effect.forkScoped)
|
|
98
|
-
// const { sendToAppHost, appHostId, isLeader } = yield* makeShared({ portForDevtoolsDeferred, responsePubSub })
|
|
99
|
-
// // NOTE we need a second listener here since we depend on the `appHostId` to be set
|
|
100
|
-
// yield* webBridgeBroadcastChannel.listen.pipe(
|
|
101
|
-
// Stream.flatten(),
|
|
102
|
-
// Stream.filter(Schema.is(Devtools.WebBridge.AppHostWillDisconnect)),
|
|
103
|
-
// Stream.filter((msg) => msg.appHostId === appHostId),
|
|
104
|
-
// Stream.tap(() => SubscriptionRef.getAndUpdate(options.bridgeInfos, HashSet.remove(selectedChannelInfo))),
|
|
105
|
-
// Stream.tap(() => PubSub.publish(responsePubSub, Devtools.Disconnect.make({ appHostId, liveStoreVersion }))),
|
|
106
|
-
// Stream.runDrain,
|
|
107
|
-
// Effect.withSpan(`@livestore/adapter-web:devtools:webBridgeChannel:listenForAppHostWillDisconnect`),
|
|
108
|
-
// Effect.ignoreLogged,
|
|
109
|
-
// Effect.forkScoped,
|
|
110
|
-
// )
|
|
111
|
-
// // NOTE this is not guaranteed to "go through" to the app host but at least we try 🤷
|
|
112
|
-
// yield* Stream.fromEventListener(window, 'beforeunload').pipe(
|
|
113
|
-
// Stream.tap(() => sendToAppHost(Devtools.Disconnect.make({ appHostId, liveStoreVersion }))),
|
|
114
|
-
// Stream.runDrain,
|
|
115
|
-
// Effect.ignoreLogged,
|
|
116
|
-
// Effect.forkScoped,
|
|
117
|
-
// )
|
|
118
|
-
// const copyToClipboard = (text: string) =>
|
|
119
|
-
// Effect.sync(() => {
|
|
120
|
-
// navigator.clipboard.writeText(text)
|
|
121
|
-
// })
|
|
122
|
-
// return {
|
|
123
|
-
// responsePubSub,
|
|
124
|
-
// sendToAppHost,
|
|
125
|
-
// appHostId,
|
|
126
|
-
// copyToClipboard,
|
|
127
|
-
// sendEscapeKey: Effect.void,
|
|
128
|
-
// isLeader,
|
|
129
|
-
// } satisfies Devtools.PrepareDevtoolsBridge
|
|
130
|
-
// }).pipe(Effect.orDie)
|
|
131
|
-
//# sourceMappingURL=web-bridge.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"web-bridge.js","sourceRoot":"","sources":["../../src/devtools-bridge/web-bridge.ts"],"names":[],"mappings":"AAMA,OAAO,EAAyB,KAAK,EAAY,IAAI,EAAU,MAAM,EAAkB,MAAM,yBAAyB,CAAA;AAKtH,MAAM,OAAO,aAAc,SAAQ,MAAM,CAAC,KAAK,CAAgB,sBAAsB,CAAC,CAAC;IACrF,SAAS,EAAE,MAAM,CAAC,MAAM;IACxB,OAAO,EAAE,MAAM,CAAC,MAAM;IACtB,WAAW,EAAE,MAAM,CAAC,MAAM;IAC1B,QAAQ,EAAE,MAAM,CAAC,OAAO;CACzB,CAAC;IACA,+DAA+D;IAC/D,CAAC,IAAI,CAAC,MAAM,CAAC;QACX,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAA;IACpC,CAAC;IAED,+DAA+D;IAC/D,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,IAAiB;QAC9B,OAAO,IAAI,CAAC,SAAS,KAAM,IAAsB,CAAC,SAAS,CAAA;IAC7D,CAAC;CACF;AAOD,qCAAqC;AACrC,eAAe;AACf,sDAAsD;AACtD,iCAAiC;AACjC,0BAA0B;AAC1B,0EAA0E;AAC1E,8BAA8B;AAC9B,sDAAsD;AACtD,0DAA0D;AAC1D,uDAAuD;AAEvD,kCAAkC;AAElC,0EAA0E;AAE1E,yFAAyF;AAEzF,oDAAoD;AACpD,0BAA0B;AAC1B,mEAAmE;AACnE,iHAAiH;AACjH,yBAAyB;AACzB,oFAAoF;AACpF,6BAA6B;AAC7B,2BAA2B;AAC3B,QAAQ;AAER,mGAAmG;AAEnG,wDAAwD;AAExD,oDAAoD;AACpD,0BAA0B;AAC1B,wEAAwE;AACxE,4BAA4B;AAC5B,oCAAoC;AACpC,sDAAsD;AAEtD,mDAAmD;AACnD,wCAAwC;AACxC,4CAA4C;AAC5C,sCAAsC;AACtC,oCAAoC;AACpC,eAAe;AAEf,4DAA4D;AAC5D,6FAA6F;AAC7F,0DAA0D;AAC1D,gCAAgC;AAChC,kFAAkF;AAClF,8EAA8E;AAC9E,+GAA+G;AAC/G,+BAA+B;AAC/B,kHAAkH;AAClH,wCAAwC;AACxC,gDAAgD;AAChD,cAAc;AAEd,8FAA8F;AAC9F,cAAc;AACd,WAAW;AACX,yBAAyB;AACzB,oFAAoF;AACpF,kCAAkC;AAClC,0CAA0C;AAC1C,QAAQ;AAER,6FAA6F;AAE7F,uEAAuE;AACvE,wEAAwE;AACxE,SAAS;AAET,iHAAiH;AACjH,oHAAoH;AACpH,eAAe;AACf,iEAAiE;AACjE,kCAAkC;AAClC,iFAAiF;AACjF,iCAAiC;AACjC,QAAQ;AAER,uCAAuC;AACvC,wCAAwC;AAExC,mEAAmE;AACnE,qCAAqC;AACrC,qEAAqE;AACrE,4BAA4B;AAC5B,0DAA0D;AAC1D,cAAc;AACd,UAAU;AAEV,mEAAmE;AAEnE,0FAA0F;AAC1F,kDAAkD;AAClD,2DAA2D;AAE3D,oHAAoH;AAEpH,0FAA0F;AAC1F,oDAAoD;AACpD,0BAA0B;AAC1B,4EAA4E;AAC5E,6DAA6D;AAC7D,kHAAkH;AAClH,qHAAqH;AACrH,yBAAyB;AACzB,4GAA4G;AAC5G,6BAA6B;AAC7B,2BAA2B;AAC3B,QAAQ;AAER,4FAA4F;AAC5F,oEAAoE;AACpE,oGAAoG;AACpG,yBAAyB;AACzB,6BAA6B;AAC7B,2BAA2B;AAC3B,QAAQ;AAER,gDAAgD;AAChD,4BAA4B;AAC5B,8CAA8C;AAC9C,WAAW;AAEX,eAAe;AACf,wBAAwB;AACxB,uBAAuB;AACvB,mBAAmB;AACnB,yBAAyB;AACzB,oCAAoC;AACpC,kBAAkB;AAClB,iDAAiD;AACjD,0BAA0B"}
|