@krak-stack/registry 0.1.31 → 0.1.33
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/README.md +21 -0
- package/dist/components/ui/code-block.d.ts +8 -6
- package/dist/components/ui/code-block.js +40 -19
- package/dist/components/ui/copy-button.d.ts +9 -6
- package/dist/components/ui/copy-button.js +15 -8
- package/dist/components/ui/data-table.d.ts +9 -5
- package/dist/components/ui/data-table.js +74 -479
- package/dist/components/ui/editing-locale-switcher.d.ts +8 -4
- package/dist/components/ui/editing-locale-switcher.js +20 -448
- package/dist/components/ui/effect-form.d.ts +39 -10
- package/dist/components/ui/effect-form.js +141 -527
- package/dist/components/ui/error-component.d.ts +4 -2
- package/dist/components/ui/error-component.js +24 -450
- package/dist/components/ui/file-picker.d.ts +4 -2
- package/dist/components/ui/file-picker.js +25 -452
- package/dist/components/ui/form.d.ts +123 -71
- package/dist/components/ui/form.js +81 -474
- package/dist/components/ui/google-map.d.ts +2 -1
- package/dist/components/ui/google-map.js +4 -439
- package/dist/components/ui/icon-input.d.ts +50 -1
- package/dist/components/ui/icon-input.js +30 -446
- package/dist/components/ui/loading.d.ts +7 -1
- package/dist/components/ui/loading.js +4 -438
- package/dist/components/ui/locale-switcher.d.ts +8 -4
- package/dist/components/ui/locale-switcher.js +29 -453
- package/dist/components/ui/pagination.d.ts +5 -3
- package/dist/components/ui/pagination.js +5 -439
- package/dist/components/ui/search-menu.d.ts +4 -2
- package/dist/components/ui/search-menu.js +6 -440
- package/dist/components/ui/theme-switcher.d.ts +5 -3
- package/dist/components/ui/theme-switcher.js +6 -440
- package/dist/components/ui/virtualized-combobox.d.ts +4 -2
- package/dist/components/ui/virtualized-combobox.js +11 -443
- package/dist/lib/docs.d.ts +2 -0
- package/dist/lib/docs.js +86 -481
- package/dist/lib/docs.server.js +0 -21
- package/dist/lib/documentation-toolkit.js +0 -21
- package/dist/lib/markdown/content.d.ts +4 -5
- package/dist/services/agent/client/index.js +75 -463
- package/dist/services/agent/client/widget.d.ts +6 -3
- package/dist/services/notification/client/index.js +8 -440
- package/dist/services/notification/client/notification-menu.d.ts +6 -3
- package/dist/services/notification/public.js +8 -440
- package/dist/services/opentelemetry/api.d.ts +5 -0
- package/dist/services/opentelemetry/api.js +44 -0
- package/dist/services/opentelemetry/browser.d.ts +10 -0
- package/dist/services/opentelemetry/browser.js +59 -0
- package/package.json +9 -1
- package/dist/paraglide/runtime.d.ts +0 -978
|
@@ -395,442 +395,6 @@ function TabsTrigger({ className, ...props }) {
|
|
|
395
395
|
});
|
|
396
396
|
}
|
|
397
397
|
|
|
398
|
-
// ../../src/paraglide/runtime.js
|
|
399
|
-
import"@inlang/paraglide-js/urlpattern-polyfill";
|
|
400
|
-
var baseLocale = "en";
|
|
401
|
-
var locales = ["en", "fr"];
|
|
402
|
-
var cookieName = "locale";
|
|
403
|
-
var cookieMaxAge = 34560000;
|
|
404
|
-
var cookieDomain = "";
|
|
405
|
-
var localStorageKey = "PARAGLIDE_LOCALE";
|
|
406
|
-
var strategy = [
|
|
407
|
-
"url",
|
|
408
|
-
"cookie",
|
|
409
|
-
"preferredLanguage",
|
|
410
|
-
"baseLocale"
|
|
411
|
-
];
|
|
412
|
-
var routeStrategies = [
|
|
413
|
-
{
|
|
414
|
-
match: "/api/:path(.*)?",
|
|
415
|
-
exclude: true
|
|
416
|
-
},
|
|
417
|
-
{
|
|
418
|
-
match: "/sitemap.xml",
|
|
419
|
-
exclude: true
|
|
420
|
-
},
|
|
421
|
-
{
|
|
422
|
-
match: "/llms.txt",
|
|
423
|
-
exclude: true
|
|
424
|
-
}
|
|
425
|
-
];
|
|
426
|
-
var urlPatterns = [
|
|
427
|
-
{
|
|
428
|
-
pattern: "/:path(.*)?",
|
|
429
|
-
localized: [
|
|
430
|
-
[
|
|
431
|
-
"en",
|
|
432
|
-
"/en/:path(.*)?"
|
|
433
|
-
],
|
|
434
|
-
[
|
|
435
|
-
"fr",
|
|
436
|
-
"/fr/:path(.*)?"
|
|
437
|
-
]
|
|
438
|
-
]
|
|
439
|
-
}
|
|
440
|
-
];
|
|
441
|
-
var cachedRouteStrategyUrl;
|
|
442
|
-
var cachedRouteStrategy;
|
|
443
|
-
function findMatchingRouteStrategy(url) {
|
|
444
|
-
if (routeStrategies.length === 0) {
|
|
445
|
-
return;
|
|
446
|
-
}
|
|
447
|
-
const urlString = typeof url === "string" ? url : url.href;
|
|
448
|
-
if (cachedRouteStrategyUrl === urlString) {
|
|
449
|
-
return cachedRouteStrategy;
|
|
450
|
-
}
|
|
451
|
-
const urlObject = new URL(urlString, "http://dummy.com");
|
|
452
|
-
let match;
|
|
453
|
-
for (const routeStrategy of routeStrategies) {
|
|
454
|
-
const pattern = new URLPattern(routeStrategy.match, urlObject.href);
|
|
455
|
-
if (pattern.exec(urlObject.href)) {
|
|
456
|
-
match = routeStrategy;
|
|
457
|
-
break;
|
|
458
|
-
}
|
|
459
|
-
}
|
|
460
|
-
cachedRouteStrategyUrl = urlString;
|
|
461
|
-
cachedRouteStrategy = match;
|
|
462
|
-
return match;
|
|
463
|
-
}
|
|
464
|
-
function getStrategyForUrl(url) {
|
|
465
|
-
const routeStrategy = findMatchingRouteStrategy(url);
|
|
466
|
-
if (routeStrategy && routeStrategy.exclude !== true && Array.isArray(routeStrategy.strategy)) {
|
|
467
|
-
return routeStrategy.strategy;
|
|
468
|
-
}
|
|
469
|
-
return strategy;
|
|
470
|
-
}
|
|
471
|
-
var serverAsyncLocalStorage = undefined;
|
|
472
|
-
var isServer = import.meta.env?.SSR ?? typeof window === "undefined";
|
|
473
|
-
var experimentalStaticLocale = undefined;
|
|
474
|
-
var TREE_SHAKE_COOKIE_STRATEGY_USED = true;
|
|
475
|
-
var TREE_SHAKE_URL_STRATEGY_USED = true;
|
|
476
|
-
var TREE_SHAKE_GLOBAL_VARIABLE_STRATEGY_USED = false;
|
|
477
|
-
var TREE_SHAKE_PREFERRED_LANGUAGE_STRATEGY_USED = true;
|
|
478
|
-
var TREE_SHAKE_DEFAULT_URL_PATTERN_USED = false;
|
|
479
|
-
var TREE_SHAKE_LOCAL_STORAGE_STRATEGY_USED = false;
|
|
480
|
-
globalThis.__paraglide = globalThis.__paraglide ?? {};
|
|
481
|
-
globalThis.__paraglide.ssr = globalThis.__paraglide.ssr ?? {};
|
|
482
|
-
var _locale;
|
|
483
|
-
var localeInitiallySet = false;
|
|
484
|
-
var getLocale = () => {
|
|
485
|
-
if (experimentalStaticLocale !== undefined) {
|
|
486
|
-
return experimentalStaticLocale;
|
|
487
|
-
}
|
|
488
|
-
if (serverAsyncLocalStorage) {
|
|
489
|
-
const locale = serverAsyncLocalStorage?.getStore()?.locale;
|
|
490
|
-
if (locale) {
|
|
491
|
-
return locale;
|
|
492
|
-
}
|
|
493
|
-
}
|
|
494
|
-
let strategyToUse = strategy;
|
|
495
|
-
if (!isServer && typeof window !== "undefined" && window.location?.href) {
|
|
496
|
-
strategyToUse = getStrategyForUrl(window.location.href);
|
|
497
|
-
}
|
|
498
|
-
const resolved = resolveLocaleWithStrategies(strategyToUse, typeof window !== "undefined" ? window.location?.href : undefined);
|
|
499
|
-
if (resolved) {
|
|
500
|
-
if (!localeInitiallySet) {
|
|
501
|
-
_locale = resolved;
|
|
502
|
-
localeInitiallySet = true;
|
|
503
|
-
setLocale(resolved, { reload: false });
|
|
504
|
-
}
|
|
505
|
-
return resolved;
|
|
506
|
-
}
|
|
507
|
-
throw new Error("No locale found. Read the docs https://paraglidejs.com/errors#no-locale-found");
|
|
508
|
-
};
|
|
509
|
-
function resolveLocaleWithStrategies(strategyToUse, urlForUrlStrategy) {
|
|
510
|
-
let locale;
|
|
511
|
-
for (const strat of strategyToUse) {
|
|
512
|
-
if (TREE_SHAKE_COOKIE_STRATEGY_USED && strat === "cookie") {
|
|
513
|
-
locale = extractLocaleFromCookie();
|
|
514
|
-
} else if (strat === "baseLocale") {
|
|
515
|
-
locale = baseLocale;
|
|
516
|
-
} else if (TREE_SHAKE_URL_STRATEGY_USED && strat === "url" && !isServer && typeof urlForUrlStrategy === "string") {
|
|
517
|
-
locale = extractLocaleFromUrl(urlForUrlStrategy);
|
|
518
|
-
} else if (TREE_SHAKE_GLOBAL_VARIABLE_STRATEGY_USED && strat === "globalVariable" && _locale !== undefined) {
|
|
519
|
-
locale = _locale;
|
|
520
|
-
} else if (TREE_SHAKE_PREFERRED_LANGUAGE_STRATEGY_USED && strat === "preferredLanguage" && !isServer) {
|
|
521
|
-
locale = extractLocaleFromNavigator();
|
|
522
|
-
} else if (TREE_SHAKE_LOCAL_STORAGE_STRATEGY_USED && strat === "localStorage" && !isServer) {
|
|
523
|
-
locale = localStorage.getItem(localStorageKey) ?? undefined;
|
|
524
|
-
} else if (isCustomStrategy(strat) && customClientStrategies.has(strat)) {
|
|
525
|
-
const handler = customClientStrategies.get(strat);
|
|
526
|
-
if (handler) {
|
|
527
|
-
const result = handler.getLocale();
|
|
528
|
-
if (result instanceof Promise) {
|
|
529
|
-
continue;
|
|
530
|
-
}
|
|
531
|
-
if (result !== undefined) {
|
|
532
|
-
return assertIsLocale(result);
|
|
533
|
-
}
|
|
534
|
-
}
|
|
535
|
-
}
|
|
536
|
-
const matchedLocale = toLocale(locale);
|
|
537
|
-
if (matchedLocale) {
|
|
538
|
-
return matchedLocale;
|
|
539
|
-
}
|
|
540
|
-
}
|
|
541
|
-
return;
|
|
542
|
-
}
|
|
543
|
-
var rtlLanguages = new Set([
|
|
544
|
-
"ar",
|
|
545
|
-
"dv",
|
|
546
|
-
"fa",
|
|
547
|
-
"he",
|
|
548
|
-
"ks",
|
|
549
|
-
"ku",
|
|
550
|
-
"ps",
|
|
551
|
-
"sd",
|
|
552
|
-
"ug",
|
|
553
|
-
"ur",
|
|
554
|
-
"yi"
|
|
555
|
-
]);
|
|
556
|
-
var navigateOrReload = (newLocation) => {
|
|
557
|
-
if (newLocation) {
|
|
558
|
-
window.location.href = newLocation;
|
|
559
|
-
} else {
|
|
560
|
-
window.location.reload();
|
|
561
|
-
}
|
|
562
|
-
};
|
|
563
|
-
var setLocale = (newLocale, options) => {
|
|
564
|
-
const optionsWithDefaults = {
|
|
565
|
-
reload: true,
|
|
566
|
-
...options
|
|
567
|
-
};
|
|
568
|
-
let currentLocale;
|
|
569
|
-
try {
|
|
570
|
-
currentLocale = getLocale();
|
|
571
|
-
} catch {}
|
|
572
|
-
const customSetLocalePromises = [];
|
|
573
|
-
let newLocation = undefined;
|
|
574
|
-
let strategyToUse = strategy;
|
|
575
|
-
if (!isServer && typeof window !== "undefined" && window.location?.href) {
|
|
576
|
-
strategyToUse = getStrategyForUrl(window.location.href);
|
|
577
|
-
}
|
|
578
|
-
for (const strat of strategyToUse) {
|
|
579
|
-
if (TREE_SHAKE_GLOBAL_VARIABLE_STRATEGY_USED && strat === "globalVariable") {
|
|
580
|
-
_locale = newLocale;
|
|
581
|
-
} else if (TREE_SHAKE_COOKIE_STRATEGY_USED && strat === "cookie") {
|
|
582
|
-
if (isServer || typeof document === "undefined" || typeof window === "undefined") {
|
|
583
|
-
continue;
|
|
584
|
-
}
|
|
585
|
-
const cookieString = `${cookieName}=${newLocale}; path=/; max-age=${cookieMaxAge}`;
|
|
586
|
-
document.cookie = cookieDomain ? `${cookieString}; domain=${cookieDomain}` : cookieString;
|
|
587
|
-
} else if (strat === "baseLocale") {
|
|
588
|
-
continue;
|
|
589
|
-
} else if (TREE_SHAKE_URL_STRATEGY_USED && strat === "url" && typeof window !== "undefined") {
|
|
590
|
-
newLocation = localizeUrl(window.location.href, {
|
|
591
|
-
locale: newLocale
|
|
592
|
-
}).href;
|
|
593
|
-
} else if (TREE_SHAKE_LOCAL_STORAGE_STRATEGY_USED && strat === "localStorage" && typeof window !== "undefined") {
|
|
594
|
-
localStorage.setItem(localStorageKey, newLocale);
|
|
595
|
-
} else if (isCustomStrategy(strat) && customClientStrategies.has(strat)) {
|
|
596
|
-
const handler = customClientStrategies.get(strat);
|
|
597
|
-
if (handler) {
|
|
598
|
-
let result = handler.setLocale(newLocale);
|
|
599
|
-
if (result instanceof Promise) {
|
|
600
|
-
result = result.catch((error) => {
|
|
601
|
-
throw new Error(`Custom strategy "${strat}" setLocale failed.`, {
|
|
602
|
-
cause: error
|
|
603
|
-
});
|
|
604
|
-
});
|
|
605
|
-
customSetLocalePromises.push(result);
|
|
606
|
-
}
|
|
607
|
-
}
|
|
608
|
-
}
|
|
609
|
-
}
|
|
610
|
-
const runReload = () => {
|
|
611
|
-
if (!isServer && optionsWithDefaults.reload && window.location && newLocale !== currentLocale) {
|
|
612
|
-
navigateOrReload(newLocation);
|
|
613
|
-
}
|
|
614
|
-
};
|
|
615
|
-
if (customSetLocalePromises.length) {
|
|
616
|
-
return Promise.all(customSetLocalePromises).then(() => {
|
|
617
|
-
runReload();
|
|
618
|
-
});
|
|
619
|
-
}
|
|
620
|
-
runReload();
|
|
621
|
-
return;
|
|
622
|
-
};
|
|
623
|
-
var getUrlOrigin = () => {
|
|
624
|
-
if (serverAsyncLocalStorage) {
|
|
625
|
-
return serverAsyncLocalStorage.getStore()?.origin ?? "http://fallback.com";
|
|
626
|
-
} else if (typeof window !== "undefined") {
|
|
627
|
-
return window.location.origin;
|
|
628
|
-
}
|
|
629
|
-
return "http://fallback.com";
|
|
630
|
-
};
|
|
631
|
-
function toLocale(value) {
|
|
632
|
-
if (typeof value !== "string") {
|
|
633
|
-
return;
|
|
634
|
-
}
|
|
635
|
-
const lowerValue = value.toLowerCase();
|
|
636
|
-
for (const locale of locales) {
|
|
637
|
-
if (locale.toLowerCase() === lowerValue) {
|
|
638
|
-
return locale;
|
|
639
|
-
}
|
|
640
|
-
}
|
|
641
|
-
return;
|
|
642
|
-
}
|
|
643
|
-
function assertIsLocale(input) {
|
|
644
|
-
const locale = toLocale(input);
|
|
645
|
-
if (locale)
|
|
646
|
-
return locale;
|
|
647
|
-
throw new Error(`Invalid locale: ${input}. Expected one of: ${locales.join(", ")}`);
|
|
648
|
-
}
|
|
649
|
-
function extractLocaleFromCookie() {
|
|
650
|
-
if (typeof document === "undefined" || !document.cookie) {
|
|
651
|
-
return;
|
|
652
|
-
}
|
|
653
|
-
const match = document.cookie.match(new RegExp(`(^| )${cookieName}=([^;]+)`));
|
|
654
|
-
const locale = match?.[2];
|
|
655
|
-
return toLocale(locale);
|
|
656
|
-
}
|
|
657
|
-
function extractLocaleFromNavigator() {
|
|
658
|
-
if (!navigator?.languages?.length) {
|
|
659
|
-
return;
|
|
660
|
-
}
|
|
661
|
-
const languages = navigator.languages.map((lang) => ({
|
|
662
|
-
fullTag: lang,
|
|
663
|
-
baseTag: lang.split("-")[0]
|
|
664
|
-
}));
|
|
665
|
-
for (const lang of languages) {
|
|
666
|
-
const fullLocale = toLocale(lang.fullTag);
|
|
667
|
-
if (fullLocale) {
|
|
668
|
-
return fullLocale;
|
|
669
|
-
}
|
|
670
|
-
const baseLocale2 = toLocale(lang.baseTag);
|
|
671
|
-
if (baseLocale2) {
|
|
672
|
-
return baseLocale2;
|
|
673
|
-
}
|
|
674
|
-
}
|
|
675
|
-
return;
|
|
676
|
-
}
|
|
677
|
-
var cachedUrl;
|
|
678
|
-
var cachedLocale;
|
|
679
|
-
function extractLocaleFromUrl(url) {
|
|
680
|
-
const urlString = typeof url === "string" ? url : url.href;
|
|
681
|
-
if (cachedUrl === urlString) {
|
|
682
|
-
return cachedLocale;
|
|
683
|
-
}
|
|
684
|
-
let result;
|
|
685
|
-
if (TREE_SHAKE_DEFAULT_URL_PATTERN_USED) {
|
|
686
|
-
result = defaultUrlPatternExtractLocale(url);
|
|
687
|
-
} else {
|
|
688
|
-
const urlObj = typeof url === "string" ? new URL(url) : url;
|
|
689
|
-
for (const element of urlPatterns) {
|
|
690
|
-
for (const [locale, localizedPattern] of element.localized) {
|
|
691
|
-
const match = new URLPattern(localizedPattern, urlObj.href).exec(urlObj.href);
|
|
692
|
-
if (match) {
|
|
693
|
-
result = locale;
|
|
694
|
-
break;
|
|
695
|
-
}
|
|
696
|
-
}
|
|
697
|
-
if (result)
|
|
698
|
-
break;
|
|
699
|
-
}
|
|
700
|
-
}
|
|
701
|
-
cachedUrl = urlString;
|
|
702
|
-
cachedLocale = result;
|
|
703
|
-
return result;
|
|
704
|
-
}
|
|
705
|
-
function defaultUrlPatternExtractLocale(url) {
|
|
706
|
-
const urlObj = new URL(url, "http://dummy.com");
|
|
707
|
-
const pathSegments = urlObj.pathname.split("/").filter(Boolean);
|
|
708
|
-
return toLocale(pathSegments[0]) || baseLocale;
|
|
709
|
-
}
|
|
710
|
-
function localizeUrl(url, options) {
|
|
711
|
-
const targetLocale = options?.locale ? assertIsLocale(options?.locale) : getLocale();
|
|
712
|
-
if (TREE_SHAKE_DEFAULT_URL_PATTERN_USED) {
|
|
713
|
-
return localizeUrlDefaultPattern(url, targetLocale);
|
|
714
|
-
}
|
|
715
|
-
const urlObj = typeof url === "string" ? new URL(url) : url;
|
|
716
|
-
for (const element of urlPatterns) {
|
|
717
|
-
for (const [, localizedPattern] of element.localized) {
|
|
718
|
-
const match = new URLPattern(localizedPattern, urlObj.href).exec(urlObj.href);
|
|
719
|
-
if (!match) {
|
|
720
|
-
continue;
|
|
721
|
-
}
|
|
722
|
-
const targetPattern = element.localized.find(([locale]) => locale === targetLocale)?.[1];
|
|
723
|
-
if (!targetPattern) {
|
|
724
|
-
continue;
|
|
725
|
-
}
|
|
726
|
-
const localizedUrl = fillPattern(targetPattern, aggregateGroups(match), urlObj.origin);
|
|
727
|
-
return fillMissingUrlParts(localizedUrl, match);
|
|
728
|
-
}
|
|
729
|
-
const unlocalizedMatch = new URLPattern(element.pattern, urlObj.href).exec(urlObj.href);
|
|
730
|
-
if (unlocalizedMatch) {
|
|
731
|
-
const targetPattern = element.localized.find(([locale]) => locale === targetLocale)?.[1];
|
|
732
|
-
if (targetPattern) {
|
|
733
|
-
const localizedUrl = fillPattern(targetPattern, aggregateGroups(unlocalizedMatch), urlObj.origin);
|
|
734
|
-
return fillMissingUrlParts(localizedUrl, unlocalizedMatch);
|
|
735
|
-
}
|
|
736
|
-
}
|
|
737
|
-
}
|
|
738
|
-
return urlObj;
|
|
739
|
-
}
|
|
740
|
-
function localizeUrlDefaultPattern(url, locale) {
|
|
741
|
-
const urlObj = typeof url === "string" ? new URL(url, getUrlOrigin()) : new URL(url);
|
|
742
|
-
const currentLocale = extractLocaleFromUrl(urlObj);
|
|
743
|
-
if (currentLocale === locale) {
|
|
744
|
-
return urlObj;
|
|
745
|
-
}
|
|
746
|
-
const pathSegments = urlObj.pathname.split("/").filter(Boolean);
|
|
747
|
-
if (pathSegments.length > 0 && toLocale(pathSegments[0])) {
|
|
748
|
-
pathSegments.shift();
|
|
749
|
-
}
|
|
750
|
-
if (locale === baseLocale) {
|
|
751
|
-
urlObj.pathname = "/" + pathSegments.join("/");
|
|
752
|
-
} else {
|
|
753
|
-
urlObj.pathname = "/" + locale + "/" + pathSegments.join("/");
|
|
754
|
-
}
|
|
755
|
-
return urlObj;
|
|
756
|
-
}
|
|
757
|
-
function fillMissingUrlParts(url, match) {
|
|
758
|
-
if (match.protocol.groups["0"]) {
|
|
759
|
-
url.protocol = match.protocol.groups["0"] ?? "";
|
|
760
|
-
}
|
|
761
|
-
if (match.hostname.groups["0"]) {
|
|
762
|
-
url.hostname = match.hostname.groups["0"] ?? "";
|
|
763
|
-
}
|
|
764
|
-
if (match.username.groups["0"]) {
|
|
765
|
-
url.username = match.username.groups["0"] ?? "";
|
|
766
|
-
}
|
|
767
|
-
if (match.password.groups["0"]) {
|
|
768
|
-
url.password = match.password.groups["0"] ?? "";
|
|
769
|
-
}
|
|
770
|
-
if (match.port.groups["0"]) {
|
|
771
|
-
url.port = match.port.groups["0"] ?? "";
|
|
772
|
-
}
|
|
773
|
-
if (match.pathname.groups["0"]) {
|
|
774
|
-
url.pathname = match.pathname.groups["0"] ?? "";
|
|
775
|
-
}
|
|
776
|
-
if (match.search.groups["0"]) {
|
|
777
|
-
url.search = match.search.groups["0"] ?? "";
|
|
778
|
-
}
|
|
779
|
-
if (match.hash.groups["0"]) {
|
|
780
|
-
url.hash = match.hash.groups["0"] ?? "";
|
|
781
|
-
}
|
|
782
|
-
return url;
|
|
783
|
-
}
|
|
784
|
-
function fillPattern(pattern, values, origin) {
|
|
785
|
-
let processedPattern = pattern.replace(/(https?:\/\/[^:/]+):(\d+)(\/|$)/g, (_, protocol, port, slash) => {
|
|
786
|
-
return `${protocol}#PORT-${port}#${slash}`;
|
|
787
|
-
});
|
|
788
|
-
let processedGroupDelimiters = processedPattern.replace(/\{([^{}]*)\}([?+*]?)/g, (_, content, modifier) => {
|
|
789
|
-
if (modifier === "?") {
|
|
790
|
-
return content;
|
|
791
|
-
}
|
|
792
|
-
return content;
|
|
793
|
-
});
|
|
794
|
-
let filled = processedGroupDelimiters.replace(/(\/?):([a-zA-Z0-9_]+)(\([^)]*\))?([?+*]?)/g, (_, slash, name, __, modifier) => {
|
|
795
|
-
const value = values[name];
|
|
796
|
-
if (value === null) {
|
|
797
|
-
return "";
|
|
798
|
-
}
|
|
799
|
-
if (modifier === "?") {
|
|
800
|
-
return value !== undefined ? `${slash}${value}` : "";
|
|
801
|
-
}
|
|
802
|
-
if (modifier === "+" || modifier === "*") {
|
|
803
|
-
if (value === undefined && modifier === "+") {
|
|
804
|
-
throw new Error(`Missing value for "${name}" (one or more required)`);
|
|
805
|
-
}
|
|
806
|
-
return value ? `${slash}${value}` : "";
|
|
807
|
-
}
|
|
808
|
-
if (value === undefined) {
|
|
809
|
-
throw new Error(`Missing value for "${name}"`);
|
|
810
|
-
}
|
|
811
|
-
return `${slash}${value}`;
|
|
812
|
-
});
|
|
813
|
-
filled = filled.replace(/#PORT-(\d+)#/g, ":$1");
|
|
814
|
-
return new URL(filled, origin);
|
|
815
|
-
}
|
|
816
|
-
function aggregateGroups(match) {
|
|
817
|
-
return {
|
|
818
|
-
...match.hash.groups,
|
|
819
|
-
...match.hostname.groups,
|
|
820
|
-
...match.password.groups,
|
|
821
|
-
...match.pathname.groups,
|
|
822
|
-
...match.port.groups,
|
|
823
|
-
...match.protocol.groups,
|
|
824
|
-
...match.search.groups,
|
|
825
|
-
...match.username.groups
|
|
826
|
-
};
|
|
827
|
-
}
|
|
828
|
-
var customServerStrategies = new Map;
|
|
829
|
-
var customClientStrategies = new Map;
|
|
830
|
-
function isCustomStrategy(strategy2) {
|
|
831
|
-
return typeof strategy2 === "string" && /^custom-[A-Za-z0-9_-]+$/.test(strategy2);
|
|
832
|
-
}
|
|
833
|
-
|
|
834
398
|
// ../../src/services/notification/client/notification-menu.tsx
|
|
835
399
|
import { jsx as jsx7, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
836
400
|
var defaultMessages = {
|
|
@@ -867,16 +431,17 @@ var defaultMessages = {
|
|
|
867
431
|
unread: (count) => `${count} notification${count === 1 ? "" : "s"} non lue${count === 1 ? "" : "s"}`
|
|
868
432
|
}
|
|
869
433
|
};
|
|
870
|
-
var notificationMenuMessages = (locale =
|
|
434
|
+
var notificationMenuMessages = (locale = "en", translations) => ({
|
|
871
435
|
...locale.startsWith("fr") ? defaultMessages.fr : defaultMessages.en,
|
|
872
|
-
...
|
|
436
|
+
...translations?.[locale.split("-")[0] ?? locale],
|
|
437
|
+
...translations?.[locale]
|
|
873
438
|
});
|
|
874
439
|
function NotificationMenu({
|
|
875
440
|
className,
|
|
876
441
|
defaultOpen = false,
|
|
877
442
|
error = false,
|
|
878
443
|
isLoading = false,
|
|
879
|
-
locale =
|
|
444
|
+
locale = "en",
|
|
880
445
|
markReadOnOpen = true,
|
|
881
446
|
messages: messageOverrides,
|
|
882
447
|
notifications,
|
|
@@ -989,9 +554,12 @@ function NotificationMenu({
|
|
|
989
554
|
});
|
|
990
555
|
}
|
|
991
556
|
function NotificationMenuTrigger({
|
|
992
|
-
labels
|
|
557
|
+
labels: providedLabels,
|
|
558
|
+
locale = "en",
|
|
559
|
+
messages,
|
|
993
560
|
unreadCount
|
|
994
561
|
}) {
|
|
562
|
+
const labels = providedLabels ?? notificationMenuMessages(locale, messages);
|
|
995
563
|
return /* @__PURE__ */ jsxs2(PopoverTrigger, {
|
|
996
564
|
"aria-label": unreadCount > 0 ? `${labels.notifications}, ${labels.unread(unreadCount)}` : labels.notifications,
|
|
997
565
|
className: cn(buttonVariants({ variant: "outline", size: "icon" }), "relative rounded-full"),
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Config, Layer } from "effect";
|
|
2
|
+
import { HttpRouter } from "effect/unstable/http";
|
|
3
|
+
export declare class HttpApiOtlp {
|
|
4
|
+
static readonly layer: Layer.Layer<import("effect/FileSystem").FileSystem | import("effect/unstable/http/Etag").Generator | import("effect/unstable/http/HttpPlatform").HttpPlatform | import("effect/Path").Path, Config.ConfigError, HttpRouter.HttpRouter>;
|
|
5
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
// ../../src/services/opentelemetry/api.ts
|
|
2
|
+
import { Config, Effect, Layer } from "effect";
|
|
3
|
+
import {
|
|
4
|
+
FetchHttpClient,
|
|
5
|
+
HttpClient,
|
|
6
|
+
HttpClientRequest,
|
|
7
|
+
HttpMiddleware,
|
|
8
|
+
HttpRouter,
|
|
9
|
+
HttpServer,
|
|
10
|
+
HttpServerRequest,
|
|
11
|
+
HttpServerResponse
|
|
12
|
+
} from "effect/unstable/http";
|
|
13
|
+
import { Otlp, OtlpSerialization } from "effect/unstable/observability";
|
|
14
|
+
var OpenTelemetryLive = Otlp.layerFromConfig().pipe(Layer.provide(OtlpSerialization.layerJson), Layer.provide(FetchHttpClient.layer));
|
|
15
|
+
var otlpProxyPaths = [
|
|
16
|
+
"/api/otel/v1/traces",
|
|
17
|
+
"/api/otel/v1/metrics",
|
|
18
|
+
"/api/otel/v1/logs"
|
|
19
|
+
];
|
|
20
|
+
var proxyOtlp = (baseUrl, signal) => Effect.gen(function* () {
|
|
21
|
+
const incoming = yield* HttpServerRequest.HttpServerRequest;
|
|
22
|
+
const client = yield* HttpClient.HttpClient;
|
|
23
|
+
const contentType = incoming.headers["content-type"] ?? "application/json";
|
|
24
|
+
const body = new Uint8Array(yield* incoming.arrayBuffer);
|
|
25
|
+
const request = HttpClientRequest.get(baseUrl).pipe(HttpClientRequest.appendUrl(`/v1/${signal}`), HttpClientRequest.setMethod("POST"), HttpClientRequest.bodyUint8Array(body, contentType));
|
|
26
|
+
const upstream = yield* client.execute(request);
|
|
27
|
+
const responseBody = new Uint8Array(yield* upstream.arrayBuffer);
|
|
28
|
+
return HttpServerResponse.uint8Array(responseBody, {
|
|
29
|
+
status: upstream.status,
|
|
30
|
+
contentType: upstream.headers["content-type"],
|
|
31
|
+
headers: {
|
|
32
|
+
"retry-after": upstream.headers["retry-after"]
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
}).pipe(Effect.withTracerEnabled(false), HttpMiddleware.withLoggerDisabled, Effect.catch((error) => Effect.logError("Failed to proxy browser telemetry", error).pipe(Effect.as(HttpServerResponse.empty({ status: 502 })))), Effect.provide(FetchHttpClient.layer));
|
|
36
|
+
var otlpProxyLayer = Layer.unwrap(Effect.map(Config.url("OTEL_COLLECTOR_PROXY_URL").pipe(Config.withDefault(new URL("http://localhost:4318"))), (baseUrl) => Layer.mergeAll(HttpRouter.add("POST", otlpProxyPaths[0], proxyOtlp(baseUrl, "traces")), HttpRouter.add("POST", otlpProxyPaths[1], proxyOtlp(baseUrl, "metrics")), HttpRouter.add("POST", otlpProxyPaths[2], proxyOtlp(baseUrl, "logs")))));
|
|
37
|
+
var serverServices = HttpServer.layerServices.pipe(Layer.provideMerge(HttpMiddleware.layerTracerDisabledForUrls(otlpProxyPaths)));
|
|
38
|
+
|
|
39
|
+
class HttpApiOtlp {
|
|
40
|
+
static layer = Layer.mergeAll(OpenTelemetryLive, otlpProxyLayer, serverServices);
|
|
41
|
+
}
|
|
42
|
+
export {
|
|
43
|
+
HttpApiOtlp
|
|
44
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Layer } from "effect";
|
|
2
|
+
import { Otlp } from "effect/unstable/observability";
|
|
3
|
+
export declare class BrowserOtlp {
|
|
4
|
+
static readonly layer: ({ attributes, baseUrl, serviceName, serviceVersion, ...options }: Omit<Parameters<typeof Otlp.layerJson>[0], "baseUrl" | "resource"> & {
|
|
5
|
+
readonly serviceName: string;
|
|
6
|
+
readonly serviceVersion?: string;
|
|
7
|
+
readonly attributes?: NonNullable<Parameters<typeof Otlp.layerJson>[0]["resource"]>["attributes"];
|
|
8
|
+
readonly baseUrl?: string;
|
|
9
|
+
}) => Layer.Layer<never, never, never>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
// ../../src/services/opentelemetry/browser.ts
|
|
2
|
+
import { Effect, Layer, Predicate, Schema, Stream } from "effect";
|
|
3
|
+
import { FetchHttpClient } from "effect/unstable/http";
|
|
4
|
+
import { Otlp } from "effect/unstable/observability";
|
|
5
|
+
|
|
6
|
+
class BrowserReportedError extends Schema.TaggedError()("BrowserReportedError", {
|
|
7
|
+
type: Schema.Literals(["window.error", "unhandledrejection"]),
|
|
8
|
+
message: Schema.String,
|
|
9
|
+
stack: Schema.optional(Schema.String)
|
|
10
|
+
}) {
|
|
11
|
+
}
|
|
12
|
+
var reportBrowserException = (exception) => Effect.fail(exception).pipe(Effect.withSpan("browser.exception", {
|
|
13
|
+
attributes: {
|
|
14
|
+
"exception.type": exception.type,
|
|
15
|
+
"exception.message": exception.message,
|
|
16
|
+
"exception.stacktrace": exception.stack ?? ""
|
|
17
|
+
}
|
|
18
|
+
}), Effect.ignoreCause);
|
|
19
|
+
var BrowserExceptionTrackingLive = Layer.effectDiscard(Stream.merge(Stream.fromEventListener(globalThis, "error", {
|
|
20
|
+
bufferSize: 100
|
|
21
|
+
}).pipe(Stream.map((event) => {
|
|
22
|
+
const error = event.error;
|
|
23
|
+
return new BrowserReportedError({
|
|
24
|
+
type: "window.error",
|
|
25
|
+
message: event.message,
|
|
26
|
+
stack: Predicate.isError(error) ? error.stack : undefined
|
|
27
|
+
});
|
|
28
|
+
})), Stream.fromEventListener(globalThis, "unhandledrejection", { bufferSize: 100 }).pipe(Stream.map((event) => {
|
|
29
|
+
const reason = event.reason;
|
|
30
|
+
return new BrowserReportedError(Predicate.isError(reason) ? {
|
|
31
|
+
type: "unhandledrejection",
|
|
32
|
+
message: reason.message,
|
|
33
|
+
stack: reason.stack
|
|
34
|
+
} : {
|
|
35
|
+
type: "unhandledrejection",
|
|
36
|
+
message: "Unhandled promise rejection"
|
|
37
|
+
});
|
|
38
|
+
}))).pipe(Stream.runForEach(reportBrowserException), Effect.forkScoped));
|
|
39
|
+
|
|
40
|
+
class BrowserOtlp {
|
|
41
|
+
static layer = ({
|
|
42
|
+
attributes,
|
|
43
|
+
baseUrl = "/api/otel",
|
|
44
|
+
serviceName,
|
|
45
|
+
serviceVersion,
|
|
46
|
+
...options
|
|
47
|
+
}) => BrowserExceptionTrackingLive.pipe(Layer.provideMerge(Otlp.layerJson({
|
|
48
|
+
tracerExportInterval: "5 seconds",
|
|
49
|
+
metricsExportInterval: "30 seconds",
|
|
50
|
+
loggerExcludeLogSpans: true,
|
|
51
|
+
loggerMergeWithExisting: true,
|
|
52
|
+
...options,
|
|
53
|
+
baseUrl,
|
|
54
|
+
resource: { attributes, serviceName, serviceVersion }
|
|
55
|
+
}).pipe(Layer.provide(FetchHttpClient.layer))));
|
|
56
|
+
}
|
|
57
|
+
export {
|
|
58
|
+
BrowserOtlp
|
|
59
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@krak-stack/registry",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.33",
|
|
4
4
|
"description": "Tree-shakable KrakStack components and Effect services.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -48,6 +48,14 @@
|
|
|
48
48
|
"types": "./dist/lib/httpapi-mcp.d.ts",
|
|
49
49
|
"import": "./dist/lib/httpapi-mcp.js"
|
|
50
50
|
},
|
|
51
|
+
"./opentelemetry/api": {
|
|
52
|
+
"types": "./dist/services/opentelemetry/api.d.ts",
|
|
53
|
+
"import": "./dist/services/opentelemetry/api.js"
|
|
54
|
+
},
|
|
55
|
+
"./opentelemetry/browser": {
|
|
56
|
+
"types": "./dist/services/opentelemetry/browser.d.ts",
|
|
57
|
+
"import": "./dist/services/opentelemetry/browser.js"
|
|
58
|
+
},
|
|
51
59
|
"./docs": {
|
|
52
60
|
"types": "./dist/lib/docs.d.ts",
|
|
53
61
|
"import": "./dist/lib/docs.js"
|