Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
72cc253
feat(realtime): add submodule for phoenix, change deps
GuzekAlan Nov 27, 2025
f4bda92
fix(realtime): add temporary types since types/phoenix was removed
GuzekAlan Nov 27, 2025
f172209
feat(realtime): use phoenix consts
GuzekAlan Nov 27, 2025
4e60857
fix(realtime): rename vitest extension
GuzekAlan Nov 27, 2025
c9f9573
fix(realtime): cannot import form path
GuzekAlan Nov 27, 2025
3cb23ea
feat(realtime): add phoenixAdapter with basic stuff
GuzekAlan Nov 27, 2025
ec16365
fix(realtime): add path to compile project
GuzekAlan Nov 28, 2025
28b8de8
feat(realtime): make presence use phoenixAdapter
GuzekAlan Nov 28, 2025
b0f12e0
feat(realtime): use github path instead of git submodules
GuzekAlan Dec 1, 2025
2c100ec
fix(realtime): update phoenix github dependency
GuzekAlan Dec 2, 2025
e7b6c03
fix(realtime): properly export constatns with types form phoenix
GuzekAlan Dec 2, 2025
aa862a0
fix(realtime): use proper types in phoenixAdapter, fix package-lock file
GuzekAlan Dec 2, 2025
f9693b5
fix(realtime): small changes
GuzekAlan Dec 2, 2025
310418a
fix(realtime): add and remove comments
GuzekAlan Dec 2, 2025
b7c6f91
fix(realtime): use proper url string
GuzekAlan Dec 2, 2025
1b1944f
fix(realtime): better imports, fix constatns
GuzekAlan Dec 3, 2025
af1006b
fix(realtime): point to branch, fix commnet place
GuzekAlan Dec 3, 2025
07d2bd0
fix(realtime): change config file extension
GuzekAlan Dec 3, 2025
161a6fb
feat(realtime): update phoenix dep, remove ts-ignore
GuzekAlan Dec 3, 2025
792c4cb
fix(realtime): fix config extension
GuzekAlan Dec 3, 2025
618fb38
fix(realtime): generic helper function in phoenixAdapter
GuzekAlan Dec 3, 2025
4c84e34
feat(realtime): update dep to supabase/phoenix
GuzekAlan Dec 3, 2025
cec4529
fix(realtime): remove unuse function
GuzekAlan Dec 4, 2025
308681f
feat(realtime): better presence translation code, split into files
GuzekAlan Dec 4, 2025
2512cc8
fix(realtime): fix cloneDeep function
GuzekAlan Dec 4, 2025
6350a12
fix(realtime): change privarte to internal in docs
GuzekAlan Dec 4, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,098 changes: 542 additions & 556 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion packages/core/realtime-js/example/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/core/realtime-js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"test:ci": "vitest run --coverage"
},
"dependencies": {
"@types/phoenix": "^1.6.6",
"phoenix": "git://github.com/supabase/phoenix.git",
"@types/ws": "^8.18.1",
"tslib": "2.8.1",
"ws": "^8.18.2"
Expand Down
6 changes: 5 additions & 1 deletion packages/core/realtime-js/src/RealtimeChannel.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { CHANNEL_EVENTS, CHANNEL_STATES, MAX_PUSH_BUFFER_SIZE } from './lib/constants'
import type { ChannelState } from './lib/constants'
import Push from './lib/push'
import type RealtimeClient from './RealtimeClient'
import Timer from './lib/timer'
Expand All @@ -10,6 +11,7 @@ import type {
} from './RealtimePresence'
import * as Transformers from './lib/transformers'
import { httpEndpointURL } from './lib/transformers'
import ChannelAdapter from './phoenix/channelAdapter'

type ReplayOption = {
since: number
Expand Down Expand Up @@ -171,7 +173,7 @@ export default class RealtimeChannel {
}[]
} = {}
timeout: number
state: CHANNEL_STATES = CHANNEL_STATES.closed
state: ChannelState = CHANNEL_STATES.closed
joinedOnce = false
joinPush: Push
rejoinTimer: Timer
Expand All @@ -180,6 +182,7 @@ export default class RealtimeChannel {
broadcastEndpointURL: string
subTopic: string
private: boolean
channelAdapter: ChannelAdapter

/**
* Creates a channel that can broadcast messages, sync presence, and listen to Postgres changes.
Expand Down Expand Up @@ -256,6 +259,7 @@ export default class RealtimeChannel {
this._trigger(this._replyEventName(ref), payload)
})

this.channelAdapter = new ChannelAdapter(this.socket.socketAdapter, this.subTopic, this.params)
this.presence = new RealtimePresence(this)

this.broadcastEndpointURL = httpEndpointURL(this.socket.endPoint)
Expand Down
15 changes: 9 additions & 6 deletions packages/core/realtime-js/src/RealtimeClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import Timer from './lib/timer'
import { httpEndpointURL } from './lib/transformers'
import RealtimeChannel from './RealtimeChannel'
import type { RealtimeChannelOptions } from './RealtimeChannel'
import SocketAdapter from './phoenix/socketAdapter'

type Fetch = typeof fetch

Expand Down Expand Up @@ -100,6 +101,7 @@ const WORKER_SCRIPT = `
});`

export default class RealtimeClient {
socketAdapter: SocketAdapter
accessTokenValue: string | null = null
apiKey: string | null = null
channels: RealtimeChannel[] = new Array()
Expand Down Expand Up @@ -187,6 +189,7 @@ export default class RealtimeClient {
this._initializeOptions(options)
this._setupReconnectionTimer()
this.fetch = this._resolveFetch(options?.fetch)
this.socketAdapter = new SocketAdapter(endPoint, options)
}

/**
Expand Down Expand Up @@ -334,24 +337,24 @@ export default class RealtimeClient {
/**
* Returns the current state of the socket.
*/
connectionState(): CONNECTION_STATE {
connectionState() {
switch (this.conn && this.conn.readyState) {
case SOCKET_STATES.connecting:
return CONNECTION_STATE.Connecting
return CONNECTION_STATE.connecting
case SOCKET_STATES.open:
return CONNECTION_STATE.Open
return CONNECTION_STATE.open
case SOCKET_STATES.closing:
return CONNECTION_STATE.Closing
return CONNECTION_STATE.closing
default:
return CONNECTION_STATE.Closed
return CONNECTION_STATE.closed
}
}

/**
* Returns `true` is the connection is open.
*/
isConnected(): boolean {
return this.connectionState() === CONNECTION_STATE.Open
return this.connectionState() === CONNECTION_STATE.open
}

/**
Expand Down
Loading