@gethashd/bytecave-browser 1.0.43 → 1.0.44

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.
@@ -6077,12 +6077,14 @@ var StorageWebSocketClient = class {
6077
6077
  }
6078
6078
  async connect() {
6079
6079
  if (this.ws && this.ws.readyState === WebSocket.OPEN) {
6080
+ console.log("[Storage WS] Already connected");
6080
6081
  return;
6081
6082
  }
6083
+ console.log("[Storage WS] Connecting to relay:", this.relayUrl);
6082
6084
  return new Promise((resolve, reject) => {
6083
6085
  this.ws = new WebSocket(this.relayUrl);
6084
6086
  this.ws.onopen = () => {
6085
- console.log("[Storage WS] Connected to relay");
6087
+ console.log("[Storage WS] \u2713 Connected to relay");
6086
6088
  resolve();
6087
6089
  };
6088
6090
  this.ws.onmessage = (event) => {
@@ -6139,10 +6141,13 @@ var StorageWebSocketClient = class {
6139
6141
  }
6140
6142
  }
6141
6143
  async store(options) {
6144
+ console.log("[Storage WS] store() called, data size:", options.data.length, "bytes");
6142
6145
  if (!this.ws || this.ws.readyState !== WebSocket.OPEN) {
6146
+ console.log("[Storage WS] Not connected, connecting now...");
6143
6147
  await this.connect();
6144
6148
  }
6145
6149
  const requestId = Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15);
6150
+ console.log("[Storage WS] Converting data to base64...");
6146
6151
  const chunkSize = 8192;
6147
6152
  let binaryString = "";
6148
6153
  for (let i = 0; i < options.data.length; i += chunkSize) {
@@ -6150,6 +6155,7 @@ var StorageWebSocketClient = class {
6150
6155
  binaryString += String.fromCharCode(...chunk);
6151
6156
  }
6152
6157
  const base64Data = btoa(binaryString);
6158
+ console.log("[Storage WS] Base64 data length:", base64Data.length);
6153
6159
  const request = {
6154
6160
  type: "storage-request",
6155
6161
  requestId,
@@ -6158,16 +6164,20 @@ var StorageWebSocketClient = class {
6158
6164
  hashIdToken: options.hashIdToken,
6159
6165
  authorization: options.authorization
6160
6166
  };
6167
+ console.log("[Storage WS] Creating promise for request:", requestId);
6161
6168
  return new Promise((resolve, reject) => {
6162
6169
  const timeout = setTimeout(() => {
6170
+ console.error("[Storage WS] Request timed out:", requestId);
6163
6171
  this.pendingRequests.delete(requestId);
6164
6172
  reject(new Error("Storage request timeout"));
6165
6173
  }, options.timeout || 3e4);
6166
6174
  this.pendingRequests.set(requestId, { resolve, reject, timeout });
6167
6175
  try {
6176
+ console.log("[Storage WS] Sending request to relay, WS state:", this.ws?.readyState);
6168
6177
  this.ws.send(JSON.stringify(request));
6169
- console.log("[Storage WS] Sent storage request:", requestId);
6178
+ console.log("[Storage WS] \u2713 Sent storage request:", requestId);
6170
6179
  } catch (error) {
6180
+ console.error("[Storage WS] Failed to send request:", error.message);
6171
6181
  clearTimeout(timeout);
6172
6182
  this.pendingRequests.delete(requestId);
6173
6183
  reject(error);
package/dist/index.cjs CHANGED
@@ -6130,12 +6130,14 @@ var StorageWebSocketClient = class {
6130
6130
  }
6131
6131
  async connect() {
6132
6132
  if (this.ws && this.ws.readyState === WebSocket.OPEN) {
6133
+ console.log("[Storage WS] Already connected");
6133
6134
  return;
6134
6135
  }
6136
+ console.log("[Storage WS] Connecting to relay:", this.relayUrl);
6135
6137
  return new Promise((resolve, reject) => {
6136
6138
  this.ws = new WebSocket(this.relayUrl);
6137
6139
  this.ws.onopen = () => {
6138
- console.log("[Storage WS] Connected to relay");
6140
+ console.log("[Storage WS] \u2713 Connected to relay");
6139
6141
  resolve();
6140
6142
  };
6141
6143
  this.ws.onmessage = (event) => {
@@ -6192,10 +6194,13 @@ var StorageWebSocketClient = class {
6192
6194
  }
6193
6195
  }
6194
6196
  async store(options) {
6197
+ console.log("[Storage WS] store() called, data size:", options.data.length, "bytes");
6195
6198
  if (!this.ws || this.ws.readyState !== WebSocket.OPEN) {
6199
+ console.log("[Storage WS] Not connected, connecting now...");
6196
6200
  await this.connect();
6197
6201
  }
6198
6202
  const requestId = Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15);
6203
+ console.log("[Storage WS] Converting data to base64...");
6199
6204
  const chunkSize = 8192;
6200
6205
  let binaryString = "";
6201
6206
  for (let i = 0; i < options.data.length; i += chunkSize) {
@@ -6203,6 +6208,7 @@ var StorageWebSocketClient = class {
6203
6208
  binaryString += String.fromCharCode(...chunk);
6204
6209
  }
6205
6210
  const base64Data = btoa(binaryString);
6211
+ console.log("[Storage WS] Base64 data length:", base64Data.length);
6206
6212
  const request = {
6207
6213
  type: "storage-request",
6208
6214
  requestId,
@@ -6211,16 +6217,20 @@ var StorageWebSocketClient = class {
6211
6217
  hashIdToken: options.hashIdToken,
6212
6218
  authorization: options.authorization
6213
6219
  };
6220
+ console.log("[Storage WS] Creating promise for request:", requestId);
6214
6221
  return new Promise((resolve, reject) => {
6215
6222
  const timeout = setTimeout(() => {
6223
+ console.error("[Storage WS] Request timed out:", requestId);
6216
6224
  this.pendingRequests.delete(requestId);
6217
6225
  reject(new Error("Storage request timeout"));
6218
6226
  }, options.timeout || 3e4);
6219
6227
  this.pendingRequests.set(requestId, { resolve, reject, timeout });
6220
6228
  try {
6229
+ console.log("[Storage WS] Sending request to relay, WS state:", this.ws?.readyState);
6221
6230
  this.ws.send(JSON.stringify(request));
6222
- console.log("[Storage WS] Sent storage request:", requestId);
6231
+ console.log("[Storage WS] \u2713 Sent storage request:", requestId);
6223
6232
  } catch (error) {
6233
+ console.error("[Storage WS] Failed to send request:", error.message);
6224
6234
  clearTimeout(timeout);
6225
6235
  this.pendingRequests.delete(requestId);
6226
6236
  reject(error);
package/dist/index.js CHANGED
@@ -13,7 +13,7 @@ import {
13
13
  useHashdImage,
14
14
  useHashdMedia,
15
15
  useHashdUrl
16
- } from "./chunk-AS5ZERB4.js";
16
+ } from "./chunk-M5BKEAWD.js";
17
17
  import {
18
18
  clearHashdCache,
19
19
  createHashdUrl,
@@ -8,7 +8,7 @@ import {
8
8
  useHashdImage,
9
9
  useHashdMedia,
10
10
  useHashdUrl
11
- } from "../chunk-AS5ZERB4.js";
11
+ } from "../chunk-M5BKEAWD.js";
12
12
  import "../chunk-EEZWRIUI.js";
13
13
  export {
14
14
  HashdAudio,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gethashd/bytecave-browser",
3
- "version": "1.0.43",
3
+ "version": "1.0.44",
4
4
  "description": "ByteCave browser client for WebRTC P2P connections to storage nodes",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.js",
@@ -71,14 +71,16 @@ export class StorageWebSocketClient {
71
71
 
72
72
  async connect(): Promise<void> {
73
73
  if (this.ws && this.ws.readyState === WebSocket.OPEN) {
74
+ console.log('[Storage WS] Already connected');
74
75
  return;
75
76
  }
76
77
 
78
+ console.log('[Storage WS] Connecting to relay:', this.relayUrl);
77
79
  return new Promise((resolve, reject) => {
78
80
  this.ws = new WebSocket(this.relayUrl);
79
81
 
80
82
  this.ws.onopen = () => {
81
- console.log('[Storage WS] Connected to relay');
83
+ console.log('[Storage WS] Connected to relay');
82
84
  resolve();
83
85
  };
84
86
 
@@ -144,13 +146,17 @@ export class StorageWebSocketClient {
144
146
  }
145
147
 
146
148
  async store(options: StoreViaWebSocketOptions): Promise<{ success: boolean; cid?: string; error?: string }> {
149
+ console.log('[Storage WS] store() called, data size:', options.data.length, 'bytes');
150
+
147
151
  if (!this.ws || this.ws.readyState !== WebSocket.OPEN) {
152
+ console.log('[Storage WS] Not connected, connecting now...');
148
153
  await this.connect();
149
154
  }
150
155
 
151
156
  const requestId = Math.random().toString(36).substring(2, 15) +
152
157
  Math.random().toString(36).substring(2, 15);
153
158
 
159
+ console.log('[Storage WS] Converting data to base64...');
154
160
  // Convert Uint8Array to base64
155
161
  // Chunk the data to avoid stack overflow with large files
156
162
  const chunkSize = 8192;
@@ -160,6 +166,7 @@ export class StorageWebSocketClient {
160
166
  binaryString += String.fromCharCode(...chunk);
161
167
  }
162
168
  const base64Data = btoa(binaryString);
169
+ console.log('[Storage WS] Base64 data length:', base64Data.length);
163
170
 
164
171
  const request: StorageRequestMessage = {
165
172
  type: 'storage-request',
@@ -170,8 +177,10 @@ export class StorageWebSocketClient {
170
177
  authorization: options.authorization
171
178
  };
172
179
 
180
+ console.log('[Storage WS] Creating promise for request:', requestId);
173
181
  return new Promise((resolve, reject) => {
174
182
  const timeout = setTimeout(() => {
183
+ console.error('[Storage WS] Request timed out:', requestId);
175
184
  this.pendingRequests.delete(requestId);
176
185
  reject(new Error('Storage request timeout'));
177
186
  }, options.timeout || 30000);
@@ -179,9 +188,11 @@ export class StorageWebSocketClient {
179
188
  this.pendingRequests.set(requestId, { resolve, reject, timeout });
180
189
 
181
190
  try {
191
+ console.log('[Storage WS] Sending request to relay, WS state:', this.ws?.readyState);
182
192
  this.ws!.send(JSON.stringify(request));
183
- console.log('[Storage WS] Sent storage request:', requestId);
193
+ console.log('[Storage WS] Sent storage request:', requestId);
184
194
  } catch (error: any) {
195
+ console.error('[Storage WS] Failed to send request:', error.message);
185
196
  clearTimeout(timeout);
186
197
  this.pendingRequests.delete(requestId);
187
198
  reject(error);