@donotdev/ui 0.3.0 → 0.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (301) hide show
  1. package/dist/components/auth/AuthHeader.js +1 -93
  2. package/dist/components/auth/AuthMenu.d.ts.map +1 -1
  3. package/dist/components/auth/AuthMenu.js +3 -286
  4. package/dist/components/auth/index.js +1 -9
  5. package/dist/components/common/FeatureCard.d.ts.map +1 -1
  6. package/dist/components/common/FeatureCard.js +1 -86
  7. package/dist/components/common/FeatureDisabled.js +1 -67
  8. package/dist/components/common/IconPlaceholder.d.ts +24 -0
  9. package/dist/components/common/IconPlaceholder.d.ts.map +1 -0
  10. package/dist/components/common/IconPlaceholder.js +1 -0
  11. package/dist/components/common/LazyLucideIcon.d.ts +39 -0
  12. package/dist/components/common/LazyLucideIcon.d.ts.map +1 -0
  13. package/dist/components/common/LazyLucideIcon.js +1 -0
  14. package/dist/components/common/ProgressBar.js +1 -84
  15. package/dist/components/common/RedirectOverlay.js +1 -243
  16. package/dist/components/common/Skeleton.js +1 -144
  17. package/dist/components/common/TechBento.d.ts.map +1 -1
  18. package/dist/components/common/TechBento.js +1 -53
  19. package/dist/components/common/icon.d.ts +1 -1
  20. package/dist/components/common/icon.d.ts.map +1 -1
  21. package/dist/components/common/icon.js +1 -84
  22. package/dist/components/common/iconByName.d.ts +33 -0
  23. package/dist/components/common/iconByName.d.ts.map +1 -0
  24. package/dist/components/common/iconByName.js +1 -0
  25. package/dist/components/common/index.js +1 -16
  26. package/dist/components/cookie-consent/ConsentBanner.d.ts +3 -1
  27. package/dist/components/cookie-consent/ConsentBanner.d.ts.map +1 -1
  28. package/dist/components/cookie-consent/ConsentBanner.js +1 -31
  29. package/dist/components/cookie-consent/CookieConsent.d.ts.map +1 -1
  30. package/dist/components/cookie-consent/CookieConsent.js +1 -183
  31. package/dist/components/cookie-consent/index.js +1 -11
  32. package/dist/components/cookie-consent/useCookieNoticeRequired.d.ts +7 -0
  33. package/dist/components/cookie-consent/useCookieNoticeRequired.d.ts.map +1 -0
  34. package/dist/components/cookie-consent/useCookieNoticeRequired.js +1 -0
  35. package/dist/components/index.js +1 -13
  36. package/dist/components/layout/GameContainer.d.ts.map +1 -1
  37. package/dist/components/layout/GameContainer.js +1 -72
  38. package/dist/components/layout/GameFlow.d.ts.map +1 -1
  39. package/dist/components/layout/GameFlow.js +1 -93
  40. package/dist/components/layout/PageConfig.d.ts.map +1 -1
  41. package/dist/components/layout/PageConfig.js +1 -47
  42. package/dist/components/layout/PageContainer.d.ts.map +1 -1
  43. package/dist/components/layout/PageContainer.js +1 -38
  44. package/dist/components/layout/components/Breadcrumbs.d.ts +2 -1
  45. package/dist/components/layout/components/Breadcrumbs.d.ts.map +1 -1
  46. package/dist/components/layout/components/Breadcrumbs.js +1 -89
  47. package/dist/components/layout/components/DropdownNavigation.d.ts.map +1 -1
  48. package/dist/components/layout/components/DropdownNavigation.js +1 -30
  49. package/dist/components/layout/components/FloatingLanguageSwitcher.d.ts.map +1 -1
  50. package/dist/components/layout/components/FloatingLanguageSwitcher.js +1 -26
  51. package/dist/components/layout/components/Notifications.js +1 -182
  52. package/dist/components/layout/components/header/AppBranding.d.ts.map +1 -1
  53. package/dist/components/layout/components/header/AppBranding.js +1 -54
  54. package/dist/components/layout/components/header/AppIcon.d.ts.map +1 -1
  55. package/dist/components/layout/components/header/AppIcon.js +1 -59
  56. package/dist/components/layout/components/header/AppTitle.d.ts.map +1 -1
  57. package/dist/components/layout/components/header/AppTitle.js +1 -40
  58. package/dist/components/layout/components/header/CacheSettings.js +1 -225
  59. package/dist/components/layout/components/header/GameTitle.d.ts.map +1 -1
  60. package/dist/components/layout/components/header/GameTitle.js +1 -66
  61. package/dist/components/layout/components/header/HeaderMenu.d.ts +17 -16
  62. package/dist/components/layout/components/header/HeaderMenu.d.ts.map +1 -1
  63. package/dist/components/layout/components/header/HeaderMenu.js +1 -47
  64. package/dist/components/layout/components/header/HeaderNavigation.d.ts.map +1 -1
  65. package/dist/components/layout/components/header/HeaderNavigation.js +1 -66
  66. package/dist/components/layout/components/header/SettingsMenu.d.ts.map +1 -1
  67. package/dist/components/layout/components/header/SettingsMenu.js +1 -85
  68. package/dist/components/layout/components/header/ThemeToggle.d.ts.map +1 -1
  69. package/dist/components/layout/components/header/ThemeToggle.js +1 -93
  70. package/dist/components/layout/components/index.js +1 -25
  71. package/dist/components/layout/index.js +1 -14
  72. package/dist/crud/components/ChildRowsPicker.js +1 -68
  73. package/dist/crud/components/CrudCardLink.js +1 -14
  74. package/dist/crud/components/EntityCardList.js +1 -184
  75. package/dist/crud/components/EntityDisplayRenderer.js +1 -130
  76. package/dist/crud/components/EntityFormRenderer.js +1 -433
  77. package/dist/crud/components/EntityList.js +1 -521
  78. package/dist/crud/components/EntityRecommendations.js +1 -87
  79. package/dist/crud/components/EntityWorkflow.js +1 -55
  80. package/dist/crud/components/Form.d.ts.map +1 -1
  81. package/dist/crud/components/Form.js +1 -198
  82. package/dist/crud/components/cellEditFor.js +1 -74
  83. package/dist/crud/components/entityParent.js +1 -76
  84. package/dist/crud/components/index.js +1 -16
  85. package/dist/crud/components/useRecordBreadcrumb.d.ts.map +1 -1
  86. package/dist/crud/components/useRecordBreadcrumb.js +1 -43
  87. package/dist/crud/crudImports.js +1 -51
  88. package/dist/crud/index.js +1 -11
  89. package/dist/data/techLogos.js +1 -99
  90. package/dist/dndev-next.css +104 -17
  91. package/dist/dndev.css +104 -17
  92. package/dist/index.js +1 -5
  93. package/dist/internal/common/DnDevErrorBoundary.js +1 -55
  94. package/dist/internal/common/ErrorFallback.js +3 -214
  95. package/dist/internal/common/GlobalErrorFallback.js +1 -45
  96. package/dist/internal/common/RouteErrorFallback.js +3 -140
  97. package/dist/internal/devtools/DebugTools.js +1 -131
  98. package/dist/internal/devtools/components/AuthDebugButton.js +1 -72
  99. package/dist/internal/devtools/components/ConfigTab.js +1 -61
  100. package/dist/internal/devtools/components/CookieTab.js +1 -156
  101. package/dist/internal/devtools/components/DebugDialog.js +1 -48
  102. package/dist/internal/devtools/components/DesignTab.js +1 -469
  103. package/dist/internal/devtools/components/LayoutReset.js +1 -214
  104. package/dist/internal/devtools/components/MaskedValue.js +1 -39
  105. package/dist/internal/devtools/components/StoresTab.js +1 -90
  106. package/dist/internal/devtools/components/index.js +1 -16
  107. package/dist/internal/devtools/index.js +1 -13
  108. package/dist/internal/devtools/types.js +0 -2
  109. package/dist/internal/devtools/utils/envVarDiscovery.js +1 -106
  110. package/dist/internal/devtools/utils/index.js +1 -12
  111. package/dist/internal/devtools/utils/maskSensitive.js +1 -59
  112. package/dist/internal/devtools/utils/virtualModuleInspector.js +1 -309
  113. package/dist/internal/initializers/BaseStoresInitializer.js +1 -367
  114. package/dist/internal/initializers/NextJsStoresInitializer.js +1 -78
  115. package/dist/internal/initializers/ViteStoresInitializer.js +1 -20
  116. package/dist/internal/initializers/index.js +1 -11
  117. package/dist/internal/layout/DnDevLayout.js +1 -321
  118. package/dist/internal/layout/components/AutoMetaTags.d.ts +2 -0
  119. package/dist/internal/layout/components/AutoMetaTags.d.ts.map +1 -1
  120. package/dist/internal/layout/components/AutoMetaTags.js +1 -338
  121. package/dist/internal/layout/components/FaviconHead.js +1 -60
  122. package/dist/internal/layout/components/FontPreloadLinks.js +1 -31
  123. package/dist/internal/layout/components/HeadTags.js +1 -20
  124. package/dist/internal/layout/components/PWAUpdateNotification.js +1 -131
  125. package/dist/internal/layout/components/footer/FooterBranding.d.ts.map +1 -1
  126. package/dist/internal/layout/components/footer/FooterBranding.js +1 -35
  127. package/dist/internal/layout/components/footer/FooterCopyright.d.ts.map +1 -1
  128. package/dist/internal/layout/components/footer/FooterCopyright.js +1 -37
  129. package/dist/internal/layout/components/footer/FooterLegalLinks.d.ts.map +1 -1
  130. package/dist/internal/layout/components/footer/FooterLegalLinks.js +1 -44
  131. package/dist/internal/layout/components/footer/useLegalLinks.d.ts +4 -2
  132. package/dist/internal/layout/components/footer/useLegalLinks.d.ts.map +1 -1
  133. package/dist/internal/layout/components/footer/useLegalLinks.js +1 -21
  134. package/dist/internal/layout/components/i18nSeoMeta.js +1 -53
  135. package/dist/internal/layout/components/index.js +1 -13
  136. package/dist/internal/layout/config/defaults.js +1 -47
  137. package/dist/internal/layout/config/index.js +1 -11
  138. package/dist/internal/layout/config/presets/admin.js +1 -35
  139. package/dist/internal/layout/config/presets/blog.js +1 -31
  140. package/dist/internal/layout/config/presets/docs.js +1 -51
  141. package/dist/internal/layout/config/presets/game.js +1 -53
  142. package/dist/internal/layout/config/presets/index.js +1 -24
  143. package/dist/internal/layout/config/presets/landing.js +1 -42
  144. package/dist/internal/layout/config/presets/moolti.js +1 -52
  145. package/dist/internal/layout/config/presets/plain.js +1 -25
  146. package/dist/internal/layout/renderers/index.js +0 -10
  147. package/dist/internal/layout/zones/DnDevFooter.d.ts.map +1 -1
  148. package/dist/internal/layout/zones/DnDevFooter.js +1 -67
  149. package/dist/internal/layout/zones/DnDevHeader.js +1 -41
  150. package/dist/internal/layout/zones/DnDevMergedBar.d.ts.map +1 -1
  151. package/dist/internal/layout/zones/DnDevMergedBar.js +1 -52
  152. package/dist/internal/layout/zones/DnDevSidebar.d.ts.map +1 -1
  153. package/dist/internal/layout/zones/DnDevSidebar.js +1 -181
  154. package/dist/internal/layout/zones/index.js +1 -14
  155. package/dist/internal/providers/NavigationProvider.d.ts.map +1 -1
  156. package/dist/internal/providers/NavigationProvider.js +1 -71
  157. package/dist/internal/providers/SentryInitializer.d.ts.map +1 -1
  158. package/dist/internal/providers/SentryInitializer.js +1 -36
  159. package/dist/internal/providers/UIProviders.js +1 -79
  160. package/dist/internal/providers/index.js +1 -12
  161. package/dist/next.js +1 -11
  162. package/dist/providers/NextJsAppProviders.d.ts.map +1 -1
  163. package/dist/providers/NextJsAppProviders.js +1 -107
  164. package/dist/providers/ViteAppProviders.d.ts.map +1 -1
  165. package/dist/providers/ViteAppProviders.js +1 -117
  166. package/dist/providers/index.js +1 -11
  167. package/dist/routing/404.js +1 -108
  168. package/dist/routing/AuthGuard.js +1 -178
  169. package/dist/routing/AuthGuardFallback.d.ts.map +1 -1
  170. package/dist/routing/AuthGuardFallback.js +1 -67
  171. package/dist/routing/AuthReturnTo.js +1 -68
  172. package/dist/routing/DnDevNavigationMenu.d.ts.map +1 -1
  173. package/dist/routing/DnDevNavigationMenu.js +1 -138
  174. package/dist/routing/GoTo.d.ts.map +1 -1
  175. package/dist/routing/GoTo.js +1 -38
  176. package/dist/routing/GoToDialog.d.ts.map +1 -1
  177. package/dist/routing/GoToDialog.js +1 -97
  178. package/dist/routing/GoToInput.d.ts.map +1 -1
  179. package/dist/routing/GoToInput.js +1 -49
  180. package/dist/routing/GoToWrapper.d.ts.map +1 -1
  181. package/dist/routing/GoToWrapper.js +1 -59
  182. package/dist/routing/Link.d.ts +10 -2
  183. package/dist/routing/Link.d.ts.map +1 -1
  184. package/dist/routing/Link.js +1 -109
  185. package/dist/routing/NavigationItem.d.ts.map +1 -1
  186. package/dist/routing/NavigationItem.js +1 -44
  187. package/dist/routing/NotFoundDocument.d.ts +33 -0
  188. package/dist/routing/NotFoundDocument.d.ts.map +1 -0
  189. package/dist/routing/NotFoundDocument.js +1 -0
  190. package/dist/routing/SignedInRedirect.js +1 -47
  191. package/dist/routing/hooks/hooks.vite.js +1 -1
  192. package/dist/routing/hooks/index.js +1 -26
  193. package/dist/routing/hooks/types.js +0 -2
  194. package/dist/routing/hooks/useLocation.next.js +1 -35
  195. package/dist/routing/hooks/useLocation.vite.js +1 -13
  196. package/dist/routing/hooks/useMatch.next.js +1 -31
  197. package/dist/routing/hooks/useMatch.vite.js +1 -6
  198. package/dist/routing/hooks/useNavigate.next.js +1 -64
  199. package/dist/routing/hooks/useNavigate.vite.js +1 -61
  200. package/dist/routing/hooks/useParams.next.js +1 -9
  201. package/dist/routing/hooks/useParams.vite.js +1 -6
  202. package/dist/routing/hooks/useQueryParams.next.js +1 -66
  203. package/dist/routing/hooks/useQueryParams.vite.js +1 -66
  204. package/dist/routing/hooks/useRedirectGuard.next.js +1 -119
  205. package/dist/routing/hooks/useRedirectGuard.vite.js +1 -117
  206. package/dist/routing/hooks/useRouteParam.next.js +1 -38
  207. package/dist/routing/hooks/useRouteParam.vite.js +1 -38
  208. package/dist/routing/hooks/useRoutePath.next.js +1 -36
  209. package/dist/routing/hooks/useRoutePath.vite.js +1 -25
  210. package/dist/routing/hooks/useSearchParams.next.js +1 -22
  211. package/dist/routing/hooks/useSearchParams.vite.js +1 -22
  212. package/dist/routing/hooks/useUrlLanguage.next.js +1 -50
  213. package/dist/routing/hooks/useUrlLanguage.vite.js +1 -41
  214. package/dist/routing/index.d.ts +1 -0
  215. package/dist/routing/index.d.ts.map +1 -1
  216. package/dist/routing/index.js +1 -32
  217. package/dist/routing/link/InternalLink.next.d.ts +23 -0
  218. package/dist/routing/link/InternalLink.next.d.ts.map +1 -0
  219. package/dist/routing/link/InternalLink.next.js +1 -0
  220. package/dist/routing/link/InternalLink.vite.d.ts +22 -0
  221. package/dist/routing/link/InternalLink.vite.d.ts.map +1 -0
  222. package/dist/routing/link/InternalLink.vite.js +1 -0
  223. package/dist/routing/link/absolutePath.d.ts +17 -0
  224. package/dist/routing/link/absolutePath.d.ts.map +1 -0
  225. package/dist/routing/link/absolutePath.js +1 -0
  226. package/dist/routing/link/link.next.d.ts +12 -0
  227. package/dist/routing/link/link.next.d.ts.map +1 -0
  228. package/dist/routing/link/link.next.js +1 -0
  229. package/dist/routing/link/link.vite.d.ts +12 -0
  230. package/dist/routing/link/link.vite.d.ts.map +1 -0
  231. package/dist/routing/link/link.vite.js +1 -0
  232. package/dist/routing/link/types.d.ts +30 -0
  233. package/dist/routing/link/types.d.ts.map +1 -0
  234. package/dist/routing/link/types.js +0 -0
  235. package/dist/routing/parentRoute.js +1 -43
  236. package/dist/routing/useGoTo.d.ts.map +1 -1
  237. package/dist/routing/useGoTo.js +1 -59
  238. package/dist/routing/useNavigation.d.ts.map +1 -1
  239. package/dist/routing/useNavigation.js +1 -114
  240. package/dist/routing/useRouteDiscovery.d.ts +1 -0
  241. package/dist/routing/useRouteDiscovery.d.ts.map +1 -1
  242. package/dist/routing/useRouteDiscovery.js +1 -313
  243. package/dist/rsc.d.ts +28 -0
  244. package/dist/rsc.d.ts.map +1 -0
  245. package/dist/rsc.js +1 -0
  246. package/dist/styles/index.css +104 -17
  247. package/dist/styles/index.js +1 -10
  248. package/dist/styles/layoutConstants.js +1 -134
  249. package/dist/symbol-index.json +1 -1
  250. package/dist/utils/assetResolver.d.ts.map +1 -1
  251. package/dist/utils/assetResolver.js +1 -297
  252. package/dist/utils/index.js +1 -23
  253. package/dist/utils/sanitizeSvg.js +1 -51
  254. package/dist/utils/tList.js +1 -42
  255. package/dist/utils/useAISafe.d.ts.map +1 -1
  256. package/dist/utils/useAISafe.js +1 -53
  257. package/dist/utils/useAuthSafe.d.ts.map +1 -1
  258. package/dist/utils/useAuthSafe.js +1 -78
  259. package/dist/utils/useAuthVisibility.d.ts.map +1 -1
  260. package/dist/utils/useAuthVisibility.js +1 -63
  261. package/dist/utils/useBillingVisibility.d.ts.map +1 -1
  262. package/dist/utils/useBillingVisibility.js +1 -57
  263. package/dist/utils/useCrudSafe.d.ts.map +1 -1
  264. package/dist/utils/useCrudSafe.js +1 -75
  265. package/dist/utils/useDeleteAccountSafe.js +1 -52
  266. package/dist/utils/useFormStoreSafe.d.ts.map +1 -1
  267. package/dist/utils/useFormStoreSafe.js +1 -85
  268. package/dist/utils/useOAuthSafe.d.ts.map +1 -1
  269. package/dist/utils/useOAuthSafe.js +1 -38
  270. package/dist/utils/useSeo.js +1 -151
  271. package/dist/utils/useStripeBillingSafe.d.ts.map +1 -1
  272. package/dist/utils/useStripeBillingSafe.js +1 -81
  273. package/dist/vite-routing/AppRoutes.d.ts.map +1 -1
  274. package/dist/vite-routing/AppRoutes.js +1 -235
  275. package/dist/vite-routing/RootLayout.d.ts.map +1 -1
  276. package/dist/vite-routing/RootLayout.js +1 -205
  277. package/dist/vite-routing/index.js +1 -11
  278. package/dist/vite.js +1 -10
  279. package/guidelines/COMPONENTS.md +4 -4
  280. package/guidelines/PAGES.md +3 -0
  281. package/guidelines/ROUTING.md +15 -0
  282. package/guidelines/SEO.md +4 -1
  283. package/package.json +18 -8
  284. package/dist/ChildRowsPicker-63M4EQUQ.js +0 -1
  285. package/dist/ChildRowsPicker-ISP365ON.js +0 -1
  286. package/dist/ChildRowsPicker-PQFE6NCR.js +0 -1
  287. package/dist/ChildRowsPicker-XXFFSMWY.js +0 -1
  288. package/dist/CookieConsent-QOUAY6B4.js +0 -1
  289. package/dist/GoToDialog-KSBGOIWO.js +0 -1
  290. package/dist/GoToDialog-XBK5EZF4.js +0 -1
  291. package/dist/chunk-3CIZFGST.js +0 -1
  292. package/dist/chunk-LHMKU342.js +0 -1
  293. package/dist/chunk-MS7ZIW5Z.js +0 -1
  294. package/dist/chunk-O2XFH626.js +0 -1
  295. package/dist/chunk-P2DHZWPY.js +0 -1
  296. package/dist/components/common/lucideIconByName.d.ts +0 -9
  297. package/dist/components/common/lucideIconByName.d.ts.map +0 -1
  298. package/dist/components/common/lucideIconByName.js +0 -32
  299. package/dist/internal/layout/components/PerformanceHints.d.ts +0 -71
  300. package/dist/internal/layout/components/PerformanceHints.d.ts.map +0 -1
  301. package/dist/internal/layout/components/PerformanceHints.js +0 -71
@@ -1,338 +1 @@
1
- 'use client';
2
- import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
3
- // packages/ui/src/internal/layout/components/AutoMetaTags.tsx
4
- /**
5
- * @fileoverview Automatic meta tags system integrated with DnDev framework
6
- * @description Zero-config SEO/GEO with route-based meta generation.
7
- * All features ON by default, opt-out per feature via appConfig.seo.{feature}: false.
8
- *
9
- * Features:
10
- * - Zero-configuration SEO setup
11
- * - Open Graph and Twitter Card support with image dimensions
12
- * - hreflang alternate links (auto from i18n config)
13
- * - Speculation Rules API (prefetch/prerender for Chromium) - opt-in, requires CSP config
14
- * - BreadcrumbList + WebSite JSON-LD structured data
15
- * - Internationalization integration
16
- * - Canonical URL management
17
- *
18
- * @version 0.3.0
19
- * @since 0.0.1
20
- * @author AMBROISE PARK Consulting
21
- */
22
- import { useMemo } from 'react';
23
- import { getLanguageRouting, isMultilingual, isNextJs, languageUrls, localizePath, useTranslation, } from '@donotdev/core';
24
- import { getDndevConfig } from '@donotdev/core';
25
- import { useSeoConfig, useAppConfig, getPlatformEnvVar } from '@donotdev/core';
26
- import { AssetResolver } from '@donotdev/ui';
27
- // Platform-specific hooks via conditional exports
28
- import { useRoutePath, useUrlLanguage } from '@donotdev/ui/routing/hooks';
29
- import { HeadTags } from './HeadTags';
30
- import { readI18nSeoMeta, resolveSeoField } from './i18nSeoMeta';
31
- /**
32
- * Match pathname against route path pattern (e.g. /cars/:id or /blog/:slug/comments/:id).
33
- * Supports arbitrary nesting: any depth, any mix of static and :param segments.
34
- */
35
- function matchRoutePath(pattern, pathname) {
36
- const patternSegments = pattern.split('/').filter(Boolean);
37
- const pathnameSegments = pathname.split('/').filter(Boolean);
38
- if (patternSegments.length !== pathnameSegments.length)
39
- return false;
40
- for (let i = 0; i < patternSegments.length; i++) {
41
- const segment = patternSegments[i];
42
- const pathSegment = pathnameSegments[i];
43
- if (segment === undefined || pathSegment === undefined)
44
- return false;
45
- if (segment.startsWith(':'))
46
- continue; // param matches any value
47
- if (segment !== pathSegment)
48
- return false;
49
- }
50
- return true;
51
- }
52
- /**
53
- * Get route metadata from the build-time config (`globalThis._DNDEV_CONFIG_`).
54
- * Resolves dynamic routes by pattern (e.g. /cars/:id) so PageMeta (including namespace) is used for SEO.
55
- * The config is set at module load on the server (Next SSR) and in the browser, so the
56
- * server render and the hydration pass resolve the same metadata.
57
- */
58
- function getRouteMetadata(pathname) {
59
- const config = getDndevConfig();
60
- const routeData = config?.routes?.mapping;
61
- if (routeData && Array.isArray(routeData)) {
62
- // 1. Exact match (static routes)
63
- let route = routeData.find((r) => r.path === pathname);
64
- if (route)
65
- return { meta: route.meta, dynamic: false };
66
- // 2. Pattern match (dynamic routes: /cars/:id, /blog/:slug/comments/:id, etc.)
67
- const dynamicRoutes = routeData.filter((r) => typeof r.path === 'string' && r.path.includes(':'));
68
- const matches = dynamicRoutes.filter((r) => matchRoutePath(r.path, pathname));
69
- // Prefer most specific (longest path) so /blog/:slug/comments wins over /blog/:slug for /blog/a/comments
70
- if (matches.length > 0) {
71
- route = matches.reduce((best, r) => r.path.length > best.path.length ? r : best);
72
- return { meta: route.meta, dynamic: true };
73
- }
74
- }
75
- // Fallback: first path segment as namespace (e.g. /cars/abc123 → ns: cars)
76
- const segments = pathname.split('/').filter(Boolean);
77
- if (segments.length > 0) {
78
- return { meta: { namespace: segments[0] }, dynamic: false };
79
- }
80
- return { meta: {}, dynamic: false };
81
- }
82
- /**
83
- * Build BreadcrumbList JSON-LD from URL path segments
84
- */
85
- function buildBreadcrumbSchema(pathname, baseUrl, siteName, localize) {
86
- const segments = pathname.split('/').filter(Boolean);
87
- const items = [
88
- {
89
- '@type': 'ListItem',
90
- position: 1,
91
- name: siteName,
92
- item: `${baseUrl}${localize('/')}`,
93
- },
94
- ];
95
- let currentPath = '';
96
- for (let i = 0; i < segments.length; i++) {
97
- currentPath += `/${segments[i]}`;
98
- items.push({
99
- '@type': 'ListItem',
100
- position: i + 2,
101
- name: segments[i].split('-')
102
- .map((w) => w.charAt(0).toUpperCase() + w.slice(1))
103
- .join(' '),
104
- item: `${baseUrl}${localize(currentPath)}`,
105
- });
106
- }
107
- return {
108
- '@context': 'https://schema.org',
109
- '@type': 'BreadcrumbList',
110
- itemListElement: items,
111
- };
112
- }
113
- /**
114
- * Build WebSite JSON-LD with SearchAction (sitelinks search box)
115
- */
116
- function buildWebSiteSchema(baseUrl, siteName) {
117
- return {
118
- '@context': 'https://schema.org',
119
- '@type': 'WebSite',
120
- name: siteName,
121
- url: baseUrl || '/',
122
- potentialAction: {
123
- '@type': 'SearchAction',
124
- target: {
125
- '@type': 'EntryPoint',
126
- urlTemplate: `${baseUrl}/search?q={search_term_string}`,
127
- },
128
- 'query-input': 'required name=search_term_string',
129
- },
130
- };
131
- }
132
- /**
133
- * Build Organization JSON-LD from app metadata (links, description)
134
- * Only emitted on homepage when links are configured
135
- */
136
- function buildOrganizationSchema(baseUrl, siteName, description, links) {
137
- const sameAs = links
138
- ? Object.values(links).filter((url) => !!url)
139
- : [];
140
- return {
141
- '@context': 'https://schema.org',
142
- '@type': 'Organization',
143
- name: siteName,
144
- url: baseUrl || '/',
145
- ...(description && { description }),
146
- ...(sameAs.length > 0 && { sameAs }),
147
- logo: {
148
- '@type': 'ImageObject',
149
- url: `${baseUrl}/icon-512x512.png`,
150
- },
151
- };
152
- }
153
- /**
154
- * Build speculation rules for prefetch/prerender of public internal links
155
- * Excludes auth-gated and API routes
156
- */
157
- function buildSpeculationRules() {
158
- return {
159
- prerender: [
160
- {
161
- where: {
162
- and: [
163
- { href_matches: '/*' },
164
- { not: { href_matches: '/api/*' } },
165
- { not: { href_matches: '/admin/*' } },
166
- { not: { href_matches: '/login*' } },
167
- { not: { href_matches: '/signin*' } },
168
- { not: { href_matches: '/signup*' } },
169
- { not: { href_matches: '/logout*' } },
170
- ],
171
- },
172
- eagerness: 'moderate',
173
- },
174
- ],
175
- prefetch: [
176
- {
177
- where: {
178
- and: [{ href_matches: '/*' }, { not: { href_matches: '/api/*' } }],
179
- },
180
- eagerness: 'conservative',
181
- },
182
- ],
183
- };
184
- }
185
- /**
186
- * AutoMetaTags component
187
- *
188
- * Uses configuration from AppConfigProvider context.
189
- * No props needed - all config comes from useSeoConfig() and useAppConfig().
190
- *
191
- * Features:
192
- * - Automatic route-based meta tag generation
193
- * - i18n integration with hreflang
194
- * - Open Graph and Twitter Cards with image dimensions
195
- * - Speculation Rules API
196
- * - BreadcrumbList + WebSite JSON-LD
197
- * - 100% Lighthouse SEO compliance
198
- */
199
- export const AutoMetaTags = () => {
200
- const { t } = useTranslation();
201
- const pathname = useRoutePath();
202
- const seoConfig = useSeoConfig();
203
- const appMeta = useAppConfig('app');
204
- const siteName = (seoConfig && seoConfig.siteName) || appMeta?.name || '';
205
- const baseUrl = getPlatformEnvVar('APP_URL') || '';
206
- // Get route metadata — computed from current pathname
207
- const { meta: routeMeta, dynamic: isDynamicRoute } = getRouteMetadata(pathname);
208
- // On Next, a dynamic route's page renders the record's <Seo> (title, description,
209
- // image). React 19 hoists every <title>/<meta> without deduping (unlike Helmet on
210
- // Vite), so the page owns those tags there and this component emits site-level tags only.
211
- const pageOwnsIdentity = isDynamicRoute && isNextJs();
212
- // One URL per language (default language at the root): canonical, og:url, JSON-LD
213
- // and hreflang use the page's URL in each language.
214
- const routing = getLanguageRouting();
215
- const language = useUrlLanguage();
216
- const localize = (path) => localizePath(path, language, routing);
217
- // Memoize computed values for performance — must be called before any early return
218
- const metaData = useMemo(() => {
219
- if (!seoConfig)
220
- return null;
221
- const { defaultNamespace = 'home', defaultImage = '/og-image.png' } = seoConfig;
222
- // Canonical: this page in this language (`/en/x`; `/x` for the default language)
223
- const currentUrl = `${baseUrl}${localizePath(pathname, language, routing)}`;
224
- const ns = routeMeta.namespace || defaultNamespace;
225
- const seo = routeMeta.seo;
226
- // Get the meta fields from i18n (image, type, keywords, author, fullTitle)
227
- const metaObject = readI18nSeoMeta(t, ns);
228
- // Title resolution priority:
229
- // 1. i18n meta.fullTitle → translated, language-aware (wins)
230
- // 2. seo.fullTitle (static PageMeta) → fallback for non-i18n apps
231
- // 3. seo.title (explicit) → "title | siteName"
232
- // 4. i18n ns:title → "translated | siteName"
233
- // 5. siteName only (when seo.title === null or no translation)
234
- let fullTitle;
235
- if (metaObject?.fullTitle) {
236
- // i18n fullTitle (ns:meta.fullTitle) → translated, takes priority
237
- fullTitle = metaObject.fullTitle;
238
- }
239
- else if (seo?.fullTitle) {
240
- // Static fullTitle in PageMeta → fallback for non-i18n apps
241
- fullTitle = seo.fullTitle;
242
- }
243
- else {
244
- // Standard resolution: title | siteName
245
- const pageTitle = resolveSeoField(seo?.title, `${ns}:title`, t);
246
- fullTitle = pageTitle ? `${pageTitle} | ${siteName}` : siteName;
247
- }
248
- // Description resolution: seo.description > i18n
249
- const description = resolveSeoField(seo?.description, `${ns}:description`, t);
250
- // Other meta fields: seo > i18n meta object > defaults
251
- const pageImage = seo?.image || metaObject?.image || defaultImage;
252
- const pageType = seo?.type || metaObject?.type || 'website';
253
- const pageKeywords = seo?.keywords || metaObject?.keywords;
254
- const pageAuthor = routeMeta.author || metaObject?.author;
255
- const image = pageImage || undefined;
256
- const type = pageType || 'website';
257
- const keywords = pageKeywords || undefined;
258
- const author = pageAuthor || undefined;
259
- // Link-preview crawlers need an absolute URL
260
- const imagePath = image && !image.startsWith('http') ? `${baseUrl}${image}` : image;
261
- return {
262
- title: fullTitle,
263
- description,
264
- image: imagePath,
265
- url: currentUrl,
266
- type,
267
- noindex: seo?.noindex || routeMeta.noindex || false,
268
- keywords,
269
- author,
270
- publishDate: routeMeta.publishDate,
271
- modifiedDate: routeMeta.modifiedDate,
272
- };
273
- }, [pathname, language, routeMeta, siteName, baseUrl, seoConfig, t]);
274
- // Return null if SEO is disabled — after all hooks have been called
275
- if (!seoConfig || !metaData)
276
- return null;
277
- const { twitterHandle, staticTags = {} } = seoConfig;
278
- // Feature flags — all default to true (ON by default), except speculationRules (CSP conflict)
279
- // Speculation rules require inline script which conflicts with strict CSP.
280
- // Opt-in only: set seo.speculationRules: true and add CSP hash to your headers.
281
- const speculationRulesEnabled = seoConfig.speculationRules === true;
282
- const hreflangEnabled = seoConfig.hreflang !== false;
283
- const breadcrumbSchemaEnabled = seoConfig.breadcrumbSchema !== false;
284
- const websiteSchemaEnabled = seoConfig.websiteSchema !== false;
285
- const organizationSchemaEnabled = seoConfig.organizationSchema !== false;
286
- // hreflang: only emit when 2+ languages configured
287
- const shouldEmitHreflang = hreflangEnabled && isMultilingual(routing.languages);
288
- const alternates = languageUrls(pathname, baseUrl, routing);
289
- return (_jsxs(HeadTags, { children: [baseUrl && _jsx("link", { rel: "canonical", href: metaData.url }), baseUrl && _jsx("meta", { property: "og:url", content: metaData.url }), _jsx("meta", { property: "og:site_name", content: siteName }), !pageOwnsIdentity && (_jsxs(_Fragment, { children: [_jsx("title", { children: metaData.title }), metaData.description && (_jsx("meta", { name: "description", content: metaData.description })), metaData.keywords && (_jsx("meta", { name: "keywords", content: Array.isArray(metaData.keywords)
290
- ? metaData.keywords.join(', ')
291
- : metaData.keywords })), metaData.author && _jsx("meta", { name: "author", content: metaData.author }), metaData.noindex && (_jsx("meta", { name: "robots", content: "noindex, nofollow" })), _jsx("meta", { property: "og:title", content: metaData.title }), metaData.description && (_jsx("meta", { property: "og:description", content: metaData.description })), _jsx("meta", { property: "og:type", content: metaData.type }), metaData.image && (_jsx("meta", { property: "og:image", content: metaData.image })), metaData.image && _jsx("meta", { property: "og:image:width", content: "1200" }), metaData.image && _jsx("meta", { property: "og:image:height", content: "630" }), metaData.type === 'article' && (_jsxs(_Fragment, { children: [metaData.author && (_jsx("meta", { property: "article:author", content: metaData.author })), metaData.publishDate && (_jsx("meta", { property: "article:published_time", content: metaData.publishDate })), metaData.modifiedDate && (_jsx("meta", { property: "article:modified_time", content: metaData.modifiedDate }))] })), _jsx("meta", { name: "twitter:card", content: "summary_large_image" }), _jsx("meta", { name: "twitter:title", content: metaData.title }), metaData.description && (_jsx("meta", { name: "twitter:description", content: metaData.description })), metaData.image && (_jsx("meta", { name: "twitter:image", content: metaData.image })), metaData.author && (_jsx("meta", { name: "twitter:creator", content: metaData.author }))] })), twitterHandle && (_jsx("meta", { name: "twitter:site", content: `@${twitterHandle}` })), _jsx("meta", { name: "format-detection", content: "telephone=no" }), _jsx("meta", { name: "mobile-web-app-capable", content: "yes" }), _jsx("meta", { name: "apple-mobile-web-app-status-bar-style", content: "default" }), Object.entries(staticTags).map(([name, content]) => (_jsx("meta", { name: name, content: content }, name))), shouldEmitHreflang &&
292
- routing.languages.map((lang) => (_jsx("link", { rel: "alternate", hrefLang: lang, href: alternates[lang] }, `hreflang-${lang}`))), shouldEmitHreflang && (_jsx("link", { rel: "alternate", hrefLang: "x-default", href: alternates[routing.defaultLanguage] })), baseUrl && (_jsx("link", { rel: "alternate", type: "application/rss+xml", title: `${siteName} Blog`, href: `${baseUrl}/rss.xml` })), !pageOwnsIdentity &&
293
- metaData.image &&
294
- metaData.image.startsWith('http') && (_jsx("link", { rel: "dns-prefetch", href: new URL(metaData.image).origin })), !pageOwnsIdentity && (_jsx("script", { type: "application/ld+json", children: JSON.stringify({
295
- '@context': 'https://schema.org',
296
- '@type': metaData.type === 'article' ? 'Article' : 'WebPage',
297
- name: metaData.title,
298
- ...(metaData.description && { description: metaData.description }),
299
- url: metaData.url,
300
- ...(metaData.image && { image: metaData.image }),
301
- ...(metaData.type === 'article' && {
302
- ...(metaData.author && {
303
- author: {
304
- '@type': 'Person',
305
- name: metaData.author,
306
- },
307
- }),
308
- ...(metaData.publishDate && {
309
- datePublished: metaData.publishDate,
310
- }),
311
- ...(metaData.modifiedDate && {
312
- dateModified: metaData.modifiedDate,
313
- }),
314
- }),
315
- publisher: {
316
- '@type': 'Organization',
317
- name: siteName,
318
- logo: {
319
- '@type': 'ImageObject',
320
- // Absolute: schema.org consumers (Google) ignore a relative logo URL
321
- url: `${baseUrl}${AssetResolver.assetExists('/icon-512x512.png')
322
- ? '/icon-512x512.png'
323
- : AssetResolver.assetExists('/icon-192x192.png')
324
- ? '/icon-192x192.png'
325
- : '/logo.svg'}`,
326
- },
327
- },
328
- }) })), breadcrumbSchemaEnabled && pathname !== '/' && (_jsx("script", { type: "application/ld+json", children: JSON.stringify(buildBreadcrumbSchema(pathname, baseUrl, siteName, localize)) })), websiteSchemaEnabled && baseUrl && (_jsx("script", { type: "application/ld+json", children: JSON.stringify(buildWebSiteSchema(baseUrl, siteName)) })), organizationSchemaEnabled &&
329
- baseUrl &&
330
- pathname === '/' &&
331
- appMeta?.links &&
332
- Object.values(appMeta.links).some(Boolean) && (_jsx("script", { type: "application/ld+json", children: JSON.stringify(buildOrganizationSchema(baseUrl, siteName, appMeta.description, appMeta.links)) })), speculationRulesEnabled && (_jsx("script", { type: "speculationrules", children: JSON.stringify(buildSpeculationRules()) }))] }));
333
- };
334
- /**
335
- * AutoMetaTags retrieves all configuration from AppConfigProvider.
336
- * Page-specific overrides should be configured through AppConfig or route metadata.
337
- */
338
- export default AutoMetaTags;
1
+ "use client";import{useMemo as G}from"react";import{getLanguageRouting as Q,isMultilingual as X,isNextJs as Y,languageUrls as Z,localizePath as T,useTranslation as ee}from"@donotdev/core";import{getDndevConfig as M}from"@donotdev/core";import{useSeoConfig as te,useAppConfig as ne,getPlatformEnvVar as ae}from"@donotdev/core";import{useRoutePath as ie,useUrlLanguage as oe}from"@donotdev/ui/routing/hooks";import{useIsNotFoundDocument as re}from"../../../routing/NotFoundDocument.js";import{AssetResolver as k}from"../../../utils/assetResolver.js";import{HeadTags as se}from"./HeadTags.js";import{readI18nSeoMeta as ce,resolveSeoField as O}from"./i18nSeoMeta.js";import{Fragment as A,jsx as t,jsxs as R}from"react/jsx-runtime";function le(r,s){let n=r.split("/").filter(Boolean),c=s.split("/").filter(Boolean);if(n.length!==c.length)return!1;for(let a=0;a<n.length;a++){let i=n[a],m=c[a];if(i===void 0||m===void 0)return!1;if(!i.startsWith(":")&&i!==m)return!1}return!0}var me={meta:{},dynamic:!1};function pe(r){let n=M()?.routes?.mapping;if(n&&Array.isArray(n)){let a=n.find(o=>o.path===r);if(a)return{meta:a.meta,dynamic:!1};let m=n.filter(o=>typeof o.path=="string"&&o.path.includes(":")).filter(o=>le(o.path,r));if(m.length>0)return a=m.reduce((o,l)=>l.path.length>o.path.length?l:o),{meta:a.meta,dynamic:!0}}let c=r.split("/").filter(Boolean);return c.length>0?{meta:{namespace:c[0]},dynamic:!1}:{meta:{},dynamic:!1}}function ue(r,s,n,c){let a=r.split("/").filter(Boolean),i=[{"@type":"ListItem",position:1,name:n,item:`${s}${c("/")}`}],m="";for(let o=0;o<a.length;o++)m+=`/${a[o]}`,i.push({"@type":"ListItem",position:o+2,name:a[o].split("-").map(l=>l.charAt(0).toUpperCase()+l.slice(1)).join(" "),item:`${s}${c(m)}`});return{"@context":"https://schema.org","@type":"BreadcrumbList",itemListElement:i}}function ge(r,s){return{"@context":"https://schema.org","@type":"WebSite",name:s,url:r||"/",potentialAction:{"@type":"SearchAction",target:{"@type":"EntryPoint",urlTemplate:`${r}/search?q={search_term_string}`},"query-input":"required name=search_term_string"}}}function de(r,s,n,c){let a=c?Object.values(c).filter(i=>!!i):[];return{"@context":"https://schema.org","@type":"Organization",name:s,url:r||"/",...n&&{description:n},...a.length>0&&{sameAs:a},logo:{"@type":"ImageObject",url:`${r}/icon-512x512.png`}}}function fe(){return{prerender:[{where:{and:[{href_matches:"/*"},{not:{href_matches:"/api/*"}},{not:{href_matches:"/admin/*"}},{not:{href_matches:"/login*"}},{not:{href_matches:"/signin*"}},{not:{href_matches:"/signup*"}},{not:{href_matches:"/logout*"}}]},eagerness:"moderate"}],prefetch:[{where:{and:[{href_matches:"/*"},{not:{href_matches:"/api/*"}}]},eagerness:"conservative"}]}}var he=()=>{let{t:r}=ee(),s=ie(),n=te(),c=ne("app"),a=n&&n.siteName||c?.name||"",i=ae("APP_URL")||"",m=M()?.routes?.manifest?.hasBlogFeed===!0,o=re(),{meta:l,dynamic:v}=o?me:pe(s),b=v&&Y(),g=Q(),w=oe(),E=p=>T(p,w,g),e=G(()=>{if(!n)return null;let{defaultNamespace:p="home",defaultImage:S="/og-image.png"}=n,C=o?null:`${i}${T(s,w,g)}`,d=o?null:l.namespace||p,u=l.seo,f=d?ce(r,d):null,h;if(f?.fullTitle)h=f.fullTitle;else if(u?.fullTitle)h=u.fullTitle;else{let $=d?O(u?.title,`${d}:title`,r):void 0;h=$?`${$} | ${a}`:a}let z=d?O(u?.description,`${d}:description`,r):void 0,F=u?.image||f?.image||S,J=u?.type||f?.type||"website",U=u?.keywords||f?.keywords,W=l.author||f?.author,y=F||void 0,H=J||"website",q=U||void 0,K=W||void 0,V=y&&!y.startsWith("http")?`${i}${y}`:y;return{title:h,description:z,image:V,url:C,type:H,noindex:u?.noindex||l.noindex||!1,keywords:q,author:K,publishDate:l.publishDate,modifiedDate:l.modifiedDate}},[o,s,w,l,a,i,n,r]);if(!n||!e)return null;let{twitterHandle:x,staticTags:N={}}=n,P=n.speculationRules===!0,j=n.hreflang!==!1,L=n.breadcrumbSchema!==!1,B=n.websiteSchema!==!1,I=n.organizationSchema!==!1,D=j&&!o&&X(g.languages),_=Z(s,i,g);return R(se,{children:[i&&e.url&&t("link",{rel:"canonical",href:e.url}),i&&e.url&&t("meta",{property:"og:url",content:e.url}),t("meta",{property:"og:site_name",content:a}),!b&&R(A,{children:[t("title",{children:e.title}),e.description&&t("meta",{name:"description",content:e.description}),e.keywords&&t("meta",{name:"keywords",content:Array.isArray(e.keywords)?e.keywords.join(", "):e.keywords}),e.author&&t("meta",{name:"author",content:e.author}),e.noindex&&t("meta",{name:"robots",content:"noindex, nofollow"}),t("meta",{property:"og:title",content:e.title}),e.description&&t("meta",{property:"og:description",content:e.description}),t("meta",{property:"og:type",content:e.type}),e.image&&t("meta",{property:"og:image",content:e.image}),e.image&&t("meta",{property:"og:image:width",content:"1200"}),e.image&&t("meta",{property:"og:image:height",content:"630"}),e.type==="article"&&R(A,{children:[e.author&&t("meta",{property:"article:author",content:e.author}),e.publishDate&&t("meta",{property:"article:published_time",content:e.publishDate}),e.modifiedDate&&t("meta",{property:"article:modified_time",content:e.modifiedDate})]}),t("meta",{name:"twitter:card",content:"summary_large_image"}),t("meta",{name:"twitter:title",content:e.title}),e.description&&t("meta",{name:"twitter:description",content:e.description}),e.image&&t("meta",{name:"twitter:image",content:e.image}),e.author&&t("meta",{name:"twitter:creator",content:e.author})]}),x&&t("meta",{name:"twitter:site",content:`@${x}`}),t("meta",{name:"format-detection",content:"telephone=no"}),t("meta",{name:"mobile-web-app-capable",content:"yes"}),t("meta",{name:"apple-mobile-web-app-status-bar-style",content:"default"}),Object.entries(N).map(([p,S])=>t("meta",{name:p,content:S},p)),D&&g.languages.map(p=>t("link",{rel:"alternate",hrefLang:p,href:_[p]},`hreflang-${p}`)),D&&t("link",{rel:"alternate",hrefLang:"x-default",href:_[g.defaultLanguage]}),i&&m&&t("link",{rel:"alternate",type:"application/rss+xml",title:`${a} Blog`,href:`${i}/rss.xml`}),!b&&e.image&&e.image.startsWith("http")&&t("link",{rel:"dns-prefetch",href:new URL(e.image).origin}),!b&&e.url&&t("script",{type:"application/ld+json",children:JSON.stringify({"@context":"https://schema.org","@type":e.type==="article"?"Article":"WebPage",name:e.title,...e.description&&{description:e.description},url:e.url,...e.image&&{image:e.image},...e.type==="article"&&{...e.author&&{author:{"@type":"Person",name:e.author}},...e.publishDate&&{datePublished:e.publishDate},...e.modifiedDate&&{dateModified:e.modifiedDate}},publisher:{"@type":"Organization",name:a,logo:{"@type":"ImageObject",url:`${i}${k.assetExists("/icon-512x512.png")?"/icon-512x512.png":k.assetExists("/icon-192x192.png")?"/icon-192x192.png":"/logo.svg"}`}}})}),L&&!o&&s!=="/"&&t("script",{type:"application/ld+json",children:JSON.stringify(ue(s,i,a,E))}),B&&i&&t("script",{type:"application/ld+json",children:JSON.stringify(ge(i,a))}),I&&i&&s==="/"&&c?.links&&Object.values(c.links).some(Boolean)&&t("script",{type:"application/ld+json",children:JSON.stringify(de(i,a,c.description,c.links))}),P&&t("script",{type:"speculationrules",children:JSON.stringify(fe())})]})},Te=he;export{he as AutoMetaTags,Te as default};
@@ -1,60 +1 @@
1
- 'use client';
2
- import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
3
- // packages/ui/src/internal/layout/components/FaviconHead.tsx
4
- /**
5
- * @fileoverview Modern favicon system component
6
- * @description Comprehensive favicon setup following PWA and web.dev best practices
7
- *
8
- * IMPORTANT: This component is designed to be rendered inside <head> via:
9
- * - react-helmet-async
10
- * - Next.js Head component
11
- * - Nuxt.js Head component
12
- * - or similar head management solutions
13
- *
14
- * Microsoft Edge Tools false positives:
15
- * - apple-touch-icons: These ARE placed in <head> via React head management
16
- * - theme-color: Progressive enhancement - intentionally used for modern browsers
17
- *
18
- * @version 0.1.0
19
- * @since 0.0.1
20
- * @author AMBROISE PARK Consulting
21
- */
22
- import { useEffect, useState } from 'react';
23
- import { useFaviconConfig } from '@donotdev/core';
24
- import { AssetResolver } from '../../../utils/assetResolver';
25
- /**
26
- * Modern favicon system component
27
- *
28
- * Uses configuration from AppConfigProvider context.
29
- * No props needed - all config comes from useFaviconConfig().
30
- *
31
- * Features:
32
- * - SVG favicon with dark mode support
33
- * - Complete size set for all devices
34
- * - PWA manifest integration
35
- * - Microsoft tile support
36
- * - Apple touch icons
37
- * - Prevents default favicon requests
38
- *
39
- * @version 0.1.0
40
- * @since 0.0.1
41
- * @author AMBROISE PARK Consulting
42
- * @note This component must be rendered inside <head> via React head management
43
- */
44
- const FaviconHead = () => {
45
- const faviconConfig = useFaviconConfig();
46
- // Return null if disabled
47
- if (!faviconConfig)
48
- return null;
49
- const { appName = 'DoNotDev App', themeColor = '#2563eb', backgroundColor = '#ffffff', includeManifestIcons = true, includeMSIcons = false, } = faviconConfig;
50
- const [faviconSet, setFaviconSet] = useState(null);
51
- useEffect(() => {
52
- const resolved = AssetResolver.resolveFaviconSet();
53
- setFaviconSet(resolved);
54
- }, []);
55
- if (!faviconSet) {
56
- return null;
57
- }
58
- return (_jsxs(_Fragment, { children: [faviconSet.svg && (_jsx("link", { rel: "icon", type: "image/svg+xml", href: faviconSet.svg })), faviconSet.ico && (_jsx("link", { rel: "icon", type: "image/x-icon", href: faviconSet.ico })), faviconSet.png16 && (_jsx("link", { rel: "icon", type: "image/png", sizes: "16x16", href: faviconSet.png16 })), faviconSet.png32 && (_jsx("link", { rel: "icon", type: "image/png", sizes: "32x32", href: faviconSet.png32 })), faviconSet.apple180 && (_jsxs(_Fragment, { children: [_jsx("link", { rel: "apple-touch-icon", sizes: "180x180", href: faviconSet.apple180 }), _jsx("meta", { name: "apple-mobile-web-app-status-bar-style", content: "default" }), _jsx("meta", { name: "apple-mobile-web-app-title", content: appName })] })), includeManifestIcons && (_jsxs(_Fragment, { children: [faviconSet.android192 && (_jsx("link", { rel: "icon", type: "image/png", sizes: "192x192", href: faviconSet.android192 })), faviconSet.android512 && (_jsx("link", { rel: "icon", type: "image/png", sizes: "512x512", href: faviconSet.android512 }))] })), includeMSIcons && faviconSet.png32 && (_jsxs(_Fragment, { children: [_jsx("meta", { name: "msapplication-TileImage", content: faviconSet.png32 }), _jsx("meta", { name: "msapplication-TileColor", content: themeColor }), _jsx("meta", { name: "msapplication-config", content: "/browserconfig.xml" })] })), _jsx("meta", { name: "theme-color", content: themeColor }), _jsx("meta", { name: "color-scheme", content: "light dark" }), _jsx("link", { rel: "shortcut icon", href: "data:," })] }));
59
- };
60
- export default FaviconHead;
1
+ "use client";import{useEffect as m,useState as f}from"react";import{useFaviconConfig as g}from"@donotdev/core";import{AssetResolver as u}from"../../../utils/assetResolver.js";import{Fragment as o,jsx as n,jsxs as t}from"react/jsx-runtime";var d=()=>{let i=g();if(!i)return null;let{appName:l="DoNotDev App",themeColor:a="#2563eb",backgroundColor:v="#ffffff",includeManifestIcons:p=!0,includeMSIcons:r=!1}=i,[e,c]=f(null);return m(()=>{let s=u.resolveFaviconSet();c(s)},[]),e?t(o,{children:[e.svg&&n("link",{rel:"icon",type:"image/svg+xml",href:e.svg}),e.ico&&n("link",{rel:"icon",type:"image/x-icon",href:e.ico}),e.png16&&n("link",{rel:"icon",type:"image/png",sizes:"16x16",href:e.png16}),e.png32&&n("link",{rel:"icon",type:"image/png",sizes:"32x32",href:e.png32}),e.apple180&&t(o,{children:[n("link",{rel:"apple-touch-icon",sizes:"180x180",href:e.apple180}),n("meta",{name:"apple-mobile-web-app-status-bar-style",content:"default"}),n("meta",{name:"apple-mobile-web-app-title",content:l})]}),p&&t(o,{children:[e.android192&&n("link",{rel:"icon",type:"image/png",sizes:"192x192",href:e.android192}),e.android512&&n("link",{rel:"icon",type:"image/png",sizes:"512x512",href:e.android512})]}),r&&e.png32&&t(o,{children:[n("meta",{name:"msapplication-TileImage",content:e.png32}),n("meta",{name:"msapplication-TileColor",content:a}),n("meta",{name:"msapplication-config",content:"/browserconfig.xml"})]}),n("meta",{name:"theme-color",content:a}),n("meta",{name:"color-scheme",content:"light dark"}),n("link",{rel:"shortcut icon",href:"data:,"})]}):null},b=d;export{b as default};
@@ -1,31 +1 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- // packages/ui/src/internal/layout/components/FontPreloadLinks.tsx
3
- /**
4
- * @fileoverview FontPreloadLinks - Server-only component for Next.js
5
- * @description Links public/dndev-fonts.css, the @font-face rules of the framework
6
- * fonts the app's theme uses (written at build by copyFontsToPublic). Renders nothing
7
- * when the theme uses none (an app that packs its own fonts). Include in the root
8
- * document's <head>.
9
- *
10
- * @version 0.2.0
11
- * @since 0.0.1
12
- * @author AMBROISE PARK Consulting
13
- */
14
- import fs from 'node:fs/promises';
15
- import path from 'node:path';
16
- const FONTS_CSS_FILENAME = 'dndev-fonts.css';
17
- /**
18
- * Server component: `<link rel="stylesheet" href="/dndev-fonts.css">` when discovery
19
- * generated that file (the theme renders text in a framework font), else null.
20
- */
21
- export async function FontPreloadLinks() {
22
- try {
23
- await fs.access(path.join(process.cwd(), 'public', FONTS_CSS_FILENAME));
24
- }
25
- catch {
26
- // Not generated: the theme uses no framework font
27
- return null;
28
- }
29
- return _jsx("link", { rel: "stylesheet", href: `/${FONTS_CSS_FILENAME}` });
30
- }
31
- export default FontPreloadLinks;
1
+ import e from"node:fs/promises";import o from"node:path";import{jsx as c}from"react/jsx-runtime";var t="dndev-fonts.css";async function r(){try{await e.access(o.join(process.cwd(),"public",t))}catch{return null}return c("link",{rel:"stylesheet",href:`/${t}`})}var a=r;export{r as FontPreloadLinks,a as default};
@@ -1,20 +1 @@
1
- 'use client';
2
- import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
3
- import { Helmet } from 'react-helmet-async';
4
- import { isNextJs } from '@donotdev/core';
5
- export function HeadTags({ children }) {
6
- // On any server render, never touch react-helmet-async — it reads `document`
7
- // and throws. React 19 hoists <title>/<meta>/<link> to <head> natively during
8
- // SSR, so a fragment is all that's needed. (Vite is a CSR SPA and never renders
9
- // on a server, so this branch is Next-SSR only.)
10
- if (typeof document === 'undefined') {
11
- return _jsx(_Fragment, { children: children });
12
- }
13
- // Client render: on Next, React 19 already hoisted these tags server-side and
14
- // there is no <HelmetProvider> — so keep using the native fragment. Only the
15
- // Vite SPA (no Next markers) uses react-helmet-async, exactly as before.
16
- if (isNextJs()) {
17
- return _jsx(_Fragment, { children: children });
18
- }
19
- return _jsx(Helmet, { children: children });
20
- }
1
+ "use client";import{Helmet as r}from"react-helmet-async";import{isNextJs as f}from"@donotdev/core";import{Fragment as o,jsx as t}from"react/jsx-runtime";function n({children:e}){return typeof document>"u"?t(o,{children:e}):f()?t(o,{children:e}):t(r,{children:e})}export{n as HeadTags};
@@ -1,131 +1 @@
1
- 'use client';
2
- import { jsx as _jsx } from "react/jsx-runtime";
3
- // packages/ui/src/internal/layout/components/PWAUpdateNotification.tsx
4
- /**
5
- * @fileoverview PWAUpdateNotification component
6
- * @description PWA update notification using toast system (industry standard)
7
- *
8
- * CSR/SSR Safe:
9
- * - Returns null on server (isClient() check)
10
- * - Guards all browser APIs
11
- * - Handles service worker rejection gracefully
12
- * - Uses toast system instead of Card component
13
- *
14
- * @version 0.1.0
15
- * @since 0.0.1
16
- * @author AMBROISE PARK Consulting
17
- */
18
- import { RefreshCw } from 'lucide-react';
19
- import { useEffect, useRef, useCallback } from 'react';
20
- import { toast, Button, ToastAction } from '@donotdev/components';
21
- import { isClient, useTranslation } from '@donotdev/core';
22
- /**
23
- * PWAUpdateNotification - PWA update notification using toast system
24
- *
25
- * Industry standard pattern:
26
- * - Detects service worker updates
27
- * - Shows persistent toast (duration: 0)
28
- * - Component returns null (toast handles UI)
29
- * - CSR/SSR safe with proper guards
30
- *
31
- * @version 0.1.0
32
- * @since 0.0.1
33
- * @author AMBROISE PARK Consulting
34
- */
35
- function PWAUpdateNotification({ onUpdate }) {
36
- const { t } = useTranslation('dndev');
37
- const registrationRef = useRef(null);
38
- const toastIdRef = useRef(null);
39
- const isUpdatingRef = useRef(false);
40
- // CSR/SSR safe: Early return on server
41
- useEffect(() => {
42
- if (!isClient() || !('serviceWorker' in navigator))
43
- return;
44
- let refreshing = false;
45
- const handleControllerChange = () => {
46
- if (refreshing || !isClient())
47
- return;
48
- refreshing = true;
49
- window.location.reload();
50
- };
51
- navigator.serviceWorker.addEventListener('controllerchange', handleControllerChange);
52
- // Track listeners for cleanup
53
- let currentReg = null;
54
- let handleUpdateFound = null;
55
- let trackedWorker = null;
56
- let handleStateChange = null;
57
- const checkForUpdates = async () => {
58
- // CSR guard: Check client again
59
- if (!isClient())
60
- return;
61
- try {
62
- const reg = await navigator.serviceWorker.ready;
63
- registrationRef.current = reg;
64
- currentReg = reg;
65
- handleUpdateFound = () => {
66
- const newWorker = reg.installing;
67
- if (!newWorker)
68
- return;
69
- trackedWorker = newWorker;
70
- handleStateChange = () => {
71
- if (newWorker.state === 'installed' &&
72
- navigator.serviceWorker.controller &&
73
- !toastIdRef.current) {
74
- showUpdateToast();
75
- }
76
- };
77
- newWorker.addEventListener('statechange', handleStateChange);
78
- };
79
- reg.addEventListener('updatefound', handleUpdateFound);
80
- if (reg.waiting && !toastIdRef.current) {
81
- showUpdateToast();
82
- }
83
- }
84
- catch (error) {
85
- // No service worker registered - silently return (industry standard)
86
- // Don't log warnings for missing service workers
87
- return;
88
- }
89
- };
90
- const showUpdateToast = () => {
91
- if (!isClient() || toastIdRef.current)
92
- return;
93
- const handleUpdate = async () => {
94
- if (!registrationRef.current?.waiting ||
95
- isUpdatingRef.current ||
96
- !isClient())
97
- return;
98
- isUpdatingRef.current = true;
99
- if (onUpdate) {
100
- onUpdate();
101
- }
102
- registrationRef.current.waiting.postMessage({ type: 'SKIP_WAITING' });
103
- };
104
- const { id } = toast({
105
- title: t('pwa.update.title', 'Update available'),
106
- description: t('pwa.update.description', 'A new version is ready. Refresh to update.'),
107
- toastType: 'info',
108
- duration: 0, // Persistent (industry standard)
109
- action: (_jsx(ToastAction, { asChild: true, altText: t('pwa.update.altText', 'Update application'), children: _jsx(Button, { onClick: handleUpdate, icon: RefreshCw, children: t('pwa.update.button', 'Update') }) })),
110
- });
111
- toastIdRef.current = id;
112
- };
113
- checkForUpdates();
114
- const interval = setInterval(checkForUpdates, 60000);
115
- return () => {
116
- if (isClient() && 'serviceWorker' in navigator) {
117
- navigator.serviceWorker.removeEventListener('controllerchange', handleControllerChange);
118
- }
119
- if (currentReg && handleUpdateFound) {
120
- currentReg.removeEventListener('updatefound', handleUpdateFound);
121
- }
122
- if (trackedWorker && handleStateChange) {
123
- trackedWorker.removeEventListener('statechange', handleStateChange);
124
- }
125
- clearInterval(interval);
126
- };
127
- }, [onUpdate]);
128
- // Component doesn't render UI - toast handles it (industry standard)
129
- return null;
130
- }
131
- export default PWAUpdateNotification;
1
+ "use client";import{RefreshCw as w}from"lucide-react";import{useEffect as m,useRef as d}from"react";import{toast as U,Button as R,ToastAction as C}from"@donotdev/components";import{isClient as r,useTranslation as T}from"@donotdev/core";import{jsx as k}from"react/jsx-runtime";function y({onUpdate:l}){let{t:n}=T("dndev"),s=d(null),a=d(null),f=d(!1);return m(()=>{if(!r()||!("serviceWorker"in navigator))return;let p=!1,v=()=>{p||!r()||(p=!0,window.location.reload())};navigator.serviceWorker.addEventListener("controllerchange",v);let c=null,i=null,u=null,o=null,g=async()=>{if(r())try{let e=await navigator.serviceWorker.ready;s.current=e,c=e,i=()=>{let t=e.installing;t&&(u=t,o=()=>{t.state==="installed"&&navigator.serviceWorker.controller&&!a.current&&h()},t.addEventListener("statechange",o))},e.addEventListener("updatefound",i),e.waiting&&!a.current&&h()}catch{return}},h=()=>{if(!r()||a.current)return;let e=async()=>{!s.current?.waiting||f.current||!r()||(f.current=!0,l&&l(),s.current.waiting.postMessage({type:"SKIP_WAITING"}))},{id:t}=U({title:n("pwa.update.title","Update available"),description:n("pwa.update.description","A new version is ready. Refresh to update."),toastType:"info",duration:0,action:k(C,{asChild:!0,altText:n("pwa.update.altText","Update application"),children:k(R,{onClick:e,icon:w,children:n("pwa.update.button","Update")})})});a.current=t};g();let W=setInterval(g,6e4);return()=>{r()&&"serviceWorker"in navigator&&navigator.serviceWorker.removeEventListener("controllerchange",v),c&&i&&c.removeEventListener("updatefound",i),u&&o&&u.removeEventListener("statechange",o),clearInterval(W)}},[l]),null}var S=y;export{S as default};
@@ -1 +1 @@
1
- {"version":3,"file":"FooterBranding.d.ts","sourceRoot":"","sources":["../../../../../src/internal/layout/components/footer/FooterBranding.tsx"],"names":[],"mappings":"AAeA,MAAM,WAAW,mBAAmB;IAClC,6BAA6B;IAC7B,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,cAAc,EAAE,KAAK,CAAC,aAAa,CAAC,mBAAmB,CA8BnE,CAAC;AAEF,eAAe,cAAc,CAAC"}
1
+ {"version":3,"file":"FooterBranding.d.ts","sourceRoot":"","sources":["../../../../../src/internal/layout/components/footer/FooterBranding.tsx"],"names":[],"mappings":"AAgBA,MAAM,WAAW,mBAAmB;IAClC,6BAA6B;IAC7B,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,cAAc,EAAE,KAAK,CAAC,aAAa,CAAC,mBAAmB,CA8BnE,CAAC;AAEF,eAAe,cAAc,CAAC"}