dfx 0.101.1 → 0.102.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/DiscordGateway/DiscordWS.d.ts +2 -1
- package/DiscordGateway/DiscordWS.d.ts.map +1 -1
- package/DiscordGateway/DiscordWS.js +11 -6
- package/DiscordGateway/DiscordWS.js.map +1 -1
- package/DiscordGateway/Messaging.d.ts +3 -3
- package/DiscordGateway/Messaging.d.ts.map +1 -1
- package/DiscordGateway/Messaging.js +4 -4
- package/DiscordGateway/Messaging.js.map +1 -1
- package/DiscordGateway/Shard/heartbeats.d.ts +2 -2
- package/DiscordGateway/Shard/heartbeats.d.ts.map +1 -1
- package/DiscordGateway/Shard/heartbeats.js +2 -3
- package/DiscordGateway/Shard/heartbeats.js.map +1 -1
- package/DiscordGateway/Shard.d.ts.map +1 -1
- package/DiscordGateway/Shard.js +15 -15
- package/DiscordGateway/Shard.js.map +1 -1
- package/DiscordGateway/Sharder.d.ts +1 -1
- package/DiscordGateway.d.ts +1 -1
- package/DiscordREST.d.ts +1 -1
- package/DiscordREST.js +3 -3
- package/DiscordREST.js.map +1 -1
- package/gateway.d.ts +2 -2
- package/index.d.ts +1 -1
- package/mjs/DiscordGateway/DiscordWS.mjs +11 -6
- package/mjs/DiscordGateway/DiscordWS.mjs.map +1 -1
- package/mjs/DiscordGateway/Messaging.mjs +4 -4
- package/mjs/DiscordGateway/Messaging.mjs.map +1 -1
- package/mjs/DiscordGateway/Shard/heartbeats.mjs +2 -3
- package/mjs/DiscordGateway/Shard/heartbeats.mjs.map +1 -1
- package/mjs/DiscordGateway/Shard.mjs +15 -15
- package/mjs/DiscordGateway/Shard.mjs.map +1 -1
- package/mjs/DiscordREST.mjs +3 -3
- package/mjs/DiscordREST.mjs.map +1 -1
- package/mjs/version.mjs +1 -1
- package/package.json +4 -4
- package/src/DiscordGateway/DiscordWS.ts +14 -10
- package/src/DiscordGateway/Messaging.ts +6 -6
- package/src/DiscordGateway/Shard/heartbeats.ts +5 -5
- package/src/DiscordGateway/Shard.ts +26 -23
- package/src/DiscordREST.ts +3 -3
- package/src/version.ts +1 -1
- package/version.d.ts +1 -1
- package/version.js +1 -1
- package/webhooks.d.ts +1 -1
|
@@ -20,7 +20,8 @@ import { pipe } from "effect/Function"
|
|
|
20
20
|
import * as Layer from "effect/Layer"
|
|
21
21
|
import * as Option from "effect/Option"
|
|
22
22
|
import * as PubSub from "effect/PubSub"
|
|
23
|
-
import * as
|
|
23
|
+
import * as Mailbox from "effect/Mailbox"
|
|
24
|
+
|
|
24
25
|
import * as Redacted from "effect/Redacted"
|
|
25
26
|
import * as Ref from "effect/Ref"
|
|
26
27
|
import type * as Types from "effect/Types"
|
|
@@ -35,13 +36,13 @@ export const make = Effect.gen(function* () {
|
|
|
35
36
|
const { gateway, token } = yield* DiscordConfig
|
|
36
37
|
const limiter = yield* RateLimiter
|
|
37
38
|
const dws = yield* DiscordWS
|
|
38
|
-
const { hub,
|
|
39
|
+
const { hub, sendMailbox } = yield* Messaging
|
|
39
40
|
const shardState = yield* ShardStateStore
|
|
40
41
|
|
|
41
42
|
const connect = (shard: [id: number, count: number]) =>
|
|
42
43
|
Effect.gen(function* (_) {
|
|
43
|
-
const outboundQueue = yield*
|
|
44
|
-
const pendingQueue = yield*
|
|
44
|
+
const outboundQueue = yield* Mailbox.make<Message>()
|
|
45
|
+
const pendingQueue = yield* Mailbox.make<Message>()
|
|
45
46
|
const phase = yield* Ref.make(Phase.Connecting)
|
|
46
47
|
const stateStore = shardState.forShard(shard)
|
|
47
48
|
const resumeState: Types.Mutable<ShardState> = Option.getOrElse(
|
|
@@ -57,39 +58,40 @@ export const make = Effect.gen(function* () {
|
|
|
57
58
|
Ref.set(phase, p),
|
|
58
59
|
Effect.annotateLogs(Effect.logTrace("phase transition"), "phase", p),
|
|
59
60
|
)
|
|
60
|
-
const outbound = Effect.
|
|
61
|
-
|
|
62
|
-
|
|
61
|
+
const outbound = Effect.orDie(
|
|
62
|
+
Effect.zipLeft(
|
|
63
|
+
outboundQueue.take,
|
|
64
|
+
limiter.maybeWait("dfx.shard.send", Duration.minutes(1), 120),
|
|
65
|
+
),
|
|
63
66
|
)
|
|
64
67
|
|
|
65
68
|
const send = (p: Message) =>
|
|
66
69
|
Effect.flatMap(Ref.get(phase), phase =>
|
|
67
70
|
phase === Phase.Connected
|
|
68
|
-
?
|
|
69
|
-
:
|
|
71
|
+
? outboundQueue.offer(p)
|
|
72
|
+
: pendingQueue.offer(p),
|
|
70
73
|
)
|
|
71
74
|
|
|
72
75
|
const heartbeatSend = (p: Message) =>
|
|
73
76
|
Effect.flatMap(Ref.get(phase), phase =>
|
|
74
77
|
phase !== Phase.Connecting
|
|
75
|
-
?
|
|
78
|
+
? outboundQueue.offer(p)
|
|
76
79
|
: Effect.succeed(false),
|
|
77
80
|
)
|
|
78
81
|
|
|
79
|
-
const prioritySend = (p: Message) =>
|
|
82
|
+
const prioritySend = (p: Message) => outboundQueue.offer(p)
|
|
80
83
|
|
|
81
84
|
const resume = pipe(
|
|
82
85
|
setPhase(Phase.Connected),
|
|
83
|
-
Effect.zipRight(
|
|
84
|
-
Effect.tap(_ =>
|
|
86
|
+
Effect.zipRight(pendingQueue.clear),
|
|
87
|
+
Effect.tap(_ => outboundQueue.offerAll(_)),
|
|
85
88
|
Effect.asVoid,
|
|
86
89
|
)
|
|
87
90
|
|
|
88
91
|
const onConnecting = pipe(
|
|
89
|
-
|
|
92
|
+
outboundQueue.clear,
|
|
90
93
|
Effect.tap(msgs =>
|
|
91
|
-
|
|
92
|
-
pendingQueue,
|
|
94
|
+
pendingQueue.offerAll(
|
|
93
95
|
Chunk.filter(
|
|
94
96
|
msgs,
|
|
95
97
|
msg =>
|
|
@@ -106,12 +108,12 @@ export const make = Effect.gen(function* () {
|
|
|
106
108
|
const socket = yield* dws.connect({ outbound, onConnecting })
|
|
107
109
|
|
|
108
110
|
const hellos = yield* Effect.acquireRelease(
|
|
109
|
-
|
|
110
|
-
|
|
111
|
+
Mailbox.make<Discord.GatewayPayload>(),
|
|
112
|
+
_ => _.shutdown,
|
|
111
113
|
)
|
|
112
114
|
const acks = yield* Effect.acquireRelease(
|
|
113
|
-
|
|
114
|
-
|
|
115
|
+
Mailbox.make<Discord.GatewayPayload>(),
|
|
116
|
+
_ => _.shutdown,
|
|
115
117
|
)
|
|
116
118
|
|
|
117
119
|
// heartbeats
|
|
@@ -157,11 +159,11 @@ export const make = Effect.gen(function* () {
|
|
|
157
159
|
return pipe(
|
|
158
160
|
Effect.tap(identify, prioritySend),
|
|
159
161
|
Effect.zipRight(setPhase(Phase.Handshake)),
|
|
160
|
-
Effect.zipRight(
|
|
162
|
+
Effect.zipRight(hellos.offer(p)),
|
|
161
163
|
)
|
|
162
164
|
}
|
|
163
165
|
case Discord.GatewayOpcode.HEARTBEAT_ACK: {
|
|
164
|
-
return
|
|
166
|
+
return acks.offer(p)
|
|
165
167
|
}
|
|
166
168
|
case Discord.GatewayOpcode.INVALID_SESSION: {
|
|
167
169
|
if (p.d) {
|
|
@@ -186,7 +188,7 @@ export const make = Effect.gen(function* () {
|
|
|
186
188
|
}),
|
|
187
189
|
)
|
|
188
190
|
|
|
189
|
-
yield*
|
|
191
|
+
yield* sendMailbox.take.pipe(
|
|
190
192
|
Effect.tap(send),
|
|
191
193
|
Effect.forever,
|
|
192
194
|
Effect.forkScoped,
|
|
@@ -224,5 +226,6 @@ export const ShardLive = Layer.effect(Shard, make).pipe(
|
|
|
224
226
|
Layer.provide(RateLimiterLive),
|
|
225
227
|
)
|
|
226
228
|
|
|
229
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
|
227
230
|
export interface RunningShard
|
|
228
231
|
extends Effect.Effect.Success<ReturnType<ShardService["connect"]>> {}
|
package/src/DiscordREST.ts
CHANGED
|
@@ -147,7 +147,7 @@ const make = Effect.gen(function* () {
|
|
|
147
147
|
Effect.ignore,
|
|
148
148
|
)
|
|
149
149
|
|
|
150
|
-
const
|
|
150
|
+
const httpClient = pipe(
|
|
151
151
|
HttpClient.filterStatusOk(http),
|
|
152
152
|
HttpClient.mapRequest(req =>
|
|
153
153
|
pipe(
|
|
@@ -176,7 +176,7 @@ const make = Effect.gen(function* () {
|
|
|
176
176
|
requestRateLimit(request.url, request).pipe(
|
|
177
177
|
Effect.zipLeft(globalRateLimit),
|
|
178
178
|
Effect.zipRight(
|
|
179
|
-
|
|
179
|
+
httpClient.execute(request) as Effect.Effect<
|
|
180
180
|
ResponseWithData<A>,
|
|
181
181
|
DiscordRESTError,
|
|
182
182
|
Scope
|
|
@@ -257,7 +257,7 @@ const make = Effect.gen(function* () {
|
|
|
257
257
|
} else if (params && request.body._tag === "FormData") {
|
|
258
258
|
request.body.formData.append("payload_json", JSON.stringify(params))
|
|
259
259
|
} else if (params) {
|
|
260
|
-
request = HttpRequest.
|
|
260
|
+
request = HttpRequest.bodyUnsafeJson(request, params)
|
|
261
261
|
}
|
|
262
262
|
|
|
263
263
|
return new RestResponseImpl(executor(request))
|
package/src/version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const LIB_VERSION = "0.
|
|
1
|
+
export const LIB_VERSION = "0.102.0";
|
package/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const LIB_VERSION = "0.
|
|
1
|
+
export declare const LIB_VERSION = "0.102.0";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
package/version.js
CHANGED
package/webhooks.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import * as Layer from "effect/Layer";
|
|
2
2
|
export { BadWebhookSignature, WebhookConfig, WebhookParseError, makeHandler, makeSimpleHandler, layer as webhookLayer, layerConfig as webhookLayerConfig, } from "dfx/Interactions/webhook";
|
|
3
|
-
export declare const DiscordLive: Layer.Layer<import("dfx/DiscordREST").DiscordREST | import("dfx/RateLimit").RateLimiter, never, import("./DiscordConfig").DiscordConfig | import("@effect/platform/HttpClient").HttpClient.
|
|
3
|
+
export declare const DiscordLive: Layer.Layer<import("dfx/DiscordREST").DiscordREST | import("dfx/RateLimit").RateLimiter, never, import("./DiscordConfig").DiscordConfig | import("@effect/platform/HttpClient").HttpClient.Service>;
|
|
4
4
|
//# sourceMappingURL=webhooks.d.ts.map
|