@gengage/assistant-fe 0.5.7 → 0.6.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.
- package/dist/agentic/adaptor/create-adaptor.d.ts +19 -0
- package/dist/agentic/adaptor/fetch-bridge.d.ts +11 -0
- package/dist/agentic/adaptor/mount.d.ts +38 -0
- package/dist/agentic/context/chat-context.d.ts +15 -0
- package/dist/agentic/context/context-store.d.ts +20 -0
- package/dist/agentic/context/persistence.d.ts +12 -0
- package/dist/agentic/events/builders.d.ts +10 -0
- package/dist/agentic/events/error-taxonomy.d.ts +27 -0
- package/dist/agentic/events/product-normalize.d.ts +47 -0
- package/dist/agentic/events/ui-specs.d.ts +37 -0
- package/dist/agentic/flow/beauty-consulting-turn.d.ts +1 -0
- package/dist/agentic/flow/create-flow.d.ts +2 -0
- package/dist/agentic/flow/dispatch.d.ts +3 -0
- package/dist/agentic/index.d.ts +18 -0
- package/dist/agentic/index.js +620 -0
- package/dist/agentic/types.d.ts +212 -0
- package/dist/agentic/util/assistant-host.d.ts +11 -0
- package/dist/agentic/util/be-url.d.ts +4 -0
- package/dist/agentic/util/browser-memory.d.ts +13 -0
- package/dist/agentic/util/browser-tools.d.ts +31 -0
- package/dist/agentic/util/lazy-runtime-loader.d.ts +9 -0
- package/dist/agentic/util/request-text.d.ts +3 -0
- package/dist/agentic/util/time.d.ts +2 -0
- package/dist/agentic/worker/be-client.d.ts +15 -0
- package/dist/agentic/worker/entry.d.ts +2 -0
- package/dist/agentic/worker/flow-runner.d.ts +24 -0
- package/dist/agentic/worker/jwt-mint.d.ts +21 -0
- package/dist/agentic/worker/rpc.d.ts +24 -0
- package/dist/agentic/worker/tool-bridge.d.ts +2 -0
- package/dist/agentic/worker.d.ts +16 -0
- package/dist/agentic/worker.js +119 -0
- package/dist/agentic.iife.js +5 -0
- package/dist/{api-paths-CwzwbgQZ.js → api-paths-DJFF9RuZ.js} +1 -1
- package/dist/beauty-consulting-turn-BmPXbkQg.js +1019 -0
- package/dist/chat/api.d.ts +17 -0
- package/dist/chat/assistant-mode.d.ts +20 -0
- package/dist/chat/attachment-utils.d.ts +9 -0
- package/dist/chat/catalog.d.ts +455 -0
- package/dist/chat/chat-presentation-state.d.ts +53 -0
- package/dist/chat/components/AIGroupingCards.d.ts +15 -0
- package/dist/chat/components/AISuggestedSearchCards.d.ts +13 -0
- package/dist/chat/components/AITopPicks.d.ts +9 -0
- package/dist/chat/components/BeautyPhotoStep.d.ts +31 -0
- package/dist/chat/components/CategoriesContainer.d.ts +11 -0
- package/dist/chat/components/ChatDrawer.d.ts +362 -0
- package/dist/chat/components/ChoicePrompter.d.ts +21 -0
- package/dist/chat/components/ComparisonTable.d.ts +66 -0
- package/dist/chat/components/ConsultingStylePicker.d.ts +40 -0
- package/dist/chat/components/FloatingComparisonButton.d.ts +7 -0
- package/dist/chat/components/FloatingLauncher.d.ts +79 -0
- package/dist/chat/components/GroundingReviewCard.d.ts +11 -0
- package/dist/chat/components/HandoffNotice.d.ts +9 -0
- package/dist/chat/components/KvkkBanner.d.ts +6 -0
- package/dist/chat/components/Launcher.d.ts +28 -0
- package/dist/chat/components/PanelRestoreCard.d.ts +4 -0
- package/dist/chat/components/PanelTopBar.d.ts +32 -0
- package/dist/chat/components/PhotoAnalysisCard.d.ts +27 -0
- package/dist/chat/components/ProductSummaryCard.d.ts +12 -0
- package/dist/chat/components/ProsAndCons.d.ts +8 -0
- package/dist/chat/components/ReviewHighlights.d.ts +16 -0
- package/dist/chat/components/actionClassifier.d.ts +12 -0
- package/dist/chat/components/product-price-layout.d.ts +17 -0
- package/dist/chat/components/productMentionLinker.d.ts +26 -0
- package/dist/chat/components/renderUISpec.d.ts +15 -0
- package/dist/chat/components/typewriter.d.ts +24 -0
- package/dist/chat/extendedModeManager.d.ts +32 -0
- package/dist/chat/features/beauty-consulting/consulting-grid.d.ts +38 -0
- package/dist/chat/features/beauty-consulting/drawer-extensions.d.ts +22 -0
- package/dist/chat/features/beauty-consulting/mode-controller.d.ts +59 -0
- package/dist/chat/features/beauty-consulting/registry.d.ts +9 -0
- package/dist/chat/features/beauty-consulting/stream-handler.d.ts +45 -0
- package/dist/chat/history-storage.d.ts +85 -0
- package/dist/chat/index.d.ts +6 -0
- package/dist/chat/kvkk.d.ts +20 -0
- package/dist/chat/locales/en.d.ts +2 -0
- package/dist/chat/locales/index.d.ts +5 -0
- package/dist/chat/locales/tr.d.ts +2 -0
- package/dist/chat/panel-manager.d.ts +142 -0
- package/dist/chat/runtime.d.ts +416 -0
- package/dist/chat/session-persistence.d.ts +73 -0
- package/dist/chat/stream-error-display.d.ts +6 -0
- package/dist/chat/types.d.ts +547 -0
- package/dist/chat/utils/chat-presentation-debug.d.ts +18 -0
- package/dist/chat/utils/get-chat-scroll-element.d.ts +10 -0
- package/dist/chat/utils/ui.d.ts +10 -0
- package/dist/chat-runtime.js +1 -1
- package/dist/chat.iife.js +12 -12
- package/dist/chat.js +1 -1
- package/dist/common/action-router.d.ts +26 -0
- package/dist/common/api-paths.d.ts +23 -0
- package/dist/common/client.d.ts +27 -0
- package/dist/common/communication-bridge.d.ts +51 -0
- package/dist/common/config-constants.d.ts +1 -0
- package/dist/common/config-schema.d.ts +54 -0
- package/dist/common/connection-warning.d.ts +8 -0
- package/dist/common/consulting-sources.d.ts +8 -0
- package/dist/common/context.d.ts +64 -0
- package/dist/common/css-escape.d.ts +1 -0
- package/dist/common/customization-factories.d.ts +59 -0
- package/dist/common/debug.d.ts +13 -0
- package/dist/common/events.d.ts +55 -0
- package/dist/common/fastIntent.d.ts +1 -0
- package/dist/common/find-similar-payload.d.ts +3 -0
- package/dist/common/ga-datalayer.d.ts +80 -0
- package/dist/common/global-error-toast.d.ts +6 -0
- package/dist/common/index.d.ts +47 -0
- package/dist/common/indexed-db.d.ts +89 -0
- package/dist/common/locale.d.ts +1 -0
- package/dist/common/native-webview.d.ts +60 -0
- package/dist/common/navigation.d.ts +1 -0
- package/dist/common/overlay.d.ts +172 -0
- package/dist/common/page-detect.d.ts +36 -0
- package/dist/common/pill-launcher.d.ts +51 -0
- package/dist/common/preflight.d.ts +13 -0
- package/dist/common/price-formatter.d.ts +35 -0
- package/dist/common/product-utils.d.ts +35 -0
- package/dist/common/protocol-adapter.d.ts +108 -0
- package/dist/common/renderer/dom.d.ts +3 -0
- package/dist/common/renderer/index.d.ts +4 -0
- package/dist/common/renderer/overrides.d.ts +23 -0
- package/dist/common/renderer/registry.d.ts +2 -0
- package/dist/common/renderer/types.d.ts +19 -0
- package/dist/common/safe-html.d.ts +22 -0
- package/dist/common/sdk-version.d.ts +3 -0
- package/dist/common/streaming.d.ts +52 -0
- package/dist/common/suggested-search-keywords.d.ts +18 -0
- package/dist/common/theme-utils.d.ts +15 -0
- package/dist/common/transport.d.ts +75 -0
- package/dist/common/tts-player.d.ts +13 -0
- package/dist/common/types.d.ts +379 -0
- package/dist/common/ui-theme.d.ts +9 -0
- package/dist/common/uuidv7.d.ts +7 -0
- package/dist/common/voice-input.d.ts +74 -0
- package/dist/common/widget-base.d.ts +82 -0
- package/dist/{common-KpJP1YwP.js → common-BydCGBNn.js} +90 -139
- package/dist/common.js +41 -41
- package/dist/{connection-warning-B5T_1oBn.js → connection-warning-Pbvk3J8k.js} +1 -1
- package/dist/{fastIntent--Ukm2nOh.js → fastIntent-CkYN2UOl.js} +199 -137
- package/dist/index.d.ts +25 -0
- package/dist/index.js +50 -50
- package/dist/native/index.d.ts +2 -0
- package/dist/{native-webview-qfjm4SHx.js → native-webview-JDC1vtde.js} +1 -1
- package/dist/native.iife.js +14 -14
- package/dist/native.js +1 -1
- package/dist/{overlay-CP5A0Hhf.js → overlay-BetAvpVZ.js} +19 -19
- package/dist/overlay.d.ts +4 -0
- package/dist/overlay.js +1 -1
- package/dist/qna/api.d.ts +23 -0
- package/dist/qna/catalog.d.ts +60 -0
- package/dist/qna/components/ButtonRow.d.ts +15 -0
- package/dist/qna/components/TextInput.d.ts +11 -0
- package/dist/qna/components/renderUISpec.d.ts +7 -0
- package/dist/qna/index.d.ts +3 -0
- package/dist/qna/locales/en.d.ts +2 -0
- package/dist/qna/locales/index.d.ts +4 -0
- package/dist/qna/locales/tr.d.ts +2 -0
- package/dist/qna/normalize-ui-specs.d.ts +15 -0
- package/dist/qna/runtime.d.ts +73 -0
- package/dist/qna/types.d.ts +98 -0
- package/dist/qna-runtime.js +1 -1
- package/dist/qna.iife.js +1 -1
- package/dist/qna.js +1 -1
- package/dist/{runtime-BPyXOyyp.js → runtime-DbZO1qG5.js} +3 -3
- package/dist/{runtime-G3idwfkM.js → runtime-OpNoB3cu.js} +894 -853
- package/dist/{runtime-C3yOvNFK.js → runtime-iCLkUjI3.js} +3 -3
- package/dist/simbut/index.d.ts +31 -0
- package/dist/simbut/locales.d.ts +3 -0
- package/dist/simbut/types.d.ts +43 -0
- package/dist/{simbut-CiknJI6-.js → simbut-FyXolmZY.js} +1 -1
- package/dist/simbut.iife.js +1 -1
- package/dist/simbut.js +1 -1
- package/dist/simrel/api.d.ts +25 -0
- package/dist/simrel/catalog.d.ts +77 -0
- package/dist/simrel/components/GroupTabs.d.ts +24 -0
- package/dist/simrel/components/ProductCard.d.ts +19 -0
- package/dist/simrel/components/ProductGrid.d.ts +17 -0
- package/dist/simrel/components/renderUISpec.d.ts +7 -0
- package/dist/simrel/index.d.ts +5 -0
- package/dist/simrel/locales/en.d.ts +2 -0
- package/dist/simrel/locales/index.d.ts +4 -0
- package/dist/simrel/locales/tr.d.ts +2 -0
- package/dist/simrel/renderers/default.d.ts +41 -0
- package/dist/simrel/runtime.d.ts +68 -0
- package/dist/simrel/types.d.ts +145 -0
- package/dist/{simrel-C1YN71aW.js → simrel-CbLe5OAr.js} +1 -1
- package/dist/simrel-runtime.js +1 -1
- package/dist/simrel.iife.js +1 -1
- package/dist/simrel.js +2 -2
- package/dist/{widget-base-UmvgIqDk.js → widget-base-COP8QwU3.js} +1 -1
- package/package.json +20 -6
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Compact browse-card keyword line for `aiSuggestedSearches`.
|
|
3
|
+
*
|
|
4
|
+
* Prefer backend `display_keywords`; otherwise derive short fragments from
|
|
5
|
+
* `chosen_attribute` / `short_name`. Does not use `why_different` (avoids long
|
|
6
|
+
* explanatory sentences in the tertiary line).
|
|
7
|
+
*/
|
|
8
|
+
export type SuggestedSearchKeywordSource = {
|
|
9
|
+
display_keywords?: string[];
|
|
10
|
+
chosen_attribute?: string;
|
|
11
|
+
short_name?: string;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Ordered unique keywords (max 3) for suggested-search browse cards.
|
|
15
|
+
*/
|
|
16
|
+
export declare function getSuggestedSearchKeywords(search: SuggestedSearchKeywordSource): string[];
|
|
17
|
+
/** Join keywords for the tertiary browse line (e.g. "A • B • C"). */
|
|
18
|
+
export declare function getSuggestedSearchKeywordsText(search: SuggestedSearchKeywordSource): string;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { WidgetTheme } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Shared baseline tokens used by account customizations.
|
|
4
|
+
*
|
|
5
|
+
* These values come from historical Gengage host defaults and are
|
|
6
|
+
* intentionally conservative so account themes can override only what differs.
|
|
7
|
+
*/
|
|
8
|
+
export declare const BASE_WIDGET_THEME: WidgetTheme;
|
|
9
|
+
/**
|
|
10
|
+
* Merge account overrides on top of the shared base theme.
|
|
11
|
+
*
|
|
12
|
+
* Account customization files should call this helper so shared defaults stay
|
|
13
|
+
* centralized under src/common.
|
|
14
|
+
*/
|
|
15
|
+
export declare function withBaseTheme(overrides: WidgetTheme): WidgetTheme;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import type { BackendContext, PageContext, StreamEvent, UISpec } from './types.js';
|
|
2
|
+
export interface BackendRequestMeta {
|
|
3
|
+
outputLanguage: string;
|
|
4
|
+
parentUrl: string;
|
|
5
|
+
windowWidth: string;
|
|
6
|
+
windowHeight: string;
|
|
7
|
+
selfUrl: string;
|
|
8
|
+
id: string;
|
|
9
|
+
userId: string;
|
|
10
|
+
appId: string;
|
|
11
|
+
threads: unknown[];
|
|
12
|
+
createdAt: string;
|
|
13
|
+
kvkkApproved: boolean;
|
|
14
|
+
voiceEnabled: boolean;
|
|
15
|
+
threadId: string;
|
|
16
|
+
isControlGroup: boolean;
|
|
17
|
+
isMobile: boolean;
|
|
18
|
+
viewId?: string;
|
|
19
|
+
assistantMode?: string;
|
|
20
|
+
openPdpSimilars?: boolean;
|
|
21
|
+
}
|
|
22
|
+
export interface ProcessActionRequest {
|
|
23
|
+
account_id: string;
|
|
24
|
+
session_id: string;
|
|
25
|
+
correlation_id: string;
|
|
26
|
+
user_id?: string;
|
|
27
|
+
view_id?: string;
|
|
28
|
+
/**
|
|
29
|
+
* @deprecated Use top-level `type` and `payload` instead.
|
|
30
|
+
* Kept for one release cycle of backward compatibility.
|
|
31
|
+
*/
|
|
32
|
+
action?: {
|
|
33
|
+
title: string;
|
|
34
|
+
type: string;
|
|
35
|
+
payload?: unknown;
|
|
36
|
+
};
|
|
37
|
+
/** Backend action type identifier (preferred over `action.type`). */
|
|
38
|
+
type?: string;
|
|
39
|
+
/** Arbitrary action data passed to the backend (preferred over `action.payload`). */
|
|
40
|
+
payload?: unknown;
|
|
41
|
+
sku?: string;
|
|
42
|
+
page_type?: string;
|
|
43
|
+
locale?: string;
|
|
44
|
+
meta?: BackendRequestMeta;
|
|
45
|
+
context?: {
|
|
46
|
+
messages?: Array<{
|
|
47
|
+
role: string;
|
|
48
|
+
content: string;
|
|
49
|
+
}>;
|
|
50
|
+
[key: string]: unknown;
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
export interface ActionEnrichmentContext {
|
|
54
|
+
pageContext?: PageContext | undefined;
|
|
55
|
+
backendContext?: BackendContext | null | undefined;
|
|
56
|
+
isMobile?: boolean | undefined;
|
|
57
|
+
}
|
|
58
|
+
export interface StreamCallbacks {
|
|
59
|
+
onTextChunk: (content: string, isFinal: boolean, extra?: {
|
|
60
|
+
productMentions?: Array<{
|
|
61
|
+
sku: string;
|
|
62
|
+
short_name: string;
|
|
63
|
+
}> | undefined;
|
|
64
|
+
skuToProductItem?: Record<string, Record<string, unknown>> | undefined;
|
|
65
|
+
conversationMode?: string | undefined;
|
|
66
|
+
renderHint?: string | undefined;
|
|
67
|
+
kvkk?: boolean | undefined;
|
|
68
|
+
}) => void;
|
|
69
|
+
onUISpec: (spec: UISpec, widget: string, panelHint?: 'panel', clearPanel?: boolean) => void;
|
|
70
|
+
onAction: (event: StreamEvent) => void;
|
|
71
|
+
onMetadata: (event: StreamEvent) => void;
|
|
72
|
+
onError: (err: Error) => void;
|
|
73
|
+
onDone: () => void;
|
|
74
|
+
}
|
|
75
|
+
export type InjectorAdapter = (request: ProcessActionRequest, callbacks: StreamCallbacks, signal: AbortSignal, attachment?: File) => void | Promise<void>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/** Returned by `playTtsAudio` on successful playback initiation. */
|
|
2
|
+
export interface AudioHandle {
|
|
3
|
+
/** Stop playback immediately. Safe to call multiple times. */
|
|
4
|
+
stop: () => void;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Plays a base64-encoded audio clip.
|
|
8
|
+
* Returns an `AudioHandle` that can stop playback, or `null` if playback
|
|
9
|
+
* could not be initiated (blocked by browser, unsupported environment, etc.).
|
|
10
|
+
*/
|
|
11
|
+
export declare function playTtsAudio(base64: string, contentType?: string): AudioHandle | null;
|
|
12
|
+
/** Stop and release all active TTS audio elements. */
|
|
13
|
+
export declare function destroyAllTtsAudio(): void;
|
|
@@ -0,0 +1,379 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Core shared types for all Gengage widgets.
|
|
3
|
+
*
|
|
4
|
+
* These types define the public contract between:
|
|
5
|
+
* - The host page and widgets (PageContext, WidgetConfig)
|
|
6
|
+
* - The backend wire protocol and widgets (StreamEvent, UISpec)
|
|
7
|
+
* - Widgets and each other (GengageEvent, SessionContext)
|
|
8
|
+
*/
|
|
9
|
+
import type { InjectorAdapter } from './transport.js';
|
|
10
|
+
/**
|
|
11
|
+
* Describes the current page's context.
|
|
12
|
+
* Widgets use this to tailor their behaviour (e.g. show/hide, fetch the right SKU).
|
|
13
|
+
*
|
|
14
|
+
* CSR/SPA: call widget.update(context) on every navigation.
|
|
15
|
+
* SSR: set window.gengage.pageContext before loading widget scripts.
|
|
16
|
+
*/
|
|
17
|
+
export interface PageContext {
|
|
18
|
+
/** The current page type. Determines which features activate. */
|
|
19
|
+
pageType: 'pdp' | 'plp' | 'home' | 'cart' | 'search' | 'other';
|
|
20
|
+
/** Product SKU — required on PDP pages for QNA and Similar Products. */
|
|
21
|
+
sku?: string;
|
|
22
|
+
/** Product SKU list — for PLP pages, used with the launchProductList init action. */
|
|
23
|
+
skuList?: string[];
|
|
24
|
+
/** Product price, formatted as a string (e.g. "149.99"). */
|
|
25
|
+
price?: string;
|
|
26
|
+
/** Category path array, from broad to specific (e.g. ["Electronics", "TVs"]). */
|
|
27
|
+
categoryTree?: string[];
|
|
28
|
+
/** Raw page URL (defaults to window.location.href). */
|
|
29
|
+
url?: string;
|
|
30
|
+
/** Arbitrary key/value metadata the host page wants to pass through to the backend. */
|
|
31
|
+
extra?: Record<string, unknown>;
|
|
32
|
+
}
|
|
33
|
+
export interface SessionContext {
|
|
34
|
+
/**
|
|
35
|
+
* A UUID created once per browser session, shared across all widgets.
|
|
36
|
+
* Used as correlation_id in backend logging and frontend event correlation.
|
|
37
|
+
*
|
|
38
|
+
* Bootstrap:
|
|
39
|
+
* window.__gengageSessionId =
|
|
40
|
+
* window.__gengageSessionId
|
|
41
|
+
* ?? sessionStorage.getItem('gengage_session_id')
|
|
42
|
+
* ?? crypto.randomUUID();
|
|
43
|
+
* sessionStorage.setItem('gengage_session_id', window.__gengageSessionId);
|
|
44
|
+
*/
|
|
45
|
+
sessionId: string;
|
|
46
|
+
/** Opaque user identifier set by the host site's auth system. */
|
|
47
|
+
userId?: string;
|
|
48
|
+
/** View/visit identifier (e.g. from analytics platform). */
|
|
49
|
+
viewId?: string;
|
|
50
|
+
/** AB test variant assignment (e.g. 'control', 'treatment'). */
|
|
51
|
+
abTestVariant?: string;
|
|
52
|
+
/** AB test experiment identifier (e.g. 'exp_chat_v2'). */
|
|
53
|
+
abTestExperimentId?: string;
|
|
54
|
+
}
|
|
55
|
+
export interface BaseWidgetConfig {
|
|
56
|
+
/** Your Gengage account identifier. */
|
|
57
|
+
accountId: string;
|
|
58
|
+
/** Backend middleware URL — must be explicitly provided, no default. */
|
|
59
|
+
middlewareUrl: string;
|
|
60
|
+
/** AGENTIC_ADAPTER_SEAM: optional in-browser adaptor exposed by gengage-assistant-injector. */
|
|
61
|
+
injectorAdapter?: InjectorAdapter;
|
|
62
|
+
/** Session context for backend requests and frontend event correlation. */
|
|
63
|
+
session?: SessionContext;
|
|
64
|
+
/** Initial page context. Can be updated later via widget.update(). */
|
|
65
|
+
pageContext?: PageContext;
|
|
66
|
+
/** Where to mount the widget's root element. */
|
|
67
|
+
mountTarget?: HTMLElement | string;
|
|
68
|
+
/**
|
|
69
|
+
* Theme tokens applied as CSS custom properties on the widget root.
|
|
70
|
+
* Consumers can override these in their own CSS; these are just the defaults.
|
|
71
|
+
*/
|
|
72
|
+
theme?: WidgetTheme;
|
|
73
|
+
/** Price formatting options. Defaults to Turkish locale (TL, dot thousands, comma decimal). */
|
|
74
|
+
pricing?: import('./price-formatter.js').PriceFormatConfig;
|
|
75
|
+
}
|
|
76
|
+
export interface WidgetTheme {
|
|
77
|
+
primaryColor?: string;
|
|
78
|
+
primaryForeground?: string;
|
|
79
|
+
backgroundColor?: string;
|
|
80
|
+
foregroundColor?: string;
|
|
81
|
+
borderRadius?: string;
|
|
82
|
+
fontFamily?: string;
|
|
83
|
+
fontSize?: string;
|
|
84
|
+
/** Arbitrary additional CSS custom properties */
|
|
85
|
+
[cssVar: string]: string | undefined;
|
|
86
|
+
}
|
|
87
|
+
export interface GengageWidget<TConfig extends BaseWidgetConfig = BaseWidgetConfig> {
|
|
88
|
+
/** Mount the widget and fetch initial data. Must be called once. */
|
|
89
|
+
init(config: TConfig): Promise<void>;
|
|
90
|
+
/**
|
|
91
|
+
* Update page context after SPA navigation or page state changes.
|
|
92
|
+
* Widgets re-fetch relevant data (e.g. QNA buttons for new SKU).
|
|
93
|
+
*/
|
|
94
|
+
update(context: Partial<PageContext>): void;
|
|
95
|
+
/** Make the widget visible. No-op if already visible. */
|
|
96
|
+
show(): void;
|
|
97
|
+
/** Hide the widget. Preserves state (conversation history, etc.). */
|
|
98
|
+
hide(): void;
|
|
99
|
+
/** Fully remove the widget from the DOM and release all resources. */
|
|
100
|
+
destroy(): void;
|
|
101
|
+
/**
|
|
102
|
+
* Subscribe to widget events.
|
|
103
|
+
* Returns an unsubscribe function.
|
|
104
|
+
*
|
|
105
|
+
* @example
|
|
106
|
+
* const off = widget.on('open', () => console.log('chat opened'));
|
|
107
|
+
* // later:
|
|
108
|
+
* off();
|
|
109
|
+
*/
|
|
110
|
+
on(event: string, handler: (...args: unknown[]) => void): () => void;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Every event sent over the stream has a `type` discriminant.
|
|
114
|
+
* Events are newline-delimited JSON (NDJSON) over a streaming HTTP response.
|
|
115
|
+
*/
|
|
116
|
+
export type StreamEvent = StreamEventMetadata | StreamEventTextChunk | StreamEventUISpec | StreamEventAction | StreamEventError | StreamEventDone;
|
|
117
|
+
/** First event in every stream — session and model info. */
|
|
118
|
+
export interface StreamEventMetadata {
|
|
119
|
+
type: 'metadata';
|
|
120
|
+
sessionId: string;
|
|
121
|
+
model: string;
|
|
122
|
+
/** Any extra server-side metadata the backend wants to forward. */
|
|
123
|
+
meta?: Record<string, unknown>;
|
|
124
|
+
}
|
|
125
|
+
/** A chunk of assistant text (streamed word-by-word or sentence-by-sentence). */
|
|
126
|
+
export interface StreamEventTextChunk {
|
|
127
|
+
type: 'text_chunk';
|
|
128
|
+
content: string;
|
|
129
|
+
/** If true this chunk closes the current text block. */
|
|
130
|
+
final?: boolean;
|
|
131
|
+
/** AGENTIC_ADAPTER_SEAM: product mentions may come from legacy NDJSON or adapter events. */
|
|
132
|
+
productMentions?: Array<{
|
|
133
|
+
sku: string;
|
|
134
|
+
short_name: string;
|
|
135
|
+
}>;
|
|
136
|
+
/** Map from SKU to full product data (for enriching product mention links). */
|
|
137
|
+
skuToProductItem?: Record<string, Record<string, unknown>>;
|
|
138
|
+
/** Current conversation mode from outputText (e.g., 'product_search'). */
|
|
139
|
+
conversationMode?: string;
|
|
140
|
+
/** Backend render hint for special rendering (e.g. 'photo_analysis'). */
|
|
141
|
+
renderHint?: string;
|
|
142
|
+
/** True when the outputText contains KVKK consent content (set by backend). */
|
|
143
|
+
kvkk?: boolean;
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* A json-render UI spec sent from the backend.
|
|
147
|
+
* The frontend renders it using the active widget registry.
|
|
148
|
+
* Backend can send UI specs mid-stream to show product cards,
|
|
149
|
+
* action buttons, or any structured component alongside text.
|
|
150
|
+
*/
|
|
151
|
+
export interface StreamEventUISpec {
|
|
152
|
+
type: 'ui_spec';
|
|
153
|
+
/** Which widget catalog this spec targets. */
|
|
154
|
+
widget: 'chat' | 'qna' | 'simrel';
|
|
155
|
+
/** The json-render spec: root + elements map. */
|
|
156
|
+
spec: UISpec;
|
|
157
|
+
/** Routing hint for two-panel layout: 'panel' = detail/results panel, default = chat thread. */
|
|
158
|
+
panelHint?: 'panel';
|
|
159
|
+
/** When present, dismiss panel loading and hide/clear the assistant side panel. */
|
|
160
|
+
clearPanel?: true;
|
|
161
|
+
}
|
|
162
|
+
/** A discrete action the backend instructs the widget to perform. */
|
|
163
|
+
export interface StreamEventAction {
|
|
164
|
+
type: 'action';
|
|
165
|
+
action: {
|
|
166
|
+
kind: 'open_chat';
|
|
167
|
+
payload?: ActionPayload;
|
|
168
|
+
} | {
|
|
169
|
+
kind: 'navigate';
|
|
170
|
+
url: string;
|
|
171
|
+
newTab?: boolean;
|
|
172
|
+
} | {
|
|
173
|
+
kind: 'save_session';
|
|
174
|
+
sessionId: string;
|
|
175
|
+
sku: string;
|
|
176
|
+
} | {
|
|
177
|
+
kind: 'add_to_cart';
|
|
178
|
+
sku: string;
|
|
179
|
+
quantity: number;
|
|
180
|
+
cartCode: string;
|
|
181
|
+
} | {
|
|
182
|
+
kind: 'script_call';
|
|
183
|
+
name: string;
|
|
184
|
+
payload?: Record<string, unknown>;
|
|
185
|
+
} | {
|
|
186
|
+
kind: string;
|
|
187
|
+
[key: string]: unknown;
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
export interface StreamEventError {
|
|
191
|
+
type: 'error';
|
|
192
|
+
code: string;
|
|
193
|
+
message: string;
|
|
194
|
+
}
|
|
195
|
+
export interface StreamEventDone {
|
|
196
|
+
type: 'done';
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* A json-render spec is a flat map of element IDs to element definitions
|
|
200
|
+
* plus a root element ID.
|
|
201
|
+
*
|
|
202
|
+
* See: https://github.com/vercel-labs/json-render
|
|
203
|
+
*/
|
|
204
|
+
export interface UISpec {
|
|
205
|
+
root: string;
|
|
206
|
+
elements: Record<string, UIElement>;
|
|
207
|
+
}
|
|
208
|
+
export interface UIElement {
|
|
209
|
+
type: string;
|
|
210
|
+
props?: Record<string, unknown>;
|
|
211
|
+
children?: string[];
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* Shape of `context.panel` as returned by the backend's `context` event
|
|
215
|
+
* and sent back with each request. Field names match the backend `SessionContext`.
|
|
216
|
+
*
|
|
217
|
+
* This is intentionally extensible (index signature) because the backend
|
|
218
|
+
* may add fields without a frontend release.
|
|
219
|
+
*/
|
|
220
|
+
interface BackendPanelContext {
|
|
221
|
+
screen_type?: 'product_list' | 'product_details' | 'comparison_table';
|
|
222
|
+
screen_summary?: string;
|
|
223
|
+
screen_sku_list?: string[];
|
|
224
|
+
chat_mentioned_skus?: string[];
|
|
225
|
+
conversation_stage?: 'exploring' | 'evaluating' | 'deciding' | 'refining';
|
|
226
|
+
last_search_query?: string;
|
|
227
|
+
last_search_offset?: number;
|
|
228
|
+
last_search_page_size?: number;
|
|
229
|
+
last_search_end_of_list?: boolean;
|
|
230
|
+
last_search_category_id?: string;
|
|
231
|
+
last_search_title?: string;
|
|
232
|
+
last_search_max_budget?: number;
|
|
233
|
+
product_refs?: Array<{
|
|
234
|
+
ref: string;
|
|
235
|
+
sku: string;
|
|
236
|
+
name: string;
|
|
237
|
+
brand?: string;
|
|
238
|
+
price?: number;
|
|
239
|
+
}>;
|
|
240
|
+
session_memory?: Record<string, unknown>;
|
|
241
|
+
suggested_action_titles?: string[];
|
|
242
|
+
[key: string]: unknown;
|
|
243
|
+
}
|
|
244
|
+
/**
|
|
245
|
+
* The full backend context object stored between turns.
|
|
246
|
+
* Contains `panel` (session state), `messages` (conversation history),
|
|
247
|
+
* and `message_id` (last message identifier).
|
|
248
|
+
*/
|
|
249
|
+
export interface BackendContext {
|
|
250
|
+
panel?: BackendPanelContext;
|
|
251
|
+
messages?: Array<{
|
|
252
|
+
role?: string;
|
|
253
|
+
content?: string;
|
|
254
|
+
}>;
|
|
255
|
+
message_id?: string;
|
|
256
|
+
[key: string]: unknown;
|
|
257
|
+
}
|
|
258
|
+
/** Params passed to add-to-cart callbacks across all widgets. */
|
|
259
|
+
export interface AddToCartParams {
|
|
260
|
+
sku: string;
|
|
261
|
+
cartCode: string;
|
|
262
|
+
quantity: number;
|
|
263
|
+
}
|
|
264
|
+
/** Add-to-cart callbacks may complete synchronously or after host cart confirmation. */
|
|
265
|
+
export type AddToCartHandlerResult = void | Promise<void>;
|
|
266
|
+
export interface ActionPayload {
|
|
267
|
+
/** Display label shown to the user. */
|
|
268
|
+
title: string;
|
|
269
|
+
/** Backend action type identifier. */
|
|
270
|
+
type: string;
|
|
271
|
+
/** Arbitrary action data passed to the backend as-is. */
|
|
272
|
+
payload?: unknown;
|
|
273
|
+
}
|
|
274
|
+
/**
|
|
275
|
+
* All inter-widget and host-page events follow this naming convention:
|
|
276
|
+
* gengage:<widget>:<action>
|
|
277
|
+
*
|
|
278
|
+
* Widgets dispatch these; host pages and other widgets listen.
|
|
279
|
+
*/
|
|
280
|
+
export type GengageEventName = 'gengage:chat:open' | 'gengage:chat:close' | 'gengage:chat:ready' | 'gengage:chat:metadata' | 'gengage:chat:voice' | 'gengage:chat:redirect' | 'gengage:chat:script-call' | 'gengage:chat:add-to-cart' | 'gengage:chat:product-favorite' | 'gengage:qna:action' | 'gengage:qna:open-chat' | 'gengage:similar:product-click' | 'gengage:similar:grouping-click' | 'gengage:similar:products-impression' | 'gengage:similar:add-to-cart' | 'gengage:global:error' | 'gengage:checkout:start' | 'gengage:checkout:complete' | 'gengage:context:update';
|
|
281
|
+
export type GengageEventDetailMap = {
|
|
282
|
+
'gengage:chat:open': {
|
|
283
|
+
state?: 'full' | 'half';
|
|
284
|
+
};
|
|
285
|
+
'gengage:chat:close': Record<string, never>;
|
|
286
|
+
'gengage:chat:ready': Record<string, never>;
|
|
287
|
+
'gengage:chat:metadata': {
|
|
288
|
+
payload: Record<string, unknown>;
|
|
289
|
+
};
|
|
290
|
+
'gengage:chat:voice': {
|
|
291
|
+
payload: unknown;
|
|
292
|
+
};
|
|
293
|
+
'gengage:chat:redirect': {
|
|
294
|
+
target: unknown;
|
|
295
|
+
payload: unknown;
|
|
296
|
+
};
|
|
297
|
+
'gengage:chat:script-call': {
|
|
298
|
+
name: string;
|
|
299
|
+
payload?: Record<string, unknown>;
|
|
300
|
+
};
|
|
301
|
+
'gengage:chat:add-to-cart': {
|
|
302
|
+
sku: string;
|
|
303
|
+
cartCode: string;
|
|
304
|
+
quantity: number;
|
|
305
|
+
sessionId: string | null;
|
|
306
|
+
};
|
|
307
|
+
'gengage:chat:product-favorite': {
|
|
308
|
+
sku: string;
|
|
309
|
+
product: Record<string, unknown>;
|
|
310
|
+
favorited: boolean;
|
|
311
|
+
sessionId: string | null;
|
|
312
|
+
};
|
|
313
|
+
'gengage:qna:action': ActionPayload;
|
|
314
|
+
'gengage:qna:open-chat': Record<string, never>;
|
|
315
|
+
'gengage:similar:product-click': {
|
|
316
|
+
sku: string;
|
|
317
|
+
url: string;
|
|
318
|
+
sessionId: string | null;
|
|
319
|
+
productName?: string;
|
|
320
|
+
};
|
|
321
|
+
'gengage:similar:grouping-click': {
|
|
322
|
+
grouping_label: string;
|
|
323
|
+
grouping_index: number;
|
|
324
|
+
sessionId: string | null;
|
|
325
|
+
};
|
|
326
|
+
'gengage:similar:products-impression': {
|
|
327
|
+
source_sku: string;
|
|
328
|
+
product_count: number;
|
|
329
|
+
grouped: boolean;
|
|
330
|
+
sessionId: string | null;
|
|
331
|
+
};
|
|
332
|
+
'gengage:similar:add-to-cart': {
|
|
333
|
+
sku: string;
|
|
334
|
+
quantity: number;
|
|
335
|
+
cartCode: string;
|
|
336
|
+
};
|
|
337
|
+
'gengage:global:error': {
|
|
338
|
+
source: 'chat' | 'qna' | 'simrel' | 'sdk';
|
|
339
|
+
message: string;
|
|
340
|
+
code?: string;
|
|
341
|
+
durationMs?: number;
|
|
342
|
+
sticky?: boolean;
|
|
343
|
+
};
|
|
344
|
+
'gengage:checkout:start': {
|
|
345
|
+
attribution_source: 'chat' | 'qna' | 'simrel';
|
|
346
|
+
attribution_action_id: string;
|
|
347
|
+
cart_value: number;
|
|
348
|
+
currency: string;
|
|
349
|
+
line_items: number;
|
|
350
|
+
};
|
|
351
|
+
'gengage:checkout:complete': {
|
|
352
|
+
attribution_source: 'chat' | 'qna' | 'simrel';
|
|
353
|
+
attribution_action_id: string;
|
|
354
|
+
cart_value: number;
|
|
355
|
+
currency: string;
|
|
356
|
+
line_items: number;
|
|
357
|
+
};
|
|
358
|
+
'gengage:context:update': Partial<PageContext>;
|
|
359
|
+
};
|
|
360
|
+
declare global {
|
|
361
|
+
interface Window {
|
|
362
|
+
/**
|
|
363
|
+
* Set this before loading widget scripts for SSR / static pages.
|
|
364
|
+
* CSR/SPA: call widget.update() instead.
|
|
365
|
+
*/
|
|
366
|
+
gengage?: {
|
|
367
|
+
pageContext?: PageContext;
|
|
368
|
+
/** Shared session ID — set once at page bootstrap. */
|
|
369
|
+
sessionId?: string;
|
|
370
|
+
/** Chat widget public API, available after chat widget init(). */
|
|
371
|
+
chat?: import('./widget-base').ChatPublicAPI;
|
|
372
|
+
/** Overlay orchestration API, available after initOverlayWidgets(). */
|
|
373
|
+
overlay?: import('./overlay.js').OverlayWidgetsController;
|
|
374
|
+
};
|
|
375
|
+
/** @internal Legacy compat — do not use in new integrations. */
|
|
376
|
+
__gengageSessionId?: string;
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { WidgetTheme } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Shared SDK-wide visual tokens.
|
|
4
|
+
*
|
|
5
|
+
* Applied to every widget root by default so account customizations only
|
|
6
|
+
* override what they need.
|
|
7
|
+
*/
|
|
8
|
+
export declare const DEFAULT_WIDGET_THEME_TOKENS: WidgetTheme;
|
|
9
|
+
export declare function withDefaultWidgetTheme(theme?: WidgetTheme): WidgetTheme;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Browser-native Web Speech API voice input.
|
|
3
|
+
*
|
|
4
|
+
* Uses the SpeechRecognition API for real-time speech-to-text.
|
|
5
|
+
* The frontend sends transcribed text directly — no audio blobs
|
|
6
|
+
* are sent to the backend. This replaces server-side Groq Whisper.
|
|
7
|
+
*
|
|
8
|
+
* Supports:
|
|
9
|
+
* - Real-time transcription with interim results
|
|
10
|
+
* - Turkish (`tr-TR`) and English (`en-US`) language support
|
|
11
|
+
* - Auto-submit on silence (configurable timeout)
|
|
12
|
+
* - Microphone permission handling with descriptive errors
|
|
13
|
+
*
|
|
14
|
+
* Browser support:
|
|
15
|
+
* - Chrome 33+, Edge 79+, Safari 14.1+ (via webkitSpeechRecognition)
|
|
16
|
+
* - Firefox: NOT SUPPORTED (no SpeechRecognition API)
|
|
17
|
+
*/
|
|
18
|
+
export type VoiceInputState = 'idle' | 'listening' | 'error';
|
|
19
|
+
export type VoiceInputErrorCode = 'not-supported' | 'not-allowed' | 'no-microphone' | 'no-speech' | 'network' | 'aborted' | 'unknown';
|
|
20
|
+
export interface VoiceInputCallbacks {
|
|
21
|
+
/** Called with interim transcript while the user speaks. */
|
|
22
|
+
onInterim?: (text: string) => void;
|
|
23
|
+
/** Called with final transcript when a phrase is recognized. */
|
|
24
|
+
onFinal?: (text: string) => void;
|
|
25
|
+
/** Called when auto-submit fires (silence timeout reached with final text). */
|
|
26
|
+
onAutoSubmit?: (text: string) => void;
|
|
27
|
+
/** Called when voice input state changes. */
|
|
28
|
+
onStateChange?: (state: VoiceInputState) => void;
|
|
29
|
+
/** Called on recognition error. */
|
|
30
|
+
onError?: (code: VoiceInputErrorCode, message: string) => void;
|
|
31
|
+
}
|
|
32
|
+
export interface VoiceInputOptions {
|
|
33
|
+
/** BCP 47 language tag. Default: 'tr-TR'. */
|
|
34
|
+
lang?: string;
|
|
35
|
+
/** Silence duration in ms before auto-submit. Default: 1500. */
|
|
36
|
+
silenceTimeoutMs?: number;
|
|
37
|
+
/** Whether to auto-submit on silence. Default: true. */
|
|
38
|
+
autoSubmit?: boolean;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Check whether the browser supports the Web Speech API.
|
|
42
|
+
*/
|
|
43
|
+
export declare function isVoiceInputSupported(): boolean;
|
|
44
|
+
export declare class VoiceInput {
|
|
45
|
+
private recognition;
|
|
46
|
+
private _state;
|
|
47
|
+
private silenceTimer;
|
|
48
|
+
private accumulatedTranscript;
|
|
49
|
+
private readonly callbacks;
|
|
50
|
+
private readonly lang;
|
|
51
|
+
private readonly silenceTimeoutMs;
|
|
52
|
+
private readonly autoSubmit;
|
|
53
|
+
private intentionalStop;
|
|
54
|
+
private _lastRestartAt;
|
|
55
|
+
constructor(callbacks: VoiceInputCallbacks, options?: VoiceInputOptions);
|
|
56
|
+
get state(): VoiceInputState;
|
|
57
|
+
/**
|
|
58
|
+
* Start listening. Requests microphone permission on first call.
|
|
59
|
+
*/
|
|
60
|
+
start(): void;
|
|
61
|
+
/**
|
|
62
|
+
* Stop listening. Returns the accumulated transcript.
|
|
63
|
+
*/
|
|
64
|
+
stop(): string;
|
|
65
|
+
/**
|
|
66
|
+
* Abort listening. Discards any accumulated transcript.
|
|
67
|
+
*/
|
|
68
|
+
abort(): void;
|
|
69
|
+
/** Destroy the instance and release resources. */
|
|
70
|
+
destroy(): void;
|
|
71
|
+
private setState;
|
|
72
|
+
private startSilenceTimer;
|
|
73
|
+
private clearSilenceTimer;
|
|
74
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Abstract base class for all Gengage widgets.
|
|
3
|
+
*
|
|
4
|
+
* Provides:
|
|
5
|
+
* - Lifecycle management (init → update → show/hide → destroy)
|
|
6
|
+
* - Typed event emitter
|
|
7
|
+
* - Theme application via CSS custom properties
|
|
8
|
+
* - SPA context-update listener (gengage:context:update)
|
|
9
|
+
* - Mount target resolution (selector string or HTMLElement)
|
|
10
|
+
*
|
|
11
|
+
* Subclasses must implement:
|
|
12
|
+
* - protected onInit(config): Promise<void>
|
|
13
|
+
* - protected onUpdate(context): void
|
|
14
|
+
* - protected onShow(): void
|
|
15
|
+
* - protected onHide(): void
|
|
16
|
+
* - protected onDestroy(): void
|
|
17
|
+
*/
|
|
18
|
+
import type { BaseWidgetConfig, GengageWidget, PageContext } from './types.js';
|
|
19
|
+
type AnyHandler = (...args: unknown[]) => void;
|
|
20
|
+
export declare abstract class BaseWidget<TConfig extends BaseWidgetConfig = BaseWidgetConfig> implements GengageWidget<TConfig> {
|
|
21
|
+
protected config: TConfig;
|
|
22
|
+
protected root: HTMLElement;
|
|
23
|
+
protected isVisible: boolean;
|
|
24
|
+
protected isInitialised: boolean;
|
|
25
|
+
private readonly _handlers;
|
|
26
|
+
private readonly _cleanups;
|
|
27
|
+
private _ownsRoot;
|
|
28
|
+
private _destroying;
|
|
29
|
+
init(config: TConfig): Promise<void>;
|
|
30
|
+
update(context: Partial<PageContext>): void;
|
|
31
|
+
show(): void;
|
|
32
|
+
hide(): void;
|
|
33
|
+
destroy(): void;
|
|
34
|
+
/**
|
|
35
|
+
* Called at the end of destroy() to remove or clear the root node.
|
|
36
|
+
* Subclasses that mount into a merchant-owned element (e.g. SimBut) should
|
|
37
|
+
* override this to a no-op so the host page's DOM is never mutated.
|
|
38
|
+
*/
|
|
39
|
+
protected _cleanupRoot(): void;
|
|
40
|
+
on(event: string, handler: AnyHandler): () => void;
|
|
41
|
+
protected abstract onInit(config: TConfig): Promise<void>;
|
|
42
|
+
protected abstract onUpdate(context: Partial<PageContext>): void;
|
|
43
|
+
protected abstract onShow(): void;
|
|
44
|
+
protected abstract onHide(): void;
|
|
45
|
+
protected abstract onDestroy(): void;
|
|
46
|
+
/** Emit a widget event to all registered handlers. */
|
|
47
|
+
protected emit(event: string, ...args: unknown[]): void;
|
|
48
|
+
/** Register a cleanup function to run on destroy(). */
|
|
49
|
+
protected addCleanup(fn: () => void): void;
|
|
50
|
+
private _resolveMount;
|
|
51
|
+
private _applyTheme;
|
|
52
|
+
}
|
|
53
|
+
export interface ChatPublicAPI {
|
|
54
|
+
open(options?: {
|
|
55
|
+
state?: 'full' | 'half';
|
|
56
|
+
initialMessage?: string;
|
|
57
|
+
}): void;
|
|
58
|
+
openWithAction(action: import('./types.js').ActionPayload, options?: {
|
|
59
|
+
sku?: string;
|
|
60
|
+
state?: 'full' | 'half';
|
|
61
|
+
}): void;
|
|
62
|
+
/** Send a user message programmatically (same as typing + submit). */
|
|
63
|
+
sendMessage(text: string): void;
|
|
64
|
+
/** Send a backend action programmatically. */
|
|
65
|
+
sendAction(action: import('./types.js').ActionPayload, options?: {
|
|
66
|
+
silent?: boolean;
|
|
67
|
+
}): void;
|
|
68
|
+
close(): void;
|
|
69
|
+
saveSession(sessionId: string, sku: string): void;
|
|
70
|
+
readonly isOpen: boolean;
|
|
71
|
+
on(event: 'open' | 'close' | 'ready' | 'message' | 'error' | 'context-update' | 'destroy', handler: (...args: unknown[]) => void): () => void;
|
|
72
|
+
/**
|
|
73
|
+
* Register a callback for a GA4 event name.
|
|
74
|
+
* When the widget fires that event, the callback is invoked with the event detail.
|
|
75
|
+
* Callbacks that return `false` or throw signal failure — the widget reacts accordingly
|
|
76
|
+
* (e.g. showing an error message for add-to-cart failures).
|
|
77
|
+
*
|
|
78
|
+
* @returns unsubscribe function
|
|
79
|
+
*/
|
|
80
|
+
addCallback(eventName: string, callback: (detail: Record<string, unknown>) => boolean | Promise<boolean>): () => void;
|
|
81
|
+
}
|
|
82
|
+
export {};
|