@hissuno/widget 0.1.0 → 0.1.1

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/README.md CHANGED
@@ -51,7 +51,7 @@ function App() {
51
51
  | `theme` | `'light' \| 'dark' \| 'auto'` | `'light'` | Color theme (`auto` follows system preference) |
52
52
  | `userId` | `string` | - | End-user identifier for session tracking |
53
53
  | `userMetadata` | `Record<string, string>` | - | Additional user info (name, email, plan, etc.) |
54
- | `apiUrl` | `string` | `'/api/agent'` | Custom API endpoint URL |
54
+ | `apiUrl` | `string` | `'/api/integrations/widget/chat'` | Custom API endpoint URL |
55
55
  | `title` | `string` | `'Support'` | Chat window title |
56
56
  | `placeholder` | `string` | `'Ask a question...'` | Input field placeholder |
57
57
  | `initialMessage` | `string` | `'Hi! How can I help?'` | First message shown to users |
package/dist/index.d.mts CHANGED
@@ -88,8 +88,7 @@ interface HissunoWidgetProps {
88
88
  */
89
89
  userMetadata?: Record<string, string>;
90
90
  /**
91
- * The URL of your Hissuno API endpoint
92
- * @default "/api/agent"
91
+ * Optional: The URL of your Hissuno API endpoint
93
92
  */
94
93
  apiUrl?: string;
95
94
  /**
@@ -275,7 +274,7 @@ interface UseHissunoChatOptions {
275
274
  projectId: string;
276
275
  /** JWT token for secure widget authentication */
277
276
  widgetToken?: string;
278
- /** Custom API endpoint URL (default: '/api/agent') */
277
+ /** Custom API endpoint URL (default: '/api/integrations/widget/chat') */
279
278
  apiUrl?: string;
280
279
  /** Initial assistant message shown when chat opens */
281
280
  initialMessage?: string;
package/dist/index.d.ts CHANGED
@@ -88,8 +88,7 @@ interface HissunoWidgetProps {
88
88
  */
89
89
  userMetadata?: Record<string, string>;
90
90
  /**
91
- * The URL of your Hissuno API endpoint
92
- * @default "/api/agent"
91
+ * Optional: The URL of your Hissuno API endpoint
93
92
  */
94
93
  apiUrl?: string;
95
94
  /**
@@ -275,7 +274,7 @@ interface UseHissunoChatOptions {
275
274
  projectId: string;
276
275
  /** JWT token for secure widget authentication */
277
276
  widgetToken?: string;
278
- /** Custom API endpoint URL (default: '/api/agent') */
277
+ /** Custom API endpoint URL (default: '/api/integrations/widget/chat') */
279
278
  apiUrl?: string;
280
279
  /** Initial assistant message shown when chat opens */
281
280
  initialMessage?: string;
package/dist/index.js CHANGED
@@ -2012,7 +2012,7 @@ function deleteSessionFromRegistry(projectId, userId, sessionId) {
2012
2012
  function useHissunoChat({
2013
2013
  projectId,
2014
2014
  widgetToken,
2015
- apiUrl = "/api/agent",
2015
+ apiUrl = "/api/integrations/widget/chat",
2016
2016
  initialMessage,
2017
2017
  headers = {},
2018
2018
  userId,
@@ -2171,7 +2171,7 @@ function useHissunoChat({
2171
2171
  }, [apiUrl, projectId, sessionId, connectToStream]);
2172
2172
  (0, import_react4.useEffect)(() => {
2173
2173
  if (sessionClosedRef.current || !sessionId) return;
2174
- const updatesUrl = `${apiUrl}/session/updates?sessionId=${encodeURIComponent(sessionId)}&projectId=${encodeURIComponent(projectId)}`;
2174
+ const updatesUrl = `${apiUrl}/updates?sessionId=${encodeURIComponent(sessionId)}&projectId=${encodeURIComponent(projectId)}`;
2175
2175
  const connectUpdates = () => {
2176
2176
  if (updatesEventSourceRef.current) return;
2177
2177
  const eventSource = new EventSource(updatesUrl);
@@ -2328,7 +2328,7 @@ function useHissunoChat({
2328
2328
  inactivityTimerRef.current = null;
2329
2329
  }
2330
2330
  try {
2331
- await fetch(`${apiUrl}/session/close`, {
2331
+ await fetch(`${apiUrl}/close`, {
2332
2332
  method: "POST",
2333
2333
  headers: {
2334
2334
  "Content-Type": "application/json",
@@ -2343,7 +2343,7 @@ function useHissunoChat({
2343
2343
  }, [sessionId, apiUrl, projectId, headers, onSessionClose]);
2344
2344
  const cancelChat = (0, import_react4.useCallback)(async () => {
2345
2345
  try {
2346
- const cancelUrl = `${apiUrl}/cancel`;
2346
+ const cancelUrl = `${apiUrl}/stream/cancel`;
2347
2347
  const response = await fetch(cancelUrl, {
2348
2348
  method: "POST",
2349
2349
  headers: {
@@ -2389,7 +2389,7 @@ function useHissunoChat({
2389
2389
  (0, import_react4.useEffect)(() => {
2390
2390
  const handleBeforeUnload = () => {
2391
2391
  if (!sessionId || sessionClosedRef.current) return;
2392
- const url = `${apiUrl}/session/close`;
2392
+ const url = `${apiUrl}/close`;
2393
2393
  const data = JSON.stringify({ sessionId, projectId });
2394
2394
  navigator.sendBeacon(url, data);
2395
2395
  };
@@ -2584,7 +2584,7 @@ function useResolvedTheme(theme) {
2584
2584
 
2585
2585
  // src/HissunoWidget.tsx
2586
2586
  var import_jsx_runtime9 = require("react/jsx-runtime");
2587
- var DEFAULT_API_URL = "/api/agent";
2587
+ var DEFAULT_API_URL = "/api/integrations/widget/chat";
2588
2588
  function HissunoWidget({
2589
2589
  projectId,
2590
2590
  widgetToken,
@@ -2619,7 +2619,7 @@ function HissunoWidget({
2619
2619
  blocked,
2620
2620
  loading: settingsLoading,
2621
2621
  error: settingsError
2622
- } = useWidgetSettings(projectId || "", fetchDefaults && !!projectId, apiUrl, widgetToken);
2622
+ } = useWidgetSettings(projectId || "", fetchDefaults && !!projectId, apiUrl ?? DEFAULT_API_URL, widgetToken);
2623
2623
  const resolveTrigger = () => {
2624
2624
  if (propTrigger) return propTrigger;
2625
2625
  if (renderTrigger) return "headless";
@@ -2858,7 +2858,7 @@ function useWidgetSettings(projectId, enabled, apiUrl, widgetToken) {
2858
2858
  }
2859
2859
  setLoading(true);
2860
2860
  setError(false);
2861
- const settingsUrl = `${apiUrl.replace(/\/api\/agent\/?$/, "/api/integrations/widget")}?projectId=${encodeURIComponent(projectId)}`;
2861
+ const settingsUrl = `${apiUrl.replace(/\/chat\/?$/, "")}?projectId=${encodeURIComponent(projectId)}`;
2862
2862
  const controller = new AbortController();
2863
2863
  fetch(settingsUrl, {
2864
2864
  signal: controller.signal
package/dist/index.mjs CHANGED
@@ -1972,7 +1972,7 @@ function deleteSessionFromRegistry(projectId, userId, sessionId) {
1972
1972
  function useHissunoChat({
1973
1973
  projectId,
1974
1974
  widgetToken,
1975
- apiUrl = "/api/agent",
1975
+ apiUrl = "/api/integrations/widget/chat",
1976
1976
  initialMessage,
1977
1977
  headers = {},
1978
1978
  userId,
@@ -2131,7 +2131,7 @@ function useHissunoChat({
2131
2131
  }, [apiUrl, projectId, sessionId, connectToStream]);
2132
2132
  useEffect4(() => {
2133
2133
  if (sessionClosedRef.current || !sessionId) return;
2134
- const updatesUrl = `${apiUrl}/session/updates?sessionId=${encodeURIComponent(sessionId)}&projectId=${encodeURIComponent(projectId)}`;
2134
+ const updatesUrl = `${apiUrl}/updates?sessionId=${encodeURIComponent(sessionId)}&projectId=${encodeURIComponent(projectId)}`;
2135
2135
  const connectUpdates = () => {
2136
2136
  if (updatesEventSourceRef.current) return;
2137
2137
  const eventSource = new EventSource(updatesUrl);
@@ -2288,7 +2288,7 @@ function useHissunoChat({
2288
2288
  inactivityTimerRef.current = null;
2289
2289
  }
2290
2290
  try {
2291
- await fetch(`${apiUrl}/session/close`, {
2291
+ await fetch(`${apiUrl}/close`, {
2292
2292
  method: "POST",
2293
2293
  headers: {
2294
2294
  "Content-Type": "application/json",
@@ -2303,7 +2303,7 @@ function useHissunoChat({
2303
2303
  }, [sessionId, apiUrl, projectId, headers, onSessionClose]);
2304
2304
  const cancelChat = useCallback3(async () => {
2305
2305
  try {
2306
- const cancelUrl = `${apiUrl}/cancel`;
2306
+ const cancelUrl = `${apiUrl}/stream/cancel`;
2307
2307
  const response = await fetch(cancelUrl, {
2308
2308
  method: "POST",
2309
2309
  headers: {
@@ -2349,7 +2349,7 @@ function useHissunoChat({
2349
2349
  useEffect4(() => {
2350
2350
  const handleBeforeUnload = () => {
2351
2351
  if (!sessionId || sessionClosedRef.current) return;
2352
- const url = `${apiUrl}/session/close`;
2352
+ const url = `${apiUrl}/close`;
2353
2353
  const data = JSON.stringify({ sessionId, projectId });
2354
2354
  navigator.sendBeacon(url, data);
2355
2355
  };
@@ -2544,7 +2544,7 @@ function useResolvedTheme(theme) {
2544
2544
 
2545
2545
  // src/HissunoWidget.tsx
2546
2546
  import { jsx as jsx9, jsxs as jsxs8 } from "react/jsx-runtime";
2547
- var DEFAULT_API_URL = "/api/agent";
2547
+ var DEFAULT_API_URL = "/api/integrations/widget/chat";
2548
2548
  function HissunoWidget({
2549
2549
  projectId,
2550
2550
  widgetToken,
@@ -2579,7 +2579,7 @@ function HissunoWidget({
2579
2579
  blocked,
2580
2580
  loading: settingsLoading,
2581
2581
  error: settingsError
2582
- } = useWidgetSettings(projectId || "", fetchDefaults && !!projectId, apiUrl, widgetToken);
2582
+ } = useWidgetSettings(projectId || "", fetchDefaults && !!projectId, apiUrl ?? DEFAULT_API_URL, widgetToken);
2583
2583
  const resolveTrigger = () => {
2584
2584
  if (propTrigger) return propTrigger;
2585
2585
  if (renderTrigger) return "headless";
@@ -2818,7 +2818,7 @@ function useWidgetSettings(projectId, enabled, apiUrl, widgetToken) {
2818
2818
  }
2819
2819
  setLoading(true);
2820
2820
  setError(false);
2821
- const settingsUrl = `${apiUrl.replace(/\/api\/agent\/?$/, "/api/integrations/widget")}?projectId=${encodeURIComponent(projectId)}`;
2821
+ const settingsUrl = `${apiUrl.replace(/\/chat\/?$/, "")}?projectId=${encodeURIComponent(projectId)}`;
2822
2822
  const controller = new AbortController();
2823
2823
  fetch(settingsUrl, {
2824
2824
  signal: controller.signal
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hissuno/widget",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Embeddable AI-powered support chat widget for Hissuno platform",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",