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