@evelan/jexity-widget 0.3.0 → 0.4.0

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.
Files changed (34) hide show
  1. package/dist/index.mjs +4503 -877
  2. package/dist/index.mjs.map +1 -1
  3. package/dist/types/features/chat/components/ChatInput.d.ts +13 -2
  4. package/dist/types/features/chat/components/ChatInput.d.ts.map +1 -1
  5. package/dist/types/features/chat/components/ChatScreen.d.ts +6 -3
  6. package/dist/types/features/chat/components/ChatScreen.d.ts.map +1 -1
  7. package/dist/types/features/chat/components/MessageList.d.ts +9 -2
  8. package/dist/types/features/chat/components/MessageList.d.ts.map +1 -1
  9. package/dist/types/features/chat/hooks/useConvexSession.d.ts +22 -0
  10. package/dist/types/features/chat/hooks/useConvexSession.d.ts.map +1 -0
  11. package/dist/types/features/chat/lib/chat.d.ts +1 -11
  12. package/dist/types/features/chat/lib/chat.d.ts.map +1 -1
  13. package/dist/types/lib/convex-url.d.ts +18 -0
  14. package/dist/types/lib/convex-url.d.ts.map +1 -0
  15. package/dist/types/lib/widget-config.d.ts +61 -0
  16. package/dist/types/lib/widget-config.d.ts.map +1 -0
  17. package/dist/types/module/screens/ScreenRouter.d.ts +2 -1
  18. package/dist/types/module/screens/ScreenRouter.d.ts.map +1 -1
  19. package/dist/types/module/shell/{AppShell.d.ts → WidgetShell.d.ts} +3 -3
  20. package/dist/types/module/shell/WidgetShell.d.ts.map +1 -0
  21. package/dist/types/module/shell/hooks/usePreviewBridge.d.ts +16 -0
  22. package/dist/types/module/shell/hooks/usePreviewBridge.d.ts.map +1 -0
  23. package/dist/types/module/shell/hooks/useRemoteConfig.d.ts +13 -0
  24. package/dist/types/module/shell/hooks/useRemoteConfig.d.ts.map +1 -0
  25. package/dist/types/module/shell/mount.d.ts +20 -9
  26. package/dist/types/module/shell/mount.d.ts.map +1 -1
  27. package/dist/types/module/shell/shell.state.d.ts +12 -0
  28. package/dist/types/module/shell/shell.state.d.ts.map +1 -1
  29. package/dist/types/module/shell/widget-instance.d.ts +27 -0
  30. package/dist/types/module/shell/widget-instance.d.ts.map +1 -0
  31. package/dist/widget.js +2 -1
  32. package/dist/widget.js.map +1 -1
  33. package/package.json +3 -1
  34. package/dist/types/module/shell/AppShell.d.ts.map +0 -1
@@ -1,3 +1,14 @@
1
- /** Text input + send button. Demo mode: echoes user messages with a 1s bot delay. */
2
- export declare function ChatInput(): import("preact").JSX.Element;
1
+ import type { Id } from '@repo/backend/convex/_generated/dataModel';
2
+ interface ChatInputProps {
3
+ sessionId: Id<'contactSessions'> | null;
4
+ visitorId: string | null;
5
+ isLoading: boolean;
6
+ ensureSession: () => Promise<{
7
+ sessionId: Id<'contactSessions'>;
8
+ visitorId: string;
9
+ } | null>;
10
+ }
11
+ /** Text input + send button. Creates session lazily on first send. */
12
+ export declare function ChatInput({ sessionId, visitorId, isLoading, ensureSession }: ChatInputProps): import("preact").JSX.Element;
13
+ export {};
3
14
  //# sourceMappingURL=ChatInput.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ChatInput.d.ts","sourceRoot":"","sources":["../../../../../src/features/chat/components/ChatInput.tsx"],"names":[],"mappings":"AAMA,qFAAqF;AACrF,wBAAgB,SAAS,iCAkDxB"}
1
+ {"version":3,"file":"ChatInput.d.ts","sourceRoot":"","sources":["../../../../../src/features/chat/components/ChatInput.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,2CAA2C,CAAA;AAEnE,UAAU,cAAc;IACtB,SAAS,EAAE,EAAE,CAAC,iBAAiB,CAAC,GAAG,IAAI,CAAA;IACvC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAA;IACxB,SAAS,EAAE,OAAO,CAAA;IAClB,aAAa,EAAE,MAAM,OAAO,CAAC;QAAE,SAAS,EAAE,EAAE,CAAC,iBAAiB,CAAC,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC,CAAA;CAC7F;AAED,sEAAsE;AACtE,wBAAgB,SAAS,CAAC,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,aAAa,EAAE,EAAE,cAAc,gCAgD3F"}
@@ -1,8 +1,11 @@
1
1
  interface ChatScreenProps {
2
- /** Initial bot greeting — seeded once when chat is first opened. */
3
2
  greeting: string;
3
+ orgSlug: string;
4
4
  }
5
- /** Full chat conversation screen — orchestrates message list and input. */
6
- export declare function ChatScreen({ greeting }: ChatScreenProps): import("preact").JSX.Element;
5
+ /**
6
+ * Chat screen — renders immediately with greeting + input.
7
+ * Session is created lazily on first send (no loading spinner on open).
8
+ */
9
+ export declare function ChatScreen({ greeting, orgSlug }: ChatScreenProps): import("preact").JSX.Element;
7
10
  export {};
8
11
  //# sourceMappingURL=ChatScreen.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ChatScreen.d.ts","sourceRoot":"","sources":["../../../../../src/features/chat/components/ChatScreen.tsx"],"names":[],"mappings":"AAKA,UAAU,eAAe;IACvB,oEAAoE;IACpE,QAAQ,EAAE,MAAM,CAAA;CACjB;AAED,2EAA2E;AAC3E,wBAAgB,UAAU,CAAC,EAAE,QAAQ,EAAE,EAAE,eAAe,gCAevD"}
1
+ {"version":3,"file":"ChatScreen.d.ts","sourceRoot":"","sources":["../../../../../src/features/chat/components/ChatScreen.tsx"],"names":[],"mappings":"AAIA,UAAU,eAAe;IACvB,QAAQ,EAAE,MAAM,CAAA;IAChB,OAAO,EAAE,MAAM,CAAA;CAChB;AAED;;;GAGG;AACH,wBAAgB,UAAU,CAAC,EAAE,QAAQ,EAAE,OAAO,EAAE,EAAE,eAAe,gCAkBhE"}
@@ -1,3 +1,10 @@
1
- /** Scrollable message area auto-scrolls to the latest message. */
2
- export declare function MessageList(): import("preact").JSX.Element;
1
+ import type { Id } from '@repo/backend/convex/_generated/dataModel';
2
+ interface MessageListProps {
3
+ sessionId: Id<'contactSessions'> | null;
4
+ visitorId: string | null;
5
+ greeting: string;
6
+ }
7
+ /** Scrollable message area — subscribes to Convex once a session exists. */
8
+ export declare function MessageList({ sessionId, visitorId, greeting }: MessageListProps): import("preact").JSX.Element;
9
+ export {};
3
10
  //# sourceMappingURL=MessageList.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"MessageList.d.ts","sourceRoot":"","sources":["../../../../../src/features/chat/components/MessageList.tsx"],"names":[],"mappings":"AAMA,oEAAoE;AACpE,wBAAgB,WAAW,iCAkB1B"}
1
+ {"version":3,"file":"MessageList.d.ts","sourceRoot":"","sources":["../../../../../src/features/chat/components/MessageList.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,EAAE,EAAO,MAAM,2CAA2C,CAAA;AAExE,UAAU,gBAAgB;IACxB,SAAS,EAAE,EAAE,CAAC,iBAAiB,CAAC,GAAG,IAAI,CAAA;IACvC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAA;IACxB,QAAQ,EAAE,MAAM,CAAA;CACjB;AAED,4EAA4E;AAC5E,wBAAgB,WAAW,CAAC,EAAE,SAAS,EAAE,SAAS,EAAE,QAAQ,EAAE,EAAE,gBAAgB,gCA8B/E"}
@@ -0,0 +1,22 @@
1
+ import type { Id } from '@repo/backend/convex/_generated/dataModel';
2
+ interface SessionResult {
3
+ sessionId: Id<'contactSessions'>;
4
+ visitorId: string;
5
+ }
6
+ interface ConvexSession {
7
+ sessionId: Id<'contactSessions'> | null;
8
+ visitorId: string | null;
9
+ isLoading: boolean;
10
+ /** Call before the first send — creates/resumes a Convex session lazily. */
11
+ ensureSession: () => Promise<SessionResult | null>;
12
+ }
13
+ /**
14
+ * Lazy session hook — does NOT create a session on mount.
15
+ * Call `ensureSession()` when the visitor sends their first message.
16
+ *
17
+ * Uses a ref to track the resolved session, avoiding stale closures
18
+ * and preventing duplicate mutations on rapid double-sends.
19
+ */
20
+ export declare function useConvexSession(orgSlug: string): ConvexSession;
21
+ export {};
22
+ //# sourceMappingURL=useConvexSession.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useConvexSession.d.ts","sourceRoot":"","sources":["../../../../../src/features/chat/hooks/useConvexSession.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,2CAA2C,CAAA;AAEnE,UAAU,aAAa;IACrB,SAAS,EAAE,EAAE,CAAC,iBAAiB,CAAC,CAAA;IAChC,SAAS,EAAE,MAAM,CAAA;CAClB;AAED,UAAU,aAAa;IACrB,SAAS,EAAE,EAAE,CAAC,iBAAiB,CAAC,GAAG,IAAI,CAAA;IACvC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAA;IACxB,SAAS,EAAE,OAAO,CAAA;IAClB,4EAA4E;IAC5E,aAAa,EAAE,MAAM,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC,CAAA;CACnD;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,aAAa,CAmC/D"}
@@ -1,13 +1,3 @@
1
- export interface Message {
2
- id: number;
3
- text: string;
4
- sender: 'user' | 'bot';
5
- }
6
- /** Demo messages — replaced in Phase 2 with Convex subscription */
7
- export declare const messages: import("@preact/signals").Signal<Message[]>;
8
- export declare const isTyping: import("@preact/signals").Signal<boolean>;
9
- /** Convex session ID — populated in Phase 2 */
10
- export declare const sessionId: import("@preact/signals").Signal<string | null>;
11
- /** Reset all chat state for a new conversation. */
1
+ /** Reset chat state for a new conversation. */
12
2
  export declare function clearChat(): void;
13
3
  //# sourceMappingURL=chat.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"chat.d.ts","sourceRoot":"","sources":["../../../../../src/features/chat/lib/chat.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,OAAO;IACtB,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,MAAM,GAAG,KAAK,CAAA;CACvB;AAED,mEAAmE;AACnE,eAAO,MAAM,QAAQ,6CAAwB,CAAA;AAC7C,eAAO,MAAM,QAAQ,2CAAgB,CAAA;AACrC,+CAA+C;AAC/C,eAAO,MAAM,SAAS,iDAA8B,CAAA;AAEpD,mDAAmD;AACnD,wBAAgB,SAAS,IAAI,IAAI,CAIhC"}
1
+ {"version":3,"file":"chat.d.ts","sourceRoot":"","sources":["../../../../../src/features/chat/lib/chat.ts"],"names":[],"mappings":"AAAA,+CAA+C;AAC/C,wBAAgB,SAAS,IAAI,IAAI,CAGhC"}
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Convex URL normalisation helpers.
3
+ *
4
+ * VITE_CONVEX_URL accepts either Convex URL format:
5
+ * https://<name>.convex.cloud — WebSocket / REST API base
6
+ * https://<name>.convex.site — HTTP Actions base
7
+ *
8
+ * These helpers normalise whichever format is provided to the one needed
9
+ * by each consumer, so only a single env var is required.
10
+ *
11
+ * The \b word-boundary in each regex prevents partial matches if the
12
+ * hostname ever contains the pattern mid-string.
13
+ */
14
+ /** Returns the .convex.cloud URL regardless of which format is provided. */
15
+ export declare function toConvexCloudUrl(url: string): string;
16
+ /** Returns the .convex.site URL regardless of which format is provided. */
17
+ export declare function toConvexSiteUrl(url: string): string;
18
+ //# sourceMappingURL=convex-url.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"convex-url.d.ts","sourceRoot":"","sources":["../../../src/lib/convex-url.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,4EAA4E;AAC5E,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAEpD;AAED,2EAA2E;AAC3E,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAEnD"}
@@ -0,0 +1,61 @@
1
+ import type { JexityChatOptions } from '../types';
2
+ import type { WidgetLocale } from '../i18n/index';
3
+ /**
4
+ * Fully-resolved widget configuration — produced by merging embed-script
5
+ * options with the Convex remote config (embed options take precedence).
6
+ *
7
+ * All fields with defaults are non-optional so consumers never need ?? chains.
8
+ */
9
+ export interface ResolvedWidgetConfig {
10
+ title: string;
11
+ greeting: string;
12
+ locale: string | undefined;
13
+ position: JexityChatOptions['position'];
14
+ colorScheme: JexityChatOptions['colorScheme'];
15
+ hideBranding: boolean;
16
+ triggerIcon: NonNullable<JexityChatOptions['triggerIcon']>;
17
+ triggerRadius: NonNullable<JexityChatOptions['triggerRadius']>;
18
+ triggerLabel: string;
19
+ primaryColor: string | undefined;
20
+ accentColor: string | undefined;
21
+ fontFamily: string | undefined;
22
+ fontSize: number | undefined;
23
+ borderRadius: string | undefined;
24
+ windowWidth: number | undefined;
25
+ windowHeight: number | undefined;
26
+ }
27
+ /**
28
+ * Merges embed-script options with the remote Convex config.
29
+ * Embed-script values always take precedence; remote config fills the gaps.
30
+ *
31
+ * Centralising the merge here means AppShell never needs ?? chains,
32
+ * and any new remote config field has exactly one place to wire it in.
33
+ */
34
+ export declare function mergeWidgetConfig(options: JexityChatOptions, remote: RemoteConfig | null): ResolvedWidgetConfig;
35
+ /**
36
+ * Shape of the response from the public GET /widget/config endpoint.
37
+ *
38
+ * Uses Pick<JexityChatOptions, ...> so that field types stay in sync with
39
+ * the embed-script options automatically — no need to duplicate type definitions.
40
+ *
41
+ * Extra fields (primaryColor, title, welcomeMessage) come from the database
42
+ * and have no equivalent in JexityChatOptions, so they're defined separately.
43
+ */
44
+ export type RemoteConfig = Pick<JexityChatOptions, 'position' | 'colorScheme' | 'hideBranding' | 'accentColor' | 'fontFamily' | 'fontSize' | 'borderRadius' | 'windowWidth' | 'windowHeight' | 'triggerIcon' | 'triggerRadius' | 'triggerLabel'> & {
45
+ primaryColor: string;
46
+ title: string;
47
+ welcomeMessage: string;
48
+ locale?: WidgetLocale;
49
+ };
50
+ /**
51
+ * Fetches the widget's remote configuration from the Convex HTTP endpoint.
52
+ *
53
+ * @param siteUrl The .convex.site base URL (HTTP Actions domain).
54
+ * @param orgSlug The organisation slug embedded in the script tag.
55
+ * @param signal AbortSignal to cancel the request on component unmount.
56
+ *
57
+ * @returns The parsed config, or null if the org is not found (404) or the
58
+ * server returns any non-OK status.
59
+ */
60
+ export declare function fetchRemoteConfig(siteUrl: string, orgSlug: string, signal: AbortSignal): Promise<RemoteConfig | null>;
61
+ //# sourceMappingURL=widget-config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"widget-config.d.ts","sourceRoot":"","sources":["../../../src/lib/widget-config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAA;AACjD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAEjD;;;;;GAKG;AACH,MAAM,WAAW,oBAAoB;IAEnC,KAAK,EAAE,MAAM,CAAA;IACb,QAAQ,EAAE,MAAM,CAAA;IAChB,MAAM,EAAE,MAAM,GAAG,SAAS,CAAA;IAE1B,QAAQ,EAAE,iBAAiB,CAAC,UAAU,CAAC,CAAA;IACvC,WAAW,EAAE,iBAAiB,CAAC,aAAa,CAAC,CAAA;IAC7C,YAAY,EAAE,OAAO,CAAA;IAErB,WAAW,EAAE,WAAW,CAAC,iBAAiB,CAAC,aAAa,CAAC,CAAC,CAAA;IAC1D,aAAa,EAAE,WAAW,CAAC,iBAAiB,CAAC,eAAe,CAAC,CAAC,CAAA;IAC9D,YAAY,EAAE,MAAM,CAAA;IAEpB,YAAY,EAAE,MAAM,GAAG,SAAS,CAAA;IAChC,WAAW,EAAE,MAAM,GAAG,SAAS,CAAA;IAC/B,UAAU,EAAE,MAAM,GAAG,SAAS,CAAA;IAC9B,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAA;IAC5B,YAAY,EAAE,MAAM,GAAG,SAAS,CAAA;IAChC,WAAW,EAAE,MAAM,GAAG,SAAS,CAAA;IAC/B,YAAY,EAAE,MAAM,GAAG,SAAS,CAAA;CACjC;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE,iBAAiB,EAC1B,MAAM,EAAE,YAAY,GAAG,IAAI,GAC1B,oBAAoB,CAoBtB;AAED;;;;;;;;GAQG;AACH,MAAM,MAAM,YAAY,GAAG,IAAI,CAAC,iBAAiB,EAC7C,UAAU,GAAG,aAAa,GAAG,cAAc,GAC3C,aAAa,GAAG,YAAY,GAAG,UAAU,GACzC,cAAc,GAAG,aAAa,GAAG,cAAc,GAC/C,aAAa,GAAG,eAAe,GAAG,cAAc,CACnD,GAAG;IACF,YAAY,EAAE,MAAM,CAAA;IACpB,KAAK,EAAE,MAAM,CAAA;IACb,cAAc,EAAE,MAAM,CAAA;IACtB,MAAM,CAAC,EAAE,YAAY,CAAA;CACtB,CAAA;AAED;;;;;;;;;GASG;AACH,wBAAsB,iBAAiB,CACrC,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,WAAW,GAClB,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC,CAS9B"}
@@ -1,8 +1,9 @@
1
1
  interface ScreenRouterProps {
2
2
  greeting: string;
3
3
  title: string;
4
+ orgSlug: string;
4
5
  }
5
6
  /** Renders only the active screen. No animation — add transitions later once routing is stable. */
6
- export declare function ScreenRouter({ greeting, title }: ScreenRouterProps): import("preact").JSX.Element;
7
+ export declare function ScreenRouter({ greeting, title, orgSlug }: ScreenRouterProps): import("preact").JSX.Element;
7
8
  export {};
8
9
  //# sourceMappingURL=ScreenRouter.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ScreenRouter.d.ts","sourceRoot":"","sources":["../../../../src/module/screens/ScreenRouter.tsx"],"names":[],"mappings":"AAWA,UAAU,iBAAiB;IACzB,QAAQ,EAAE,MAAM,CAAA;IAChB,KAAK,EAAE,MAAM,CAAA;CACd;AAED,mGAAmG;AACnG,wBAAgB,YAAY,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,EAAE,iBAAiB,gCAqClE"}
1
+ {"version":3,"file":"ScreenRouter.d.ts","sourceRoot":"","sources":["../../../../src/module/screens/ScreenRouter.tsx"],"names":[],"mappings":"AAWA,UAAU,iBAAiB;IACzB,QAAQ,EAAE,MAAM,CAAA;IAChB,KAAK,EAAE,MAAM,CAAA;IACb,OAAO,EAAE,MAAM,CAAA;CAChB;AAED,mGAAmG;AACnG,wBAAgB,YAAY,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,iBAAiB,gCAqC3E"}
@@ -1,8 +1,8 @@
1
1
  import type { JexityChatOptions } from '../../types';
2
- interface AppShellProps {
2
+ interface WidgetShellProps {
3
3
  options: JexityChatOptions;
4
4
  }
5
5
  /** Inner Preact component tree — rendered inside the shadow root container. */
6
- export declare function AppShell({ options }: AppShellProps): import("preact").JSX.Element;
6
+ export declare function WidgetShell({ options }: WidgetShellProps): import("preact").JSX.Element;
7
7
  export {};
8
- //# sourceMappingURL=AppShell.d.ts.map
8
+ //# sourceMappingURL=WidgetShell.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WidgetShell.d.ts","sourceRoot":"","sources":["../../../../src/module/shell/WidgetShell.tsx"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAA;AAEpD,UAAU,gBAAgB;IACxB,OAAO,EAAE,iBAAiB,CAAA;CAC3B;AAED,+EAA+E;AAC/E,wBAAgB,WAAW,CAAC,EAAE,OAAO,EAAE,EAAE,gBAAgB,gCA2DxD"}
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Listens for postMessage config updates sent from the dashboard preview iframe.
3
+ *
4
+ * This is a playground/dashboard-only concern — the `parentOrigin` option is
5
+ * only set when the widget is embedded inside the dashboard preview panel.
6
+ * Production embeds on customer websites never send this message type.
7
+ *
8
+ * Message shape:
9
+ * { type: 'jexity:config', payload: { locale?: string } }
10
+ *
11
+ * Incoming locale strings are passed through `resolveWidgetLocale` so the full
12
+ * priority chain (config → localStorage → browser → default) is respected,
13
+ * and no type assertions are needed.
14
+ */
15
+ export declare function usePreviewBridge(parentOrigin: string | undefined): void;
16
+ //# sourceMappingURL=usePreviewBridge.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"usePreviewBridge.d.ts","sourceRoot":"","sources":["../../../../../src/module/shell/hooks/usePreviewBridge.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;GAaG;AACH,wBAAgB,gBAAgB,CAAC,YAAY,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,CAkBvE"}
@@ -0,0 +1,13 @@
1
+ import { type RemoteConfig } from '../../../lib/widget-config';
2
+ /**
3
+ * Fetches the widget's remote config from Convex for the given orgSlug.
4
+ *
5
+ * - Returns null on first render, then updates once the fetch resolves.
6
+ * - Clears stale config immediately when orgSlug changes (prevents flashing
7
+ * the previous org's title/colors while the new fetch is in flight).
8
+ * - Aborts the in-flight request if orgSlug changes or the hook unmounts.
9
+ * - Silent fail: any error (network, 404, parse) resolves to null so the
10
+ * widget still renders using embed-script options as a fallback.
11
+ */
12
+ export declare function useRemoteConfig(orgSlug: string): RemoteConfig | null;
13
+ //# sourceMappingURL=useRemoteConfig.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useRemoteConfig.d.ts","sourceRoot":"","sources":["../../../../../src/module/shell/hooks/useRemoteConfig.ts"],"names":[],"mappings":"AAEA,OAAO,EAAqB,KAAK,YAAY,EAAE,MAAM,4BAA4B,CAAA;AAEjF;;;;;;;;;GASG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,YAAY,GAAG,IAAI,CAkCpE"}
@@ -1,13 +1,24 @@
1
- import type { JexityChatOptions, JexityChatInstance } from '../../types';
1
+ import type { JexityChatOptions } from '../../types';
2
2
  /**
3
- * Mounts the widget into a Shadow DOM on the given host element.
4
- * Reuses an existing shadow root on re-mount (avoids "already has a shadow root" error
5
- * when the dev playground re-mounts on options change).
3
+ * LOW-LEVEL: Renders the widget into a Shadow DOM on the given host element.
4
+ *
5
+ * Why Shadow DOM?
6
+ * The widget is injected into customer websites that have their own CSS.
7
+ * Shadow DOM creates an isolated DOM subtree — styles on the host page
8
+ * cannot leak in, and widget styles cannot leak out.
9
+ *
10
+ * Why injectStyles?
11
+ * Stylesheets do not cross Shadow DOM boundaries automatically.
12
+ * We must explicitly stamp the widget's CSS into the shadow root.
13
+ *
14
+ * Why reuse the existing shadow root?
15
+ * Calling attachShadow() on an element that already has a shadow root
16
+ * throws "already has a shadow root". The Studio playground re-mounts
17
+ * on every config change, so we reuse the root instead of re-creating it.
18
+ *
19
+ * Returns a shutdown function that unmounts the Preact tree and resets state.
20
+ * Called by createInstance() — entry points (esm.ts, iife.ts) should not
21
+ * call this directly; use createInstance() instead.
6
22
  */
7
23
  export declare function mountWidget(hostEl: HTMLElement, options: JexityChatOptions): () => void;
8
- /**
9
- * Creates a JexityChatInstance wrapping mountWidget.
10
- * Used by entry points (iife.ts, esm.ts).
11
- */
12
- export declare function createInstance(mountEl: HTMLElement, options: JexityChatOptions, onRemove?: () => void): JexityChatInstance;
13
24
  //# sourceMappingURL=mount.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"mount.d.ts","sourceRoot":"","sources":["../../../../src/module/shell/mount.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAExE;;;;GAIG;AACH,wBAAgB,WAAW,CACzB,MAAM,EAAE,WAAW,EACnB,OAAO,EAAE,iBAAiB,GACzB,MAAM,IAAI,CAmBZ;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAC5B,OAAO,EAAE,WAAW,EACpB,OAAO,EAAE,iBAAiB,EAC1B,QAAQ,CAAC,EAAE,MAAM,IAAI,GACpB,kBAAkB,CA0BpB"}
1
+ {"version":3,"file":"mount.d.ts","sourceRoot":"","sources":["../../../../src/module/shell/mount.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAA;AASpD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,WAAW,CACzB,MAAM,EAAE,WAAW,EACnB,OAAO,EAAE,iBAAiB,GACzB,MAAM,IAAI,CA0BZ"}
@@ -1,2 +1,14 @@
1
+ /**
2
+ * Whether the chat window is currently open.
3
+ *
4
+ * Lives in its own file because it is read and written across multiple layers:
5
+ * - widget-instance.ts open() / close() / toggle() / subscribe()
6
+ * - mount.tsx reset to false on shutdown
7
+ * - WidgetShell.tsx conditionally renders the chat window
8
+ * - FAB.tsx toggle button reads and flips this value
9
+ *
10
+ * Keeping it here prevents any one of those files from becoming the
11
+ * "source" that others import from — none of them own it, they all share it.
12
+ */
1
13
  export declare const isOpen: import("@preact/signals").Signal<boolean>;
2
14
  //# sourceMappingURL=shell.state.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"shell.state.d.ts","sourceRoot":"","sources":["../../../../src/module/shell/shell.state.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,MAAM,2CAAgB,CAAA"}
1
+ {"version":3,"file":"shell.state.d.ts","sourceRoot":"","sources":["../../../../src/module/shell/shell.state.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,MAAM,2CAAgB,CAAA"}
@@ -0,0 +1,27 @@
1
+ import type { JexityChatOptions, JexityChatInstance } from '../../types';
2
+ /**
3
+ * HIGH-LEVEL: Creates a JexityChatInstance for the given host element.
4
+ *
5
+ * This is the function entry points (esm.ts, iife.ts) call to get a widget.
6
+ * It wraps mountWidget() with the full public API:
7
+ *
8
+ * instance.open() — opens the chat window
9
+ * instance.close() — closes the chat window
10
+ * instance.toggle() — flips open/closed
11
+ * instance.isOpen — current open state (getter)
12
+ * instance.subscribe(cb) — notified whenever open state changes
13
+ * instance.shutdown() — destroys the widget and cleans up everything
14
+ *
15
+ * How open/close state works:
16
+ * `isOpen` is a Preact signal — a reactive value that any component can
17
+ * subscribe to. When its value changes, only the components that read it
18
+ * re-render (no prop drilling needed). `subscribe()` below taps into the
19
+ * same signal so external callers (e.g. the React wrapper) can react to
20
+ * open/close events without polling.
21
+ *
22
+ * The onRemove callback:
23
+ * Passed by esm.ts to clean up the host <div> from document.body after
24
+ * shutdown. Undefined when the caller manages the container themselves.
25
+ */
26
+ export declare function createInstance(mountEl: HTMLElement, options: JexityChatOptions, onRemove?: () => void): JexityChatInstance;
27
+ //# sourceMappingURL=widget-instance.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"widget-instance.d.ts","sourceRoot":"","sources":["../../../../src/module/shell/widget-instance.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAExE;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,cAAc,CAC5B,OAAO,EAAE,WAAW,EACpB,OAAO,EAAE,iBAAiB,EAC1B,QAAQ,CAAC,EAAE,MAAM,IAAI,GACpB,kBAAkB,CA8BpB"}