@eventmodelers/node-kit 0.0.2

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 (546) hide show
  1. package/README.md +66 -0
  2. package/package.json +36 -0
  3. package/src/cli.js +176 -0
  4. package/templates/.claude/skills/connect/SKILL.md +169 -0
  5. package/templates/.claude/skills/load-slice/SKILL.md +86 -0
  6. package/templates/realtime-agent/node_modules/.package-lock.json +107 -0
  7. package/templates/realtime-agent/node_modules/@supabase/auth-js/LICENSE +21 -0
  8. package/templates/realtime-agent/node_modules/@supabase/auth-js/README.md +190 -0
  9. package/templates/realtime-agent/node_modules/@supabase/auth-js/dist/main/AuthAdminApi.d.ts +4 -0
  10. package/templates/realtime-agent/node_modules/@supabase/auth-js/dist/main/AuthAdminApi.d.ts.map +1 -0
  11. package/templates/realtime-agent/node_modules/@supabase/auth-js/dist/main/AuthAdminApi.js +7 -0
  12. package/templates/realtime-agent/node_modules/@supabase/auth-js/dist/main/AuthAdminApi.js.map +1 -0
  13. package/templates/realtime-agent/node_modules/@supabase/auth-js/dist/main/AuthClient.d.ts +4 -0
  14. package/templates/realtime-agent/node_modules/@supabase/auth-js/dist/main/AuthClient.d.ts.map +1 -0
  15. package/templates/realtime-agent/node_modules/@supabase/auth-js/dist/main/AuthClient.js +7 -0
  16. package/templates/realtime-agent/node_modules/@supabase/auth-js/dist/main/AuthClient.js.map +1 -0
  17. package/templates/realtime-agent/node_modules/@supabase/auth-js/dist/main/GoTrueAdminApi.d.ts +716 -0
  18. package/templates/realtime-agent/node_modules/@supabase/auth-js/dist/main/GoTrueAdminApi.d.ts.map +1 -0
  19. package/templates/realtime-agent/node_modules/@supabase/auth-js/dist/main/GoTrueAdminApi.js +1108 -0
  20. package/templates/realtime-agent/node_modules/@supabase/auth-js/dist/main/GoTrueAdminApi.js.map +1 -0
  21. package/templates/realtime-agent/node_modules/@supabase/auth-js/dist/main/GoTrueClient.d.ts +2473 -0
  22. package/templates/realtime-agent/node_modules/@supabase/auth-js/dist/main/GoTrueClient.d.ts.map +1 -0
  23. package/templates/realtime-agent/node_modules/@supabase/auth-js/dist/main/GoTrueClient.js +5217 -0
  24. package/templates/realtime-agent/node_modules/@supabase/auth-js/dist/main/GoTrueClient.js.map +1 -0
  25. package/templates/realtime-agent/node_modules/@supabase/auth-js/dist/main/index.d.ts +9 -0
  26. package/templates/realtime-agent/node_modules/@supabase/auth-js/dist/main/index.d.ts.map +1 -0
  27. package/templates/realtime-agent/node_modules/@supabase/auth-js/dist/main/index.js +20 -0
  28. package/templates/realtime-agent/node_modules/@supabase/auth-js/dist/main/index.js.map +1 -0
  29. package/templates/realtime-agent/node_modules/@supabase/auth-js/dist/main/lib/base64url.d.ts +76 -0
  30. package/templates/realtime-agent/node_modules/@supabase/auth-js/dist/main/lib/base64url.d.ts.map +1 -0
  31. package/templates/realtime-agent/node_modules/@supabase/auth-js/dist/main/lib/base64url.js +269 -0
  32. package/templates/realtime-agent/node_modules/@supabase/auth-js/dist/main/lib/base64url.js.map +1 -0
  33. package/templates/realtime-agent/node_modules/@supabase/auth-js/dist/main/lib/constants.d.ts +26 -0
  34. package/templates/realtime-agent/node_modules/@supabase/auth-js/dist/main/lib/constants.d.ts.map +1 -0
  35. package/templates/realtime-agent/node_modules/@supabase/auth-js/dist/main/lib/constants.js +31 -0
  36. package/templates/realtime-agent/node_modules/@supabase/auth-js/dist/main/lib/constants.js.map +1 -0
  37. package/templates/realtime-agent/node_modules/@supabase/auth-js/dist/main/lib/error-codes.d.ts +7 -0
  38. package/templates/realtime-agent/node_modules/@supabase/auth-js/dist/main/lib/error-codes.d.ts.map +1 -0
  39. package/templates/realtime-agent/node_modules/@supabase/auth-js/dist/main/lib/error-codes.js +3 -0
  40. package/templates/realtime-agent/node_modules/@supabase/auth-js/dist/main/lib/error-codes.js.map +1 -0
  41. package/templates/realtime-agent/node_modules/@supabase/auth-js/dist/main/lib/errors.d.ts +258 -0
  42. package/templates/realtime-agent/node_modules/@supabase/auth-js/dist/main/lib/errors.d.ts.map +1 -0
  43. package/templates/realtime-agent/node_modules/@supabase/auth-js/dist/main/lib/errors.js +290 -0
  44. package/templates/realtime-agent/node_modules/@supabase/auth-js/dist/main/lib/errors.js.map +1 -0
  45. package/templates/realtime-agent/node_modules/@supabase/auth-js/dist/main/lib/fetch.d.ts +54 -0
  46. package/templates/realtime-agent/node_modules/@supabase/auth-js/dist/main/lib/fetch.d.ts.map +1 -0
  47. package/templates/realtime-agent/node_modules/@supabase/auth-js/dist/main/lib/fetch.js +200 -0
  48. package/templates/realtime-agent/node_modules/@supabase/auth-js/dist/main/lib/fetch.js.map +1 -0
  49. package/templates/realtime-agent/node_modules/@supabase/auth-js/dist/main/lib/helpers.d.ts +94 -0
  50. package/templates/realtime-agent/node_modules/@supabase/auth-js/dist/main/lib/helpers.d.ts.map +1 -0
  51. package/templates/realtime-agent/node_modules/@supabase/auth-js/dist/main/lib/helpers.js +406 -0
  52. package/templates/realtime-agent/node_modules/@supabase/auth-js/dist/main/lib/helpers.js.map +1 -0
  53. package/templates/realtime-agent/node_modules/@supabase/auth-js/dist/main/lib/local-storage.d.ts +9 -0
  54. package/templates/realtime-agent/node_modules/@supabase/auth-js/dist/main/lib/local-storage.d.ts.map +1 -0
  55. package/templates/realtime-agent/node_modules/@supabase/auth-js/dist/main/lib/local-storage.js +21 -0
  56. package/templates/realtime-agent/node_modules/@supabase/auth-js/dist/main/lib/local-storage.js.map +1 -0
  57. package/templates/realtime-agent/node_modules/@supabase/auth-js/dist/main/lib/locks.d.ts +107 -0
  58. package/templates/realtime-agent/node_modules/@supabase/auth-js/dist/main/lib/locks.d.ts.map +1 -0
  59. package/templates/realtime-agent/node_modules/@supabase/auth-js/dist/main/lib/locks.js +349 -0
  60. package/templates/realtime-agent/node_modules/@supabase/auth-js/dist/main/lib/locks.js.map +1 -0
  61. package/templates/realtime-agent/node_modules/@supabase/auth-js/dist/main/lib/polyfills.d.ts +5 -0
  62. package/templates/realtime-agent/node_modules/@supabase/auth-js/dist/main/lib/polyfills.d.ts.map +1 -0
  63. package/templates/realtime-agent/node_modules/@supabase/auth-js/dist/main/lib/polyfills.js +29 -0
  64. package/templates/realtime-agent/node_modules/@supabase/auth-js/dist/main/lib/polyfills.js.map +1 -0
  65. package/templates/realtime-agent/node_modules/@supabase/auth-js/dist/main/lib/types.d.ts +2498 -0
  66. package/templates/realtime-agent/node_modules/@supabase/auth-js/dist/main/lib/types.d.ts.map +1 -0
  67. package/templates/realtime-agent/node_modules/@supabase/auth-js/dist/main/lib/types.js +23 -0
  68. package/templates/realtime-agent/node_modules/@supabase/auth-js/dist/main/lib/types.js.map +1 -0
  69. package/templates/realtime-agent/node_modules/@supabase/auth-js/dist/main/lib/version.d.ts +2 -0
  70. package/templates/realtime-agent/node_modules/@supabase/auth-js/dist/main/lib/version.d.ts.map +1 -0
  71. package/templates/realtime-agent/node_modules/@supabase/auth-js/dist/main/lib/version.js +11 -0
  72. package/templates/realtime-agent/node_modules/@supabase/auth-js/dist/main/lib/version.js.map +1 -0
  73. package/templates/realtime-agent/node_modules/@supabase/auth-js/dist/main/lib/web3/ethereum.d.ts +96 -0
  74. package/templates/realtime-agent/node_modules/@supabase/auth-js/dist/main/lib/web3/ethereum.d.ts.map +1 -0
  75. package/templates/realtime-agent/node_modules/@supabase/auth-js/dist/main/lib/web3/ethereum.js +66 -0
  76. package/templates/realtime-agent/node_modules/@supabase/auth-js/dist/main/lib/web3/ethereum.js.map +1 -0
  77. package/templates/realtime-agent/node_modules/@supabase/auth-js/dist/main/lib/web3/solana.d.ts +160 -0
  78. package/templates/realtime-agent/node_modules/@supabase/auth-js/dist/main/lib/web3/solana.d.ts.map +1 -0
  79. package/templates/realtime-agent/node_modules/@supabase/auth-js/dist/main/lib/web3/solana.js +4 -0
  80. package/templates/realtime-agent/node_modules/@supabase/auth-js/dist/main/lib/web3/solana.js.map +1 -0
  81. package/templates/realtime-agent/node_modules/@supabase/auth-js/dist/main/lib/webauthn.d.ts +284 -0
  82. package/templates/realtime-agent/node_modules/@supabase/auth-js/dist/main/lib/webauthn.d.ts.map +1 -0
  83. package/templates/realtime-agent/node_modules/@supabase/auth-js/dist/main/lib/webauthn.dom.d.ts +583 -0
  84. package/templates/realtime-agent/node_modules/@supabase/auth-js/dist/main/lib/webauthn.dom.d.ts.map +1 -0
  85. package/templates/realtime-agent/node_modules/@supabase/auth-js/dist/main/lib/webauthn.dom.js +4 -0
  86. package/templates/realtime-agent/node_modules/@supabase/auth-js/dist/main/lib/webauthn.dom.js.map +1 -0
  87. package/templates/realtime-agent/node_modules/@supabase/auth-js/dist/main/lib/webauthn.errors.d.ts +85 -0
  88. package/templates/realtime-agent/node_modules/@supabase/auth-js/dist/main/lib/webauthn.errors.d.ts.map +1 -0
  89. package/templates/realtime-agent/node_modules/@supabase/auth-js/dist/main/lib/webauthn.errors.js +272 -0
  90. package/templates/realtime-agent/node_modules/@supabase/auth-js/dist/main/lib/webauthn.errors.js.map +1 -0
  91. package/templates/realtime-agent/node_modules/@supabase/auth-js/dist/main/lib/webauthn.js +707 -0
  92. package/templates/realtime-agent/node_modules/@supabase/auth-js/dist/main/lib/webauthn.js.map +1 -0
  93. package/templates/realtime-agent/node_modules/@supabase/auth-js/dist/module/AuthAdminApi.d.ts +4 -0
  94. package/templates/realtime-agent/node_modules/@supabase/auth-js/dist/module/AuthAdminApi.d.ts.map +1 -0
  95. package/templates/realtime-agent/node_modules/@supabase/auth-js/dist/module/AuthAdminApi.js +4 -0
  96. package/templates/realtime-agent/node_modules/@supabase/auth-js/dist/module/AuthAdminApi.js.map +1 -0
  97. package/templates/realtime-agent/node_modules/@supabase/auth-js/dist/module/AuthClient.d.ts +4 -0
  98. package/templates/realtime-agent/node_modules/@supabase/auth-js/dist/module/AuthClient.d.ts.map +1 -0
  99. package/templates/realtime-agent/node_modules/@supabase/auth-js/dist/module/AuthClient.js +4 -0
  100. package/templates/realtime-agent/node_modules/@supabase/auth-js/dist/module/AuthClient.js.map +1 -0
  101. package/templates/realtime-agent/node_modules/@supabase/auth-js/dist/module/GoTrueAdminApi.d.ts +716 -0
  102. package/templates/realtime-agent/node_modules/@supabase/auth-js/dist/module/GoTrueAdminApi.d.ts.map +1 -0
  103. package/templates/realtime-agent/node_modules/@supabase/auth-js/dist/module/GoTrueAdminApi.js +1105 -0
  104. package/templates/realtime-agent/node_modules/@supabase/auth-js/dist/module/GoTrueAdminApi.js.map +1 -0
  105. package/templates/realtime-agent/node_modules/@supabase/auth-js/dist/module/GoTrueClient.d.ts +2473 -0
  106. package/templates/realtime-agent/node_modules/@supabase/auth-js/dist/module/GoTrueClient.d.ts.map +1 -0
  107. package/templates/realtime-agent/node_modules/@supabase/auth-js/dist/module/GoTrueClient.js +5214 -0
  108. package/templates/realtime-agent/node_modules/@supabase/auth-js/dist/module/GoTrueClient.js.map +1 -0
  109. package/templates/realtime-agent/node_modules/@supabase/auth-js/dist/module/index.d.ts +9 -0
  110. package/templates/realtime-agent/node_modules/@supabase/auth-js/dist/module/index.d.ts.map +1 -0
  111. package/templates/realtime-agent/node_modules/@supabase/auth-js/dist/module/index.js +9 -0
  112. package/templates/realtime-agent/node_modules/@supabase/auth-js/dist/module/index.js.map +1 -0
  113. package/templates/realtime-agent/node_modules/@supabase/auth-js/dist/module/lib/base64url.d.ts +76 -0
  114. package/templates/realtime-agent/node_modules/@supabase/auth-js/dist/module/lib/base64url.d.ts.map +1 -0
  115. package/templates/realtime-agent/node_modules/@supabase/auth-js/dist/module/lib/base64url.js +257 -0
  116. package/templates/realtime-agent/node_modules/@supabase/auth-js/dist/module/lib/base64url.js.map +1 -0
  117. package/templates/realtime-agent/node_modules/@supabase/auth-js/dist/module/lib/constants.d.ts +26 -0
  118. package/templates/realtime-agent/node_modules/@supabase/auth-js/dist/module/lib/constants.d.ts.map +1 -0
  119. package/templates/realtime-agent/node_modules/@supabase/auth-js/dist/module/lib/constants.js +28 -0
  120. package/templates/realtime-agent/node_modules/@supabase/auth-js/dist/module/lib/constants.js.map +1 -0
  121. package/templates/realtime-agent/node_modules/@supabase/auth-js/dist/module/lib/error-codes.d.ts +7 -0
  122. package/templates/realtime-agent/node_modules/@supabase/auth-js/dist/module/lib/error-codes.d.ts.map +1 -0
  123. package/templates/realtime-agent/node_modules/@supabase/auth-js/dist/module/lib/error-codes.js +2 -0
  124. package/templates/realtime-agent/node_modules/@supabase/auth-js/dist/module/lib/error-codes.js.map +1 -0
  125. package/templates/realtime-agent/node_modules/@supabase/auth-js/dist/module/lib/errors.d.ts +258 -0
  126. package/templates/realtime-agent/node_modules/@supabase/auth-js/dist/module/lib/errors.d.ts.map +1 -0
  127. package/templates/realtime-agent/node_modules/@supabase/auth-js/dist/module/lib/errors.js +267 -0
  128. package/templates/realtime-agent/node_modules/@supabase/auth-js/dist/module/lib/errors.js.map +1 -0
  129. package/templates/realtime-agent/node_modules/@supabase/auth-js/dist/module/lib/fetch.d.ts +54 -0
  130. package/templates/realtime-agent/node_modules/@supabase/auth-js/dist/module/lib/fetch.d.ts.map +1 -0
  131. package/templates/realtime-agent/node_modules/@supabase/auth-js/dist/module/lib/fetch.js +190 -0
  132. package/templates/realtime-agent/node_modules/@supabase/auth-js/dist/module/lib/fetch.js.map +1 -0
  133. package/templates/realtime-agent/node_modules/@supabase/auth-js/dist/module/lib/helpers.d.ts +94 -0
  134. package/templates/realtime-agent/node_modules/@supabase/auth-js/dist/module/lib/helpers.d.ts.map +1 -0
  135. package/templates/realtime-agent/node_modules/@supabase/auth-js/dist/module/lib/helpers.js +378 -0
  136. package/templates/realtime-agent/node_modules/@supabase/auth-js/dist/module/lib/helpers.js.map +1 -0
  137. package/templates/realtime-agent/node_modules/@supabase/auth-js/dist/module/lib/local-storage.d.ts +9 -0
  138. package/templates/realtime-agent/node_modules/@supabase/auth-js/dist/module/lib/local-storage.d.ts.map +1 -0
  139. package/templates/realtime-agent/node_modules/@supabase/auth-js/dist/module/lib/local-storage.js +18 -0
  140. package/templates/realtime-agent/node_modules/@supabase/auth-js/dist/module/lib/local-storage.js.map +1 -0
  141. package/templates/realtime-agent/node_modules/@supabase/auth-js/dist/module/lib/locks.d.ts +107 -0
  142. package/templates/realtime-agent/node_modules/@supabase/auth-js/dist/module/lib/locks.d.ts.map +1 -0
  143. package/templates/realtime-agent/node_modules/@supabase/auth-js/dist/module/lib/locks.js +341 -0
  144. package/templates/realtime-agent/node_modules/@supabase/auth-js/dist/module/lib/locks.js.map +1 -0
  145. package/templates/realtime-agent/node_modules/@supabase/auth-js/dist/module/lib/polyfills.d.ts +5 -0
  146. package/templates/realtime-agent/node_modules/@supabase/auth-js/dist/module/lib/polyfills.d.ts.map +1 -0
  147. package/templates/realtime-agent/node_modules/@supabase/auth-js/dist/module/lib/polyfills.js +26 -0
  148. package/templates/realtime-agent/node_modules/@supabase/auth-js/dist/module/lib/polyfills.js.map +1 -0
  149. package/templates/realtime-agent/node_modules/@supabase/auth-js/dist/module/lib/types.d.ts +2498 -0
  150. package/templates/realtime-agent/node_modules/@supabase/auth-js/dist/module/lib/types.d.ts.map +1 -0
  151. package/templates/realtime-agent/node_modules/@supabase/auth-js/dist/module/lib/types.js +20 -0
  152. package/templates/realtime-agent/node_modules/@supabase/auth-js/dist/module/lib/types.js.map +1 -0
  153. package/templates/realtime-agent/node_modules/@supabase/auth-js/dist/module/lib/version.d.ts +2 -0
  154. package/templates/realtime-agent/node_modules/@supabase/auth-js/dist/module/lib/version.d.ts.map +1 -0
  155. package/templates/realtime-agent/node_modules/@supabase/auth-js/dist/module/lib/version.js +8 -0
  156. package/templates/realtime-agent/node_modules/@supabase/auth-js/dist/module/lib/version.js.map +1 -0
  157. package/templates/realtime-agent/node_modules/@supabase/auth-js/dist/module/lib/web3/ethereum.d.ts +96 -0
  158. package/templates/realtime-agent/node_modules/@supabase/auth-js/dist/module/lib/web3/ethereum.d.ts.map +1 -0
  159. package/templates/realtime-agent/node_modules/@supabase/auth-js/dist/module/lib/web3/ethereum.js +60 -0
  160. package/templates/realtime-agent/node_modules/@supabase/auth-js/dist/module/lib/web3/ethereum.js.map +1 -0
  161. package/templates/realtime-agent/node_modules/@supabase/auth-js/dist/module/lib/web3/solana.d.ts +160 -0
  162. package/templates/realtime-agent/node_modules/@supabase/auth-js/dist/module/lib/web3/solana.d.ts.map +1 -0
  163. package/templates/realtime-agent/node_modules/@supabase/auth-js/dist/module/lib/web3/solana.js +3 -0
  164. package/templates/realtime-agent/node_modules/@supabase/auth-js/dist/module/lib/web3/solana.js.map +1 -0
  165. package/templates/realtime-agent/node_modules/@supabase/auth-js/dist/module/lib/webauthn.d.ts +284 -0
  166. package/templates/realtime-agent/node_modules/@supabase/auth-js/dist/module/lib/webauthn.d.ts.map +1 -0
  167. package/templates/realtime-agent/node_modules/@supabase/auth-js/dist/module/lib/webauthn.dom.d.ts +583 -0
  168. package/templates/realtime-agent/node_modules/@supabase/auth-js/dist/module/lib/webauthn.dom.d.ts.map +1 -0
  169. package/templates/realtime-agent/node_modules/@supabase/auth-js/dist/module/lib/webauthn.dom.js +3 -0
  170. package/templates/realtime-agent/node_modules/@supabase/auth-js/dist/module/lib/webauthn.dom.js.map +1 -0
  171. package/templates/realtime-agent/node_modules/@supabase/auth-js/dist/module/lib/webauthn.errors.d.ts +85 -0
  172. package/templates/realtime-agent/node_modules/@supabase/auth-js/dist/module/lib/webauthn.errors.d.ts.map +1 -0
  173. package/templates/realtime-agent/node_modules/@supabase/auth-js/dist/module/lib/webauthn.errors.js +264 -0
  174. package/templates/realtime-agent/node_modules/@supabase/auth-js/dist/module/lib/webauthn.errors.js.map +1 -0
  175. package/templates/realtime-agent/node_modules/@supabase/auth-js/dist/module/lib/webauthn.js +689 -0
  176. package/templates/realtime-agent/node_modules/@supabase/auth-js/dist/module/lib/webauthn.js.map +1 -0
  177. package/templates/realtime-agent/node_modules/@supabase/auth-js/dist/tsconfig.module.tsbuildinfo +1 -0
  178. package/templates/realtime-agent/node_modules/@supabase/auth-js/dist/tsconfig.tsbuildinfo +1 -0
  179. package/templates/realtime-agent/node_modules/@supabase/auth-js/package.json +44 -0
  180. package/templates/realtime-agent/node_modules/@supabase/auth-js/src/AuthAdminApi.ts +5 -0
  181. package/templates/realtime-agent/node_modules/@supabase/auth-js/src/AuthClient.ts +5 -0
  182. package/templates/realtime-agent/node_modules/@supabase/auth-js/src/GoTrueAdminApi.ts +1267 -0
  183. package/templates/realtime-agent/node_modules/@supabase/auth-js/src/GoTrueClient.ts +6360 -0
  184. package/templates/realtime-agent/node_modules/@supabase/auth-js/src/index.ts +13 -0
  185. package/templates/realtime-agent/node_modules/@supabase/auth-js/src/lib/base64url.ts +308 -0
  186. package/templates/realtime-agent/node_modules/@supabase/auth-js/src/lib/constants.ts +34 -0
  187. package/templates/realtime-agent/node_modules/@supabase/auth-js/src/lib/error-codes.ts +90 -0
  188. package/templates/realtime-agent/node_modules/@supabase/auth-js/src/lib/errors.ts +359 -0
  189. package/templates/realtime-agent/node_modules/@supabase/auth-js/src/lib/fetch.ts +320 -0
  190. package/templates/realtime-agent/node_modules/@supabase/auth-js/src/lib/helpers.ts +476 -0
  191. package/templates/realtime-agent/node_modules/@supabase/auth-js/src/lib/local-storage.ts +21 -0
  192. package/templates/realtime-agent/node_modules/@supabase/auth-js/src/lib/locks.ts +420 -0
  193. package/templates/realtime-agent/node_modules/@supabase/auth-js/src/lib/polyfills.ts +23 -0
  194. package/templates/realtime-agent/node_modules/@supabase/auth-js/src/lib/types.ts +2917 -0
  195. package/templates/realtime-agent/node_modules/@supabase/auth-js/src/lib/version.ts +7 -0
  196. package/templates/realtime-agent/node_modules/@supabase/auth-js/src/lib/web3/ethereum.ts +184 -0
  197. package/templates/realtime-agent/node_modules/@supabase/auth-js/src/lib/web3/solana.ts +186 -0
  198. package/templates/realtime-agent/node_modules/@supabase/auth-js/src/lib/webauthn.dom.ts +636 -0
  199. package/templates/realtime-agent/node_modules/@supabase/auth-js/src/lib/webauthn.errors.ts +329 -0
  200. package/templates/realtime-agent/node_modules/@supabase/auth-js/src/lib/webauthn.ts +946 -0
  201. package/templates/realtime-agent/node_modules/@supabase/functions-js/README.md +134 -0
  202. package/templates/realtime-agent/node_modules/@supabase/functions-js/dist/main/FunctionsClient.d.ts +177 -0
  203. package/templates/realtime-agent/node_modules/@supabase/functions-js/dist/main/FunctionsClient.d.ts.map +1 -0
  204. package/templates/realtime-agent/node_modules/@supabase/functions-js/dist/main/FunctionsClient.js +309 -0
  205. package/templates/realtime-agent/node_modules/@supabase/functions-js/dist/main/FunctionsClient.js.map +1 -0
  206. package/templates/realtime-agent/node_modules/@supabase/functions-js/dist/main/helper.d.ts +3 -0
  207. package/templates/realtime-agent/node_modules/@supabase/functions-js/dist/main/helper.d.ts.map +1 -0
  208. package/templates/realtime-agent/node_modules/@supabase/functions-js/dist/main/helper.js +11 -0
  209. package/templates/realtime-agent/node_modules/@supabase/functions-js/dist/main/helper.js.map +1 -0
  210. package/templates/realtime-agent/node_modules/@supabase/functions-js/dist/main/index.d.ts +3 -0
  211. package/templates/realtime-agent/node_modules/@supabase/functions-js/dist/main/index.d.ts.map +1 -0
  212. package/templates/realtime-agent/node_modules/@supabase/functions-js/dist/main/index.js +12 -0
  213. package/templates/realtime-agent/node_modules/@supabase/functions-js/dist/main/index.js.map +1 -0
  214. package/templates/realtime-agent/node_modules/@supabase/functions-js/dist/main/types.d.ts +122 -0
  215. package/templates/realtime-agent/node_modules/@supabase/functions-js/dist/main/types.d.ts.map +1 -0
  216. package/templates/realtime-agent/node_modules/@supabase/functions-js/dist/main/types.js +98 -0
  217. package/templates/realtime-agent/node_modules/@supabase/functions-js/dist/main/types.js.map +1 -0
  218. package/templates/realtime-agent/node_modules/@supabase/functions-js/dist/main/version.d.ts +2 -0
  219. package/templates/realtime-agent/node_modules/@supabase/functions-js/dist/main/version.d.ts.map +1 -0
  220. package/templates/realtime-agent/node_modules/@supabase/functions-js/dist/main/version.js +11 -0
  221. package/templates/realtime-agent/node_modules/@supabase/functions-js/dist/main/version.js.map +1 -0
  222. package/templates/realtime-agent/node_modules/@supabase/functions-js/dist/module/FunctionsClient.d.ts +177 -0
  223. package/templates/realtime-agent/node_modules/@supabase/functions-js/dist/module/FunctionsClient.d.ts.map +1 -0
  224. package/templates/realtime-agent/node_modules/@supabase/functions-js/dist/module/FunctionsClient.js +305 -0
  225. package/templates/realtime-agent/node_modules/@supabase/functions-js/dist/module/FunctionsClient.js.map +1 -0
  226. package/templates/realtime-agent/node_modules/@supabase/functions-js/dist/module/helper.d.ts +3 -0
  227. package/templates/realtime-agent/node_modules/@supabase/functions-js/dist/module/helper.d.ts.map +1 -0
  228. package/templates/realtime-agent/node_modules/@supabase/functions-js/dist/module/helper.js +7 -0
  229. package/templates/realtime-agent/node_modules/@supabase/functions-js/dist/module/helper.js.map +1 -0
  230. package/templates/realtime-agent/node_modules/@supabase/functions-js/dist/module/index.d.ts +3 -0
  231. package/templates/realtime-agent/node_modules/@supabase/functions-js/dist/module/index.d.ts.map +1 -0
  232. package/templates/realtime-agent/node_modules/@supabase/functions-js/dist/module/index.js +3 -0
  233. package/templates/realtime-agent/node_modules/@supabase/functions-js/dist/module/index.js.map +1 -0
  234. package/templates/realtime-agent/node_modules/@supabase/functions-js/dist/module/types.d.ts +122 -0
  235. package/templates/realtime-agent/node_modules/@supabase/functions-js/dist/module/types.d.ts.map +1 -0
  236. package/templates/realtime-agent/node_modules/@supabase/functions-js/dist/module/types.js +91 -0
  237. package/templates/realtime-agent/node_modules/@supabase/functions-js/dist/module/types.js.map +1 -0
  238. package/templates/realtime-agent/node_modules/@supabase/functions-js/dist/module/version.d.ts +2 -0
  239. package/templates/realtime-agent/node_modules/@supabase/functions-js/dist/module/version.d.ts.map +1 -0
  240. package/templates/realtime-agent/node_modules/@supabase/functions-js/dist/module/version.js +8 -0
  241. package/templates/realtime-agent/node_modules/@supabase/functions-js/dist/module/version.js.map +1 -0
  242. package/templates/realtime-agent/node_modules/@supabase/functions-js/dist/tsconfig.module.tsbuildinfo +1 -0
  243. package/templates/realtime-agent/node_modules/@supabase/functions-js/dist/tsconfig.tsbuildinfo +1 -0
  244. package/templates/realtime-agent/node_modules/@supabase/functions-js/package.json +52 -0
  245. package/templates/realtime-agent/node_modules/@supabase/functions-js/src/FunctionsClient.ts +335 -0
  246. package/templates/realtime-agent/node_modules/@supabase/functions-js/src/edge-runtime.d.ts +214 -0
  247. package/templates/realtime-agent/node_modules/@supabase/functions-js/src/helper.ts +8 -0
  248. package/templates/realtime-agent/node_modules/@supabase/functions-js/src/index.ts +10 -0
  249. package/templates/realtime-agent/node_modules/@supabase/functions-js/src/types.ts +146 -0
  250. package/templates/realtime-agent/node_modules/@supabase/functions-js/src/version.ts +7 -0
  251. package/templates/realtime-agent/node_modules/@supabase/phoenix/LICENSE.md +22 -0
  252. package/templates/realtime-agent/node_modules/@supabase/phoenix/README.md +121 -0
  253. package/templates/realtime-agent/node_modules/@supabase/phoenix/assets/js/phoenix/ajax.js +116 -0
  254. package/templates/realtime-agent/node_modules/@supabase/phoenix/assets/js/phoenix/channel.js +331 -0
  255. package/templates/realtime-agent/node_modules/@supabase/phoenix/assets/js/phoenix/constants.js +35 -0
  256. package/templates/realtime-agent/node_modules/@supabase/phoenix/assets/js/phoenix/index.js +212 -0
  257. package/templates/realtime-agent/node_modules/@supabase/phoenix/assets/js/phoenix/longpoll.js +192 -0
  258. package/templates/realtime-agent/node_modules/@supabase/phoenix/assets/js/phoenix/presence.js +208 -0
  259. package/templates/realtime-agent/node_modules/@supabase/phoenix/assets/js/phoenix/push.js +134 -0
  260. package/templates/realtime-agent/node_modules/@supabase/phoenix/assets/js/phoenix/serializer.js +133 -0
  261. package/templates/realtime-agent/node_modules/@supabase/phoenix/assets/js/phoenix/socket.js +756 -0
  262. package/templates/realtime-agent/node_modules/@supabase/phoenix/assets/js/phoenix/timer.js +48 -0
  263. package/templates/realtime-agent/node_modules/@supabase/phoenix/assets/js/phoenix/types.js +184 -0
  264. package/templates/realtime-agent/node_modules/@supabase/phoenix/assets/js/phoenix/utils.js +16 -0
  265. package/templates/realtime-agent/node_modules/@supabase/phoenix/package.json +58 -0
  266. package/templates/realtime-agent/node_modules/@supabase/phoenix/priv/static/favicon.ico +0 -0
  267. package/templates/realtime-agent/node_modules/@supabase/phoenix/priv/static/phoenix-orange.png +0 -0
  268. package/templates/realtime-agent/node_modules/@supabase/phoenix/priv/static/phoenix.cjs.js +1825 -0
  269. package/templates/realtime-agent/node_modules/@supabase/phoenix/priv/static/phoenix.cjs.js.map +7 -0
  270. package/templates/realtime-agent/node_modules/@supabase/phoenix/priv/static/phoenix.js +1847 -0
  271. package/templates/realtime-agent/node_modules/@supabase/phoenix/priv/static/phoenix.min.js +2 -0
  272. package/templates/realtime-agent/node_modules/@supabase/phoenix/priv/static/phoenix.mjs +1802 -0
  273. package/templates/realtime-agent/node_modules/@supabase/phoenix/priv/static/phoenix.mjs.map +7 -0
  274. package/templates/realtime-agent/node_modules/@supabase/phoenix/priv/static/phoenix.png +0 -0
  275. package/templates/realtime-agent/node_modules/@supabase/phoenix/priv/static/types/ajax.d.ts +10 -0
  276. package/templates/realtime-agent/node_modules/@supabase/phoenix/priv/static/types/ajax.d.ts.map +1 -0
  277. package/templates/realtime-agent/node_modules/@supabase/phoenix/priv/static/types/channel.d.ts +167 -0
  278. package/templates/realtime-agent/node_modules/@supabase/phoenix/priv/static/types/channel.d.ts.map +1 -0
  279. package/templates/realtime-agent/node_modules/@supabase/phoenix/priv/static/types/constants.d.ts +36 -0
  280. package/templates/realtime-agent/node_modules/@supabase/phoenix/priv/static/types/constants.d.ts.map +1 -0
  281. package/templates/realtime-agent/node_modules/@supabase/phoenix/priv/static/types/index.d.ts +10 -0
  282. package/templates/realtime-agent/node_modules/@supabase/phoenix/priv/static/types/index.d.ts.map +1 -0
  283. package/templates/realtime-agent/node_modules/@supabase/phoenix/priv/static/types/longpoll.d.ts +29 -0
  284. package/templates/realtime-agent/node_modules/@supabase/phoenix/priv/static/types/longpoll.d.ts.map +1 -0
  285. package/templates/realtime-agent/node_modules/@supabase/phoenix/priv/static/types/presence.d.ts +107 -0
  286. package/templates/realtime-agent/node_modules/@supabase/phoenix/priv/static/types/presence.d.ts.map +1 -0
  287. package/templates/realtime-agent/node_modules/@supabase/phoenix/priv/static/types/push.d.ts +70 -0
  288. package/templates/realtime-agent/node_modules/@supabase/phoenix/priv/static/types/push.d.ts.map +1 -0
  289. package/templates/realtime-agent/node_modules/@supabase/phoenix/priv/static/types/serializer.d.ts +74 -0
  290. package/templates/realtime-agent/node_modules/@supabase/phoenix/priv/static/types/serializer.d.ts.map +1 -0
  291. package/templates/realtime-agent/node_modules/@supabase/phoenix/priv/static/types/socket.d.ts +291 -0
  292. package/templates/realtime-agent/node_modules/@supabase/phoenix/priv/static/types/socket.d.ts.map +1 -0
  293. package/templates/realtime-agent/node_modules/@supabase/phoenix/priv/static/types/timer.d.ts +36 -0
  294. package/templates/realtime-agent/node_modules/@supabase/phoenix/priv/static/types/timer.d.ts.map +1 -0
  295. package/templates/realtime-agent/node_modules/@supabase/phoenix/priv/static/types/types.d.ts +280 -0
  296. package/templates/realtime-agent/node_modules/@supabase/phoenix/priv/static/types/types.d.ts.map +1 -0
  297. package/templates/realtime-agent/node_modules/@supabase/phoenix/priv/static/types/utils.d.ts +2 -0
  298. package/templates/realtime-agent/node_modules/@supabase/phoenix/priv/static/types/utils.d.ts.map +1 -0
  299. package/templates/realtime-agent/node_modules/@supabase/phoenix/tsconfig.json +20 -0
  300. package/templates/realtime-agent/node_modules/@supabase/postgrest-js/README.md +213 -0
  301. package/templates/realtime-agent/node_modules/@supabase/postgrest-js/dist/index.cjs +5025 -0
  302. package/templates/realtime-agent/node_modules/@supabase/postgrest-js/dist/index.cjs.map +1 -0
  303. package/templates/realtime-agent/node_modules/@supabase/postgrest-js/dist/index.d.cts +3828 -0
  304. package/templates/realtime-agent/node_modules/@supabase/postgrest-js/dist/index.d.cts.map +1 -0
  305. package/templates/realtime-agent/node_modules/@supabase/postgrest-js/dist/index.d.mts +3828 -0
  306. package/templates/realtime-agent/node_modules/@supabase/postgrest-js/dist/index.d.mts.map +1 -0
  307. package/templates/realtime-agent/node_modules/@supabase/postgrest-js/dist/index.mjs +5017 -0
  308. package/templates/realtime-agent/node_modules/@supabase/postgrest-js/dist/index.mjs.map +1 -0
  309. package/templates/realtime-agent/node_modules/@supabase/postgrest-js/package.json +69 -0
  310. package/templates/realtime-agent/node_modules/@supabase/postgrest-js/src/PostgrestBuilder.ts +688 -0
  311. package/templates/realtime-agent/node_modules/@supabase/postgrest-js/src/PostgrestClient.ts +447 -0
  312. package/templates/realtime-agent/node_modules/@supabase/postgrest-js/src/PostgrestError.ts +41 -0
  313. package/templates/realtime-agent/node_modules/@supabase/postgrest-js/src/PostgrestFilterBuilder.ts +2137 -0
  314. package/templates/realtime-agent/node_modules/@supabase/postgrest-js/src/PostgrestQueryBuilder.ts +1703 -0
  315. package/templates/realtime-agent/node_modules/@supabase/postgrest-js/src/PostgrestTransformBuilder.ts +981 -0
  316. package/templates/realtime-agent/node_modules/@supabase/postgrest-js/src/constants.ts +2 -0
  317. package/templates/realtime-agent/node_modules/@supabase/postgrest-js/src/index.ts +34 -0
  318. package/templates/realtime-agent/node_modules/@supabase/postgrest-js/src/select-query-parser/parser.ts +476 -0
  319. package/templates/realtime-agent/node_modules/@supabase/postgrest-js/src/select-query-parser/result.ts +550 -0
  320. package/templates/realtime-agent/node_modules/@supabase/postgrest-js/src/select-query-parser/types.ts +129 -0
  321. package/templates/realtime-agent/node_modules/@supabase/postgrest-js/src/select-query-parser/utils.ts +704 -0
  322. package/templates/realtime-agent/node_modules/@supabase/postgrest-js/src/types/common/common.ts +83 -0
  323. package/templates/realtime-agent/node_modules/@supabase/postgrest-js/src/types/common/rpc.ts +148 -0
  324. package/templates/realtime-agent/node_modules/@supabase/postgrest-js/src/types/feature-flags.ts +17 -0
  325. package/templates/realtime-agent/node_modules/@supabase/postgrest-js/src/types/types.ts +161 -0
  326. package/templates/realtime-agent/node_modules/@supabase/postgrest-js/src/version.ts +7 -0
  327. package/templates/realtime-agent/node_modules/@supabase/realtime-js/README.md +326 -0
  328. package/templates/realtime-agent/node_modules/@supabase/realtime-js/dist/main/RealtimeChannel.d.ts +442 -0
  329. package/templates/realtime-agent/node_modules/@supabase/realtime-js/dist/main/RealtimeChannel.d.ts.map +1 -0
  330. package/templates/realtime-agent/node_modules/@supabase/realtime-js/dist/main/RealtimeChannel.js +719 -0
  331. package/templates/realtime-agent/node_modules/@supabase/realtime-js/dist/main/RealtimeChannel.js.map +1 -0
  332. package/templates/realtime-agent/node_modules/@supabase/realtime-js/dist/main/RealtimeClient.d.ts +275 -0
  333. package/templates/realtime-agent/node_modules/@supabase/realtime-js/dist/main/RealtimeClient.d.ts.map +1 -0
  334. package/templates/realtime-agent/node_modules/@supabase/realtime-js/dist/main/RealtimeClient.js +697 -0
  335. package/templates/realtime-agent/node_modules/@supabase/realtime-js/dist/main/RealtimeClient.js.map +1 -0
  336. package/templates/realtime-agent/node_modules/@supabase/realtime-js/dist/main/RealtimePresence.d.ts +62 -0
  337. package/templates/realtime-agent/node_modules/@supabase/realtime-js/dist/main/RealtimePresence.d.ts.map +1 -0
  338. package/templates/realtime-agent/node_modules/@supabase/realtime-js/dist/main/RealtimePresence.js +43 -0
  339. package/templates/realtime-agent/node_modules/@supabase/realtime-js/dist/main/RealtimePresence.js.map +1 -0
  340. package/templates/realtime-agent/node_modules/@supabase/realtime-js/dist/main/index.d.ts +6 -0
  341. package/templates/realtime-agent/node_modules/@supabase/realtime-js/dist/main/index.d.ts.map +1 -0
  342. package/templates/realtime-agent/node_modules/@supabase/realtime-js/dist/main/index.js +18 -0
  343. package/templates/realtime-agent/node_modules/@supabase/realtime-js/dist/main/index.js.map +1 -0
  344. package/templates/realtime-agent/node_modules/@supabase/realtime-js/dist/main/lib/constants.d.ts +43 -0
  345. package/templates/realtime-agent/node_modules/@supabase/realtime-js/dist/main/lib/constants.d.ts.map +1 -0
  346. package/templates/realtime-agent/node_modules/@supabase/realtime-js/dist/main/lib/constants.js +43 -0
  347. package/templates/realtime-agent/node_modules/@supabase/realtime-js/dist/main/lib/constants.js.map +1 -0
  348. package/templates/realtime-agent/node_modules/@supabase/realtime-js/dist/main/lib/normalizeChannelError.d.ts +10 -0
  349. package/templates/realtime-agent/node_modules/@supabase/realtime-js/dist/main/lib/normalizeChannelError.d.ts.map +1 -0
  350. package/templates/realtime-agent/node_modules/@supabase/realtime-js/dist/main/lib/normalizeChannelError.js +29 -0
  351. package/templates/realtime-agent/node_modules/@supabase/realtime-js/dist/main/lib/normalizeChannelError.js.map +1 -0
  352. package/templates/realtime-agent/node_modules/@supabase/realtime-js/dist/main/lib/serializer.d.ts +33 -0
  353. package/templates/realtime-agent/node_modules/@supabase/realtime-js/dist/main/lib/serializer.d.ts.map +1 -0
  354. package/templates/realtime-agent/node_modules/@supabase/realtime-js/dist/main/lib/serializer.js +155 -0
  355. package/templates/realtime-agent/node_modules/@supabase/realtime-js/dist/main/lib/serializer.js.map +1 -0
  356. package/templates/realtime-agent/node_modules/@supabase/realtime-js/dist/main/lib/transformers.d.ts +109 -0
  357. package/templates/realtime-agent/node_modules/@supabase/realtime-js/dist/main/lib/transformers.d.ts.map +1 -0
  358. package/templates/realtime-agent/node_modules/@supabase/realtime-js/dist/main/lib/transformers.js +241 -0
  359. package/templates/realtime-agent/node_modules/@supabase/realtime-js/dist/main/lib/transformers.js.map +1 -0
  360. package/templates/realtime-agent/node_modules/@supabase/realtime-js/dist/main/lib/version.d.ts +2 -0
  361. package/templates/realtime-agent/node_modules/@supabase/realtime-js/dist/main/lib/version.d.ts.map +1 -0
  362. package/templates/realtime-agent/node_modules/@supabase/realtime-js/dist/main/lib/version.js +11 -0
  363. package/templates/realtime-agent/node_modules/@supabase/realtime-js/dist/main/lib/version.js.map +1 -0
  364. package/templates/realtime-agent/node_modules/@supabase/realtime-js/dist/main/lib/websocket-factory.d.ts +82 -0
  365. package/templates/realtime-agent/node_modules/@supabase/realtime-js/dist/main/lib/websocket-factory.d.ts.map +1 -0
  366. package/templates/realtime-agent/node_modules/@supabase/realtime-js/dist/main/lib/websocket-factory.js +130 -0
  367. package/templates/realtime-agent/node_modules/@supabase/realtime-js/dist/main/lib/websocket-factory.js.map +1 -0
  368. package/templates/realtime-agent/node_modules/@supabase/realtime-js/dist/main/phoenix/channelAdapter.d.ts +32 -0
  369. package/templates/realtime-agent/node_modules/@supabase/realtime-js/dist/main/phoenix/channelAdapter.d.ts.map +1 -0
  370. package/templates/realtime-agent/node_modules/@supabase/realtime-js/dist/main/phoenix/channelAdapter.js +103 -0
  371. package/templates/realtime-agent/node_modules/@supabase/realtime-js/dist/main/phoenix/channelAdapter.js.map +1 -0
  372. package/templates/realtime-agent/node_modules/@supabase/realtime-js/dist/main/phoenix/presenceAdapter.d.ts +53 -0
  373. package/templates/realtime-agent/node_modules/@supabase/realtime-js/dist/main/phoenix/presenceAdapter.d.ts.map +1 -0
  374. package/templates/realtime-agent/node_modules/@supabase/realtime-js/dist/main/phoenix/presenceAdapter.js +93 -0
  375. package/templates/realtime-agent/node_modules/@supabase/realtime-js/dist/main/phoenix/presenceAdapter.js.map +1 -0
  376. package/templates/realtime-agent/node_modules/@supabase/realtime-js/dist/main/phoenix/socketAdapter.d.ts +38 -0
  377. package/templates/realtime-agent/node_modules/@supabase/realtime-js/dist/main/phoenix/socketAdapter.d.ts.map +1 -0
  378. package/templates/realtime-agent/node_modules/@supabase/realtime-js/dist/main/phoenix/socketAdapter.js +114 -0
  379. package/templates/realtime-agent/node_modules/@supabase/realtime-js/dist/main/phoenix/socketAdapter.js.map +1 -0
  380. package/templates/realtime-agent/node_modules/@supabase/realtime-js/dist/main/phoenix/types.d.ts +5 -0
  381. package/templates/realtime-agent/node_modules/@supabase/realtime-js/dist/main/phoenix/types.d.ts.map +1 -0
  382. package/templates/realtime-agent/node_modules/@supabase/realtime-js/dist/main/phoenix/types.js +3 -0
  383. package/templates/realtime-agent/node_modules/@supabase/realtime-js/dist/main/phoenix/types.js.map +1 -0
  384. package/templates/realtime-agent/node_modules/@supabase/realtime-js/dist/module/RealtimeChannel.d.ts +442 -0
  385. package/templates/realtime-agent/node_modules/@supabase/realtime-js/dist/module/RealtimeChannel.d.ts.map +1 -0
  386. package/templates/realtime-agent/node_modules/@supabase/realtime-js/dist/module/RealtimeChannel.js +714 -0
  387. package/templates/realtime-agent/node_modules/@supabase/realtime-js/dist/module/RealtimeChannel.js.map +1 -0
  388. package/templates/realtime-agent/node_modules/@supabase/realtime-js/dist/module/RealtimeClient.d.ts +275 -0
  389. package/templates/realtime-agent/node_modules/@supabase/realtime-js/dist/module/RealtimeClient.d.ts.map +1 -0
  390. package/templates/realtime-agent/node_modules/@supabase/realtime-js/dist/module/RealtimeClient.js +693 -0
  391. package/templates/realtime-agent/node_modules/@supabase/realtime-js/dist/module/RealtimeClient.js.map +1 -0
  392. package/templates/realtime-agent/node_modules/@supabase/realtime-js/dist/module/RealtimePresence.d.ts +62 -0
  393. package/templates/realtime-agent/node_modules/@supabase/realtime-js/dist/module/RealtimePresence.d.ts.map +1 -0
  394. package/templates/realtime-agent/node_modules/@supabase/realtime-js/dist/module/RealtimePresence.js +38 -0
  395. package/templates/realtime-agent/node_modules/@supabase/realtime-js/dist/module/RealtimePresence.js.map +1 -0
  396. package/templates/realtime-agent/node_modules/@supabase/realtime-js/dist/module/index.d.ts +6 -0
  397. package/templates/realtime-agent/node_modules/@supabase/realtime-js/dist/module/index.d.ts.map +1 -0
  398. package/templates/realtime-agent/node_modules/@supabase/realtime-js/dist/module/index.js +6 -0
  399. package/templates/realtime-agent/node_modules/@supabase/realtime-js/dist/module/index.js.map +1 -0
  400. package/templates/realtime-agent/node_modules/@supabase/realtime-js/dist/module/lib/constants.d.ts +43 -0
  401. package/templates/realtime-agent/node_modules/@supabase/realtime-js/dist/module/lib/constants.d.ts.map +1 -0
  402. package/templates/realtime-agent/node_modules/@supabase/realtime-js/dist/module/lib/constants.js +40 -0
  403. package/templates/realtime-agent/node_modules/@supabase/realtime-js/dist/module/lib/constants.js.map +1 -0
  404. package/templates/realtime-agent/node_modules/@supabase/realtime-js/dist/module/lib/normalizeChannelError.d.ts +10 -0
  405. package/templates/realtime-agent/node_modules/@supabase/realtime-js/dist/module/lib/normalizeChannelError.d.ts.map +1 -0
  406. package/templates/realtime-agent/node_modules/@supabase/realtime-js/dist/module/lib/normalizeChannelError.js +26 -0
  407. package/templates/realtime-agent/node_modules/@supabase/realtime-js/dist/module/lib/normalizeChannelError.js.map +1 -0
  408. package/templates/realtime-agent/node_modules/@supabase/realtime-js/dist/module/lib/serializer.d.ts +33 -0
  409. package/templates/realtime-agent/node_modules/@supabase/realtime-js/dist/module/lib/serializer.d.ts.map +1 -0
  410. package/templates/realtime-agent/node_modules/@supabase/realtime-js/dist/module/lib/serializer.js +152 -0
  411. package/templates/realtime-agent/node_modules/@supabase/realtime-js/dist/module/lib/serializer.js.map +1 -0
  412. package/templates/realtime-agent/node_modules/@supabase/realtime-js/dist/module/lib/transformers.d.ts +109 -0
  413. package/templates/realtime-agent/node_modules/@supabase/realtime-js/dist/module/lib/transformers.d.ts.map +1 -0
  414. package/templates/realtime-agent/node_modules/@supabase/realtime-js/dist/module/lib/transformers.js +229 -0
  415. package/templates/realtime-agent/node_modules/@supabase/realtime-js/dist/module/lib/transformers.js.map +1 -0
  416. package/templates/realtime-agent/node_modules/@supabase/realtime-js/dist/module/lib/version.d.ts +2 -0
  417. package/templates/realtime-agent/node_modules/@supabase/realtime-js/dist/module/lib/version.d.ts.map +1 -0
  418. package/templates/realtime-agent/node_modules/@supabase/realtime-js/dist/module/lib/version.js +8 -0
  419. package/templates/realtime-agent/node_modules/@supabase/realtime-js/dist/module/lib/version.js.map +1 -0
  420. package/templates/realtime-agent/node_modules/@supabase/realtime-js/dist/module/lib/websocket-factory.d.ts +82 -0
  421. package/templates/realtime-agent/node_modules/@supabase/realtime-js/dist/module/lib/websocket-factory.d.ts.map +1 -0
  422. package/templates/realtime-agent/node_modules/@supabase/realtime-js/dist/module/lib/websocket-factory.js +126 -0
  423. package/templates/realtime-agent/node_modules/@supabase/realtime-js/dist/module/lib/websocket-factory.js.map +1 -0
  424. package/templates/realtime-agent/node_modules/@supabase/realtime-js/dist/module/phoenix/channelAdapter.d.ts +32 -0
  425. package/templates/realtime-agent/node_modules/@supabase/realtime-js/dist/module/phoenix/channelAdapter.d.ts.map +1 -0
  426. package/templates/realtime-agent/node_modules/@supabase/realtime-js/dist/module/phoenix/channelAdapter.js +100 -0
  427. package/templates/realtime-agent/node_modules/@supabase/realtime-js/dist/module/phoenix/channelAdapter.js.map +1 -0
  428. package/templates/realtime-agent/node_modules/@supabase/realtime-js/dist/module/phoenix/presenceAdapter.d.ts +53 -0
  429. package/templates/realtime-agent/node_modules/@supabase/realtime-js/dist/module/phoenix/presenceAdapter.d.ts.map +1 -0
  430. package/templates/realtime-agent/node_modules/@supabase/realtime-js/dist/module/phoenix/presenceAdapter.js +90 -0
  431. package/templates/realtime-agent/node_modules/@supabase/realtime-js/dist/module/phoenix/presenceAdapter.js.map +1 -0
  432. package/templates/realtime-agent/node_modules/@supabase/realtime-js/dist/module/phoenix/socketAdapter.d.ts +38 -0
  433. package/templates/realtime-agent/node_modules/@supabase/realtime-js/dist/module/phoenix/socketAdapter.d.ts.map +1 -0
  434. package/templates/realtime-agent/node_modules/@supabase/realtime-js/dist/module/phoenix/socketAdapter.js +111 -0
  435. package/templates/realtime-agent/node_modules/@supabase/realtime-js/dist/module/phoenix/socketAdapter.js.map +1 -0
  436. package/templates/realtime-agent/node_modules/@supabase/realtime-js/dist/module/phoenix/types.d.ts +5 -0
  437. package/templates/realtime-agent/node_modules/@supabase/realtime-js/dist/module/phoenix/types.d.ts.map +1 -0
  438. package/templates/realtime-agent/node_modules/@supabase/realtime-js/dist/module/phoenix/types.js +2 -0
  439. package/templates/realtime-agent/node_modules/@supabase/realtime-js/dist/module/phoenix/types.js.map +1 -0
  440. package/templates/realtime-agent/node_modules/@supabase/realtime-js/dist/tsconfig.module.tsbuildinfo +1 -0
  441. package/templates/realtime-agent/node_modules/@supabase/realtime-js/dist/tsconfig.tsbuildinfo +1 -0
  442. package/templates/realtime-agent/node_modules/@supabase/realtime-js/package.json +58 -0
  443. package/templates/realtime-agent/node_modules/@supabase/realtime-js/src/RealtimeChannel.ts +1118 -0
  444. package/templates/realtime-agent/node_modules/@supabase/realtime-js/src/RealtimeClient.ts +868 -0
  445. package/templates/realtime-agent/node_modules/@supabase/realtime-js/src/RealtimePresence.ts +71 -0
  446. package/templates/realtime-agent/node_modules/@supabase/realtime-js/src/index.ts +53 -0
  447. package/templates/realtime-agent/node_modules/@supabase/realtime-js/src/lib/constants.ts +62 -0
  448. package/templates/realtime-agent/node_modules/@supabase/realtime-js/src/lib/normalizeChannelError.ts +30 -0
  449. package/templates/realtime-agent/node_modules/@supabase/realtime-js/src/lib/serializer.ts +203 -0
  450. package/templates/realtime-agent/node_modules/@supabase/realtime-js/src/lib/transformers.ts +270 -0
  451. package/templates/realtime-agent/node_modules/@supabase/realtime-js/src/lib/version.ts +7 -0
  452. package/templates/realtime-agent/node_modules/@supabase/realtime-js/src/lib/websocket-factory.ts +204 -0
  453. package/templates/realtime-agent/node_modules/@supabase/realtime-js/src/phoenix/channelAdapter.ts +149 -0
  454. package/templates/realtime-agent/node_modules/@supabase/realtime-js/src/phoenix/presenceAdapter.ts +116 -0
  455. package/templates/realtime-agent/node_modules/@supabase/realtime-js/src/phoenix/socketAdapter.ts +168 -0
  456. package/templates/realtime-agent/node_modules/@supabase/realtime-js/src/phoenix/types.ts +32 -0
  457. package/templates/realtime-agent/node_modules/@supabase/storage-js/README.md +1262 -0
  458. package/templates/realtime-agent/node_modules/@supabase/storage-js/dist/index.cjs +2995 -0
  459. package/templates/realtime-agent/node_modules/@supabase/storage-js/dist/index.cjs.map +1 -0
  460. package/templates/realtime-agent/node_modules/@supabase/storage-js/dist/index.d.cts +2956 -0
  461. package/templates/realtime-agent/node_modules/@supabase/storage-js/dist/index.d.cts.map +1 -0
  462. package/templates/realtime-agent/node_modules/@supabase/storage-js/dist/index.d.mts +2956 -0
  463. package/templates/realtime-agent/node_modules/@supabase/storage-js/dist/index.d.mts.map +1 -0
  464. package/templates/realtime-agent/node_modules/@supabase/storage-js/dist/index.mjs +2979 -0
  465. package/templates/realtime-agent/node_modules/@supabase/storage-js/dist/index.mjs.map +1 -0
  466. package/templates/realtime-agent/node_modules/@supabase/storage-js/dist/umd/supabase.js +1 -0
  467. package/templates/realtime-agent/node_modules/@supabase/storage-js/package.json +62 -0
  468. package/templates/realtime-agent/node_modules/@supabase/storage-js/src/StorageClient.ts +98 -0
  469. package/templates/realtime-agent/node_modules/@supabase/storage-js/src/index.ts +19 -0
  470. package/templates/realtime-agent/node_modules/@supabase/storage-js/src/lib/common/BaseApiClient.ts +104 -0
  471. package/templates/realtime-agent/node_modules/@supabase/storage-js/src/lib/common/errors.ts +160 -0
  472. package/templates/realtime-agent/node_modules/@supabase/storage-js/src/lib/common/fetch.ts +303 -0
  473. package/templates/realtime-agent/node_modules/@supabase/storage-js/src/lib/common/headers.ts +43 -0
  474. package/templates/realtime-agent/node_modules/@supabase/storage-js/src/lib/common/helpers.ts +146 -0
  475. package/templates/realtime-agent/node_modules/@supabase/storage-js/src/lib/constants.ts +4 -0
  476. package/templates/realtime-agent/node_modules/@supabase/storage-js/src/lib/types.ts +654 -0
  477. package/templates/realtime-agent/node_modules/@supabase/storage-js/src/lib/version.ts +7 -0
  478. package/templates/realtime-agent/node_modules/@supabase/storage-js/src/packages/BlobDownloadBuilder.ts +62 -0
  479. package/templates/realtime-agent/node_modules/@supabase/storage-js/src/packages/StorageAnalyticsClient.ts +420 -0
  480. package/templates/realtime-agent/node_modules/@supabase/storage-js/src/packages/StorageBucketApi.ts +414 -0
  481. package/templates/realtime-agent/node_modules/@supabase/storage-js/src/packages/StorageFileApi.ts +1423 -0
  482. package/templates/realtime-agent/node_modules/@supabase/storage-js/src/packages/StorageVectorsClient.ts +644 -0
  483. package/templates/realtime-agent/node_modules/@supabase/storage-js/src/packages/StreamDownloadBuilder.ts +39 -0
  484. package/templates/realtime-agent/node_modules/@supabase/storage-js/src/packages/VectorBucketApi.ts +73 -0
  485. package/templates/realtime-agent/node_modules/@supabase/storage-js/src/packages/VectorDataApi.ts +98 -0
  486. package/templates/realtime-agent/node_modules/@supabase/storage-js/src/packages/VectorIndexApi.ts +90 -0
  487. package/templates/realtime-agent/node_modules/@supabase/supabase-js/README.md +238 -0
  488. package/templates/realtime-agent/node_modules/@supabase/supabase-js/dist/cors.cjs +89 -0
  489. package/templates/realtime-agent/node_modules/@supabase/supabase-js/dist/cors.cjs.map +1 -0
  490. package/templates/realtime-agent/node_modules/@supabase/supabase-js/dist/cors.d.cts +58 -0
  491. package/templates/realtime-agent/node_modules/@supabase/supabase-js/dist/cors.d.cts.map +1 -0
  492. package/templates/realtime-agent/node_modules/@supabase/supabase-js/dist/cors.d.mts +58 -0
  493. package/templates/realtime-agent/node_modules/@supabase/supabase-js/dist/cors.d.mts.map +1 -0
  494. package/templates/realtime-agent/node_modules/@supabase/supabase-js/dist/cors.mjs +88 -0
  495. package/templates/realtime-agent/node_modules/@supabase/supabase-js/dist/cors.mjs.map +1 -0
  496. package/templates/realtime-agent/node_modules/@supabase/supabase-js/dist/index.cjs +660 -0
  497. package/templates/realtime-agent/node_modules/@supabase/supabase-js/dist/index.cjs.map +1 -0
  498. package/templates/realtime-agent/node_modules/@supabase/supabase-js/dist/index.d.cts +616 -0
  499. package/templates/realtime-agent/node_modules/@supabase/supabase-js/dist/index.d.cts.map +1 -0
  500. package/templates/realtime-agent/node_modules/@supabase/supabase-js/dist/index.d.mts +616 -0
  501. package/templates/realtime-agent/node_modules/@supabase/supabase-js/dist/index.d.mts.map +1 -0
  502. package/templates/realtime-agent/node_modules/@supabase/supabase-js/dist/index.mjs +607 -0
  503. package/templates/realtime-agent/node_modules/@supabase/supabase-js/dist/index.mjs.map +1 -0
  504. package/templates/realtime-agent/node_modules/@supabase/supabase-js/dist/umd/supabase.js +24 -0
  505. package/templates/realtime-agent/node_modules/@supabase/supabase-js/package.json +122 -0
  506. package/templates/realtime-agent/node_modules/@supabase/supabase-js/src/SupabaseClient.ts +625 -0
  507. package/templates/realtime-agent/node_modules/@supabase/supabase-js/src/cors.ts +84 -0
  508. package/templates/realtime-agent/node_modules/@supabase/supabase-js/src/index.ts +106 -0
  509. package/templates/realtime-agent/node_modules/@supabase/supabase-js/src/lib/SupabaseAuthClient.ts +8 -0
  510. package/templates/realtime-agent/node_modules/@supabase/supabase-js/src/lib/constants.ts +35 -0
  511. package/templates/realtime-agent/node_modules/@supabase/supabase-js/src/lib/fetch.ts +36 -0
  512. package/templates/realtime-agent/node_modules/@supabase/supabase-js/src/lib/helpers.ts +98 -0
  513. package/templates/realtime-agent/node_modules/@supabase/supabase-js/src/lib/rest/types/common/common.ts +93 -0
  514. package/templates/realtime-agent/node_modules/@supabase/supabase-js/src/lib/rest/types/common/rpc.ts +158 -0
  515. package/templates/realtime-agent/node_modules/@supabase/supabase-js/src/lib/types.ts +196 -0
  516. package/templates/realtime-agent/node_modules/@supabase/supabase-js/src/lib/version.ts +7 -0
  517. package/templates/realtime-agent/node_modules/iceberg-js/LICENSE +21 -0
  518. package/templates/realtime-agent/node_modules/iceberg-js/README.md +439 -0
  519. package/templates/realtime-agent/node_modules/iceberg-js/dist/index.cjs +596 -0
  520. package/templates/realtime-agent/node_modules/iceberg-js/dist/index.cjs.map +1 -0
  521. package/templates/realtime-agent/node_modules/iceberg-js/dist/index.d.cts +547 -0
  522. package/templates/realtime-agent/node_modules/iceberg-js/dist/index.d.ts +547 -0
  523. package/templates/realtime-agent/node_modules/iceberg-js/dist/index.mjs +587 -0
  524. package/templates/realtime-agent/node_modules/iceberg-js/dist/index.mjs.map +1 -0
  525. package/templates/realtime-agent/node_modules/iceberg-js/package.json +77 -0
  526. package/templates/realtime-agent/node_modules/tslib/CopyrightNotice.txt +15 -0
  527. package/templates/realtime-agent/node_modules/tslib/LICENSE.txt +12 -0
  528. package/templates/realtime-agent/node_modules/tslib/README.md +164 -0
  529. package/templates/realtime-agent/node_modules/tslib/SECURITY.md +41 -0
  530. package/templates/realtime-agent/node_modules/tslib/modules/index.d.ts +38 -0
  531. package/templates/realtime-agent/node_modules/tslib/modules/index.js +70 -0
  532. package/templates/realtime-agent/node_modules/tslib/modules/package.json +3 -0
  533. package/templates/realtime-agent/node_modules/tslib/package.json +47 -0
  534. package/templates/realtime-agent/node_modules/tslib/tslib.d.ts +460 -0
  535. package/templates/realtime-agent/node_modules/tslib/tslib.es6.html +1 -0
  536. package/templates/realtime-agent/node_modules/tslib/tslib.es6.js +402 -0
  537. package/templates/realtime-agent/node_modules/tslib/tslib.es6.mjs +401 -0
  538. package/templates/realtime-agent/node_modules/tslib/tslib.html +1 -0
  539. package/templates/realtime-agent/node_modules/tslib/tslib.js +484 -0
  540. package/templates/realtime-agent/package-lock.json +114 -0
  541. package/templates/realtime-agent/package.json +11 -0
  542. package/templates/realtime-agent/src/index.js +152 -0
  543. package/templates/root/AGENT.md +37 -0
  544. package/templates/root/model.md +1 -0
  545. package/templates/root/prompt.md +91 -0
  546. package/templates/root/ralph.sh +47 -0
@@ -0,0 +1,1847 @@
1
+ "use strict";
2
+ var Phoenix = (() => {
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
+ var __async = (__this, __arguments, generator) => {
21
+ return new Promise((resolve, reject) => {
22
+ var fulfilled = (value) => {
23
+ try {
24
+ step(generator.next(value));
25
+ } catch (e) {
26
+ reject(e);
27
+ }
28
+ };
29
+ var rejected = (value) => {
30
+ try {
31
+ step(generator.throw(value));
32
+ } catch (e) {
33
+ reject(e);
34
+ }
35
+ };
36
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
37
+ step((generator = generator.apply(__this, __arguments)).next());
38
+ });
39
+ };
40
+
41
+ // js/phoenix/index.js
42
+ var phoenix_exports = {};
43
+ __export(phoenix_exports, {
44
+ Channel: () => Channel,
45
+ LongPoll: () => LongPoll,
46
+ Presence: () => Presence,
47
+ Push: () => Push,
48
+ Serializer: () => serializer_default,
49
+ Socket: () => Socket,
50
+ Timer: () => Timer
51
+ });
52
+
53
+ // js/phoenix/utils.js
54
+ var closure = (value) => {
55
+ if (typeof value === "function") {
56
+ return (
57
+ /** @type {() => T} */
58
+ value
59
+ );
60
+ } else {
61
+ let closure2 = function() {
62
+ return value;
63
+ };
64
+ return closure2;
65
+ }
66
+ };
67
+
68
+ // js/phoenix/constants.js
69
+ var globalSelf = typeof self !== "undefined" ? self : null;
70
+ var phxWindow = typeof window !== "undefined" ? window : null;
71
+ var global = globalSelf || phxWindow || globalThis;
72
+ var DEFAULT_VSN = "2.0.0";
73
+ var DEFAULT_TIMEOUT = 1e4;
74
+ var WS_CLOSE_NORMAL = 1e3;
75
+ var SOCKET_STATES = (
76
+ /** @type {const} */
77
+ { connecting: 0, open: 1, closing: 2, closed: 3 }
78
+ );
79
+ var CHANNEL_STATES = (
80
+ /** @type {const} */
81
+ {
82
+ closed: "closed",
83
+ errored: "errored",
84
+ joined: "joined",
85
+ joining: "joining",
86
+ leaving: "leaving"
87
+ }
88
+ );
89
+ var CHANNEL_EVENTS = (
90
+ /** @type {const} */
91
+ {
92
+ close: "phx_close",
93
+ error: "phx_error",
94
+ join: "phx_join",
95
+ reply: "phx_reply",
96
+ leave: "phx_leave"
97
+ }
98
+ );
99
+ var TRANSPORTS = (
100
+ /** @type {const} */
101
+ {
102
+ longpoll: "longpoll",
103
+ websocket: "websocket"
104
+ }
105
+ );
106
+ var XHR_STATES = (
107
+ /** @type {const} */
108
+ {
109
+ complete: 4
110
+ }
111
+ );
112
+ var AUTH_TOKEN_PREFIX = "base64url.bearer.phx.";
113
+
114
+ // js/phoenix/push.js
115
+ var Push = class {
116
+ /**
117
+ * Initializes the Push
118
+ * @param {Channel} channel - The Channel
119
+ * @param {ChannelEvent} event - The event, for example `"phx_join"`
120
+ * @param {() => Record<string, unknown>} payload - The payload, for example `{user_id: 123}`
121
+ * @param {number} timeout - The push timeout in milliseconds
122
+ */
123
+ constructor(channel, event, payload, timeout) {
124
+ this.channel = channel;
125
+ this.event = event;
126
+ this.payload = payload || function() {
127
+ return {};
128
+ };
129
+ this.receivedResp = null;
130
+ this.timeout = timeout;
131
+ this.timeoutTimer = null;
132
+ this.recHooks = [];
133
+ this.sent = false;
134
+ this.ref = void 0;
135
+ }
136
+ /**
137
+ *
138
+ * @param {number} timeout
139
+ */
140
+ resend(timeout) {
141
+ this.timeout = timeout;
142
+ this.reset();
143
+ this.send();
144
+ }
145
+ /**
146
+ *
147
+ */
148
+ send() {
149
+ if (this.hasReceived("timeout")) {
150
+ return;
151
+ }
152
+ this.startTimeout();
153
+ this.sent = true;
154
+ this.channel.socket.push({
155
+ topic: this.channel.topic,
156
+ event: this.event,
157
+ payload: this.payload(),
158
+ ref: this.ref,
159
+ join_ref: this.channel.joinRef()
160
+ });
161
+ }
162
+ /**
163
+ *
164
+ * @param {string} status
165
+ * @param {(response: any) => void} callback
166
+ */
167
+ receive(status, callback) {
168
+ if (this.hasReceived(status)) {
169
+ callback(this.receivedResp.response);
170
+ }
171
+ this.recHooks.push({ status, callback });
172
+ return this;
173
+ }
174
+ reset() {
175
+ this.cancelRefEvent();
176
+ this.ref = null;
177
+ this.refEvent = null;
178
+ this.receivedResp = null;
179
+ this.sent = false;
180
+ }
181
+ destroy() {
182
+ this.cancelRefEvent();
183
+ this.cancelTimeout();
184
+ }
185
+ /**
186
+ * @private
187
+ */
188
+ matchReceive({ status, response, _ref }) {
189
+ this.recHooks.filter((h) => h.status === status).forEach((h) => h.callback(response));
190
+ }
191
+ /**
192
+ * @private
193
+ */
194
+ cancelRefEvent() {
195
+ if (!this.refEvent) {
196
+ return;
197
+ }
198
+ this.channel.off(this.refEvent);
199
+ }
200
+ cancelTimeout() {
201
+ clearTimeout(this.timeoutTimer);
202
+ this.timeoutTimer = null;
203
+ }
204
+ startTimeout() {
205
+ if (this.timeoutTimer) {
206
+ this.cancelTimeout();
207
+ }
208
+ this.ref = this.channel.socket.makeRef();
209
+ this.refEvent = this.channel.replyEventName(this.ref);
210
+ this.channel.on(this.refEvent, (payload) => {
211
+ this.cancelRefEvent();
212
+ this.cancelTimeout();
213
+ this.receivedResp = payload;
214
+ this.matchReceive(payload);
215
+ });
216
+ this.timeoutTimer = setTimeout(() => {
217
+ this.trigger("timeout", {});
218
+ }, this.timeout);
219
+ }
220
+ /**
221
+ * @private
222
+ */
223
+ hasReceived(status) {
224
+ return this.receivedResp && this.receivedResp.status === status;
225
+ }
226
+ trigger(status, response) {
227
+ this.channel.trigger(this.refEvent, { status, response });
228
+ }
229
+ };
230
+
231
+ // js/phoenix/timer.js
232
+ var Timer = class {
233
+ /**
234
+ * @param {() => void} callback
235
+ * @param {(tries: number) => number} timerCalc
236
+ */
237
+ constructor(callback, timerCalc) {
238
+ this.callback = callback;
239
+ this.timerCalc = timerCalc;
240
+ this.timer = void 0;
241
+ this.tries = 0;
242
+ }
243
+ reset() {
244
+ this.tries = 0;
245
+ clearTimeout(this.timer);
246
+ }
247
+ /**
248
+ * Cancels any previous scheduleTimeout and schedules callback
249
+ */
250
+ scheduleTimeout() {
251
+ clearTimeout(this.timer);
252
+ this.timer = setTimeout(() => {
253
+ this.tries = this.tries + 1;
254
+ this.callback();
255
+ }, this.timerCalc(this.tries + 1));
256
+ }
257
+ };
258
+
259
+ // js/phoenix/channel.js
260
+ var Channel = class {
261
+ /**
262
+ * @param {string} topic
263
+ * @param {Params | (() => Params)} params
264
+ * @param {Socket} socket
265
+ */
266
+ constructor(topic, params, socket) {
267
+ this.state = CHANNEL_STATES.closed;
268
+ this.topic = topic;
269
+ this.params = closure(params || {});
270
+ this.socket = socket;
271
+ this.bindings = [];
272
+ this.bindingRef = 0;
273
+ this.timeout = this.socket.timeout;
274
+ this.joinedOnce = false;
275
+ this.joinPush = new Push(this, CHANNEL_EVENTS.join, this.params, this.timeout);
276
+ this.pushBuffer = [];
277
+ this.stateChangeRefs = [];
278
+ this.rejoinTimer = new Timer(() => {
279
+ if (this.socket.isConnected()) {
280
+ this.rejoin();
281
+ }
282
+ }, this.socket.rejoinAfterMs);
283
+ this.stateChangeRefs.push(this.socket.onError(() => this.rejoinTimer.reset()));
284
+ this.stateChangeRefs.push(
285
+ this.socket.onOpen(() => {
286
+ this.rejoinTimer.reset();
287
+ if (this.isErrored()) {
288
+ this.rejoin();
289
+ }
290
+ })
291
+ );
292
+ this.joinPush.receive("ok", () => {
293
+ this.state = CHANNEL_STATES.joined;
294
+ this.rejoinTimer.reset();
295
+ this.pushBuffer.forEach((pushEvent) => pushEvent.send());
296
+ this.pushBuffer = [];
297
+ });
298
+ this.joinPush.receive("error", (reason) => {
299
+ this.state = CHANNEL_STATES.errored;
300
+ if (this.socket.hasLogger()) this.socket.log("channel", `error ${this.topic}`, reason);
301
+ if (this.socket.isConnected()) {
302
+ this.rejoinTimer.scheduleTimeout();
303
+ }
304
+ });
305
+ this.onClose(() => {
306
+ this.rejoinTimer.reset();
307
+ if (this.socket.hasLogger()) this.socket.log("channel", `close ${this.topic}`);
308
+ this.state = CHANNEL_STATES.closed;
309
+ this.socket.remove(this);
310
+ });
311
+ this.onError((reason) => {
312
+ if (this.socket.hasLogger()) this.socket.log("channel", `error ${this.topic}`, reason);
313
+ if (this.isJoining()) {
314
+ this.joinPush.reset();
315
+ }
316
+ this.state = CHANNEL_STATES.errored;
317
+ if (this.socket.isConnected()) {
318
+ this.rejoinTimer.scheduleTimeout();
319
+ }
320
+ });
321
+ this.joinPush.receive("timeout", () => {
322
+ if (this.socket.hasLogger()) this.socket.log("channel", `timeout ${this.topic}`, this.joinPush.timeout);
323
+ let leavePush = new Push(this, CHANNEL_EVENTS.leave, closure({}), this.timeout);
324
+ leavePush.send();
325
+ this.state = CHANNEL_STATES.errored;
326
+ this.joinPush.reset();
327
+ if (this.socket.isConnected()) {
328
+ this.rejoinTimer.scheduleTimeout();
329
+ }
330
+ });
331
+ this.on(CHANNEL_EVENTS.reply, (payload, ref) => {
332
+ this.trigger(this.replyEventName(ref), payload);
333
+ });
334
+ }
335
+ /**
336
+ * Join the channel
337
+ * @param {number} timeout
338
+ * @returns {Push}
339
+ */
340
+ join(timeout = this.timeout) {
341
+ if (this.joinedOnce) {
342
+ throw new Error("tried to join multiple times. 'join' can only be called a single time per channel instance");
343
+ } else {
344
+ this.timeout = timeout;
345
+ this.joinedOnce = true;
346
+ this.rejoin();
347
+ return this.joinPush;
348
+ }
349
+ }
350
+ /**
351
+ * Teardown the channel.
352
+ *
353
+ * Destroys and stops related timers.
354
+ */
355
+ teardown() {
356
+ this.pushBuffer.forEach((push) => push.destroy());
357
+ this.pushBuffer = [];
358
+ this.rejoinTimer.reset();
359
+ this.joinPush.destroy();
360
+ this.state = CHANNEL_STATES.closed;
361
+ this.bindings = [];
362
+ }
363
+ /**
364
+ * Hook into channel close
365
+ * @param {ChannelBindingCallback} callback
366
+ */
367
+ onClose(callback) {
368
+ this.on(CHANNEL_EVENTS.close, callback);
369
+ }
370
+ /**
371
+ * Hook into channel errors
372
+ * @param {ChannelOnErrorCallback} callback
373
+ * @return {number}
374
+ */
375
+ onError(callback) {
376
+ return this.on(CHANNEL_EVENTS.error, (reason) => callback(reason));
377
+ }
378
+ /**
379
+ * Subscribes on channel events
380
+ *
381
+ * Subscription returns a ref counter, which can be used later to
382
+ * unsubscribe the exact event listener
383
+ *
384
+ * @example
385
+ * const ref1 = channel.on("event", do_stuff)
386
+ * const ref2 = channel.on("event", do_other_stuff)
387
+ * channel.off("event", ref1)
388
+ * // Since unsubscription, do_stuff won't fire,
389
+ * // while do_other_stuff will keep firing on the "event"
390
+ *
391
+ * @param {string} event
392
+ * @param {ChannelBindingCallback} callback
393
+ * @returns {number} ref
394
+ */
395
+ on(event, callback) {
396
+ let ref = this.bindingRef++;
397
+ this.bindings.push({ event, ref, callback });
398
+ return ref;
399
+ }
400
+ /**
401
+ * Unsubscribes off of channel events
402
+ *
403
+ * Use the ref returned from a channel.on() to unsubscribe one
404
+ * handler, or pass nothing for the ref to unsubscribe all
405
+ * handlers for the given event.
406
+ *
407
+ * @example
408
+ * // Unsubscribe the do_stuff handler
409
+ * const ref1 = channel.on("event", do_stuff)
410
+ * channel.off("event", ref1)
411
+ *
412
+ * // Unsubscribe all handlers from event
413
+ * channel.off("event")
414
+ *
415
+ * @param {string} event
416
+ * @param {number} [ref]
417
+ */
418
+ off(event, ref) {
419
+ this.bindings = this.bindings.filter((bind) => {
420
+ return !(bind.event === event && (typeof ref === "undefined" || ref === bind.ref));
421
+ });
422
+ }
423
+ /**
424
+ * @private
425
+ */
426
+ canPush() {
427
+ return this.socket.isConnected() && this.isJoined();
428
+ }
429
+ /**
430
+ * Sends a message `event` to phoenix with the payload `payload`.
431
+ * Phoenix receives this in the `handle_in(event, payload, socket)`
432
+ * function. if phoenix replies or it times out (default 10000ms),
433
+ * then optionally the reply can be received.
434
+ *
435
+ * @example
436
+ * channel.push("event")
437
+ * .receive("ok", payload => console.log("phoenix replied:", payload))
438
+ * .receive("error", err => console.log("phoenix errored", err))
439
+ * .receive("timeout", () => console.log("timed out pushing"))
440
+ * @param {string} event
441
+ * @param {Object} payload
442
+ * @param {number} [timeout]
443
+ * @returns {Push}
444
+ */
445
+ push(event, payload, timeout = this.timeout) {
446
+ payload = payload || {};
447
+ if (!this.joinedOnce) {
448
+ throw new Error(`tried to push '${event}' to '${this.topic}' before joining. Use channel.join() before pushing events`);
449
+ }
450
+ let pushEvent = new Push(this, event, function() {
451
+ return payload;
452
+ }, timeout);
453
+ if (this.canPush()) {
454
+ pushEvent.send();
455
+ } else {
456
+ pushEvent.startTimeout();
457
+ this.pushBuffer.push(pushEvent);
458
+ }
459
+ return pushEvent;
460
+ }
461
+ /** Leaves the channel
462
+ *
463
+ * Unsubscribes from server events, and
464
+ * instructs channel to terminate on server
465
+ *
466
+ * Triggers onClose() hooks
467
+ *
468
+ * To receive leave acknowledgements, use the `receive`
469
+ * hook to bind to the server ack, ie:
470
+ *
471
+ * @example
472
+ * channel.leave().receive("ok", () => alert("left!") )
473
+ *
474
+ * @param {number} timeout
475
+ * @returns {Push}
476
+ */
477
+ leave(timeout = this.timeout) {
478
+ this.rejoinTimer.reset();
479
+ this.joinPush.cancelTimeout();
480
+ this.state = CHANNEL_STATES.leaving;
481
+ let onClose = () => {
482
+ if (this.socket.hasLogger()) this.socket.log("channel", `leave ${this.topic}`);
483
+ this.trigger(CHANNEL_EVENTS.close, "leave");
484
+ };
485
+ let leavePush = new Push(this, CHANNEL_EVENTS.leave, closure({}), timeout);
486
+ leavePush.receive("ok", () => onClose()).receive("timeout", () => onClose());
487
+ leavePush.send();
488
+ if (!this.canPush()) {
489
+ leavePush.trigger("ok", {});
490
+ }
491
+ return leavePush;
492
+ }
493
+ /**
494
+ * Overridable message hook
495
+ *
496
+ * Receives all events for specialized message handling
497
+ * before dispatching to the channel callbacks.
498
+ *
499
+ * Must return the payload, modified or unmodified
500
+ * @type{ChannelOnMessage}
501
+ */
502
+ onMessage(_event, payload, _ref) {
503
+ return payload;
504
+ }
505
+ /**
506
+ * Overridable filter hook
507
+ *
508
+ * If this function returns `true`, `binding`'s callback will be called.
509
+ *
510
+ * @type{ChannelFilterBindings}
511
+ */
512
+ filterBindings(_binding, _payload, _ref) {
513
+ return true;
514
+ }
515
+ isMember(topic, event, payload, joinRef) {
516
+ if (this.topic !== topic) {
517
+ return false;
518
+ }
519
+ if (joinRef && joinRef !== this.joinRef()) {
520
+ if (this.socket.hasLogger()) this.socket.log("channel", "dropping outdated message", { topic, event, payload, joinRef });
521
+ return false;
522
+ } else {
523
+ return true;
524
+ }
525
+ }
526
+ joinRef() {
527
+ return this.joinPush.ref;
528
+ }
529
+ /**
530
+ * @private
531
+ */
532
+ rejoin(timeout = this.timeout) {
533
+ if (this.isLeaving()) {
534
+ return;
535
+ }
536
+ this.socket.leaveOpenTopic(this.topic);
537
+ this.state = CHANNEL_STATES.joining;
538
+ this.joinPush.resend(timeout);
539
+ }
540
+ /**
541
+ * @param {string} event
542
+ * @param {unknown} [payload]
543
+ * @param {?string} [ref]
544
+ * @param {?string} [joinRef]
545
+ */
546
+ trigger(event, payload, ref, joinRef) {
547
+ let handledPayload = this.onMessage(event, payload, ref, joinRef);
548
+ if (payload && !handledPayload) {
549
+ throw new Error("channel onMessage callbacks must return the payload, modified or unmodified");
550
+ }
551
+ let eventBindings = this.bindings.filter((bind) => bind.event === event && this.filterBindings(bind, payload, ref));
552
+ for (let i = 0; i < eventBindings.length; i++) {
553
+ let bind = eventBindings[i];
554
+ bind.callback(handledPayload, ref, joinRef || this.joinRef());
555
+ }
556
+ }
557
+ /**
558
+ * @param {string} ref
559
+ */
560
+ replyEventName(ref) {
561
+ return `chan_reply_${ref}`;
562
+ }
563
+ isClosed() {
564
+ return this.state === CHANNEL_STATES.closed;
565
+ }
566
+ isErrored() {
567
+ return this.state === CHANNEL_STATES.errored;
568
+ }
569
+ isJoined() {
570
+ return this.state === CHANNEL_STATES.joined;
571
+ }
572
+ isJoining() {
573
+ return this.state === CHANNEL_STATES.joining;
574
+ }
575
+ isLeaving() {
576
+ return this.state === CHANNEL_STATES.leaving;
577
+ }
578
+ };
579
+
580
+ // js/phoenix/ajax.js
581
+ var Ajax = class {
582
+ static request(method, endPoint, headers, body, timeout, ontimeout, callback) {
583
+ if (global.XDomainRequest) {
584
+ let req = new global.XDomainRequest();
585
+ return this.xdomainRequest(req, method, endPoint, body, timeout, ontimeout, callback);
586
+ } else if (global.XMLHttpRequest) {
587
+ let req = new global.XMLHttpRequest();
588
+ return this.xhrRequest(req, method, endPoint, headers, body, timeout, ontimeout, callback);
589
+ } else if (global.fetch && global.AbortController) {
590
+ return this.fetchRequest(method, endPoint, headers, body, timeout, ontimeout, callback);
591
+ } else {
592
+ throw new Error("No suitable XMLHttpRequest implementation found");
593
+ }
594
+ }
595
+ static fetchRequest(method, endPoint, headers, body, timeout, ontimeout, callback) {
596
+ let options = {
597
+ method,
598
+ headers,
599
+ body
600
+ };
601
+ let controller = null;
602
+ if (timeout) {
603
+ controller = new AbortController();
604
+ const _timeoutId = setTimeout(() => controller.abort(), timeout);
605
+ options.signal = controller.signal;
606
+ }
607
+ global.fetch(endPoint, options).then((response) => response.text()).then((data) => this.parseJSON(data)).then((data) => callback && callback(data)).catch((err) => {
608
+ if (err.name === "AbortError" && ontimeout) {
609
+ ontimeout();
610
+ } else {
611
+ callback && callback(null);
612
+ }
613
+ });
614
+ return controller;
615
+ }
616
+ static xdomainRequest(req, method, endPoint, body, timeout, ontimeout, callback) {
617
+ req.timeout = timeout;
618
+ req.open(method, endPoint);
619
+ req.onload = () => {
620
+ let response = this.parseJSON(req.responseText);
621
+ callback && callback(response);
622
+ };
623
+ if (ontimeout) {
624
+ req.ontimeout = ontimeout;
625
+ }
626
+ req.onprogress = () => {
627
+ };
628
+ req.send(body);
629
+ return req;
630
+ }
631
+ static xhrRequest(req, method, endPoint, headers, body, timeout, ontimeout, callback) {
632
+ req.open(method, endPoint, true);
633
+ req.timeout = timeout;
634
+ for (let [key, value] of Object.entries(headers)) {
635
+ req.setRequestHeader(key, value);
636
+ }
637
+ req.onerror = () => callback && callback(null);
638
+ req.onreadystatechange = () => {
639
+ if (req.readyState === XHR_STATES.complete && callback) {
640
+ let response = this.parseJSON(req.responseText);
641
+ callback(response);
642
+ }
643
+ };
644
+ if (ontimeout) {
645
+ req.ontimeout = ontimeout;
646
+ }
647
+ req.send(body);
648
+ return req;
649
+ }
650
+ static parseJSON(resp) {
651
+ if (!resp || resp === "") {
652
+ return null;
653
+ }
654
+ try {
655
+ return JSON.parse(resp);
656
+ } catch (e) {
657
+ console && console.log("failed to parse JSON response", resp);
658
+ return null;
659
+ }
660
+ }
661
+ static serialize(obj, parentKey) {
662
+ let queryStr = [];
663
+ for (var key in obj) {
664
+ if (!Object.prototype.hasOwnProperty.call(obj, key)) {
665
+ continue;
666
+ }
667
+ let paramKey = parentKey ? `${parentKey}[${key}]` : key;
668
+ let paramVal = obj[key];
669
+ if (typeof paramVal === "object") {
670
+ queryStr.push(this.serialize(paramVal, paramKey));
671
+ } else {
672
+ queryStr.push(encodeURIComponent(paramKey) + "=" + encodeURIComponent(paramVal));
673
+ }
674
+ }
675
+ return queryStr.join("&");
676
+ }
677
+ static appendParams(url, params) {
678
+ if (Object.keys(params).length === 0) {
679
+ return url;
680
+ }
681
+ let prefix = url.match(/\?/) ? "&" : "?";
682
+ return `${url}${prefix}${this.serialize(params)}`;
683
+ }
684
+ };
685
+
686
+ // js/phoenix/longpoll.js
687
+ var arrayBufferToBase64 = (buffer) => {
688
+ let binary = "";
689
+ let bytes = new Uint8Array(buffer);
690
+ let len = bytes.byteLength;
691
+ for (let i = 0; i < len; i++) {
692
+ binary += String.fromCharCode(bytes[i]);
693
+ }
694
+ return btoa(binary);
695
+ };
696
+ var LongPoll = class {
697
+ constructor(endPoint, protocols) {
698
+ if (protocols && protocols.length === 2 && protocols[1].startsWith(AUTH_TOKEN_PREFIX)) {
699
+ this.authToken = atob(protocols[1].slice(AUTH_TOKEN_PREFIX.length));
700
+ }
701
+ this.endPoint = null;
702
+ this.token = null;
703
+ this.skipHeartbeat = true;
704
+ this.reqs = /* @__PURE__ */ new Set();
705
+ this.awaitingBatchAck = false;
706
+ this.currentBatch = null;
707
+ this.currentBatchTimer = null;
708
+ this.batchBuffer = [];
709
+ this.onopen = function() {
710
+ };
711
+ this.onerror = function() {
712
+ };
713
+ this.onmessage = function() {
714
+ };
715
+ this.onclose = function() {
716
+ };
717
+ this.pollEndpoint = this.normalizeEndpoint(endPoint);
718
+ this.readyState = SOCKET_STATES.connecting;
719
+ setTimeout(() => this.poll(), 0);
720
+ }
721
+ normalizeEndpoint(endPoint) {
722
+ return endPoint.replace("ws://", "http://").replace("wss://", "https://").replace(new RegExp("(.*)/" + TRANSPORTS.websocket), "$1/" + TRANSPORTS.longpoll);
723
+ }
724
+ endpointURL() {
725
+ return Ajax.appendParams(this.pollEndpoint, { token: this.token });
726
+ }
727
+ closeAndRetry(code, reason, wasClean) {
728
+ this.close(code, reason, wasClean);
729
+ this.readyState = SOCKET_STATES.connecting;
730
+ }
731
+ ontimeout() {
732
+ this.onerror("timeout");
733
+ this.closeAndRetry(1005, "timeout", false);
734
+ }
735
+ isActive() {
736
+ return this.readyState === SOCKET_STATES.open || this.readyState === SOCKET_STATES.connecting;
737
+ }
738
+ poll() {
739
+ const headers = { "Accept": "application/json" };
740
+ if (this.authToken) {
741
+ headers["X-Phoenix-AuthToken"] = this.authToken;
742
+ }
743
+ this.ajax("GET", headers, null, () => this.ontimeout(), (resp) => {
744
+ if (resp) {
745
+ var { status, token, messages } = resp;
746
+ if (status === 410 && this.token !== null) {
747
+ this.onerror(410);
748
+ this.closeAndRetry(3410, "session_gone", false);
749
+ return;
750
+ }
751
+ this.token = token;
752
+ } else {
753
+ status = 0;
754
+ }
755
+ switch (status) {
756
+ case 200:
757
+ messages.forEach((msg) => {
758
+ setTimeout(() => this.onmessage({ data: msg }), 0);
759
+ });
760
+ this.poll();
761
+ break;
762
+ case 204:
763
+ this.poll();
764
+ break;
765
+ case 410:
766
+ this.readyState = SOCKET_STATES.open;
767
+ this.onopen({});
768
+ this.poll();
769
+ break;
770
+ case 403:
771
+ this.onerror(403);
772
+ this.close(1008, "forbidden", false);
773
+ break;
774
+ case 0:
775
+ case 500:
776
+ this.onerror(500);
777
+ this.closeAndRetry(1011, "internal server error", 500);
778
+ break;
779
+ default:
780
+ throw new Error(`unhandled poll status ${status}`);
781
+ }
782
+ });
783
+ }
784
+ // we collect all pushes within the current event loop by
785
+ // setTimeout 0, which optimizes back-to-back procedural
786
+ // pushes against an empty buffer
787
+ send(body) {
788
+ if (typeof body !== "string") {
789
+ body = arrayBufferToBase64(body);
790
+ }
791
+ if (this.currentBatch) {
792
+ this.currentBatch.push(body);
793
+ } else if (this.awaitingBatchAck) {
794
+ this.batchBuffer.push(body);
795
+ } else {
796
+ this.currentBatch = [body];
797
+ this.currentBatchTimer = setTimeout(() => {
798
+ this.batchSend(this.currentBatch);
799
+ this.currentBatch = null;
800
+ }, 0);
801
+ }
802
+ }
803
+ batchSend(messages) {
804
+ this.awaitingBatchAck = true;
805
+ this.ajax("POST", { "Content-Type": "application/x-ndjson" }, messages.join("\n"), () => this.onerror("timeout"), (resp) => {
806
+ this.awaitingBatchAck = false;
807
+ if (!resp || resp.status !== 200) {
808
+ this.onerror(resp && resp.status);
809
+ this.closeAndRetry(1011, "internal server error", false);
810
+ } else if (this.batchBuffer.length > 0) {
811
+ this.batchSend(this.batchBuffer);
812
+ this.batchBuffer = [];
813
+ }
814
+ });
815
+ }
816
+ close(code, reason, wasClean) {
817
+ for (let req of this.reqs) {
818
+ req.abort();
819
+ }
820
+ this.readyState = SOCKET_STATES.closed;
821
+ let opts = Object.assign({ code: 1e3, reason: void 0, wasClean: true }, { code, reason, wasClean });
822
+ this.batchBuffer = [];
823
+ clearTimeout(this.currentBatchTimer);
824
+ this.currentBatchTimer = null;
825
+ if (typeof CloseEvent !== "undefined") {
826
+ this.onclose(new CloseEvent("close", opts));
827
+ } else {
828
+ this.onclose(opts);
829
+ }
830
+ }
831
+ ajax(method, headers, body, onCallerTimeout, callback) {
832
+ let req;
833
+ let ontimeout = () => {
834
+ this.reqs.delete(req);
835
+ onCallerTimeout();
836
+ };
837
+ req = Ajax.request(method, this.endpointURL(), headers, body, this.timeout, ontimeout, (resp) => {
838
+ this.reqs.delete(req);
839
+ if (this.isActive()) {
840
+ callback(resp);
841
+ }
842
+ });
843
+ this.reqs.add(req);
844
+ }
845
+ };
846
+
847
+ // js/phoenix/presence.js
848
+ var Presence = class _Presence {
849
+ /**
850
+ * Initializes the Presence
851
+ * @param {Channel} channel - The Channel
852
+ * @param {PresenceOptions} [opts] - The options, for example `{events: {state: "state", diff: "diff"}}`
853
+ */
854
+ constructor(channel, opts = {}) {
855
+ let events = opts.events || /** @type {PresenceEvents} */
856
+ { state: "presence_state", diff: "presence_diff" };
857
+ this.state = {};
858
+ this.pendingDiffs = [];
859
+ this.channel = channel;
860
+ this.joinRef = null;
861
+ this.caller = {
862
+ onJoin: function() {
863
+ },
864
+ onLeave: function() {
865
+ },
866
+ onSync: function() {
867
+ }
868
+ };
869
+ this.channel.on(events.state, (newState) => {
870
+ let { onJoin, onLeave, onSync } = this.caller;
871
+ this.joinRef = this.channel.joinRef();
872
+ this.state = _Presence.syncState(this.state, newState, onJoin, onLeave);
873
+ this.pendingDiffs.forEach((diff) => {
874
+ this.state = _Presence.syncDiff(this.state, diff, onJoin, onLeave);
875
+ });
876
+ this.pendingDiffs = [];
877
+ onSync();
878
+ });
879
+ this.channel.on(events.diff, (diff) => {
880
+ let { onJoin, onLeave, onSync } = this.caller;
881
+ if (this.inPendingSyncState()) {
882
+ this.pendingDiffs.push(diff);
883
+ } else {
884
+ this.state = _Presence.syncDiff(this.state, diff, onJoin, onLeave);
885
+ onSync();
886
+ }
887
+ });
888
+ }
889
+ /**
890
+ * @param {PresenceOnJoin} callback
891
+ */
892
+ onJoin(callback) {
893
+ this.caller.onJoin = callback;
894
+ }
895
+ /**
896
+ * @param {PresenceOnLeave} callback
897
+ */
898
+ onLeave(callback) {
899
+ this.caller.onLeave = callback;
900
+ }
901
+ /**
902
+ * @param {PresenceOnSync} callback
903
+ */
904
+ onSync(callback) {
905
+ this.caller.onSync = callback;
906
+ }
907
+ /**
908
+ * Returns the array of presences, with selected metadata.
909
+ *
910
+ * @template [T=PresenceState]
911
+ * @param {((key: string, obj: PresenceState) => T)} [by]
912
+ *
913
+ * @returns {T[]}
914
+ */
915
+ list(by) {
916
+ return _Presence.list(this.state, by);
917
+ }
918
+ inPendingSyncState() {
919
+ return !this.joinRef || this.joinRef !== this.channel.joinRef();
920
+ }
921
+ // lower-level public static API
922
+ /**
923
+ * Used to sync the list of presences on the server
924
+ * with the client's state. An optional `onJoin` and `onLeave` callback can
925
+ * be provided to react to changes in the client's local presences across
926
+ * disconnects and reconnects with the server.
927
+ *
928
+ * @param {Record<string, PresenceState>} currentState
929
+ * @param {Record<string, PresenceState>} newState
930
+ * @param {PresenceOnJoin} onJoin
931
+ * @param {PresenceOnLeave} onLeave
932
+ *
933
+ * @returns {Record<string, PresenceState>}
934
+ */
935
+ static syncState(currentState, newState, onJoin, onLeave) {
936
+ let state = this.clone(currentState);
937
+ let joins = {};
938
+ let leaves = {};
939
+ this.map(state, (key, presence) => {
940
+ if (!newState[key]) {
941
+ leaves[key] = presence;
942
+ }
943
+ });
944
+ this.map(newState, (key, newPresence) => {
945
+ let currentPresence = state[key];
946
+ if (currentPresence) {
947
+ let newRefs = newPresence.metas.map((m) => m.phx_ref);
948
+ let curRefs = currentPresence.metas.map((m) => m.phx_ref);
949
+ let joinedMetas = newPresence.metas.filter((m) => curRefs.indexOf(m.phx_ref) < 0);
950
+ let leftMetas = currentPresence.metas.filter((m) => newRefs.indexOf(m.phx_ref) < 0);
951
+ if (joinedMetas.length > 0) {
952
+ joins[key] = newPresence;
953
+ joins[key].metas = joinedMetas;
954
+ }
955
+ if (leftMetas.length > 0) {
956
+ leaves[key] = this.clone(currentPresence);
957
+ leaves[key].metas = leftMetas;
958
+ }
959
+ } else {
960
+ joins[key] = newPresence;
961
+ }
962
+ });
963
+ return this.syncDiff(state, { joins, leaves }, onJoin, onLeave);
964
+ }
965
+ /**
966
+ *
967
+ * Used to sync a diff of presence join and leave
968
+ * events from the server, as they happen. Like `syncState`, `syncDiff`
969
+ * accepts optional `onJoin` and `onLeave` callbacks to react to a user
970
+ * joining or leaving from a device.
971
+ *
972
+ * @param {Record<string, PresenceState>} state
973
+ * @param {PresenceDiff} diff
974
+ * @param {PresenceOnJoin} onJoin
975
+ * @param {PresenceOnLeave} onLeave
976
+ *
977
+ * @returns {Record<string, PresenceState>}
978
+ */
979
+ static syncDiff(state, diff, onJoin, onLeave) {
980
+ let { joins, leaves } = this.clone(diff);
981
+ if (!onJoin) {
982
+ onJoin = function() {
983
+ };
984
+ }
985
+ if (!onLeave) {
986
+ onLeave = function() {
987
+ };
988
+ }
989
+ this.map(joins, (key, newPresence) => {
990
+ let currentPresence = state[key];
991
+ state[key] = this.clone(newPresence);
992
+ if (currentPresence) {
993
+ let joinedRefs = state[key].metas.map((m) => m.phx_ref);
994
+ let curMetas = currentPresence.metas.filter((m) => joinedRefs.indexOf(m.phx_ref) < 0);
995
+ state[key].metas.unshift(...curMetas);
996
+ }
997
+ onJoin(key, currentPresence, newPresence);
998
+ });
999
+ this.map(leaves, (key, leftPresence) => {
1000
+ let currentPresence = state[key];
1001
+ if (!currentPresence) {
1002
+ return;
1003
+ }
1004
+ let refsToRemove = leftPresence.metas.map((m) => m.phx_ref);
1005
+ currentPresence.metas = currentPresence.metas.filter((p) => {
1006
+ return refsToRemove.indexOf(p.phx_ref) < 0;
1007
+ });
1008
+ onLeave(key, currentPresence, leftPresence);
1009
+ if (currentPresence.metas.length === 0) {
1010
+ delete state[key];
1011
+ }
1012
+ });
1013
+ return state;
1014
+ }
1015
+ /**
1016
+ * Returns the array of presences, with selected metadata.
1017
+ *
1018
+ * @template [T=PresenceState]
1019
+ * @param {Record<string, PresenceState>} presences
1020
+ * @param {((key: string, obj: PresenceState) => T)} [chooser]
1021
+ *
1022
+ * @returns {T[]}
1023
+ */
1024
+ static list(presences, chooser) {
1025
+ if (!chooser) {
1026
+ chooser = function(key, pres) {
1027
+ return pres;
1028
+ };
1029
+ }
1030
+ return this.map(presences, (key, presence) => {
1031
+ return chooser(key, presence);
1032
+ });
1033
+ }
1034
+ // private
1035
+ /**
1036
+ * @template T
1037
+ * @param {Record<string, PresenceState>} obj
1038
+ * @param {(key: string, obj: PresenceState) => T} func
1039
+ */
1040
+ static map(obj, func) {
1041
+ return Object.getOwnPropertyNames(obj).map((key) => func(key, obj[key]));
1042
+ }
1043
+ /**
1044
+ * @template T
1045
+ * @param {T} obj
1046
+ * @returns {T}
1047
+ */
1048
+ static clone(obj) {
1049
+ return JSON.parse(JSON.stringify(obj));
1050
+ }
1051
+ };
1052
+
1053
+ // js/phoenix/serializer.js
1054
+ var serializer_default = {
1055
+ HEADER_LENGTH: 1,
1056
+ META_LENGTH: 4,
1057
+ KINDS: { push: 0, reply: 1, broadcast: 2 },
1058
+ /**
1059
+ * @template T
1060
+ * @param {Message<Record<string, any>>} msg
1061
+ * @param {(msg: ArrayBuffer | string) => T} callback
1062
+ * @returns {T}
1063
+ */
1064
+ encode(msg, callback) {
1065
+ if (msg.payload.constructor === ArrayBuffer) {
1066
+ return callback(this.binaryEncode(msg));
1067
+ } else {
1068
+ let payload = [msg.join_ref, msg.ref, msg.topic, msg.event, msg.payload];
1069
+ return callback(JSON.stringify(payload));
1070
+ }
1071
+ },
1072
+ /**
1073
+ * @template T
1074
+ * @param {ArrayBuffer | string} rawPayload
1075
+ * @param {(msg: Message<unknown>) => T} callback
1076
+ * @returns {T}
1077
+ */
1078
+ decode(rawPayload, callback) {
1079
+ if (rawPayload.constructor === ArrayBuffer) {
1080
+ return callback(this.binaryDecode(rawPayload));
1081
+ } else {
1082
+ let [join_ref, ref, topic, event, payload] = JSON.parse(rawPayload);
1083
+ return callback({ join_ref, ref, topic, event, payload });
1084
+ }
1085
+ },
1086
+ /** @private */
1087
+ binaryEncode(message) {
1088
+ let { join_ref, ref, event, topic, payload } = message;
1089
+ let metaLength = this.META_LENGTH + join_ref.length + ref.length + topic.length + event.length;
1090
+ let header = new ArrayBuffer(this.HEADER_LENGTH + metaLength);
1091
+ let view = new DataView(header);
1092
+ let offset = 0;
1093
+ view.setUint8(offset++, this.KINDS.push);
1094
+ view.setUint8(offset++, join_ref.length);
1095
+ view.setUint8(offset++, ref.length);
1096
+ view.setUint8(offset++, topic.length);
1097
+ view.setUint8(offset++, event.length);
1098
+ Array.from(join_ref, (char) => view.setUint8(offset++, char.charCodeAt(0)));
1099
+ Array.from(ref, (char) => view.setUint8(offset++, char.charCodeAt(0)));
1100
+ Array.from(topic, (char) => view.setUint8(offset++, char.charCodeAt(0)));
1101
+ Array.from(event, (char) => view.setUint8(offset++, char.charCodeAt(0)));
1102
+ var combined = new Uint8Array(header.byteLength + payload.byteLength);
1103
+ combined.set(new Uint8Array(header), 0);
1104
+ combined.set(new Uint8Array(payload), header.byteLength);
1105
+ return combined.buffer;
1106
+ },
1107
+ /**
1108
+ * @private
1109
+ */
1110
+ binaryDecode(buffer) {
1111
+ let view = new DataView(buffer);
1112
+ let kind = view.getUint8(0);
1113
+ let decoder = new TextDecoder();
1114
+ switch (kind) {
1115
+ case this.KINDS.push:
1116
+ return this.decodePush(buffer, view, decoder);
1117
+ case this.KINDS.reply:
1118
+ return this.decodeReply(buffer, view, decoder);
1119
+ case this.KINDS.broadcast:
1120
+ return this.decodeBroadcast(buffer, view, decoder);
1121
+ }
1122
+ },
1123
+ /** @private */
1124
+ decodePush(buffer, view, decoder) {
1125
+ let joinRefSize = view.getUint8(1);
1126
+ let topicSize = view.getUint8(2);
1127
+ let eventSize = view.getUint8(3);
1128
+ let offset = this.HEADER_LENGTH + this.META_LENGTH - 1;
1129
+ let joinRef = decoder.decode(buffer.slice(offset, offset + joinRefSize));
1130
+ offset = offset + joinRefSize;
1131
+ let topic = decoder.decode(buffer.slice(offset, offset + topicSize));
1132
+ offset = offset + topicSize;
1133
+ let event = decoder.decode(buffer.slice(offset, offset + eventSize));
1134
+ offset = offset + eventSize;
1135
+ let data = buffer.slice(offset, buffer.byteLength);
1136
+ return { join_ref: joinRef, ref: null, topic, event, payload: data };
1137
+ },
1138
+ /** @private */
1139
+ decodeReply(buffer, view, decoder) {
1140
+ let joinRefSize = view.getUint8(1);
1141
+ let refSize = view.getUint8(2);
1142
+ let topicSize = view.getUint8(3);
1143
+ let eventSize = view.getUint8(4);
1144
+ let offset = this.HEADER_LENGTH + this.META_LENGTH;
1145
+ let joinRef = decoder.decode(buffer.slice(offset, offset + joinRefSize));
1146
+ offset = offset + joinRefSize;
1147
+ let ref = decoder.decode(buffer.slice(offset, offset + refSize));
1148
+ offset = offset + refSize;
1149
+ let topic = decoder.decode(buffer.slice(offset, offset + topicSize));
1150
+ offset = offset + topicSize;
1151
+ let event = decoder.decode(buffer.slice(offset, offset + eventSize));
1152
+ offset = offset + eventSize;
1153
+ let data = buffer.slice(offset, buffer.byteLength);
1154
+ let payload = { status: event, response: data };
1155
+ return { join_ref: joinRef, ref, topic, event: CHANNEL_EVENTS.reply, payload };
1156
+ },
1157
+ /** @private */
1158
+ decodeBroadcast(buffer, view, decoder) {
1159
+ let topicSize = view.getUint8(1);
1160
+ let eventSize = view.getUint8(2);
1161
+ let offset = this.HEADER_LENGTH + 2;
1162
+ let topic = decoder.decode(buffer.slice(offset, offset + topicSize));
1163
+ offset = offset + topicSize;
1164
+ let event = decoder.decode(buffer.slice(offset, offset + eventSize));
1165
+ offset = offset + eventSize;
1166
+ let data = buffer.slice(offset, buffer.byteLength);
1167
+ return { join_ref: null, ref: null, topic, event, payload: data };
1168
+ }
1169
+ };
1170
+
1171
+ // js/phoenix/socket.js
1172
+ var Socket = class {
1173
+ /** Initializes the Socket *
1174
+ *
1175
+ * For IE8 support use an ES5-shim (https://github.com/es-shims/es5-shim)
1176
+ *
1177
+ * @constructor
1178
+ * @param {string} endPoint - The string WebSocket endpoint, ie, `"ws://example.com/socket"`,
1179
+ * `"wss://example.com"`
1180
+ * `"/socket"` (inherited host & protocol)
1181
+ * @param {SocketOptions} [opts] - Optional configuration
1182
+ */
1183
+ constructor(endPoint, opts = {}) {
1184
+ var _a, _b;
1185
+ this.stateChangeCallbacks = { open: [], close: [], error: [], message: [] };
1186
+ this.channels = [];
1187
+ this.sendBuffer = [];
1188
+ this.ref = 0;
1189
+ this.fallbackRef = null;
1190
+ this.timeout = opts.timeout || DEFAULT_TIMEOUT;
1191
+ this.transport = opts.transport || global.WebSocket || LongPoll;
1192
+ this.conn = void 0;
1193
+ this.primaryPassedHealthCheck = false;
1194
+ this.longPollFallbackMs = opts.longPollFallbackMs;
1195
+ this.fallbackTimer = null;
1196
+ let envSessionStorage = null;
1197
+ try {
1198
+ envSessionStorage = global && global.sessionStorage;
1199
+ } catch (e) {
1200
+ }
1201
+ this.sessionStore = opts.sessionStorage || envSessionStorage;
1202
+ this.establishedConnections = 0;
1203
+ this.defaultEncoder = serializer_default.encode.bind(serializer_default);
1204
+ this.defaultDecoder = serializer_default.decode.bind(serializer_default);
1205
+ this.closeWasClean = true;
1206
+ this.disconnecting = false;
1207
+ this.binaryType = opts.binaryType || "arraybuffer";
1208
+ this.connectClock = 1;
1209
+ this.pageHidden = false;
1210
+ this.encode = void 0;
1211
+ this.decode = void 0;
1212
+ if (this.transport !== LongPoll) {
1213
+ this.encode = opts.encode || this.defaultEncoder;
1214
+ this.decode = opts.decode || this.defaultDecoder;
1215
+ } else {
1216
+ this.encode = this.defaultEncoder;
1217
+ this.decode = this.defaultDecoder;
1218
+ }
1219
+ let awaitingConnectionOnPageShow = null;
1220
+ if (phxWindow && phxWindow.addEventListener) {
1221
+ phxWindow.addEventListener("pagehide", (_e) => {
1222
+ if (this.conn) {
1223
+ this.disconnect();
1224
+ awaitingConnectionOnPageShow = this.connectClock;
1225
+ }
1226
+ });
1227
+ phxWindow.addEventListener("pageshow", (_e) => {
1228
+ if (awaitingConnectionOnPageShow === this.connectClock) {
1229
+ awaitingConnectionOnPageShow = null;
1230
+ this.connect();
1231
+ }
1232
+ });
1233
+ phxWindow.addEventListener("visibilitychange", () => {
1234
+ if (document.visibilityState === "hidden") {
1235
+ this.pageHidden = true;
1236
+ } else {
1237
+ this.pageHidden = false;
1238
+ if (!this.isConnected() && !this.closeWasClean) {
1239
+ this.teardown(() => this.connect());
1240
+ }
1241
+ }
1242
+ });
1243
+ }
1244
+ this.heartbeatIntervalMs = opts.heartbeatIntervalMs || 3e4;
1245
+ this.autoSendHeartbeat = (_a = opts.autoSendHeartbeat) != null ? _a : true;
1246
+ this.heartbeatCallback = (_b = opts.heartbeatCallback) != null ? _b : () => {
1247
+ };
1248
+ this.rejoinAfterMs = (tries) => {
1249
+ if (opts.rejoinAfterMs) {
1250
+ return opts.rejoinAfterMs(tries);
1251
+ } else {
1252
+ return [1e3, 2e3, 5e3][tries - 1] || 1e4;
1253
+ }
1254
+ };
1255
+ this.reconnectAfterMs = (tries) => {
1256
+ if (opts.reconnectAfterMs) {
1257
+ return opts.reconnectAfterMs(tries);
1258
+ } else {
1259
+ return [10, 50, 100, 150, 200, 250, 500, 1e3, 2e3][tries - 1] || 5e3;
1260
+ }
1261
+ };
1262
+ this.logger = opts.logger || null;
1263
+ if (!this.logger && opts.debug) {
1264
+ this.logger = (kind, msg, data) => {
1265
+ console.log(`${kind}: ${msg}`, data);
1266
+ };
1267
+ }
1268
+ this.longpollerTimeout = opts.longpollerTimeout || 2e4;
1269
+ this.params = closure(opts.params || {});
1270
+ this.endPoint = `${endPoint}/${TRANSPORTS.websocket}`;
1271
+ this.vsn = opts.vsn || DEFAULT_VSN;
1272
+ this.heartbeatTimeoutTimer = null;
1273
+ this.heartbeatTimer = null;
1274
+ this.heartbeatSentAt = null;
1275
+ this.pendingHeartbeatRef = null;
1276
+ this.reconnectTimer = new Timer(() => {
1277
+ if (this.pageHidden) {
1278
+ this.log("Not reconnecting as page is hidden!");
1279
+ this.teardown();
1280
+ return;
1281
+ }
1282
+ this.teardown(() => __async(this, null, function* () {
1283
+ if (opts.beforeReconnect) yield opts.beforeReconnect();
1284
+ this.connect();
1285
+ }));
1286
+ }, this.reconnectAfterMs);
1287
+ this.authToken = opts.authToken;
1288
+ }
1289
+ /**
1290
+ * Returns the LongPoll transport reference
1291
+ */
1292
+ getLongPollTransport() {
1293
+ return LongPoll;
1294
+ }
1295
+ /**
1296
+ * Disconnects and replaces the active transport
1297
+ *
1298
+ * @param {SocketTransport} newTransport - The new transport class to instantiate
1299
+ *
1300
+ */
1301
+ replaceTransport(newTransport) {
1302
+ this.connectClock++;
1303
+ this.closeWasClean = true;
1304
+ clearTimeout(this.fallbackTimer);
1305
+ this.reconnectTimer.reset();
1306
+ if (this.conn) {
1307
+ this.conn.close();
1308
+ this.conn = null;
1309
+ }
1310
+ this.transport = newTransport;
1311
+ }
1312
+ /**
1313
+ * Returns the socket protocol
1314
+ *
1315
+ * @returns {"wss" | "ws"}
1316
+ */
1317
+ protocol() {
1318
+ return location.protocol.match(/^https/) ? "wss" : "ws";
1319
+ }
1320
+ /**
1321
+ * The fully qualified socket url
1322
+ *
1323
+ * @returns {string}
1324
+ */
1325
+ endPointURL() {
1326
+ let uri = Ajax.appendParams(
1327
+ Ajax.appendParams(this.endPoint, this.params()),
1328
+ { vsn: this.vsn }
1329
+ );
1330
+ if (uri.charAt(0) !== "/") {
1331
+ return uri;
1332
+ }
1333
+ if (uri.charAt(1) === "/") {
1334
+ return `${this.protocol()}:${uri}`;
1335
+ }
1336
+ return `${this.protocol()}://${location.host}${uri}`;
1337
+ }
1338
+ /**
1339
+ * Disconnects the socket
1340
+ *
1341
+ * See https://developer.mozilla.org/en-US/docs/Web/API/CloseEvent#Status_codes for valid status codes.
1342
+ *
1343
+ * @param {() => void} [callback] - Optional callback which is called after socket is disconnected.
1344
+ * @param {number} [code] - A status code for disconnection (Optional).
1345
+ * @param {string} [reason] - A textual description of the reason to disconnect. (Optional)
1346
+ */
1347
+ disconnect(callback, code, reason) {
1348
+ this.connectClock++;
1349
+ this.disconnecting = true;
1350
+ this.closeWasClean = true;
1351
+ clearTimeout(this.fallbackTimer);
1352
+ this.reconnectTimer.reset();
1353
+ this.teardown(() => {
1354
+ this.disconnecting = false;
1355
+ callback && callback();
1356
+ }, code, reason);
1357
+ }
1358
+ /**
1359
+ * @param {Params} [params] - [DEPRECATED] The params to send when connecting, for example `{user_id: userToken}`
1360
+ *
1361
+ * Passing params to connect is deprecated; pass them in the Socket constructor instead:
1362
+ * `new Socket("/socket", {params: {user_id: userToken}})`.
1363
+ */
1364
+ connect(params) {
1365
+ if (params) {
1366
+ console && console.log("passing params to connect is deprecated. Instead pass :params to the Socket constructor");
1367
+ this.params = closure(params);
1368
+ }
1369
+ if (this.conn && !this.disconnecting) {
1370
+ return;
1371
+ }
1372
+ if (this.longPollFallbackMs && this.transport !== LongPoll) {
1373
+ this.connectWithFallback(LongPoll, this.longPollFallbackMs);
1374
+ } else {
1375
+ this.transportConnect();
1376
+ }
1377
+ }
1378
+ /**
1379
+ * Logs the message. Override `this.logger` for specialized logging. noops by default
1380
+ * @param {string} kind
1381
+ * @param {string} msg
1382
+ * @param {Object} data
1383
+ */
1384
+ log(kind, msg, data) {
1385
+ this.logger && this.logger(kind, msg, data);
1386
+ }
1387
+ /**
1388
+ * Returns true if a logger has been set on this socket.
1389
+ */
1390
+ hasLogger() {
1391
+ return this.logger !== null;
1392
+ }
1393
+ /**
1394
+ * Registers callbacks for connection open events
1395
+ *
1396
+ * @example socket.onOpen(function(){ console.info("the socket was opened") })
1397
+ *
1398
+ * @param {SocketOnOpen} callback
1399
+ */
1400
+ onOpen(callback) {
1401
+ let ref = this.makeRef();
1402
+ this.stateChangeCallbacks.open.push([ref, callback]);
1403
+ return ref;
1404
+ }
1405
+ /**
1406
+ * Registers callbacks for connection close events
1407
+ * @param {SocketOnClose} callback
1408
+ * @returns {string}
1409
+ */
1410
+ onClose(callback) {
1411
+ let ref = this.makeRef();
1412
+ this.stateChangeCallbacks.close.push([ref, callback]);
1413
+ return ref;
1414
+ }
1415
+ /**
1416
+ * Registers callbacks for connection error events
1417
+ *
1418
+ * @example socket.onError(function(error){ alert("An error occurred") })
1419
+ *
1420
+ * @param {SocketOnError} callback
1421
+ * @returns {string}
1422
+ */
1423
+ onError(callback) {
1424
+ let ref = this.makeRef();
1425
+ this.stateChangeCallbacks.error.push([ref, callback]);
1426
+ return ref;
1427
+ }
1428
+ /**
1429
+ * Registers callbacks for connection message events
1430
+ * @param {SocketOnMessage} callback
1431
+ * @returns {string}
1432
+ */
1433
+ onMessage(callback) {
1434
+ let ref = this.makeRef();
1435
+ this.stateChangeCallbacks.message.push([ref, callback]);
1436
+ return ref;
1437
+ }
1438
+ /**
1439
+ * Sets a callback that receives lifecycle events for internal heartbeat messages.
1440
+ * Useful for instrumenting connection health (e.g. sent/ok/timeout/disconnected).
1441
+ * @param {HeartbeatCallback} callback
1442
+ */
1443
+ onHeartbeat(callback) {
1444
+ this.heartbeatCallback = callback;
1445
+ }
1446
+ /**
1447
+ * Pings the server and invokes the callback with the RTT in milliseconds
1448
+ * @param {(timeDelta: number) => void} callback
1449
+ *
1450
+ * Returns true if the ping was pushed or false if unable to be pushed.
1451
+ */
1452
+ ping(callback) {
1453
+ if (!this.isConnected()) {
1454
+ return false;
1455
+ }
1456
+ let ref = this.makeRef();
1457
+ let startTime = Date.now();
1458
+ this.push({ topic: "phoenix", event: "heartbeat", payload: {}, ref });
1459
+ let onMsgRef = this.onMessage((msg) => {
1460
+ if (msg.ref === ref) {
1461
+ this.off([onMsgRef]);
1462
+ callback(Date.now() - startTime);
1463
+ }
1464
+ });
1465
+ return true;
1466
+ }
1467
+ /**
1468
+ * @private
1469
+ *
1470
+ * @param {Function}
1471
+ */
1472
+ transportName(transport) {
1473
+ switch (transport) {
1474
+ case LongPoll:
1475
+ return "LongPoll";
1476
+ default:
1477
+ return transport.name;
1478
+ }
1479
+ }
1480
+ /**
1481
+ * @private
1482
+ */
1483
+ transportConnect() {
1484
+ this.connectClock++;
1485
+ this.closeWasClean = false;
1486
+ let protocols = void 0;
1487
+ if (this.authToken) {
1488
+ protocols = ["phoenix", `${AUTH_TOKEN_PREFIX}${btoa(this.authToken).replace(/=/g, "")}`];
1489
+ }
1490
+ this.conn = new this.transport(this.endPointURL(), protocols);
1491
+ this.conn.binaryType = this.binaryType;
1492
+ this.conn.timeout = this.longpollerTimeout;
1493
+ this.conn.onopen = () => this.onConnOpen();
1494
+ this.conn.onerror = (error) => this.onConnError(error);
1495
+ this.conn.onmessage = (event) => this.onConnMessage(event);
1496
+ this.conn.onclose = (event) => this.onConnClose(event);
1497
+ }
1498
+ getSession(key) {
1499
+ return this.sessionStore && this.sessionStore.getItem(key);
1500
+ }
1501
+ storeSession(key, val) {
1502
+ this.sessionStore && this.sessionStore.setItem(key, val);
1503
+ }
1504
+ connectWithFallback(fallbackTransport, fallbackThreshold = 2500) {
1505
+ clearTimeout(this.fallbackTimer);
1506
+ let established = false;
1507
+ let primaryTransport = true;
1508
+ let openRef, errorRef;
1509
+ let fallbackTransportName = this.transportName(fallbackTransport);
1510
+ let fallback = (reason) => {
1511
+ this.log("transport", `falling back to ${fallbackTransportName}...`, reason);
1512
+ this.off([openRef, errorRef]);
1513
+ primaryTransport = false;
1514
+ this.replaceTransport(fallbackTransport);
1515
+ this.transportConnect();
1516
+ };
1517
+ if (this.getSession(`phx:fallback:${fallbackTransportName}`)) {
1518
+ return fallback("memorized");
1519
+ }
1520
+ this.fallbackTimer = setTimeout(fallback, fallbackThreshold);
1521
+ errorRef = this.onError((reason) => {
1522
+ this.log("transport", "error", reason);
1523
+ if (primaryTransport && !established) {
1524
+ clearTimeout(this.fallbackTimer);
1525
+ fallback(reason);
1526
+ }
1527
+ });
1528
+ if (this.fallbackRef) {
1529
+ this.off([this.fallbackRef]);
1530
+ }
1531
+ this.fallbackRef = this.onOpen(() => {
1532
+ established = true;
1533
+ if (!primaryTransport) {
1534
+ let fallbackTransportName2 = this.transportName(fallbackTransport);
1535
+ if (!this.primaryPassedHealthCheck) {
1536
+ this.storeSession(`phx:fallback:${fallbackTransportName2}`, "true");
1537
+ }
1538
+ return this.log("transport", `established ${fallbackTransportName2} fallback`);
1539
+ }
1540
+ clearTimeout(this.fallbackTimer);
1541
+ this.fallbackTimer = setTimeout(fallback, fallbackThreshold);
1542
+ this.ping((rtt) => {
1543
+ this.log("transport", "connected to primary after", rtt);
1544
+ this.primaryPassedHealthCheck = true;
1545
+ clearTimeout(this.fallbackTimer);
1546
+ });
1547
+ });
1548
+ this.transportConnect();
1549
+ }
1550
+ clearHeartbeats() {
1551
+ clearTimeout(this.heartbeatTimer);
1552
+ clearTimeout(this.heartbeatTimeoutTimer);
1553
+ }
1554
+ onConnOpen() {
1555
+ if (this.hasLogger()) this.log("transport", `connected to ${this.endPointURL()}`);
1556
+ this.closeWasClean = false;
1557
+ this.disconnecting = false;
1558
+ this.establishedConnections++;
1559
+ this.flushSendBuffer();
1560
+ this.reconnectTimer.reset();
1561
+ if (this.autoSendHeartbeat) {
1562
+ this.resetHeartbeat();
1563
+ }
1564
+ this.triggerStateCallbacks("open");
1565
+ }
1566
+ /**
1567
+ * @private
1568
+ */
1569
+ heartbeatTimeout() {
1570
+ if (this.pendingHeartbeatRef) {
1571
+ this.pendingHeartbeatRef = null;
1572
+ this.heartbeatSentAt = null;
1573
+ if (this.hasLogger()) {
1574
+ this.log("transport", "heartbeat timeout. Attempting to re-establish connection");
1575
+ }
1576
+ try {
1577
+ this.heartbeatCallback("timeout");
1578
+ } catch (e) {
1579
+ this.log("error", "error in heartbeat callback", e);
1580
+ }
1581
+ this.triggerChanError(new Error("heartbeat timeout"));
1582
+ this.closeWasClean = false;
1583
+ this.teardown(() => this.reconnectTimer.scheduleTimeout(), WS_CLOSE_NORMAL, "heartbeat timeout");
1584
+ }
1585
+ }
1586
+ resetHeartbeat() {
1587
+ if (this.conn && this.conn.skipHeartbeat) {
1588
+ return;
1589
+ }
1590
+ this.pendingHeartbeatRef = null;
1591
+ this.clearHeartbeats();
1592
+ this.heartbeatTimer = setTimeout(() => this.sendHeartbeat(), this.heartbeatIntervalMs);
1593
+ }
1594
+ teardown(callback, code, reason) {
1595
+ if (!this.conn) {
1596
+ return callback && callback();
1597
+ }
1598
+ const connToClose = this.conn;
1599
+ this.waitForBufferDone(connToClose, () => {
1600
+ if (code) {
1601
+ connToClose.close(code, reason || "");
1602
+ } else {
1603
+ connToClose.close();
1604
+ }
1605
+ this.waitForSocketClosed(connToClose, () => {
1606
+ if (this.conn === connToClose) {
1607
+ this.conn.onopen = function() {
1608
+ };
1609
+ this.conn.onerror = function() {
1610
+ };
1611
+ this.conn.onmessage = function() {
1612
+ };
1613
+ this.conn.onclose = function() {
1614
+ };
1615
+ this.conn = null;
1616
+ }
1617
+ callback && callback();
1618
+ });
1619
+ });
1620
+ }
1621
+ waitForBufferDone(conn, callback, tries = 1) {
1622
+ if (tries === 5 || !conn.bufferedAmount) {
1623
+ callback();
1624
+ return;
1625
+ }
1626
+ setTimeout(() => {
1627
+ this.waitForBufferDone(conn, callback, tries + 1);
1628
+ }, 150 * tries);
1629
+ }
1630
+ waitForSocketClosed(conn, callback, tries = 1) {
1631
+ if (tries === 5 || conn.readyState === SOCKET_STATES.closed) {
1632
+ callback();
1633
+ return;
1634
+ }
1635
+ setTimeout(() => {
1636
+ this.waitForSocketClosed(conn, callback, tries + 1);
1637
+ }, 150 * tries);
1638
+ }
1639
+ /**
1640
+ * @param {CloseEvent} event
1641
+ */
1642
+ onConnClose(event) {
1643
+ if (this.conn) this.conn.onclose = () => {
1644
+ };
1645
+ if (this.hasLogger()) this.log("transport", "close", event);
1646
+ this.triggerChanError(event);
1647
+ this.clearHeartbeats();
1648
+ if (!this.closeWasClean) {
1649
+ this.reconnectTimer.scheduleTimeout();
1650
+ }
1651
+ this.triggerStateCallbacks("close", event);
1652
+ }
1653
+ /**
1654
+ * @private
1655
+ * @param {Event} error
1656
+ */
1657
+ onConnError(error) {
1658
+ if (this.hasLogger()) this.log("transport", "error", error);
1659
+ let transportBefore = this.transport;
1660
+ let establishedBefore = this.establishedConnections;
1661
+ this.triggerStateCallbacks("error", error, transportBefore, establishedBefore);
1662
+ if (transportBefore === this.transport || establishedBefore > 0) {
1663
+ this.triggerChanError(error);
1664
+ }
1665
+ }
1666
+ /**
1667
+ * @private
1668
+ * @param {unknown} [reason] underlying close/error event forwarded to channel error listeners
1669
+ */
1670
+ triggerChanError(reason) {
1671
+ this.channels.forEach((channel) => {
1672
+ if (!(channel.isErrored() || channel.isLeaving() || channel.isClosed())) {
1673
+ channel.trigger(CHANNEL_EVENTS.error, reason);
1674
+ }
1675
+ });
1676
+ }
1677
+ /**
1678
+ * @returns {string}
1679
+ */
1680
+ connectionState() {
1681
+ switch (this.conn && this.conn.readyState) {
1682
+ case SOCKET_STATES.connecting:
1683
+ return "connecting";
1684
+ case SOCKET_STATES.open:
1685
+ return "open";
1686
+ case SOCKET_STATES.closing:
1687
+ return "closing";
1688
+ default:
1689
+ return "closed";
1690
+ }
1691
+ }
1692
+ /**
1693
+ * @returns {boolean}
1694
+ */
1695
+ isConnected() {
1696
+ return this.connectionState() === "open";
1697
+ }
1698
+ /**
1699
+ *
1700
+ * @param {Channel} channel
1701
+ */
1702
+ remove(channel) {
1703
+ this.off(channel.stateChangeRefs);
1704
+ this.channels = this.channels.filter((c) => c !== channel);
1705
+ }
1706
+ /**
1707
+ * Removes `onOpen`, `onClose`, `onError,` and `onMessage` registrations.
1708
+ *
1709
+ * @param {string[]} refs - list of refs returned by calls to
1710
+ * `onOpen`, `onClose`, `onError,` and `onMessage`
1711
+ */
1712
+ off(refs) {
1713
+ for (let key in this.stateChangeCallbacks) {
1714
+ this.stateChangeCallbacks[key] = this.stateChangeCallbacks[key].filter(([ref]) => {
1715
+ return refs.indexOf(ref) === -1;
1716
+ });
1717
+ }
1718
+ }
1719
+ /**
1720
+ * Initiates a new channel for the given topic
1721
+ *
1722
+ * @param {string} topic
1723
+ * @param {Params | (() => Params)} [chanParams]- Parameters for the channel
1724
+ * @returns {Channel}
1725
+ */
1726
+ channel(topic, chanParams = {}) {
1727
+ let chan = new Channel(topic, chanParams, this);
1728
+ this.channels.push(chan);
1729
+ return chan;
1730
+ }
1731
+ /**
1732
+ * @param {Message<Record<string, any>>} data
1733
+ */
1734
+ push(data) {
1735
+ if (this.hasLogger()) {
1736
+ let { topic, event, payload, ref, join_ref } = data;
1737
+ this.log("push", `${topic} ${event} (${join_ref}, ${ref})`, payload);
1738
+ }
1739
+ if (this.isConnected()) {
1740
+ this.encode(data, (result) => this.conn.send(result));
1741
+ } else {
1742
+ this.sendBuffer.push(() => this.encode(data, (result) => this.conn.send(result)));
1743
+ }
1744
+ }
1745
+ /**
1746
+ * Return the next message ref, accounting for overflows
1747
+ * @returns {string}
1748
+ */
1749
+ makeRef() {
1750
+ let newRef = this.ref + 1;
1751
+ if (newRef === this.ref) {
1752
+ this.ref = 0;
1753
+ } else {
1754
+ this.ref = newRef;
1755
+ }
1756
+ return this.ref.toString();
1757
+ }
1758
+ sendHeartbeat() {
1759
+ if (!this.isConnected()) {
1760
+ try {
1761
+ this.heartbeatCallback("disconnected");
1762
+ } catch (e) {
1763
+ this.log("error", "error in heartbeat callback", e);
1764
+ }
1765
+ return;
1766
+ }
1767
+ if (this.pendingHeartbeatRef) {
1768
+ this.heartbeatTimeout();
1769
+ return;
1770
+ }
1771
+ this.pendingHeartbeatRef = this.makeRef();
1772
+ this.heartbeatSentAt = Date.now();
1773
+ this.push({ topic: "phoenix", event: "heartbeat", payload: {}, ref: this.pendingHeartbeatRef });
1774
+ try {
1775
+ this.heartbeatCallback("sent");
1776
+ } catch (e) {
1777
+ this.log("error", "error in heartbeat callback", e);
1778
+ }
1779
+ this.heartbeatTimeoutTimer = setTimeout(() => this.heartbeatTimeout(), this.heartbeatIntervalMs);
1780
+ }
1781
+ flushSendBuffer() {
1782
+ if (this.isConnected() && this.sendBuffer.length > 0) {
1783
+ this.sendBuffer.forEach((callback) => callback());
1784
+ this.sendBuffer = [];
1785
+ }
1786
+ }
1787
+ /**
1788
+ * @param {MessageEvent<any>} rawMessage
1789
+ */
1790
+ onConnMessage(rawMessage) {
1791
+ this.decode(rawMessage.data, (msg) => {
1792
+ let { topic, event, payload, ref, join_ref } = msg;
1793
+ if (ref && ref === this.pendingHeartbeatRef) {
1794
+ const latency = this.heartbeatSentAt ? Date.now() - this.heartbeatSentAt : void 0;
1795
+ this.clearHeartbeats();
1796
+ try {
1797
+ this.heartbeatCallback(payload.status === "ok" ? "ok" : "error", latency);
1798
+ } catch (e) {
1799
+ this.log("error", "error in heartbeat callback", e);
1800
+ }
1801
+ this.pendingHeartbeatRef = null;
1802
+ this.heartbeatSentAt = null;
1803
+ if (this.autoSendHeartbeat) {
1804
+ this.heartbeatTimer = setTimeout(() => this.sendHeartbeat(), this.heartbeatIntervalMs);
1805
+ }
1806
+ }
1807
+ if (this.hasLogger()) this.log("receive", `${payload.status || ""} ${topic} ${event} ${ref && "(" + ref + ")" || ""}`.trim(), payload);
1808
+ for (let i = 0; i < this.channels.length; i++) {
1809
+ const channel = this.channels[i];
1810
+ if (!channel.isMember(topic, event, payload, join_ref)) {
1811
+ continue;
1812
+ }
1813
+ channel.trigger(event, payload, ref, join_ref);
1814
+ }
1815
+ this.triggerStateCallbacks("message", msg);
1816
+ });
1817
+ }
1818
+ /**
1819
+ * @private
1820
+ * @template {keyof SocketStateChangeCallbacks} K
1821
+ * @param {K} event
1822
+ * @param {...Parameters<SocketStateChangeCallbacks[K][number][1]>} args
1823
+ * @returns {void}
1824
+ */
1825
+ triggerStateCallbacks(event, ...args) {
1826
+ try {
1827
+ this.stateChangeCallbacks[event].forEach(([_, callback]) => {
1828
+ try {
1829
+ callback(...args);
1830
+ } catch (e) {
1831
+ this.log("error", `error in ${event} callback`, e);
1832
+ }
1833
+ });
1834
+ } catch (e) {
1835
+ this.log("error", `error triggering ${event} callbacks`, e);
1836
+ }
1837
+ }
1838
+ leaveOpenTopic(topic) {
1839
+ let dupChannel = this.channels.find((c) => c.topic === topic && (c.isJoined() || c.isJoining()));
1840
+ if (dupChannel) {
1841
+ if (this.hasLogger()) this.log("transport", `leaving duplicate topic "${topic}"`);
1842
+ dupChannel.leave();
1843
+ }
1844
+ }
1845
+ };
1846
+ return __toCommonJS(phoenix_exports);
1847
+ })();