@snowcone-app/sdk 0.1.13 → 0.1.14
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/dist/react.cjs +4 -2
- package/dist/react.js +4 -2
- package/package.json +1 -1
package/dist/react.cjs
CHANGED
|
@@ -681,7 +681,9 @@ ${versionToSend}
|
|
|
681
681
|
};
|
|
682
682
|
|
|
683
683
|
// src/realtime/react.ts
|
|
684
|
+
var DEFAULT_REALTIME_WS_URL = "wss://cdn.snowcone.app/realtime";
|
|
684
685
|
function useRealtimeMockup(options = {}) {
|
|
686
|
+
const wsUrl = options.wsUrl ?? (options.getToken ? DEFAULT_REALTIME_WS_URL : void 0);
|
|
685
687
|
const serviceRef = (0, import_react.useRef)(null);
|
|
686
688
|
const getTokenRef = (0, import_react.useRef)(options.getToken);
|
|
687
689
|
getTokenRef.current = options.getToken;
|
|
@@ -695,7 +697,7 @@ function useRealtimeMockup(options = {}) {
|
|
|
695
697
|
lastError: null
|
|
696
698
|
});
|
|
697
699
|
(0, import_react.useEffect)(() => {
|
|
698
|
-
const service = new RealtimeMockupService(
|
|
700
|
+
const service = new RealtimeMockupService(wsUrl);
|
|
699
701
|
serviceRef.current = service;
|
|
700
702
|
service.setCallbacks({
|
|
701
703
|
onConnected: (sessionId) => {
|
|
@@ -739,7 +741,7 @@ function useRealtimeMockup(options = {}) {
|
|
|
739
741
|
return () => {
|
|
740
742
|
service.disconnect();
|
|
741
743
|
};
|
|
742
|
-
}, [
|
|
744
|
+
}, [wsUrl]);
|
|
743
745
|
const connect = (0, import_react.useCallback)(() => {
|
|
744
746
|
serviceRef.current?.connect();
|
|
745
747
|
}, []);
|
package/dist/react.js
CHANGED
|
@@ -4,7 +4,9 @@ import {
|
|
|
4
4
|
|
|
5
5
|
// src/realtime/react.ts
|
|
6
6
|
import { useCallback, useEffect, useRef, useState } from "react";
|
|
7
|
+
var DEFAULT_REALTIME_WS_URL = "wss://cdn.snowcone.app/realtime";
|
|
7
8
|
function useRealtimeMockup(options = {}) {
|
|
9
|
+
const wsUrl = options.wsUrl ?? (options.getToken ? DEFAULT_REALTIME_WS_URL : void 0);
|
|
8
10
|
const serviceRef = useRef(null);
|
|
9
11
|
const getTokenRef = useRef(options.getToken);
|
|
10
12
|
getTokenRef.current = options.getToken;
|
|
@@ -18,7 +20,7 @@ function useRealtimeMockup(options = {}) {
|
|
|
18
20
|
lastError: null
|
|
19
21
|
});
|
|
20
22
|
useEffect(() => {
|
|
21
|
-
const service = new RealtimeMockupService(
|
|
23
|
+
const service = new RealtimeMockupService(wsUrl);
|
|
22
24
|
serviceRef.current = service;
|
|
23
25
|
service.setCallbacks({
|
|
24
26
|
onConnected: (sessionId) => {
|
|
@@ -62,7 +64,7 @@ function useRealtimeMockup(options = {}) {
|
|
|
62
64
|
return () => {
|
|
63
65
|
service.disconnect();
|
|
64
66
|
};
|
|
65
|
-
}, [
|
|
67
|
+
}, [wsUrl]);
|
|
66
68
|
const connect = useCallback(() => {
|
|
67
69
|
serviceRef.current?.connect();
|
|
68
70
|
}, []);
|