mindcache 3.5.0 → 3.5.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.
@@ -183,6 +183,7 @@ var init_CloudAdapter = __esm({
183
183
  if (!config.baseUrl) {
184
184
  throw new Error("MindCache Cloud: baseUrl is required. Please provide the cloud API URL in your configuration.");
185
185
  }
186
+ this.validateConfig(config);
186
187
  this.setupNetworkDetection();
187
188
  }
188
189
  ws = null;
@@ -198,6 +199,43 @@ var init_CloudAdapter = __esm({
198
199
  handleOnline = null;
199
200
  handleOffline = null;
200
201
  _synced = false;
202
+ /**
203
+ * Validate configuration and warn about common mistakes
204
+ */
205
+ validateConfig(config) {
206
+ const baseUrl = config.baseUrl;
207
+ if (!baseUrl) {
208
+ return;
209
+ }
210
+ console.log("\u2601\uFE0F MindCache Cloud Config:", {
211
+ baseUrl,
212
+ instanceId: config.instanceId,
213
+ hasTokenProvider: !!config.tokenProvider,
214
+ hasApiKey: !!config.apiKey
215
+ });
216
+ try {
217
+ const url = new URL(baseUrl);
218
+ if (url.hostname === "mindcache.dev") {
219
+ console.error(
220
+ '\u26A0\uFE0F MindCache Cloud WARNING: baseUrl is set to "mindcache.dev" but the API is at "api.mindcache.dev".\n Current: ' + baseUrl + "\n Expected: https://api.mindcache.dev\n This will cause WebSocket connection failures (404 errors)."
221
+ );
222
+ }
223
+ if (url.protocol === "ws:" || url.protocol === "wss:") {
224
+ console.warn(
225
+ "\u26A0\uFE0F MindCache Cloud: baseUrl uses WebSocket protocol (" + url.protocol + "). Consider using http:// or https:// - CloudAdapter will handle the WebSocket upgrade automatically."
226
+ );
227
+ }
228
+ if (url.hostname === "localhost" && url.port !== "8787" && url.port !== "3000") {
229
+ console.warn(
230
+ "\u26A0\uFE0F MindCache Cloud: localhost URL detected with non-standard port " + url.port + ". Default MindCache dev server runs on port 8787."
231
+ );
232
+ }
233
+ const wsUrl = baseUrl.replace("https://", "wss://").replace("http://", "ws://");
234
+ console.log("\u2601\uFE0F WebSocket will connect to:", wsUrl + "/sync/" + config.instanceId);
235
+ } catch (e) {
236
+ console.error("\u26A0\uFE0F MindCache Cloud: Invalid baseUrl format:", baseUrl);
237
+ }
238
+ }
201
239
  /** Browser network status - instantly updated via navigator.onLine */
202
240
  get isOnline() {
203
241
  return this._isOnline;
@@ -366,10 +404,12 @@ var init_CloudAdapter = __esm({
366
404
  try {
367
405
  if (typeof event.data === "string") {
368
406
  const msg = JSON.parse(event.data);
407
+ console.log("\u2601\uFE0F CloudAdapter: Received JSON message:", msg.type, msg);
369
408
  if (msg.type === "auth_success") {
370
409
  this._state = "connected";
371
410
  this.reconnectAttempts = 0;
372
411
  this.emit("connected");
412
+ console.log("\u2601\uFE0F Connected to MindCache cloud");
373
413
  } else if (msg.type === "auth_error" || msg.type === "error") {
374
414
  this._state = "error";
375
415
  this.emit("error", new Error(msg.error));
@@ -377,6 +417,7 @@ var init_CloudAdapter = __esm({
377
417
  console.debug("MindCache Cloud: Received message type:", msg.type, msg);
378
418
  }
379
419
  } else {
420
+ console.log("\u2601\uFE0F CloudAdapter: Received binary message, length:", event.data.byteLength);
380
421
  const encoder = encoding.createEncoder();
381
422
  const decoder = decoding.createDecoder(new Uint8Array(event.data));
382
423
  if (this.mindcache) {
@@ -387,6 +428,7 @@ var init_CloudAdapter = __esm({
387
428
  if (!this._synced && (messageType === 1 || messageType === 2)) {
388
429
  this._synced = true;
389
430
  this.emit("synced");
431
+ console.log("\u2601\uFE0F Synced with cloud");
390
432
  }
391
433
  }
392
434
  }