dfx 0.21.5 → 0.21.6
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 +2 -3
- package/Cache/index.js.map +1 -1
- package/Cache/memory.d.ts +3 -3
- package/Cache/memory.js +19 -18
- package/Cache/memory.js.map +1 -1
- package/Cache/memoryTTL.d.ts +5 -5
- package/Cache/memoryTTL.js +15 -15
- package/Cache/memoryTTL.js.map +1 -1
- package/Cache/prelude.d.ts +37 -37
- package/Cache/prelude.js +5 -6
- package/Cache/prelude.js.map +1 -1
- package/DiscordConfig/index.d.ts +4 -4
- package/DiscordConfig/index.js +8 -5
- package/DiscordConfig/index.js.map +1 -1
- package/DiscordGateway/DiscordWS/index.d.ts +8 -9
- package/DiscordGateway/DiscordWS/index.js +19 -16
- package/DiscordGateway/DiscordWS/index.js.map +1 -1
- package/DiscordGateway/Shard/heartbeats.d.ts +3 -3
- package/DiscordGateway/Shard/heartbeats.js +12 -10
- package/DiscordGateway/Shard/heartbeats.js.map +1 -1
- package/DiscordGateway/Shard/identify.d.ts +4 -5
- package/DiscordGateway/Shard/identify.js +4 -4
- package/DiscordGateway/Shard/identify.js.map +1 -1
- package/DiscordGateway/Shard/index.d.ts +7 -8
- package/DiscordGateway/Shard/index.js +17 -17
- package/DiscordGateway/Shard/index.js.map +1 -1
- package/DiscordGateway/Shard/invalidSession.d.ts +2 -2
- package/DiscordGateway/Shard/invalidSession.js +7 -5
- package/DiscordGateway/Shard/invalidSession.js.map +1 -1
- package/DiscordGateway/Shard/utils.d.ts +3 -3
- package/DiscordGateway/Shard/utils.js +5 -5
- package/DiscordGateway/Shard/utils.js.map +1 -1
- package/DiscordGateway/ShardStore/index.d.ts +6 -6
- package/DiscordGateway/ShardStore/index.js +10 -7
- package/DiscordGateway/ShardStore/index.js.map +1 -1
- package/DiscordGateway/Sharder/index.d.ts +10 -12
- package/DiscordGateway/Sharder/index.js +15 -14
- package/DiscordGateway/Sharder/index.js.map +1 -1
- package/DiscordGateway/WS/index.d.ts +3 -3
- package/DiscordGateway/WS/index.js +12 -11
- package/DiscordGateway/WS/index.js.map +1 -1
- package/DiscordGateway/index.d.ts +8 -8
- package/DiscordGateway/index.js +9 -8
- package/DiscordGateway/index.js.map +1 -1
- package/DiscordREST/index.d.ts +136 -136
- package/DiscordREST/index.js +39 -36
- package/DiscordREST/index.js.map +1 -1
- package/DiscordREST/types.d.ts +4 -4
- package/DiscordREST/utils.d.ts +4 -5
- package/DiscordREST/utils.js +5 -5
- package/DiscordREST/utils.js.map +1 -1
- package/Helpers/intents.js +9 -8
- package/Helpers/intents.js.map +1 -1
- package/Helpers/interactions.d.ts +18 -18
- package/Helpers/interactions.js +23 -22
- package/Helpers/interactions.js.map +1 -1
- package/Helpers/members.d.ts +3 -3
- package/Helpers/members.js.map +1 -1
- package/Helpers/permissions.d.ts +4 -5
- package/Helpers/permissions.js +14 -13
- package/Helpers/permissions.js.map +1 -1
- package/Http/index.d.ts +9 -10
- package/Http/index.js +8 -7
- package/Http/index.js.map +1 -1
- package/Interactions/context.d.ts +23 -22
- package/Interactions/context.js +25 -22
- package/Interactions/context.js.map +1 -1
- package/Interactions/definitions.d.ts +29 -30
- package/Interactions/definitions.js +2 -1
- package/Interactions/definitions.js.map +1 -1
- package/Interactions/gateway.d.ts +3 -4
- package/Interactions/gateway.js +6 -6
- package/Interactions/gateway.js.map +1 -1
- package/Interactions/handlers.d.ts +2 -2
- package/Interactions/handlers.js +18 -17
- package/Interactions/handlers.js.map +1 -1
- package/Interactions/index.d.ts +7 -7
- package/Interactions/index.js +7 -8
- package/Interactions/index.js.map +1 -1
- package/Interactions/webhook.d.ts +7 -7
- package/Interactions/webhook.js +13 -11
- package/Interactions/webhook.js.map +1 -1
- package/Log/index.d.ts +8 -8
- package/Log/index.js +11 -9
- package/Log/index.js.map +1 -1
- package/RateLimit/index.d.ts +12 -13
- package/RateLimit/index.js +12 -11
- package/RateLimit/index.js.map +1 -1
- package/RateLimit/memory.js +7 -7
- package/RateLimit/memory.js.map +1 -1
- package/RateLimit/utils.d.ts +1 -1
- package/RateLimit/utils.js.map +1 -1
- package/_common.d.ts +22 -18
- package/_common.js +0 -18
- package/_common.js.map +1 -1
- package/gateway.d.ts +6 -7
- package/gateway.js +0 -2
- package/gateway.js.map +1 -1
- package/global.d.ts +21 -0
- package/global.js +2 -0
- package/global.js.map +1 -0
- package/package.json +3 -3
- package/utils/effect.d.ts +9 -8
- package/utils/effect.js +4 -4
- package/utils/effect.js.map +1 -1
- package/webhooks.d.ts +4 -5
- package/webhooks.js +3 -5
- package/webhooks.js.map +1 -1
|
@@ -1,23 +1,22 @@
|
|
|
1
1
|
/// <reference types="ws" />
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { Discord, Effect, Stream } from "dfx/_common";
|
|
3
|
+
import { WS } from "dfx/gateway";
|
|
4
4
|
import WebSocket from "isomorphic-ws";
|
|
5
|
-
import * as WS from "../WS/index.js";
|
|
6
5
|
export type Message = Discord.GatewayPayload | WS.Reconnect;
|
|
7
6
|
export interface OpenOpts {
|
|
8
7
|
url?: string;
|
|
9
8
|
version?: number;
|
|
10
9
|
encoding?: DiscordWSCodec;
|
|
11
|
-
outbound: Effect
|
|
10
|
+
outbound: Effect<never, never, Message>;
|
|
12
11
|
}
|
|
13
12
|
export interface DiscordWSCodec {
|
|
14
13
|
type: "json" | "etf";
|
|
15
14
|
encode: (p: Discord.GatewayPayload) => string;
|
|
16
15
|
decode: (p: WebSocket.Data) => Discord.GatewayPayload;
|
|
17
16
|
}
|
|
18
|
-
export declare const DiscordWSCodec:
|
|
19
|
-
export declare const LiveJsonDiscordWSCodec:
|
|
20
|
-
export declare const make: ({ url, version, outbound, }: OpenOpts) =>
|
|
21
|
-
source:
|
|
22
|
-
setUrl: (url: string) =>
|
|
17
|
+
export declare const DiscordWSCodec: import("../../_common.js").Tag<DiscordWSCodec>;
|
|
18
|
+
export declare const LiveJsonDiscordWSCodec: import("../../_common.js").Layer<never, never, DiscordWSCodec>;
|
|
19
|
+
export declare const make: ({ url, version, outbound, }: OpenOpts) => import("../../_common.js").Effect<import("../../Log/index.js").Log | DiscordWSCodec, never, {
|
|
20
|
+
source: import("../../_common.js").Stream<never, never, import("../../types.js").GatewayPayload<any>>;
|
|
21
|
+
setUrl: (url: string) => import("../../_common.js").Effect<never, never, void>;
|
|
23
22
|
}>;
|
|
@@ -1,22 +1,25 @@
|
|
|
1
|
-
import * as tsplus_module_1 from "
|
|
2
|
-
import * as tsplus_module_2 from "@effect/io/
|
|
3
|
-
import * as tsplus_module_3 from "@
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import * as
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import * as tsplus_module_1 from "dfx/_common";
|
|
2
|
+
import * as tsplus_module_2 from "@effect/io/Layer";
|
|
3
|
+
import * as tsplus_module_3 from "@fp-ts/data/Duration";
|
|
4
|
+
import * as tsplus_module_4 from "@effect/io/Schedule";
|
|
5
|
+
import * as tsplus_module_5 from "@effect/stream/Stream";
|
|
6
|
+
import * as tsplus_module_6 from "dfx/gateway";
|
|
7
|
+
import * as tsplus_module_7 from "dfx";
|
|
8
|
+
import * as tsplus_module_8 from "@effect/io/Effect";
|
|
9
|
+
import * as tsplus_module_9 from "@effect/io/Ref";
|
|
10
|
+
export const DiscordWSCodec = tsplus_module_1.Tag();
|
|
11
|
+
export const LiveJsonDiscordWSCodec = tsplus_module_2.succeed(DiscordWSCodec)({
|
|
9
12
|
type: "json",
|
|
10
13
|
encode: (p) => JSON.stringify(p),
|
|
11
14
|
decode: (p) => JSON.parse(p.toString("utf8")),
|
|
12
15
|
});
|
|
13
|
-
export const make = ({ url = "wss://gateway.discord.gg/", version = 10, outbound, }) =>
|
|
14
|
-
const setUrl = (url) =>
|
|
15
|
-
const take =
|
|
16
|
-
return
|
|
17
|
-
const ws =
|
|
18
|
-
const source =
|
|
16
|
+
export const make = ({ url = "wss://gateway.discord.gg/", version = 10, outbound, }) => tsplus_module_8.flatMap(encoding => tsplus_module_8.flatMap(urlRef => {
|
|
17
|
+
const setUrl = (url) => tsplus_module_9.set(`${url}?v=${version}&encoding=${encoding.type}`)(urlRef);
|
|
18
|
+
const take = tsplus_module_8.map((a) => a === tsplus_module_6.WS.Reconnect ? a : encoding.encode(a))(outbound);
|
|
19
|
+
return tsplus_module_8.map(log => {
|
|
20
|
+
const ws = tsplus_module_5.provideService(tsplus_module_7.Log.Log)(log)(tsplus_module_6.WS.make(urlRef, take));
|
|
21
|
+
const source = tsplus_module_5.map(encoding.decode)(tsplus_module_5.retry(tsplus_module_4.exponential(tsplus_module_3.seconds(0.5)))(tsplus_module_5.tapError((e) => log.info("DiscordWS", "ERROR", e))(ws)));
|
|
19
22
|
return { source, setUrl };
|
|
20
|
-
})(
|
|
21
|
-
})(
|
|
23
|
+
})(tsplus_module_8.service(tsplus_module_7.Log.Log));
|
|
24
|
+
})(tsplus_module_9.make(`${url}?v=${version}&encoding=${encoding.type}`)))(tsplus_module_8.service(DiscordWSCodec));
|
|
22
25
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/DiscordGateway/DiscordWS/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/DiscordGateway/DiscordWS/index.ts"],"names":[],"mappings":";;;;;;;;;AAgBA,MAAM,CAAC,MAAM,cAAc,GAAG,gBAAA,GAAG,EAAkB,CAAA;AACnD,MAAM,CAAC,MAAM,sBAAsB,GAAG,wBAAc,cAAc,CAAC,CAAC;IAClE,IAAI,EAAE,MAAM;IACZ,MAAM,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC;IAChC,MAAM,EAAE,CAAC,CAAC,EAAE,EA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|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
export declare const fromRaw: <R, E>(source:
|
|
1
|
+
import { Ref, Maybe, Effect, Stream, Discord } from "dfx/_common";
|
|
2
|
+
import { DiscordWS } from "dfx/gateway";
|
|
3
|
+
export declare const fromRaw: <R, E>(source: import("../../_common.js").Stream<R, E, import("../../types.js").GatewayPayload<any>>, seqRef: Ref<Maybe<number>>) => import("../../_common.js").Stream<R, E, import("../DiscordWS/index.js").Message>;
|
|
@@ -1,17 +1,19 @@
|
|
|
1
1
|
import * as tsplus_module_1 from "@effect/io/Ref";
|
|
2
2
|
import * as tsplus_module_2 from "@fp-ts/data/Option";
|
|
3
3
|
import * as tsplus_module_3 from "@effect/io/Effect";
|
|
4
|
-
import * as tsplus_module_4 from "
|
|
5
|
-
import * as tsplus_module_5 from "
|
|
6
|
-
import
|
|
7
|
-
import * as
|
|
4
|
+
import * as tsplus_module_4 from "dfx/gateway";
|
|
5
|
+
import * as tsplus_module_5 from "dfx/_common";
|
|
6
|
+
import * as tsplus_module_6 from "@effect/stream/Stream";
|
|
7
|
+
import * as tsplus_module_7 from "@effect/io/Schedule";
|
|
8
|
+
import * as tsplus_module_8 from "@fp-ts/data/Function";
|
|
8
9
|
import * as SendEvents from "./sendEvents.js";
|
|
9
10
|
import * as Utils from "./utils.js";
|
|
11
|
+
import { millis } from "@fp-ts/data/Duration";
|
|
10
12
|
const send = (ref, seqRef) => tsplus_module_3.tap(() => tsplus_module_1.set(false)(ref))(tsplus_module_3.map((a) => SendEvents.heartbeat(tsplus_module_2.getOrNull(a)))(tsplus_module_1.get(seqRef)));
|
|
11
|
-
const maybeSend = (ref, seqRef) => tsplus_module_3.flatMap((acked) => acked ? send(ref, seqRef) :
|
|
12
|
-
export const fromRaw = (source, seqRef) => pipe(tsplus_module_3.map((ackedRef) => {
|
|
13
|
-
const heartbeats =
|
|
14
|
-
const acks =
|
|
15
|
-
return
|
|
16
|
-
})(
|
|
13
|
+
const maybeSend = (ref, seqRef) => tsplus_module_3.flatMap((acked) => acked ? send(ref, seqRef) : tsplus_module_3.succeed(tsplus_module_4.WS.Reconnect))(tsplus_module_1.get(ref));
|
|
14
|
+
export const fromRaw = (source, seqRef) => tsplus_module_8.pipe(tsplus_module_3.map((ackedRef) => {
|
|
15
|
+
const heartbeats = tsplus_module_6.mapEffect(() => maybeSend(ackedRef, seqRef))(tsplus_module_8.pipe(tsplus_module_6.tap(() => tsplus_module_1.set(true)(ackedRef))(Utils.opCode(source)(10 /* Discord.GatewayOpcode.HELLO */)), tsplus_module_6.flatMapParSwitch(1)((p) => tsplus_module_6.fromSchedule(tsplus_module_7.andThen(tsplus_module_7.spaced(millis(p.d.heartbeat_interval)))(tsplus_module_7.duration(millis(p.d.heartbeat_interval * Math.random())))))));
|
|
16
|
+
const acks = tsplus_module_6.drain(tsplus_module_6.tap(() => tsplus_module_1.set(true)(ackedRef))(Utils.opCode(source)(11 /* Discord.GatewayOpcode.HEARTBEAT_ACK */)));
|
|
17
|
+
return tsplus_module_6.merge(acks)(heartbeats);
|
|
18
|
+
})(tsplus_module_1.make(true)), tsplus_module_6.unwrap);
|
|
17
19
|
//# sourceMappingURL=heartbeats.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"heartbeats.js","sourceRoot":"","sources":["../../../src/DiscordGateway/Shard/heartbeats.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"heartbeats.js","sourceRoot":"","sources":["../../../src/DiscordGateway/Shard/heartbeats.ts"],"names":[],"mappings":";;;;;;;;AAAA,OAAO,KAAK,UAAU,MAAM,iBAAiB,CAAA;AAC7C,OAAO,KAAK,KAAK,MAAM,YAAY,CAAA;AACnC,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAA;AAE7C,MAAM,IAAI,GAAG,CAAC,GAAiB,EAAE,MAA0B,EAAE,EAAE,CAC7D,oBAEO,GAAG,EAAE,CAAC,oBAAQ,KAAK,EAAb,GAAG,CAAW,EAF3B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qBAAS,IAAI,CAAC,CAmBZ,yBAEH,CAAA"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { Discord } from "dfx";
|
|
2
|
-
import { Option, Ref, Stream } from "dfx/_common";
|
|
1
|
+
import { Discord, Ref, Maybe, Stream } from "dfx/_common";
|
|
3
2
|
export interface Options {
|
|
4
3
|
token: string;
|
|
5
4
|
intents: number;
|
|
@@ -7,7 +6,7 @@ export interface Options {
|
|
|
7
6
|
presence?: Discord.UpdatePresence;
|
|
8
7
|
}
|
|
9
8
|
export interface Requirements {
|
|
10
|
-
latestReady: Ref
|
|
11
|
-
latestSequence: Ref
|
|
9
|
+
latestReady: Ref<Maybe<Discord.ReadyEvent>>;
|
|
10
|
+
latestSequence: Ref<Maybe<number>>;
|
|
12
11
|
}
|
|
13
|
-
export declare const fromRaw: <R, E>(source:
|
|
12
|
+
export declare const fromRaw: <R, E>(source: import("../../_common.js").Stream<R, E, import("../../types.js").GatewayPayload<any>>, { latestReady, latestSequence, ...opts }: Options & Requirements) => import("../../_common.js").Stream<R, E, import("../../types.js").GatewayPayload<any>>;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import * as tsplus_module_1 from "@fp-ts/data/Option";
|
|
2
2
|
import * as tsplus_module_2 from "@effect/io/Ref";
|
|
3
3
|
import * as tsplus_module_3 from "@effect/io/Effect";
|
|
4
|
-
import * as tsplus_module_4 from "
|
|
4
|
+
import * as tsplus_module_4 from "dfx/_common";
|
|
5
|
+
import * as tsplus_module_5 from "@effect/stream/Stream";
|
|
5
6
|
import * as SendEvents from "./sendEvents.js";
|
|
6
7
|
import * as OS from "os";
|
|
7
8
|
import { opCode } from "./utils.js";
|
|
8
|
-
import { Option } from "dfx/_common";
|
|
9
9
|
const identify = ({ token, intents, shard, presence }) => SendEvents.identify({
|
|
10
10
|
token,
|
|
11
11
|
intents,
|
|
@@ -22,9 +22,9 @@ const resume = (token, ready, seq) => SendEvents.resume({
|
|
|
22
22
|
session_id: ready.session_id,
|
|
23
23
|
seq,
|
|
24
24
|
});
|
|
25
|
-
const identifyOrResume = (opts, ready, seq) => tsplus_module_3.flatMap(readyEvent => tsplus_module_3.map(seqNumber => tsplus_module_1.match(() => identify(opts), ({ readyEvent, seqNumber }) => resume(opts.token, readyEvent, seqNumber))(
|
|
25
|
+
const identifyOrResume = (opts, ready, seq) => tsplus_module_3.flatMap(readyEvent => tsplus_module_3.map(seqNumber => tsplus_module_1.match(() => identify(opts), ({ readyEvent, seqNumber }) => resume(opts.token, readyEvent, seqNumber))(tsplus_module_1.struct({
|
|
26
26
|
readyEvent,
|
|
27
27
|
seqNumber,
|
|
28
28
|
})))(tsplus_module_2.get(seq)))(tsplus_module_2.get(ready));
|
|
29
|
-
export const fromRaw = (source, { latestReady, latestSequence, ...opts }) =>
|
|
29
|
+
export const fromRaw = (source, { latestReady, latestSequence, ...opts }) => tsplus_module_5.mapEffect(() => identifyOrResume(opts, latestReady, latestSequence))(opCode(source)(10 /* Discord.GatewayOpcode.HELLO */));
|
|
30
30
|
//# sourceMappingURL=identify.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"identify.js","sourceRoot":"","sources":["../../../src/DiscordGateway/Shard/identify.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"identify.js","sourceRoot":"","sources":["../../../src/DiscordGateway/Shard/identify.ts"],"names":[],"mappings":";;;;;AAAA,OAAO,KAAK,UAAU,MAAM,iBAAiB,CAAA;AAC7C,OAAO,KAAK,EAAE,MAAM,IAAI,CAAA;AACxB,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAA;AAcnC,MAAM,QAAQ,GAAG,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAW,EAAE,EAAE,CAChE,UAAU,CAAC,QAAQ,CAAC;IAClB,KAAK;IACL,OAAO;IACP,UAAU,EAAE;QACV,EAAE,EAAE,EAAE,CAAC,QAAQ,EAAE;QACjB,OAAO,EAAE,KAAK;QACd,MAAM,EAAE,KAAK;KACd;IACD,KAAK;IACL,QAAQ;CACT,CAAC,CAAA;AAEJ,MAAM,MAAM,GAAG,CAAC,KAAa,EAAE,KAAyB,EAAE,GAAW,EAAE,EAAE,CACvE,UAAU,CAAC,MAAM,CAAC;IAChB,KAAK;IACL,UAAU,EAAE,KAAK,CAAC,UAAU;IAC5B,GAAG;CACJ,CAAC,CAAA;AAEJ,MAAM,gBAAgB,GAAG,CACvB,IAAa,EACb,KAAqC,EACrC,GAAuB,EACvB,EAAE,yBAEM,UAAU,wBACV,SAAS,IAER,sBAIL,GAAG,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,EACpB,CAAC,EAAE,UAAU,EAAE,SAAS,EAAE,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,UAAU,EAAE,SAAS,CAAC,EALnE,uBAAa;IAClB,UAAU;IACV,SAAS;CACV,CAAC,CAGD,sBARmB,GAAG,wBADF,KAAK,EAU1B,CAAA;AAEJ,MAAM,CAAC,MAAM,OAAO,GAAG,CACrB,MAA4C,EAC5C,EAAE,WAAW,EAAE,cAAc,EAAE,GAAG,IAAI,EAA0B,EAChE,EAAE,CACF,0BACE,GAAG,EAAE,CAAC,gBAAgB,CAAC,IAAI,EAAE,WAAW,EAAE,cAAc,CAAC,EAD3D,MAAM,CAAC,MAAM,CAAC,sCAAiD,CAE9D,CAAA"}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { Config, RateLimiter } from "dfx";
|
|
2
1
|
import { DiscordWS } from "dfx/gateway";
|
|
3
|
-
import { Discord
|
|
4
|
-
export declare const make: (shard: [id: number, count: number]) =>
|
|
5
|
-
run:
|
|
6
|
-
raw:
|
|
7
|
-
dispatch:
|
|
8
|
-
send: (p: Discord.GatewayPayload) =>
|
|
9
|
-
reconnect:
|
|
2
|
+
import { Discord } from "dfx/_common";
|
|
3
|
+
export declare const make: (shard: [id: number, count: number]) => import("../../_common.js").Effect<import("../../_common.js").Scope | import("../../DiscordConfig/index.js").DiscordConfig | import("../../Log/index.js").Log | import("../../index.js").RateLimiter | import("../DiscordWS/index.js").DiscordWSCodec, never, {
|
|
4
|
+
run: import("../../_common.js").Effect<never, never, void>;
|
|
5
|
+
raw: import("../../_common.js").Stream<never, never, import("../../types.js").GatewayPayload<any>>;
|
|
6
|
+
dispatch: import("../../_common.js").Stream<never, never, import("../../types.js").GatewayPayload<import("../../types.js").ReceiveEvent>>;
|
|
7
|
+
send: (p: Discord.GatewayPayload) => import("../../_common.js").Effect<never, never, boolean>;
|
|
8
|
+
reconnect: import("../../_common.js").Effect<never, never, boolean>;
|
|
10
9
|
}>;
|
|
@@ -1,27 +1,27 @@
|
|
|
1
1
|
import * as tsplus_module_1 from "@effect/io/Effect";
|
|
2
|
-
import * as tsplus_module_2 from "
|
|
3
|
-
import * as tsplus_module_3 from "@
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
2
|
+
import * as tsplus_module_2 from "dfx/gateway";
|
|
3
|
+
import * as tsplus_module_3 from "@effect/stream/Stream";
|
|
4
|
+
import * as tsplus_module_4 from "dfx/_common";
|
|
5
|
+
import * as tsplus_module_5 from "@fp-ts/data/Option";
|
|
6
|
+
import * as tsplus_module_6 from "@fp-ts/data/Duration";
|
|
7
|
+
import * as tsplus_module_7 from "@effect/io/Queue";
|
|
8
|
+
import * as tsplus_module_8 from "dfx";
|
|
7
9
|
import * as Heartbeats from "./heartbeats.js";
|
|
8
10
|
import * as Identify from "./identify.js";
|
|
9
11
|
import * as InvalidSession from "./invalidSession.js";
|
|
10
12
|
import * as Utils from "./utils.js";
|
|
11
|
-
const _scope = Scope.Tag;
|
|
12
|
-
const _stream = Stream.StreamTypeId;
|
|
13
13
|
export const make = (shard) => tsplus_module_1.flatMap(({ token, gateway }) => tsplus_module_1.flatMap(limiter => tsplus_module_1.flatMap(outboundQueue => {
|
|
14
|
-
const outbound = tsplus_module_1.tap(() => limiter.maybeWait("dfx.shard.send",
|
|
14
|
+
const outbound = tsplus_module_1.tap(() => limiter.maybeWait("dfx.shard.send", tsplus_module_6.minutes(1), 120))(outboundQueue
|
|
15
15
|
.take());
|
|
16
16
|
const send = (p) => outboundQueue.offer(p);
|
|
17
17
|
return tsplus_module_1.flatMap(socket => tsplus_module_1.flatMap(raw => tsplus_module_1.flatMap(([latestReady, updateLatestReady]) => tsplus_module_1.map(([latestSequence, updateLatestSequence]) => {
|
|
18
|
-
const maybeUpdateUrl = (p) =>
|
|
19
|
-
const updateRefs =
|
|
18
|
+
const maybeUpdateUrl = (p) => tsplus_module_5.match(() => tsplus_module_1.unit(), (a) => socket.setUrl(a.resume_gateway_url))(tsplus_module_5.map((p) => p.d)(tsplus_module_5.filter((p) => p.op === 0 /* Discord.GatewayOpcode.DISPATCH */ && p.t === "READY")(tsplus_module_5.some(p))));
|
|
19
|
+
const updateRefs = tsplus_module_3.runDrain(tsplus_module_3.tap(maybeUpdateUrl)(tsplus_module_3.tap(updateLatestSequence)(tsplus_module_3.tap(updateLatestReady)(raw))));
|
|
20
20
|
// heartbeats
|
|
21
|
-
const heartbeatEffects =
|
|
22
|
-
const dispatch =
|
|
21
|
+
const heartbeatEffects = tsplus_module_3.runForEach(send)(Heartbeats.fromRaw(raw, latestSequence));
|
|
22
|
+
const dispatch = tsplus_module_3.filter((p) => p.op === 0 /* Discord.GatewayOpcode.DISPATCH */)(raw);
|
|
23
23
|
// identify
|
|
24
|
-
const identifyEffects =
|
|
24
|
+
const identifyEffects = tsplus_module_3.runForEach(send)(Identify.fromRaw(raw, {
|
|
25
25
|
token,
|
|
26
26
|
shard,
|
|
27
27
|
intents: gateway.intents,
|
|
@@ -30,14 +30,14 @@ export const make = (shard) => tsplus_module_1.flatMap(({ token, gateway }) => t
|
|
|
30
30
|
latestReady,
|
|
31
31
|
}));
|
|
32
32
|
// invalid session
|
|
33
|
-
const invalidEffects =
|
|
33
|
+
const invalidEffects = tsplus_module_3.runForEach(send)(InvalidSession.fromRaw(raw, latestReady));
|
|
34
34
|
return {
|
|
35
35
|
run: tsplus_module_1.asUnit(tsplus_module_1.zipPar(invalidEffects)(tsplus_module_1.zipPar(identifyEffects)(tsplus_module_1.zipPar(heartbeatEffects)(updateRefs)))),
|
|
36
36
|
raw,
|
|
37
37
|
dispatch,
|
|
38
38
|
send: (p) => send(p),
|
|
39
|
-
reconnect: send(WS.Reconnect),
|
|
39
|
+
reconnect: send(tsplus_module_2.WS.Reconnect),
|
|
40
40
|
};
|
|
41
|
-
})(Utils.latest((p) =>
|
|
42
|
-
})(
|
|
41
|
+
})(Utils.latest((p) => tsplus_module_5.fromNullable(p.s))))(Utils.latest((p) => tsplus_module_5.map((p) => p.d)(tsplus_module_5.filter((p) => p.op === 0 /* Discord.GatewayOpcode.DISPATCH */ && p.t === "READY")(tsplus_module_5.some(p))))))(tsplus_module_3.broadcastDynamic(1)(socket.source)))(tsplus_module_2.DiscordWS.make({ outbound }));
|
|
42
|
+
})(tsplus_module_7.unbounded()))(tsplus_module_1.service(tsplus_module_8.RateLimiter)))(tsplus_module_1.service(tsplus_module_8.Config.DiscordConfig));
|
|
43
43
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/DiscordGateway/Shard/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/DiscordGateway/Shard/index.ts"],"names":[],"mappings":";;;;;;;;AAAA,OAAO,KAAK,UAAU,MAAM,iBAAiB,CAAA;AAC7C,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAA;AACzC,OAAO,KAAK,cAAc,MAAM,qBAAqB,CAAA;AACrD,OAAO,KAAK,KAAK,MAAM,YAAY,CAAA;AAEnC,MAAM,CAAC,MAAM,IAAI,GAAG,CAAC,KAAkC,EAAE,EAAE,0BAEjD,EAAE,KAAK,EAAE,OAAO,EAAE,6BAClB,OAAO,4BAEP,aAAa;IACnB,MAAM,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
2
|
-
|
|
3
|
-
export declare const fromRaw: <R, E>(raw: Stream.Stream<R, E, Discord.GatewayPayload<any>>, latestReady: Ref.Ref<Option.Option<Discord.ReadyEvent>>) => Stream.Stream<R, E, DiscordWS.Message>;
|
|
3
|
+
export declare const fromRaw: <R, E>(raw: import("../../_common.js").Stream<R, E, import("../../types.js").GatewayPayload<any>>, latestReady: Ref<Maybe<Discord.ReadyEvent>>) => import("../../_common.js").Stream<R, E, import("../DiscordWS/index.js").Message>;
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import * as tsplus_module_1 from "
|
|
2
|
-
import * as tsplus_module_2 from "@effect/
|
|
3
|
-
import
|
|
4
|
-
import
|
|
1
|
+
import * as tsplus_module_1 from "dfx/gateway";
|
|
2
|
+
import * as tsplus_module_2 from "@effect/io/Effect";
|
|
3
|
+
import * as tsplus_module_3 from "@fp-ts/data/Option";
|
|
4
|
+
import * as tsplus_module_4 from "@effect/io/Ref";
|
|
5
|
+
import * as tsplus_module_5 from "dfx/_common";
|
|
6
|
+
import * as tsplus_module_6 from "@effect/stream/Stream";
|
|
5
7
|
import { opCode } from "./utils.js";
|
|
6
|
-
export const fromRaw = (raw, latestReady) =>
|
|
8
|
+
export const fromRaw = (raw, latestReady) => tsplus_module_6.map(() => tsplus_module_1.WS.Reconnect)(tsplus_module_6.tap((p) => (p.d ? tsplus_module_2.unit() : tsplus_module_4.set(tsplus_module_3.none)(latestReady)))(opCode(raw)(9 /* Discord.GatewayOpcode.INVALID_SESSION */)));
|
|
7
9
|
//# 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,EAAE,MAAM,EAAE,MAAM,YAAY,CAAA;AAEnC,MAAM,CAAC,MAAM,OAAO,GAAG,CACrB,GAAyC,EACzC,WAA2C,EAC3C,EAAE,CACF,oBAIO,GAAsB,EAAE,CAAC,gBAAA,EAAE,CAAC,SAAS,EAJ5C,oBAGO,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,sBAAa,CAAC,CAAC,CAAC,0CAAA,WAAW,CAAgB,CAAC,EAHjE,MAAM,CAAC,GAAG,CAAC,+CAEV,CACiE,CACrB,CAAA"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare const opCode: <R, E>(source:
|
|
3
|
-
export declare const latest: <T>(f: (p: Discord.GatewayPayload) =>
|
|
1
|
+
import { Stream, Discord, Maybe, Ref } from "dfx/_common";
|
|
2
|
+
export declare const opCode: <R, E>(source: import("../../_common.js").Stream<R, E, import("../../types.js").GatewayPayload<any>>) => <T = any>(code: Discord.GatewayOpcode) => import("../../_common.js").Stream<R, E, import("../../types.js").GatewayPayload<T>>;
|
|
3
|
+
export declare const latest: <T>(f: (p: Discord.GatewayPayload) => import("../../index.js").Maybe<T>) => import("../../_common.js").Effect<never, never, readonly [import("../../_common.js").Ref<import("../../index.js").Maybe<T>>, (p: import("../../types.js").GatewayPayload<any>) => import("../../_common.js").Effect<never, never, void>]>;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import * as tsplus_module_1 from "@effect/stream/Stream";
|
|
2
|
-
import * as tsplus_module_2 from "@effect/io/
|
|
2
|
+
import * as tsplus_module_2 from "@effect/io/Effect";
|
|
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/Ref";
|
|
5
|
+
import * as tsplus_module_5 from "@fp-ts/data/Function";
|
|
6
6
|
export const opCode = (source) => (code) => tsplus_module_1.filter((p) => p.op === code)(source);
|
|
7
|
-
const maybeUpdateRef = (f, ref) => flow(f, (o) => tsplus_module_3.match(
|
|
8
|
-
export const latest = (f) =>
|
|
7
|
+
const maybeUpdateRef = (f, ref) => tsplus_module_5.flow(f, (o) => tsplus_module_3.match(tsplus_module_2.unit, (a) => tsplus_module_4.set(tsplus_module_3.some(a))(ref))(o));
|
|
8
|
+
export const latest = (f) => tsplus_module_2.map((ref) => [ref, maybeUpdateRef(f, ref)])(tsplus_module_4.make(tsplus_module_3.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,MAAM,CAAC,MAAM,MAAM,GACjB,CAAO,MAA4C,EAAE,EAAE,CACvD,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,CAA0C,EAC1C,GAAkB,EAClB,EAAE,CAAC,gBAAA,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,4CAAqB,CAAC,CAAC,EAAE,EAAE,CAAC,oBAAQ,qBAAW,CAAC,CAAC,EAArB,GAAG,CAAmB,EAAlD,CAAC,CAAkD,CAAC,CAAA;AAExE,MAAM,CAAC,MAAM,MAAM,GAAG,CAAI,CAA0C,EAAE,EAAE,CACtE,oBACE,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,GAAG,EAAE,cAAc,CAAC,CAAC,EAAE,GAAG,CAAC,CAAU,EADjD,0CAA8B,CAE7B,CAAA"}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Effect, Maybe } 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
|
|
8
|
-
allClaimed: (totalCount: number) => Effect
|
|
9
|
-
heartbeat?: (shardId: number) => Effect
|
|
7
|
+
claimId: (ctx: ClaimIdContext) => Effect<never, never, Maybe<number>>;
|
|
8
|
+
allClaimed: (totalCount: number) => Effect<never, never, boolean>;
|
|
9
|
+
heartbeat?: (shardId: number) => Effect<never, never, void>;
|
|
10
10
|
}
|
|
11
|
-
export declare const ShardStore:
|
|
12
|
-
export declare const LiveMemoryShardStore:
|
|
11
|
+
export declare const ShardStore: import("../../_common.js").Tag<ShardStore>;
|
|
12
|
+
export declare const LiveMemoryShardStore: import("../../_common.js").Layer<never, never, ShardStore>;
|
|
@@ -1,19 +1,22 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import * as tsplus_module_1 from "dfx/_common";
|
|
2
|
+
import * as tsplus_module_2 from "@fp-ts/data/Option";
|
|
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();
|
|
3
6
|
// Very basic shard id store, that does no health checks
|
|
4
7
|
const memoryStore = () => {
|
|
5
8
|
let currentId = 0;
|
|
6
9
|
return {
|
|
7
|
-
claimId: ({ totalCount }) =>
|
|
10
|
+
claimId: ({ totalCount }) => tsplus_module_3.sync(() => {
|
|
8
11
|
if (currentId >= totalCount) {
|
|
9
|
-
return
|
|
12
|
+
return tsplus_module_2.none;
|
|
10
13
|
}
|
|
11
14
|
const id = currentId;
|
|
12
15
|
currentId++;
|
|
13
|
-
return
|
|
16
|
+
return tsplus_module_2.some(id);
|
|
14
17
|
}),
|
|
15
|
-
allClaimed: (totalCount) =>
|
|
18
|
+
allClaimed: (totalCount) => tsplus_module_3.sync(() => currentId >= totalCount),
|
|
16
19
|
};
|
|
17
20
|
};
|
|
18
|
-
export const LiveMemoryShardStore =
|
|
21
|
+
export const LiveMemoryShardStore = tsplus_module_4.sync(ShardStore)(memoryStore);
|
|
19
22
|
//# 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":";;;;AAUA,MAAM,CAAC,MAAM,UAAU,GAAG,gBAAA,GAAG,EAAc,CAAA;AAE3C,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,qBAAY,GAAG,EAAE;YACf,IAAI,SAAS,IAAI,UAAU,EAAE;gBAC3B,4BAAiB;aAClB;YAED,MAAM,EAAE,GAAG,SAAS,CAAA;YACpB,SAAS,EAAE,CAAA;YACX,OAAO,qBAAW,EAAE,CAAC,CAAA;QACvB,CAAC,CAAC;QAEJ,UAAU,EAAE,CAAC,UAAU,EAAE,EAAE,CAAC,qBAAY,GAAG,EAAE,CAAC,SAAS,IAAI,UAAU,CAAC;KACvE,CAAA;AACH,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,oBAAoB,GAAG,qBAAW,UAAU,CAAC,CAAC,WAAW,CAAC,CAAA"}
|
|
@@ -1,18 +1,16 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Effect, Discord } from "dfx/_common";
|
|
2
2
|
import { Success } from "dfx/utils/effect";
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
send: (p: Discord.GatewayPayload<any>) => Effect.Effect<never, never, boolean>;
|
|
11
|
-
reconnect: Effect.Effect<never, never, boolean>;
|
|
3
|
+
declare const make: import("../../_common.js").Effect<import("../../_common.js").Scope | import("../../index.js").DiscordREST | import("../../DiscordConfig/index.js").DiscordConfig | import("../../Log/index.js").Log | import("../../index.js").RateLimiter | import("../DiscordWS/index.js").DiscordWSCodec | import("../ShardStore/index.js").ShardStore, never, {
|
|
4
|
+
shards: import("../../_common.js").Stream<never, never, {
|
|
5
|
+
run: import("../../_common.js").Effect<never, never, void>;
|
|
6
|
+
raw: import("../../_common.js").Stream<never, never, import("../../types.js").GatewayPayload<any>>;
|
|
7
|
+
dispatch: import("../../_common.js").Stream<never, never, import("../../types.js").GatewayPayload<import("../../types.js").ReceiveEvent>>;
|
|
8
|
+
send: (p: import("../../types.js").GatewayPayload<any>) => import("../../_common.js").Effect<never, never, boolean>;
|
|
9
|
+
reconnect: import("../../_common.js").Effect<never, never, boolean>;
|
|
12
10
|
}>;
|
|
13
11
|
}>;
|
|
14
12
|
export interface Sharder extends Success<typeof make> {
|
|
15
13
|
}
|
|
16
|
-
export declare const Sharder:
|
|
17
|
-
export declare const LiveSharder:
|
|
14
|
+
export declare const Sharder: import("../../_common.js").Tag<Sharder>;
|
|
15
|
+
export declare const LiveSharder: import("../../_common.js").Layer<import("../../index.js").DiscordREST | import("../../DiscordConfig/index.js").DiscordConfig | import("../../Log/index.js").Log | import("../../index.js").RateLimiter | import("../DiscordWS/index.js").DiscordWSCodec | import("../ShardStore/index.js").ShardStore, never, Sharder>;
|
|
18
16
|
export {};
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import * as tsplus_module_1 from "@effect/stream/Stream";
|
|
2
|
-
import * as tsplus_module_2 from "
|
|
2
|
+
import * as tsplus_module_2 from "dfx/gateway";
|
|
3
3
|
import * as tsplus_module_3 from "@effect/io/Effect";
|
|
4
|
-
import * as tsplus_module_4 from "@
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
|
|
4
|
+
import * as tsplus_module_4 from "@effect/stream/GroupBy";
|
|
5
|
+
import * as tsplus_module_5 from "@fp-ts/data/Duration";
|
|
6
|
+
import * as tsplus_module_6 from "@fp-ts/data/Option";
|
|
7
|
+
import * as tsplus_module_7 from "dfx";
|
|
8
|
+
import * as tsplus_module_8 from "dfx/_common";
|
|
9
|
+
import * as tsplus_module_9 from "@effect/io/Layer";
|
|
10
|
+
import { millis } from "@fp-ts/data/Duration";
|
|
10
11
|
const make = tsplus_module_3.flatMap(store => tsplus_module_3.flatMap(rest => tsplus_module_3.flatMap(({ gateway: config }) => tsplus_module_3.flatMap(limiter => {
|
|
11
12
|
const configs = (totalCount) => {
|
|
12
|
-
const claimId = (sharderCount) => tsplus_module_3.flatMap((a) =>
|
|
13
|
+
const claimId = (sharderCount) => tsplus_module_3.flatMap((a) => tsplus_module_6.match(() => tsplus_module_3.delay(tsplus_module_5.minutes(3))(claimId(sharderCount)), (id) => tsplus_module_3.succeed(id))(a))(store
|
|
13
14
|
.claimId({
|
|
14
15
|
totalCount,
|
|
15
16
|
sharderCount,
|
|
@@ -17,13 +18,13 @@ const make = tsplus_module_3.flatMap(store => tsplus_module_3.flatMap(rest => ts
|
|
|
17
18
|
return tsplus_module_1.map((id) => ({
|
|
18
19
|
id,
|
|
19
20
|
totalCount,
|
|
20
|
-
}))(
|
|
21
|
+
}))(tsplus_module_1.unfoldEffect(0, (sharderCount) => tsplus_module_3.map((id) => tsplus_module_6.some([id, sharderCount + 1]))(claimId(sharderCount))));
|
|
21
22
|
};
|
|
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(
|
|
23
|
+
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(tsplus_module_1.fromEffect(shard.run)))(tsplus_module_1.succeed(shard)))(tsplus_module_4.evaluate((key, shardConfig) => tsplus_module_1.mapEffect((c) => tsplus_module_2.Shard.make([c.id, c.totalCount]))(tsplus_module_1.tap(() => limiter.maybeWait(`dfx.sharder.${key}`, millis(config.identifyRateLimit[0]), config.identifyRateLimit[1]))(shardConfig)))(tsplus_module_1.groupBy((c) => tsplus_module_3.succeed([c.id % c.concurrency, c]))(tsplus_module_1.map((config) => ({
|
|
23
24
|
...config,
|
|
24
25
|
url: gateway.url,
|
|
25
26
|
concurrency: gateway.session_start_limit.max_concurrency,
|
|
26
|
-
}))(configs(config.shardCount ?? gateway.shards))))))))(tsplus_module_3.catchAll(() =>
|
|
27
|
+
}))(configs(config.shardCount ?? gateway.shards))))))))(tsplus_module_3.catchAll(() => tsplus_module_3.succeed({
|
|
27
28
|
url: "wss://gateway.discord.gg/",
|
|
28
29
|
shards: 1,
|
|
29
30
|
session_start_limit: {
|
|
@@ -34,7 +35,7 @@ const make = tsplus_module_3.flatMap(store => tsplus_module_3.flatMap(rest => ts
|
|
|
34
35
|
},
|
|
35
36
|
}))(tsplus_module_3.flatMap((r) => r.json)(rest
|
|
36
37
|
.getGatewayBot())));
|
|
37
|
-
})(
|
|
38
|
-
export const Sharder =
|
|
39
|
-
export const LiveSharder =
|
|
38
|
+
})(tsplus_module_3.service(tsplus_module_7.RateLimiter)))(tsplus_module_3.service(tsplus_module_7.Config.DiscordConfig)))(tsplus_module_3.service(tsplus_module_7.DiscordREST)))(tsplus_module_3.service(tsplus_module_2.ShardStore.ShardStore));
|
|
39
|
+
export const Sharder = tsplus_module_8.Tag();
|
|
40
|
+
export const LiveSharder = tsplus_module_9.scoped(Sharder)(make);
|
|
40
41
|
//# 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,MAAM,sBAAsB,CAAA;AAE7C,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,CAAC,YAAoB,EAAgC,EAAE,CACrE,wBAKW,CAAC,CAAC,EAAE,EAAE,CACb,sBACE,GAAG,EAAE,CAAC,sBAA4B,wBAAiB,CAAC,CAAC,EAA/C,OAAO,CAAC,YAAY,CAAC,CAA2B,EACtD,CAAC,EAAE,EAAE,EAAE,CAAC,wBAAe,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,6BAAoB,CAAC,EAAE,CAAC,YAAY,EAAE,EAAE,CAC7C,oBAA0B,CAAC,EAAE,EAAE,EAAE,CAC/B,qBAAW,CAAC,EAAE,EAAE,YAAY,GAAG,CAAC,CAAU,CAAC,EAD7C,OAAO,CAAC,YAAY,CAAC,CAEpB,CACF,CAGE,CAAA;IACL,CAAC,CAAA;mCAEK,OAAO,wBAkBP,MAAM,IAyBL,CAAA,EAAE,MAAM,EAAE,CAAA,EAxBf,iCAqBoB,CAAC,EArBrB,wBAkBW,CAAC,KAAK,EAAE,EAAE,CACjB,4CAA4B,2BAAkB,KAAK,CAAC,GAAG,CAAC,GAAxD,wBAAe,KAAK,CAAC,CAA0C,EAnBnE,yBAOY,CAAC,GAAG,EAAE,WAAW,EAAE,EAA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MAAM,OAAO,GAAG,gBAAA,GAAG,EAAW,CAAA;AACrC,MAAM,CAAC,MAAM,WAAW,GAAG,uBAAY,OAAO,EAAnB,IAAI,CAAgB,CAAA"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="node" resolution-mode="require"/>
|
|
2
2
|
/// <reference types="ws" />
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { Ref, Effect } from "dfx/_common";
|
|
4
|
+
import { Log } from "dfx";
|
|
5
5
|
import WebSocket from "isomorphic-ws";
|
|
6
6
|
export declare const Reconnect: unique symbol;
|
|
7
7
|
export type Reconnect = typeof Reconnect;
|
|
@@ -17,4 +17,4 @@ export declare class WebSocketCloseError {
|
|
|
17
17
|
readonly _tag = "WebSocketCloseError";
|
|
18
18
|
constructor(code: number, reason: string);
|
|
19
19
|
}
|
|
20
|
-
export declare const make: (url: Ref
|
|
20
|
+
export declare const make: (url: Ref<string>, takeOutbound: Effect<never, never, Message>) => import("../../_common.js").Stream<import("../../Log/index.js").Log, WebSocketError | WebSocketCloseError, WebSocket.Data>;
|