dfx 0.89.0 → 0.90.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.
Files changed (153) hide show
  1. package/Cache/driver.d.ts.map +1 -1
  2. package/Cache/driver.js.map +1 -1
  3. package/Cache/memory.d.ts +2 -2
  4. package/Cache/memory.d.ts.map +1 -1
  5. package/Cache/memory.js.map +1 -1
  6. package/Cache/memoryTTL.d.ts +2 -2
  7. package/Cache/memoryTTL.d.ts.map +1 -1
  8. package/Cache/memoryTTL.js.map +1 -1
  9. package/Cache/prelude.d.ts +5 -5
  10. package/Cache/prelude.d.ts.map +1 -1
  11. package/Cache/prelude.js.map +1 -1
  12. package/Cache.d.ts +2 -2
  13. package/Cache.d.ts.map +1 -1
  14. package/Cache.js.map +1 -1
  15. package/DiscordConfig.js.map +1 -1
  16. package/DiscordGateway/DiscordWS.d.ts +5 -6
  17. package/DiscordGateway/DiscordWS.d.ts.map +1 -1
  18. package/DiscordGateway/DiscordWS.js +31 -15
  19. package/DiscordGateway/DiscordWS.js.map +1 -1
  20. package/DiscordGateway/Messaging.d.ts.map +1 -1
  21. package/DiscordGateway/Messaging.js.map +1 -1
  22. package/DiscordGateway/Shard/heartbeats.d.ts +1 -1
  23. package/DiscordGateway/Shard/heartbeats.d.ts.map +1 -1
  24. package/DiscordGateway/Shard/heartbeats.js +2 -2
  25. package/DiscordGateway/Shard/heartbeats.js.map +1 -1
  26. package/DiscordGateway/Shard/identify.js.map +1 -1
  27. package/DiscordGateway/Shard/invalidSession.d.ts +1 -1
  28. package/DiscordGateway/Shard/invalidSession.d.ts.map +1 -1
  29. package/DiscordGateway/Shard/invalidSession.js +2 -2
  30. package/DiscordGateway/Shard/invalidSession.js.map +1 -1
  31. package/DiscordGateway/Shard/sendEvents.js.map +1 -1
  32. package/DiscordGateway/Shard/utils.d.ts +1 -1
  33. package/DiscordGateway/Shard/utils.d.ts.map +1 -1
  34. package/DiscordGateway/Shard/utils.js.map +1 -1
  35. package/DiscordGateway/Shard.d.ts +2 -2
  36. package/DiscordGateway/Shard.d.ts.map +1 -1
  37. package/DiscordGateway/Shard.js +1 -2
  38. package/DiscordGateway/Shard.js.map +1 -1
  39. package/DiscordGateway/ShardStore.js.map +1 -1
  40. package/DiscordGateway/Sharder.d.ts +1 -1
  41. package/DiscordGateway/Sharder.js.map +1 -1
  42. package/DiscordGateway/WS.js.map +1 -1
  43. package/DiscordGateway.d.ts +1 -1
  44. package/DiscordGateway.js.map +1 -1
  45. package/DiscordREST/types.js.map +1 -1
  46. package/DiscordREST/utils.js.map +1 -1
  47. package/DiscordREST.d.ts +1 -1
  48. package/DiscordREST.js.map +1 -1
  49. package/Helpers/flags.d.ts +2 -2
  50. package/Helpers/flags.d.ts.map +1 -1
  51. package/Helpers/flags.js.map +1 -1
  52. package/Helpers/intents.js.map +1 -1
  53. package/Helpers/interactions.d.ts +1 -1
  54. package/Helpers/interactions.d.ts.map +1 -1
  55. package/Helpers/interactions.js.map +1 -1
  56. package/Helpers/members.js.map +1 -1
  57. package/Helpers/permissions.d.ts.map +1 -1
  58. package/Helpers/permissions.js.map +1 -1
  59. package/Helpers/ui.js.map +1 -1
  60. package/Interactions/builder.js.map +1 -1
  61. package/Interactions/context.d.ts +2 -2
  62. package/Interactions/context.d.ts.map +1 -1
  63. package/Interactions/context.js.map +1 -1
  64. package/Interactions/definitions.d.ts.map +1 -1
  65. package/Interactions/definitions.js.map +1 -1
  66. package/Interactions/gateway.d.ts +1 -1
  67. package/Interactions/gateway.d.ts.map +1 -1
  68. package/Interactions/gateway.js.map +1 -1
  69. package/Interactions/handlers.d.ts.map +1 -1
  70. package/Interactions/handlers.js.map +1 -1
  71. package/Interactions/index.js.map +1 -1
  72. package/Interactions/utils.d.ts +1 -21
  73. package/Interactions/utils.d.ts.map +1 -1
  74. package/Interactions/utils.js.map +1 -1
  75. package/Interactions/webhook.d.ts +1 -1
  76. package/Interactions/webhook.d.ts.map +1 -1
  77. package/Interactions/webhook.js.map +1 -1
  78. package/RateLimit/memory.js.map +1 -1
  79. package/RateLimit/utils.js.map +1 -1
  80. package/RateLimit.js.map +1 -1
  81. package/gateway.d.ts +1 -2
  82. package/gateway.d.ts.map +1 -1
  83. package/gateway.js +1 -3
  84. package/gateway.js.map +1 -1
  85. package/index.js.map +1 -1
  86. package/mjs/Cache/driver.mjs.map +1 -1
  87. package/mjs/Cache/memory.mjs.map +1 -1
  88. package/mjs/Cache/memoryTTL.mjs.map +1 -1
  89. package/mjs/Cache/prelude.mjs.map +1 -1
  90. package/mjs/Cache.mjs.map +1 -1
  91. package/mjs/DiscordConfig.mjs.map +1 -1
  92. package/mjs/DiscordGateway/DiscordWS.mjs +30 -14
  93. package/mjs/DiscordGateway/DiscordWS.mjs.map +1 -1
  94. package/mjs/DiscordGateway/Messaging.mjs.map +1 -1
  95. package/mjs/DiscordGateway/Shard/heartbeats.mjs +2 -2
  96. package/mjs/DiscordGateway/Shard/heartbeats.mjs.map +1 -1
  97. package/mjs/DiscordGateway/Shard/identify.mjs.map +1 -1
  98. package/mjs/DiscordGateway/Shard/invalidSession.mjs +1 -1
  99. package/mjs/DiscordGateway/Shard/invalidSession.mjs.map +1 -1
  100. package/mjs/DiscordGateway/Shard/sendEvents.mjs.map +1 -1
  101. package/mjs/DiscordGateway/Shard/utils.mjs.map +1 -1
  102. package/mjs/DiscordGateway/Shard.mjs +1 -2
  103. package/mjs/DiscordGateway/Shard.mjs.map +1 -1
  104. package/mjs/DiscordGateway/ShardStore.mjs.map +1 -1
  105. package/mjs/DiscordGateway/Sharder.mjs.map +1 -1
  106. package/mjs/DiscordGateway/WS.mjs.map +1 -1
  107. package/mjs/DiscordGateway.mjs.map +1 -1
  108. package/mjs/DiscordREST/types.mjs.map +1 -1
  109. package/mjs/DiscordREST/utils.mjs.map +1 -1
  110. package/mjs/DiscordREST.mjs.map +1 -1
  111. package/mjs/Helpers/flags.mjs.map +1 -1
  112. package/mjs/Helpers/intents.mjs.map +1 -1
  113. package/mjs/Helpers/interactions.mjs.map +1 -1
  114. package/mjs/Helpers/members.mjs.map +1 -1
  115. package/mjs/Helpers/permissions.mjs.map +1 -1
  116. package/mjs/Helpers/ui.mjs.map +1 -1
  117. package/mjs/Interactions/builder.mjs.map +1 -1
  118. package/mjs/Interactions/context.mjs.map +1 -1
  119. package/mjs/Interactions/definitions.mjs.map +1 -1
  120. package/mjs/Interactions/gateway.mjs.map +1 -1
  121. package/mjs/Interactions/handlers.mjs.map +1 -1
  122. package/mjs/Interactions/index.mjs.map +1 -1
  123. package/mjs/Interactions/utils.mjs.map +1 -1
  124. package/mjs/Interactions/webhook.mjs.map +1 -1
  125. package/mjs/RateLimit/memory.mjs.map +1 -1
  126. package/mjs/RateLimit/utils.mjs.map +1 -1
  127. package/mjs/RateLimit.mjs.map +1 -1
  128. package/mjs/gateway.mjs +1 -2
  129. package/mjs/gateway.mjs.map +1 -1
  130. package/mjs/index.mjs.map +1 -1
  131. package/mjs/types.mjs.map +1 -1
  132. package/mjs/utils/Effect.mjs.map +1 -1
  133. package/mjs/version.mjs +1 -1
  134. package/mjs/version.mjs.map +1 -1
  135. package/mjs/webhooks.mjs.map +1 -1
  136. package/package.json +4 -8
  137. package/src/DiscordGateway/DiscordWS.ts +67 -25
  138. package/src/DiscordGateway/Shard/heartbeats.ts +2 -3
  139. package/src/DiscordGateway/Shard/invalidSession.ts +1 -2
  140. package/src/DiscordGateway/Shard.ts +5 -2
  141. package/src/gateway.ts +1 -2
  142. package/src/types.ts +6 -4
  143. package/src/version.ts +1 -1
  144. package/types.d.ts +6 -4
  145. package/types.d.ts.map +1 -1
  146. package/types.js.map +1 -1
  147. package/utils/Effect.d.ts.map +1 -1
  148. package/utils/Effect.js.map +1 -1
  149. package/version.d.ts +1 -1
  150. package/version.js +1 -1
  151. package/version.js.map +1 -1
  152. package/webhooks.js.map +1 -1
  153. package/src/DiscordGateway/WS.ts +0 -183
@@ -1 +1 @@
1
- {"version":3,"file":"Effect.mjs","names":["pipe","Deferred","Effect","PubSub","Queue","subscribeForEachPar","self","effect","flatMap","make","deferred","run","subscribe","queue","forever","take","_","fork","catchAllCause","failCause","scoped","all","await","concurrency","discard","foreverSwitch","f","fiberId","causeDeferred","fiber","tap","interruptAsFork","unit","tapErrorCause","fiber_","sync"],"sources":["../../src/utils/Effect.ts"],"sourcesContent":[null],"mappings":"AAAA,SAASA,IAAI,QAAQ,iBAAiB;AACtC,OAAO,KAAKC,QAAQ,MAAM,iBAAiB;AAC3C,OAAO,KAAKC,MAAM,MAAM,eAAe;AAEvC,OAAO,KAAKC,MAAM,MAAM,eAAe;AACvC,OAAO,KAAKC,KAAK,MAAM,cAAc;AAErC,OAAO,MAAMC,mBAAmB,GAAGA,CACjCC,IAAsB,EACtBC,MAAwC,KAExCL,MAAM,CAACM,OAAO,CAACP,QAAQ,CAACQ,IAAI,EAAY,EAAEC,QAAQ,IAAG;EACnD,MAAMC,GAAG,GAAGX,IAAI,CACdG,MAAM,CAACS,SAAS,CAACN,IAAI,CAAC,EACtBJ,MAAM,CAACM,OAAO,CAACK,KAAK,IAClBX,MAAM,CAACY,OAAO,CACZZ,MAAM,CAACM,OAAO,CAACJ,KAAK,CAACW,IAAI,CAACF,KAAK,CAAC,EAAEG,CAAC,IACjCd,MAAM,CAACe,IAAI,CACTf,MAAM,CAACgB,aAAa,CAACX,MAAM,CAACS,CAAC,CAAC,EAAEA,CAAC,IAC/Bf,QAAQ,CAACkB,SAAS,CAACT,QAAQ,EAAEM,CAAC,CAAC,CAChC,CACF,CACF,CACF,CACF,EACDd,MAAM,CAACkB,MAAM,CACd;EAED,OAAOlB,MAAM,CAACmB,GAAG,CAAC,CAACV,GAAG,EAAEV,QAAQ,CAACqB,KAAK,CAACZ,QAAQ,CAAC,CAAC,EAAE;IACjDa,WAAW,EAAE,WAAW;IACxBC,OAAO,EAAE;GACV,CAA+B;AAClC,CAAC,CAAC;AAEJ,OAAO,MAAMC,aAAa,GAAGA,CAC3BnB,IAA4B,EAC5BoB,CAAqC,KAErC1B,IAAI,CACFE,MAAM,CAACmB,GAAG,CAAC,CAACpB,QAAQ,CAACQ,IAAI,EAAa,EAAEP,MAAM,CAACyB,OAAO,CAAC,CAAC,EACxDzB,MAAM,CAACM,OAAO,CAAC,CAAC,CAACoB,aAAa,EAAED,OAAO,CAAC,KAAI;EAC1C,IAAIE,KAAuD;EAE3D,MAAMlB,GAAG,GAAGX,IAAI,CACdM,IAAI,EACJJ,MAAM,CAAC4B,GAAG,CAAC,MACTD,KAAK,GAAGA,KAAK,CAACE,eAAe,CAACJ,OAAO,CAAC,GAAGzB,MAAM,CAAC8B,IAAI,CACrD,EACD9B,MAAM,CAACM,OAAO,CAACQ,CAAC,IACdhB,IAAI,CACF0B,CAAC,CAACV,CAAC,CAAC,EACJd,MAAM,CAAC+B,aAAa,CAACjB,CAAC,IAAIf,QAAQ,CAACkB,SAAS,CAACS,aAAa,EAAEZ,CAAC,CAAC,CAAC,EAC/Dd,MAAM,CAACe,IAAI,CACZ,CACF,EACDf,MAAM,CAAC4B,GAAG,CAACI,MAAM,IACfhC,MAAM,CAACiC,IAAI,CAAC,MAAK;IACfN,KAAK,GAAGK,MAAM;EAChB,CAAC,CAAC,CACH,EACDhC,MAAM,CAACY,OAAO,CACf;EAED,OAAOZ,MAAM,CAACmB,GAAG,CAAC,CAACV,GAAG,EAAEV,QAAQ,CAACqB,KAAK,CAACM,aAAa,CAAC,CAAC,EAAE;IACtDL,WAAW,EAAE,WAAW;IACxBC,OAAO,EAAE;GACV,CAAyC;AAC5C,CAAC,CAAC,CACH"}
1
+ {"version":3,"file":"Effect.mjs","names":["pipe","Deferred","Effect","PubSub","Queue","subscribeForEachPar","self","effect","flatMap","make","deferred","run","subscribe","queue","forever","take","_","fork","catchAllCause","failCause","scoped","all","await","concurrency","discard","foreverSwitch","f","fiberId","causeDeferred","fiber","tap","interruptAsFork","unit","tapErrorCause","fiber_","sync"],"sources":["../../src/utils/Effect.ts"],"sourcesContent":[null],"mappings":"AAAA,SAASA,IAAI,QAAQ,iBAAiB;AACtC,OAAO,KAAKC,QAAQ,MAAM,iBAAiB;AAC3C,OAAO,KAAKC,MAAM,MAAM,eAAe;AAEvC,OAAO,KAAKC,MAAM,MAAM,eAAe;AACvC,OAAO,KAAKC,KAAK,MAAM,cAAc;AAErC,OAAO,MAAMC,mBAAmB,GAAGA,CACjCC,IAAsB,EACtBC,MAAwC,KAExCL,MAAM,CAACM,OAAO,CAACP,QAAQ,CAACQ,IAAI,EAAY,EAAEC,QAAQ,IAAG;EACnD,MAAMC,GAAG,GAAGX,IAAI,CACdG,MAAM,CAACS,SAAS,CAACN,IAAI,CAAC,EACtBJ,MAAM,CAACM,OAAO,CAACK,KAAK,IAClBX,MAAM,CAACY,OAAO,CACZZ,MAAM,CAACM,OAAO,CAACJ,KAAK,CAACW,IAAI,CAACF,KAAK,CAAC,EAAEG,CAAC,IACjCd,MAAM,CAACe,IAAI,CACTf,MAAM,CAACgB,aAAa,CAACX,MAAM,CAACS,CAAC,CAAC,EAAEA,CAAC,IAC/Bf,QAAQ,CAACkB,SAAS,CAACT,QAAQ,EAAEM,CAAC,CAAC,CAChC,CACF,CACF,CACF,CACF,EACDd,MAAM,CAACkB,MAAM,CACd;EAED,OAAOlB,MAAM,CAACmB,GAAG,CAAC,CAACV,GAAG,EAAEV,QAAQ,CAACqB,KAAK,CAACZ,QAAQ,CAAC,CAAC,EAAE;IACjDa,WAAW,EAAE,WAAW;IACxBC,OAAO,EAAE;GACV,CAA+B;AAClC,CAAC,CAAC;AAEJ,OAAO,MAAMC,aAAa,GAAGA,CAC3BnB,IAA4B,EAC5BoB,CAAqC,KAErC1B,IAAI,CACFE,MAAM,CAACmB,GAAG,CAAC,CAACpB,QAAQ,CAACQ,IAAI,EAAa,EAAEP,MAAM,CAACyB,OAAO,CAAC,CAAC,EACxDzB,MAAM,CAACM,OAAO,CAAC,CAAC,CAACoB,aAAa,EAAED,OAAO,CAAC,KAAI;EAC1C,IAAIE,KAAuD;EAE3D,MAAMlB,GAAG,GAAGX,IAAI,CACdM,IAAI,EACJJ,MAAM,CAAC4B,GAAG,CAAC,MACTD,KAAK,GAAGA,KAAK,CAACE,eAAe,CAACJ,OAAO,CAAC,GAAGzB,MAAM,CAAC8B,IAAI,CACrD,EACD9B,MAAM,CAACM,OAAO,CAACQ,CAAC,IACdhB,IAAI,CACF0B,CAAC,CAACV,CAAC,CAAC,EACJd,MAAM,CAAC+B,aAAa,CAACjB,CAAC,IAAIf,QAAQ,CAACkB,SAAS,CAACS,aAAa,EAAEZ,CAAC,CAAC,CAAC,EAC/Dd,MAAM,CAACe,IAAI,CACZ,CACF,EACDf,MAAM,CAAC4B,GAAG,CAACI,MAAM,IACfhC,MAAM,CAACiC,IAAI,CAAC,MAAK;IACfN,KAAK,GAAGK,MAAM;EAChB,CAAC,CAAC,CACH,EACDhC,MAAM,CAACY,OAAO,CACf;EAED,OAAOZ,MAAM,CAACmB,GAAG,CAAC,CAACV,GAAG,EAAEV,QAAQ,CAACqB,KAAK,CAACM,aAAa,CAAC,CAAC,EAAE;IACtDL,WAAW,EAAE,WAAW;IACxBC,OAAO,EAAE;GACV,CAAyC;AAC5C,CAAC,CAAC,CACH","ignoreList":[]}
package/mjs/version.mjs CHANGED
@@ -1,2 +1,2 @@
1
- export const LIB_VERSION = "0.89.0";
1
+ export const LIB_VERSION = "0.90.0";
2
2
  //# sourceMappingURL=version.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"version.mjs","names":["LIB_VERSION"],"sources":["../src/version.ts"],"sourcesContent":[null],"mappings":"AAAA,OAAO,MAAMA,WAAW,GAAG,QAAQ"}
1
+ {"version":3,"file":"version.mjs","names":["LIB_VERSION"],"sources":["../src/version.ts"],"sourcesContent":[null],"mappings":"AAAA,OAAO,MAAMA,WAAW,GAAG,QAAQ","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"webhooks.mjs","names":["DiscordRESTLive","MemoryRateLimitStoreLive","RateLimiterLive","Layer","BadWebhookSignature","WebhookConfig","WebhookParseError","makeHandler","makeSimpleHandler","layer","webhookLayer","layerConfig","webhookLayerConfig","DiscordLive","mergeAll","pipe","provide"],"sources":["../src/webhooks.ts"],"sourcesContent":[null],"mappings":"AAAA,SAASA,eAAe,QAAQ,iBAAiB;AACjD,SACEC,wBAAoD,EACpDC,eAAkC,QAC7B,eAAe;AACtB,OAAO,KAAKC,KAAK,MAAM,cAAc;AAErC,SACEC,mBAAmB,EACnBC,aAAa,EACbC,iBAAiB,EACjBC,WAAW,EACXC,iBAAiB,EACjBC,KAAK,IAAIC,YAAY,EACrBC,WAAW,IAAIC,kBAAkB,QAC5B,0BAA0B;AAEjC,OAAO,MAAMC,WAAW,gBAAGV,KAAK,CAACW,QAAQ,CACvCd,eAAe,EACfE,eAAe,CAChB,CAACa,IAAI,eAACZ,KAAK,CAACa,OAAO,CAACf,wBAAwB,CAAC,CAAC"}
1
+ {"version":3,"file":"webhooks.mjs","names":["DiscordRESTLive","MemoryRateLimitStoreLive","RateLimiterLive","Layer","BadWebhookSignature","WebhookConfig","WebhookParseError","makeHandler","makeSimpleHandler","layer","webhookLayer","layerConfig","webhookLayerConfig","DiscordLive","mergeAll","pipe","provide"],"sources":["../src/webhooks.ts"],"sourcesContent":[null],"mappings":"AAAA,SAASA,eAAe,QAAQ,iBAAiB;AACjD,SACEC,wBAAoD,EACpDC,eAAkC,QAC7B,eAAe;AACtB,OAAO,KAAKC,KAAK,MAAM,cAAc;AAErC,SACEC,mBAAmB,EACnBC,aAAa,EACbC,iBAAiB,EACjBC,WAAW,EACXC,iBAAiB,EACjBC,KAAK,IAAIC,YAAY,EACrBC,WAAW,IAAIC,kBAAkB,QAC5B,0BAA0B;AAEjC,OAAO,MAAMC,WAAW,gBAAGV,KAAK,CAACW,QAAQ,CACvCd,eAAe,EACfE,eAAe,CAChB,CAACa,IAAI,eAACZ,KAAK,CAACa,OAAO,CAACf,wBAAwB,CAAC,CAAC","ignoreList":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dfx",
3
- "version": "0.89.0",
3
+ "version": "0.90.0",
4
4
  "description": "Effect-TS discord library",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -34,13 +34,9 @@
34
34
  },
35
35
  "sideEffects": [],
36
36
  "author": "Tim Smart <hello@timsmart.co>",
37
- "dependencies": {
38
- "isomorphic-ws": "^5.0.0",
39
- "ws": "^8.16.0"
40
- },
41
37
  "peerDependencies": {
42
- "@effect/platform": "^0.46.0",
43
- "effect": "^2.4.0"
38
+ "@effect/platform": "^0.48.2",
39
+ "effect": "^2.4.6"
44
40
  },
45
41
  "optionalDependencies": {
46
42
  "bufferutil": "^4.0.8",
@@ -48,6 +44,6 @@
48
44
  "utf-8-validate": "^6.0.3",
49
45
  "zlib-sync": "^0.1.9"
50
46
  },
51
- "gitHead": "ec82c7e09cb83b7f41c3e2a7d82002289612e00f",
47
+ "gitHead": "2f083ee47cd86e30b6b2e15b8141fa3f2d68d391",
52
48
  "main": "./index.js"
53
49
  }
@@ -2,39 +2,46 @@ import { GenericTag } from "effect/Context"
2
2
  import * as Effect from "effect/Effect"
3
3
  import * as Layer from "effect/Layer"
4
4
  import * as Ref from "effect/Ref"
5
- import { WSLive, Reconnect, WS } from "dfx/DiscordGateway/WS"
6
5
  import type * as Discord from "dfx/types"
7
- import type WebSocket from "isomorphic-ws"
6
+ import * as Socket from "@effect/platform/Socket"
7
+ import * as Queue from "effect/Queue"
8
+ import * as Schedule from "effect/Schedule"
8
9
 
9
10
  export type Message = Discord.GatewayPayload | Reconnect
10
11
 
12
+ export const Reconnect = Symbol.for("dfx/DiscordGateway/WS/Reconnect")
13
+ export type Reconnect = typeof Reconnect
14
+
11
15
  export interface OpenOpts {
12
16
  url?: string
13
17
  version?: number
14
18
  encoding?: DiscordWSCodec
15
19
  outbound: Effect.Effect<Message>
16
- onConnecting?: Effect.Effect<void>
20
+ onConnecting: Effect.Effect<void>
17
21
  }
18
22
 
19
23
  export interface DiscordWSCodecService {
20
24
  type: "json" | "etf"
21
- encode: (p: Discord.GatewayPayload) => string
22
- decode: (p: WebSocket.Data) => Discord.GatewayPayload
25
+ encode: (p: Discord.GatewayPayload) => Uint8Array
26
+ decode: (p: Uint8Array) => Discord.GatewayPayload
23
27
  }
24
28
  export interface DiscordWSCodec {
25
29
  readonly _: unique symbol
26
30
  }
31
+
32
+ const decoder = new TextDecoder()
33
+ const encoder = new TextEncoder()
34
+
27
35
  export const DiscordWSCodec = GenericTag<DiscordWSCodec, DiscordWSCodecService>(
28
36
  "dfx/DiscordGateway/DiscordWS/Codec",
29
37
  )
30
38
  export const JsonDiscordWSCodecLive = Layer.succeed(DiscordWSCodec, {
31
39
  type: "json",
32
- encode: p => JSON.stringify(p),
33
- decode: p => JSON.parse(p.toString("utf8")),
40
+ encode: p => encoder.encode(JSON.stringify(p)),
41
+ decode: p => JSON.parse(decoder.decode(p)),
34
42
  })
35
43
 
36
44
  const make = Effect.gen(function* (_) {
37
- const ws = yield* _(WS)
38
45
  const encoding = yield* _(DiscordWSCodec)
39
46
 
40
47
  const connect = ({
@@ -49,26 +56,64 @@ const make = Effect.gen(function* (_) {
49
56
  )
50
57
  const setUrl = (url: string) =>
51
58
  Ref.set(urlRef, `${url}?v=${version}&encoding=${encoding.type}`)
52
- const takeOutbound = Effect.map(outbound, msg =>
53
- msg === Reconnect ? msg : encoding.encode(msg),
54
- )
59
+ const messages = yield* _(Queue.unbounded<Discord.GatewayPayload>())
55
60
  const socket = yield* _(
56
- ws.connect({
57
- urlRef,
58
- takeOutbound,
59
- onConnecting,
60
- reconnectWhen: e =>
61
- (e._tag === "WebSocketCloseError" && e.code < 2000) ||
62
- (e._tag === "WebSocketError" && e.reason === "open-timeout"),
61
+ Socket.makeWebSocket(Ref.get(urlRef), {
62
+ closeCodeIsError: _ => true,
63
+ openTimeout: 5000,
63
64
  }),
64
65
  )
65
- const take = Effect.map(socket.take, encoding.decode)
66
+ const write = yield* _(socket.writer)
67
+ yield* _(
68
+ outbound,
69
+ Effect.flatMap(_ => {
70
+ if (_ === Reconnect) {
71
+ return Effect.zipRight(
72
+ Effect.logTrace("Reconnecting"),
73
+ write(new Socket.CloseEvent(1012, "reconnecting")),
74
+ )
75
+ }
76
+ return Effect.zipRight(Effect.logTrace(_), write(encoding.encode(_)))
77
+ }),
78
+ Effect.forever,
79
+ Effect.annotateLogs("channel", "outbound"),
80
+ Effect.forkScoped,
81
+ )
82
+ yield* _(
83
+ onConnecting,
84
+ Effect.zipRight(
85
+ socket.run(_ => {
86
+ const message = encoding.decode(_)
87
+ return Effect.zipRight(
88
+ Effect.logTrace(message),
89
+ messages.offer(message),
90
+ )
91
+ }),
92
+ ),
93
+ Effect.retry({
94
+ while: e => e.reason === "Close" && e.code === 1012,
95
+ }),
96
+ Effect.catchAllCause(cause =>
97
+ Effect.logDebug("Got socket error, reconnecting", cause),
98
+ ),
99
+ Effect.repeat(
100
+ Schedule.exponential(500).pipe(
101
+ Schedule.union(Schedule.spaced(10000)),
102
+ ),
103
+ ),
104
+ Effect.annotateLogs("channel", "inbound"),
105
+ Effect.forkScoped,
106
+ )
66
107
 
67
108
  return {
68
- take,
109
+ take: Queue.take(messages),
69
110
  setUrl,
70
111
  } as const
71
- })
112
+ }).pipe(
113
+ Effect.annotateLogs({
114
+ module: "DiscordGateway/DiscordWS",
115
+ }),
116
+ )
72
117
 
73
118
  return { connect } as const
74
119
  })
@@ -80,7 +125,4 @@ export const DiscordWS = GenericTag<
80
125
  DiscordWS,
81
126
  Effect.Effect.Success<typeof make>
82
127
  >("dfx/DiscordGateway/DiscordWS")
83
- export const DiscordWSLive = Layer.provide(
84
- Layer.effect(DiscordWS, make),
85
- WSLive,
86
- )
128
+ export const DiscordWSLive = Layer.effect(DiscordWS, make)
@@ -4,9 +4,8 @@ import * as Effect from "effect/Effect"
4
4
  import * as Queue from "effect/Queue"
5
5
  import * as Ref from "effect/Ref"
6
6
  import * as Schedule from "effect/Schedule"
7
- import type * as DiscordWS from "dfx/DiscordGateway/DiscordWS"
7
+ import * as DiscordWS from "dfx/DiscordGateway/DiscordWS"
8
8
  import * as SendEvents from "dfx/DiscordGateway/Shard/sendEvents"
9
- import { Reconnect } from "dfx/DiscordGateway/WS"
10
9
  import type * as Discord from "dfx/types"
11
10
  import * as EffectU from "dfx/utils/Effect"
12
11
 
@@ -22,7 +21,7 @@ const payloadOrReconnect = (
22
21
  Effect.flatMap(
23
22
  Ref.get(ref),
24
23
  (acked): Effect.Effect<DiscordWS.Message> =>
25
- acked ? payload(seqRef) : Effect.succeed(Reconnect),
24
+ acked ? payload(seqRef) : Effect.succeed(DiscordWS.Reconnect),
26
25
  )
27
26
 
28
27
  export const send = (
@@ -1,8 +1,7 @@
1
1
  import * as Option from "effect/Option"
2
2
  import * as Effect from "effect/Effect"
3
3
  import * as Ref from "effect/Ref"
4
- import type { Message } from "dfx/DiscordGateway/DiscordWS"
5
- import { Reconnect } from "dfx/DiscordGateway/WS"
4
+ import { Reconnect, type Message } from "dfx/DiscordGateway/DiscordWS"
6
5
  import type * as Discord from "dfx/types"
7
6
 
8
7
  export const fromPayload = (
@@ -11,12 +11,15 @@ import * as Queue from "effect/Queue"
11
11
  import * as Ref from "effect/Ref"
12
12
  import { DiscordConfig } from "dfx/DiscordConfig"
13
13
  import type { Message } from "dfx/DiscordGateway/DiscordWS"
14
- import { DiscordWS, DiscordWSLive } from "dfx/DiscordGateway/DiscordWS"
14
+ import {
15
+ DiscordWS,
16
+ DiscordWSLive,
17
+ Reconnect,
18
+ } from "dfx/DiscordGateway/DiscordWS"
15
19
  import * as Heartbeats from "dfx/DiscordGateway/Shard/heartbeats"
16
20
  import * as Identify from "dfx/DiscordGateway/Shard/identify"
17
21
  import * as InvalidSession from "dfx/DiscordGateway/Shard/invalidSession"
18
22
  import * as Utils from "dfx/DiscordGateway/Shard/utils"
19
- import { Reconnect } from "dfx/DiscordGateway/WS"
20
23
  import { RateLimiterLive, RateLimiter } from "dfx/RateLimit"
21
24
  import * as Discord from "dfx/types"
22
25
  import { Messaging, MesssagingLive } from "dfx/DiscordGateway/Messaging"
package/src/gateway.ts CHANGED
@@ -6,7 +6,6 @@ import * as Shard from "dfx/DiscordGateway/Shard"
6
6
  import * as SendEvent from "dfx/DiscordGateway/Shard/sendEvents"
7
7
  import * as ShardStore from "dfx/DiscordGateway/ShardStore"
8
8
  import { MemoryShardStoreLive } from "dfx/DiscordGateway/ShardStore"
9
- import * as WS from "dfx/DiscordGateway/WS"
10
9
  import { DiscordRESTLive } from "dfx/DiscordREST"
11
10
  import { InteractionsRegistryLive } from "dfx/Interactions/gateway"
12
11
  import { MemoryRateLimitStoreLive, RateLimiterLive } from "dfx/RateLimit"
@@ -22,7 +21,7 @@ export {
22
21
  setInteractionsSync,
23
22
  } from "dfx/Interactions/gateway"
24
23
 
25
- export { CachePrelude, DiscordWS, SendEvent, Shard, ShardStore, WS }
24
+ export { CachePrelude, DiscordWS, SendEvent, Shard, ShardStore }
26
25
 
27
26
  export const DiscordLive = Layer.mergeAll(
28
27
  RateLimiterLive,
package/src/types.ts CHANGED
@@ -1156,10 +1156,12 @@ export interface CreateMessageParams {
1156
1156
  readonly files?: string
1157
1157
  /** JSON-encoded body of non-file params, only for multipart/form-data requests. See Uploading Files */
1158
1158
  readonly payload_json?: string
1159
- /** Attachment objects with filename and description. See Uploading Files */
1159
+ /** Attachment objects with filename and description. See [Uploading Files](#DOCS_REFERENCE/uploading-files */
1160
1160
  readonly attachments?: Array<Attachment>
1161
1161
  /** Message flags combined as a bitfield (only SUPPRESS_EMBEDS and SUPPRESS_NOTIFICATIONS can be set) */
1162
1162
  readonly flags?: number
1163
+ /** If true and nonce is present, it will be checked for uniqueness in the past few minutes. If another message was created by the same author with the same nonce, that message will be returned and no new message will be created. */
1164
+ readonly enforce_nonce?: boolean
1163
1165
  }
1164
1166
  export function createRoutes<O = any>(
1165
1167
  fetch: <R, P>(route: Route<P, O>) => RestResponse<R>,
@@ -3100,7 +3102,7 @@ The emoji must be URL Encoded or the request will fail with 10014: Unknown Emoji
3100
3102
  params?: Partial<EditWebhookMessageParams>,
3101
3103
  options?: O,
3102
3104
  ) => RestResponse<Message>
3103
- /** Add a new webhook to your GitHub repo (in the repo's settings), and use this endpoint as the "Payload URL." You can choose what events your Discord channel receives by choosing the "Let me select individual events" option and selecting individual events for the new webhook you're configuring. */
3105
+ /** Add a new webhook to your GitHub repo (in the repo's settings), and use this endpoint as the "Payload URL." You can choose what events your Discord channel receives by choosing the "Let me select individual events" option and selecting individual events for the new webhook you're configuring. The supported events are commit_comment, create, delete, fork, issue_comment, issues, member, public, pull_request, pull_request_review, pull_request_review_comment, push, release, watch, check_run, check_suite, discussion, and discussion_comment. */
3104
3106
  executeGitHubCompatibleWebhook: (
3105
3107
  webhookId: string,
3106
3108
  webhookToken: string,
@@ -3772,7 +3774,7 @@ export interface ExecuteWebhookParams {
3772
3774
  readonly payload_json: string
3773
3775
  /** attachment objects with filename and description */
3774
3776
  readonly attachments: Array<Attachment>
3775
- /** message flags combined as a bitfield (only SUPPRESS_EMBEDS can be set) */
3777
+ /** message flags combined as a bitfield (only SUPPRESS_EMBEDS and SUPPRESS_NOTIFICATIONS can be set can be set) */
3776
3778
  readonly flags: number
3777
3779
  /** name of thread to create (requires the webhook channel to be a forum or media channel) */
3778
3780
  readonly thread_name: string
@@ -4661,7 +4663,7 @@ export interface InteractionCallbackMessage {
4661
4663
  readonly embeds?: Array<Embed>
4662
4664
  /** allowed mentions object */
4663
4665
  readonly allowed_mentions?: AllowedMention
4664
- /** message flags combined as a bitfield (only SUPPRESS_EMBEDS and EPHEMERAL can be set) */
4666
+ /** message flags combined as a bitfield (only SUPPRESS_EMBEDS, EPHEMERAL, and SUPPRESS_NOTIFICATIONS can be set) */
4665
4667
  readonly flags?: number
4666
4668
  /** message components */
4667
4669
  readonly components?: Array<Component>
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const LIB_VERSION = "0.89.0";
1
+ export const LIB_VERSION = "0.90.0";
package/types.d.ts CHANGED
@@ -1154,10 +1154,12 @@ export interface CreateMessageParams {
1154
1154
  readonly files?: string;
1155
1155
  /** JSON-encoded body of non-file params, only for multipart/form-data requests. See Uploading Files */
1156
1156
  readonly payload_json?: string;
1157
- /** Attachment objects with filename and description. See Uploading Files */
1157
+ /** Attachment objects with filename and description. See [Uploading Files](#DOCS_REFERENCE/uploading-files */
1158
1158
  readonly attachments?: Array<Attachment>;
1159
1159
  /** Message flags combined as a bitfield (only SUPPRESS_EMBEDS and SUPPRESS_NOTIFICATIONS can be set) */
1160
1160
  readonly flags?: number;
1161
+ /** If true and nonce is present, it will be checked for uniqueness in the past few minutes. If another message was created by the same author with the same nonce, that message will be returned and no new message will be created. */
1162
+ readonly enforce_nonce?: boolean;
1161
1163
  }
1162
1164
  export declare function createRoutes<O = any>(fetch: <R, P>(route: Route<P, O>) => RestResponse<R>): Endpoints<O>;
1163
1165
  export interface CreateStageInstanceParams {
@@ -1548,7 +1550,7 @@ export interface Endpoints<O> {
1548
1550
  editOriginalInteractionResponse: (applicationId: string, interactionToken: string, params?: Partial<EditWebhookMessageParams>, options?: O) => RestResponse<Message>;
1549
1551
  /** Edits a previously-sent webhook message from the same token. Returns a message object on success. */
1550
1552
  editWebhookMessage: (webhookId: string, webhookToken: string, messageId: string, params?: Partial<EditWebhookMessageParams>, options?: O) => RestResponse<Message>;
1551
- /** Add a new webhook to your GitHub repo (in the repo's settings), and use this endpoint as the "Payload URL." You can choose what events your Discord channel receives by choosing the "Let me select individual events" option and selecting individual events for the new webhook you're configuring. */
1553
+ /** Add a new webhook to your GitHub repo (in the repo's settings), and use this endpoint as the "Payload URL." You can choose what events your Discord channel receives by choosing the "Let me select individual events" option and selecting individual events for the new webhook you're configuring. The supported events are commit_comment, create, delete, fork, issue_comment, issues, member, public, pull_request, pull_request_review, pull_request_review_comment, push, release, watch, check_run, check_suite, discussion, and discussion_comment. */
1552
1554
  executeGitHubCompatibleWebhook: (webhookId: string, webhookToken: string, options?: O) => RestResponse<any>;
1553
1555
  /** Refer to Slack's documentation for more information. We do not support Slack's channel, icon_emoji, mrkdwn, or mrkdwn_in properties. */
1554
1556
  executeSlackCompatibleWebhook: (webhookId: string, webhookToken: string, options?: O) => RestResponse<any>;
@@ -1837,7 +1839,7 @@ export interface ExecuteWebhookParams {
1837
1839
  readonly payload_json: string;
1838
1840
  /** attachment objects with filename and description */
1839
1841
  readonly attachments: Array<Attachment>;
1840
- /** message flags combined as a bitfield (only SUPPRESS_EMBEDS can be set) */
1842
+ /** message flags combined as a bitfield (only SUPPRESS_EMBEDS and SUPPRESS_NOTIFICATIONS can be set can be set) */
1841
1843
  readonly flags: number;
1842
1844
  /** name of thread to create (requires the webhook channel to be a forum or media channel) */
1843
1845
  readonly thread_name: string;
@@ -2721,7 +2723,7 @@ export interface InteractionCallbackMessage {
2721
2723
  readonly embeds?: Array<Embed>;
2722
2724
  /** allowed mentions object */
2723
2725
  readonly allowed_mentions?: AllowedMention;
2724
- /** message flags combined as a bitfield (only SUPPRESS_EMBEDS and EPHEMERAL can be set) */
2726
+ /** message flags combined as a bitfield (only SUPPRESS_EMBEDS, EPHEMERAL, and SUPPRESS_NOTIFICATIONS can be set) */
2725
2727
  readonly flags?: number;
2726
2728
  /** message components */
2727
2729
  readonly components?: Array<Component>;