mindcache 3.5.1 → 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.
package/dist/index.mjs CHANGED
@@ -184,6 +184,7 @@ var init_CloudAdapter = __esm({
184
184
  if (!config.baseUrl) {
185
185
  throw new Error("MindCache Cloud: baseUrl is required. Please provide the cloud API URL in your configuration.");
186
186
  }
187
+ this.validateConfig(config);
187
188
  this.setupNetworkDetection();
188
189
  }
189
190
  ws = null;
@@ -199,6 +200,43 @@ var init_CloudAdapter = __esm({
199
200
  handleOnline = null;
200
201
  handleOffline = null;
201
202
  _synced = false;
203
+ /**
204
+ * Validate configuration and warn about common mistakes
205
+ */
206
+ validateConfig(config) {
207
+ const baseUrl = config.baseUrl;
208
+ if (!baseUrl) {
209
+ return;
210
+ }
211
+ console.log("\u2601\uFE0F MindCache Cloud Config:", {
212
+ baseUrl,
213
+ instanceId: config.instanceId,
214
+ hasTokenProvider: !!config.tokenProvider,
215
+ hasApiKey: !!config.apiKey
216
+ });
217
+ try {
218
+ const url = new URL(baseUrl);
219
+ if (url.hostname === "mindcache.dev") {
220
+ console.error(
221
+ '\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)."
222
+ );
223
+ }
224
+ if (url.protocol === "ws:" || url.protocol === "wss:") {
225
+ console.warn(
226
+ "\u26A0\uFE0F MindCache Cloud: baseUrl uses WebSocket protocol (" + url.protocol + "). Consider using http:// or https:// - CloudAdapter will handle the WebSocket upgrade automatically."
227
+ );
228
+ }
229
+ if (url.hostname === "localhost" && url.port !== "8787" && url.port !== "3000") {
230
+ console.warn(
231
+ "\u26A0\uFE0F MindCache Cloud: localhost URL detected with non-standard port " + url.port + ". Default MindCache dev server runs on port 8787."
232
+ );
233
+ }
234
+ const wsUrl = baseUrl.replace("https://", "wss://").replace("http://", "ws://");
235
+ console.log("\u2601\uFE0F WebSocket will connect to:", wsUrl + "/sync/" + config.instanceId);
236
+ } catch (e) {
237
+ console.error("\u26A0\uFE0F MindCache Cloud: Invalid baseUrl format:", baseUrl);
238
+ }
239
+ }
202
240
  /** Browser network status - instantly updated via navigator.onLine */
203
241
  get isOnline() {
204
242
  return this._isOnline;