@gengage/assistant-fe 0.4.20 → 0.5.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 (165) hide show
  1. package/README.md +1 -1
  2. package/dist/{api-paths-CReMDZWg.js → api-paths-y5nkfEBG.js} +1 -1
  3. package/dist/chat-runtime.js +1 -1
  4. package/dist/chat.iife.js +43 -43
  5. package/dist/chat.js +1 -1
  6. package/dist/common-BKPSOoIP.js +324 -0
  7. package/dist/common.js +64 -81
  8. package/dist/{connection-warning-C_4e7ahZ.js → connection-warning-DJiyLM46.js} +1 -1
  9. package/dist/{fastIntent-DMNzXOSI.js → fastIntent-1T2g9art.js} +2 -2
  10. package/dist/index.js +49 -52
  11. package/dist/{native-webview-Bbcvvi_5.js → native-webview-y3a9R9hH.js} +1 -1
  12. package/dist/native.iife.js +23 -23
  13. package/dist/native.js +1 -1
  14. package/dist/{overlay-O4nlUrzw.js → overlay-v3nvcGlE.js} +2 -5
  15. package/dist/overlay.js +2 -2
  16. package/dist/qna-runtime.js +1 -1
  17. package/dist/qna.iife.js +36 -36
  18. package/dist/qna.js +1 -1
  19. package/dist/{runtime-C51WykbJ.js → runtime-BMNOS2Mq.js} +176 -196
  20. package/dist/runtime-DOS9yRRx.js +650 -0
  21. package/dist/{runtime-DBh8899B.js → runtime-DsP6go8z.js} +2194 -2225
  22. package/dist/{simbut-CO1rLVM9.js → simbut-BwxzoBcY.js} +7 -7
  23. package/dist/simbut.iife.js +12 -12
  24. package/dist/simbut.js +1 -1
  25. package/dist/{simrel-zCDlCrqG.js → simrel-C07wZN8Q.js} +2 -2
  26. package/dist/simrel-runtime.js +1 -1
  27. package/dist/simrel.iife.js +35 -35
  28. package/dist/simrel.js +2 -2
  29. package/dist/widget-base-Dliq3QAf.js +362 -0
  30. package/package.json +8 -6
  31. package/dist/chat/api.d.ts +0 -88
  32. package/dist/chat/assistant-mode.d.ts +0 -19
  33. package/dist/chat/attachment-utils.d.ts +0 -9
  34. package/dist/chat/catalog.d.ts +0 -826
  35. package/dist/chat/chat-presentation-state.d.ts +0 -53
  36. package/dist/chat/components/AIGroupingCards.d.ts +0 -3
  37. package/dist/chat/components/AISuggestedSearchCards.d.ts +0 -3
  38. package/dist/chat/components/AITopPicks.d.ts +0 -3
  39. package/dist/chat/components/BeautyPhotoStep.d.ts +0 -16
  40. package/dist/chat/components/CategoriesContainer.d.ts +0 -3
  41. package/dist/chat/components/ChatDrawer.d.ts +0 -360
  42. package/dist/chat/components/ChoicePrompter.d.ts +0 -21
  43. package/dist/chat/components/ComparisonTable.d.ts +0 -57
  44. package/dist/chat/components/ConsultingStylePicker.d.ts +0 -34
  45. package/dist/chat/components/FloatingComparisonButton.d.ts +0 -2
  46. package/dist/chat/components/FloatingLauncher.d.ts +0 -79
  47. package/dist/chat/components/GroundingReviewCard.d.ts +0 -3
  48. package/dist/chat/components/HandoffNotice.d.ts +0 -4
  49. package/dist/chat/components/KvkkBanner.d.ts +0 -6
  50. package/dist/chat/components/Launcher.d.ts +0 -28
  51. package/dist/chat/components/PanelRestoreCard.d.ts +0 -4
  52. package/dist/chat/components/PanelTopBar.d.ts +0 -32
  53. package/dist/chat/components/PhotoAnalysisCard.d.ts +0 -20
  54. package/dist/chat/components/ProductSummaryCard.d.ts +0 -3
  55. package/dist/chat/components/ProsAndCons.d.ts +0 -8
  56. package/dist/chat/components/ReviewHighlights.d.ts +0 -9
  57. package/dist/chat/components/actionClassifier.d.ts +0 -12
  58. package/dist/chat/components/product-price-layout.d.ts +0 -18
  59. package/dist/chat/components/productMentionLinker.d.ts +0 -25
  60. package/dist/chat/components/renderUISpec.d.ts +0 -11
  61. package/dist/chat/components/typewriter.d.ts +0 -24
  62. package/dist/chat/extendedModeManager.d.ts +0 -32
  63. package/dist/chat/features/beauty-consulting/consulting-grid.d.ts +0 -31
  64. package/dist/chat/features/beauty-consulting/drawer-extensions.d.ts +0 -20
  65. package/dist/chat/features/beauty-consulting/mode-controller.d.ts +0 -53
  66. package/dist/chat/features/beauty-consulting/registry.d.ts +0 -3
  67. package/dist/chat/features/beauty-consulting/stream-handler.d.ts +0 -38
  68. package/dist/chat/history-storage.d.ts +0 -85
  69. package/dist/chat/index.d.ts +0 -5
  70. package/dist/chat/kvkk.d.ts +0 -20
  71. package/dist/chat/locales/en.d.ts +0 -2
  72. package/dist/chat/locales/index.d.ts +0 -5
  73. package/dist/chat/locales/tr.d.ts +0 -2
  74. package/dist/chat/panel-manager.d.ts +0 -126
  75. package/dist/chat/runtime.d.ts +0 -400
  76. package/dist/chat/session-persistence.d.ts +0 -65
  77. package/dist/chat/stream-error-display.d.ts +0 -6
  78. package/dist/chat/types.d.ts +0 -543
  79. package/dist/chat/utils/chat-presentation-debug.d.ts +0 -19
  80. package/dist/chat/utils/get-chat-scroll-element.d.ts +0 -10
  81. package/dist/chat/utils/ui.d.ts +0 -10
  82. package/dist/common/action-router.d.ts +0 -26
  83. package/dist/common/activity-tracker.d.ts +0 -37
  84. package/dist/common/analytics-events.d.ts +0 -91
  85. package/dist/common/analytics.d.ts +0 -61
  86. package/dist/common/api-paths.d.ts +0 -15
  87. package/dist/common/client.d.ts +0 -27
  88. package/dist/common/communication-bridge.d.ts +0 -51
  89. package/dist/common/config-constants.d.ts +0 -1
  90. package/dist/common/config-schema.d.ts +0 -81
  91. package/dist/common/connection-warning.d.ts +0 -8
  92. package/dist/common/consulting-sources.d.ts +0 -9
  93. package/dist/common/context.d.ts +0 -27
  94. package/dist/common/css-escape.d.ts +0 -1
  95. package/dist/common/customization-factories.d.ts +0 -62
  96. package/dist/common/debug.d.ts +0 -13
  97. package/dist/common/events.d.ts +0 -46
  98. package/dist/common/fastIntent.d.ts +0 -1
  99. package/dist/common/find-similar-payload.d.ts +0 -3
  100. package/dist/common/ga-datalayer.d.ts +0 -89
  101. package/dist/common/global-error-toast.d.ts +0 -6
  102. package/dist/common/index.d.ts +0 -50
  103. package/dist/common/indexed-db.d.ts +0 -79
  104. package/dist/common/locale.d.ts +0 -1
  105. package/dist/common/native-webview.d.ts +0 -60
  106. package/dist/common/navigation.d.ts +0 -5
  107. package/dist/common/overlay.d.ts +0 -168
  108. package/dist/common/page-detect.d.ts +0 -30
  109. package/dist/common/pill-launcher.d.ts +0 -51
  110. package/dist/common/preflight.d.ts +0 -13
  111. package/dist/common/price-formatter.d.ts +0 -35
  112. package/dist/common/product-utils.d.ts +0 -35
  113. package/dist/common/protocol-adapter.d.ts +0 -105
  114. package/dist/common/renderer/dom.d.ts +0 -3
  115. package/dist/common/renderer/index.d.ts +0 -4
  116. package/dist/common/renderer/overrides.d.ts +0 -23
  117. package/dist/common/renderer/registry.d.ts +0 -2
  118. package/dist/common/renderer/types.d.ts +0 -19
  119. package/dist/common/safe-html.d.ts +0 -22
  120. package/dist/common/sdk-version.d.ts +0 -3
  121. package/dist/common/skeleton.d.ts +0 -8
  122. package/dist/common/streaming.d.ts +0 -37
  123. package/dist/common/suggested-search-keywords.d.ts +0 -18
  124. package/dist/common/theme-utils.d.ts +0 -15
  125. package/dist/common/tts-player.d.ts +0 -13
  126. package/dist/common/types.d.ts +0 -381
  127. package/dist/common/ui-theme.d.ts +0 -9
  128. package/dist/common/uuidv7.d.ts +0 -7
  129. package/dist/common/voice-input.d.ts +0 -74
  130. package/dist/common/widget-base.d.ts +0 -97
  131. package/dist/common-BM2ZsSLI.js +0 -491
  132. package/dist/index.d.ts +0 -25
  133. package/dist/native/index.d.ts +0 -2
  134. package/dist/overlay.d.ts +0 -4
  135. package/dist/qna/api.d.ts +0 -23
  136. package/dist/qna/catalog.d.ts +0 -73
  137. package/dist/qna/components/ButtonRow.d.ts +0 -15
  138. package/dist/qna/components/TextInput.d.ts +0 -11
  139. package/dist/qna/components/renderUISpec.d.ts +0 -7
  140. package/dist/qna/index.d.ts +0 -3
  141. package/dist/qna/locales/en.d.ts +0 -2
  142. package/dist/qna/locales/index.d.ts +0 -5
  143. package/dist/qna/locales/tr.d.ts +0 -2
  144. package/dist/qna/normalize-ui-specs.d.ts +0 -15
  145. package/dist/qna/runtime.d.ts +0 -62
  146. package/dist/qna/types.d.ts +0 -98
  147. package/dist/runtime-bbMljGVG.js +0 -688
  148. package/dist/simbut/index.d.ts +0 -22
  149. package/dist/simbut/locales.d.ts +0 -3
  150. package/dist/simbut/types.d.ts +0 -43
  151. package/dist/simrel/api.d.ts +0 -25
  152. package/dist/simrel/catalog.d.ts +0 -110
  153. package/dist/simrel/components/GroupTabs.d.ts +0 -24
  154. package/dist/simrel/components/ProductCard.d.ts +0 -19
  155. package/dist/simrel/components/ProductGrid.d.ts +0 -17
  156. package/dist/simrel/components/renderUISpec.d.ts +0 -7
  157. package/dist/simrel/index.d.ts +0 -5
  158. package/dist/simrel/locales/en.d.ts +0 -2
  159. package/dist/simrel/locales/index.d.ts +0 -5
  160. package/dist/simrel/locales/tr.d.ts +0 -2
  161. package/dist/simrel/renderers/default.d.ts +0 -40
  162. package/dist/simrel/runtime.d.ts +0 -59
  163. package/dist/simrel/types.d.ts +0 -141
  164. package/dist/widget-base-Cf9ofZhh.js +0 -589
  165. /package/dist/{context-DGz5F81j.js → context-BBuSsXZ9.js} +0 -0
package/dist/simrel.js CHANGED
@@ -1,5 +1,5 @@
1
- import { a, i as r, n as t, r as i, t as m } from "./runtime-bbMljGVG.js";
2
- import { n as R, t as n } from "./simrel-zCDlCrqG.js";
1
+ import { a, i as r, n as t, r as i, t as m } from "./runtime-DOS9yRRx.js";
2
+ import { n as R, t as n } from "./simrel-C07wZN8Q.js";
3
3
  export {
4
4
  m as GengageSimRel,
5
5
  i as createDefaultSimRelUISpecRegistry,
@@ -0,0 +1,362 @@
1
+ import { o as m, r as x } from "./context-BBuSsXZ9.js";
2
+ var l = {
3
+ "--gengage-chat-offset": "20px",
4
+ "--gengage-chat-launcher-width": "56px",
5
+ "--gengage-chat-launcher-height": "56px",
6
+ "--gengage-chat-width": "400px",
7
+ "--gengage-chat-shell-radius": "1rem",
8
+ "--gengage-chat-header-height": "72px",
9
+ "--gengage-chat-conversation-width": "396px",
10
+ "--gengage-chat-panel-min-width": "320px",
11
+ "--gengage-chat-panel-max-width": "1200px",
12
+ "--gengage-chat-input-height": "48px",
13
+ "--gengage-qna-pill-radius": "999px",
14
+ "--gengage-qna-input-radius": "12px",
15
+ "--gengage-simrel-card-radius": "0.75rem",
16
+ "--radius-control": "12px",
17
+ "--radius-card": "16px",
18
+ "--radius-panel": "24px",
19
+ "--radius-pill": "999px",
20
+ "--surface-card-muted": "#f8fafc",
21
+ "--text-secondary": "#4b5563",
22
+ "--text-muted": "#6b7280",
23
+ "--border-default": "rgba(17, 24, 39, 0.10)"
24
+ };
25
+ function w(e) {
26
+ if (!e) return { ...l };
27
+ const t = {
28
+ ...l,
29
+ ...e
30
+ }, r = e["--gengage-chat-launcher-size"];
31
+ return r !== void 0 && (e["--gengage-chat-launcher-width"] === void 0 && (t["--gengage-chat-launcher-width"] = r), e["--gengage-chat-launcher-height"] === void 0 && (t["--gengage-chat-launcher-height"] = r)), t;
32
+ }
33
+ var i = {
34
+ primaryColor: "#b7102a",
35
+ primaryForeground: "#ffffff",
36
+ backgroundColor: "#ffffff",
37
+ foregroundColor: "#111827",
38
+ borderRadius: "0.75rem",
39
+ fontFamily: '"Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',
40
+ fontSize: "14px",
41
+ zIndex: "1000",
42
+ "--glov-chatbot-width": "420px",
43
+ "--glov-left-spacing": "260px",
44
+ "--chatbot-padding": "16px",
45
+ "--root-wrapper-background-color": "#f8f9fa",
46
+ "--root-wrapper-border-color": "#edeeef",
47
+ "--gengage-chat-width": "400px",
48
+ "--gengage-chat-shell-radius": "1rem",
49
+ "--gengage-chat-header-height": "72px",
50
+ "--gengage-chat-conversation-width": "396px",
51
+ "--gengage-chat-panel-min-width": "320px",
52
+ "--gengage-chat-panel-max-width": "1200px",
53
+ "--gengage-chat-input-height": "48px",
54
+ "--gengage-qna-pill-radius": "999px",
55
+ "--gengage-qna-input-radius": "0.75rem",
56
+ "--gengage-simrel-card-radius": "0.75rem",
57
+ "--client-primary": "#b7102a",
58
+ "--client-primary-hover": "color-mix(in srgb, #b7102a 88%, black 12%)",
59
+ "--client-primary-active": "color-mix(in srgb, #b7102a 78%, black 22%)",
60
+ "--client-primary-subtle": "color-mix(in srgb, #b7102a 12%, white)",
61
+ "--client-primary-soft": "color-mix(in srgb, #b7102a 20%, white)",
62
+ "--client-on-primary": "#ffffff",
63
+ "--client-focus-ring": "color-mix(in srgb, #b7102a 32%, transparent)",
64
+ "--surface-page": "#f6f7fb",
65
+ "--surface-shell": "#10131a",
66
+ "--surface-card": "#ffffff",
67
+ "--surface-card-muted": "#f8fafc",
68
+ "--surface-card-soft": "#f8fafc",
69
+ "--surface-elevated": "#ffffff",
70
+ "--surface-input": "#ffffff",
71
+ "--surface-overlay": "rgba(16, 19, 26, 0.52)",
72
+ "--text-primary": "#111827",
73
+ "--text-secondary": "#4b5563",
74
+ "--text-muted": "#6b7280",
75
+ "--text-inverse": "#f9fafb",
76
+ "--border-subtle": "rgba(17, 24, 39, 0.06)",
77
+ "--border-default": "rgba(17, 24, 39, 0.10)",
78
+ "--border-strong": "rgba(17, 24, 39, 0.18)",
79
+ "--shadow-1": "0 1px 2px rgba(16, 24, 40, 0.04), 0 1px 3px rgba(16, 24, 40, 0.06)",
80
+ "--shadow-2": "0 4px 12px rgba(16, 24, 40, 0.08)",
81
+ "--shadow-3": "0 10px 24px rgba(16, 24, 40, 0.12)",
82
+ "--radius-control": "12px",
83
+ "--radius-card": "16px",
84
+ "--radius-panel": "24px",
85
+ "--radius-pill": "999px",
86
+ "--success": "#16a34a",
87
+ "--warning": "#d97706",
88
+ "--error": "#dc2626",
89
+ "--info": "#2563eb",
90
+ "--rating": "#f5b301",
91
+ "--ai-accent-start": "#0b24d6",
92
+ "--ai-accent-end": "#f768f2",
93
+ "--ai-accent-soft": "linear-gradient(135deg, rgba(11, 36, 214, 0.08), rgba(247, 104, 242, 0.08))"
94
+ };
95
+ function F(e) {
96
+ return {
97
+ ...i,
98
+ ...e
99
+ };
100
+ }
101
+ var o = "gengage-global-toast-root", u = "gengage-global-toast-style", c = "gengage-global-toast-root--visible", v = 4200, _ = 1500, E = 15e3, T = [
102
+ "--gengage-font-family",
103
+ "--surface-card",
104
+ "--text-primary",
105
+ "--text-muted",
106
+ "--border-default",
107
+ "--radius-card",
108
+ "--shadow-3",
109
+ "--error",
110
+ "--ds-toast-error-bg",
111
+ "--ds-toast-error-border",
112
+ "--ds-toast-error-accent",
113
+ "--ds-toast-error-fg",
114
+ "--ds-toast-error-shadow"
115
+ ], f = !1, s = null, C = [
116
+ /failed to fetch/i,
117
+ /networkerror/i,
118
+ /network request failed/i,
119
+ /load failed/i,
120
+ /err_network/i,
121
+ /fetch failed/i,
122
+ /network error/i
123
+ ];
124
+ function h(e) {
125
+ return typeof e == "string" && e.toLowerCase().startsWith("tr");
126
+ }
127
+ function I(e) {
128
+ if (typeof navigator < "u" && navigator.onLine === !1) return !0;
129
+ const t = e instanceof Error ? e.message.trim() : "";
130
+ return t ? C.some((r) => r.test(t)) : !1;
131
+ }
132
+ function H(e, t) {
133
+ return I(t) ? h(e) ? "Bağlantı sorunu oluştu. Lütfen tekrar deneyin." : "Connection issue. Please try again." : h(e) ? "Bir hata oluştu. Lütfen tekrar deneyin." : "Something went wrong. Please try again.";
134
+ }
135
+ function S() {
136
+ f || typeof window > "u" || typeof document > "u" || (f = !0, m("gengage:global:error", (e) => {
137
+ k(e);
138
+ }));
139
+ }
140
+ function k(e) {
141
+ if (typeof document > "u") return;
142
+ const t = e.message.trim();
143
+ if (!t) return;
144
+ A();
145
+ const r = $();
146
+ M(r), r.innerHTML = "";
147
+ const a = document.createElement("section");
148
+ a.className = "gengage-global-toast gengage-global-toast--error", a.setAttribute("role", "status"), a.setAttribute("aria-live", "polite");
149
+ const n = document.createElement("div");
150
+ n.className = "gengage-global-toast-title", n.textContent = R(e.source);
151
+ const g = document.createElement("div");
152
+ g.className = "gengage-global-toast-message", g.textContent = t, a.appendChild(n), a.appendChild(g), r.appendChild(a), r.classList.add(c), s && (clearTimeout(s), s = null), e.sticky !== !0 && (s = setTimeout(() => {
153
+ L();
154
+ }, N(e.durationMs)));
155
+ }
156
+ function L() {
157
+ if (typeof document > "u") return;
158
+ const e = document.getElementById(o);
159
+ e && (e.classList.remove(c), e.innerHTML = "", s && (clearTimeout(s), s = null));
160
+ }
161
+ function R(e) {
162
+ switch (e) {
163
+ case "chat":
164
+ return "Chat warning";
165
+ case "qna":
166
+ return "QnA warning";
167
+ case "simrel":
168
+ return "Widget warning";
169
+ default:
170
+ return "Connection warning";
171
+ }
172
+ }
173
+ function $() {
174
+ const e = document.getElementById(o);
175
+ if (e instanceof HTMLElement) return e;
176
+ const t = document.createElement("div");
177
+ return t.id = o, t.className = "gengage-global-toast-root", document.body.appendChild(t), t;
178
+ }
179
+ function M(e) {
180
+ if (typeof document > "u" || typeof window > "u") return;
181
+ const t = document.querySelector(".gengage-chat-root, .gengage-qna-container, .gengage-simrel-container, .gengage-simbut-root");
182
+ if (!t) return;
183
+ const r = window.getComputedStyle(t);
184
+ for (const a of T) {
185
+ const n = r.getPropertyValue(a).trim();
186
+ n ? e.style.setProperty(a, n) : e.style.removeProperty(a);
187
+ }
188
+ }
189
+ function N(e) {
190
+ return typeof e != "number" || !Number.isFinite(e) ? v : Math.min(E, Math.max(_, Math.round(e)));
191
+ }
192
+ function A() {
193
+ if (document.getElementById(u)) return;
194
+ const e = document.createElement("style");
195
+ e.id = u;
196
+ const t = i["--surface-card"] ?? i.backgroundColor ?? "#ffffff", r = i["--text-primary"] ?? i.foregroundColor ?? "#111827", a = i["--border-default"] ?? "rgba(17, 24, 39, 0.10)", n = i["--error"] ?? "#dc2626", g = i["--shadow-3"] ?? "0 10px 24px rgba(16, 24, 40, 0.12)", b = i["--radius-card"] ?? "16px", y = i["--text-muted"] ?? "#6b7280";
197
+ e.textContent = `
198
+ #${o} {
199
+ position: fixed;
200
+ top: 16px;
201
+ right: 16px;
202
+ z-index: 2147483646;
203
+ pointer-events: none;
204
+ }
205
+ #${o}.${c} {
206
+ pointer-events: auto;
207
+ }
208
+ #${o} .gengage-global-toast {
209
+ min-width: 260px;
210
+ max-width: min(92vw, 420px);
211
+ border-radius: var(--radius-card, ${b});
212
+ border: 1px solid var(--ds-toast-error-border, color-mix(in srgb, var(--error, ${n}) 18%, var(--border-default, ${a})));
213
+ border-left: 4px solid var(--ds-toast-error-accent, var(--error, ${n}));
214
+ background: var(--ds-toast-error-bg, color-mix(in srgb, var(--error, ${n}) 5%, var(--surface-card, ${t})));
215
+ color: var(--ds-toast-error-fg, color-mix(in srgb, var(--error, ${n}) 22%, var(--text-primary, ${r})));
216
+ box-shadow: var(--ds-toast-error-shadow, var(--shadow-3, ${g}));
217
+ padding: 10px 12px;
218
+ font-family: var(--gengage-font-family, ${JSON.stringify(i.fontFamily ?? '-apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif')});
219
+ font-size: 13px;
220
+ line-height: 1.4;
221
+ animation: gengage-global-toast-in 180ms ease-out forwards;
222
+ }
223
+ #${o} .gengage-global-toast-title {
224
+ margin: 0 0 4px;
225
+ font-size: 12px;
226
+ font-weight: 700;
227
+ color: var(--text-muted, ${y});
228
+ }
229
+ #${o} .gengage-global-toast-message {
230
+ margin: 0;
231
+ font-weight: 500;
232
+ }
233
+ @keyframes gengage-global-toast-in {
234
+ from {
235
+ opacity: 0;
236
+ transform: translateY(-8px);
237
+ }
238
+ to {
239
+ opacity: 1;
240
+ transform: translateY(0);
241
+ }
242
+ }
243
+ `, document.head.appendChild(e);
244
+ }
245
+ var d = null;
246
+ function O() {
247
+ if (d !== null) return d;
248
+ try {
249
+ d = localStorage.getItem("gengage:debug") === "1";
250
+ } catch {
251
+ d = !1;
252
+ }
253
+ return d;
254
+ }
255
+ function p(e, t, r) {
256
+ if (!O()) return;
257
+ const a = [`[gengage:${e}]`, t];
258
+ r !== void 0 && a.push(r), console.debug(...a);
259
+ }
260
+ var D = ("0.5.0".trim(), "0.5.0".trim()), B = ("package-build".trim(), "package-build".trim());
261
+ function G() {
262
+ if (typeof window > "u") return;
263
+ const e = window;
264
+ e.__gengageSdkRuntimeInfoLogged || (e.__gengageSdkRuntimeInfoLogged = !0, console.info(`[gengage] @gengage/assistant-fe v${D} (${B})`));
265
+ }
266
+ var P = class {
267
+ constructor() {
268
+ this.isVisible = !1, this.isInitialised = !1, this._handlers = /* @__PURE__ */ new Map(), this._cleanups = [], this._ownsRoot = !1, this._destroying = !1;
269
+ }
270
+ async init(e) {
271
+ if (this.isInitialised) {
272
+ console.warn("[gengage] Widget already initialised. Call update() instead.");
273
+ return;
274
+ }
275
+ const t = w(e.theme);
276
+ G(), this.config = {
277
+ ...e,
278
+ theme: t,
279
+ session: x(e.session)
280
+ }, this.root = this._resolveMount(e.mountTarget), this._applyTheme(t), S();
281
+ const r = m("gengage:context:update", (a) => this.update(a));
282
+ this._cleanups.push(r), p("lifecycle", `${this.constructor.name}.init`, {
283
+ accountId: e.accountId,
284
+ sku: e.pageContext?.sku
285
+ });
286
+ try {
287
+ await this.onInit(this.config);
288
+ } catch (a) {
289
+ throw this.destroy(), a;
290
+ }
291
+ this._destroying || (this.isInitialised = !0, p("lifecycle", `${this.constructor.name} ready`), this.emit("ready"));
292
+ }
293
+ update(e) {
294
+ this.isInitialised && (this.config.pageContext ? this.config = {
295
+ ...this.config,
296
+ pageContext: {
297
+ ...this.config.pageContext,
298
+ ...e
299
+ }
300
+ } : e.pageType !== void 0 && (this.config = {
301
+ ...this.config,
302
+ pageContext: e
303
+ }), this.onUpdate(e), this.emit("context-update", this.config.pageContext));
304
+ }
305
+ show() {
306
+ this.isVisible || (this.isVisible = !0, this.root.style.display = "", this.onShow(), this.emit("show"));
307
+ }
308
+ hide() {
309
+ this.isVisible && (this.isVisible = !1, this.root.style.display = "none", this.onHide(), this.emit("hide"));
310
+ }
311
+ destroy() {
312
+ this._destroying || (this._destroying = !0, this.emit("destroy"), this._cleanups.forEach((e) => e()), this._cleanups.length = 0, this._handlers.clear(), this.onDestroy(), this._cleanupRoot(), this.isInitialised = !1);
313
+ }
314
+ _cleanupRoot() {
315
+ this._ownsRoot ? this.root.remove() : this.root.innerHTML = "";
316
+ }
317
+ on(e, t) {
318
+ return this._handlers.has(e) || this._handlers.set(e, /* @__PURE__ */ new Set()), this._handlers.get(e).add(t), () => this._handlers.get(e)?.delete(t);
319
+ }
320
+ emit(e, ...t) {
321
+ this._handlers.get(e)?.forEach((r) => r(...t));
322
+ }
323
+ addCleanup(e) {
324
+ this._cleanups.push(e);
325
+ }
326
+ _resolveMount(e) {
327
+ if (e instanceof HTMLElement) return e;
328
+ if (typeof e == "string") {
329
+ const r = document.querySelector(e);
330
+ if (!r) throw new Error(`[gengage] Mount target not found: "${e}"`);
331
+ return r;
332
+ }
333
+ const t = document.createElement("div");
334
+ return t.dataset.gengageWidget = this.constructor.name.toLowerCase(), document.body.insertBefore(t, document.body.firstChild), this._ownsRoot = !0, t;
335
+ }
336
+ _applyTheme(e) {
337
+ if (e) {
338
+ for (const [t, r] of Object.entries(e)) if (r !== void 0) {
339
+ const a = t.startsWith("--") ? t : `--gengage-${V(t)}`;
340
+ this.root.style.setProperty(a, r);
341
+ }
342
+ }
343
+ }
344
+ };
345
+ function V(e) {
346
+ return e.replace(/([A-Z])/g, "-$1").toLowerCase();
347
+ }
348
+ export {
349
+ L as a,
350
+ S as c,
351
+ F as d,
352
+ l as f,
353
+ p as i,
354
+ k as l,
355
+ B as n,
356
+ H as o,
357
+ w as p,
358
+ D as r,
359
+ I as s,
360
+ P as t,
361
+ i as u
362
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gengage/assistant-fe",
3
- "version": "0.4.20",
3
+ "version": "0.5.0",
4
4
  "description": "Source-available frontend widgets for Gengage AI Assistant — chat, Q&A, and similar-products. Backend is SaaS (gengage.ai).",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "type": "module",
@@ -90,8 +90,8 @@
90
90
  },
91
91
  "types": "./dist/index.d.ts",
92
92
  "scripts": {
93
- "build": "tsc && vite build && tsx scripts/build-iife.ts",
94
- "build:lib": "tsc && vite build",
93
+ "build": "tsc -p tsconfig.src.json && vite build && tsx scripts/build-iife.ts",
94
+ "build:lib": "tsc -p tsconfig.src.json && vite build",
95
95
  "build:iife": "tsx scripts/build-iife.ts",
96
96
  "build:demos": "vite build --config vite.config.demos.ts",
97
97
  "dev": "node --env-file=.env --import=tsx/esm scripts/dev.ts",
@@ -124,11 +124,14 @@
124
124
  "teknosacom": "npm run dev -- teknosacom --sku=125077817",
125
125
  "skecherscomtr": "npm run dev -- skecherscomtr --sku=232700",
126
126
  "kill": "tsx scripts/kill.ts",
127
- "typecheck": "tsc --noEmit",
127
+ "typecheck": "tsc --noEmit -p tsconfig.src.json",
128
128
  "typecheck:catalog": "tsc --noEmit -p catalog/tsconfig.json",
129
+ "typecheck:tests": "tsc --noEmit -p tsconfig.tests.json",
130
+ "typecheck:tools": "tsc --noEmit -p tsconfig.tools.json",
129
131
  "lint": "eslint src",
130
132
  "lint:fix": "eslint src --fix",
131
- "format": "prettier --write \"src/**/*.{ts,tsx,css}\" \"catalog/**/*.{ts,tsx,css,js,html}\" \"demos/**/*.{ts,tsx,css,js,html}\" \"tests/**/*.ts\" \"scripts/**/*.ts\" && eslint src --fix && npm run typecheck && npm run typecheck:catalog",
133
+ "check:css": "tsx scripts/check-css-compat.ts",
134
+ "format": "prettier --write \"src/**/*.{ts,tsx,css}\" \"catalog/**/*.{ts,tsx,css,js,html}\" \"demos/**/*.{ts,tsx,css,js,html}\" \"tests/**/*.ts\" \"scripts/**/*.ts\" && eslint src --fix && npm run check:css && npm run typecheck && npm run typecheck:catalog && npm run typecheck:tests && npm run typecheck:tools",
132
135
  "test:chat-history": "vitest run tests/history-storage.test.ts tests/save-session-navigate.test.ts tests/chat-drawer-panel.test.ts tests/chat-open.test.ts tests/session-restore.test.ts tests/session-persistence.test.ts tests/chat-panel-state-restore.test.ts",
133
136
  "test": "npm run test:unit && npm run test:e2e",
134
137
  "test:unit": "vitest run",
@@ -176,7 +179,6 @@
176
179
  }
177
180
  },
178
181
  "dependencies": {
179
- "@json-render/core": "^0.19.0",
180
182
  "zod": "^4.3.6"
181
183
  },
182
184
  "overrides": {
@@ -1,88 +0,0 @@
1
- import { StreamEvent, UISpec, PageContext } from '../common/types.js';
2
- import { ChatTransportConfig } from '../common/api-paths.js';
3
- export interface BackendRequestMeta {
4
- outputLanguage: string;
5
- parentUrl: string;
6
- windowWidth: string;
7
- windowHeight: string;
8
- selfUrl: string;
9
- id: string;
10
- userId: string;
11
- appId: string;
12
- threads: unknown[];
13
- createdAt: string;
14
- kvkkApproved: boolean;
15
- voiceEnabled: boolean;
16
- threadId: string;
17
- isControlGroup: boolean;
18
- isMobile: boolean;
19
- viewId?: string;
20
- assistantMode?: string;
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?: import('../common/types.js').BackendContext | null | undefined;
56
- isMobile?: boolean | undefined;
57
- }
58
- /**
59
- * Enriches action payloads with fields the backend expects.
60
- * Only adds fields that are not already present in the payload.
61
- */
62
- export declare function enrichActionPayload(action: {
63
- title: string;
64
- type: string;
65
- payload?: unknown;
66
- }, ctx: ActionEnrichmentContext): {
67
- title: string;
68
- type: string;
69
- payload?: unknown;
70
- };
71
- export interface StreamCallbacks {
72
- onTextChunk: (content: string, isFinal: boolean, extra?: {
73
- productMentions?: Array<{
74
- sku: string;
75
- short_name: string;
76
- }> | undefined;
77
- skuToProductItem?: Record<string, Record<string, unknown>> | undefined;
78
- conversationMode?: string | undefined;
79
- renderHint?: string | undefined;
80
- kvkk?: boolean | undefined;
81
- }) => void;
82
- onUISpec: (spec: UISpec, widget: string, panelHint?: 'panel', clearPanel?: boolean) => void;
83
- onAction: (event: StreamEvent) => void;
84
- onMetadata: (event: StreamEvent) => void;
85
- onError: (err: Error) => void;
86
- onDone: () => void;
87
- }
88
- export declare function sendChatMessage(request: ProcessActionRequest, callbacks: StreamCallbacks, transport: ChatTransportConfig): AbortController;
@@ -1,19 +0,0 @@
1
- /**
2
- * Assistant-mode utilities for the chat widget.
3
- *
4
- * The chat widget can operate in multiple modes (shopping, beauty consulting,
5
- * watch expert, booking). This module contains the type, parsing helpers, and
6
- * recognised mode list so the main index.ts stays focused on orchestration.
7
- */
8
- export type AssistantMode = 'shopping' | 'booking' | 'beauty_consulting' | 'watch_expert';
9
- /** Return the value as an AssistantMode if it is a known mode string, otherwise null. */
10
- export declare function toAssistantMode(value: unknown): AssistantMode | null;
11
- /** Safely cast an unknown value to a plain Record, or null. */
12
- export declare function asRecord(value: unknown): Record<string, unknown> | null;
13
- /** Return the first non-empty string among the given values. */
14
- export declare function firstString(...values: unknown[]): string | undefined;
15
- /**
16
- * Parse a redirect metadata payload and return the target assistant mode,
17
- * or `null` if the payload is not a valid mode-switch redirect.
18
- */
19
- export declare function parseRedirectMode(redirectPayload: unknown): AssistantMode | null;
@@ -1,9 +0,0 @@
1
- export declare const ALLOWED_MIME_TYPES: readonly ["image/jpeg", "image/png", "image/webp"];
2
- export declare const MAX_FILE_SIZE: number;
3
- export type ValidationResult = {
4
- ok: true;
5
- } | {
6
- ok: false;
7
- reason: 'invalid_type' | 'too_large';
8
- };
9
- export declare function validateImageFile(file: File): ValidationResult;