@memori.ai/memori-react 9.0.2 → 9.0.4
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/CHANGELOG.md +21 -0
- package/README.md +2 -0
- package/dist/components/Header/Header.d.ts +1 -0
- package/dist/components/Header/Header.js +7 -6
- package/dist/components/Header/Header.js.map +1 -1
- package/dist/components/MemoriArtifactSystem/useArtifactColumnResize.d.ts +8 -0
- package/dist/components/MemoriArtifactSystem/useArtifactColumnResize.js +97 -0
- package/dist/components/MemoriArtifactSystem/useArtifactColumnResize.js.map +1 -0
- package/dist/components/MemoriWidget/MemoriWidget.d.ts +2 -1
- package/dist/components/MemoriWidget/MemoriWidget.js +40 -27
- package/dist/components/MemoriWidget/MemoriWidget.js.map +1 -1
- package/dist/components/StartPanel/StartPanel.css +17 -0
- package/dist/components/StartPanel/StartPanel.d.ts +1 -0
- package/dist/components/StartPanel/StartPanel.js +4 -3
- package/dist/components/StartPanel/StartPanel.js.map +1 -1
- package/dist/components/layouts/Chat.js +12 -7
- package/dist/components/layouts/Chat.js.map +1 -1
- package/dist/components/layouts/FullPage.js +7 -71
- package/dist/components/layouts/FullPage.js.map +1 -1
- package/dist/components/layouts/HiddenChat.js +1 -1
- package/dist/components/layouts/HiddenChat.js.map +1 -1
- package/dist/components/layouts/WebsiteAssistant/WebsiteAssistant.js +3 -2
- package/dist/components/layouts/WebsiteAssistant/WebsiteAssistant.js.map +1 -1
- package/dist/components/layouts/ZoomedFullBody.js +7 -71
- package/dist/components/layouts/ZoomedFullBody.js.map +1 -1
- package/dist/components/layouts/chat.css +58 -2
- package/dist/helpers/credits.d.ts +6 -2
- package/dist/helpers/credits.js +16 -8
- package/dist/helpers/credits.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/locales/de.json +1 -0
- package/dist/locales/en.json +1 -0
- package/dist/locales/es.json +1 -0
- package/dist/locales/fr.json +1 -0
- package/dist/locales/it.json +1 -0
- package/dist/styles.css +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/esm/components/Header/Header.d.ts +1 -0
- package/esm/components/Header/Header.js +7 -6
- package/esm/components/Header/Header.js.map +1 -1
- package/esm/components/MemoriArtifactSystem/useArtifactColumnResize.d.ts +8 -0
- package/esm/components/MemoriArtifactSystem/useArtifactColumnResize.js +94 -0
- package/esm/components/MemoriArtifactSystem/useArtifactColumnResize.js.map +1 -0
- package/esm/components/MemoriWidget/MemoriWidget.d.ts +2 -1
- package/esm/components/MemoriWidget/MemoriWidget.js +41 -28
- package/esm/components/MemoriWidget/MemoriWidget.js.map +1 -1
- package/esm/components/StartPanel/StartPanel.css +17 -0
- package/esm/components/StartPanel/StartPanel.d.ts +1 -0
- package/esm/components/StartPanel/StartPanel.js +5 -4
- package/esm/components/StartPanel/StartPanel.js.map +1 -1
- package/esm/components/layouts/Chat.js +12 -7
- package/esm/components/layouts/Chat.js.map +1 -1
- package/esm/components/layouts/FullPage.js +8 -72
- package/esm/components/layouts/FullPage.js.map +1 -1
- package/esm/components/layouts/HiddenChat.js +1 -1
- package/esm/components/layouts/HiddenChat.js.map +1 -1
- package/esm/components/layouts/WebsiteAssistant/WebsiteAssistant.js +3 -2
- package/esm/components/layouts/WebsiteAssistant/WebsiteAssistant.js.map +1 -1
- package/esm/components/layouts/ZoomedFullBody.js +8 -72
- package/esm/components/layouts/ZoomedFullBody.js.map +1 -1
- package/esm/components/layouts/chat.css +58 -2
- package/esm/helpers/credits.d.ts +6 -2
- package/esm/helpers/credits.js +14 -7
- package/esm/helpers/credits.js.map +1 -1
- package/esm/index.d.ts +1 -0
- package/esm/index.js +3 -1
- package/esm/index.js.map +1 -1
- package/esm/locales/de.json +1 -0
- package/esm/locales/en.json +1 -0
- package/esm/locales/es.json +1 -0
- package/esm/locales/fr.json +1 -0
- package/esm/locales/it.json +1 -0
- package/esm/styles.css +1 -1
- package/esm/version.d.ts +1 -1
- package/esm/version.js +1 -1
- package/package.json +4 -4
|
@@ -199,8 +199,8 @@ function getChatStyles(config) {
|
|
|
199
199
|
'--memori-icon-recording-bg': 'color-mix(in oklch, var(--memori-error) 12%, transparent)',
|
|
200
200
|
};
|
|
201
201
|
}
|
|
202
|
-
const MemoriWidget = ({ memori, memoriConfigs, ownerUserID,
|
|
203
|
-
var _a, _b, _c, _d, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17;
|
|
202
|
+
const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, tenantID, memoriLang, uiLang, spokenLang, multilingual, integration, layout, customLayout, showShare, preview = false, embed = false, showCopyButton, showTranslationOriginal, showInputs = true, showDates = false, showContextPerLine = false, showMessageConsumption, showSettings, showTypingText, showClear, showExperts, showLogin, showUpload, showOnlyLastMessages, showChatHistory, showReasoning, show3dAvatar, avatar3dHidden, height: heightProp, secret, baseUrl = 'https://aisuru-staging.aclambda.online', apiURL = 'https://backend-staging.memori.ai', engineURL = 'https://engine-staging.memori.ai', initialContextVars, initialQuestion, ttsProvider, ogImage, sessionID: initialSessionID, tenant, personification, authToken, enableAudio, defaultSpeakerActive = true, disableTextEnteredEvents = false, onStateChange, additionalInfo, additionalSettings, customMediaRenderer, userAvatar, __WEBCOMPONENT__ = false, useMathFormatting = false, autoStart = false, applyVarsToRoot = false, showFunctionCache = false, maxTotalMessagePayload, maxTextareaCharacters, }) => {
|
|
203
|
+
var _a, _b, _c, _d, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18;
|
|
204
204
|
const { t, i18n } = (0, react_i18next_1.useTranslation)();
|
|
205
205
|
const { add, close } = (0, ui_1.useAlertManager)();
|
|
206
206
|
const [isClient, setIsClient] = (0, react_1.useState)(false);
|
|
@@ -282,6 +282,8 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
282
282
|
const sessionStartingRef = (0, react_1.useRef)(false);
|
|
283
283
|
const needsCredits = tenant === null || tenant === void 0 ? void 0 : tenant.billingDelegation;
|
|
284
284
|
const [hasEnoughCredits, setHasEnoughCredits] = (0, react_1.useState)(true);
|
|
285
|
+
const [creditsCheckFailed, setCreditsCheckFailed] = (0, react_1.useState)(false);
|
|
286
|
+
const creditsBlocked = !!needsCredits && (!hasEnoughCredits || creditsCheckFailed);
|
|
285
287
|
const language = ((_h = (_g = (_f = memori.culture) === null || _f === void 0 ? void 0 : _f.split('-')) === null || _g === void 0 ? void 0 : _g[0]) === null || _h === void 0 ? void 0 : _h.toUpperCase()) ||
|
|
286
288
|
((_m = (_l = (_k = (_j = memoriConfigs === null || memoriConfigs === void 0 ? void 0 : memoriConfigs.find(c => c.memoriConfigID === memori.memoriConfigurationID)) === null || _j === void 0 ? void 0 : _j.culture) === null || _k === void 0 ? void 0 : _k.split('-')) === null || _l === void 0 ? void 0 : _l[0]) === null || _m === void 0 ? void 0 : _m.toUpperCase());
|
|
287
289
|
const isMultilanguageEnabled = multilingual !== undefined
|
|
@@ -2163,7 +2165,7 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
2163
2165
|
!sessionId &&
|
|
2164
2166
|
autoStart &&
|
|
2165
2167
|
(!isCollapsibleLayout || layoutOpen) &&
|
|
2166
|
-
|
|
2168
|
+
!creditsBlocked &&
|
|
2167
2169
|
!(0, positionPopover_1.shouldHoldAutoStartForPosition)(!!memori.needsPosition, hasPosition) &&
|
|
2168
2170
|
!(0, autoStart_1.shouldHoldAutoStartForLogin)(!!memori.requireLoginToken, isUserLoggedIn)) {
|
|
2169
2171
|
autoStartAttemptedRef.current = true;
|
|
@@ -2175,8 +2177,7 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
2175
2177
|
isCollapsibleLayout,
|
|
2176
2178
|
layoutOpen,
|
|
2177
2179
|
sessionId,
|
|
2178
|
-
|
|
2179
|
-
hasEnoughCredits,
|
|
2180
|
+
creditsBlocked,
|
|
2180
2181
|
position,
|
|
2181
2182
|
memori.needsPosition,
|
|
2182
2183
|
memori.requireLoginToken,
|
|
@@ -2249,28 +2250,29 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
2249
2250
|
severity: 'error',
|
|
2250
2251
|
}));
|
|
2251
2252
|
}, [add, t]);
|
|
2253
|
+
const handleCreditsCheckFailed = (0, react_1.useCallback)(() => {
|
|
2254
|
+
setAuthModalState(null);
|
|
2255
|
+
add((0, ui_1.createAlertOptions)({
|
|
2256
|
+
description: t('creditsCheckFailed'),
|
|
2257
|
+
severity: 'error',
|
|
2258
|
+
}));
|
|
2259
|
+
}, [add, t]);
|
|
2260
|
+
const creditsOwnerUserID = ownerUserID !== null && ownerUserID !== void 0 ? ownerUserID : memori.ownerUserID;
|
|
2261
|
+
const creditsEngineMemoriID = memori.engineMemoriID;
|
|
2252
2262
|
const checkCredits = (0, react_1.useCallback)(async (options) => {
|
|
2253
2263
|
if (!(tenant === null || tenant === void 0 ? void 0 : tenant.billingDelegation))
|
|
2254
2264
|
return true;
|
|
2255
|
-
if (!ownerUserID && !ownerUserName) {
|
|
2256
|
-
if (options === null || options === void 0 ? void 0 : options.notify) {
|
|
2257
|
-
handleNotEnoughCredits();
|
|
2258
|
-
}
|
|
2259
|
-
else {
|
|
2260
|
-
setHasEnoughCredits(false);
|
|
2261
|
-
}
|
|
2262
|
-
return false;
|
|
2263
|
-
}
|
|
2264
2265
|
try {
|
|
2265
2266
|
const resp = await (0, credits_1.getCredits)({
|
|
2266
2267
|
operation: deepThoughtEnabled
|
|
2267
2268
|
? 'dt_session_creation'
|
|
2268
2269
|
: 'session_creation',
|
|
2269
2270
|
baseUrl: baseUrl,
|
|
2270
|
-
userID:
|
|
2271
|
-
|
|
2271
|
+
userID: creditsOwnerUserID,
|
|
2272
|
+
engineMemoriID: creditsEngineMemoriID,
|
|
2272
2273
|
tenant: tenantID,
|
|
2273
2274
|
});
|
|
2275
|
+
setCreditsCheckFailed(false);
|
|
2274
2276
|
if (resp.enough) {
|
|
2275
2277
|
setHasEnoughCredits(true);
|
|
2276
2278
|
return true;
|
|
@@ -2287,14 +2289,22 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
2287
2289
|
}
|
|
2288
2290
|
catch (err) {
|
|
2289
2291
|
logWidgetError('checkCredits failed', err);
|
|
2290
|
-
|
|
2292
|
+
const isRejected = err instanceof credits_1.CreditsCheckError &&
|
|
2293
|
+
(err.status === undefined || (err.status >= 400 && err.status < 500));
|
|
2294
|
+
if (!isRejected)
|
|
2295
|
+
return true;
|
|
2296
|
+
setCreditsCheckFailed(true);
|
|
2297
|
+
if (options === null || options === void 0 ? void 0 : options.notify)
|
|
2298
|
+
handleCreditsCheckFailed();
|
|
2299
|
+
return false;
|
|
2291
2300
|
}
|
|
2292
2301
|
}, [
|
|
2293
2302
|
baseUrl,
|
|
2294
2303
|
deepThoughtEnabled,
|
|
2295
2304
|
handleNotEnoughCredits,
|
|
2296
|
-
|
|
2297
|
-
|
|
2305
|
+
handleCreditsCheckFailed,
|
|
2306
|
+
creditsOwnerUserID,
|
|
2307
|
+
creditsEngineMemoriID,
|
|
2298
2308
|
tenant === null || tenant === void 0 ? void 0 : tenant.billingDelegation,
|
|
2299
2309
|
tenantID,
|
|
2300
2310
|
]);
|
|
@@ -2352,6 +2362,7 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
2352
2362
|
hasUserActivatedSpeak,
|
|
2353
2363
|
showReload: selectedLayout === 'TOTEM',
|
|
2354
2364
|
showClear: (_5 = showClear !== null && showClear !== void 0 ? showClear : integrationConfig === null || integrationConfig === void 0 ? void 0 : integrationConfig.showClear) !== null && _5 !== void 0 ? _5 : false,
|
|
2365
|
+
showExperts: (_6 = showExperts !== null && showExperts !== void 0 ? showExperts : integrationConfig === null || integrationConfig === void 0 ? void 0 : integrationConfig.showExperts) !== null && _6 !== void 0 ? _6 : false,
|
|
2355
2366
|
clearHistory: () => setHistory(h => h.slice(-1)),
|
|
2356
2367
|
showLogin: canShowLoginButton,
|
|
2357
2368
|
setShowLoginDrawer,
|
|
@@ -2382,7 +2393,7 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
2382
2393
|
hasUserActivatedSpeak,
|
|
2383
2394
|
isPlayingAudio: isPlayingAudio &&
|
|
2384
2395
|
!speakerMuted &&
|
|
2385
|
-
((
|
|
2396
|
+
((_7 = enableAudio !== null && enableAudio !== void 0 ? enableAudio : integrationConfig === null || integrationConfig === void 0 ? void 0 : integrationConfig.enableAudio) !== null && _7 !== void 0 ? _7 : true),
|
|
2386
2397
|
loading: !!memoriTyping,
|
|
2387
2398
|
baseUrl,
|
|
2388
2399
|
apiUrl: client.constants.BACKEND_URL,
|
|
@@ -2412,11 +2423,12 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
2412
2423
|
isUserLoggedIn,
|
|
2413
2424
|
hasInitialSession: !!initialSessionID,
|
|
2414
2425
|
notEnoughCredits: needsCredits && !hasEnoughCredits,
|
|
2426
|
+
creditsCheckFailed: needsCredits && creditsCheckFailed,
|
|
2415
2427
|
showLogin: canShowLoginButton,
|
|
2416
2428
|
setShowLoginDrawer,
|
|
2417
2429
|
showChatHistory: selectedLayout === 'WEBSITE_ASSISTANT'
|
|
2418
2430
|
? false
|
|
2419
|
-
: (
|
|
2431
|
+
: (_8 = showChatHistory !== null && showChatHistory !== void 0 ? showChatHistory : integrationConfig === null || integrationConfig === void 0 ? void 0 : integrationConfig.showChatHistory) !== null && _8 !== void 0 ? _8 : true,
|
|
2420
2432
|
setShowChatHistoryDrawer,
|
|
2421
2433
|
user,
|
|
2422
2434
|
};
|
|
@@ -2426,7 +2438,7 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
2426
2438
|
tenant,
|
|
2427
2439
|
translateTo: isMultilanguageEnabled &&
|
|
2428
2440
|
userLang.toUpperCase() !==
|
|
2429
|
-
((
|
|
2441
|
+
((_13 = ((_12 = (_11 = (_10 = (_9 = memori.culture) === null || _9 === void 0 ? void 0 : _9.split('-')) === null || _10 === void 0 ? void 0 : _10[0]) !== null && _11 !== void 0 ? _11 : i18n.language) !== null && _12 !== void 0 ? _12 : 'IT')) === null || _13 === void 0 ? void 0 : _13.toUpperCase())
|
|
2430
2442
|
? userLang
|
|
2431
2443
|
: undefined,
|
|
2432
2444
|
baseUrl,
|
|
@@ -2434,7 +2446,7 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
2434
2446
|
layout,
|
|
2435
2447
|
memoriTyping,
|
|
2436
2448
|
typingText,
|
|
2437
|
-
showTypingText: (
|
|
2449
|
+
showTypingText: (_14 = showTypingText !== null && showTypingText !== void 0 ? showTypingText : integrationConfig === null || integrationConfig === void 0 ? void 0 : integrationConfig.showTypingText) !== null && _14 !== void 0 ? _14 : false,
|
|
2438
2450
|
history: showFullHistory ? history : history.slice(-2),
|
|
2439
2451
|
authToken: resolveLoginToken(),
|
|
2440
2452
|
dialogState: currentDialogState,
|
|
@@ -2447,8 +2459,8 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
2447
2459
|
showUpload: enableUpload,
|
|
2448
2460
|
showReasoning: enableReasoning,
|
|
2449
2461
|
showWhyThisAnswer,
|
|
2450
|
-
showCopyButton: (
|
|
2451
|
-
showTranslationOriginal: (
|
|
2462
|
+
showCopyButton: (_15 = showCopyButton !== null && showCopyButton !== void 0 ? showCopyButton : integrationConfig === null || integrationConfig === void 0 ? void 0 : integrationConfig.showCopyButton) !== null && _15 !== void 0 ? _15 : true,
|
|
2463
|
+
showTranslationOriginal: (_16 = showTranslationOriginal !== null && showTranslationOriginal !== void 0 ? showTranslationOriginal : integrationConfig === null || integrationConfig === void 0 ? void 0 : integrationConfig.showTranslationOriginal) !== null && _16 !== void 0 ? _16 : false,
|
|
2452
2464
|
client,
|
|
2453
2465
|
instruct,
|
|
2454
2466
|
preview,
|
|
@@ -2459,7 +2471,7 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
2459
2471
|
setAttachmentsMenuOpen,
|
|
2460
2472
|
showInputs: showInputs &&
|
|
2461
2473
|
!(0, autoStart_1.shouldHoldAutoStartForLogin)(!!memori.requireLoginToken, isUserLoggedIn),
|
|
2462
|
-
showMicrophone: !!ttsProvider && ((
|
|
2474
|
+
showMicrophone: !!ttsProvider && ((_17 = enableAudio !== null && enableAudio !== void 0 ? enableAudio : integrationConfig === null || integrationConfig === void 0 ? void 0 : integrationConfig.enableAudio) !== null && _17 !== void 0 ? _17 : true),
|
|
2463
2475
|
showFunctionCache,
|
|
2464
2476
|
userMessage,
|
|
2465
2477
|
onChangeUserMessage,
|
|
@@ -2524,6 +2536,7 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
2524
2536
|
: 'light';
|
|
2525
2537
|
return ((0, jsx_runtime_1.jsx)("div", { ref: setWidgetRootEl, className: (0, classnames_1.default)('memori', 'memori-widget', `memori-layout-${String(selectedLayout).toLowerCase()}`, `memori-controls-${String(controlsPosition).toLowerCase()}`, `memori--avatar-${(integrationConfig === null || integrationConfig === void 0 ? void 0 : integrationConfig.avatar) || 'default'}`, {
|
|
2526
2538
|
'memori--auto-start': autoStart &&
|
|
2539
|
+
!creditsBlocked &&
|
|
2527
2540
|
!(0, positionPopover_1.shouldHoldAutoStartForPosition)(!!memori.needsPosition, !!position) &&
|
|
2528
2541
|
!(0, autoStart_1.shouldHoldAutoStartForLogin)(!!memori.requireLoginToken, isUserLoggedIn),
|
|
2529
2542
|
'memori--preview': preview,
|
|
@@ -2584,7 +2597,7 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
2584
2597
|
}
|
|
2585
2598
|
throw error;
|
|
2586
2599
|
});
|
|
2587
|
-
}, minimumNumberOfRecoveryTokens: (
|
|
2600
|
+
}, minimumNumberOfRecoveryTokens: (_18 = memori === null || memori === void 0 ? void 0 : memori.minimumNumberOfRecoveryTokens) !== null && _18 !== void 0 ? _18 : 1 })), isClient && ((0, jsx_runtime_1.jsx)(AgeVerificationModal_1.default, { visible: showAgeVerification, minAge: minAge, onClose: birthDate => {
|
|
2588
2601
|
var _a, _b, _c, _d;
|
|
2589
2602
|
if (birthDate) {
|
|
2590
2603
|
setBirthDate(birthDate);
|