@krak-stack/registry 0.1.32 → 0.1.34
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/components/ui/code-block.d.ts +8 -6
- package/dist/components/ui/code-block.js +44 -19
- package/dist/components/ui/copy-button.d.ts +9 -6
- package/dist/components/ui/copy-button.js +17 -8
- package/dist/components/ui/data-table.d.ts +9 -5
- package/dist/components/ui/data-table.js +90 -486
- package/dist/components/ui/editing-locale-switcher.d.ts +8 -4
- package/dist/components/ui/editing-locale-switcher.js +26 -448
- package/dist/components/ui/effect-form.d.ts +39 -10
- package/dist/components/ui/effect-form.js +171 -541
- package/dist/components/ui/error-component.d.ts +4 -2
- package/dist/components/ui/error-component.js +28 -450
- package/dist/components/ui/file-picker.d.ts +4 -2
- package/dist/components/ui/file-picker.js +27 -452
- package/dist/components/ui/form.d.ts +123 -71
- package/dist/components/ui/form.js +95 -476
- package/dist/components/ui/google-map.d.ts +3 -2
- package/dist/components/ui/google-map.js +6 -439
- package/dist/components/ui/icon-input.d.ts +50 -1
- package/dist/components/ui/icon-input.js +38 -448
- package/dist/components/ui/krakstack-provider.d.ts +9 -0
- package/dist/components/ui/krakstack-provider.js +28 -0
- package/dist/components/ui/loading.d.ts +7 -1
- package/dist/components/ui/loading.js +6 -438
- package/dist/components/ui/locale-switcher.d.ts +8 -4
- package/dist/components/ui/locale-switcher.js +35 -453
- package/dist/components/ui/pagination.d.ts +5 -3
- package/dist/components/ui/pagination.js +7 -439
- package/dist/components/ui/search-menu.d.ts +4 -2
- package/dist/components/ui/search-menu.js +8 -440
- package/dist/components/ui/theme-switcher.d.ts +5 -3
- package/dist/components/ui/theme-switcher.js +8 -440
- package/dist/components/ui/virtualized-combobox.d.ts +4 -2
- package/dist/components/ui/virtualized-combobox.js +17 -445
- package/dist/lib/docs.d.ts +2 -0
- package/dist/lib/docs.js +92 -481
- package/dist/lib/docs.server.js +4 -20
- package/dist/lib/documentation-toolkit.js +4 -20
- package/dist/lib/markdown/content.d.ts +4 -5
- package/dist/services/agent/client/index.js +81 -463
- package/dist/services/agent/client/widget.d.ts +6 -3
- package/dist/services/notification/client/index.js +11 -440
- package/dist/services/notification/client/notification-menu.d.ts +7 -4
- package/dist/services/notification/public.js +11 -440
- package/package.json +5 -1
- package/dist/paraglide/runtime.d.ts +0 -978
|
@@ -211,12 +211,23 @@ function Button({
|
|
|
211
211
|
// ../../src/components/ui/copy-button.tsx
|
|
212
212
|
import { Check, Copy, TriangleAlert } from "lucide-react";
|
|
213
213
|
import { useEffect, useRef, useState } from "react";
|
|
214
|
+
import { useKrakstackLocale } from "@krak-stack/registry/krakstack-provider";
|
|
214
215
|
import { jsx as jsx2, jsxs } from "react/jsx-runtime";
|
|
216
|
+
var messages = {
|
|
217
|
+
en: { copy: "Copy", copied: "Copied", copyFailed: "Copy failed" },
|
|
218
|
+
fr: { copy: "Copier", copied: "Copié", copyFailed: "Échec de la copie" }
|
|
219
|
+
};
|
|
220
|
+
var copyButtonMessages = (locale = "en", translations) => ({
|
|
221
|
+
...locale.startsWith("fr") ? messages.fr : messages.en,
|
|
222
|
+
...translations?.[locale.split("-")[0] ?? locale],
|
|
223
|
+
...translations?.[locale]
|
|
224
|
+
});
|
|
215
225
|
function CopyButton({
|
|
216
226
|
value,
|
|
217
227
|
valueDescription,
|
|
218
228
|
copyVariant = "default",
|
|
219
|
-
|
|
229
|
+
locale: localeOverride,
|
|
230
|
+
messages: messages2,
|
|
220
231
|
onCopied,
|
|
221
232
|
onCopyError,
|
|
222
233
|
resetDelay = 1500,
|
|
@@ -225,13 +236,10 @@ function CopyButton({
|
|
|
225
236
|
"aria-label": ariaLabel,
|
|
226
237
|
...props
|
|
227
238
|
}) {
|
|
239
|
+
const locale = useKrakstackLocale(localeOverride);
|
|
228
240
|
const [copyState, setCopyState] = useState("idle");
|
|
229
241
|
const copyTimeout = useRef(undefined);
|
|
230
|
-
const labels =
|
|
231
|
-
copy: messages?.copy ?? "Copy",
|
|
232
|
-
copied: messages?.copied ?? "Copied",
|
|
233
|
-
copyFailed: messages?.copyFailed ?? "Copy failed"
|
|
234
|
-
};
|
|
242
|
+
const labels = copyButtonMessages(locale, messages2);
|
|
235
243
|
const accessibleLabel = ariaLabel ?? (valueDescription ? `${labels.copy} ${valueDescription}` : labels.copy);
|
|
236
244
|
const isLarge = copyVariant === "large";
|
|
237
245
|
const defaultSize = copyVariant === "sm" ? "icon-xs" : isLarge ? "sm" : "icon-sm";
|
|
@@ -253,7 +261,7 @@ function CopyButton({
|
|
|
253
261
|
onCopied?.();
|
|
254
262
|
} catch (error) {
|
|
255
263
|
setCopyState("failed");
|
|
256
|
-
onCopyError?.(error instanceof Error ? error : new Error(
|
|
264
|
+
onCopyError?.(error instanceof Error ? error : new Error(labels.copyFailed, { cause: error }));
|
|
257
265
|
}
|
|
258
266
|
resetCopyState();
|
|
259
267
|
};
|
|
@@ -292,6 +300,7 @@ import { highlight } from "@tanstack/highlight";
|
|
|
292
300
|
import { createThemeCss } from "@tanstack/highlight/theme";
|
|
293
301
|
import { githubDarkTheme } from "@tanstack/highlight/themes/github-dark";
|
|
294
302
|
import { githubLightTheme } from "@tanstack/highlight/themes/github-light";
|
|
303
|
+
import { useKrakstackLocale as useKrakstackLocale2 } from "@krak-stack/registry/krakstack-provider";
|
|
295
304
|
import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
296
305
|
var themeCss = `${createThemeCss({
|
|
297
306
|
light: githubLightTheme,
|
|
@@ -309,21 +318,35 @@ var themeCss = `${createThemeCss({
|
|
|
309
318
|
color: inherit;
|
|
310
319
|
}
|
|
311
320
|
[data-code-theme] pre.th-code code { font: inherit; }`;
|
|
321
|
+
var messages2 = {
|
|
322
|
+
en: {
|
|
323
|
+
codeDescription: (language) => `${language} code`,
|
|
324
|
+
copy: "Copy",
|
|
325
|
+
copied: "Copied",
|
|
326
|
+
copyFailed: "Copy failed"
|
|
327
|
+
},
|
|
328
|
+
fr: {
|
|
329
|
+
codeDescription: (language) => `code ${language}`,
|
|
330
|
+
copy: "Copier",
|
|
331
|
+
copied: "Copié",
|
|
332
|
+
copyFailed: "Échec de la copie"
|
|
333
|
+
}
|
|
334
|
+
};
|
|
335
|
+
var codeBlockMessages = (locale = "en", translations) => ({
|
|
336
|
+
...locale.startsWith("fr") ? messages2.fr : messages2.en,
|
|
337
|
+
...translations?.[locale.split("-")[0] ?? locale],
|
|
338
|
+
...translations?.[locale]
|
|
339
|
+
});
|
|
312
340
|
function CodeBlock({
|
|
313
341
|
code,
|
|
314
342
|
language = "text",
|
|
315
|
-
|
|
343
|
+
locale: localeOverride,
|
|
344
|
+
messages: messages3
|
|
316
345
|
}) {
|
|
346
|
+
const locale = useKrakstackLocale2(localeOverride);
|
|
317
347
|
const normalizedLanguage = language.toLowerCase() || "text";
|
|
318
348
|
const highlighted = highlight(code, { lang: normalizedLanguage });
|
|
319
|
-
const
|
|
320
|
-
if (messages?.copy !== undefined)
|
|
321
|
-
copyMessages.copy = messages.copy;
|
|
322
|
-
if (messages?.copied !== undefined)
|
|
323
|
-
copyMessages.copied = messages.copied;
|
|
324
|
-
if (messages?.copyFailed !== undefined) {
|
|
325
|
-
copyMessages.copyFailed = messages.copyFailed;
|
|
326
|
-
}
|
|
349
|
+
const labels = codeBlockMessages(locale, messages3);
|
|
327
350
|
return /* @__PURE__ */ jsxs2("div", {
|
|
328
351
|
className: "not-prose bg-muted overflow-hidden rounded-md border text-[var(--th-token)]",
|
|
329
352
|
"data-code-theme": true,
|
|
@@ -340,9 +363,10 @@ function CodeBlock({
|
|
|
340
363
|
}),
|
|
341
364
|
/* @__PURE__ */ jsx3(CopyButton, {
|
|
342
365
|
value: code,
|
|
343
|
-
valueDescription:
|
|
366
|
+
valueDescription: labels.codeDescription(highlighted.lang),
|
|
344
367
|
variant: "secondary",
|
|
345
|
-
|
|
368
|
+
locale,
|
|
369
|
+
messages: { [locale]: labels }
|
|
346
370
|
})
|
|
347
371
|
]
|
|
348
372
|
}),
|
|
@@ -360,7 +384,8 @@ var MarkdownContent = ({
|
|
|
360
384
|
className,
|
|
361
385
|
codeBlocks,
|
|
362
386
|
html,
|
|
363
|
-
|
|
387
|
+
locale,
|
|
388
|
+
messages: messages3
|
|
364
389
|
}) => {
|
|
365
390
|
const content = [];
|
|
366
391
|
let remainingHtml = html;
|
|
@@ -378,7 +403,8 @@ var MarkdownContent = ({
|
|
|
378
403
|
children: /* @__PURE__ */ jsx4(CodeBlock, {
|
|
379
404
|
code: block.code,
|
|
380
405
|
language: block.language,
|
|
381
|
-
|
|
406
|
+
locale,
|
|
407
|
+
messages: messages3
|
|
382
408
|
})
|
|
383
409
|
}, `code-${index}`));
|
|
384
410
|
remainingHtml = remainingHtml.slice(markerIndex + marker.length);
|
|
@@ -1102,442 +1128,6 @@ function TooltipContent({
|
|
|
1102
1128
|
});
|
|
1103
1129
|
}
|
|
1104
1130
|
|
|
1105
|
-
// ../../src/paraglide/runtime.js
|
|
1106
|
-
import"@inlang/paraglide-js/urlpattern-polyfill";
|
|
1107
|
-
var baseLocale = "en";
|
|
1108
|
-
var locales = ["en", "fr"];
|
|
1109
|
-
var cookieName = "locale";
|
|
1110
|
-
var cookieMaxAge = 34560000;
|
|
1111
|
-
var cookieDomain = "";
|
|
1112
|
-
var localStorageKey = "PARAGLIDE_LOCALE";
|
|
1113
|
-
var strategy = [
|
|
1114
|
-
"url",
|
|
1115
|
-
"cookie",
|
|
1116
|
-
"preferredLanguage",
|
|
1117
|
-
"baseLocale"
|
|
1118
|
-
];
|
|
1119
|
-
var routeStrategies = [
|
|
1120
|
-
{
|
|
1121
|
-
match: "/api/:path(.*)?",
|
|
1122
|
-
exclude: true
|
|
1123
|
-
},
|
|
1124
|
-
{
|
|
1125
|
-
match: "/sitemap.xml",
|
|
1126
|
-
exclude: true
|
|
1127
|
-
},
|
|
1128
|
-
{
|
|
1129
|
-
match: "/llms.txt",
|
|
1130
|
-
exclude: true
|
|
1131
|
-
}
|
|
1132
|
-
];
|
|
1133
|
-
var urlPatterns = [
|
|
1134
|
-
{
|
|
1135
|
-
pattern: "/:path(.*)?",
|
|
1136
|
-
localized: [
|
|
1137
|
-
[
|
|
1138
|
-
"en",
|
|
1139
|
-
"/en/:path(.*)?"
|
|
1140
|
-
],
|
|
1141
|
-
[
|
|
1142
|
-
"fr",
|
|
1143
|
-
"/fr/:path(.*)?"
|
|
1144
|
-
]
|
|
1145
|
-
]
|
|
1146
|
-
}
|
|
1147
|
-
];
|
|
1148
|
-
var cachedRouteStrategyUrl;
|
|
1149
|
-
var cachedRouteStrategy;
|
|
1150
|
-
function findMatchingRouteStrategy(url) {
|
|
1151
|
-
if (routeStrategies.length === 0) {
|
|
1152
|
-
return;
|
|
1153
|
-
}
|
|
1154
|
-
const urlString = typeof url === "string" ? url : url.href;
|
|
1155
|
-
if (cachedRouteStrategyUrl === urlString) {
|
|
1156
|
-
return cachedRouteStrategy;
|
|
1157
|
-
}
|
|
1158
|
-
const urlObject = new URL(urlString, "http://dummy.com");
|
|
1159
|
-
let match;
|
|
1160
|
-
for (const routeStrategy of routeStrategies) {
|
|
1161
|
-
const pattern = new URLPattern(routeStrategy.match, urlObject.href);
|
|
1162
|
-
if (pattern.exec(urlObject.href)) {
|
|
1163
|
-
match = routeStrategy;
|
|
1164
|
-
break;
|
|
1165
|
-
}
|
|
1166
|
-
}
|
|
1167
|
-
cachedRouteStrategyUrl = urlString;
|
|
1168
|
-
cachedRouteStrategy = match;
|
|
1169
|
-
return match;
|
|
1170
|
-
}
|
|
1171
|
-
function getStrategyForUrl(url) {
|
|
1172
|
-
const routeStrategy = findMatchingRouteStrategy(url);
|
|
1173
|
-
if (routeStrategy && routeStrategy.exclude !== true && Array.isArray(routeStrategy.strategy)) {
|
|
1174
|
-
return routeStrategy.strategy;
|
|
1175
|
-
}
|
|
1176
|
-
return strategy;
|
|
1177
|
-
}
|
|
1178
|
-
var serverAsyncLocalStorage = undefined;
|
|
1179
|
-
var isServer = import.meta.env?.SSR ?? typeof window === "undefined";
|
|
1180
|
-
var experimentalStaticLocale = undefined;
|
|
1181
|
-
var TREE_SHAKE_COOKIE_STRATEGY_USED = true;
|
|
1182
|
-
var TREE_SHAKE_URL_STRATEGY_USED = true;
|
|
1183
|
-
var TREE_SHAKE_GLOBAL_VARIABLE_STRATEGY_USED = false;
|
|
1184
|
-
var TREE_SHAKE_PREFERRED_LANGUAGE_STRATEGY_USED = true;
|
|
1185
|
-
var TREE_SHAKE_DEFAULT_URL_PATTERN_USED = false;
|
|
1186
|
-
var TREE_SHAKE_LOCAL_STORAGE_STRATEGY_USED = false;
|
|
1187
|
-
globalThis.__paraglide = globalThis.__paraglide ?? {};
|
|
1188
|
-
globalThis.__paraglide.ssr = globalThis.__paraglide.ssr ?? {};
|
|
1189
|
-
var _locale;
|
|
1190
|
-
var localeInitiallySet = false;
|
|
1191
|
-
var getLocale = () => {
|
|
1192
|
-
if (experimentalStaticLocale !== undefined) {
|
|
1193
|
-
return experimentalStaticLocale;
|
|
1194
|
-
}
|
|
1195
|
-
if (serverAsyncLocalStorage) {
|
|
1196
|
-
const locale = serverAsyncLocalStorage?.getStore()?.locale;
|
|
1197
|
-
if (locale) {
|
|
1198
|
-
return locale;
|
|
1199
|
-
}
|
|
1200
|
-
}
|
|
1201
|
-
let strategyToUse = strategy;
|
|
1202
|
-
if (!isServer && typeof window !== "undefined" && window.location?.href) {
|
|
1203
|
-
strategyToUse = getStrategyForUrl(window.location.href);
|
|
1204
|
-
}
|
|
1205
|
-
const resolved = resolveLocaleWithStrategies(strategyToUse, typeof window !== "undefined" ? window.location?.href : undefined);
|
|
1206
|
-
if (resolved) {
|
|
1207
|
-
if (!localeInitiallySet) {
|
|
1208
|
-
_locale = resolved;
|
|
1209
|
-
localeInitiallySet = true;
|
|
1210
|
-
setLocale(resolved, { reload: false });
|
|
1211
|
-
}
|
|
1212
|
-
return resolved;
|
|
1213
|
-
}
|
|
1214
|
-
throw new Error("No locale found. Read the docs https://paraglidejs.com/errors#no-locale-found");
|
|
1215
|
-
};
|
|
1216
|
-
function resolveLocaleWithStrategies(strategyToUse, urlForUrlStrategy) {
|
|
1217
|
-
let locale;
|
|
1218
|
-
for (const strat of strategyToUse) {
|
|
1219
|
-
if (TREE_SHAKE_COOKIE_STRATEGY_USED && strat === "cookie") {
|
|
1220
|
-
locale = extractLocaleFromCookie();
|
|
1221
|
-
} else if (strat === "baseLocale") {
|
|
1222
|
-
locale = baseLocale;
|
|
1223
|
-
} else if (TREE_SHAKE_URL_STRATEGY_USED && strat === "url" && !isServer && typeof urlForUrlStrategy === "string") {
|
|
1224
|
-
locale = extractLocaleFromUrl(urlForUrlStrategy);
|
|
1225
|
-
} else if (TREE_SHAKE_GLOBAL_VARIABLE_STRATEGY_USED && strat === "globalVariable" && _locale !== undefined) {
|
|
1226
|
-
locale = _locale;
|
|
1227
|
-
} else if (TREE_SHAKE_PREFERRED_LANGUAGE_STRATEGY_USED && strat === "preferredLanguage" && !isServer) {
|
|
1228
|
-
locale = extractLocaleFromNavigator();
|
|
1229
|
-
} else if (TREE_SHAKE_LOCAL_STORAGE_STRATEGY_USED && strat === "localStorage" && !isServer) {
|
|
1230
|
-
locale = localStorage.getItem(localStorageKey) ?? undefined;
|
|
1231
|
-
} else if (isCustomStrategy(strat) && customClientStrategies.has(strat)) {
|
|
1232
|
-
const handler = customClientStrategies.get(strat);
|
|
1233
|
-
if (handler) {
|
|
1234
|
-
const result = handler.getLocale();
|
|
1235
|
-
if (result instanceof Promise) {
|
|
1236
|
-
continue;
|
|
1237
|
-
}
|
|
1238
|
-
if (result !== undefined) {
|
|
1239
|
-
return assertIsLocale(result);
|
|
1240
|
-
}
|
|
1241
|
-
}
|
|
1242
|
-
}
|
|
1243
|
-
const matchedLocale = toLocale(locale);
|
|
1244
|
-
if (matchedLocale) {
|
|
1245
|
-
return matchedLocale;
|
|
1246
|
-
}
|
|
1247
|
-
}
|
|
1248
|
-
return;
|
|
1249
|
-
}
|
|
1250
|
-
var rtlLanguages = new Set([
|
|
1251
|
-
"ar",
|
|
1252
|
-
"dv",
|
|
1253
|
-
"fa",
|
|
1254
|
-
"he",
|
|
1255
|
-
"ks",
|
|
1256
|
-
"ku",
|
|
1257
|
-
"ps",
|
|
1258
|
-
"sd",
|
|
1259
|
-
"ug",
|
|
1260
|
-
"ur",
|
|
1261
|
-
"yi"
|
|
1262
|
-
]);
|
|
1263
|
-
var navigateOrReload = (newLocation) => {
|
|
1264
|
-
if (newLocation) {
|
|
1265
|
-
window.location.href = newLocation;
|
|
1266
|
-
} else {
|
|
1267
|
-
window.location.reload();
|
|
1268
|
-
}
|
|
1269
|
-
};
|
|
1270
|
-
var setLocale = (newLocale, options) => {
|
|
1271
|
-
const optionsWithDefaults = {
|
|
1272
|
-
reload: true,
|
|
1273
|
-
...options
|
|
1274
|
-
};
|
|
1275
|
-
let currentLocale;
|
|
1276
|
-
try {
|
|
1277
|
-
currentLocale = getLocale();
|
|
1278
|
-
} catch {}
|
|
1279
|
-
const customSetLocalePromises = [];
|
|
1280
|
-
let newLocation = undefined;
|
|
1281
|
-
let strategyToUse = strategy;
|
|
1282
|
-
if (!isServer && typeof window !== "undefined" && window.location?.href) {
|
|
1283
|
-
strategyToUse = getStrategyForUrl(window.location.href);
|
|
1284
|
-
}
|
|
1285
|
-
for (const strat of strategyToUse) {
|
|
1286
|
-
if (TREE_SHAKE_GLOBAL_VARIABLE_STRATEGY_USED && strat === "globalVariable") {
|
|
1287
|
-
_locale = newLocale;
|
|
1288
|
-
} else if (TREE_SHAKE_COOKIE_STRATEGY_USED && strat === "cookie") {
|
|
1289
|
-
if (isServer || typeof document === "undefined" || typeof window === "undefined") {
|
|
1290
|
-
continue;
|
|
1291
|
-
}
|
|
1292
|
-
const cookieString = `${cookieName}=${newLocale}; path=/; max-age=${cookieMaxAge}`;
|
|
1293
|
-
document.cookie = cookieDomain ? `${cookieString}; domain=${cookieDomain}` : cookieString;
|
|
1294
|
-
} else if (strat === "baseLocale") {
|
|
1295
|
-
continue;
|
|
1296
|
-
} else if (TREE_SHAKE_URL_STRATEGY_USED && strat === "url" && typeof window !== "undefined") {
|
|
1297
|
-
newLocation = localizeUrl(window.location.href, {
|
|
1298
|
-
locale: newLocale
|
|
1299
|
-
}).href;
|
|
1300
|
-
} else if (TREE_SHAKE_LOCAL_STORAGE_STRATEGY_USED && strat === "localStorage" && typeof window !== "undefined") {
|
|
1301
|
-
localStorage.setItem(localStorageKey, newLocale);
|
|
1302
|
-
} else if (isCustomStrategy(strat) && customClientStrategies.has(strat)) {
|
|
1303
|
-
const handler = customClientStrategies.get(strat);
|
|
1304
|
-
if (handler) {
|
|
1305
|
-
let result = handler.setLocale(newLocale);
|
|
1306
|
-
if (result instanceof Promise) {
|
|
1307
|
-
result = result.catch((error) => {
|
|
1308
|
-
throw new Error(`Custom strategy "${strat}" setLocale failed.`, {
|
|
1309
|
-
cause: error
|
|
1310
|
-
});
|
|
1311
|
-
});
|
|
1312
|
-
customSetLocalePromises.push(result);
|
|
1313
|
-
}
|
|
1314
|
-
}
|
|
1315
|
-
}
|
|
1316
|
-
}
|
|
1317
|
-
const runReload = () => {
|
|
1318
|
-
if (!isServer && optionsWithDefaults.reload && window.location && newLocale !== currentLocale) {
|
|
1319
|
-
navigateOrReload(newLocation);
|
|
1320
|
-
}
|
|
1321
|
-
};
|
|
1322
|
-
if (customSetLocalePromises.length) {
|
|
1323
|
-
return Promise.all(customSetLocalePromises).then(() => {
|
|
1324
|
-
runReload();
|
|
1325
|
-
});
|
|
1326
|
-
}
|
|
1327
|
-
runReload();
|
|
1328
|
-
return;
|
|
1329
|
-
};
|
|
1330
|
-
var getUrlOrigin = () => {
|
|
1331
|
-
if (serverAsyncLocalStorage) {
|
|
1332
|
-
return serverAsyncLocalStorage.getStore()?.origin ?? "http://fallback.com";
|
|
1333
|
-
} else if (typeof window !== "undefined") {
|
|
1334
|
-
return window.location.origin;
|
|
1335
|
-
}
|
|
1336
|
-
return "http://fallback.com";
|
|
1337
|
-
};
|
|
1338
|
-
function toLocale(value) {
|
|
1339
|
-
if (typeof value !== "string") {
|
|
1340
|
-
return;
|
|
1341
|
-
}
|
|
1342
|
-
const lowerValue = value.toLowerCase();
|
|
1343
|
-
for (const locale of locales) {
|
|
1344
|
-
if (locale.toLowerCase() === lowerValue) {
|
|
1345
|
-
return locale;
|
|
1346
|
-
}
|
|
1347
|
-
}
|
|
1348
|
-
return;
|
|
1349
|
-
}
|
|
1350
|
-
function assertIsLocale(input) {
|
|
1351
|
-
const locale = toLocale(input);
|
|
1352
|
-
if (locale)
|
|
1353
|
-
return locale;
|
|
1354
|
-
throw new Error(`Invalid locale: ${input}. Expected one of: ${locales.join(", ")}`);
|
|
1355
|
-
}
|
|
1356
|
-
function extractLocaleFromCookie() {
|
|
1357
|
-
if (typeof document === "undefined" || !document.cookie) {
|
|
1358
|
-
return;
|
|
1359
|
-
}
|
|
1360
|
-
const match = document.cookie.match(new RegExp(`(^| )${cookieName}=([^;]+)`));
|
|
1361
|
-
const locale = match?.[2];
|
|
1362
|
-
return toLocale(locale);
|
|
1363
|
-
}
|
|
1364
|
-
function extractLocaleFromNavigator() {
|
|
1365
|
-
if (!navigator?.languages?.length) {
|
|
1366
|
-
return;
|
|
1367
|
-
}
|
|
1368
|
-
const languages = navigator.languages.map((lang) => ({
|
|
1369
|
-
fullTag: lang,
|
|
1370
|
-
baseTag: lang.split("-")[0]
|
|
1371
|
-
}));
|
|
1372
|
-
for (const lang of languages) {
|
|
1373
|
-
const fullLocale = toLocale(lang.fullTag);
|
|
1374
|
-
if (fullLocale) {
|
|
1375
|
-
return fullLocale;
|
|
1376
|
-
}
|
|
1377
|
-
const baseLocale2 = toLocale(lang.baseTag);
|
|
1378
|
-
if (baseLocale2) {
|
|
1379
|
-
return baseLocale2;
|
|
1380
|
-
}
|
|
1381
|
-
}
|
|
1382
|
-
return;
|
|
1383
|
-
}
|
|
1384
|
-
var cachedUrl;
|
|
1385
|
-
var cachedLocale;
|
|
1386
|
-
function extractLocaleFromUrl(url) {
|
|
1387
|
-
const urlString = typeof url === "string" ? url : url.href;
|
|
1388
|
-
if (cachedUrl === urlString) {
|
|
1389
|
-
return cachedLocale;
|
|
1390
|
-
}
|
|
1391
|
-
let result;
|
|
1392
|
-
if (TREE_SHAKE_DEFAULT_URL_PATTERN_USED) {
|
|
1393
|
-
result = defaultUrlPatternExtractLocale(url);
|
|
1394
|
-
} else {
|
|
1395
|
-
const urlObj = typeof url === "string" ? new URL(url) : url;
|
|
1396
|
-
for (const element of urlPatterns) {
|
|
1397
|
-
for (const [locale, localizedPattern] of element.localized) {
|
|
1398
|
-
const match = new URLPattern(localizedPattern, urlObj.href).exec(urlObj.href);
|
|
1399
|
-
if (match) {
|
|
1400
|
-
result = locale;
|
|
1401
|
-
break;
|
|
1402
|
-
}
|
|
1403
|
-
}
|
|
1404
|
-
if (result)
|
|
1405
|
-
break;
|
|
1406
|
-
}
|
|
1407
|
-
}
|
|
1408
|
-
cachedUrl = urlString;
|
|
1409
|
-
cachedLocale = result;
|
|
1410
|
-
return result;
|
|
1411
|
-
}
|
|
1412
|
-
function defaultUrlPatternExtractLocale(url) {
|
|
1413
|
-
const urlObj = new URL(url, "http://dummy.com");
|
|
1414
|
-
const pathSegments = urlObj.pathname.split("/").filter(Boolean);
|
|
1415
|
-
return toLocale(pathSegments[0]) || baseLocale;
|
|
1416
|
-
}
|
|
1417
|
-
function localizeUrl(url, options) {
|
|
1418
|
-
const targetLocale = options?.locale ? assertIsLocale(options?.locale) : getLocale();
|
|
1419
|
-
if (TREE_SHAKE_DEFAULT_URL_PATTERN_USED) {
|
|
1420
|
-
return localizeUrlDefaultPattern(url, targetLocale);
|
|
1421
|
-
}
|
|
1422
|
-
const urlObj = typeof url === "string" ? new URL(url) : url;
|
|
1423
|
-
for (const element of urlPatterns) {
|
|
1424
|
-
for (const [, localizedPattern] of element.localized) {
|
|
1425
|
-
const match = new URLPattern(localizedPattern, urlObj.href).exec(urlObj.href);
|
|
1426
|
-
if (!match) {
|
|
1427
|
-
continue;
|
|
1428
|
-
}
|
|
1429
|
-
const targetPattern = element.localized.find(([locale]) => locale === targetLocale)?.[1];
|
|
1430
|
-
if (!targetPattern) {
|
|
1431
|
-
continue;
|
|
1432
|
-
}
|
|
1433
|
-
const localizedUrl = fillPattern(targetPattern, aggregateGroups(match), urlObj.origin);
|
|
1434
|
-
return fillMissingUrlParts(localizedUrl, match);
|
|
1435
|
-
}
|
|
1436
|
-
const unlocalizedMatch = new URLPattern(element.pattern, urlObj.href).exec(urlObj.href);
|
|
1437
|
-
if (unlocalizedMatch) {
|
|
1438
|
-
const targetPattern = element.localized.find(([locale]) => locale === targetLocale)?.[1];
|
|
1439
|
-
if (targetPattern) {
|
|
1440
|
-
const localizedUrl = fillPattern(targetPattern, aggregateGroups(unlocalizedMatch), urlObj.origin);
|
|
1441
|
-
return fillMissingUrlParts(localizedUrl, unlocalizedMatch);
|
|
1442
|
-
}
|
|
1443
|
-
}
|
|
1444
|
-
}
|
|
1445
|
-
return urlObj;
|
|
1446
|
-
}
|
|
1447
|
-
function localizeUrlDefaultPattern(url, locale) {
|
|
1448
|
-
const urlObj = typeof url === "string" ? new URL(url, getUrlOrigin()) : new URL(url);
|
|
1449
|
-
const currentLocale = extractLocaleFromUrl(urlObj);
|
|
1450
|
-
if (currentLocale === locale) {
|
|
1451
|
-
return urlObj;
|
|
1452
|
-
}
|
|
1453
|
-
const pathSegments = urlObj.pathname.split("/").filter(Boolean);
|
|
1454
|
-
if (pathSegments.length > 0 && toLocale(pathSegments[0])) {
|
|
1455
|
-
pathSegments.shift();
|
|
1456
|
-
}
|
|
1457
|
-
if (locale === baseLocale) {
|
|
1458
|
-
urlObj.pathname = "/" + pathSegments.join("/");
|
|
1459
|
-
} else {
|
|
1460
|
-
urlObj.pathname = "/" + locale + "/" + pathSegments.join("/");
|
|
1461
|
-
}
|
|
1462
|
-
return urlObj;
|
|
1463
|
-
}
|
|
1464
|
-
function fillMissingUrlParts(url, match) {
|
|
1465
|
-
if (match.protocol.groups["0"]) {
|
|
1466
|
-
url.protocol = match.protocol.groups["0"] ?? "";
|
|
1467
|
-
}
|
|
1468
|
-
if (match.hostname.groups["0"]) {
|
|
1469
|
-
url.hostname = match.hostname.groups["0"] ?? "";
|
|
1470
|
-
}
|
|
1471
|
-
if (match.username.groups["0"]) {
|
|
1472
|
-
url.username = match.username.groups["0"] ?? "";
|
|
1473
|
-
}
|
|
1474
|
-
if (match.password.groups["0"]) {
|
|
1475
|
-
url.password = match.password.groups["0"] ?? "";
|
|
1476
|
-
}
|
|
1477
|
-
if (match.port.groups["0"]) {
|
|
1478
|
-
url.port = match.port.groups["0"] ?? "";
|
|
1479
|
-
}
|
|
1480
|
-
if (match.pathname.groups["0"]) {
|
|
1481
|
-
url.pathname = match.pathname.groups["0"] ?? "";
|
|
1482
|
-
}
|
|
1483
|
-
if (match.search.groups["0"]) {
|
|
1484
|
-
url.search = match.search.groups["0"] ?? "";
|
|
1485
|
-
}
|
|
1486
|
-
if (match.hash.groups["0"]) {
|
|
1487
|
-
url.hash = match.hash.groups["0"] ?? "";
|
|
1488
|
-
}
|
|
1489
|
-
return url;
|
|
1490
|
-
}
|
|
1491
|
-
function fillPattern(pattern, values, origin) {
|
|
1492
|
-
let processedPattern = pattern.replace(/(https?:\/\/[^:/]+):(\d+)(\/|$)/g, (_, protocol, port, slash) => {
|
|
1493
|
-
return `${protocol}#PORT-${port}#${slash}`;
|
|
1494
|
-
});
|
|
1495
|
-
let processedGroupDelimiters = processedPattern.replace(/\{([^{}]*)\}([?+*]?)/g, (_, content, modifier) => {
|
|
1496
|
-
if (modifier === "?") {
|
|
1497
|
-
return content;
|
|
1498
|
-
}
|
|
1499
|
-
return content;
|
|
1500
|
-
});
|
|
1501
|
-
let filled = processedGroupDelimiters.replace(/(\/?):([a-zA-Z0-9_]+)(\([^)]*\))?([?+*]?)/g, (_, slash, name, __, modifier) => {
|
|
1502
|
-
const value = values[name];
|
|
1503
|
-
if (value === null) {
|
|
1504
|
-
return "";
|
|
1505
|
-
}
|
|
1506
|
-
if (modifier === "?") {
|
|
1507
|
-
return value !== undefined ? `${slash}${value}` : "";
|
|
1508
|
-
}
|
|
1509
|
-
if (modifier === "+" || modifier === "*") {
|
|
1510
|
-
if (value === undefined && modifier === "+") {
|
|
1511
|
-
throw new Error(`Missing value for "${name}" (one or more required)`);
|
|
1512
|
-
}
|
|
1513
|
-
return value ? `${slash}${value}` : "";
|
|
1514
|
-
}
|
|
1515
|
-
if (value === undefined) {
|
|
1516
|
-
throw new Error(`Missing value for "${name}"`);
|
|
1517
|
-
}
|
|
1518
|
-
return `${slash}${value}`;
|
|
1519
|
-
});
|
|
1520
|
-
filled = filled.replace(/#PORT-(\d+)#/g, ":$1");
|
|
1521
|
-
return new URL(filled, origin);
|
|
1522
|
-
}
|
|
1523
|
-
function aggregateGroups(match) {
|
|
1524
|
-
return {
|
|
1525
|
-
...match.hash.groups,
|
|
1526
|
-
...match.hostname.groups,
|
|
1527
|
-
...match.password.groups,
|
|
1528
|
-
...match.pathname.groups,
|
|
1529
|
-
...match.port.groups,
|
|
1530
|
-
...match.protocol.groups,
|
|
1531
|
-
...match.search.groups,
|
|
1532
|
-
...match.username.groups
|
|
1533
|
-
};
|
|
1534
|
-
}
|
|
1535
|
-
var customServerStrategies = new Map;
|
|
1536
|
-
var customClientStrategies = new Map;
|
|
1537
|
-
function isCustomStrategy(strategy2) {
|
|
1538
|
-
return typeof strategy2 === "string" && /^custom-[A-Za-z0-9_-]+$/.test(strategy2);
|
|
1539
|
-
}
|
|
1540
|
-
|
|
1541
1131
|
// ../../src/services/agent/schema.ts
|
|
1542
1132
|
import { Schema as Schema2 } from "effect";
|
|
1543
1133
|
import {
|
|
@@ -1622,8 +1212,9 @@ var AgentStreamError = Schema2.Struct({
|
|
|
1622
1212
|
});
|
|
1623
1213
|
|
|
1624
1214
|
// ../../src/services/agent/client/widget.tsx
|
|
1215
|
+
import { useKrakstackLocale as useKrakstackLocale3 } from "@krak-stack/registry/krakstack-provider";
|
|
1625
1216
|
import { jsx as jsx19, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
1626
|
-
var
|
|
1217
|
+
var messages3 = {
|
|
1627
1218
|
en: {
|
|
1628
1219
|
approve: "Approve",
|
|
1629
1220
|
approvalDestructive: "This may permanently remove data. Check the action before continuing.",
|
|
@@ -1631,6 +1222,7 @@ var messages = {
|
|
|
1631
1222
|
approvalRequired: "The assistant needs your confirmation before making this change.",
|
|
1632
1223
|
cancel: "Cancel",
|
|
1633
1224
|
close: "Close",
|
|
1225
|
+
codeDescription: (language) => `${language} code`,
|
|
1634
1226
|
copied: "Copied",
|
|
1635
1227
|
copy: "Copy",
|
|
1636
1228
|
description: "Ask questions and use available tools to get things done.",
|
|
@@ -1664,6 +1256,7 @@ var messages = {
|
|
|
1664
1256
|
approvalRequired: "L'assistant a besoin de votre confirmation avant d'effectuer cette modification.",
|
|
1665
1257
|
cancel: "Annuler",
|
|
1666
1258
|
close: "Fermer",
|
|
1259
|
+
codeDescription: (language) => `code ${language}`,
|
|
1667
1260
|
copied: "Copié",
|
|
1668
1261
|
copy: "Copier",
|
|
1669
1262
|
description: "Posez des questions et utilisez les outils disponibles pour accomplir vos tâches.",
|
|
@@ -1691,9 +1284,10 @@ var messages = {
|
|
|
1691
1284
|
welcome: "Comment puis-je vous aider?"
|
|
1692
1285
|
}
|
|
1693
1286
|
};
|
|
1694
|
-
var agentWidgetMessages = (locale =
|
|
1695
|
-
...locale.startsWith("fr") ?
|
|
1696
|
-
...
|
|
1287
|
+
var agentWidgetMessages = (locale = "en", translations) => ({
|
|
1288
|
+
...locale.startsWith("fr") ? messages3.fr : messages3.en,
|
|
1289
|
+
...translations?.[locale.split("-")[0] ?? locale],
|
|
1290
|
+
...translations?.[locale]
|
|
1697
1291
|
});
|
|
1698
1292
|
var errorMessage = (code, labels) => {
|
|
1699
1293
|
switch (code) {
|
|
@@ -1769,6 +1363,7 @@ var ToolLabel = ({
|
|
|
1769
1363
|
function ToolActivityCard({
|
|
1770
1364
|
disabled,
|
|
1771
1365
|
labels,
|
|
1366
|
+
locale,
|
|
1772
1367
|
onApproval,
|
|
1773
1368
|
tool
|
|
1774
1369
|
}) {
|
|
@@ -1828,7 +1423,14 @@ function ToolActivityCard({
|
|
|
1828
1423
|
children: /* @__PURE__ */ jsx19(CodeBlock, {
|
|
1829
1424
|
code: inputCode(tool.input),
|
|
1830
1425
|
language: "json",
|
|
1831
|
-
|
|
1426
|
+
locale,
|
|
1427
|
+
messages: {
|
|
1428
|
+
[locale]: {
|
|
1429
|
+
codeDescription: labels.codeDescription,
|
|
1430
|
+
copied: labels.copied,
|
|
1431
|
+
copy: labels.copy
|
|
1432
|
+
}
|
|
1433
|
+
}
|
|
1832
1434
|
})
|
|
1833
1435
|
})
|
|
1834
1436
|
}),
|
|
@@ -1872,6 +1474,7 @@ function ToolActivityCard({
|
|
|
1872
1474
|
function ToolActivityLog({
|
|
1873
1475
|
disabled,
|
|
1874
1476
|
labels,
|
|
1477
|
+
locale,
|
|
1875
1478
|
onApproval,
|
|
1876
1479
|
pending,
|
|
1877
1480
|
tools,
|
|
@@ -1920,6 +1523,7 @@ function ToolActivityLog({
|
|
|
1920
1523
|
children: loggedTools.map((tool) => /* @__PURE__ */ jsx19(ToolActivityCard, {
|
|
1921
1524
|
disabled,
|
|
1922
1525
|
labels,
|
|
1526
|
+
locale,
|
|
1923
1527
|
onApproval,
|
|
1924
1528
|
tool
|
|
1925
1529
|
}, tool.toolCallId))
|
|
@@ -1929,6 +1533,7 @@ function ToolActivityLog({
|
|
|
1929
1533
|
/* @__PURE__ */ jsx19(ToolActivityCard, {
|
|
1930
1534
|
disabled,
|
|
1931
1535
|
labels,
|
|
1536
|
+
locale,
|
|
1932
1537
|
onApproval,
|
|
1933
1538
|
tool: currentTool
|
|
1934
1539
|
})
|
|
@@ -1978,6 +1583,7 @@ function ToolActivityLog({
|
|
|
1978
1583
|
loggedTools.map((tool) => /* @__PURE__ */ jsx19(ToolActivityCard, {
|
|
1979
1584
|
disabled,
|
|
1980
1585
|
labels,
|
|
1586
|
+
locale,
|
|
1981
1587
|
onApproval,
|
|
1982
1588
|
tool
|
|
1983
1589
|
}, tool.toolCallId))
|
|
@@ -1989,6 +1595,7 @@ function ToolActivityLog({
|
|
|
1989
1595
|
function AgentMessageRow({
|
|
1990
1596
|
disabled,
|
|
1991
1597
|
labels,
|
|
1598
|
+
locale,
|
|
1992
1599
|
message,
|
|
1993
1600
|
onApproval,
|
|
1994
1601
|
pending
|
|
@@ -2030,6 +1637,7 @@ function AgentMessageRow({
|
|
|
2030
1637
|
!isUser && (message.tools.length > 0 || pending && !message.text) ? /* @__PURE__ */ jsx19(ToolActivityLog, {
|
|
2031
1638
|
disabled,
|
|
2032
1639
|
labels,
|
|
1640
|
+
locale,
|
|
2033
1641
|
onApproval,
|
|
2034
1642
|
pending,
|
|
2035
1643
|
tools: message.tools,
|
|
@@ -2045,7 +1653,14 @@ function AgentMessageRow({
|
|
|
2045
1653
|
className: "w-full",
|
|
2046
1654
|
codeBlocks: message.markdown.codeBlocks,
|
|
2047
1655
|
html: message.markdown.html,
|
|
2048
|
-
messages: {
|
|
1656
|
+
messages: {
|
|
1657
|
+
[locale]: {
|
|
1658
|
+
codeDescription: labels.codeDescription,
|
|
1659
|
+
copied: labels.copied,
|
|
1660
|
+
copy: labels.copy
|
|
1661
|
+
}
|
|
1662
|
+
},
|
|
1663
|
+
locale
|
|
2049
1664
|
}) : /* @__PURE__ */ jsx19("div", {
|
|
2050
1665
|
className: "w-full whitespace-pre-wrap",
|
|
2051
1666
|
children: message.text
|
|
@@ -2057,6 +1672,7 @@ function AgentMessageRow({
|
|
|
2057
1672
|
function AgentWidget({
|
|
2058
1673
|
availableReferences = [],
|
|
2059
1674
|
context,
|
|
1675
|
+
locale: localeOverride,
|
|
2060
1676
|
messages: messageOverrides,
|
|
2061
1677
|
onInterrupt,
|
|
2062
1678
|
onRemoveContext,
|
|
@@ -2064,7 +1680,8 @@ function AgentWidget({
|
|
|
2064
1680
|
onSubmit,
|
|
2065
1681
|
state
|
|
2066
1682
|
}) {
|
|
2067
|
-
const
|
|
1683
|
+
const locale = useKrakstackLocale3(localeOverride);
|
|
1684
|
+
const labels = agentWidgetMessages(locale, messageOverrides);
|
|
2068
1685
|
const referenceInputId = useId();
|
|
2069
1686
|
const referenceListId = `${referenceInputId}-list`;
|
|
2070
1687
|
const [open, setOpen] = useState2(false);
|
|
@@ -2250,6 +1867,7 @@ function AgentWidget({
|
|
|
2250
1867
|
children: /* @__PURE__ */ jsx19(AgentMessageRow, {
|
|
2251
1868
|
disabled: state.pending,
|
|
2252
1869
|
labels,
|
|
1870
|
+
locale,
|
|
2253
1871
|
message,
|
|
2254
1872
|
onApproval: respondToApproval,
|
|
2255
1873
|
pending: state.pending && index === state.messages.length - 1
|