dfx 0.20.5 → 0.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Cache/driver.d.ts +16 -16
- package/Cache/driver.js.map +1 -1
- package/Cache/index.d.ts +21 -21
- package/Cache/index.js +12 -13
- package/Cache/index.js.map +1 -1
- package/Cache/memory.d.ts +3 -3
- package/Cache/memory.js +19 -20
- package/Cache/memory.js.map +1 -1
- package/Cache/memoryTTL.d.ts +5 -5
- package/Cache/memoryTTL.js +16 -16
- package/Cache/memoryTTL.js.map +1 -1
- package/Cache/prelude.d.ts +41 -41
- package/Cache/prelude.js +39 -41
- package/Cache/prelude.js.map +1 -1
- package/DiscordConfig/index.d.ts +4 -19
- package/DiscordConfig/index.js +5 -12
- package/DiscordConfig/index.js.map +1 -1
- package/DiscordGateway/DiscordWS/index.d.ts +9 -9
- package/DiscordGateway/DiscordWS/index.js +16 -20
- package/DiscordGateway/DiscordWS/index.js.map +1 -1
- package/DiscordGateway/Shard/heartbeats.d.ts +3 -4
- package/DiscordGateway/Shard/heartbeats.js +9 -16
- package/DiscordGateway/Shard/heartbeats.js.map +1 -1
- package/DiscordGateway/Shard/identify.d.ts +4 -4
- package/DiscordGateway/Shard/identify.js +5 -4
- package/DiscordGateway/Shard/identify.js.map +1 -1
- package/DiscordGateway/Shard/index.d.ts +8 -7
- package/DiscordGateway/Shard/index.js +17 -20
- package/DiscordGateway/Shard/index.js.map +1 -1
- package/DiscordGateway/Shard/invalidSession.d.ts +2 -3
- package/DiscordGateway/Shard/invalidSession.js +5 -8
- package/DiscordGateway/Shard/invalidSession.js.map +1 -1
- package/DiscordGateway/Shard/sendEvents.d.ts +1 -1
- package/DiscordGateway/Shard/sendEvents.js +7 -7
- package/DiscordGateway/Shard/sendEvents.js.map +1 -1
- package/DiscordGateway/Shard/utils.d.ts +3 -4
- package/DiscordGateway/Shard/utils.js +6 -6
- package/DiscordGateway/Shard/utils.js.map +1 -1
- package/DiscordGateway/ShardStore/index.d.ts +6 -6
- package/DiscordGateway/ShardStore/index.js +7 -10
- package/DiscordGateway/ShardStore/index.js.map +1 -1
- package/DiscordGateway/Sharder/index.d.ts +11 -11
- package/DiscordGateway/Sharder/index.js +21 -42
- package/DiscordGateway/Sharder/index.js.map +1 -1
- package/DiscordGateway/WS/index.d.ts +3 -2
- package/DiscordGateway/WS/index.js +30 -40
- package/DiscordGateway/WS/index.js.map +1 -1
- package/DiscordGateway/index.d.ts +8 -9
- package/DiscordGateway/index.js +10 -15
- package/DiscordGateway/index.js.map +1 -1
- package/DiscordREST/index.d.ts +132 -132
- package/DiscordREST/index.js +37 -40
- package/DiscordREST/index.js.map +1 -1
- package/DiscordREST/types.d.ts +6 -6
- package/DiscordREST/utils.d.ts +5 -4
- package/DiscordREST/utils.js +5 -5
- package/DiscordREST/utils.js.map +1 -1
- package/Helpers/intents.js +8 -8
- package/Helpers/intents.js.map +1 -1
- package/Helpers/interactions.d.ts +18 -19
- package/Helpers/interactions.js +22 -23
- package/Helpers/interactions.js.map +1 -1
- package/Helpers/members.d.ts +2 -2
- package/Helpers/members.js.map +1 -1
- package/Helpers/permissions.d.ts +4 -4
- package/Helpers/permissions.js +13 -13
- package/Helpers/permissions.js.map +1 -1
- package/Http/index.d.ts +10 -9
- package/Http/index.js +7 -8
- package/Http/index.js.map +1 -1
- package/Interactions/context.d.ts +22 -23
- package/Interactions/context.js +21 -21
- package/Interactions/context.js.map +1 -1
- package/Interactions/definitions.d.ts +31 -31
- package/Interactions/definitions.js +1 -2
- package/Interactions/definitions.js.map +1 -1
- package/Interactions/gateway.d.ts +4 -3
- package/Interactions/gateway.js +6 -6
- package/Interactions/gateway.js.map +1 -1
- package/Interactions/handlers.d.ts +3 -4
- package/Interactions/handlers.js +23 -23
- package/Interactions/handlers.js.map +1 -1
- package/Interactions/index.d.ts +11 -11
- package/Interactions/index.js +11 -10
- package/Interactions/index.js.map +1 -1
- package/Interactions/webhook.d.ts +7 -8
- package/Interactions/webhook.js +11 -12
- package/Interactions/webhook.js.map +1 -1
- package/Log/index.d.ts +8 -7
- package/Log/index.js +9 -11
- package/Log/index.js.map +1 -1
- package/RateLimit/index.d.ts +13 -12
- package/RateLimit/index.js +11 -12
- package/RateLimit/index.js.map +1 -1
- package/RateLimit/memory.d.ts +1 -1
- package/RateLimit/memory.js +7 -7
- package/RateLimit/memory.js.map +1 -1
- package/RateLimit/utils.d.ts +2 -2
- package/RateLimit/utils.js.map +1 -1
- package/_common.d.ts +19 -0
- package/_common.js +20 -0
- package/_common.js.map +1 -0
- package/gateway.d.ts +11 -10
- package/gateway.js +17 -14
- package/gateway.js.map +1 -1
- package/package.json +5 -15
- package/utils/effect.d.ts +8 -8
- package/utils/effect.js +4 -4
- package/utils/effect.js.map +1 -1
- package/webhooks.d.ts +6 -5
- package/webhooks.js +12 -8
- package/webhooks.js.map +1 -1
- package/global.d.ts +0 -21
- package/global.js +0 -2
- package/global.js.map +0 -1
- package/utils/common.d.ts +0 -18
- package/utils/common.js +0 -3
- package/utils/common.js.map +0 -1
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
import * as tsplus_module_1 from "
|
|
2
|
-
import * as tsplus_module_2 from "@effect/
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import * as tsplus_module_5 from "dfx";
|
|
6
|
-
import * as tsplus_module_6 from "callbag-effect-ts/Source/tap";
|
|
7
|
-
import * as tsplus_module_7 from "callbag-effect-ts/Source/map";
|
|
1
|
+
import * as tsplus_module_1 from "@effect/io/Ref";
|
|
2
|
+
import * as tsplus_module_2 from "@effect/stream/Stream";
|
|
3
|
+
import { WS } from "dfx/gateway";
|
|
4
|
+
import { Discord, Effect, Option } from "dfx/_common";
|
|
8
5
|
import { opCode } from "./utils.js";
|
|
9
|
-
export const fromRaw = (raw, latestReady) =>
|
|
6
|
+
export const fromRaw = (raw, latestReady) => tsplus_module_2.map(() => WS.Reconnect)(tsplus_module_2.tap((p) => (p.d ? Effect.unit() : tsplus_module_1.set(Option.none)(latestReady)))(opCode(raw)(Discord.GatewayOpcode.INVALID_SESSION)));
|
|
10
7
|
//# sourceMappingURL=invalidSession.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"invalidSession.js","sourceRoot":"","sources":["../../../src/DiscordGateway/Shard/invalidSession.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"invalidSession.js","sourceRoot":"","sources":["../../../src/DiscordGateway/Shard/invalidSession.ts"],"names":[],"mappings":";;AAAA,OAAO,EAAa,EAAE,EAAE,MAAM,aAAa,CAAA;AAC3C,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAe,MAAM,aAAa,CAAA;AAClE,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAA;AAEnC,MAAM,CAAC,MAAM,OAAO,GAAG,CACrB,GAAgD,EAChD,WAAuD,EACvD,EAAE,CACF,oBAIO,GAAsB,EAAE,CAAC,EAAE,CAAC,SAAS,EAJ5C,oBAGO,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,oBAAgB,MAAM,CAAC,IAAI,EAA3B,WAAW,CAAiB,CAAC,EAHlE,MAAM,CAAC,GAAG,CAAC,CACT,OAAO,CAAC,aAAa,CAAC,eAAe,CACtC,CACkE,CACtB,CAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Discord } from "dfx";
|
|
1
|
+
import { Discord } from "dfx/_common";
|
|
2
2
|
export declare const heartbeat: (d: Discord.Heartbeat) => Discord.GatewayPayload;
|
|
3
3
|
export declare const identify: (d: Discord.Identify) => Discord.GatewayPayload;
|
|
4
4
|
export declare const resume: (d: Discord.Resume) => Discord.GatewayPayload;
|
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { Discord } from "dfx/_common";
|
|
2
2
|
export const heartbeat = (d) => ({
|
|
3
|
-
op:
|
|
3
|
+
op: Discord.GatewayOpcode.HEARTBEAT,
|
|
4
4
|
d,
|
|
5
5
|
});
|
|
6
6
|
export const identify = (d) => ({
|
|
7
|
-
op:
|
|
7
|
+
op: Discord.GatewayOpcode.IDENTIFY,
|
|
8
8
|
d,
|
|
9
9
|
});
|
|
10
10
|
export const resume = (d) => ({
|
|
11
|
-
op:
|
|
11
|
+
op: Discord.GatewayOpcode.RESUME,
|
|
12
12
|
d,
|
|
13
13
|
});
|
|
14
14
|
export const requestGuildMembers = (d) => ({
|
|
15
|
-
op:
|
|
15
|
+
op: Discord.GatewayOpcode.REQUEST_GUILD_MEMBERS,
|
|
16
16
|
d,
|
|
17
17
|
});
|
|
18
18
|
export const voiceStateUpdate = (d) => ({
|
|
19
|
-
op:
|
|
19
|
+
op: Discord.GatewayOpcode.VOICE_STATE_UPDATE,
|
|
20
20
|
d,
|
|
21
21
|
});
|
|
22
22
|
export const presenceUpdate = (d) => ({
|
|
23
|
-
op:
|
|
23
|
+
op: Discord.GatewayOpcode.PRESENCE_UPDATE,
|
|
24
24
|
d,
|
|
25
25
|
});
|
|
26
26
|
//# sourceMappingURL=sendEvents.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sendEvents.js","sourceRoot":"","sources":["../../../src/DiscordGateway/Shard/sendEvents.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"sendEvents.js","sourceRoot":"","sources":["../../../src/DiscordGateway/Shard/sendEvents.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AAErC,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,CAAoB,EAA0B,EAAE,CAAC,CAAC;IAC1E,EAAE,EAAE,OAAO,CAAC,aAAa,CAAC,SAAS;IACnC,CAAC;CACF,CAAC,CAAA;AAEF,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,CAAmB,EAA0B,EAAE,CAAC,CAAC;IACxE,EAAE,EAAE,OAAO,CAAC,aAAa,CAAC,QAAQ;IAClC,CAAC;CACF,CAAC,CAAA;AAEF,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,CAAiB,EAA0B,EAAE,CAAC,CAAC;IACpE,EAAE,EAAE,OAAO,CAAC,aAAa,CAAC,MAAM;IAChC,CAAC;CACF,CAAC,CAAA;AAEF,MAAM,CAAC,MAAM,mBAAmB,GAAG,CACjC,CAA6B,EACL,EAAE,CAAC,CAAC;IAC5B,EAAE,EAAE,OAAO,CAAC,aAAa,CAAC,qBAAqB;IAC/C,CAAC;CACF,CAAC,CAAA;AAEF,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAC9B,CAA2B,EACH,EAAE,CAAC,CAAC;IAC5B,EAAE,EAAE,OAAO,CAAC,aAAa,CAAC,kBAAkB;IAC5C,CAAC;CACF,CAAC,CAAA;AAEF,MAAM,CAAC,MAAM,cAAc,GAAG,CAC5B,CAAyB,EACD,EAAE,CAAC,CAAC;IAC5B,EAAE,EAAE,OAAO,CAAC,aAAa,CAAC,eAAe;IACzC,CAAC;CACF,CAAC,CAAA"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
export declare const
|
|
4
|
-
export declare const latest: <T>(f: (p: Discord.GatewayPayload) => import("../../index.js").Maybe<T>) => import("../../utils/common.js").Effect<never, never, readonly [import("../../utils/common.js").Ref<import("../../index.js").Maybe<T>>, (p: import("../../types.js").GatewayPayload<any>) => import("../../utils/common.js").Effect<never, never, void>]>;
|
|
1
|
+
import { Discord, Effect, Option, Ref, Stream } from "dfx/_common";
|
|
2
|
+
export declare const opCode: <R, E>(source: Stream.Stream<R, E, Discord.GatewayPayload<any>>) => <T = any>(code: Discord.GatewayOpcode) => Stream.Stream<R, E, Discord.GatewayPayload<T>>;
|
|
3
|
+
export declare const latest: <T>(f: (p: Discord.GatewayPayload) => Option.Option<T>) => Effect.Effect<never, never, readonly [Ref.Ref<Option.Option<T>>, (p: Discord.GatewayPayload<any>) => Effect.Effect<never, never, void>]>;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import * as tsplus_module_1 from "
|
|
2
|
-
import * as tsplus_module_2 from "@effect/io/
|
|
1
|
+
import * as tsplus_module_1 from "@effect/stream/Stream";
|
|
2
|
+
import * as tsplus_module_2 from "@effect/io/Ref";
|
|
3
3
|
import * as tsplus_module_3 from "@fp-ts/data/Option";
|
|
4
|
-
import * as tsplus_module_4 from "@effect/io/
|
|
5
|
-
import
|
|
4
|
+
import * as tsplus_module_4 from "@effect/io/Effect";
|
|
5
|
+
import { Effect, flow, Option, Ref } from "dfx/_common";
|
|
6
6
|
export const opCode = (source) => (code) => tsplus_module_1.filter((p) => p.op === code)(source);
|
|
7
|
-
const maybeUpdateRef = (f, ref) =>
|
|
8
|
-
export const latest = (f) =>
|
|
7
|
+
const maybeUpdateRef = (f, ref) => flow(f, (o) => tsplus_module_3.match(Effect.unit, (a) => tsplus_module_2.set(Option.some(a))(ref))(o));
|
|
8
|
+
export const latest = (f) => tsplus_module_4.map((ref) => [ref, maybeUpdateRef(f, ref)])(Ref.make(Option.none));
|
|
9
9
|
//# sourceMappingURL=utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/DiscordGateway/Shard/utils.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/DiscordGateway/Shard/utils.ts"],"names":[],"mappings":";;;;AAAA,OAAO,EAAW,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,EAAU,MAAM,aAAa,CAAA;AAExE,MAAM,CAAC,MAAM,MAAM,GACjB,CAAO,MAAmD,EAAE,EAAE,CAC9D,CAAU,IAA2B,EAAE,EAAE,CACvC,uBAAc,CAAC,CAAC,EAAkC,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,IAAI,EAAlE,MAAM,CAA6D,CAAA;AAEvE,MAAM,cAAc,GAAG,CACrB,CAAkD,EAClD,GAA8B,EAC9B,EAAE,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,sBAAQ,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,oBAAQ,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAtB,GAAG,CAAoB,EAAnD,CAAC,CAAmD,CAAC,CAAA;AAEzE,MAAM,CAAC,MAAM,MAAM,GAAG,CAAI,CAAkD,EAAE,EAAE,CAC9E,oBACE,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,GAAG,EAAE,cAAc,CAAC,CAAC,EAAE,GAAG,CAAC,CAAU,EADjD,GAAG,CAAC,IAAI,CAAmB,MAAM,CAAC,IAAI,CAAC,CAEtC,CAAA"}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { Effect,
|
|
1
|
+
import { Context, Effect, Layer, Option } from "dfx/_common";
|
|
2
2
|
export interface ClaimIdContext {
|
|
3
3
|
sharderCount: number;
|
|
4
4
|
totalCount: number;
|
|
5
5
|
}
|
|
6
6
|
export interface ShardStore {
|
|
7
|
-
claimId: (ctx: ClaimIdContext) => Effect<never, never,
|
|
8
|
-
allClaimed: (totalCount: number) => Effect<never, never, boolean>;
|
|
9
|
-
heartbeat?: (shardId: number) => Effect<never, never, void>;
|
|
7
|
+
claimId: (ctx: ClaimIdContext) => Effect.Effect<never, never, Option.Option<number>>;
|
|
8
|
+
allClaimed: (totalCount: number) => Effect.Effect<never, never, boolean>;
|
|
9
|
+
heartbeat?: (shardId: number) => Effect.Effect<never, never, void>;
|
|
10
10
|
}
|
|
11
|
-
export declare const ShardStore:
|
|
12
|
-
export declare const LiveMemoryShardStore:
|
|
11
|
+
export declare const ShardStore: Context.Tag<ShardStore>;
|
|
12
|
+
export declare const LiveMemoryShardStore: Layer.Layer<never, never, ShardStore>;
|
|
@@ -1,22 +1,19 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
import * as tsplus_module_3 from "@effect/io/Effect";
|
|
4
|
-
import * as tsplus_module_4 from "@effect/io/Layer";
|
|
5
|
-
export const ShardStore = tsplus_module_1.Tag();
|
|
1
|
+
import { Context, Effect, Layer, Option } from "dfx/_common";
|
|
2
|
+
export const ShardStore = Context.Tag();
|
|
6
3
|
// Very basic shard id store, that does no health checks
|
|
7
4
|
const memoryStore = () => {
|
|
8
5
|
let currentId = 0;
|
|
9
6
|
return {
|
|
10
|
-
claimId: ({ totalCount }) =>
|
|
7
|
+
claimId: ({ totalCount }) => Effect.sync(() => {
|
|
11
8
|
if (currentId >= totalCount) {
|
|
12
|
-
return
|
|
9
|
+
return Option.none;
|
|
13
10
|
}
|
|
14
11
|
const id = currentId;
|
|
15
12
|
currentId++;
|
|
16
|
-
return
|
|
13
|
+
return Option.some(id);
|
|
17
14
|
}),
|
|
18
|
-
allClaimed: (totalCount) =>
|
|
15
|
+
allClaimed: (totalCount) => Effect.sync(() => currentId >= totalCount),
|
|
19
16
|
};
|
|
20
17
|
};
|
|
21
|
-
export const LiveMemoryShardStore =
|
|
18
|
+
export const LiveMemoryShardStore = Layer.sync(ShardStore)(memoryStore);
|
|
22
19
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/DiscordGateway/ShardStore/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/DiscordGateway/ShardStore/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAc5D,MAAM,CAAC,MAAM,UAAU,GAAG,OAAO,CAAC,GAAG,EAAc,CAAA;AAEnD,wDAAwD;AACxD,MAAM,WAAW,GAAG,GAAe,EAAE;IACnC,IAAI,SAAS,GAAG,CAAC,CAAA;IAEjB,OAAO;QACL,OAAO,EAAE,CAAC,EAAE,UAAU,EAAE,EAAE,EAAE,CAC1B,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE;YACf,IAAI,SAAS,IAAI,UAAU,EAAE;gBAC3B,OAAO,MAAM,CAAC,IAAI,CAAA;aACnB;YAED,MAAM,EAAE,GAAG,SAAS,CAAA;YACpB,SAAS,EAAE,CAAA;YACX,OAAO,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;QACxB,CAAC,CAAC;QAEJ,UAAU,EAAE,CAAC,UAAU,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,SAAS,IAAI,UAAU,CAAC;KACvE,CAAA;AACH,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,oBAAoB,GAAG,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,WAAW,CAAC,CAAA"}
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Discord } from "dfx";
|
|
1
|
+
import { Config, DiscordREST, RateLimiter } from "dfx";
|
|
3
2
|
import { Success } from "dfx/utils/effect";
|
|
3
|
+
import { Context, Discord, Effect, Layer, Scope, Stream } from "dfx/_common";
|
|
4
4
|
import { ShardStore } from "../ShardStore/index.js";
|
|
5
|
-
declare const make:
|
|
6
|
-
shards:
|
|
7
|
-
run:
|
|
8
|
-
raw:
|
|
9
|
-
dispatch:
|
|
10
|
-
send: (p:
|
|
11
|
-
reconnect:
|
|
5
|
+
declare const make: Effect.Effect<Scope.Scope | DiscordREST | Config.DiscordConfig | import("../../Log/index.js").Log | RateLimiter | import("../DiscordWS/index.js").DiscordWSCodec | ShardStore, never, {
|
|
6
|
+
shards: Stream.Stream<never, never, {
|
|
7
|
+
run: Effect.Effect<never, never, void>;
|
|
8
|
+
raw: Stream.Stream<never, never, Discord.GatewayPayload<any>>;
|
|
9
|
+
dispatch: Stream.Stream<never, never, Discord.GatewayPayload<Discord.ReceiveEvent>>;
|
|
10
|
+
send: (p: Discord.GatewayPayload<any>) => Effect.Effect<never, never, boolean>;
|
|
11
|
+
reconnect: Effect.Effect<never, never, boolean>;
|
|
12
12
|
}>;
|
|
13
13
|
}>;
|
|
14
14
|
export interface Sharder extends Success<typeof make> {
|
|
15
15
|
}
|
|
16
|
-
export declare const Sharder:
|
|
17
|
-
export declare const LiveSharder:
|
|
16
|
+
export declare const Sharder: Context.Tag<Sharder>;
|
|
17
|
+
export declare const LiveSharder: Layer.Layer<DiscordREST | Config.DiscordConfig | import("../../Log/index.js").Log | RateLimiter | import("../DiscordWS/index.js").DiscordWSCodec | ShardStore, never, Sharder>;
|
|
18
18
|
export {};
|
|
@@ -1,50 +1,29 @@
|
|
|
1
|
-
import * as tsplus_module_1 from "
|
|
2
|
-
import * as tsplus_module_2 from "
|
|
3
|
-
import * as tsplus_module_3 from "
|
|
4
|
-
import * as tsplus_module_4 from "
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import * as tsplus_module_8 from "callbag-effect-ts/Source/mapEffect";
|
|
9
|
-
import * as tsplus_module_9 from "callbag-effect-ts/Source/map";
|
|
10
|
-
import * as tsplus_module_10 from "callbag-effect-ts/Source/groupBy";
|
|
11
|
-
import * as tsplus_module_11 from "callbag-effect-ts/Source/chainPar";
|
|
12
|
-
import * as tsplus_module_12 from "callbag-effect-ts/Source/share";
|
|
13
|
-
import * as tsplus_module_13 from "@fp-ts/data/Duration";
|
|
14
|
-
import * as tsplus_module_14 from "@fp-ts/data/Option";
|
|
15
|
-
import * as tsplus_module_15 from "callbag-effect-ts/Source/empty";
|
|
16
|
-
import * as tsplus_module_16 from "callbag-effect-ts/Source/resource";
|
|
17
|
-
import * as tsplus_module_17 from "dfx";
|
|
18
|
-
import * as tsplus_module_18 from "dfx/utils/common";
|
|
19
|
-
import { millis } from "@fp-ts/data/Duration";
|
|
20
|
-
import { overridePull } from "callbag-effect-ts/Source";
|
|
1
|
+
import * as tsplus_module_1 from "@effect/stream/Stream";
|
|
2
|
+
import * as tsplus_module_2 from "@effect/stream/GroupBy";
|
|
3
|
+
import * as tsplus_module_3 from "@effect/io/Effect";
|
|
4
|
+
import * as tsplus_module_4 from "@fp-ts/data/Option";
|
|
5
|
+
import { Config, DiscordREST, RateLimiter } from "dfx";
|
|
6
|
+
import { Shard } from "dfx/gateway";
|
|
7
|
+
import { Context, Duration, Effect, Layer, Option, Scope, Stream, } from "dfx/_common";
|
|
21
8
|
import { ShardStore } from "../ShardStore/index.js";
|
|
22
|
-
const
|
|
9
|
+
const _scope = Scope.ScopeTypeId;
|
|
10
|
+
const make = tsplus_module_3.flatMap(store => tsplus_module_3.flatMap(rest => tsplus_module_3.flatMap(({ gateway: config }) => tsplus_module_3.flatMap(limiter => {
|
|
23
11
|
const configs = (totalCount) => {
|
|
24
|
-
const claimId = (sharderCount) =>
|
|
25
|
-
tsplus_module_14.some(sharderCount),
|
|
26
|
-
tsplus_module_15.empty,
|
|
27
|
-
])), (id) => tsplus_module_5.succeed([
|
|
28
|
-
tsplus_module_14.some(sharderCount + 1),
|
|
29
|
-
tsplus_module_3.of(id),
|
|
30
|
-
]))(a))(store
|
|
12
|
+
const claimId = (sharderCount) => tsplus_module_3.flatMap((a) => tsplus_module_4.match(() => tsplus_module_3.delay(Duration.minutes(3))(claimId(sharderCount)), (id) => Effect.succeed(id))(a))(store
|
|
31
13
|
.claimId({
|
|
32
14
|
totalCount,
|
|
33
15
|
sharderCount,
|
|
34
16
|
}));
|
|
35
|
-
return
|
|
17
|
+
return tsplus_module_1.map((id) => ({
|
|
36
18
|
id,
|
|
37
19
|
totalCount,
|
|
38
|
-
}))(
|
|
20
|
+
}))(Stream.unfoldEffect(0, (sharderCount) => tsplus_module_3.map((id) => Option.some([id, sharderCount + 1]))(claimId(sharderCount))));
|
|
39
21
|
};
|
|
40
|
-
return
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
concurrency: gateway.session_start_limit.max_concurrency,
|
|
46
|
-
}))(source)))))));
|
|
47
|
-
})(tsplus_module_5.catchAll(() => tsplus_module_5.succeed({
|
|
22
|
+
return tsplus_module_3.flatMap(gateway => tsplus_module_3.map(shards => ({ shards }))(tsplus_module_1.broadcastDynamic(1)(tsplus_module_1.flatMap((shard) => tsplus_module_1.merge(tsplus_module_1.drain(Stream.fromEffect(shard.run)))(Stream.succeed(shard)))(tsplus_module_2.evaluate((key, shardConfig) => tsplus_module_1.mapEffect((c) => Shard.make([c.id, c.totalCount]))(tsplus_module_1.tap(() => limiter.maybeWait(`dfx.sharder.${key}`, Duration.millis(config.identifyRateLimit[0]), config.identifyRateLimit[1]))(shardConfig)))(tsplus_module_1.groupBy((c) => Effect.succeed([c.id % c.concurrency, c]))(tsplus_module_1.map((config) => ({
|
|
23
|
+
...config,
|
|
24
|
+
url: gateway.url,
|
|
25
|
+
concurrency: gateway.session_start_limit.max_concurrency,
|
|
26
|
+
}))(configs(config.shardCount ?? gateway.shards))))))))(tsplus_module_3.catchAll(() => Effect.succeed({
|
|
48
27
|
url: "wss://gateway.discord.gg/",
|
|
49
28
|
shards: 1,
|
|
50
29
|
session_start_limit: {
|
|
@@ -53,9 +32,9 @@ const make = tsplus_module_5.flatMap(store => tsplus_module_5.flatMap(rest => ts
|
|
|
53
32
|
reset_after: 0,
|
|
54
33
|
max_concurrency: 1,
|
|
55
34
|
},
|
|
56
|
-
}))(
|
|
35
|
+
}))(tsplus_module_3.flatMap((r) => r.json)(rest
|
|
57
36
|
.getGatewayBot())));
|
|
58
|
-
})(
|
|
59
|
-
export const Sharder =
|
|
60
|
-
export const LiveSharder =
|
|
37
|
+
})(Effect.service(RateLimiter)))(Effect.service(Config.DiscordConfig)))(Effect.service(DiscordREST)))(Effect.service(ShardStore));
|
|
38
|
+
export const Sharder = Context.Tag();
|
|
39
|
+
export const LiveSharder = Layer.scoped(Sharder)(make);
|
|
61
40
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/DiscordGateway/Sharder/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/DiscordGateway/Sharder/index.ts"],"names":[],"mappings":";;;;AAAA,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,KAAK,CAAA;AACtD,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AAEnC,OAAO,EACL,OAAO,EAEP,QAAQ,EACR,MAAM,EACN,KAAK,EACL,MAAM,EACN,KAAK,EACL,MAAM,GACP,MAAM,aAAa,CAAA;AACpB,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AAEnD,MAAM,MAAM,GAAG,KAAK,CAAC,WAAW,CAAA;AAEhC,MAAM,IAAI,2BACF,KAAK,4BACL,IAAI,6BACJ,EAAE,OAAO,EAAE,MAAM,EAAE,6BACnB,OAAO;IAEb,MAAM,OAAO,GAAG,CAAC,UAAkB,EAAE,EAAE;QACrC,MAAM,OAAO,GAAG,CACd,YAAoB,EACiB,EAAE,CACvC,wBAKW,CAAC,CAAC,EAAE,EAAE,CACb,sBACE,GAAG,EAAE,CAAC,sBAA4B,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,EAA/C,OAAO,CAAC,YAAY,CAAC,CAA2B,EACtD,CAAC,EAAE,EAAE,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC,EAF5B,CAAC,CAGA,EATL,KAAK;aACF,OAAO,CAAC;YACP,UAAU;YACV,YAAY;SACb,CAAC,CAMD,CAAA;QAEL,OAAO,oBAID,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;YACb,EAAE;YACF,UAAU;SACX,CAAC,EAPK,MAAM,CAAC,YAAY,CAAC,CAAC,EAAE,CAAC,YAAY,EAAE,EAAE,CAC7C,oBAA0B,CAAC,EAAE,EAAE,EAAE,CAC/B,MAAM,CAAC,IAAI,CAAC,CAAC,EAAE,EAAE,YAAY,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ChC,MAAM,EAAE,CAAC;QACT,mBAAmB,EAAE;YACnB,KAAK,EAAE,CAAC;YACR,SAAS,EAAE,CAAC;YACZ,WAAW,EAAE,CAAC;YACd,eAAe,EAAE,CAAC;SACnB;KACF,CAAC,EAbN,wBAEW,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAFxB,IAAI;SACD,aAAa,EAAE,CACO,CAYtB;GA3Ca,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,GADf,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,aAAa,CAAC,GADnD,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,GAD1B,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,CA2E1C,CAAA;AAGF,MAAM,CAAC,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,EAAW,CAAA;AAC7C,MAAM,CAAC,MAAM,WAAW,GAAG,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAA"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/// <reference types="node" resolution-mode="require"/>
|
|
2
2
|
/// <reference types="ws" />
|
|
3
|
-
import {
|
|
3
|
+
import { Log } from "dfx/Log/index";
|
|
4
|
+
import { Effect, Ref, Stream } from "dfx/_common";
|
|
4
5
|
import WebSocket from "isomorphic-ws";
|
|
5
6
|
export declare const Reconnect: unique symbol;
|
|
6
7
|
export type Reconnect = typeof Reconnect;
|
|
@@ -16,4 +17,4 @@ export declare class WebSocketCloseError {
|
|
|
16
17
|
readonly _tag = "WebSocketCloseError";
|
|
17
18
|
constructor(code: number, reason: string);
|
|
18
19
|
}
|
|
19
|
-
export declare const make: (url: Ref<string>, takeOutbound: Effect<never, never, Message>) =>
|
|
20
|
+
export declare const make: (url: Ref.Ref<string>, takeOutbound: Effect.Effect<never, never, Message>) => Stream.Stream<Log, WebSocketError | WebSocketCloseError, WebSocket.Data>;
|
|
@@ -1,20 +1,10 @@
|
|
|
1
1
|
import * as tsplus_module_1 from "@effect/io/Effect";
|
|
2
2
|
import * as tsplus_module_2 from "@effect/io/Ref";
|
|
3
|
-
import * as tsplus_module_3 from "
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import * as tsplus_module_6 from "callbag-effect-ts/Source/tap";
|
|
7
|
-
import * as tsplus_module_7 from "callbag-effect-ts/Source/drain";
|
|
8
|
-
import * as tsplus_module_8 from "dfx";
|
|
9
|
-
import * as tsplus_module_9 from "@effect/io/Schedule";
|
|
10
|
-
import * as tsplus_module_10 from "callbag-effect-ts/Source/merge";
|
|
11
|
-
import * as tsplus_module_11 from "callbag-effect-ts/Source/unwrapScope";
|
|
12
|
-
import * as tsplus_module_12 from "callbag-effect-ts/Source/retry";
|
|
3
|
+
import * as tsplus_module_3 from "@effect/stream/Stream";
|
|
4
|
+
import { Log } from "dfx/Log/index";
|
|
5
|
+
import { Effect, pipe, Schedule, Stream } from "dfx/_common";
|
|
13
6
|
import WebSocket from "isomorphic-ws";
|
|
14
7
|
export const Reconnect = Symbol();
|
|
15
|
-
const socket = (urlRef) => tsplus_module_1.acquireRelease(tsplus_module_1.map(url => new WebSocket(url))(tsplus_module_2.get(urlRef)), (ws) => tsplus_module_1.sync(() => {
|
|
16
|
-
ws.close();
|
|
17
|
-
}));
|
|
18
8
|
export class WebSocketError {
|
|
19
9
|
reason;
|
|
20
10
|
_tag = "WebSocketError";
|
|
@@ -31,9 +21,21 @@ export class WebSocketCloseError {
|
|
|
31
21
|
this.reason = reason;
|
|
32
22
|
}
|
|
33
23
|
}
|
|
34
|
-
const
|
|
24
|
+
const socket = (urlRef) => tsplus_module_1.acquireRelease(tsplus_module_1.flatMap(url => {
|
|
25
|
+
const ws = new WebSocket(url);
|
|
26
|
+
return tsplus_module_1.map(() => ws)(Effect.async((resume) => {
|
|
27
|
+
ws.addEventListener("open", () => resume(Effect.unit()), {
|
|
28
|
+
once: true,
|
|
29
|
+
});
|
|
30
|
+
}));
|
|
31
|
+
})(tsplus_module_2.get(urlRef)), (ws) => Effect.sync(() => {
|
|
32
|
+
;
|
|
33
|
+
ws.removeAllListeners?.();
|
|
34
|
+
ws.close();
|
|
35
|
+
}));
|
|
36
|
+
const recv = (ws) => Stream.asyncEffect((emit) => Effect.sync(() => {
|
|
35
37
|
ws.addEventListener("message", (message) => {
|
|
36
|
-
emit.
|
|
38
|
+
emit.single(message.data);
|
|
37
39
|
});
|
|
38
40
|
ws.addEventListener("error", (cause) => {
|
|
39
41
|
emit.fail(new WebSocketError(cause));
|
|
@@ -41,32 +43,20 @@ const recv = (ws) => tsplus_module_3.async((emit) => {
|
|
|
41
43
|
ws.addEventListener("close", (e) => {
|
|
42
44
|
emit.fail(new WebSocketCloseError(e.code, e.reason));
|
|
43
45
|
});
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
ws.removeAllListeners?.();
|
|
47
|
-
};
|
|
48
|
-
});
|
|
49
|
-
const send = (ws, take) => tsplus_module_1.map(log => tsplus_module_7.drain(tsplus_module_6.tap((data) => tsplus_module_1.async((resume) => {
|
|
46
|
+
}));
|
|
47
|
+
const send = (ws, take, log) => tsplus_module_1.forever(tsplus_module_1.tap((data) => {
|
|
50
48
|
if (data === Reconnect) {
|
|
51
|
-
|
|
52
|
-
|
|
49
|
+
return Effect.failSync(() => {
|
|
50
|
+
ws.close(1012, "reconnecting");
|
|
51
|
+
return new WebSocketCloseError(1012, "reconnecting");
|
|
52
|
+
});
|
|
53
53
|
}
|
|
54
|
-
|
|
54
|
+
return Effect.sync(() => {
|
|
55
55
|
ws.send(data);
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
else {
|
|
63
|
-
ws.addEventListener("open", () => {
|
|
64
|
-
resume(tsplus_module_1.unit());
|
|
65
|
-
}, { once: true });
|
|
66
|
-
}
|
|
67
|
-
})))))))(tsplus_module_1.service(tsplus_module_8.Log.Log));
|
|
68
|
-
export const make = (url, takeOutbound) => tsplus_module_1.map(log => {
|
|
69
|
-
const withLog = tsplus_module_1.provideService(tsplus_module_8.Log.Log)(log);
|
|
70
|
-
return tsplus_module_12.retry(tsplus_module_9.recurWhile((e) => e._tag === "WebSocketCloseError" && e.code === 1012))(tsplus_module_11.unwrapScope(tsplus_module_1.flatMap(ws => tsplus_module_1.map(sendEffect => tsplus_module_10.merge(sendEffect)(recv(ws)))(withLog(send(ws, takeOutbound))))(socket(url))));
|
|
71
|
-
})(tsplus_module_1.service(tsplus_module_8.Log.Log));
|
|
56
|
+
});
|
|
57
|
+
})(tsplus_module_1.tap((data) => log.debug("WS", "send", data))(take)));
|
|
58
|
+
export const make = (url, takeOutbound) => pipe(tsplus_module_1.flatMap(log => tsplus_module_1.map(ws => {
|
|
59
|
+
const sendEffect = send(ws, takeOutbound, log);
|
|
60
|
+
return tsplus_module_3.retry(Schedule.recurWhile((e) => e._tag === "WebSocketCloseError" && e.code === 1012))(tsplus_module_3.merge(Stream.fromEffect(sendEffect))(recv(ws)));
|
|
61
|
+
})(socket(url)))(Effect.service(Log)), Stream.unwrapScoped);
|
|
72
62
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/DiscordGateway/WS/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/DiscordGateway/WS/index.ts"],"names":[],"mappings":";;;AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAA;AACnC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAO,QAAQ,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACjE,OAAO,SAAS,MAAM,eAAe,CAAA;AAErC,MAAM,CAAC,MAAM,SAAS,GAAG,MAAM,EAAE,CAAA;AAIjC,MAAM,OAAO,cAAc;IAEJ;IADZ,IAAI,GAAG,gBAAgB,CAAA;IAChC,YAAqB,MAAe;QAAf,WAAM,GAAN,MAAM,CAAS;IA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CAAC,UAAU,CAAC,EAD/B,IAAI,CAAC,EAAE,CAAC,CACwB,CAKpC,CAAA;GATU,MAAM,CAAC,GAAG,CAAC,GADV,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,GAYnC,MAAM,CAAC,YAAY,CACpB,CAAA"}
|
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
import { EffectSource, Effect } from "dfx/utils/common";
|
|
2
|
-
import { Discord } from "dfx";
|
|
3
1
|
import { Success } from "dfx/utils/effect";
|
|
2
|
+
import { Context, Discord, Effect, Layer, Scope, Stream } from "dfx/_common";
|
|
4
3
|
import { Sharder } from "./Sharder/index.js";
|
|
5
|
-
export declare const make:
|
|
6
|
-
raw:
|
|
7
|
-
dispatch:
|
|
8
|
-
fromDispatch: <K extends keyof
|
|
9
|
-
handleDispatch: <K_1 extends keyof
|
|
4
|
+
export declare const make: Effect.Effect<Scope.Scope | Sharder, never, {
|
|
5
|
+
raw: Stream.Stream<never, never, Discord.GatewayPayload<any>>;
|
|
6
|
+
dispatch: Stream.Stream<never, never, Discord.GatewayPayload<Discord.ReceiveEvent>>;
|
|
7
|
+
fromDispatch: <K extends keyof Discord.ReceiveEvents>(event: K) => Stream.Stream<never, never, Discord.ReceiveEvents[K]>;
|
|
8
|
+
handleDispatch: <K_1 extends keyof Discord.ReceiveEvents, R1, E1, A>(event: K_1, handle: (event: Discord.ReceiveEvents[K_1]) => Effect.Effect<R1, E1, A>) => Effect.Effect<R1, E1, void>;
|
|
10
9
|
}>;
|
|
11
10
|
export interface DiscordGateway extends Success<typeof make> {
|
|
12
11
|
}
|
|
13
|
-
export declare const DiscordGateway:
|
|
14
|
-
export declare const LiveDiscordGateway:
|
|
12
|
+
export declare const DiscordGateway: Context.Tag<DiscordGateway>;
|
|
13
|
+
export declare const LiveDiscordGateway: Layer.Layer<Sharder, never, DiscordGateway>;
|
package/DiscordGateway/index.js
CHANGED
|
@@ -1,16 +1,11 @@
|
|
|
1
|
-
import * as tsplus_module_1 from "
|
|
2
|
-
import * as tsplus_module_2 from "
|
|
3
|
-
import
|
|
4
|
-
import * as tsplus_module_4 from "callbag-effect-ts/Source/chainPar";
|
|
5
|
-
import * as tsplus_module_5 from "callbag-effect-ts/Source/run";
|
|
6
|
-
import * as tsplus_module_6 from "callbag-effect-ts/Source/share";
|
|
7
|
-
import * as tsplus_module_7 from "@effect/io/Effect";
|
|
8
|
-
import * as tsplus_module_8 from "dfx/utils/common";
|
|
9
|
-
import * as tsplus_module_9 from "@effect/io/Layer";
|
|
1
|
+
import * as tsplus_module_1 from "@effect/stream/Stream";
|
|
2
|
+
import * as tsplus_module_2 from "@effect/io/Effect";
|
|
3
|
+
import { Context, Effect, Layer, pipe, Scope, Stream, } from "dfx/_common";
|
|
10
4
|
import { Sharder } from "./Sharder/index.js";
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
|
|
5
|
+
const _scope = Scope.ScopeTypeId;
|
|
6
|
+
const fromDispatchFactory = (source) => (event) => tsplus_module_1.map((p) => p.d)(tsplus_module_1.filter((p) => p.t === event)(source));
|
|
7
|
+
const handleDispatchFactory = (source) => (event, handle) => tsplus_module_1.runDrain(pipe(tsplus_module_1.filter((p) => p.t === event)(source), Stream.flatMapPar(128)((a) => Stream.fromEffect(handle(a.d)))));
|
|
8
|
+
export const make = tsplus_module_2.flatMap(sharder => tsplus_module_2.flatMap(raw => tsplus_module_2.map(dispatch => {
|
|
14
9
|
const fromDispatch = fromDispatchFactory(dispatch);
|
|
15
10
|
const handleDispatch = handleDispatchFactory(dispatch);
|
|
16
11
|
return {
|
|
@@ -19,7 +14,7 @@ export const make = tsplus_module_7.flatMap(sharder => tsplus_module_7.flatMap(r
|
|
|
19
14
|
fromDispatch,
|
|
20
15
|
handleDispatch,
|
|
21
16
|
};
|
|
22
|
-
})(
|
|
23
|
-
export const DiscordGateway =
|
|
24
|
-
export const LiveDiscordGateway =
|
|
17
|
+
})(tsplus_module_1.broadcastDynamic(1)(pipe(sharder.shards, Stream.flatMapPar(1024)((s) => s.dispatch)))))(tsplus_module_1.broadcastDynamic(1)(pipe(sharder.shards, Stream.flatMapPar(1024)((s) => s.raw)))))(Effect.service(Sharder));
|
|
18
|
+
export const DiscordGateway = Context.Tag();
|
|
19
|
+
export const LiveDiscordGateway = Layer.scoped(DiscordGateway)(make);
|
|
25
20
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/DiscordGateway/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/DiscordGateway/index.ts"],"names":[],"mappings":";;AACA,OAAO,EACL,OAAO,EAEP,MAAM,EACN,KAAK,EACL,IAAI,EACJ,KAAK,EACL,MAAM,GACP,MAAM,aAAa,CAAA;AACpB,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAA;AAE5C,MAAM,MAAM,GAAG,KAAK,CAAC,WAAW,CAAA;AAEhC,MAAM,mBAAmB,GACvB,CACE,MAAyE,EACzE,EAAE,CACJ,CACE,KAAQ,EACuC,EAAE,CACjD,oBAAwC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAS,EAA1D,uBAAc,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,KAAK,KAAK,EAAlC,MAAM,CAA6B,CAAwB,CAAA;AAE/D,MAAM,qBAAqB,GACzB,CACE,MAAyE,EACzE,EAAE,CACJ,CACE,KAAQ,EACR,MAAqE,EAChC,EAAE,0BACvC,IAAI,CACF,uBAAc,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,KAAK,KAAK,EAAlC,MAAM,CAA6B,EACnC,MAAM,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,CAAQ,CAAC,CAAC,CAAC,CACrE,CAAS,CAAA;AAEd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