@mulmobridge/client 0.1.1 → 0.1.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/dist/client.js CHANGED
@@ -12,7 +12,7 @@
12
12
  // See `docs/bridge-protocol.md` for the wire-level contract and a
13
13
  // minimal non-Node equivalent.
14
14
  import { io } from "socket.io-client";
15
- import { CHAT_SOCKET_EVENTS, CHAT_SOCKET_PATH, } from "@mulmobridge/protocol";
15
+ import { CHAT_SOCKET_EVENTS, CHAT_SOCKET_PATH } from "@mulmobridge/protocol";
16
16
  import { readBridgeToken, TOKEN_FILE_PATH } from "./token.js";
17
17
  // 6 min > the server's REPLY_TIMEOUT_MS (5 min) so the server's
18
18
  // timeout surfaces as a reply, not a client-side cancellation.
@@ -71,9 +71,7 @@ function sendMessage(socket, externalChatId, text, attachments) {
71
71
  if (attachments && attachments.length > 0)
72
72
  payload.attachments = attachments;
73
73
  return new Promise((resolve) => {
74
- socket
75
- .timeout(REPLY_TIMEOUT_MS)
76
- .emit(CHAT_SOCKET_EVENTS.message, payload, (err, ack) => {
74
+ socket.timeout(REPLY_TIMEOUT_MS).emit(CHAT_SOCKET_EVENTS.message, payload, (err, ack) => {
77
75
  if (err) {
78
76
  resolve({ ok: false, error: `timeout: ${err.message}` });
79
77
  return;
package/dist/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
- export { createBridgeClient, requireBearerToken, type MessageAck, type PushEvent, type BridgeClientOptions, type BridgeClient, } from "./client.js";
1
+ export { createBridgeClient, requireBearerToken, type MessageAck, type PushEvent, type BridgeClientOptions, type BridgeClient } from "./client.js";
2
2
  export { readBridgeToken, TOKEN_FILE_PATH } from "./token.js";
3
+ export { chunkText } from "./text.js";
3
4
  export { mimeFromExtension, isImageMime, isPdfMime, isSupportedAttachmentMime, isNativeAttachmentMime, parseDataUrl, buildDataUrl, type ParsedDataUrl, } from "./mime.js";
package/dist/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  // @mulmobridge/client — shared socket.io client for all MulmoBridge bridges.
2
- export { createBridgeClient, requireBearerToken, } from "./client.js";
2
+ export { createBridgeClient, requireBearerToken } from "./client.js";
3
3
  export { readBridgeToken, TOKEN_FILE_PATH } from "./token.js";
4
+ export { chunkText } from "./text.js";
4
5
  export { mimeFromExtension, isImageMime, isPdfMime, isSupportedAttachmentMime, isNativeAttachmentMime, parseDataUrl, buildDataUrl, } from "./mime.js";
package/dist/text.d.ts ADDED
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Split text into chunks of at most `max` characters.
3
+ * Returns `["(empty reply)"]` when text is empty.
4
+ */
5
+ export declare function chunkText(text: string, max: number): string[];
package/dist/text.js ADDED
@@ -0,0 +1,14 @@
1
+ // Text utilities shared across bridge packages.
2
+ /**
3
+ * Split text into chunks of at most `max` characters.
4
+ * Returns `["(empty reply)"]` when text is empty.
5
+ */
6
+ export function chunkText(text, max) {
7
+ if (text.length === 0)
8
+ return ["(empty reply)"];
9
+ const chunks = [];
10
+ for (let i = 0; i < text.length; i += max) {
11
+ chunks.push(text.slice(i, i + max));
12
+ }
13
+ return chunks;
14
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mulmobridge/client",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "Socket.io client library for MulmoBridge — shared by all bridge implementations",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -11,6 +11,24 @@
11
11
  "import": "./dist/index.js",
12
12
  "require": "./dist/index.js",
13
13
  "default": "./dist/index.js"
14
+ },
15
+ "./text": {
16
+ "types": "./dist/text.d.ts",
17
+ "import": "./dist/text.js",
18
+ "require": "./dist/text.js",
19
+ "default": "./dist/text.js"
20
+ },
21
+ "./mime": {
22
+ "types": "./dist/mime.d.ts",
23
+ "import": "./dist/mime.js",
24
+ "require": "./dist/mime.js",
25
+ "default": "./dist/mime.js"
26
+ },
27
+ "./token": {
28
+ "types": "./dist/token.d.ts",
29
+ "import": "./dist/token.js",
30
+ "require": "./dist/token.js",
31
+ "default": "./dist/token.js"
14
32
  }
15
33
  },
16
34
  "files": [