@fluxy-chat/sdk 0.2.0 → 0.2.1
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/index.js +1 -6
- package/dist/realtime-provider.js +2 -1
- package/dist/url-utils.d.ts +2 -0
- package/dist/url-utils.js +7 -0
- package/package.json +3 -1
package/dist/index.js
CHANGED
|
@@ -12,6 +12,7 @@ export { useRooms } from "./use-rooms";
|
|
|
12
12
|
import { FluxyChatRoomConnection } from "./room-connection";
|
|
13
13
|
import { clampHistoryLimit, sortMessagesChronological } from "./message-history";
|
|
14
14
|
import { normalizeRoomMembers } from "./room-rest";
|
|
15
|
+
import { trimTrailingSlashes } from "./url-utils";
|
|
15
16
|
const AUDIO_FILE_SUFFIXES = [".webm", ".m4a", ".mp3", ".wav", ".ogg"];
|
|
16
17
|
function fileNameLooksLikeAudio(fileName) {
|
|
17
18
|
const lower = fileName.toLowerCase();
|
|
@@ -31,12 +32,6 @@ function inferAttachmentKind(contentType, fileName) {
|
|
|
31
32
|
return "audio";
|
|
32
33
|
return "file";
|
|
33
34
|
}
|
|
34
|
-
function trimTrailingSlashes(url) {
|
|
35
|
-
let out = url;
|
|
36
|
-
while (out.endsWith("/"))
|
|
37
|
-
out = out.slice(0, -1);
|
|
38
|
-
return out;
|
|
39
|
-
}
|
|
40
35
|
function httpUrlToWebSocketBase(url) {
|
|
41
36
|
if (url.startsWith("https://"))
|
|
42
37
|
return `wss://${url.slice("https://".length)}`;
|
|
@@ -3,6 +3,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
3
3
|
import React from "react";
|
|
4
4
|
import { FluxyChatClient } from "./index";
|
|
5
5
|
import { decodeFluxyJwtPayload, jwtRefreshDelayMs } from "./jwt-utils";
|
|
6
|
+
import { trimTrailingSlashes } from "./url-utils";
|
|
6
7
|
import { FluxyRealtimeContext } from "./use-fluxy-chat";
|
|
7
8
|
async function resolveAuthToken(provider) {
|
|
8
9
|
if (typeof provider === "string") {
|
|
@@ -113,7 +114,7 @@ export function FluxyRealtimeProvider({ children, workerUrl, authTokenProvider,
|
|
|
113
114
|
if (!token?.trim() || !userId.trim())
|
|
114
115
|
return null;
|
|
115
116
|
return new FluxyChatClient({
|
|
116
|
-
baseUrl: workerUrl
|
|
117
|
+
baseUrl: trimTrailingSlashes(workerUrl),
|
|
117
118
|
userId,
|
|
118
119
|
token,
|
|
119
120
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluxy-chat/sdk",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "Fluxychat JavaScript/TypeScript SDK — WebSocket rooms, REST messages, FluxyRealtimeProvider, useChat with loadMore",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Fluxychat",
|
|
@@ -48,6 +48,8 @@
|
|
|
48
48
|
"dist/room-rest.d.ts",
|
|
49
49
|
"dist/agent-outbound.js",
|
|
50
50
|
"dist/agent-outbound.d.ts",
|
|
51
|
+
"dist/url-utils.js",
|
|
52
|
+
"dist/url-utils.d.ts",
|
|
51
53
|
"LICENSE",
|
|
52
54
|
"README.md"
|
|
53
55
|
],
|