@wix/realtime 1.0.17 → 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 +1311 -41
- 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 +4 -4
package/cjs/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/cjs/build/index.js
CHANGED
|
@@ -33,7 +33,10 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.subscriber = exports.publisher = exports.site = void 0;
|
|
36
|
+
exports.RealtimeErrorCode = exports.RealtimeError = exports.subscriber = exports.publisher = exports.site = void 0;
|
|
37
37
|
exports.site = __importStar(require("@wix/sdk_realtime_site"));
|
|
38
38
|
exports.publisher = __importStar(require("./publisher/publisher.context.js"));
|
|
39
39
|
exports.subscriber = __importStar(require("./subscriber/subscriber.context.js"));
|
|
40
|
+
const types_js_1 = require("./types.js");
|
|
41
|
+
Object.defineProperty(exports, "RealtimeError", { enumerable: true, get: function () { return types_js_1.RealtimeError; } });
|
|
42
|
+
Object.defineProperty(exports, "RealtimeErrorCode", { enumerable: true, get: function () { return types_js_1.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>;
|
|
@@ -36,5 +36,8 @@ const rest_modules_1 = require("@wix/sdk-runtime/rest-modules");
|
|
|
36
36
|
*
|
|
37
37
|
* await elevate(publisher.publish)({ name: 'my-channel' }, { message: 'hello' });
|
|
38
38
|
* ```
|
|
39
|
+
*
|
|
40
|
+
* @param channel - The channel, and optionally the resource, to publish to.
|
|
41
|
+
* @param payload - Message payload. Max: 10kb
|
|
39
42
|
*/
|
|
40
43
|
exports.publish = (0, rest_modules_1.createRESTModule)(publisher_public_js_1.publish);
|
|
@@ -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>;
|
|
@@ -3,5 +3,86 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.unsubscribe = exports.subscribe = void 0;
|
|
4
4
|
const subscriber_public_js_1 = require("./subscriber.public.js");
|
|
5
5
|
const rest_modules_1 = require("@wix/sdk-runtime/rest-modules");
|
|
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
|
+
* **Manual client (self-hosted / explicit auth):**
|
|
12
|
+
*
|
|
13
|
+
* ```ts
|
|
14
|
+
* import { subscriber } from '@wix/realtime';
|
|
15
|
+
* import { createClient, AppStrategy } from '@wix/sdk';
|
|
16
|
+
*
|
|
17
|
+
* const client = createClient({
|
|
18
|
+
* modules: { subscriber },
|
|
19
|
+
* auth: AppStrategy({ appId, appSecret, instanceId }),
|
|
20
|
+
* });
|
|
21
|
+
*
|
|
22
|
+
* const subscriptionId = client.subscriber.subscribe(
|
|
23
|
+
* { name: 'my-channel' },
|
|
24
|
+
* (message, channel) => {
|
|
25
|
+
* console.log('Received:', message.payload);
|
|
26
|
+
* },
|
|
27
|
+
* {
|
|
28
|
+
* onSubscribed: (id, isSynced) => console.log('Subscribed', id),
|
|
29
|
+
* onSubscriptionError: (error, id) => console.error('Error', error),
|
|
30
|
+
* },
|
|
31
|
+
* );
|
|
32
|
+
* ```
|
|
33
|
+
*
|
|
34
|
+
* **Contextual client (Wix-hosted):**
|
|
35
|
+
*
|
|
36
|
+
* ```ts
|
|
37
|
+
* import { subscriber } from '@wix/realtime';
|
|
38
|
+
*
|
|
39
|
+
* const subscriptionId = subscriber.subscribe(
|
|
40
|
+
* { name: 'my-channel' },
|
|
41
|
+
* (message, channel) => {
|
|
42
|
+
* console.log('Received:', message.payload);
|
|
43
|
+
* },
|
|
44
|
+
* );
|
|
45
|
+
* ```
|
|
46
|
+
*
|
|
47
|
+
* @param channel - The channel, and optionally the resource, to subscribe to.
|
|
48
|
+
* @param messageHandler - Callback invoked whenever a message is published to the channel.
|
|
49
|
+
* @param options - Optional lifecycle handlers for subscription events.
|
|
50
|
+
*/
|
|
6
51
|
exports.subscribe = (0, rest_modules_1.createRESTModule)(subscriber_public_js_1.subscribe);
|
|
52
|
+
/**
|
|
53
|
+
* Unsubscribe from a subscription by its ID, by channel, or both.
|
|
54
|
+
*
|
|
55
|
+
* You can unsubscribe in three ways:
|
|
56
|
+
* - By `subscriptionId` — removes a single subscription.
|
|
57
|
+
* - By `channel` — removes all subscriptions to that channel.
|
|
58
|
+
* - By both — removes the specific subscription, verifying it matches the channel.
|
|
59
|
+
*
|
|
60
|
+
* **Manual client (self-hosted / explicit auth):**
|
|
61
|
+
*
|
|
62
|
+
* ```ts
|
|
63
|
+
* import { subscriber } from '@wix/realtime';
|
|
64
|
+
* import { createClient, AppStrategy } from '@wix/sdk';
|
|
65
|
+
*
|
|
66
|
+
* const client = createClient({
|
|
67
|
+
* modules: { subscriber },
|
|
68
|
+
* auth: AppStrategy({ appId, appSecret, instanceId }),
|
|
69
|
+
* });
|
|
70
|
+
*
|
|
71
|
+
* // Unsubscribe by subscription ID
|
|
72
|
+
* client.subscriber.unsubscribe({ subscriptionId });
|
|
73
|
+
*
|
|
74
|
+
* // Unsubscribe from all subscriptions to a channel
|
|
75
|
+
* client.subscriber.unsubscribe({ channel: { name: 'my-channel' } });
|
|
76
|
+
* ```
|
|
77
|
+
*
|
|
78
|
+
* **Contextual client (Wix-hosted):**
|
|
79
|
+
*
|
|
80
|
+
* ```ts
|
|
81
|
+
* import { subscriber } from '@wix/realtime';
|
|
82
|
+
*
|
|
83
|
+
* subscriber.unsubscribe({ subscriptionId });
|
|
84
|
+
* ```
|
|
85
|
+
*
|
|
86
|
+
* @param options - Identifies what to unsubscribe from — by subscription ID, channel, or both.
|
|
87
|
+
*/
|
|
7
88
|
exports.unsubscribe = (0, rest_modules_1.createRESTModule)(subscriber_public_js_1.unsubscribe);
|
|
@@ -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;
|
|
@@ -11,11 +11,6 @@ const errors_js_1 = require("./errors.js");
|
|
|
11
11
|
const subscription_manager_js_1 = require("./subscription-manager.js");
|
|
12
12
|
const instanceConnections = new Map();
|
|
13
13
|
const subscriptionManager = new subscription_manager_js_1.SubscriptionManager();
|
|
14
|
-
/**
|
|
15
|
-
* Subscribe to a channel. Returns a subscriptionId immediately; the
|
|
16
|
-
* actual connection is established asynchronously in the background. Use the
|
|
17
|
-
* optional `options` parameter to handle subscription lifecycle events.
|
|
18
|
-
*/
|
|
19
14
|
function subscribe(httpClient) {
|
|
20
15
|
return (channel, messageHandler, options) => {
|
|
21
16
|
(0, errors_js_1.validateChannel)(channel);
|
|
@@ -31,9 +26,6 @@ function subscribe(httpClient) {
|
|
|
31
26
|
return subscriptionId;
|
|
32
27
|
};
|
|
33
28
|
}
|
|
34
|
-
/**
|
|
35
|
-
* Unsubscribe from a subscription by its ID, by channel, or both.
|
|
36
|
-
*/
|
|
37
29
|
function unsubscribe(_) {
|
|
38
30
|
return ({ channel, subscriptionId }) => {
|
|
39
31
|
if (!channel && !subscriptionId) {
|
package/cjs/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';
|