@donotdev/ui 0.3.1 → 0.3.3
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 +2 -3
- package/dist/components/auth/AuthHeader.js +1 -93
- package/dist/components/auth/AuthMenu.d.ts.map +1 -1
- package/dist/components/auth/AuthMenu.js +3 -286
- package/dist/components/auth/index.js +1 -9
- package/dist/components/common/FeatureCard.d.ts.map +1 -1
- package/dist/components/common/FeatureCard.js +1 -86
- package/dist/components/common/FeatureDisabled.js +1 -67
- package/dist/components/common/IconPlaceholder.d.ts +24 -0
- package/dist/components/common/IconPlaceholder.d.ts.map +1 -0
- package/dist/components/common/IconPlaceholder.js +1 -0
- package/dist/components/common/LazyLucideIcon.d.ts +39 -0
- package/dist/components/common/LazyLucideIcon.d.ts.map +1 -0
- package/dist/components/common/LazyLucideIcon.js +1 -0
- package/dist/components/common/ProgressBar.js +1 -84
- package/dist/components/common/RedirectOverlay.js +1 -243
- package/dist/components/common/Skeleton.js +1 -144
- package/dist/components/common/TechBento.d.ts.map +1 -1
- package/dist/components/common/TechBento.js +1 -53
- package/dist/components/common/icon.d.ts +1 -1
- package/dist/components/common/icon.d.ts.map +1 -1
- package/dist/components/common/icon.js +1 -84
- package/dist/components/common/iconByName.d.ts +33 -0
- package/dist/components/common/iconByName.d.ts.map +1 -0
- package/dist/components/common/iconByName.js +1 -0
- package/dist/components/common/index.js +1 -16
- package/dist/components/cookie-consent/ConsentBanner.d.ts +3 -1
- package/dist/components/cookie-consent/ConsentBanner.d.ts.map +1 -1
- package/dist/components/cookie-consent/ConsentBanner.js +1 -31
- package/dist/components/cookie-consent/CookieConsent.d.ts.map +1 -1
- package/dist/components/cookie-consent/CookieConsent.js +1 -183
- package/dist/components/cookie-consent/index.js +1 -11
- package/dist/components/cookie-consent/useCookieNoticeRequired.d.ts +7 -0
- package/dist/components/cookie-consent/useCookieNoticeRequired.d.ts.map +1 -0
- package/dist/components/cookie-consent/useCookieNoticeRequired.js +1 -0
- package/dist/components/index.js +1 -13
- package/dist/components/layout/GameContainer.d.ts.map +1 -1
- package/dist/components/layout/GameContainer.js +1 -72
- package/dist/components/layout/GameFlow.d.ts.map +1 -1
- package/dist/components/layout/GameFlow.js +1 -93
- package/dist/components/layout/PageConfig.d.ts.map +1 -1
- package/dist/components/layout/PageConfig.js +1 -47
- package/dist/components/layout/PageContainer.d.ts.map +1 -1
- package/dist/components/layout/PageContainer.js +1 -38
- package/dist/components/layout/components/Breadcrumbs.d.ts +2 -1
- package/dist/components/layout/components/Breadcrumbs.d.ts.map +1 -1
- package/dist/components/layout/components/Breadcrumbs.js +1 -89
- package/dist/components/layout/components/DropdownNavigation.d.ts.map +1 -1
- package/dist/components/layout/components/DropdownNavigation.js +1 -30
- package/dist/components/layout/components/FloatingLanguageSwitcher.d.ts.map +1 -1
- package/dist/components/layout/components/FloatingLanguageSwitcher.js +1 -26
- package/dist/components/layout/components/Notifications.js +1 -182
- package/dist/components/layout/components/header/AppBranding.d.ts.map +1 -1
- package/dist/components/layout/components/header/AppBranding.js +1 -54
- package/dist/components/layout/components/header/AppIcon.d.ts.map +1 -1
- package/dist/components/layout/components/header/AppIcon.js +1 -59
- package/dist/components/layout/components/header/AppTitle.d.ts.map +1 -1
- package/dist/components/layout/components/header/AppTitle.js +1 -40
- package/dist/components/layout/components/header/CacheSettings.js +1 -225
- package/dist/components/layout/components/header/GameTitle.d.ts.map +1 -1
- package/dist/components/layout/components/header/GameTitle.js +1 -66
- package/dist/components/layout/components/header/HeaderMenu.js +1 -75
- package/dist/components/layout/components/header/HeaderNavigation.d.ts.map +1 -1
- package/dist/components/layout/components/header/HeaderNavigation.js +1 -66
- package/dist/components/layout/components/header/SettingsMenu.d.ts.map +1 -1
- package/dist/components/layout/components/header/SettingsMenu.js +1 -85
- package/dist/components/layout/components/header/ThemeToggle.d.ts.map +1 -1
- package/dist/components/layout/components/header/ThemeToggle.js +1 -93
- package/dist/components/layout/components/index.js +1 -25
- package/dist/components/layout/index.js +1 -14
- package/dist/crud/components/ChildRowsPicker.js +1 -68
- package/dist/crud/components/CrudCardLink.js +1 -14
- package/dist/crud/components/EntityCardList.d.ts +4 -1
- package/dist/crud/components/EntityCardList.d.ts.map +1 -1
- package/dist/crud/components/EntityCardList.js +1 -184
- package/dist/crud/components/EntityDisplayRenderer.js +1 -130
- package/dist/crud/components/EntityFormRenderer.js +1 -433
- package/dist/crud/components/EntityList.js +1 -521
- package/dist/crud/components/EntityRecommendations.js +1 -87
- package/dist/crud/components/EntityWorkflow.js +1 -55
- package/dist/crud/components/Form.d.ts.map +1 -1
- package/dist/crud/components/Form.js +1 -198
- package/dist/crud/components/cellEditFor.js +1 -74
- package/dist/crud/components/entityParent.js +1 -76
- package/dist/crud/components/index.js +1 -16
- package/dist/crud/components/useRecordBreadcrumb.d.ts +3 -1
- package/dist/crud/components/useRecordBreadcrumb.d.ts.map +1 -1
- package/dist/crud/components/useRecordBreadcrumb.js +1 -43
- package/dist/crud/crudImports.js +1 -51
- package/dist/crud/index.js +1 -11
- package/dist/data/techLogos.js +1 -99
- package/dist/dndev-next.css +113 -41
- package/dist/dndev.css +113 -41
- package/dist/index.js +1 -5
- package/dist/internal/common/DnDevErrorBoundary.js +1 -55
- package/dist/internal/common/ErrorFallback.js +3 -214
- package/dist/internal/common/GlobalErrorFallback.js +1 -45
- package/dist/internal/common/RouteErrorFallback.js +3 -140
- package/dist/internal/devtools/DebugTools.js +1 -131
- package/dist/internal/devtools/components/AuthDebugButton.js +1 -72
- package/dist/internal/devtools/components/ConfigTab.js +1 -61
- package/dist/internal/devtools/components/CookieTab.js +1 -156
- package/dist/internal/devtools/components/DebugDialog.js +1 -48
- package/dist/internal/devtools/components/DesignTab.js +1 -469
- package/dist/internal/devtools/components/LayoutReset.js +1 -214
- package/dist/internal/devtools/components/MaskedValue.js +1 -39
- package/dist/internal/devtools/components/StoresTab.js +1 -90
- package/dist/internal/devtools/components/index.js +1 -16
- package/dist/internal/devtools/index.js +1 -13
- package/dist/internal/devtools/types.js +0 -2
- package/dist/internal/devtools/utils/envVarDiscovery.js +1 -106
- package/dist/internal/devtools/utils/index.js +1 -12
- package/dist/internal/devtools/utils/maskSensitive.js +1 -59
- package/dist/internal/devtools/utils/virtualModuleInspector.js +1 -309
- package/dist/internal/initializers/BaseStoresInitializer.js +1 -367
- package/dist/internal/initializers/NextJsStoresInitializer.js +1 -78
- package/dist/internal/initializers/ViteStoresInitializer.js +1 -20
- package/dist/internal/initializers/index.js +1 -11
- package/dist/internal/layout/DnDevLayout.js +1 -321
- package/dist/internal/layout/components/AutoMetaTags.d.ts +5 -0
- package/dist/internal/layout/components/AutoMetaTags.d.ts.map +1 -1
- package/dist/internal/layout/components/AutoMetaTags.js +1 -338
- package/dist/internal/layout/components/FaviconHead.d.ts +18 -14
- package/dist/internal/layout/components/FaviconHead.d.ts.map +1 -1
- package/dist/internal/layout/components/FaviconHead.js +1 -60
- package/dist/internal/layout/components/FontPreloadLinks.js +1 -31
- package/dist/internal/layout/components/HeadTags.js +1 -20
- package/dist/internal/layout/components/PWAUpdateNotification.js +1 -131
- package/dist/internal/layout/components/footer/FooterBranding.d.ts.map +1 -1
- package/dist/internal/layout/components/footer/FooterBranding.js +1 -35
- package/dist/internal/layout/components/footer/FooterCopyright.d.ts.map +1 -1
- package/dist/internal/layout/components/footer/FooterCopyright.js +1 -37
- package/dist/internal/layout/components/footer/FooterLegalLinks.d.ts.map +1 -1
- package/dist/internal/layout/components/footer/FooterLegalLinks.js +1 -44
- package/dist/internal/layout/components/footer/useLegalLinks.d.ts +4 -2
- package/dist/internal/layout/components/footer/useLegalLinks.d.ts.map +1 -1
- package/dist/internal/layout/components/footer/useLegalLinks.js +1 -21
- package/dist/internal/layout/components/headTagElement.d.ts +16 -0
- package/dist/internal/layout/components/headTagElement.d.ts.map +1 -0
- package/dist/internal/layout/components/headTagElement.js +1 -0
- package/dist/internal/layout/components/index.js +1 -13
- package/dist/internal/layout/components/prerenderedHead.d.ts +15 -0
- package/dist/internal/layout/components/prerenderedHead.d.ts.map +1 -0
- package/dist/internal/layout/components/prerenderedHead.js +1 -0
- package/dist/internal/layout/components/trailingSlash.d.ts +13 -0
- package/dist/internal/layout/components/trailingSlash.d.ts.map +1 -0
- package/dist/internal/layout/components/trailingSlash.js +1 -0
- package/dist/internal/layout/config/defaults.js +1 -47
- package/dist/internal/layout/config/index.js +1 -11
- package/dist/internal/layout/config/presets/admin.js +1 -35
- package/dist/internal/layout/config/presets/blog.js +1 -31
- package/dist/internal/layout/config/presets/docs.js +1 -51
- package/dist/internal/layout/config/presets/game.js +1 -53
- package/dist/internal/layout/config/presets/index.js +1 -24
- package/dist/internal/layout/config/presets/landing.js +1 -42
- package/dist/internal/layout/config/presets/moolti.js +1 -52
- package/dist/internal/layout/config/presets/plain.js +1 -25
- package/dist/internal/layout/renderers/index.js +0 -10
- package/dist/internal/layout/zones/DnDevFooter.d.ts.map +1 -1
- package/dist/internal/layout/zones/DnDevFooter.js +1 -67
- package/dist/internal/layout/zones/DnDevHeader.js +1 -41
- package/dist/internal/layout/zones/DnDevMergedBar.d.ts.map +1 -1
- package/dist/internal/layout/zones/DnDevMergedBar.js +1 -52
- package/dist/internal/layout/zones/DnDevSidebar.d.ts.map +1 -1
- package/dist/internal/layout/zones/DnDevSidebar.js +1 -181
- package/dist/internal/layout/zones/index.js +1 -14
- package/dist/internal/providers/NavigationProvider.d.ts.map +1 -1
- package/dist/internal/providers/NavigationProvider.js +1 -71
- package/dist/internal/providers/SentryInitializer.d.ts.map +1 -1
- package/dist/internal/providers/SentryInitializer.js +1 -36
- package/dist/internal/providers/UIProviders.js +1 -79
- package/dist/internal/providers/index.js +1 -12
- package/dist/next.js +1 -11
- package/dist/providers/NextJsAppProviders.d.ts.map +1 -1
- package/dist/providers/NextJsAppProviders.js +1 -107
- package/dist/providers/ViteAppProviders.d.ts +11 -9
- package/dist/providers/ViteAppProviders.d.ts.map +1 -1
- package/dist/providers/ViteAppProviders.js +1 -117
- package/dist/providers/index.js +1 -11
- package/dist/routing/404.js +1 -108
- package/dist/routing/AuthGuard.js +1 -178
- package/dist/routing/AuthGuardFallback.d.ts.map +1 -1
- package/dist/routing/AuthGuardFallback.js +1 -67
- package/dist/routing/AuthReturnTo.js +1 -68
- package/dist/routing/DnDevNavigationMenu.d.ts.map +1 -1
- package/dist/routing/DnDevNavigationMenu.js +1 -138
- package/dist/routing/GoTo.d.ts.map +1 -1
- package/dist/routing/GoTo.js +1 -38
- package/dist/routing/GoToDialog.d.ts.map +1 -1
- package/dist/routing/GoToDialog.js +1 -97
- package/dist/routing/GoToInput.d.ts.map +1 -1
- package/dist/routing/GoToInput.js +1 -49
- package/dist/routing/GoToWrapper.d.ts.map +1 -1
- package/dist/routing/GoToWrapper.js +1 -59
- package/dist/routing/Link.d.ts +10 -2
- package/dist/routing/Link.d.ts.map +1 -1
- package/dist/routing/Link.js +1 -109
- package/dist/routing/NavigationItem.d.ts.map +1 -1
- package/dist/routing/NavigationItem.js +1 -44
- package/dist/routing/NotFoundDocument.d.ts +33 -0
- package/dist/routing/NotFoundDocument.d.ts.map +1 -0
- package/dist/routing/NotFoundDocument.js +1 -0
- package/dist/routing/SignedInRedirect.js +1 -47
- package/dist/routing/hooks/hooks.next.js +1 -1
- package/dist/routing/hooks/hooks.vite.js +1 -1
- package/dist/routing/hooks/index.js +1 -26
- package/dist/routing/hooks/types.js +0 -2
- package/dist/routing/hooks/useLocation.next.js +1 -35
- package/dist/routing/hooks/useLocation.vite.js +1 -13
- package/dist/routing/hooks/useMatch.next.js +1 -31
- package/dist/routing/hooks/useMatch.vite.js +1 -6
- package/dist/routing/hooks/useNavigate.next.js +1 -64
- package/dist/routing/hooks/useNavigate.vite.js +1 -61
- package/dist/routing/hooks/useParams.next.js +1 -9
- package/dist/routing/hooks/useParams.vite.js +1 -6
- package/dist/routing/hooks/useQueryParams.next.js +1 -66
- package/dist/routing/hooks/useQueryParams.vite.js +1 -66
- package/dist/routing/hooks/useRedirectGuard.next.js +1 -119
- package/dist/routing/hooks/useRedirectGuard.vite.js +1 -117
- package/dist/routing/hooks/useRouteParam.next.js +1 -38
- package/dist/routing/hooks/useRouteParam.vite.js +1 -38
- package/dist/routing/hooks/useRoutePath.next.d.ts +5 -3
- package/dist/routing/hooks/useRoutePath.next.d.ts.map +1 -1
- package/dist/routing/hooks/useRoutePath.next.js +1 -36
- package/dist/routing/hooks/useRoutePath.vite.js +1 -25
- package/dist/routing/hooks/useSearchParams.next.js +1 -22
- package/dist/routing/hooks/useSearchParams.vite.js +1 -22
- package/dist/routing/hooks/useUrlLanguage.next.js +1 -50
- package/dist/routing/hooks/useUrlLanguage.vite.js +1 -41
- package/dist/routing/index.d.ts +1 -0
- package/dist/routing/index.d.ts.map +1 -1
- package/dist/routing/index.js +1 -32
- package/dist/routing/link/InternalLink.next.d.ts +23 -0
- package/dist/routing/link/InternalLink.next.d.ts.map +1 -0
- package/dist/routing/link/InternalLink.next.js +1 -0
- package/dist/routing/link/InternalLink.vite.d.ts +22 -0
- package/dist/routing/link/InternalLink.vite.d.ts.map +1 -0
- package/dist/routing/link/InternalLink.vite.js +1 -0
- package/dist/routing/link/absolutePath.d.ts +17 -0
- package/dist/routing/link/absolutePath.d.ts.map +1 -0
- package/dist/routing/link/absolutePath.js +1 -0
- package/dist/routing/link/link.next.d.ts +12 -0
- package/dist/routing/link/link.next.d.ts.map +1 -0
- package/dist/routing/link/link.next.js +1 -0
- package/dist/routing/link/link.vite.d.ts +12 -0
- package/dist/routing/link/link.vite.d.ts.map +1 -0
- package/dist/routing/link/link.vite.js +1 -0
- package/dist/routing/link/types.d.ts +30 -0
- package/dist/routing/link/types.d.ts.map +1 -0
- package/dist/routing/link/types.js +0 -0
- package/dist/routing/parentRoute.js +1 -43
- package/dist/routing/useGoTo.d.ts.map +1 -1
- package/dist/routing/useGoTo.js +1 -59
- package/dist/routing/useNavigation.d.ts.map +1 -1
- package/dist/routing/useNavigation.js +1 -114
- package/dist/routing/useRouteDiscovery.d.ts +4 -0
- package/dist/routing/useRouteDiscovery.d.ts.map +1 -1
- package/dist/routing/useRouteDiscovery.js +1 -313
- package/dist/rsc.d.ts +28 -0
- package/dist/rsc.d.ts.map +1 -0
- package/dist/rsc.js +1 -0
- package/dist/styles/index.css +113 -41
- package/dist/styles/index.js +1 -10
- package/dist/styles/layoutConstants.js +1 -134
- package/dist/symbol-index.json +1 -1
- package/dist/utils/assetResolver.d.ts +19 -19
- package/dist/utils/assetResolver.d.ts.map +1 -1
- package/dist/utils/assetResolver.js +1 -297
- package/dist/utils/index.d.ts +0 -1
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +1 -23
- package/dist/utils/sanitizeSvg.js +1 -51
- package/dist/utils/tList.js +1 -42
- package/dist/utils/useAISafe.d.ts.map +1 -1
- package/dist/utils/useAISafe.js +1 -53
- package/dist/utils/useAuthSafe.d.ts.map +1 -1
- package/dist/utils/useAuthSafe.js +1 -78
- package/dist/utils/useAuthVisibility.d.ts.map +1 -1
- package/dist/utils/useAuthVisibility.js +1 -63
- package/dist/utils/useBillingVisibility.d.ts.map +1 -1
- package/dist/utils/useBillingVisibility.js +1 -57
- package/dist/utils/useCrudSafe.d.ts.map +1 -1
- package/dist/utils/useCrudSafe.js +1 -75
- package/dist/utils/useDeleteAccountSafe.js +1 -52
- package/dist/utils/useFormStoreSafe.d.ts.map +1 -1
- package/dist/utils/useFormStoreSafe.js +1 -85
- package/dist/utils/useOAuthSafe.d.ts.map +1 -1
- package/dist/utils/useOAuthSafe.js +1 -38
- package/dist/utils/useStripeBillingSafe.d.ts.map +1 -1
- package/dist/utils/useStripeBillingSafe.js +1 -81
- package/dist/vite-routing/AppRoutes.d.ts.map +1 -1
- package/dist/vite-routing/AppRoutes.js +1 -235
- package/dist/vite-routing/RootLayout.d.ts.map +1 -1
- package/dist/vite-routing/RootLayout.js +1 -205
- package/dist/vite-routing/index.js +1 -11
- package/dist/vite.js +1 -10
- package/guidelines/COMPONENTS.md +3 -3
- package/guidelines/PAGES.md +3 -0
- package/guidelines/ROUTING.md +16 -0
- package/guidelines/SEO.md +160 -142
- package/package.json +18 -8
- package/dist/ChildRowsPicker-63M4EQUQ.js +0 -1
- package/dist/ChildRowsPicker-ISP365ON.js +0 -1
- package/dist/ChildRowsPicker-PQFE6NCR.js +0 -1
- package/dist/ChildRowsPicker-XXFFSMWY.js +0 -1
- package/dist/CookieConsent-QOUAY6B4.js +0 -1
- package/dist/GoToDialog-KSBGOIWO.js +0 -1
- package/dist/GoToDialog-XBK5EZF4.js +0 -1
- package/dist/chunk-3CIZFGST.js +0 -1
- package/dist/chunk-LHMKU342.js +0 -1
- package/dist/chunk-MS7ZIW5Z.js +0 -1
- package/dist/chunk-O2XFH626.js +0 -1
- package/dist/chunk-P2DHZWPY.js +0 -1
- package/dist/components/common/lucideIconByName.d.ts +0 -9
- package/dist/components/common/lucideIconByName.d.ts.map +0 -1
- package/dist/components/common/lucideIconByName.js +0 -32
- package/dist/internal/layout/components/PerformanceHints.d.ts +0 -71
- package/dist/internal/layout/components/PerformanceHints.d.ts.map +0 -1
- package/dist/internal/layout/components/PerformanceHints.js +0 -71
- package/dist/internal/layout/components/i18nSeoMeta.d.ts +0 -54
- package/dist/internal/layout/components/i18nSeoMeta.d.ts.map +0 -1
- package/dist/internal/layout/components/i18nSeoMeta.js +0 -53
- package/dist/utils/useSeo.d.ts +0 -129
- package/dist/utils/useSeo.d.ts.map +0 -1
- package/dist/utils/useSeo.js +0 -151
|
@@ -1,297 +1 @@
|
|
|
1
|
-
|
|
2
|
-
/**
|
|
3
|
-
* @fileoverview Modern asset resolution system for DoNotDev
|
|
4
|
-
* @description Handles logo and favicon resolution with format preferences and fallbacks
|
|
5
|
-
*
|
|
6
|
-
* @version 0.1.0
|
|
7
|
-
* @since 0.0.1
|
|
8
|
-
* @author AMBROISE PARK Consulting
|
|
9
|
-
*/
|
|
10
|
-
import { getDndevConfig, isClient, isDev } from '@donotdev/core';
|
|
11
|
-
// Global types are imported from @donotdev/core
|
|
12
|
-
// No local declarations needed
|
|
13
|
-
/**
|
|
14
|
-
* Modern asset resolution with format preference and browser capability detection
|
|
15
|
-
* Follows Next.js Image optimization patterns
|
|
16
|
-
*
|
|
17
|
-
* @version 0.1.0
|
|
18
|
-
* @since 0.0.1
|
|
19
|
-
* @author AMBROISE PARK Consulting
|
|
20
|
-
*/
|
|
21
|
-
export class AssetResolver {
|
|
22
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- why: value type flows into the public inferred return of getDebugInfo().cache; tightening it is an API change (see any-audit)
|
|
23
|
-
static cache = new Map();
|
|
24
|
-
/**
|
|
25
|
-
* Check if browser supports modern image formats
|
|
26
|
-
*/
|
|
27
|
-
static getBrowserSupport() {
|
|
28
|
-
// SSR-safe browser detection
|
|
29
|
-
if (!isClient()) {
|
|
30
|
-
return { svg: true, webp: false, avif: false };
|
|
31
|
-
}
|
|
32
|
-
const cached = this.cache.get('browser-support');
|
|
33
|
-
if (cached)
|
|
34
|
-
return cached;
|
|
35
|
-
const support = {
|
|
36
|
-
svg: true, // All modern browsers support SVG
|
|
37
|
-
webp: false,
|
|
38
|
-
avif: false,
|
|
39
|
-
};
|
|
40
|
-
// WebP support detection
|
|
41
|
-
try {
|
|
42
|
-
const canvas = document.createElement('canvas');
|
|
43
|
-
canvas.width = 1;
|
|
44
|
-
canvas.height = 1;
|
|
45
|
-
support.webp =
|
|
46
|
-
canvas.toDataURL('image/webp').indexOf('data:image/webp') === 0;
|
|
47
|
-
}
|
|
48
|
-
catch (e) {
|
|
49
|
-
support.webp = false;
|
|
50
|
-
}
|
|
51
|
-
// AVIF support detection (newer format)
|
|
52
|
-
try {
|
|
53
|
-
const canvas = document.createElement('canvas');
|
|
54
|
-
canvas.width = 1;
|
|
55
|
-
canvas.height = 1;
|
|
56
|
-
support.avif =
|
|
57
|
-
canvas.toDataURL('image/avif').indexOf('data:image/avif') === 0;
|
|
58
|
-
}
|
|
59
|
-
catch (e) {
|
|
60
|
-
support.avif = false;
|
|
61
|
-
}
|
|
62
|
-
this.cache.set('browser-support', support);
|
|
63
|
-
return support;
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* Recursively extract all string values from nested object/array structure
|
|
67
|
-
*/
|
|
68
|
-
static extractStringValues(obj) {
|
|
69
|
-
const values = [];
|
|
70
|
-
if (obj === null || obj === undefined)
|
|
71
|
-
return values;
|
|
72
|
-
if (typeof obj === 'string') {
|
|
73
|
-
values.push(obj);
|
|
74
|
-
}
|
|
75
|
-
else if (Array.isArray(obj)) {
|
|
76
|
-
for (const item of obj) {
|
|
77
|
-
values.push(...this.extractStringValues(item));
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
else if (typeof obj === 'object') {
|
|
81
|
-
for (const value of Object.values(obj)) {
|
|
82
|
-
values.push(...this.extractStringValues(value));
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
return values;
|
|
86
|
-
}
|
|
87
|
-
/**
|
|
88
|
-
* Check if an asset exists (SSR-safe)
|
|
89
|
-
* Checks build-time injected manifest structure (nested objects, arrays)
|
|
90
|
-
*/
|
|
91
|
-
static assetExists(path) {
|
|
92
|
-
// SSR environment
|
|
93
|
-
if (!isClient())
|
|
94
|
-
return false;
|
|
95
|
-
const manifest = this.getAssetManifest();
|
|
96
|
-
if (!manifest)
|
|
97
|
-
return false;
|
|
98
|
-
// Extract all string paths from nested manifest structure
|
|
99
|
-
const allPaths = this.extractStringValues(manifest);
|
|
100
|
-
return allPaths.includes(path);
|
|
101
|
-
}
|
|
102
|
-
/**
|
|
103
|
-
* Get asset manifest if available
|
|
104
|
-
*/
|
|
105
|
-
static getAssetManifest() {
|
|
106
|
-
if (!isClient())
|
|
107
|
-
return null;
|
|
108
|
-
const config = getDndevConfig();
|
|
109
|
-
return config?.assets?.mapping || null;
|
|
110
|
-
}
|
|
111
|
-
/**
|
|
112
|
-
* Get logo SVG content for inline rendering
|
|
113
|
-
* Works in both CSR and SSR (globalThis available in both contexts)
|
|
114
|
-
* @returns {string | null} SVG content or null if not available
|
|
115
|
-
*/
|
|
116
|
-
static getLogoSvgContent() {
|
|
117
|
-
const config = getDndevConfig();
|
|
118
|
-
return config?.assets?.logoSvgContent || null;
|
|
119
|
-
}
|
|
120
|
-
/**
|
|
121
|
-
* Resolve logo path
|
|
122
|
-
* Rule: Use manifest optimal if available, otherwise /logo.svg (user must provide)
|
|
123
|
-
*/
|
|
124
|
-
static resolveLogo(customPath) {
|
|
125
|
-
if (customPath)
|
|
126
|
-
return customPath;
|
|
127
|
-
const cacheKey = 'logo';
|
|
128
|
-
if (this.cache.has(cacheKey)) {
|
|
129
|
-
return this.cache.get(cacheKey);
|
|
130
|
-
}
|
|
131
|
-
const manifest = this.getAssetManifest();
|
|
132
|
-
const logoPath = manifest?.logo?.optimal || '/logo.svg';
|
|
133
|
-
this.cache.set(cacheKey, logoPath);
|
|
134
|
-
return logoPath;
|
|
135
|
-
}
|
|
136
|
-
/**
|
|
137
|
-
* Direct asset existence check for development
|
|
138
|
-
* More reliable than the build-time detection
|
|
139
|
-
*
|
|
140
|
-
* **Limitation:** This is a synchronous heuristic that always returns true
|
|
141
|
-
* when `new Image()` doesn't throw. It does NOT wait for the image to load,
|
|
142
|
-
* so it cannot detect 404s. A proper async check would require returning a
|
|
143
|
-
* Promise<boolean> via Image.onload/onerror, but that would change the
|
|
144
|
-
* synchronous contract used by resolveLogo/resolveFaviconSet.
|
|
145
|
-
*/
|
|
146
|
-
static directAssetCheck(path) {
|
|
147
|
-
if (!isClient())
|
|
148
|
-
return false;
|
|
149
|
-
try {
|
|
150
|
-
// Create a temporary image element to test if the resource exists
|
|
151
|
-
const testImg = new Image();
|
|
152
|
-
testImg.src = path;
|
|
153
|
-
// Synchronous heuristic: assumes asset exists if Image() doesn't throw.
|
|
154
|
-
// Cannot validate actual load — see JSDoc limitation above.
|
|
155
|
-
return true;
|
|
156
|
-
}
|
|
157
|
-
catch {
|
|
158
|
-
return false;
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
/**
|
|
162
|
-
* Resolve complete favicon set with modern standards
|
|
163
|
-
* Follows PWA manifest and web.dev best practices
|
|
164
|
-
*/
|
|
165
|
-
static resolveFaviconSet() {
|
|
166
|
-
const cacheKey = 'favicon-set';
|
|
167
|
-
if (this.cache.has(cacheKey)) {
|
|
168
|
-
return this.cache.get(cacheKey);
|
|
169
|
-
}
|
|
170
|
-
// Try to use build-time detected favicon set
|
|
171
|
-
const manifest = this.getAssetManifest();
|
|
172
|
-
if (manifest?.favicon?.set) {
|
|
173
|
-
const set = manifest.favicon.set;
|
|
174
|
-
// Use icon-512x512.png as fallback (generated from logo.svg)
|
|
175
|
-
const fallbackIcon = this.assetExists('/icon-512x512.png')
|
|
176
|
-
? '/icon-512x512.png'
|
|
177
|
-
: this.assetExists('/icon-192x192.png')
|
|
178
|
-
? '/icon-192x192.png'
|
|
179
|
-
: '/logo.svg';
|
|
180
|
-
// Filter out null values and provide framework fallbacks
|
|
181
|
-
const resolvedSet = {
|
|
182
|
-
svg: set.svg || '/favicon.svg',
|
|
183
|
-
ico: set.ico || '/favicon.ico',
|
|
184
|
-
png16: set.png16 || fallbackIcon,
|
|
185
|
-
png32: set.png32 || fallbackIcon,
|
|
186
|
-
apple180: set.apple180 || fallbackIcon,
|
|
187
|
-
android192: set.android192 || fallbackIcon,
|
|
188
|
-
android512: set.android512 || fallbackIcon,
|
|
189
|
-
};
|
|
190
|
-
this.cache.set(cacheKey, resolvedSet);
|
|
191
|
-
return resolvedSet;
|
|
192
|
-
}
|
|
193
|
-
// Manual detection fallback - use generated icons instead of logo.png
|
|
194
|
-
const fallbackIcon = this.assetExists('/icon-512x512.png')
|
|
195
|
-
? '/icon-512x512.png'
|
|
196
|
-
: this.assetExists('/icon-192x192.png')
|
|
197
|
-
? '/icon-192x192.png'
|
|
198
|
-
: '/logo.svg';
|
|
199
|
-
const faviconSet = {
|
|
200
|
-
svg: this.assetExists('/favicon.svg') ? '/favicon.svg' : '/logo.svg',
|
|
201
|
-
ico: this.assetExists('/favicon.ico') ? '/favicon.ico' : '/favicon.svg',
|
|
202
|
-
png16: this.assetExists('/favicon-16x16.png')
|
|
203
|
-
? '/favicon-16x16.png'
|
|
204
|
-
: fallbackIcon,
|
|
205
|
-
png32: this.assetExists('/favicon-32x32.png')
|
|
206
|
-
? '/favicon-32x32.png'
|
|
207
|
-
: fallbackIcon,
|
|
208
|
-
apple180: this.assetExists('/apple-touch-icon.png')
|
|
209
|
-
? '/apple-touch-icon.png'
|
|
210
|
-
: fallbackIcon,
|
|
211
|
-
android192: this.assetExists('/icon-192x192.png')
|
|
212
|
-
? '/icon-192x192.png'
|
|
213
|
-
: fallbackIcon,
|
|
214
|
-
android512: this.assetExists('/icon-512x512.png')
|
|
215
|
-
? '/icon-512x512.png'
|
|
216
|
-
: fallbackIcon,
|
|
217
|
-
};
|
|
218
|
-
this.cache.set(cacheKey, faviconSet);
|
|
219
|
-
return faviconSet;
|
|
220
|
-
}
|
|
221
|
-
/**
|
|
222
|
-
* Resolve optimal favicon for basic usage
|
|
223
|
-
*/
|
|
224
|
-
static resolveFavicon() {
|
|
225
|
-
const manifest = this.getAssetManifest();
|
|
226
|
-
if (manifest?.favicon?.optimal) {
|
|
227
|
-
return manifest.favicon.optimal;
|
|
228
|
-
}
|
|
229
|
-
// Format preference: SVG > ICO > PNG
|
|
230
|
-
const candidates = [
|
|
231
|
-
'/favicon.svg',
|
|
232
|
-
'/favicon.ico',
|
|
233
|
-
'/favicon.png',
|
|
234
|
-
'/logo.svg',
|
|
235
|
-
];
|
|
236
|
-
for (const candidate of candidates) {
|
|
237
|
-
if (this.assetExists(candidate)) {
|
|
238
|
-
return candidate;
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
return '/favicon.svg';
|
|
242
|
-
}
|
|
243
|
-
/**
|
|
244
|
-
* Clear asset resolution cache
|
|
245
|
-
* Useful when assets change during development
|
|
246
|
-
*/
|
|
247
|
-
static clearCache() {
|
|
248
|
-
this.cache.clear();
|
|
249
|
-
// In development, also clear any browser caches for immediate feedback
|
|
250
|
-
if (isDev() && isClient()) {
|
|
251
|
-
// Force re-evaluation on next resolution
|
|
252
|
-
}
|
|
253
|
-
}
|
|
254
|
-
/**
|
|
255
|
-
* Get debug information about detected assets
|
|
256
|
-
*/
|
|
257
|
-
static getDebugInfo() {
|
|
258
|
-
return {
|
|
259
|
-
browserSupport: this.getBrowserSupport(),
|
|
260
|
-
detectedAssets: isClient() ? getDndevConfig()?.assets?.mapping : null,
|
|
261
|
-
assetManifest: this.getAssetManifest(),
|
|
262
|
-
cache: Object.fromEntries(this.cache),
|
|
263
|
-
};
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
|
-
/**
|
|
267
|
-
* Utility function for logo resolution
|
|
268
|
-
*
|
|
269
|
-
* @version 0.1.0
|
|
270
|
-
* @since 0.0.1
|
|
271
|
-
* @author AMBROISE PARK Consulting
|
|
272
|
-
*/
|
|
273
|
-
export function resolveLogo(customPath) {
|
|
274
|
-
return AssetResolver.resolveLogo(customPath);
|
|
275
|
-
}
|
|
276
|
-
/**
|
|
277
|
-
* Utility function for favicon resolution
|
|
278
|
-
*
|
|
279
|
-
* @version 0.1.0
|
|
280
|
-
* @since 0.0.1
|
|
281
|
-
* @author AMBROISE PARK Consulting
|
|
282
|
-
*/
|
|
283
|
-
export function resolveFaviconSet() {
|
|
284
|
-
return AssetResolver.resolveFaviconSet();
|
|
285
|
-
}
|
|
286
|
-
// Initialize AssetResolver in development for immediate SVG preference
|
|
287
|
-
if (isDev()) {
|
|
288
|
-
// Clear any cached values to force fresh detection
|
|
289
|
-
AssetResolver.clearCache();
|
|
290
|
-
// Force immediate SVG preference detection
|
|
291
|
-
if (isClient()) {
|
|
292
|
-
window.addEventListener('DOMContentLoaded', () => {
|
|
293
|
-
AssetResolver.clearCache();
|
|
294
|
-
});
|
|
295
|
-
}
|
|
296
|
-
}
|
|
297
|
-
// Named export only (no default export needed)
|
|
1
|
+
"use client";var g=Object.defineProperty;var f=(n,t,e)=>t in n?g(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e;var c=(n,t,e)=>f(n,typeof t!="symbol"?t+"":t,e);import{getDndevConfig as r,isClient as i,isDev as l,resolveFaviconFiles as u}from"@donotdev/core";var a=class{static getBrowserSupport(){if(!i())return{svg:!0,webp:!1,avif:!1};let t=this.cache.get("browser-support");if(t)return t;let e={svg:!0,webp:!1,avif:!1};try{let s=document.createElement("canvas");s.width=1,s.height=1,e.webp=s.toDataURL("image/webp").indexOf("data:image/webp")===0}catch{e.webp=!1}try{let s=document.createElement("canvas");s.width=1,s.height=1,e.avif=s.toDataURL("image/avif").indexOf("data:image/avif")===0}catch{e.avif=!1}return this.cache.set("browser-support",e),e}static extractStringValues(t){let e=[];if(t==null)return e;if(typeof t=="string")e.push(t);else if(Array.isArray(t))for(let s of t)e.push(...this.extractStringValues(s));else if(typeof t=="object")for(let s of Object.values(t))e.push(...this.extractStringValues(s));return e}static assetExists(t){let e=this.getAssetManifest();return e?this.extractStringValues(e).includes(t):!1}static getAssetManifest(){return r()?.assets?.mapping||null}static getLogoSvgContent(){return r()?.assets?.logoSvgContent||null}static resolveLogo(t){if(t)return t;let e="logo";if(this.cache.has(e))return this.cache.get(e);let s=this.getAssetManifest(),o=s?.logo?.optimal||"/logo.svg";return s&&this.cache.set(e,o),o}static directAssetCheck(t){if(!i())return!1;try{let e=new Image;return e.src=t,!0}catch{return!1}}static resolveFaviconSet(){let t="favicon-set";if(this.cache.has(t))return this.cache.get(t);let e=u(s=>this.assetExists(s));return this.getAssetManifest()&&this.cache.set(t,e),e}static resolveFavicon(){let t=this.getAssetManifest();if(t?.favicon?.optimal)return t.favicon.optimal;let e=["/favicon.svg","/favicon.ico","/favicon.png","/logo.svg"];for(let s of e)if(this.assetExists(s))return s;return"/favicon.svg"}static clearCache(){this.cache.clear(),l()&&i()}static getDebugInfo(){return{browserSupport:this.getBrowserSupport(),detectedAssets:i()?r()?.assets?.mapping:null,assetManifest:this.getAssetManifest(),cache:Object.fromEntries(this.cache)}}};c(a,"cache",new Map);function p(n){return a.resolveLogo(n)}function d(){return a.resolveFaviconSet()}l()&&(a.clearCache(),i()&&window.addEventListener("DOMContentLoaded",()=>{a.clearCache()}));export{a as AssetResolver,d as resolveFaviconSet,p as resolveLogo};
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -16,7 +16,6 @@ export * from './useCrudSafe';
|
|
|
16
16
|
export * from './useOAuthSafe';
|
|
17
17
|
export * from './tList';
|
|
18
18
|
export * from './sanitizeSvg';
|
|
19
|
-
export * from './useSeo';
|
|
20
19
|
export { buildProductJsonLd, deriveEntitySeo } from '@donotdev/core';
|
|
21
20
|
export type { EntitySeo, EntitySeoRecord } from '@donotdev/core';
|
|
22
21
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AAEH,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,wBAAwB,CAAC;AACvC,cAAc,wBAAwB,CAAC;AAEvC,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,SAAS,CAAC;AACxB,cAAc,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AAEH,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,wBAAwB,CAAC;AACvC,cAAc,wBAAwB,CAAC;AAEvC,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,SAAS,CAAC;AACxB,cAAc,eAAe,CAAC;AAG9B,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACrE,YAAY,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC"}
|
package/dist/utils/index.js
CHANGED
|
@@ -1,23 +1 @@
|
|
|
1
|
-
|
|
2
|
-
/**
|
|
3
|
-
* @fileoverview UI Utilities Barrel Exports
|
|
4
|
-
* @description Barrel exports for UI utility functions. Provides centralized access to asset resolver and other UI utility functions.
|
|
5
|
-
*
|
|
6
|
-
* @version 0.1.0
|
|
7
|
-
* @since 0.0.1
|
|
8
|
-
* @author AMBROISE PARK Consulting
|
|
9
|
-
*/
|
|
10
|
-
export * from './assetResolver';
|
|
11
|
-
export * from './useAuthSafe';
|
|
12
|
-
export * from './useFormStoreSafe';
|
|
13
|
-
export * from './useAuthVisibility';
|
|
14
|
-
export * from './useStripeBillingSafe';
|
|
15
|
-
export * from './useBillingVisibility';
|
|
16
|
-
export * from './useCrudSafe';
|
|
17
|
-
export * from './useOAuthSafe';
|
|
18
|
-
export * from './tList';
|
|
19
|
-
export * from './sanitizeSvg';
|
|
20
|
-
export * from './useSeo';
|
|
21
|
-
// Entity-derived SEO lives in @donotdev/utils (server-safe: also used by the
|
|
22
|
-
// generated llms.txt route); re-exported here for existing imports.
|
|
23
|
-
export { buildProductJsonLd, deriveEntitySeo } from '@donotdev/core';
|
|
1
|
+
export*from"./assetResolver.js";export*from"./useAuthSafe.js";export*from"./useFormStoreSafe.js";export*from"./useAuthVisibility.js";export*from"./useStripeBillingSafe.js";export*from"./useBillingVisibility.js";export*from"./useCrudSafe.js";export*from"./useOAuthSafe.js";export*from"./tList.js";export*from"./sanitizeSvg.js";import{buildProductJsonLd as c,deriveEntitySeo as E}from"@donotdev/core";export{c as buildProductJsonLd,E as deriveEntitySeo};
|
|
@@ -1,51 +1 @@
|
|
|
1
|
-
|
|
2
|
-
/**
|
|
3
|
-
* @fileoverview Minimal SVG sanitizer
|
|
4
|
-
* @description Strips dangerous elements and attributes from SVG strings
|
|
5
|
-
* without requiring a third-party DOMPurify dependency.
|
|
6
|
-
*
|
|
7
|
-
* Removes:
|
|
8
|
-
* - `<script>` elements and their content
|
|
9
|
-
* - `<foreignObject>` elements (arbitrary HTML injection vector)
|
|
10
|
-
* - Event handler attributes (on*)
|
|
11
|
-
* - `href` / `xlink:href` values starting with `javascript:`
|
|
12
|
-
* - `data:` URIs in href attributes (except safe image types)
|
|
13
|
-
*
|
|
14
|
-
* @remarks
|
|
15
|
-
* This is intentionally a lightweight allowlist approach for SVG strings
|
|
16
|
-
* that originate from build-time assets (logo.svg) or internal static data
|
|
17
|
-
* (techLogos). For user-provided SVG content, use DOMPurify instead.
|
|
18
|
-
*
|
|
19
|
-
* @version 0.1.0
|
|
20
|
-
* @since 0.0.1
|
|
21
|
-
* @author AMBROISE PARK Consulting
|
|
22
|
-
*/
|
|
23
|
-
/** Regex patterns for known XSS vectors in SVG */
|
|
24
|
-
const SCRIPT_TAG_RE = /<script[\s\S]*?<\/script>/gi;
|
|
25
|
-
const FOREIGN_OBJECT_RE = /<foreignObject[\s\S]*?<\/foreignObject>/gi;
|
|
26
|
-
const EVENT_HANDLER_RE = /\s+on\w+\s*=\s*(?:"[^"]*"|'[^']*'|[^\s>]+)/gi;
|
|
27
|
-
const JAVASCRIPT_HREF_RE = /\s+(?:xlink:)?href\s*=\s*["']\s*javascript:[^"']*["']/gi;
|
|
28
|
-
const DATA_URI_HREF_RE = /\s+(?:xlink:)?href\s*=\s*["']\s*data:(?!image\/(?:png|jpe?g|gif|webp|svg\+xml))[^"']*["']/gi;
|
|
29
|
-
/**
|
|
30
|
-
* Strips known XSS vectors from an SVG string.
|
|
31
|
-
*
|
|
32
|
-
* @param svg - Raw SVG string (build-time or static source)
|
|
33
|
-
* @returns Sanitized SVG string safe for dangerouslySetInnerHTML
|
|
34
|
-
*
|
|
35
|
-
* @security This function uses regex-based sanitization suitable ONLY for build-time trusted SVGs.
|
|
36
|
-
* For user-uploaded or untrusted SVG content, use a dedicated sanitization library like DOMPurify.
|
|
37
|
-
* Regex-based sanitization is bypassable via mutation XSS, SVG event handlers, or entity encoding.
|
|
38
|
-
*
|
|
39
|
-
* @example
|
|
40
|
-
* ```tsx
|
|
41
|
-
* <div dangerouslySetInnerHTML={{ __html: sanitizeSvg(svgContent) }} />
|
|
42
|
-
* ```
|
|
43
|
-
*/
|
|
44
|
-
export function sanitizeSvg(svg) {
|
|
45
|
-
return svg
|
|
46
|
-
.replace(SCRIPT_TAG_RE, '')
|
|
47
|
-
.replace(FOREIGN_OBJECT_RE, '')
|
|
48
|
-
.replace(EVENT_HANDLER_RE, '')
|
|
49
|
-
.replace(JAVASCRIPT_HREF_RE, '')
|
|
50
|
-
.replace(DATA_URI_HREF_RE, '');
|
|
51
|
-
}
|
|
1
|
+
var e=/<script[\s\S]*?<\/script>/gi,i=/<foreignObject[\s\S]*?<\/foreignObject>/gi,n=/\s+on\w+\s*=\s*(?:"[^"]*"|'[^']*'|[^\s>]+)/gi,r=/\s+(?:xlink:)?href\s*=\s*["']\s*javascript:[^"']*["']/gi,t=/\s+(?:xlink:)?href\s*=\s*["']\s*data:(?!image\/(?:png|jpe?g|gif|webp|svg\+xml))[^"']*["']/gi;function c(s){return s.replace(e,"").replace(i,"").replace(n,"").replace(r,"").replace(t,"")}export{c as sanitizeSvg};
|
package/dist/utils/tList.js
CHANGED
|
@@ -1,42 +1 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { CheckCircle } from 'lucide-react';
|
|
3
|
-
import { List } from '@donotdev/components';
|
|
4
|
-
import { translateArray } from '@donotdev/core';
|
|
5
|
-
/**
|
|
6
|
-
* Framework default icon for list items
|
|
7
|
-
*/
|
|
8
|
-
const DEFAULT_ICON = CheckCircle;
|
|
9
|
-
/**
|
|
10
|
-
* Framework default icon size (matches --icon-sm)
|
|
11
|
-
*/
|
|
12
|
-
const DEFAULT_SIZE = 16;
|
|
13
|
-
/**
|
|
14
|
-
* Renders a translated array as a List with optional icon
|
|
15
|
-
*
|
|
16
|
-
* Opinionated helper that reduces boilerplate for the common pattern:
|
|
17
|
-
* `<List icon={<CheckCircle size={16} />} items={translateArray(t, key, count)} />`
|
|
18
|
-
*
|
|
19
|
-
* @param t - Translation function from useTranslation
|
|
20
|
-
* @param key - Translation key prefix for the array
|
|
21
|
-
* @param count - Maximum number of items to fetch
|
|
22
|
-
* @param icon - Lucide icon, null for no icon, or undefined for default (CheckCircle)
|
|
23
|
-
* @param size - Optional icon size (default: 16)
|
|
24
|
-
* @returns ReactNode containing the List component
|
|
25
|
-
*
|
|
26
|
-
* @example
|
|
27
|
-
* ```tsx
|
|
28
|
-
* // With default icon (CheckCircle)
|
|
29
|
-
* <Card content={tList(t, 'features.items', 4)} />
|
|
30
|
-
*
|
|
31
|
-
* // With custom icon
|
|
32
|
-
* <Card content={tList(t, 'features.items', 4, Star)} />
|
|
33
|
-
*
|
|
34
|
-
* // Without icon (for emoji-prefixed labels like "🚀 Kick-off")
|
|
35
|
-
* <Card content={tList(t, 'features.items', 4, null)} />
|
|
36
|
-
* ```
|
|
37
|
-
*/
|
|
38
|
-
export function tList(t, key, count, icon = DEFAULT_ICON, size = DEFAULT_SIZE) {
|
|
39
|
-
const Icon = icon;
|
|
40
|
-
const iconElement = Icon ? _jsx(Icon, { size: size }) : undefined;
|
|
41
|
-
return (_jsx(List, { icon: iconElement, items: translateArray(t, key, count), style: { listStyle: 'none', paddingInlineStart: 0 } }));
|
|
42
|
-
}
|
|
1
|
+
import{CheckCircle as m}from"lucide-react";import{List as l}from"@donotdev/components";import{translateArray as p}from"@donotdev/core";import{jsx as n}from"react/jsx-runtime";var s=m,u=16;function I(e,o,i,r=s,c=u){let t=r;return n(l,{icon:t?n(t,{size:c}):void 0,items:p(e,o,i),style:{listStyle:"none",paddingInlineStart:0}})}export{I as tList};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useAISafe.d.ts","sourceRoot":"","sources":["../../src/utils/useAISafe.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useAISafe.d.ts","sourceRoot":"","sources":["../../src/utils/useAISafe.ts"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAI5C,YAAY,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAehD;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,SAAS,CAAC,CAAC,SAAS,MAAM,KAAK,EAC7C,GAAG,EAAE,CAAC,EACN,SAAS,CAAC,EAAE,WAAW,GACtB,KAAK,CAAC,CAAC,CAAC,CAKV;AAED;;GAEG;AACH,eAAO,MAAM,aAAa,SAAkC,CAAC"}
|
package/dist/utils/useAISafe.js
CHANGED
|
@@ -1,53 +1 @@
|
|
|
1
|
-
|
|
2
|
-
/**
|
|
3
|
-
* @fileoverview Safe useAI wrapper for graceful degradation
|
|
4
|
-
* @description Provides AI functionality when @donotdev/ai is installed,
|
|
5
|
-
* gracefully degrades to no-op when not installed.
|
|
6
|
-
*
|
|
7
|
-
* ## CRITICAL: DO NOT USE DYNAMIC IMPORTS
|
|
8
|
-
* @see useStripeBillingSafe.ts for full explanation of why sync imports are required.
|
|
9
|
-
*
|
|
10
|
-
* @version 0.1.0
|
|
11
|
-
* @since 0.1.0
|
|
12
|
-
* @author AMBROISE PARK Consulting
|
|
13
|
-
*/
|
|
14
|
-
import * as aiModule from '@donotdev/ai';
|
|
15
|
-
import { DEGRADED_AI_API } from '@donotdev/core';
|
|
16
|
-
// Check if real hook exists (will be undefined if Vite aliased to empty module)
|
|
17
|
-
const realUseAI = aiModule?.useAI;
|
|
18
|
-
/**
|
|
19
|
-
* Stub that returns degraded AI values.
|
|
20
|
-
* Used when @donotdev/ai is not installed.
|
|
21
|
-
*/
|
|
22
|
-
function useAIStub(key) {
|
|
23
|
-
return DEGRADED_AI_API[key];
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* Safe wrapper for useAI hook.
|
|
27
|
-
*
|
|
28
|
-
* - If @donotdev/ai installed -> uses real hook
|
|
29
|
-
* - If not installed -> returns degraded API values
|
|
30
|
-
*
|
|
31
|
-
* @param key - Property name to access from AI API
|
|
32
|
-
* @param authState - Auth state from useAIAuth or useAuthSafe
|
|
33
|
-
* @returns The AI API value, or degraded value if AI unavailable
|
|
34
|
-
*
|
|
35
|
-
* @example
|
|
36
|
-
* ```typescript
|
|
37
|
-
* const authState = useAIAuth();
|
|
38
|
-
* const append = useAISafe('append', authState);
|
|
39
|
-
* const messages = useAISafe('messages', authState);
|
|
40
|
-
* const isLoading = useAISafe('isLoading', authState);
|
|
41
|
-
* const cost = useAISafe('cost', authState);
|
|
42
|
-
* ```
|
|
43
|
-
*/
|
|
44
|
-
export function useAISafe(key, authState) {
|
|
45
|
-
if (realUseAI) {
|
|
46
|
-
return realUseAI(key, authState);
|
|
47
|
-
}
|
|
48
|
-
return useAIStub(key);
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* Check if AI module is available (for conditional UI rendering)
|
|
52
|
-
*/
|
|
53
|
-
export const isAIAvailable = typeof realUseAI === 'function';
|
|
1
|
+
"use client";import*as o from"@donotdev/ai";import{DEGRADED_AI_API as I}from"@donotdev/core";var e=o?.useAI;function n(t){return I[t]}function u(t,A){return e?e(t,A):n(t)}var f=typeof e=="function";export{f as isAIAvailable,u as useAISafe};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useAuthSafe.d.ts","sourceRoot":"","sources":["../../src/utils/useAuthSafe.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useAuthSafe.d.ts","sourceRoot":"","sources":["../../src/utils/useAuthSafe.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AAEH,OAAO,KAAK,UAAU,MAAM,gBAAgB,CAAC;AAC7C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAmB9C;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,WAAW,CAAC,CAAC,SAAS,MAAM,OAAO,EAAE,GAAG,EAAE,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAKvE;AAED;;GAEG;AACH,eAAO,MAAM,eAAe,SAAoC,CAAC;AAEjE;;;GAGG;AACH,eAAO,MAAM,qBAAqB,yCACiB,CAAC"}
|
|
@@ -1,78 +1 @@
|
|
|
1
|
-
|
|
2
|
-
/**
|
|
3
|
-
* @fileoverview Safe useAuth wrapper for graceful degradation
|
|
4
|
-
* @description Provides auth functionality when @donotdev/auth is installed,
|
|
5
|
-
* gracefully degrades to no-op when not installed.
|
|
6
|
-
*
|
|
7
|
-
* ## CRITICAL: DO NOT USE DYNAMIC IMPORTS
|
|
8
|
-
*
|
|
9
|
-
* This file MUST use sync `import * as authModule from '@donotdev/auth'`
|
|
10
|
-
* at module level. DO NOT refactor to use async `import('@donotdev/auth').then(...)`.
|
|
11
|
-
*
|
|
12
|
-
* ### Why sync import is required:
|
|
13
|
-
*
|
|
14
|
-
* 1. **Bundler aliasing**: Vite/webpack alias missing packages to empty modules
|
|
15
|
-
* at BUILD TIME. The import completes immediately (no async).
|
|
16
|
-
*
|
|
17
|
-
* 2. **Rules of Hooks**: If we use async dynamic import:
|
|
18
|
-
* - First render: `realUseAuth = null` → uses stub (0 hooks)
|
|
19
|
-
* - Async completes: `realUseAuth = useAuth` → now has hooks
|
|
20
|
-
* - Next render: React sees different hook count → CRASH
|
|
21
|
-
*
|
|
22
|
-
* 3. **Monorepo gotcha**: Dynamic imports resolve workspace packages even when
|
|
23
|
-
* the consuming app doesn't have them as dependencies. This causes the
|
|
24
|
-
* real hook to activate unexpectedly → Rules of Hooks violation.
|
|
25
|
-
*
|
|
26
|
-
* 4. **Decision is immutable**: With sync import, `authModule?.useAuth` is
|
|
27
|
-
* evaluated ONCE at module load. It's either the real hook or undefined.
|
|
28
|
-
* This never changes during the app lifecycle.
|
|
29
|
-
*
|
|
30
|
-
* @see docs/development/GRACEFUL_DEGRADATION.md
|
|
31
|
-
* @version 0.1.0
|
|
32
|
-
* @since 0.0.1
|
|
33
|
-
* @author AMBROISE PARK Consulting
|
|
34
|
-
*/
|
|
35
|
-
import * as authModule from '@donotdev/auth';
|
|
36
|
-
import { DEGRADED_AUTH_API } from '@donotdev/core';
|
|
37
|
-
// Sync import - bundler aliases to empty module if not installed
|
|
38
|
-
// Decision made ONCE at module load time, never changes
|
|
39
|
-
// Extract useAuth if available (undefined if package not installed/aliased)
|
|
40
|
-
const realUseAuth = authModule?.useAuth;
|
|
41
|
-
/**
|
|
42
|
-
* Stub that returns degraded auth values.
|
|
43
|
-
* Used when @donotdev/auth is not installed.
|
|
44
|
-
*/
|
|
45
|
-
function useAuthStub(key) {
|
|
46
|
-
return DEGRADED_AUTH_API[key];
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* Safe wrapper for useAuth hook.
|
|
50
|
-
*
|
|
51
|
-
* - If @donotdev/auth installed → uses real hook (handles Firebase/consent internally)
|
|
52
|
-
* - If not installed → returns degraded API values
|
|
53
|
-
*
|
|
54
|
-
* @param key - Property name to access from auth API
|
|
55
|
-
* @returns The auth API value, or degraded value if auth unavailable
|
|
56
|
-
*
|
|
57
|
-
* @example
|
|
58
|
-
* ```typescript
|
|
59
|
-
* const user = useAuthSafe('user');
|
|
60
|
-
* const signIn = useAuthSafe('signInWithEmail');
|
|
61
|
-
* const isAvailable = useAuthSafe('isAvailable');
|
|
62
|
-
* ```
|
|
63
|
-
*/
|
|
64
|
-
export function useAuthSafe(key) {
|
|
65
|
-
if (realUseAuth) {
|
|
66
|
-
return realUseAuth(key);
|
|
67
|
-
}
|
|
68
|
-
return useAuthStub(key);
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* Check if auth module is available (for conditional UI rendering)
|
|
72
|
-
*/
|
|
73
|
-
export const isAuthAvailable = typeof realUseAuth === 'function';
|
|
74
|
-
/**
|
|
75
|
-
* PasswordResetCallback - auto-overlay for password reset flow.
|
|
76
|
-
* Renders nothing if @donotdev/auth not installed or no reset in progress.
|
|
77
|
-
*/
|
|
78
|
-
export const PasswordResetCallback = authModule?.PasswordResetCallback ?? (() => null);
|
|
1
|
+
"use client";import*as u from"@donotdev/auth";import{DEGRADED_AUTH_API as o}from"@donotdev/core";var e=u?.useAuth;function A(t){return o[t]}function r(t){return e?e(t):A(t)}var s=typeof e=="function",f=u?.PasswordResetCallback??(()=>null);export{f as PasswordResetCallback,s as isAuthAvailable,r as useAuthSafe};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useAuthVisibility.d.ts","sourceRoot":"","sources":["../../src/utils/useAuthVisibility.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useAuthVisibility.d.ts","sourceRoot":"","sources":["../../src/utils/useAuthVisibility.ts"],"names":[],"mappings":"AAqBA,kDAAkD;AAClD,MAAM,WAAW,mBAAmB;IAClC;;OAEG;IACH,UAAU,EAAE,OAAO,CAAC;IAEpB;;OAEG;IACH,SAAS,EAAE,OAAO,CAAC;IAEnB;;OAEG;IACH,OAAO,EAAE,OAAO,CAAC;IAEjB;;OAEG;IACH,eAAe,EAAE,OAAO,CAAC;CAC1B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,iBAAiB,IAAI,mBAAmB,CAqBvD"}
|
|
@@ -1,63 +1 @@
|
|
|
1
|
-
|
|
2
|
-
/**
|
|
3
|
-
* @fileoverview useAuthVisibility Hook
|
|
4
|
-
* @description Determines when to show/hide auth UI based on feature status
|
|
5
|
-
*
|
|
6
|
-
* This hook encapsulates the common pattern for auth UI visibility:
|
|
7
|
-
* - Hide if status !== 'ready' or not available (not ready yet)
|
|
8
|
-
* - Show with loading state during initialization
|
|
9
|
-
* - Show normal UI when status === 'ready'
|
|
10
|
-
*
|
|
11
|
-
* @version 0.1.0
|
|
12
|
-
* @since 0.0.1
|
|
13
|
-
* @author AMBROISE PARK Consulting
|
|
14
|
-
*/
|
|
15
|
-
import { useMemo } from 'react';
|
|
16
|
-
import { useAuthSafe } from './useAuthSafe';
|
|
17
|
-
/**
|
|
18
|
-
* Hook to determine auth UI visibility and loading states
|
|
19
|
-
*
|
|
20
|
-
* **Visibility Rules:**
|
|
21
|
-
* - Hide if `status !== 'ready' || !isAvailable` (not ready or not installed)
|
|
22
|
-
* - Show with loading if `status === 'initializing'` during operations
|
|
23
|
-
* - Show normal UI when `status === 'ready' && isAvailable`
|
|
24
|
-
*
|
|
25
|
-
* @returns AuthVisibilityState with visibility flags
|
|
26
|
-
*
|
|
27
|
-
* @example
|
|
28
|
-
* ```typescript
|
|
29
|
-
* const { shouldHide, isLoading, isReady, isAuthenticated } = useAuthVisibility();
|
|
30
|
-
*
|
|
31
|
-
* if (shouldHide) return null;
|
|
32
|
-
*
|
|
33
|
-
* if (isLoading) {
|
|
34
|
-
* return <Button disabled><Spinner /></Button>;
|
|
35
|
-
* }
|
|
36
|
-
*
|
|
37
|
-
* if (isAuthenticated) {
|
|
38
|
-
* return <UserMenu />;
|
|
39
|
-
* }
|
|
40
|
-
*
|
|
41
|
-
* return <SignInButton />;
|
|
42
|
-
* ```
|
|
43
|
-
*/
|
|
44
|
-
export function useAuthVisibility() {
|
|
45
|
-
// Read all values first - each triggers subscription
|
|
46
|
-
const status = useAuthSafe('status');
|
|
47
|
-
const isAvailable = useAuthSafe('isAvailable');
|
|
48
|
-
const user = useAuthSafe('user');
|
|
49
|
-
// Derive all visibility state atomically from current values
|
|
50
|
-
// useMemo ensures consistent state within a single render
|
|
51
|
-
return useMemo(() => {
|
|
52
|
-
const shouldHide = status !== 'ready' || !isAvailable;
|
|
53
|
-
const isLoading = status === 'initializing';
|
|
54
|
-
const isReady = status === 'ready' && isAvailable;
|
|
55
|
-
const isAuthenticated = Boolean(user);
|
|
56
|
-
return {
|
|
57
|
-
shouldHide,
|
|
58
|
-
isLoading,
|
|
59
|
-
isReady,
|
|
60
|
-
isAuthenticated,
|
|
61
|
-
};
|
|
62
|
-
}, [status, isAvailable, user]);
|
|
63
|
-
}
|
|
1
|
+
"use client";import{useMemo as o}from"react";import{useAuthSafe as e}from"./useAuthSafe.js";function c(){let i=e("status"),t=e("isAvailable"),s=e("user");return o(()=>({shouldHide:i!=="ready"||!t,isLoading:i==="initializing",isReady:i==="ready"&&t,isAuthenticated:!!s}),[i,t,s])}export{c as useAuthVisibility};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useBillingVisibility.d.ts","sourceRoot":"","sources":["../../src/utils/useBillingVisibility.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useBillingVisibility.d.ts","sourceRoot":"","sources":["../../src/utils/useBillingVisibility.ts"],"names":[],"mappings":"AAoBA,qDAAqD;AACrD,MAAM,WAAW,sBAAsB;IACrC;;OAEG;IACH,UAAU,EAAE,OAAO,CAAC;IAEpB;;OAEG;IACH,SAAS,EAAE,OAAO,CAAC;IAEnB;;OAEG;IACH,OAAO,EAAE,OAAO,CAAC;CAClB;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,oBAAoB,IAAI,sBAAsB,CAkB7D"}
|