@supabase/realtime-js 2.71.2-canary.7 → 2.72.1-canary.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 +96 -29
- package/dist/main/lib/constants.d.ts +2 -2
- package/dist/main/lib/version.d.ts +1 -1
- package/dist/main/lib/version.d.ts.map +1 -1
- package/dist/main/lib/version.js +7 -1
- package/dist/main/lib/version.js.map +1 -1
- package/dist/module/lib/constants.d.ts +2 -2
- package/dist/module/lib/version.d.ts +1 -1
- package/dist/module/lib/version.d.ts.map +1 -1
- package/dist/module/lib/version.js +7 -1
- package/dist/module/lib/version.js.map +1 -1
- package/package.json +3 -5
- package/src/lib/version.ts +7 -1
package/README.md
CHANGED
|
@@ -50,7 +50,7 @@ import { RealtimeClient } from '@supabase/realtime-js'
|
|
|
50
50
|
|
|
51
51
|
const client = new RealtimeClient(REALTIME_URL, {
|
|
52
52
|
params: {
|
|
53
|
-
apikey: API_KEY
|
|
53
|
+
apikey: API_KEY,
|
|
54
54
|
},
|
|
55
55
|
})
|
|
56
56
|
|
|
@@ -90,9 +90,7 @@ Your client can send and receive messages based on the `event`.
|
|
|
90
90
|
|
|
91
91
|
const channel = client.channel('broadcast-test', { broadcast: { ack: false, self: false } })
|
|
92
92
|
|
|
93
|
-
channel.on('broadcast', { event: 'some-event' }, (payload) =>
|
|
94
|
-
console.log(payload)
|
|
95
|
-
)
|
|
93
|
+
channel.on('broadcast', { event: 'some-event' }, (payload) => console.log(payload))
|
|
96
94
|
|
|
97
95
|
channel.subscribe(async (status) => {
|
|
98
96
|
if (status === 'SUBSCRIBED') {
|
|
@@ -119,16 +117,13 @@ Your client can track and sync state that's stored in the channel.
|
|
|
119
117
|
```js
|
|
120
118
|
// Setup...
|
|
121
119
|
|
|
122
|
-
const channel = client.channel(
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
)
|
|
120
|
+
const channel = client.channel('presence-test', {
|
|
121
|
+
config: {
|
|
122
|
+
presence: {
|
|
123
|
+
key: '',
|
|
124
|
+
},
|
|
125
|
+
},
|
|
126
|
+
})
|
|
132
127
|
|
|
133
128
|
channel.on('presence', { event: 'sync' }, () => {
|
|
134
129
|
console.log('Online users: ', channel.presenceState())
|
|
@@ -144,7 +139,7 @@ channel.on('presence', { event: 'leave' }, ({ leftPresences }) => {
|
|
|
144
139
|
|
|
145
140
|
channel.subscribe(async (status) => {
|
|
146
141
|
if (status === 'SUBSCRIBED') {
|
|
147
|
-
const status = await channel.track({
|
|
142
|
+
const status = await channel.track({ user_id: 1 })
|
|
148
143
|
console.log(status)
|
|
149
144
|
}
|
|
150
145
|
})
|
|
@@ -163,13 +158,21 @@ channel.on('postgres_changes', { event: '*', schema: 'public' }, (payload) => {
|
|
|
163
158
|
console.log('All changes in public schema: ', payload)
|
|
164
159
|
})
|
|
165
160
|
|
|
166
|
-
channel.on(
|
|
167
|
-
|
|
168
|
-
}
|
|
161
|
+
channel.on(
|
|
162
|
+
'postgres_changes',
|
|
163
|
+
{ event: 'INSERT', schema: 'public', table: 'messages' },
|
|
164
|
+
(payload) => {
|
|
165
|
+
console.log('All inserts in messages table: ', payload)
|
|
166
|
+
}
|
|
167
|
+
)
|
|
169
168
|
|
|
170
|
-
channel.on(
|
|
171
|
-
|
|
172
|
-
}
|
|
169
|
+
channel.on(
|
|
170
|
+
'postgres_changes',
|
|
171
|
+
{ event: 'UPDATE', schema: 'public', table: 'users', filter: 'username=eq.Realtime' },
|
|
172
|
+
(payload) => {
|
|
173
|
+
console.log('All updates on users table when username is Realtime: ', payload)
|
|
174
|
+
}
|
|
175
|
+
)
|
|
173
176
|
|
|
174
177
|
channel.subscribe(async (status) => {
|
|
175
178
|
if (status === 'SUBSCRIBED') {
|
|
@@ -199,25 +202,89 @@ It is highly recommended that you clean up your channels after you're done with
|
|
|
199
202
|
|
|
200
203
|
const channel = client.channel('some-channel-to-remove')
|
|
201
204
|
|
|
202
|
-
channel.
|
|
203
|
-
|
|
205
|
+
channel.unsubscribe()
|
|
204
206
|
client.removeChannel(channel)
|
|
205
207
|
```
|
|
206
208
|
|
|
207
|
-
- Remove all channels
|
|
209
|
+
- Remove all channels and close the connection
|
|
208
210
|
|
|
209
211
|
```js
|
|
210
212
|
// Setup...
|
|
211
213
|
|
|
212
|
-
|
|
213
|
-
|
|
214
|
+
client.removeAllChannels()
|
|
215
|
+
client.disconnect()
|
|
216
|
+
```
|
|
214
217
|
|
|
215
|
-
|
|
216
|
-
channel2.subscribe()
|
|
218
|
+
## Development
|
|
217
219
|
|
|
218
|
-
|
|
220
|
+
This package is part of the [Supabase JavaScript monorepo](https://github.com/supabase/supabase-js-libs). To work on this package:
|
|
221
|
+
|
|
222
|
+
### Building
|
|
223
|
+
|
|
224
|
+
```bash
|
|
225
|
+
# Complete build (from monorepo root)
|
|
226
|
+
npx nx build realtime-js
|
|
227
|
+
|
|
228
|
+
# Build with watch mode for development
|
|
229
|
+
npx nx build realtime-js --watch
|
|
230
|
+
|
|
231
|
+
# Individual build targets
|
|
232
|
+
npx nx build:main realtime-js # CommonJS build (dist/main/)
|
|
233
|
+
npx nx build:module realtime-js # ES Modules build (dist/module/)
|
|
234
|
+
|
|
235
|
+
# Other useful commands
|
|
236
|
+
npx nx clean realtime-js # Clean build artifacts
|
|
237
|
+
npx nx format realtime-js # Format code with Prettier
|
|
238
|
+
npx nx lint realtime-js # Run ESLint
|
|
239
|
+
npx nx typecheck realtime-js # TypeScript type checking
|
|
219
240
|
```
|
|
220
241
|
|
|
242
|
+
#### Build Outputs
|
|
243
|
+
|
|
244
|
+
- **CommonJS (`dist/main/`)** - For Node.js environments
|
|
245
|
+
- **ES Modules (`dist/module/`)** - For modern bundlers (Webpack, Vite, Rollup)
|
|
246
|
+
- **TypeScript definitions (`dist/module/index.d.ts`)** - Type definitions for TypeScript projects
|
|
247
|
+
|
|
248
|
+
Note: Unlike some other packages, realtime-js doesn't include a UMD build since it's primarily used in Node.js or bundled applications.
|
|
249
|
+
|
|
250
|
+
#### Validating Package Exports
|
|
251
|
+
|
|
252
|
+
```bash
|
|
253
|
+
# Check if package exports are correctly configured
|
|
254
|
+
npx nx check-exports realtime-js
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
This command uses ["Are the types wrong?"](https://github.com/arethetypeswrong/arethetypeswrong.github.io) to verify that the package exports work correctly in different environments. Run this before publishing to ensure your package can be imported correctly by all consumers.
|
|
258
|
+
|
|
259
|
+
### Testing
|
|
260
|
+
|
|
261
|
+
**No Docker or Supabase instance required!** The realtime-js tests use mocked WebSocket connections, so they're completely self-contained.
|
|
262
|
+
|
|
263
|
+
```bash
|
|
264
|
+
# Run unit tests (from monorepo root)
|
|
265
|
+
npx nx test realtime-js
|
|
266
|
+
|
|
267
|
+
# Run tests with coverage report
|
|
268
|
+
npx nx test:coverage realtime-js
|
|
269
|
+
|
|
270
|
+
# Run tests in watch mode during development
|
|
271
|
+
npx nx test:watch realtime-js
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
#### Test Scripts Explained
|
|
275
|
+
|
|
276
|
+
- **test** - Runs all unit tests once using Vitest
|
|
277
|
+
- **test:coverage** - Runs tests and generates coverage report with terminal output
|
|
278
|
+
- **test:watch** - Runs tests in interactive watch mode for development
|
|
279
|
+
|
|
280
|
+
The tests mock WebSocket connections using `mock-socket`, so you can run them anytime without any external dependencies.
|
|
281
|
+
|
|
282
|
+
### Contributing
|
|
283
|
+
|
|
284
|
+
We welcome contributions! Please see our [Contributing Guide](../../../CONTRIBUTING.md) for details on how to get started.
|
|
285
|
+
|
|
286
|
+
For major changes or if you're unsure about something, please open an issue first to discuss your proposed changes.
|
|
287
|
+
|
|
221
288
|
## Credits
|
|
222
289
|
|
|
223
290
|
This repo draws heavily from [phoenix-js](https://github.com/phoenixframework/phoenix/tree/master/assets/js/phoenix).
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export declare const DEFAULT_VERSION = "realtime-js/
|
|
1
|
+
export declare const DEFAULT_VERSION = "realtime-js/2.72.1-canary.2";
|
|
2
2
|
export declare const VSN: string;
|
|
3
|
-
export declare const VERSION = "
|
|
3
|
+
export declare const VERSION = "2.72.1-canary.2";
|
|
4
4
|
export declare const DEFAULT_TIMEOUT = 10000;
|
|
5
5
|
export declare const WS_CLOSE_NORMAL = 1000;
|
|
6
6
|
export declare const MAX_PUSH_BUFFER_SIZE = 100;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const version = "
|
|
1
|
+
export declare const version = "2.72.1-canary.2";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../../src/lib/version.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../../src/lib/version.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,OAAO,oBAAoB,CAAA"}
|
package/dist/main/lib/version.js
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.version = void 0;
|
|
4
|
-
|
|
4
|
+
// Generated automatically during releases by scripts/update-version-files.js
|
|
5
|
+
// This file provides runtime access to the package version for:
|
|
6
|
+
// - HTTP request headers (e.g., X-Client-Info header for API requests)
|
|
7
|
+
// - Debugging and support (identifying which version is running)
|
|
8
|
+
// - Telemetry and logging (version reporting in errors/analytics)
|
|
9
|
+
// - Ensuring build artifacts match the published package version
|
|
10
|
+
exports.version = '2.72.1-canary.2';
|
|
5
11
|
//# sourceMappingURL=version.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../../src/lib/version.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../../src/lib/version.ts"],"names":[],"mappings":";;;AAAA,6EAA6E;AAC7E,gEAAgE;AAChE,uEAAuE;AACvE,iEAAiE;AACjE,kEAAkE;AAClE,iEAAiE;AACpD,QAAA,OAAO,GAAG,iBAAiB,CAAA"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export declare const DEFAULT_VERSION = "realtime-js/
|
|
1
|
+
export declare const DEFAULT_VERSION = "realtime-js/2.72.1-canary.2";
|
|
2
2
|
export declare const VSN: string;
|
|
3
|
-
export declare const VERSION = "
|
|
3
|
+
export declare const VERSION = "2.72.1-canary.2";
|
|
4
4
|
export declare const DEFAULT_TIMEOUT = 10000;
|
|
5
5
|
export declare const WS_CLOSE_NORMAL = 1000;
|
|
6
6
|
export declare const MAX_PUSH_BUFFER_SIZE = 100;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const version = "
|
|
1
|
+
export declare const version = "2.72.1-canary.2";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../../src/lib/version.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../../src/lib/version.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,OAAO,oBAAoB,CAAA"}
|
|
@@ -1,2 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
// Generated automatically during releases by scripts/update-version-files.js
|
|
2
|
+
// This file provides runtime access to the package version for:
|
|
3
|
+
// - HTTP request headers (e.g., X-Client-Info header for API requests)
|
|
4
|
+
// - Debugging and support (identifying which version is running)
|
|
5
|
+
// - Telemetry and logging (version reporting in errors/analytics)
|
|
6
|
+
// - Ensuring build artifacts match the published package version
|
|
7
|
+
export const version = '2.72.1-canary.2';
|
|
2
8
|
//# sourceMappingURL=version.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../../src/lib/version.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,OAAO,GAAG,iBAAiB,CAAA"}
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../../src/lib/version.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,gEAAgE;AAChE,uEAAuE;AACvE,iEAAiE;AACjE,kEAAkE;AAClE,iEAAiE;AACjE,MAAM,CAAC,MAAM,OAAO,GAAG,iBAAiB,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@supabase/realtime-js",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.72.1-canary.2",
|
|
4
4
|
"description": "Listen to realtime updates to your PostgreSQL database",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"realtime",
|
|
@@ -35,13 +35,11 @@
|
|
|
35
35
|
"build:module": "tsc -p tsconfig.module.json",
|
|
36
36
|
"test": "vitest run",
|
|
37
37
|
"test:watch": "vitest",
|
|
38
|
-
"coverage": "vitest run --coverage",
|
|
39
|
-
"coverage:text": "vitest run --coverage.enabled true --coverage.reporter=text",
|
|
38
|
+
"test:coverage": "vitest run --coverage.enabled true --coverage.reporter=text",
|
|
40
39
|
"docs": "typedoc src/index.ts --out docs/v2",
|
|
41
40
|
"docs:json": "typedoc --json docs/v2/spec.json --excludeExternals src/index.ts",
|
|
42
41
|
"check-exports": "attw --pack .",
|
|
43
|
-
"ci": "
|
|
44
|
-
"test:ci": "npm run test && npm run coverage"
|
|
42
|
+
"test:ci": "vitest run --coverage"
|
|
45
43
|
},
|
|
46
44
|
"dependencies": {
|
|
47
45
|
"@types/phoenix": "^1.6.6",
|
package/src/lib/version.ts
CHANGED
|
@@ -1 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
// Generated automatically during releases by scripts/update-version-files.js
|
|
2
|
+
// This file provides runtime access to the package version for:
|
|
3
|
+
// - HTTP request headers (e.g., X-Client-Info header for API requests)
|
|
4
|
+
// - Debugging and support (identifying which version is running)
|
|
5
|
+
// - Telemetry and logging (version reporting in errors/analytics)
|
|
6
|
+
// - Ensuring build artifacts match the published package version
|
|
7
|
+
export const version = '2.72.1-canary.2'
|