@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,297 +1 @@
1
- // packages/ui/src/utils/assetResolver.ts
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 v=Object.defineProperty;var u=(n,t,s)=>t in n?v(n,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):n[t]=s;var f=(n,t,s)=>u(n,typeof t!="symbol"?t+"":t,s);import{getDndevConfig as g,isClient as a,isDev as p}from"@donotdev/core";var o=class{static getBrowserSupport(){if(!a())return{svg:!0,webp:!1,avif:!1};let t=this.cache.get("browser-support");if(t)return t;let s={svg:!0,webp:!1,avif:!1};try{let e=document.createElement("canvas");e.width=1,e.height=1,s.webp=e.toDataURL("image/webp").indexOf("data:image/webp")===0}catch{s.webp=!1}try{let e=document.createElement("canvas");e.width=1,e.height=1,s.avif=e.toDataURL("image/avif").indexOf("data:image/avif")===0}catch{s.avif=!1}return this.cache.set("browser-support",s),s}static extractStringValues(t){let s=[];if(t==null)return s;if(typeof t=="string")s.push(t);else if(Array.isArray(t))for(let e of t)s.push(...this.extractStringValues(e));else if(typeof t=="object")for(let e of Object.values(t))s.push(...this.extractStringValues(e));return s}static assetExists(t){if(!a())return!1;let s=this.getAssetManifest();return s?this.extractStringValues(s).includes(t):!1}static getAssetManifest(){return a()&&g()?.assets?.mapping||null}static getLogoSvgContent(){return g()?.assets?.logoSvgContent||null}static resolveLogo(t){if(t)return t;let s="logo";if(this.cache.has(s))return this.cache.get(s);let c=this.getAssetManifest()?.logo?.optimal||"/logo.svg";return this.cache.set(s,c),c}static directAssetCheck(t){if(!a())return!1;try{let s=new Image;return s.src=t,!0}catch{return!1}}static resolveFaviconSet(){let t="favicon-set";if(this.cache.has(t))return this.cache.get(t);let s=this.getAssetManifest();if(s?.favicon?.set){let i=s.favicon.set,r=this.assetExists("/icon-512x512.png")?"/icon-512x512.png":this.assetExists("/icon-192x192.png")?"/icon-192x192.png":"/logo.svg",l={svg:i.svg||"/favicon.svg",ico:i.ico||"/favicon.ico",png16:i.png16||r,png32:i.png32||r,apple180:i.apple180||r,android192:i.android192||r,android512:i.android512||r};return this.cache.set(t,l),l}let e=this.assetExists("/icon-512x512.png")?"/icon-512x512.png":this.assetExists("/icon-192x192.png")?"/icon-192x192.png":"/logo.svg",c={svg:this.assetExists("/favicon.svg")?"/favicon.svg":"/logo.svg",ico:this.assetExists("/favicon.ico")?"/favicon.ico":"/favicon.svg",png16:this.assetExists("/favicon-16x16.png")?"/favicon-16x16.png":e,png32:this.assetExists("/favicon-32x32.png")?"/favicon-32x32.png":e,apple180:this.assetExists("/apple-touch-icon.png")?"/apple-touch-icon.png":e,android192:this.assetExists("/icon-192x192.png")?"/icon-192x192.png":e,android512:this.assetExists("/icon-512x512.png")?"/icon-512x512.png":e};return this.cache.set(t,c),c}static resolveFavicon(){let t=this.getAssetManifest();if(t?.favicon?.optimal)return t.favicon.optimal;let s=["/favicon.svg","/favicon.ico","/favicon.png","/logo.svg"];for(let e of s)if(this.assetExists(e))return e;return"/favicon.svg"}static clearCache(){this.cache.clear(),p()&&a()}static getDebugInfo(){return{browserSupport:this.getBrowserSupport(),detectedAssets:a()?g()?.assets?.mapping:null,assetManifest:this.getAssetManifest(),cache:Object.fromEntries(this.cache)}}};f(o,"cache",new Map);function x(n){return o.resolveLogo(n)}function m(){return o.resolveFaviconSet()}p()&&(o.clearCache(),a()&&window.addEventListener("DOMContentLoaded",()=>{o.clearCache()}));export{o as AssetResolver,m as resolveFaviconSet,x as resolveLogo};
@@ -1,23 +1 @@
1
- // packages/ui/src/utils/index.ts
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";export*from"./useSeo.js";import{buildProductJsonLd as E,deriveEntitySeo as S}from"@donotdev/core";export{E as buildProductJsonLd,S as deriveEntitySeo};
@@ -1,51 +1 @@
1
- // packages/ui/src/utils/sanitizeSvg.ts
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};
@@ -1,42 +1 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
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":"AAgBA,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"}
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"}
@@ -1,53 +1 @@
1
- // packages/ui/src/utils/useAISafe.ts
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":"AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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
+ {"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
- // packages/ui/src/utils/useAuthSafe.ts
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":"AAoBA,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
+ {"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
- // packages/ui/src/utils/useAuthVisibility.ts
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":"AAmBA,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"}
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"}