@wix/realtime 1.0.16 → 1.0.18
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/cjs/build/index.d.ts +4 -0
- package/cjs/build/index.js +4 -1
- package/cjs/build/publisher/publisher.context.d.ts +3 -0
- package/cjs/build/publisher/publisher.context.js +3 -0
- package/cjs/build/subscriber/subscriber.context.d.ts +81 -0
- package/cjs/build/subscriber/subscriber.context.js +81 -0
- package/cjs/build/subscriber/subscriber.public.d.ts +0 -8
- package/cjs/build/subscriber/subscriber.public.js +0 -8
- package/cjs/build/types.d.ts +1 -1
- package/dist/statics/docs-ts-model.json +2406 -0
- package/es/build/index.d.ts +4 -0
- package/es/build/index.js +2 -0
- package/es/build/publisher/publisher.context.d.ts +3 -0
- package/es/build/publisher/publisher.context.js +3 -0
- package/es/build/subscriber/subscriber.context.d.ts +81 -0
- package/es/build/subscriber/subscriber.context.js +81 -0
- package/es/build/subscriber/subscriber.public.d.ts +0 -8
- package/es/build/subscriber/subscriber.public.js +0 -8
- package/es/build/types.d.ts +1 -1
- package/package.json +12 -5
package/es/build/index.d.ts
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
1
|
export * as site from '@wix/sdk_realtime_site';
|
|
2
2
|
export * as publisher from './publisher/publisher.context.js';
|
|
3
3
|
export * as subscriber from './subscriber/subscriber.context.js';
|
|
4
|
+
import type { Channel, Message, MessageHandler, Publisher, SubscriptionErrorHandler, SubscriptionHandler, SubscriptionOptions, UnsubscribeOptions } from './types.js';
|
|
5
|
+
import { RealtimeError, RealtimeErrorCode } from './types.js';
|
|
6
|
+
export type { Channel, Message, MessageHandler, Publisher, SubscriptionErrorHandler, SubscriptionHandler, SubscriptionOptions, UnsubscribeOptions, };
|
|
7
|
+
export { RealtimeError, RealtimeErrorCode };
|
package/es/build/index.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
export * as site from '@wix/sdk_realtime_site';
|
|
2
2
|
export * as publisher from './publisher/publisher.context.js';
|
|
3
3
|
export * as subscriber from './subscriber/subscriber.context.js';
|
|
4
|
+
import { RealtimeError, RealtimeErrorCode } from './types.js';
|
|
5
|
+
export { RealtimeError, RealtimeErrorCode };
|
|
@@ -33,5 +33,8 @@ import type { BuildRESTFunction, MaybeContext } from '@wix/sdk-types';
|
|
|
33
33
|
*
|
|
34
34
|
* await elevate(publisher.publish)({ name: 'my-channel' }, { message: 'hello' });
|
|
35
35
|
* ```
|
|
36
|
+
*
|
|
37
|
+
* @param channel - The channel, and optionally the resource, to publish to.
|
|
38
|
+
* @param payload - Message payload. Max: 10kb
|
|
36
39
|
*/
|
|
37
40
|
export declare const publish: MaybeContext<BuildRESTFunction<typeof publicPublish> & typeof publicPublish>;
|
|
@@ -33,5 +33,8 @@ import { createRESTModule } from '@wix/sdk-runtime/rest-modules';
|
|
|
33
33
|
*
|
|
34
34
|
* await elevate(publisher.publish)({ name: 'my-channel' }, { message: 'hello' });
|
|
35
35
|
* ```
|
|
36
|
+
*
|
|
37
|
+
* @param channel - The channel, and optionally the resource, to publish to.
|
|
38
|
+
* @param payload - Message payload. Max: 10kb
|
|
36
39
|
*/
|
|
37
40
|
export const publish = /*#__PURE__*/ createRESTModule(publicPublish);
|
|
@@ -1,4 +1,85 @@
|
|
|
1
1
|
import { subscribe as publicSubscribe, unsubscribe as publicUnsubscribe } from './subscriber.public.js';
|
|
2
2
|
import type { BuildRESTFunction, MaybeContext } from '@wix/sdk-types';
|
|
3
|
+
/**
|
|
4
|
+
* Subscribe to a channel. Returns a subscriptionId immediately; the
|
|
5
|
+
* actual connection is established asynchronously in the background. Use the
|
|
6
|
+
* optional `options` parameter to handle subscription lifecycle events.
|
|
7
|
+
*
|
|
8
|
+
* **Manual client (self-hosted / explicit auth):**
|
|
9
|
+
*
|
|
10
|
+
* ```ts
|
|
11
|
+
* import { subscriber } from '@wix/realtime';
|
|
12
|
+
* import { createClient, AppStrategy } from '@wix/sdk';
|
|
13
|
+
*
|
|
14
|
+
* const client = createClient({
|
|
15
|
+
* modules: { subscriber },
|
|
16
|
+
* auth: AppStrategy({ appId, appSecret, instanceId }),
|
|
17
|
+
* });
|
|
18
|
+
*
|
|
19
|
+
* const subscriptionId = client.subscriber.subscribe(
|
|
20
|
+
* { name: 'my-channel' },
|
|
21
|
+
* (message, channel) => {
|
|
22
|
+
* console.log('Received:', message.payload);
|
|
23
|
+
* },
|
|
24
|
+
* {
|
|
25
|
+
* onSubscribed: (id, isSynced) => console.log('Subscribed', id),
|
|
26
|
+
* onSubscriptionError: (error, id) => console.error('Error', error),
|
|
27
|
+
* },
|
|
28
|
+
* );
|
|
29
|
+
* ```
|
|
30
|
+
*
|
|
31
|
+
* **Contextual client (Wix-hosted):**
|
|
32
|
+
*
|
|
33
|
+
* ```ts
|
|
34
|
+
* import { subscriber } from '@wix/realtime';
|
|
35
|
+
*
|
|
36
|
+
* const subscriptionId = subscriber.subscribe(
|
|
37
|
+
* { name: 'my-channel' },
|
|
38
|
+
* (message, channel) => {
|
|
39
|
+
* console.log('Received:', message.payload);
|
|
40
|
+
* },
|
|
41
|
+
* );
|
|
42
|
+
* ```
|
|
43
|
+
*
|
|
44
|
+
* @param channel - The channel, and optionally the resource, to subscribe to.
|
|
45
|
+
* @param messageHandler - Callback invoked whenever a message is published to the channel.
|
|
46
|
+
* @param options - Optional lifecycle handlers for subscription events.
|
|
47
|
+
*/
|
|
3
48
|
export declare const subscribe: MaybeContext<BuildRESTFunction<typeof publicSubscribe> & typeof publicSubscribe>;
|
|
49
|
+
/**
|
|
50
|
+
* Unsubscribe from a subscription by its ID, by channel, or both.
|
|
51
|
+
*
|
|
52
|
+
* You can unsubscribe in three ways:
|
|
53
|
+
* - By `subscriptionId` — removes a single subscription.
|
|
54
|
+
* - By `channel` — removes all subscriptions to that channel.
|
|
55
|
+
* - By both — removes the specific subscription, verifying it matches the channel.
|
|
56
|
+
*
|
|
57
|
+
* **Manual client (self-hosted / explicit auth):**
|
|
58
|
+
*
|
|
59
|
+
* ```ts
|
|
60
|
+
* import { subscriber } from '@wix/realtime';
|
|
61
|
+
* import { createClient, AppStrategy } from '@wix/sdk';
|
|
62
|
+
*
|
|
63
|
+
* const client = createClient({
|
|
64
|
+
* modules: { subscriber },
|
|
65
|
+
* auth: AppStrategy({ appId, appSecret, instanceId }),
|
|
66
|
+
* });
|
|
67
|
+
*
|
|
68
|
+
* // Unsubscribe by subscription ID
|
|
69
|
+
* client.subscriber.unsubscribe({ subscriptionId });
|
|
70
|
+
*
|
|
71
|
+
* // Unsubscribe from all subscriptions to a channel
|
|
72
|
+
* client.subscriber.unsubscribe({ channel: { name: 'my-channel' } });
|
|
73
|
+
* ```
|
|
74
|
+
*
|
|
75
|
+
* **Contextual client (Wix-hosted):**
|
|
76
|
+
*
|
|
77
|
+
* ```ts
|
|
78
|
+
* import { subscriber } from '@wix/realtime';
|
|
79
|
+
*
|
|
80
|
+
* subscriber.unsubscribe({ subscriptionId });
|
|
81
|
+
* ```
|
|
82
|
+
*
|
|
83
|
+
* @param options - Identifies what to unsubscribe from — by subscription ID, channel, or both.
|
|
84
|
+
*/
|
|
4
85
|
export declare const unsubscribe: MaybeContext<BuildRESTFunction<typeof publicUnsubscribe> & typeof publicUnsubscribe>;
|
|
@@ -1,4 +1,85 @@
|
|
|
1
1
|
import { subscribe as publicSubscribe, unsubscribe as publicUnsubscribe, } from './subscriber.public.js';
|
|
2
2
|
import { createRESTModule } from '@wix/sdk-runtime/rest-modules';
|
|
3
|
+
/**
|
|
4
|
+
* Subscribe to a channel. Returns a subscriptionId immediately; the
|
|
5
|
+
* actual connection is established asynchronously in the background. Use the
|
|
6
|
+
* optional `options` parameter to handle subscription lifecycle events.
|
|
7
|
+
*
|
|
8
|
+
* **Manual client (self-hosted / explicit auth):**
|
|
9
|
+
*
|
|
10
|
+
* ```ts
|
|
11
|
+
* import { subscriber } from '@wix/realtime';
|
|
12
|
+
* import { createClient, AppStrategy } from '@wix/sdk';
|
|
13
|
+
*
|
|
14
|
+
* const client = createClient({
|
|
15
|
+
* modules: { subscriber },
|
|
16
|
+
* auth: AppStrategy({ appId, appSecret, instanceId }),
|
|
17
|
+
* });
|
|
18
|
+
*
|
|
19
|
+
* const subscriptionId = client.subscriber.subscribe(
|
|
20
|
+
* { name: 'my-channel' },
|
|
21
|
+
* (message, channel) => {
|
|
22
|
+
* console.log('Received:', message.payload);
|
|
23
|
+
* },
|
|
24
|
+
* {
|
|
25
|
+
* onSubscribed: (id, isSynced) => console.log('Subscribed', id),
|
|
26
|
+
* onSubscriptionError: (error, id) => console.error('Error', error),
|
|
27
|
+
* },
|
|
28
|
+
* );
|
|
29
|
+
* ```
|
|
30
|
+
*
|
|
31
|
+
* **Contextual client (Wix-hosted):**
|
|
32
|
+
*
|
|
33
|
+
* ```ts
|
|
34
|
+
* import { subscriber } from '@wix/realtime';
|
|
35
|
+
*
|
|
36
|
+
* const subscriptionId = subscriber.subscribe(
|
|
37
|
+
* { name: 'my-channel' },
|
|
38
|
+
* (message, channel) => {
|
|
39
|
+
* console.log('Received:', message.payload);
|
|
40
|
+
* },
|
|
41
|
+
* );
|
|
42
|
+
* ```
|
|
43
|
+
*
|
|
44
|
+
* @param channel - The channel, and optionally the resource, to subscribe to.
|
|
45
|
+
* @param messageHandler - Callback invoked whenever a message is published to the channel.
|
|
46
|
+
* @param options - Optional lifecycle handlers for subscription events.
|
|
47
|
+
*/
|
|
3
48
|
export const subscribe = /*#__PURE__*/ createRESTModule(publicSubscribe);
|
|
49
|
+
/**
|
|
50
|
+
* Unsubscribe from a subscription by its ID, by channel, or both.
|
|
51
|
+
*
|
|
52
|
+
* You can unsubscribe in three ways:
|
|
53
|
+
* - By `subscriptionId` — removes a single subscription.
|
|
54
|
+
* - By `channel` — removes all subscriptions to that channel.
|
|
55
|
+
* - By both — removes the specific subscription, verifying it matches the channel.
|
|
56
|
+
*
|
|
57
|
+
* **Manual client (self-hosted / explicit auth):**
|
|
58
|
+
*
|
|
59
|
+
* ```ts
|
|
60
|
+
* import { subscriber } from '@wix/realtime';
|
|
61
|
+
* import { createClient, AppStrategy } from '@wix/sdk';
|
|
62
|
+
*
|
|
63
|
+
* const client = createClient({
|
|
64
|
+
* modules: { subscriber },
|
|
65
|
+
* auth: AppStrategy({ appId, appSecret, instanceId }),
|
|
66
|
+
* });
|
|
67
|
+
*
|
|
68
|
+
* // Unsubscribe by subscription ID
|
|
69
|
+
* client.subscriber.unsubscribe({ subscriptionId });
|
|
70
|
+
*
|
|
71
|
+
* // Unsubscribe from all subscriptions to a channel
|
|
72
|
+
* client.subscriber.unsubscribe({ channel: { name: 'my-channel' } });
|
|
73
|
+
* ```
|
|
74
|
+
*
|
|
75
|
+
* **Contextual client (Wix-hosted):**
|
|
76
|
+
*
|
|
77
|
+
* ```ts
|
|
78
|
+
* import { subscriber } from '@wix/realtime';
|
|
79
|
+
*
|
|
80
|
+
* subscriber.unsubscribe({ subscriptionId });
|
|
81
|
+
* ```
|
|
82
|
+
*
|
|
83
|
+
* @param options - Identifies what to unsubscribe from — by subscription ID, channel, or both.
|
|
84
|
+
*/
|
|
4
85
|
export const unsubscribe = /*#__PURE__*/ createRESTModule(publicUnsubscribe);
|
|
@@ -3,18 +3,10 @@ import type { HttpClient } from '@wix/sdk-types';
|
|
|
3
3
|
interface SubscribeSignature {
|
|
4
4
|
(channel: Channel, messageHandler: MessageHandler, options?: SubscriptionOptions): string;
|
|
5
5
|
}
|
|
6
|
-
/**
|
|
7
|
-
* Subscribe to a channel. Returns a subscriptionId immediately; the
|
|
8
|
-
* actual connection is established asynchronously in the background. Use the
|
|
9
|
-
* optional `options` parameter to handle subscription lifecycle events.
|
|
10
|
-
*/
|
|
11
6
|
export declare function subscribe(httpClient: HttpClient): SubscribeSignature;
|
|
12
7
|
interface UnsubscribeSignature {
|
|
13
8
|
(options: UnsubscribeOptions): void;
|
|
14
9
|
}
|
|
15
|
-
/**
|
|
16
|
-
* Unsubscribe from a subscription by its ID, by channel, or both.
|
|
17
|
-
*/
|
|
18
10
|
export declare function unsubscribe(_: HttpClient): UnsubscribeSignature;
|
|
19
11
|
/** @internal Resets all module-level state. Only for use in tests. */
|
|
20
12
|
export declare function _resetForTesting(): void;
|
|
@@ -6,11 +6,6 @@ import { missingChannelOrSubscriptionId, channelMismatch, disconnectedError, con
|
|
|
6
6
|
import { SubscriptionManager } from './subscription-manager.js';
|
|
7
7
|
const instanceConnections = new Map();
|
|
8
8
|
const subscriptionManager = new SubscriptionManager();
|
|
9
|
-
/**
|
|
10
|
-
* Subscribe to a channel. Returns a subscriptionId immediately; the
|
|
11
|
-
* actual connection is established asynchronously in the background. Use the
|
|
12
|
-
* optional `options` parameter to handle subscription lifecycle events.
|
|
13
|
-
*/
|
|
14
9
|
export function subscribe(httpClient) {
|
|
15
10
|
return (channel, messageHandler, options) => {
|
|
16
11
|
validateChannel(channel);
|
|
@@ -26,9 +21,6 @@ export function subscribe(httpClient) {
|
|
|
26
21
|
return subscriptionId;
|
|
27
22
|
};
|
|
28
23
|
}
|
|
29
|
-
/**
|
|
30
|
-
* Unsubscribe from a subscription by its ID, by channel, or both.
|
|
31
|
-
*/
|
|
32
24
|
export function unsubscribe(_) {
|
|
33
25
|
return ({ channel, subscriptionId }) => {
|
|
34
26
|
if (!channel && !subscriptionId) {
|
package/es/build/types.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { RealtimeErrorCode, RealtimeError, type Channel, type Publisher, type Message, type MessageHandler, type SubscriptionHandler, type SubscriptionErrorHandler, type SubscriptionOptions, } from '@wix/realtime-common/types';
|
|
1
|
+
export { RealtimeErrorCode, RealtimeError, type Channel, type Publisher, type Message, type MessageHandler, type SubscriptionHandler, type SubscriptionErrorHandler, type SubscriptionOptions, type UnsubscribeOptions, } from '@wix/realtime-common/types';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wix/realtime",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.18",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"registry": "https://registry.npmjs.org/",
|
|
6
6
|
"access": "public"
|
|
@@ -30,33 +30,40 @@
|
|
|
30
30
|
},
|
|
31
31
|
"files": [
|
|
32
32
|
"es",
|
|
33
|
+
"dist",
|
|
33
34
|
"types",
|
|
34
35
|
"cjs"
|
|
35
36
|
],
|
|
36
37
|
"dependencies": {
|
|
37
38
|
"@wix/auto_sdk_duplexer_publisher": "^1.0.10",
|
|
38
39
|
"@wix/duplexer-js": "^2.0.6",
|
|
39
|
-
"@wix/realtime-common": "1.0.
|
|
40
|
+
"@wix/realtime-common": "1.0.1",
|
|
40
41
|
"@wix/sdk": "^1.21.4",
|
|
41
42
|
"@wix/sdk-runtime": "^1.0.9",
|
|
42
43
|
"@wix/sdk-types": "^1.17.5",
|
|
43
|
-
"@wix/sdk_realtime_site": "1.0.
|
|
44
|
+
"@wix/sdk_realtime_site": "1.0.17",
|
|
44
45
|
"uuid": "^11.1.0"
|
|
45
46
|
},
|
|
46
47
|
"devDependencies": {
|
|
48
|
+
"@wix/docs-ts-model": "^1.54.0",
|
|
47
49
|
"typescript": "^5.7.3",
|
|
48
50
|
"vitest": "^3.0.5"
|
|
49
51
|
},
|
|
50
52
|
"scripts": {
|
|
51
|
-
"build": "tsc -p tsconfig.json && tsc -p tsconfig.cjs.json",
|
|
53
|
+
"build": "tsc -p tsconfig.json && tsc -p tsconfig.cjs.json && npm run docs",
|
|
54
|
+
"docs": "docs-ts-model --disableSources --entryPoint src/index.ts",
|
|
52
55
|
"test": "vitest run"
|
|
53
56
|
},
|
|
54
57
|
"wix": {
|
|
55
58
|
"artifact": {
|
|
56
59
|
"groupId": "com.wixpress.sdk",
|
|
57
60
|
"artifactId": "realtime",
|
|
61
|
+
"targets": {
|
|
62
|
+
"static": true,
|
|
63
|
+
"build-docs": true
|
|
64
|
+
},
|
|
58
65
|
"isRootPublicSdk": true
|
|
59
66
|
}
|
|
60
67
|
},
|
|
61
|
-
"falconPackageHash": "
|
|
68
|
+
"falconPackageHash": "fe8c2a94e3d494c7683d22a3b4943a1e3883c91df788345d96d1425c"
|
|
62
69
|
}
|