dfx 0.20.5 → 0.21.1

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.
Files changed (118) hide show
  1. package/Cache/driver.d.ts +16 -16
  2. package/Cache/driver.js.map +1 -1
  3. package/Cache/index.d.ts +21 -21
  4. package/Cache/index.js +12 -13
  5. package/Cache/index.js.map +1 -1
  6. package/Cache/memory.d.ts +3 -3
  7. package/Cache/memory.js +19 -20
  8. package/Cache/memory.js.map +1 -1
  9. package/Cache/memoryTTL.d.ts +5 -5
  10. package/Cache/memoryTTL.js +16 -16
  11. package/Cache/memoryTTL.js.map +1 -1
  12. package/Cache/prelude.d.ts +41 -41
  13. package/Cache/prelude.js +39 -41
  14. package/Cache/prelude.js.map +1 -1
  15. package/DiscordConfig/index.d.ts +4 -19
  16. package/DiscordConfig/index.js +5 -12
  17. package/DiscordConfig/index.js.map +1 -1
  18. package/DiscordGateway/DiscordWS/index.d.ts +9 -9
  19. package/DiscordGateway/DiscordWS/index.js +16 -20
  20. package/DiscordGateway/DiscordWS/index.js.map +1 -1
  21. package/DiscordGateway/Shard/heartbeats.d.ts +3 -4
  22. package/DiscordGateway/Shard/heartbeats.js +9 -16
  23. package/DiscordGateway/Shard/heartbeats.js.map +1 -1
  24. package/DiscordGateway/Shard/identify.d.ts +4 -4
  25. package/DiscordGateway/Shard/identify.js +5 -4
  26. package/DiscordGateway/Shard/identify.js.map +1 -1
  27. package/DiscordGateway/Shard/index.d.ts +8 -7
  28. package/DiscordGateway/Shard/index.js +17 -20
  29. package/DiscordGateway/Shard/index.js.map +1 -1
  30. package/DiscordGateway/Shard/invalidSession.d.ts +2 -3
  31. package/DiscordGateway/Shard/invalidSession.js +5 -8
  32. package/DiscordGateway/Shard/invalidSession.js.map +1 -1
  33. package/DiscordGateway/Shard/sendEvents.d.ts +1 -1
  34. package/DiscordGateway/Shard/sendEvents.js +7 -7
  35. package/DiscordGateway/Shard/sendEvents.js.map +1 -1
  36. package/DiscordGateway/Shard/utils.d.ts +3 -4
  37. package/DiscordGateway/Shard/utils.js +6 -6
  38. package/DiscordGateway/Shard/utils.js.map +1 -1
  39. package/DiscordGateway/ShardStore/index.d.ts +6 -6
  40. package/DiscordGateway/ShardStore/index.js +7 -10
  41. package/DiscordGateway/ShardStore/index.js.map +1 -1
  42. package/DiscordGateway/Sharder/index.d.ts +11 -11
  43. package/DiscordGateway/Sharder/index.js +21 -42
  44. package/DiscordGateway/Sharder/index.js.map +1 -1
  45. package/DiscordGateway/WS/index.d.ts +3 -2
  46. package/DiscordGateway/WS/index.js +30 -40
  47. package/DiscordGateway/WS/index.js.map +1 -1
  48. package/DiscordGateway/index.d.ts +8 -9
  49. package/DiscordGateway/index.js +10 -15
  50. package/DiscordGateway/index.js.map +1 -1
  51. package/DiscordREST/index.d.ts +132 -132
  52. package/DiscordREST/index.js +37 -40
  53. package/DiscordREST/index.js.map +1 -1
  54. package/DiscordREST/types.d.ts +6 -6
  55. package/DiscordREST/utils.d.ts +5 -4
  56. package/DiscordREST/utils.js +5 -5
  57. package/DiscordREST/utils.js.map +1 -1
  58. package/Helpers/intents.js +8 -8
  59. package/Helpers/intents.js.map +1 -1
  60. package/Helpers/interactions.d.ts +18 -19
  61. package/Helpers/interactions.js +22 -23
  62. package/Helpers/interactions.js.map +1 -1
  63. package/Helpers/members.d.ts +2 -2
  64. package/Helpers/members.js.map +1 -1
  65. package/Helpers/permissions.d.ts +4 -4
  66. package/Helpers/permissions.js +13 -13
  67. package/Helpers/permissions.js.map +1 -1
  68. package/Http/index.d.ts +10 -9
  69. package/Http/index.js +7 -8
  70. package/Http/index.js.map +1 -1
  71. package/Interactions/context.d.ts +22 -23
  72. package/Interactions/context.js +21 -21
  73. package/Interactions/context.js.map +1 -1
  74. package/Interactions/definitions.d.ts +31 -31
  75. package/Interactions/definitions.js +1 -2
  76. package/Interactions/definitions.js.map +1 -1
  77. package/Interactions/gateway.d.ts +4 -3
  78. package/Interactions/gateway.js +6 -6
  79. package/Interactions/gateway.js.map +1 -1
  80. package/Interactions/handlers.d.ts +3 -4
  81. package/Interactions/handlers.js +23 -23
  82. package/Interactions/handlers.js.map +1 -1
  83. package/Interactions/index.d.ts +11 -11
  84. package/Interactions/index.js +11 -10
  85. package/Interactions/index.js.map +1 -1
  86. package/Interactions/webhook.d.ts +7 -8
  87. package/Interactions/webhook.js +11 -12
  88. package/Interactions/webhook.js.map +1 -1
  89. package/Log/index.d.ts +8 -7
  90. package/Log/index.js +9 -11
  91. package/Log/index.js.map +1 -1
  92. package/RateLimit/index.d.ts +13 -12
  93. package/RateLimit/index.js +11 -12
  94. package/RateLimit/index.js.map +1 -1
  95. package/RateLimit/memory.d.ts +1 -1
  96. package/RateLimit/memory.js +7 -7
  97. package/RateLimit/memory.js.map +1 -1
  98. package/RateLimit/utils.d.ts +2 -2
  99. package/RateLimit/utils.js.map +1 -1
  100. package/_common.d.ts +19 -0
  101. package/_common.js +20 -0
  102. package/_common.js.map +1 -0
  103. package/gateway.d.ts +11 -10
  104. package/gateway.js +17 -14
  105. package/gateway.js.map +1 -1
  106. package/package.json +6 -16
  107. package/utils/effect.d.ts +8 -8
  108. package/utils/effect.js +4 -4
  109. package/utils/effect.js.map +1 -1
  110. package/webhooks.d.ts +6 -5
  111. package/webhooks.js +12 -8
  112. package/webhooks.js.map +1 -1
  113. package/global.d.ts +0 -21
  114. package/global.js +0 -2
  115. package/global.js.map +0 -1
  116. package/utils/common.d.ts +0 -18
  117. package/utils/common.js +0 -3
  118. package/utils/common.js.map +0 -1
@@ -1,10 +1,7 @@
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";
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) => tsplus_module_7.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)(tsplus_module_5.Discord.GatewayOpcode.INVALID_SESSION)));
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":";;;;;;;AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAA;AAEnC,MAAM,CAAC,MAAM,OAAO,GAAG,CACrB,GAA+C,EAC/C,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,CACT,gBAAA,OAAO,CAAC,aAAa,CAAC,eAAe,CACtC,CACiE,CACrB,CAAA"}
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 * as tsplus_module_1 from "dfx";
1
+ import { Discord } from "dfx/_common";
2
2
  export const heartbeat = (d) => ({
3
- op: tsplus_module_1.Discord.GatewayOpcode.HEARTBEAT,
3
+ op: Discord.GatewayOpcode.HEARTBEAT,
4
4
  d,
5
5
  });
6
6
  export const identify = (d) => ({
7
- op: tsplus_module_1.Discord.GatewayOpcode.IDENTIFY,
7
+ op: Discord.GatewayOpcode.IDENTIFY,
8
8
  d,
9
9
  });
10
10
  export const resume = (d) => ({
11
- op: tsplus_module_1.Discord.GatewayOpcode.RESUME,
11
+ op: Discord.GatewayOpcode.RESUME,
12
12
  d,
13
13
  });
14
14
  export const requestGuildMembers = (d) => ({
15
- op: tsplus_module_1.Discord.GatewayOpcode.REQUEST_GUILD_MEMBERS,
15
+ op: Discord.GatewayOpcode.REQUEST_GUILD_MEMBERS,
16
16
  d,
17
17
  });
18
18
  export const voiceStateUpdate = (d) => ({
19
- op: tsplus_module_1.Discord.GatewayOpcode.VOICE_STATE_UPDATE,
19
+ op: Discord.GatewayOpcode.VOICE_STATE_UPDATE,
20
20
  d,
21
21
  });
22
22
  export const presenceUpdate = (d) => ({
23
- op: tsplus_module_1.Discord.GatewayOpcode.PRESENCE_UPDATE,
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":";AAAA,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,CAAoB,EAA0B,EAAE,CAAC,CAAC;IAC1E,EAAE,EAAE,gBAAA,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,gBAAA,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,gBAAA,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,gBAAA,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,gBAAA,OAAO,CAAC,aAAa,CAAC,kBAAkB;IAC5C,CAAC;CACF,CAAC,CAAA;AAEF,MAAM,CAA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{ EffectSource, Maybe, Ref } from "dfx/utils/common";
2
- import { Discord } from "dfx";
3
- export declare const opCode: <R, E>(source: import("callbag-effect-ts/Source").EffectSource<R, E, import("../../types.js").GatewayPayload<any>>) => <T = any>(code: Discord.GatewayOpcode) => import("callbag-effect-ts/Source").EffectSource<R, E, import("../../types.js").GatewayPayload<T>>;
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 "callbag-effect-ts/Source/filter";
2
- import * as tsplus_module_2 from "@effect/io/Effect";
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/Ref";
5
- import * as tsplus_module_5 from "dfx/utils/common";
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) => 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));
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":";;;;;AAAA,MAAM,CAAC,MAAM,MAAM,GACjB,CAAO,MAAkD,EAAE,EAAE,CAC7D,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
+ {"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, Maybe } from "dfx/utils/common";
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, Maybe<number>>;
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: import("../../utils/common.js").Tag<ShardStore>;
12
- export declare const LiveMemoryShardStore: import("../../utils/common.js").Layer<never, never, ShardStore>;
11
+ export declare const ShardStore: Context.Tag<ShardStore>;
12
+ export declare const LiveMemoryShardStore: Layer.Layer<never, never, ShardStore>;
@@ -1,22 +1,19 @@
1
- import * as tsplus_module_1 from "dfx/utils/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();
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 }) => tsplus_module_3.sync(() => {
7
+ claimId: ({ totalCount }) => Effect.sync(() => {
11
8
  if (currentId >= totalCount) {
12
- return tsplus_module_2.none;
9
+ return Option.none;
13
10
  }
14
11
  const id = currentId;
15
12
  currentId++;
16
- return tsplus_module_2.some(id);
13
+ return Option.some(id);
17
14
  }),
18
- allClaimed: (totalCount) => tsplus_module_3.sync(() => currentId >= totalCount),
15
+ allClaimed: (totalCount) => Effect.sync(() => currentId >= totalCount),
19
16
  };
20
17
  };
21
- export const LiveMemoryShardStore = tsplus_module_4.sync(ShardStore)(memoryStore);
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":";;;;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
+ {"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 { Effect, Maybe, EffectSource } from "dfx/utils/common";
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: import("../../utils/common.js").Effect<import("../../index.js").DiscordREST | import("../DiscordWS/index.js").DiscordWSCodec | import("../../Log/index.js").Log | ShardStore | import("../../DiscordConfig/index.js").DiscordConfig | import("../../index.js").RateLimiter, never, {
6
- shards: import("callbag-effect-ts/Source").EffectSource<never, never, {
7
- run: import("../../utils/common.js").Effect<never, never, void>;
8
- raw: import("callbag-effect-ts/Source").EffectSource<never, never, import("../../types.js").GatewayPayload<any>>;
9
- dispatch: import("callbag-effect-ts/Source").EffectSource<never, never, import("../../types.js").GatewayPayload<import("../../types.js").ReceiveEvent>>;
10
- send: (p: import("../../types.js").GatewayPayload<any>) => import("../../utils/common.js").Effect<never, never, boolean>;
11
- reconnect: import("../../utils/common.js").Effect<never, never, boolean>;
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: import("../../utils/common.js").Tag<Sharder>;
17
- export declare const LiveSharder: import("../../utils/common.js").Layer<import("../../index.js").DiscordREST | import("../DiscordWS/index.js").DiscordWSCodec | import("../../Log/index.js").Log | ShardStore | import("../../DiscordConfig/index.js").DiscordConfig | import("../../index.js").RateLimiter, never, Sharder>;
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 "callbag-effect-ts/Source/fromEffect";
2
- import * as tsplus_module_2 from "callbag-effect-ts/Source/drain";
3
- import * as tsplus_module_3 from "callbag-effect-ts/Source/of";
4
- import * as tsplus_module_4 from "callbag-effect-ts/Source/merge";
5
- import * as tsplus_module_5 from "@effect/io/Effect";
6
- import * as tsplus_module_6 from "dfx/gateway";
7
- import * as tsplus_module_7 from "callbag-effect-ts/Source/tap";
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 make = tsplus_module_5.flatMap(store => tsplus_module_5.flatMap(rest => tsplus_module_5.flatMap(({ gateway: config }) => tsplus_module_5.flatMap(limiter => {
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) => tsplus_module_5.flatMap((a) => tsplus_module_14.match(() => tsplus_module_5.delay(tsplus_module_13.minutes(3))(tsplus_module_5.succeed([
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 tsplus_module_9.map((id) => ({
17
+ return tsplus_module_1.map((id) => ({
36
18
  id,
37
19
  totalCount,
38
- }))(tsplus_module_16.resource(0, (sharderCount) => tsplus_module_1.fromEffect(claimId(sharderCount))));
20
+ }))(Stream.unfoldEffect(0, (sharderCount) => tsplus_module_3.map((id) => Option.some([id, sharderCount + 1]))(claimId(sharderCount))));
39
21
  };
40
- return tsplus_module_5.flatMap(gateway => {
41
- const [source, pull] = overridePull(configs(config.shardCount ?? gateway.shards), gateway.session_start_limit.max_concurrency);
42
- return tsplus_module_5.map(shards => ({ shards }))(tsplus_module_12.share(tsplus_module_11.chainPar((shard) => tsplus_module_4.merge(tsplus_module_2.drain(tsplus_module_1.fromEffect(shard.run)))(tsplus_module_3.of(shard)))(tsplus_module_7.tap(() => tsplus_module_5.sync(pull))(tsplus_module_11.chainPar(([shardConfig, key]) => tsplus_module_8.mapEffect((c) => tsplus_module_6.Shard.make([c.id, c.totalCount]))(tsplus_module_7.tap(() => limiter.maybeWait(`dfx.sharder.${key}`, millis(config.identifyRateLimit[0]), config.identifyRateLimit[1]))(shardConfig)))(tsplus_module_10.groupBy((c) => c.id % c.concurrency)(tsplus_module_9.map((config) => ({
43
- ...config,
44
- url: gateway.url,
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
- }))(tsplus_module_5.flatMap((r) => r.json)(rest
35
+ }))(tsplus_module_3.flatMap((r) => r.json)(rest
57
36
  .getGatewayBot())));
58
- })(tsplus_module_5.service(tsplus_module_17.RateLimiter)))(tsplus_module_5.service(tsplus_module_17.Config.DiscordConfig)))(tsplus_module_5.service(tsplus_module_17.DiscordREST)))(tsplus_module_5.service(ShardStore));
59
- export const Sharder = tsplus_module_18.Tag();
60
- export const LiveSharder = tsplus_module_5.toLayer(Sharder)(make);
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":";;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAA;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAA;AACvD,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AAEnD,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,EAAE,EAAE,CACvC,wBAMI,CACE,CAAC,EAKD,EAAE,CACF,uBACE,GAAG,EAAE,CACH,sBAGkB,yBAAiB,CAAC,CAAC,EAHrC,wBAAe;YACb,sBAAW,YAAY,CAAC;;SAEhB,CAAC,CAA2B,EACxC,CAAC,EAAE,EAAE,EAAE,CACL,wBAAe;YACb,sBAAW,YAAY,GAAG,CAAC,CAAC;YAC5B,mBAAgB,EAAE,CAAC;SACpB,CAAC,EAVN,CAAC,CAWA,EAxBP,KAAK;aACF,OAAO,CAAC;YACP,UAAU;YACV,YAAY;SACb,CAAC,CAqBD,CAAA;QAEL,OAAO,oBAED,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;YACb,EAAE;YACF,UAAU;SACX,CAAC,EALK,0BAAsB,CAAC,EAAE,CAAC,YAAY,EAAE,EAAE,CAC/C,2BAAwB,OA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D,wBAMW,CAAC,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,EAN3D,oBACO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;QAChB,GAAG,MAAM;QACT,GAAG,EAAE,OAAO,CAAC,GAAG;QAChB,WAAW,EAAE,OAAO,CAAC,mBAAmB,CAAC,eAAe;KACzD,CAAC,EALJ,OAAO,CAAC,MAAM,CAAC,UAAU,IAAI,OAAO,CAAC,MAAM,CAAC,CAKvC,CACuD,CAWzD,CAGA,CACmB,GAvCtB,yBAGY,GAAG,EAAE,CACb,MAAM,CAAC,OAAO,CAAgC;QAC5C,GAAG,EAAE,2BAA2B;QAChC,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 { Ref, Effect, EffectSource } from "dfx/utils/common";
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>) => import("../../utils/common.js").Effect<import("../../Log/index.js").Log, never, import("callbag-effect-ts/Source").EffectSource<never, WebSocketError | WebSocketCloseError, WebSocket.Data>>;
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 "callbag-effect-ts/Source/async";
4
- import * as tsplus_module_4 from "callbag-effect-ts/Source/repeatEffectOption";
5
- import * as tsplus_module_5 from "callbag-effect-ts/Source/unwrap";
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 recv = (ws) => tsplus_module_3.async((emit) => {
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.data(message.data);
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
- return () => {
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
- ws.close(1012, "reconnecting");
52
- resume(tsplus_module_1.fail(new WebSocketCloseError(1012, "reconnecting")));
49
+ return Effect.failSync(() => {
50
+ ws.close(1012, "reconnecting");
51
+ return new WebSocketCloseError(1012, "reconnecting");
52
+ });
53
53
  }
54
- else {
54
+ return Effect.sync(() => {
55
55
  ws.send(data);
56
- resume(tsplus_module_1.unit());
57
- }
58
- }))(tsplus_module_6.tap((p) => log.debug("WS", "send", p))(tsplus_module_5.unwrap(tsplus_module_1.map(() => tsplus_module_4.repeatEffectOption(take))(tsplus_module_1.async((resume) => {
59
- if (ws.readyState & ws.OPEN) {
60
- resume(tsplus_module_1.unit());
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":";;;;;;;;;;;;AAAA,OAAO,SAAS,MAAM,eAAe,CAAA;AAErC,MAAM,CAAC,MAAM,SAAS,GAAG,MAAM,EAAE,CAAA;AAIjC,MAAM,MAAM,GAAG,CAAC,MAAmB,EAAE,EAAE,CACrC,mDACQ,GAAG,IACF,IAAI,SAAS,CAAC,GAAG,CAAgC,sBAD1C,MAAM,IAEJ,CAAC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;QACtD,CAAC,CAAC,CAAA;KACH;IAED,OAAO,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE;QACtB,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IACf,CAAC,CAAC,CAAA;AACJ,CAAC,EAbH,oBACO,CAAC,IAAI,EAAE,EAAE,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAD9C,IAAI,CAC2C,CAY3C,CAAQ,CAAA;AAEd,MAAM,CAAC,MAAM,IAAI,GAAG,CAClB,GAAoB,EACpB,YAAkD,EAClD,EAAE,CACF,IAAI,yBAEM,GAAG,wBACH,EAAE;IACR,MAAM,UAAU,GAAG,IAAI,CAAC,EAAE,EAAE,YAAY,EAAE,GAAG,CAAC,CAAA;IAE9C,OAAO,sBAGH,QAAQ,CAAC,UAAU,CACjB,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,qBAAqB,IAAI,CAAC,CAAC,IAAI,KAAK,IAAI,CAC3D,EALE,sBACE,MAAM,CAAC,UAAU,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: import("../utils/common.js").Effect<Sharder, never, {
6
- raw: import("callbag-effect-ts/Source").EffectSource<never, never, import("../types.js").GatewayPayload<any>>;
7
- dispatch: import("callbag-effect-ts/Source").EffectSource<never, never, import("../types.js").GatewayPayload<import("../types.js").ReceiveEvent>>;
8
- fromDispatch: <K extends keyof import("../types.js").ReceiveEvents>(event: K) => import("callbag-effect-ts/Source").EffectSource<never, never, import("../types.js").ReceiveEvents[K]>;
9
- handleDispatch: <K_1 extends keyof import("../types.js").ReceiveEvents, R1, E1, A>(event: K_1, handle: (event: import("../types.js").ReceiveEvents[K_1]) => import("../utils/common.js").Effect<R1, E1, A>) => import("../utils/common.js").Effect<R1, E1, void>;
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: import("../utils/common.js").Tag<DiscordGateway>;
14
- export declare const LiveDiscordGateway: import("../utils/common.js").Layer<Sharder, never, DiscordGateway>;
12
+ export declare const DiscordGateway: Context.Tag<DiscordGateway>;
13
+ export declare const LiveDiscordGateway: Layer.Layer<Sharder, never, DiscordGateway>;
@@ -1,16 +1,11 @@
1
- import * as tsplus_module_1 from "callbag-effect-ts/Source/filter";
2
- import * as tsplus_module_2 from "callbag-effect-ts/Source/map";
3
- import * as tsplus_module_3 from "callbag-effect-ts/Source/fromEffect";
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 fromDispatchFactory = (source) => (event) => tsplus_module_2.map((p) => p.d)(tsplus_module_1.filter((p) => p.t === event)(source));
12
- const handleDispatchFactory = (source) => (event, handle) => tsplus_module_5.runDrain(tsplus_module_4.chainPar((a) => tsplus_module_3.fromEffect(handle(a.d)))(tsplus_module_1.filter((p) => p.t === event)(source)));
13
- export const make = tsplus_module_7.flatMap(sharder => tsplus_module_7.flatMap(raw => tsplus_module_7.map(dispatch => {
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
- })(tsplus_module_6.share(tsplus_module_4.chainPar((s) => s.dispatch)(sharder.shards))))(tsplus_module_6.share(tsplus_module_4.chainPar((s) => s.raw)(sharder.shards))))(tsplus_module_7.service(Sharder));
23
- export const DiscordGateway = tsplus_module_8.Tag();
24
- export const LiveDiscordGateway = tsplus_module_9.fromEffect(DiscordGateway)(make);
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":";;;;;;;;;AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAA;AAE5C,MAAM,mBAAmB,GACvB,CACE,MAAwE,EACxE,EAAE,CACJ,CACE,KAAQ,EACsC,EAAE,CAChD,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,MAAwE,EACxE,EAAE,CACJ,CACE,KAAQ,EACR,MAA8D,EAChC,EAAE,0BAChC,yBAEY,CAAC,CAAC,EAAE,EAAE,CAAC,2BAAwB,MAAM,CAAC,CAAC,CAAC,CAAQ,CAAC,CAAC,EAF9D,uBACU,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,KAAK,KAAK,EAD9B,MAAM,CACyB,CACgC,CAAS,CAAA;AAE5E,MAAM,CAAC,MAAM,IAAI,2BACT,OAAO,4BACP,GAAG,wBACH,QAAQ;IACd,MAAM,YAAY,GAAG,mBAAmB,CAAC,QAAQ,CAAC,CAAA;IAClD,MAAM,cAAc,GAAG,qBAAqB,CAAC,QAAQ,CAAC,CAAA;IAEtD,OAAO;QACL,GAAG;QACH,QAAQ;QACR,YAAY;QACZ,cAAc;KACf,CAAA;yBATkB,yBAAwB,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,EAAzC,OAAO,CAAC,MAAM,CAA4B,0BAD/C,yBAAwB,CAAC,CAAC,EAAE,EAAE,CAAC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