@deepfrog/pangents-widget 2.2.0 → 2.2.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.
@@ -6,5 +6,5 @@
6
6
  }
7
7
  } catch (error) {}
8
8
  })();
9
- "use strict";require("react/jsx-runtime"),require("react");const e=require("./widget-embed-BPoilyw_.cjs.js");module.exports=e.Chatbot;
9
+ "use strict";require("react/jsx-runtime"),require("react");const e=require("./widget-embed-DCSN_j6Y.cjs.js");module.exports=e.Chatbot;
10
10
  //# sourceMappingURL=widget-embed.cjs.js.map
@@ -8,7 +8,7 @@
8
8
  })();
9
9
  import "react/jsx-runtime";
10
10
  import "react";
11
- import { C } from "./widget-embed-CtD27t5y.es.js";
11
+ import { C } from "./widget-embed-DzLM7DN8.es.js";
12
12
  export {
13
13
  C as default
14
14
  };
package/dist/widget.js CHANGED
@@ -23700,7 +23700,7 @@ class EnhancedErrorHandler {
23700
23700
  // 30 seconds
23701
23701
  constructor() {
23702
23702
  __publicField(this, "errorQueue", []);
23703
- __publicField(this, "isOnline", navigator.onLine);
23703
+ __publicField(this, "isOnline", typeof navigator !== "undefined" ? navigator.onLine : true);
23704
23704
  __publicField(this, "maxQueueSize", 50);
23705
23705
  // Reduced from 100
23706
23706
  __publicField(this, "retryAttempts", 2);
@@ -23716,6 +23716,7 @@ class EnhancedErrorHandler {
23716
23716
  }
23717
23717
  // Setup event listeners for online/offline status
23718
23718
  setupEventListeners() {
23719
+ if (typeof window === "undefined") return;
23719
23720
  window.addEventListener("online", () => {
23720
23721
  this.isOnline = true;
23721
23722
  this.flushErrorQueue();
@@ -23742,10 +23743,6 @@ class EnhancedErrorHandler {
23742
23743
  console.warn("[Enhanced Error Handler] No API key provided for validation");
23743
23744
  return false;
23744
23745
  }
23745
- if (!apiKey.startsWith("pangents_wk_") || apiKey.length < 20) {
23746
- console.warn("[Enhanced Error Handler] Invalid API key format");
23747
- return false;
23748
- }
23749
23746
  return true;
23750
23747
  }
23751
23748
  // Generate error fingerprint for duplicate detection
@@ -23782,8 +23779,8 @@ class EnhancedErrorHandler {
23782
23779
  action: (context == null ? void 0 : context.action) || "Unknown",
23783
23780
  userId: context == null ? void 0 : context.userId,
23784
23781
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
23785
- userAgent: navigator.userAgent,
23786
- url: window.location.href,
23782
+ userAgent: typeof navigator !== "undefined" ? navigator.userAgent : "server",
23783
+ url: typeof window !== "undefined" ? window.location.href : "",
23787
23784
  apiKey: (context == null ? void 0 : context.apiKey) ? context.apiKey.substring(0, 20) + "..." : void 0
23788
23785
  };
23789
23786
  const severity = this.determineSeverity(apiError);
@@ -23816,8 +23813,8 @@ class EnhancedErrorHandler {
23816
23813
  action: (context == null ? void 0 : context.action) || "Runtime",
23817
23814
  userId: context == null ? void 0 : context.userId,
23818
23815
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
23819
- userAgent: navigator.userAgent,
23820
- url: window.location.href
23816
+ userAgent: typeof navigator !== "undefined" ? navigator.userAgent : "server",
23817
+ url: typeof window !== "undefined" ? window.location.href : ""
23821
23818
  };
23822
23819
  const errorReport = {
23823
23820
  error: apiError,
@@ -23896,9 +23893,9 @@ class EnhancedErrorHandler {
23896
23893
  await api2.post("/errors/report", {
23897
23894
  errors: errorsToSend,
23898
23895
  clientInfo: {
23899
- userAgent: navigator.userAgent,
23896
+ userAgent: typeof navigator !== "undefined" ? navigator.userAgent : "server",
23900
23897
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
23901
- url: window.location.href,
23898
+ url: typeof window !== "undefined" ? window.location.href : "",
23902
23899
  circuitBreakerState: this.circuitBreaker.getState(),
23903
23900
  remainingRateLimit: this.rateLimiter.getRemainingRequests()
23904
23901
  }
@@ -23933,15 +23930,17 @@ class EnhancedErrorHandler {
23933
23930
  // Show user notification based on error severity
23934
23931
  showUserNotification(error, severity) {
23935
23932
  const message = this.getUserFriendlyMessage(error);
23936
- window.dispatchEvent(new CustomEvent("error:notification", {
23937
- detail: {
23938
- message,
23939
- severity,
23940
- error,
23941
- timestamp: (/* @__PURE__ */ new Date()).toISOString(),
23942
- canRetry: this.canRetryError(error)
23943
- }
23944
- }));
23933
+ if (typeof window !== "undefined") {
23934
+ window.dispatchEvent(new CustomEvent("error:notification", {
23935
+ detail: {
23936
+ message,
23937
+ severity,
23938
+ error,
23939
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
23940
+ canRetry: this.canRetryError(error)
23941
+ }
23942
+ }));
23943
+ }
23945
23944
  }
23946
23945
  // Determine if error can be retried
23947
23946
  canRetryError(error) {
@@ -35163,14 +35162,14 @@ class ApiKeyValidator {
35163
35162
  if (!this.validateApiKeyFormat(sanitized)) {
35164
35163
  return {
35165
35164
  isValid: false,
35166
- error: "Invalid API key format. Expected format: pangents_wk_[alphanumeric characters]"
35165
+ error: "Invalid API key format."
35167
35166
  };
35168
35167
  }
35169
35168
  return { isValid: true };
35170
35169
  } catch (error) {
35171
35170
  return {
35172
35171
  isValid: false,
35173
- error: error instanceof Error ? error.message : "Invalid API key"
35172
+ error: error instanceof Error ? error.message : "Invalid API key format."
35174
35173
  };
35175
35174
  }
35176
35175
  }
@@ -36225,8 +36224,11 @@ function WidgetContent() {
36225
36224
  });
36226
36225
  }
36227
36226
  };
36227
+ const prevAuthRef = reactExports.useRef({});
36228
36228
  reactExports.useEffect(() => {
36229
- validateKey();
36229
+ const force = prevAuthRef.current.apiKey !== apiKey || prevAuthRef.current.tenantId !== tenantId;
36230
+ validateKey(force);
36231
+ prevAuthRef.current = { apiKey, tenantId };
36230
36232
  }, [apiKey, tenantId]);
36231
36233
  const handleRetry = () => {
36232
36234
  validateKey(true);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@deepfrog/pangents-widget",
3
3
  "private": false,
4
- "version": "2.2.0",
4
+ "version": "2.2.2",
5
5
  "description": "Pangents AI - Embeddable AI widget for web applications",
6
6
  "type": "module",
7
7
  "main": "dist/index.cjs.js",