@revealui/core 0.2.1 → 0.5.0

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 (395) hide show
  1. package/dist/api/compression.d.ts.map +1 -1
  2. package/dist/api/payload-optimization.d.ts.map +1 -1
  3. package/dist/api/rate-limit.d.ts +29 -28
  4. package/dist/api/rate-limit.d.ts.map +1 -1
  5. package/dist/api/rate-limit.js +63 -3
  6. package/dist/api/response-cache.d.ts.map +1 -1
  7. package/dist/api/response-cache.js +1 -1
  8. package/dist/api/rest.d.ts.map +1 -1
  9. package/dist/api/rest.js +3 -2
  10. package/dist/auth/access.d.ts.map +1 -1
  11. package/dist/auth/index.d.ts.map +1 -1
  12. package/dist/cache/query-cache.d.ts +12 -10
  13. package/dist/cache/query-cache.d.ts.map +1 -1
  14. package/dist/cache/query-cache.js +38 -42
  15. package/dist/caching/index.d.ts +6 -0
  16. package/dist/caching/index.d.ts.map +1 -0
  17. package/dist/caching/index.js +5 -0
  18. package/dist/client/admin/RichText.d.ts +1 -1
  19. package/dist/client/admin/RichText.d.ts.map +1 -1
  20. package/dist/client/admin/components/AdminDashboard.d.ts.map +1 -1
  21. package/dist/client/admin/components/AdminDashboard.js +195 -205
  22. package/dist/client/admin/components/CollectionList.d.ts.map +1 -1
  23. package/dist/client/admin/components/DocumentForm.d.ts.map +1 -1
  24. package/dist/client/admin/components/DocumentForm.js +130 -6
  25. package/dist/client/admin/components/GlobalForm.d.ts.map +1 -1
  26. package/dist/client/admin/context/ServerFunctionContext.d.ts +8 -0
  27. package/dist/client/admin/context/ServerFunctionContext.d.ts.map +1 -0
  28. package/dist/client/admin/context/ServerFunctionContext.js +15 -0
  29. package/dist/client/admin/i18n/en.d.ts.map +1 -1
  30. package/dist/client/admin/index.d.ts +1 -0
  31. package/dist/client/admin/index.d.ts.map +1 -1
  32. package/dist/client/admin/index.js +1 -0
  33. package/dist/client/admin/layout.d.ts +1 -1
  34. package/dist/client/admin/layout.d.ts.map +1 -1
  35. package/dist/client/admin/layout.js +3 -2
  36. package/dist/client/admin/page.d.ts.map +1 -1
  37. package/dist/client/admin/utils/apiClient.d.ts.map +1 -1
  38. package/dist/client/admin/utils/apiClient.js +0 -4
  39. package/dist/client/admin/utils/index.d.ts +0 -1
  40. package/dist/client/admin/utils/index.d.ts.map +1 -1
  41. package/dist/client/admin/utils/index.js +0 -1
  42. package/dist/client/admin/utils/serializeConfig.d.ts.map +1 -1
  43. package/dist/client/hooks.d.ts.map +1 -1
  44. package/dist/client/index.d.ts.map +1 -1
  45. package/dist/client/richtext/RichTextEditor.d.ts.map +1 -1
  46. package/dist/client/richtext/components/ImageNodeComponent.d.ts.map +1 -1
  47. package/dist/client/richtext/components/ImageNodeComponent.js +0 -1
  48. package/dist/client/richtext/components/ImageUploadButton.d.ts +2 -0
  49. package/dist/client/richtext/components/ImageUploadButton.d.ts.map +1 -1
  50. package/dist/client/richtext/components/ImageUploadButton.js +30 -15
  51. package/dist/client/richtext/index.d.ts.map +1 -1
  52. package/dist/client/richtext/nodes/DecoratorBlockNode.d.ts.map +1 -1
  53. package/dist/client/richtext/nodes/ImageNode.d.ts.map +1 -1
  54. package/dist/client/richtext/plugins/CollaborationPlugin.d.ts.map +1 -1
  55. package/dist/client/richtext/plugins/CursorsOverlayPlugin.d.ts.map +1 -1
  56. package/dist/client/richtext/plugins/FloatingToolbarPlugin.d.ts.map +1 -1
  57. package/dist/client/richtext/plugins/FloatingToolbarPlugin.js +1 -3
  58. package/dist/client/richtext/plugins/ImagePlugin.d.ts.map +1 -1
  59. package/dist/client/richtext/plugins/ToolbarPlugin.d.ts.map +1 -1
  60. package/dist/client/ui/index.d.ts.map +1 -1
  61. package/dist/client/ui/index.js +1 -1
  62. package/dist/collections/CollectionOperations.d.ts +7 -7
  63. package/dist/collections/CollectionOperations.d.ts.map +1 -1
  64. package/dist/collections/CollectionOperations.js +15 -1
  65. package/dist/collections/hooks.d.ts.map +1 -1
  66. package/dist/collections/index.d.ts.map +1 -1
  67. package/dist/collections/operations/create.d.ts +4 -5
  68. package/dist/collections/operations/create.d.ts.map +1 -1
  69. package/dist/collections/operations/create.js +35 -6
  70. package/dist/collections/operations/createMany.d.ts +12 -0
  71. package/dist/collections/operations/createMany.d.ts.map +1 -0
  72. package/dist/collections/operations/createMany.js +43 -0
  73. package/dist/collections/operations/delete.d.ts +1 -1
  74. package/dist/collections/operations/delete.d.ts.map +1 -1
  75. package/dist/collections/operations/delete.js +31 -2
  76. package/dist/collections/operations/deleteMany.d.ts +11 -0
  77. package/dist/collections/operations/deleteMany.d.ts.map +1 -0
  78. package/dist/collections/operations/deleteMany.js +50 -0
  79. package/dist/collections/operations/fieldHooks.d.ts +2 -2
  80. package/dist/collections/operations/fieldHooks.d.ts.map +1 -1
  81. package/dist/collections/operations/fieldHooks.js +4 -4
  82. package/dist/collections/operations/find.d.ts +2 -4
  83. package/dist/collections/operations/find.d.ts.map +1 -1
  84. package/dist/collections/operations/find.js +115 -8
  85. package/dist/collections/operations/findById.d.ts +3 -4
  86. package/dist/collections/operations/findById.d.ts.map +1 -1
  87. package/dist/collections/operations/findById.js +53 -1
  88. package/dist/collections/operations/sqlAdapter.d.ts +23 -0
  89. package/dist/collections/operations/sqlAdapter.d.ts.map +1 -0
  90. package/dist/collections/operations/sqlAdapter.js +76 -0
  91. package/dist/collections/operations/update.d.ts +3 -5
  92. package/dist/collections/operations/update.d.ts.map +1 -1
  93. package/dist/collections/operations/update.js +103 -11
  94. package/dist/collections/operations/updateMany.d.ts +11 -0
  95. package/dist/collections/operations/updateMany.d.ts.map +1 -0
  96. package/dist/collections/operations/updateMany.js +52 -0
  97. package/dist/collections/registry.d.ts +12 -0
  98. package/dist/collections/registry.d.ts.map +1 -0
  99. package/dist/collections/registry.js +38 -0
  100. package/dist/config/index.d.ts.map +1 -1
  101. package/dist/config/runtime.d.ts.map +1 -1
  102. package/dist/config/utils.d.ts +0 -10
  103. package/dist/config/utils.d.ts.map +1 -1
  104. package/dist/config/utils.js +0 -13
  105. package/dist/database/index.d.ts +3 -0
  106. package/dist/database/index.d.ts.map +1 -1
  107. package/dist/database/index.js +1 -5
  108. package/dist/database/safe-parse.d.ts.map +1 -1
  109. package/dist/database/ssl-config.d.ts.map +1 -1
  110. package/dist/database/type-adapter.d.ts.map +1 -1
  111. package/dist/database/universal-postgres.d.ts.map +1 -1
  112. package/dist/database/universal-postgres.js +6 -1
  113. package/dist/dataloader.d.ts.map +1 -1
  114. package/dist/error-handling/error-boundary.d.ts.map +1 -1
  115. package/dist/error-handling/error-reporter.d.ts +1 -1
  116. package/dist/error-handling/error-reporter.d.ts.map +1 -1
  117. package/dist/error-handling/error-reporter.js +19 -5
  118. package/dist/error-handling/fallback-components.d.ts.map +1 -1
  119. package/dist/error-handling/fallback-components.js +1 -1
  120. package/dist/error-handling/index.d.ts +2 -4
  121. package/dist/error-handling/index.d.ts.map +1 -1
  122. package/dist/error-handling/index.js +1 -4
  123. package/dist/factories/builders.d.ts.map +1 -1
  124. package/dist/factories/index.d.ts.map +1 -1
  125. package/dist/features.d.ts +7 -7
  126. package/dist/features.d.ts.map +1 -1
  127. package/dist/features.js +2 -2
  128. package/dist/fieldTraversal.d.ts.map +1 -1
  129. package/dist/fields/config/types.d.ts.map +1 -1
  130. package/dist/fields/getDefaultValue.d.ts.map +1 -1
  131. package/dist/fields/getFieldPaths.d.ts.map +1 -1
  132. package/dist/fields/hooks/afterRead/index.d.ts.map +1 -1
  133. package/dist/fields/hooks/afterRead/promise.d.ts.map +1 -1
  134. package/dist/fields/hooks/afterRead/traverseFields.d.ts.map +1 -1
  135. package/dist/generated/types/cms.d.ts.map +1 -1
  136. package/dist/generated/types/cms.js +0 -1
  137. package/dist/generated/types/neon.d.ts.map +1 -1
  138. package/dist/generated/types/neon.js +4 -2
  139. package/dist/globals/GlobalOperations.d.ts.map +1 -1
  140. package/dist/globals/GlobalOperations.js +16 -4
  141. package/dist/globals/index.d.ts.map +1 -1
  142. package/dist/index.d.ts +15 -4
  143. package/dist/index.d.ts.map +1 -1
  144. package/dist/index.js +15 -5
  145. package/dist/instance/RevealUIInstance.d.ts.map +1 -1
  146. package/dist/instance/RevealUIInstance.js +6 -19
  147. package/dist/instance/index.d.ts.map +1 -1
  148. package/dist/instance/logger.d.ts.map +1 -1
  149. package/dist/instance/methods/create.d.ts.map +1 -1
  150. package/dist/instance/methods/create.js +0 -3
  151. package/dist/instance/methods/delete.d.ts.map +1 -1
  152. package/dist/instance/methods/delete.js +1 -4
  153. package/dist/instance/methods/find.d.ts.map +1 -1
  154. package/dist/instance/methods/find.js +0 -3
  155. package/dist/instance/methods/findById.d.ts.map +1 -1
  156. package/dist/instance/methods/findById.js +0 -3
  157. package/dist/instance/methods/hooks.d.ts.map +1 -1
  158. package/dist/instance/methods/update.d.ts.map +1 -1
  159. package/dist/instance/methods/update.js +0 -3
  160. package/dist/jobs/index.d.ts +16 -0
  161. package/dist/jobs/index.d.ts.map +1 -0
  162. package/dist/jobs/index.js +14 -0
  163. package/dist/jobs/queue.d.ts +57 -0
  164. package/dist/jobs/queue.d.ts.map +1 -0
  165. package/dist/jobs/queue.js +134 -0
  166. package/dist/license-encryption.d.ts +21 -0
  167. package/dist/license-encryption.d.ts.map +1 -0
  168. package/dist/license-encryption.js +74 -0
  169. package/dist/license.d.ts +26 -3
  170. package/dist/license.d.ts.map +1 -1
  171. package/dist/license.js +87 -7
  172. package/dist/monitoring/alerts.d.ts +4 -4
  173. package/dist/monitoring/alerts.d.ts.map +1 -1
  174. package/dist/monitoring/cleanup-manager.d.ts.map +1 -1
  175. package/dist/monitoring/health-monitor.d.ts.map +1 -1
  176. package/dist/monitoring/index.d.ts.map +1 -1
  177. package/dist/monitoring/process-registry.d.ts.map +1 -1
  178. package/dist/monitoring/query-monitor.d.ts.map +1 -1
  179. package/dist/monitoring/types.d.ts.map +1 -1
  180. package/dist/monitoring/zombie-detector.d.ts.map +1 -1
  181. package/dist/monitoring/zombie-detector.js +5 -0
  182. package/dist/nextjs/index.d.ts.map +1 -1
  183. package/dist/nextjs/utilities.d.ts.map +1 -1
  184. package/dist/nextjs/withRevealUI.d.ts.map +1 -1
  185. package/dist/observability/alerts.d.ts.map +1 -1
  186. package/dist/observability/alerts.js +1 -2
  187. package/dist/observability/health-check.d.ts +0 -4
  188. package/dist/observability/health-check.d.ts.map +1 -1
  189. package/dist/observability/health-check.js +0 -36
  190. package/dist/observability/index.d.ts.map +1 -1
  191. package/dist/observability/logger.d.ts.map +1 -1
  192. package/dist/observability/logger.js +1 -1
  193. package/dist/observability/metrics.d.ts.map +1 -1
  194. package/dist/observability/tracing.d.ts.map +1 -1
  195. package/dist/observability/tracing.js +0 -1
  196. package/dist/plugins/form-builder.d.ts.map +1 -1
  197. package/dist/plugins/index.d.ts.map +1 -1
  198. package/dist/plugins/nested-docs.d.ts +4 -0
  199. package/dist/plugins/nested-docs.d.ts.map +1 -1
  200. package/dist/plugins/nested-docs.js +50 -6
  201. package/dist/plugins/redirects.d.ts.map +1 -1
  202. package/dist/queries/index.d.ts.map +1 -1
  203. package/dist/queries/queryBuilder.d.ts.map +1 -1
  204. package/dist/queries/queryBuilder.js +13 -5
  205. package/dist/relationships/analyzer.d.ts.map +1 -1
  206. package/dist/relationships/analyzer.js +8 -0
  207. package/dist/relationships/index.d.ts.map +1 -1
  208. package/dist/relationships/populate-core.d.ts +57 -0
  209. package/dist/relationships/populate-core.d.ts.map +1 -0
  210. package/dist/relationships/populate-core.js +116 -0
  211. package/dist/relationships/populate-helpers.d.ts +5 -51
  212. package/dist/relationships/populate-helpers.d.ts.map +1 -1
  213. package/dist/relationships/populate-helpers.js +4 -109
  214. package/dist/relationships/population.d.ts +1 -9
  215. package/dist/relationships/population.d.ts.map +1 -1
  216. package/dist/relationships/population.js +8 -3
  217. package/dist/revealui.d.ts.map +1 -1
  218. package/dist/richtext/exports/client/rcc.d.ts.map +1 -1
  219. package/dist/richtext/exports/client/rcc.js +1 -1
  220. package/dist/richtext/exports/server/rsc.d.ts +17 -0
  221. package/dist/richtext/exports/server/rsc.d.ts.map +1 -1
  222. package/dist/richtext/exports/server/rsc.js +61 -5
  223. package/dist/richtext/index.d.ts.map +1 -1
  224. package/dist/richtext/lexical.d.ts.map +1 -1
  225. package/dist/security/index.d.ts +3 -16
  226. package/dist/security/index.d.ts.map +1 -1
  227. package/dist/security/index.js +3 -16
  228. package/dist/server/index.d.ts.map +1 -1
  229. package/dist/server/renderPage.d.ts.map +1 -1
  230. package/dist/storage/index.d.ts +1 -0
  231. package/dist/storage/index.d.ts.map +1 -1
  232. package/dist/storage/index.js +2 -4
  233. package/dist/storage/vercel-blob.d.ts.map +1 -1
  234. package/dist/storage/vercel-blob.js +3 -0
  235. package/dist/translations/index.d.ts.map +1 -1
  236. package/dist/types/access.d.ts.map +1 -1
  237. package/dist/types/api.d.ts.map +1 -1
  238. package/dist/types/cms.d.ts.map +1 -1
  239. package/dist/types/config.d.ts.map +1 -1
  240. package/dist/types/core.d.ts +1 -1
  241. package/dist/types/core.d.ts.map +1 -1
  242. package/dist/types/extensions.d.ts.map +1 -1
  243. package/dist/types/frontend.d.ts.map +1 -1
  244. package/dist/types/generated.d.ts.map +1 -1
  245. package/dist/types/hooks.d.ts.map +1 -1
  246. package/dist/types/index.d.ts +1 -1
  247. package/dist/types/index.d.ts.map +1 -1
  248. package/dist/types/interfaces/app.d.ts.map +1 -1
  249. package/dist/types/jobs.d.ts.map +1 -1
  250. package/dist/types/legacy.d.ts.map +1 -1
  251. package/dist/types/plugins.d.ts.map +1 -1
  252. package/dist/types/query.d.ts.map +1 -1
  253. package/dist/types/request.d.ts.map +1 -1
  254. package/dist/types/richtext.d.ts.map +1 -1
  255. package/dist/types/runtime.d.ts +60 -1
  256. package/dist/types/runtime.d.ts.map +1 -1
  257. package/dist/types/schema.d.ts.map +1 -1
  258. package/dist/types/user.d.ts.map +1 -1
  259. package/dist/utils/access-conversion.d.ts.map +1 -1
  260. package/dist/utils/api-wrapper.d.ts.map +1 -1
  261. package/dist/utils/api-wrapper.js +1 -1
  262. package/dist/utils/block-conversion.d.ts.map +1 -1
  263. package/dist/utils/cache.d.ts.map +1 -1
  264. package/dist/utils/deep-clone.js +0 -1
  265. package/dist/utils/error-responses.d.ts.map +1 -1
  266. package/dist/utils/error-responses.js +2 -3
  267. package/dist/utils/errors.d.ts +36 -0
  268. package/dist/utils/errors.d.ts.map +1 -1
  269. package/dist/utils/errors.js +103 -0
  270. package/dist/utils/field-conversion.d.ts +1 -1
  271. package/dist/utils/field-conversion.d.ts.map +1 -1
  272. package/dist/utils/flattenResult.d.ts.map +1 -1
  273. package/dist/utils/flattenResult.js +0 -1
  274. package/dist/utils/getBlockSelect.d.ts.map +1 -1
  275. package/dist/utils/getSelectMode.d.ts.map +1 -1
  276. package/dist/utils/isValidID.d.ts.map +1 -1
  277. package/dist/utils/json-parsing.d.ts.map +1 -1
  278. package/dist/utils/logger-client.d.ts.map +1 -1
  279. package/dist/utils/logger-server.d.ts.map +1 -1
  280. package/dist/utils/logger.d.ts.map +1 -1
  281. package/dist/utils/request-context.d.ts.map +1 -1
  282. package/dist/utils/stripUnselectedFields.d.ts.map +1 -1
  283. package/dist/utils/type-guards.d.ts.map +1 -1
  284. package/package.json +58 -26
  285. package/dist/caching/app-cache.d.ts +0 -237
  286. package/dist/caching/app-cache.d.ts.map +0 -1
  287. package/dist/caching/app-cache.js +0 -430
  288. package/dist/caching/cdn-config.d.ts +0 -155
  289. package/dist/caching/cdn-config.d.ts.map +0 -1
  290. package/dist/caching/cdn-config.js +0 -411
  291. package/dist/caching/edge-cache.d.ts +0 -177
  292. package/dist/caching/edge-cache.d.ts.map +0 -1
  293. package/dist/caching/edge-cache.js +0 -385
  294. package/dist/caching/service-worker.d.ts +0 -154
  295. package/dist/caching/service-worker.d.ts.map +0 -1
  296. package/dist/caching/service-worker.js +0 -437
  297. package/dist/client/admin/utils/auth.d.ts +0 -23
  298. package/dist/client/admin/utils/auth.d.ts.map +0 -1
  299. package/dist/client/admin/utils/auth.js +0 -52
  300. package/dist/client/http/client.d.ts +0 -15
  301. package/dist/client/http/client.d.ts.map +0 -1
  302. package/dist/client/http/client.js +0 -49
  303. package/dist/client/http/fetchBanner.d.ts +0 -18
  304. package/dist/client/http/fetchBanner.d.ts.map +0 -1
  305. package/dist/client/http/fetchBanner.js +0 -44
  306. package/dist/client/http/fetchCard.d.ts +0 -18
  307. package/dist/client/http/fetchCard.d.ts.map +0 -1
  308. package/dist/client/http/fetchCard.js +0 -46
  309. package/dist/client/http/fetchEvents.d.ts +0 -18
  310. package/dist/client/http/fetchEvents.d.ts.map +0 -1
  311. package/dist/client/http/fetchEvents.js +0 -44
  312. package/dist/client/http/fetchHero.d.ts +0 -17
  313. package/dist/client/http/fetchHero.d.ts.map +0 -1
  314. package/dist/client/http/fetchHero.js +0 -55
  315. package/dist/client/http/fetchMainInfos.d.ts +0 -17
  316. package/dist/client/http/fetchMainInfos.d.ts.map +0 -1
  317. package/dist/client/http/fetchMainInfos.js +0 -44
  318. package/dist/client/http/fetchVideos.d.ts +0 -13
  319. package/dist/client/http/fetchVideos.d.ts.map +0 -1
  320. package/dist/client/http/fetchVideos.js +0 -36
  321. package/dist/client/http/index.d.ts +0 -19
  322. package/dist/client/http/index.d.ts.map +0 -1
  323. package/dist/client/http/index.js +0 -11
  324. package/dist/error-handling/circuit-breaker.d.ts +0 -262
  325. package/dist/error-handling/circuit-breaker.d.ts.map +0 -1
  326. package/dist/error-handling/circuit-breaker.js +0 -542
  327. package/dist/error-handling/retry.d.ts +0 -194
  328. package/dist/error-handling/retry.d.ts.map +0 -1
  329. package/dist/error-handling/retry.js +0 -450
  330. package/dist/errors/index.d.ts +0 -23
  331. package/dist/errors/index.d.ts.map +0 -1
  332. package/dist/errors/index.js +0 -40
  333. package/dist/generated/agents/index.d.ts +0 -8
  334. package/dist/generated/agents/index.d.ts.map +0 -1
  335. package/dist/generated/agents/index.js +0 -7
  336. package/dist/generated/components/index.d.ts +0 -8
  337. package/dist/generated/components/index.d.ts.map +0 -1
  338. package/dist/generated/components/index.js +0 -7
  339. package/dist/generated/functions/index.d.ts +0 -8
  340. package/dist/generated/functions/index.d.ts.map +0 -1
  341. package/dist/generated/functions/index.js +0 -7
  342. package/dist/generated/hooks/index.d.ts +0 -8
  343. package/dist/generated/hooks/index.d.ts.map +0 -1
  344. package/dist/generated/hooks/index.js +0 -7
  345. package/dist/generated/plans/index.d.ts +0 -8
  346. package/dist/generated/plans/index.d.ts.map +0 -1
  347. package/dist/generated/plans/index.js +0 -7
  348. package/dist/generated/prompts/index.d.ts +0 -8
  349. package/dist/generated/prompts/index.d.ts.map +0 -1
  350. package/dist/generated/prompts/index.js +0 -7
  351. package/dist/generated/tools/index.d.ts +0 -8
  352. package/dist/generated/tools/index.d.ts.map +0 -1
  353. package/dist/generated/tools/index.js +0 -7
  354. package/dist/generated/types/supabase.d.ts +0 -193
  355. package/dist/generated/types/supabase.d.ts.map +0 -1
  356. package/dist/generated/types/supabase.js +0 -5
  357. package/dist/optimization/asset-optimizer.d.ts +0 -202
  358. package/dist/optimization/asset-optimizer.d.ts.map +0 -1
  359. package/dist/optimization/asset-optimizer.js +0 -312
  360. package/dist/optimization/build-optimizer.d.ts +0 -202
  361. package/dist/optimization/build-optimizer.d.ts.map +0 -1
  362. package/dist/optimization/build-optimizer.js +0 -271
  363. package/dist/optimization/bundle-analyzer.d.ts +0 -98
  364. package/dist/optimization/bundle-analyzer.d.ts.map +0 -1
  365. package/dist/optimization/bundle-analyzer.js +0 -322
  366. package/dist/optimization/code-splitting.d.ts +0 -131
  367. package/dist/optimization/code-splitting.d.ts.map +0 -1
  368. package/dist/optimization/code-splitting.js +0 -277
  369. package/dist/plugin/index.d.ts +0 -12
  370. package/dist/plugin/index.d.ts.map +0 -1
  371. package/dist/plugin/index.js +0 -4
  372. package/dist/security/audit.d.ts +0 -188
  373. package/dist/security/audit.d.ts.map +0 -1
  374. package/dist/security/audit.js +0 -431
  375. package/dist/security/auth.d.ts +0 -241
  376. package/dist/security/auth.d.ts.map +0 -1
  377. package/dist/security/auth.js +0 -476
  378. package/dist/security/authorization.d.ts +0 -235
  379. package/dist/security/authorization.d.ts.map +0 -1
  380. package/dist/security/authorization.js +0 -434
  381. package/dist/security/encryption.d.ts +0 -214
  382. package/dist/security/encryption.d.ts.map +0 -1
  383. package/dist/security/encryption.js +0 -517
  384. package/dist/security/gdpr.d.ts +0 -300
  385. package/dist/security/gdpr.d.ts.map +0 -1
  386. package/dist/security/gdpr.js +0 -465
  387. package/dist/security/headers.d.ts +0 -182
  388. package/dist/security/headers.d.ts.map +0 -1
  389. package/dist/security/headers.js +0 -402
  390. package/dist/utils/jwt-validation.d.ts +0 -14
  391. package/dist/utils/jwt-validation.d.ts.map +0 -1
  392. package/dist/utils/jwt-validation.js +0 -36
  393. package/dist/utils/request-headers.d.ts +0 -15
  394. package/dist/utils/request-headers.d.ts.map +0 -1
  395. package/dist/utils/request-headers.js +0 -31
@@ -1,271 +0,0 @@
1
- /**
2
- * Build Performance Optimization
3
- *
4
- * Utilities for optimizing build performance and configuration
5
- */
6
- export const DEFAULT_NEXT_CONFIG = {
7
- compiler: {
8
- removeConsole: {
9
- exclude: ['error', 'warn'],
10
- },
11
- },
12
- swcMinify: true,
13
- outputFileTracing: true,
14
- experimental: {
15
- optimizeCss: true,
16
- optimizePackageImports: ['lodash', 'date-fns', 'recharts', '@radix-ui/react-icons'],
17
- },
18
- productionBrowserSourceMaps: false,
19
- generateEtags: true,
20
- poweredByHeader: false,
21
- compress: true,
22
- };
23
- export const DEFAULT_WEBPACK_CONFIG = {
24
- minimize: true,
25
- splitChunks: {
26
- chunks: 'all',
27
- minSize: 20000,
28
- maxSize: 244000,
29
- minChunks: 1,
30
- maxAsyncRequests: 30,
31
- maxInitialRequests: 30,
32
- cacheGroups: {
33
- defaultVendors: {
34
- test: /[\\/]node_modules[\\/]/,
35
- priority: -10,
36
- reuseExistingChunk: true,
37
- },
38
- default: {
39
- minChunks: 2,
40
- priority: -20,
41
- reuseExistingChunk: true,
42
- },
43
- },
44
- },
45
- runtimeChunk: 'single',
46
- moduleIds: 'deterministic',
47
- chunkIds: 'deterministic',
48
- concatenateModules: true,
49
- usedExports: true,
50
- sideEffects: true,
51
- providedExports: true,
52
- innerGraph: true,
53
- };
54
- export const DEFAULT_TURBOPACK_CONFIG = {
55
- resolveExtensions: ['.tsx', '.ts', '.jsx', '.js', '.json'],
56
- resolveAlias: {
57
- '@': './src',
58
- '@components': './src/components',
59
- '@lib': './src/lib',
60
- '@utils': './src/utils',
61
- },
62
- };
63
- export const DEFAULT_CACHE_CONFIG = {
64
- type: 'filesystem',
65
- cacheDirectory: '.next/cache',
66
- compression: 'gzip',
67
- maxAge: 1000 * 60 * 60 * 24 * 7, // 1 week
68
- };
69
- export const DEFAULT_TREE_SHAKING_CONFIG = {
70
- usedExports: true,
71
- sideEffects: true,
72
- providedExports: true,
73
- innerGraph: true,
74
- mangleExports: true,
75
- };
76
- /**
77
- * Generate package.json sideEffects field
78
- */
79
- export function generateSideEffectsConfig(includeCSS = true) {
80
- if (!includeCSS) {
81
- return false;
82
- }
83
- return ['*.css', '*.scss', '*.sass', '*.less'];
84
- }
85
- export const DEFAULT_MODULE_RESOLUTION = {
86
- extensions: ['.tsx', '.ts', '.jsx', '.js', '.json'],
87
- alias: {
88
- '@': './src',
89
- '@components': './src/components',
90
- '@lib': './src/lib',
91
- '@utils': './src/utils',
92
- '@hooks': './src/hooks',
93
- '@types': './src/types',
94
- },
95
- modules: ['node_modules'],
96
- symlinks: true,
97
- fullySpecified: false,
98
- };
99
- export const DEFAULT_PARALLEL_CONFIG = {
100
- parallel: true,
101
- cache: true,
102
- threads: 4,
103
- };
104
- export const DEFAULT_PERFORMANCE_CONFIG = {
105
- hints: 'warning',
106
- maxEntrypointSize: 250000, // 250KB
107
- maxAssetSize: 250000,
108
- assetFilter: (assetFilename) => {
109
- return !assetFilename.endsWith('.map');
110
- },
111
- };
112
- /**
113
- * Analyze build performance
114
- */
115
- export function analyzeBuildPerformance(stats) {
116
- const issues = [];
117
- let score = 100;
118
- // Check build duration
119
- if (stats.duration > 60000) {
120
- issues.push({
121
- type: 'warning',
122
- message: `Build time (${(stats.duration / 1000).toFixed(1)}s) is slow. Consider parallel builds.`,
123
- });
124
- score -= 10;
125
- }
126
- // Check output size
127
- if (stats.outputSize > 1024 * 1024) {
128
- issues.push({
129
- type: 'warning',
130
- message: `Output size (${(stats.outputSize / 1024 / 1024).toFixed(1)}MB) is large. Consider code splitting.`,
131
- });
132
- score -= 15;
133
- }
134
- // Check for large assets
135
- const largeAssets = stats.assets.filter((a) => a.size > 250000);
136
- if (largeAssets.length > 0) {
137
- issues.push({
138
- type: 'warning',
139
- message: `${largeAssets.length} assets exceed 250KB. Consider optimization.`,
140
- });
141
- score -= 10;
142
- }
143
- // Check for errors
144
- if (stats.errors.length > 0) {
145
- issues.push({
146
- type: 'error',
147
- message: `${stats.errors.length} build errors found.`,
148
- });
149
- score -= 30;
150
- }
151
- // Check for warnings
152
- if (stats.warnings.length > 5) {
153
- issues.push({
154
- type: 'warning',
155
- message: `${stats.warnings.length} build warnings found.`,
156
- });
157
- score -= 5;
158
- }
159
- return {
160
- score: Math.max(0, score),
161
- issues,
162
- };
163
- }
164
- /**
165
- * Generate tsconfig for optimal builds
166
- */
167
- export function generateOptimizedTSConfig() {
168
- return {
169
- compilerOptions: {
170
- target: 'ES2020',
171
- lib: ['ES2020', 'DOM', 'DOM.Iterable'],
172
- module: 'ESNext',
173
- moduleResolution: 'bundler',
174
- resolveJsonModule: true,
175
- isolatedModules: true,
176
- jsx: 'preserve',
177
- incremental: true,
178
- strict: true,
179
- esModuleInterop: true,
180
- skipLibCheck: true,
181
- forceConsistentCasingInFileNames: true,
182
- noEmit: true,
183
- paths: {
184
- '@/*': ['./src/*'],
185
- '@components/*': ['./src/components/*'],
186
- '@lib/*': ['./src/lib/*'],
187
- '@utils/*': ['./src/utils/*'],
188
- },
189
- },
190
- };
191
- }
192
- export function shouldPrebuildDependency(packageName, config = {}) {
193
- const { include = [], exclude = [] } = config;
194
- if (exclude.includes(packageName)) {
195
- return false;
196
- }
197
- if (include.length > 0) {
198
- return include.includes(packageName);
199
- }
200
- // Prebuild large, stable dependencies by default
201
- const prebuildByDefault = ['react', 'react-dom', 'lodash', 'date-fns', 'zod', '@radix-ui'];
202
- return prebuildByDefault.some((pkg) => packageName.startsWith(pkg));
203
- }
204
- export class BuildProfiler {
205
- profiles = new Map();
206
- stack = [];
207
- start(name) {
208
- const profile = {
209
- name,
210
- startTime: Date.now(),
211
- children: [],
212
- };
213
- if (this.stack.length > 0) {
214
- const parentName = this.stack[this.stack.length - 1];
215
- if (parentName) {
216
- const parent = this.profiles.get(parentName);
217
- if (parent) {
218
- parent.children.push(profile);
219
- }
220
- }
221
- }
222
- this.profiles.set(name, profile);
223
- this.stack.push(name);
224
- }
225
- end(name) {
226
- const profile = this.profiles.get(name);
227
- if (profile) {
228
- profile.endTime = Date.now();
229
- profile.duration = profile.endTime - profile.startTime;
230
- }
231
- const index = this.stack.indexOf(name);
232
- if (index !== -1) {
233
- this.stack.splice(index, 1);
234
- }
235
- }
236
- getProfile(name) {
237
- return this.profiles.get(name);
238
- }
239
- getAllProfiles() {
240
- return Array.from(this.profiles.values()).filter((p) => p.endTime !== undefined);
241
- }
242
- getSlowestProfiles(limit = 10) {
243
- return this.getAllProfiles()
244
- .sort((a, b) => (b.duration || 0) - (a.duration || 0))
245
- .slice(0, limit);
246
- }
247
- reset() {
248
- this.profiles.clear();
249
- this.stack = [];
250
- }
251
- }
252
- /**
253
- * Build optimization recommendations
254
- */
255
- export function getBuildOptimizationRecommendations(stats) {
256
- const recommendations = [];
257
- if (stats.duration > 30000) {
258
- recommendations.push('Enable parallel builds with --parallel flag', 'Use build cache with filesystem caching', 'Consider using Turbopack for faster builds');
259
- }
260
- if (stats.outputSize > 500000) {
261
- recommendations.push('Enable code splitting for better chunking', 'Use dynamic imports for large components', 'Enable tree shaking in production');
262
- }
263
- const largeAssets = stats.assets.filter((a) => a.size > 250000);
264
- if (largeAssets.length > 0) {
265
- recommendations.push('Compress large assets with gzip/brotli', 'Optimize images using next/image', 'Split large vendor bundles');
266
- }
267
- if (stats.chunks.length > 100) {
268
- recommendations.push('Too many chunks - adjust splitChunks configuration', 'Increase minSize and minChunks thresholds');
269
- }
270
- return recommendations;
271
- }
@@ -1,98 +0,0 @@
1
- /**
2
- * Bundle Analyzer
3
- *
4
- * Analyzes bundle size, dependencies, and optimization opportunities
5
- */
6
- export interface BundleStats {
7
- totalSize: number;
8
- gzipSize?: number;
9
- files: BundleFile[];
10
- chunks: BundleChunk[];
11
- dependencies: DependencyStats[];
12
- duplicates: DuplicateModule[];
13
- largeFiles: BundleFile[];
14
- }
15
- export interface BundleFile {
16
- path: string;
17
- size: number;
18
- gzipSize?: number;
19
- type: string;
20
- relativeSize: number;
21
- }
22
- export interface BundleChunk {
23
- name: string;
24
- size: number;
25
- files: string[];
26
- dependencies: string[];
27
- }
28
- export interface DependencyStats {
29
- name: string;
30
- version: string;
31
- size: number;
32
- instances: number;
33
- treeshakeable: boolean;
34
- }
35
- export interface DuplicateModule {
36
- name: string;
37
- versions: string[];
38
- totalSize: number;
39
- locations: string[];
40
- }
41
- /**
42
- * Analyze bundle directory
43
- */
44
- export declare function analyzeBundleDirectory(bundlePath: string): BundleStats;
45
- /**
46
- * Format file size
47
- */
48
- export declare function formatSize(bytes: number): string;
49
- /**
50
- * Analyze webpack stats
51
- */
52
- export declare function analyzeWebpackStats(statsPath: string): BundleStats;
53
- /**
54
- * Find duplicate dependencies
55
- */
56
- export declare function findDuplicateDependencies(_stats: BundleStats): DuplicateModule[];
57
- /**
58
- * Get optimization suggestions
59
- */
60
- export interface OptimizationSuggestion {
61
- type: 'bundle-split' | 'tree-shaking' | 'dynamic-import' | 'compression' | 'dependency';
62
- severity: 'critical' | 'warning' | 'info';
63
- message: string;
64
- potentialSavings?: number;
65
- file?: string;
66
- }
67
- export declare function getOptimizationSuggestions(stats: BundleStats): OptimizationSuggestion[];
68
- /**
69
- * Generate bundle report
70
- */
71
- export declare function generateBundleReport(stats: BundleStats): string;
72
- /**
73
- * Compare two bundle stats
74
- */
75
- export interface BundleComparison {
76
- sizeDiff: number;
77
- sizeChangePercent: number;
78
- filesAdded: number;
79
- filesRemoved: number;
80
- filesChanged: number;
81
- newLargeFiles: BundleFile[];
82
- improvements: string[];
83
- regressions: string[];
84
- }
85
- export declare function compareBundles(before: BundleStats, after: BundleStats): BundleComparison;
86
- /**
87
- * Get bundle health score (0-100)
88
- */
89
- export declare function getBundleHealthScore(stats: BundleStats): {
90
- score: number;
91
- factors: Array<{
92
- name: string;
93
- score: number;
94
- weight: number;
95
- reason: string;
96
- }>;
97
- };
98
- //# sourceMappingURL=bundle-analyzer.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"bundle-analyzer.d.ts","sourceRoot":"","sources":["../../src/optimization/bundle-analyzer.ts"],"names":[],"mappings":"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"}
@@ -1,322 +0,0 @@
1
- /**
2
- * Bundle Analyzer
3
- *
4
- * Analyzes bundle size, dependencies, and optimization opportunities
5
- */
6
- import { readdirSync, readFileSync, statSync } from 'node:fs';
7
- import { extname, join, relative } from 'node:path';
8
- /**
9
- * Analyze bundle directory
10
- */
11
- export function analyzeBundleDirectory(bundlePath) {
12
- const files = [];
13
- let totalSize = 0;
14
- // Recursively scan directory
15
- function scanDirectory(dir) {
16
- const entries = readdirSync(dir, { withFileTypes: true });
17
- for (const entry of entries) {
18
- const fullPath = join(dir, entry.name);
19
- if (entry.isDirectory()) {
20
- scanDirectory(fullPath);
21
- }
22
- else if (entry.isFile()) {
23
- const stats = statSync(fullPath);
24
- const relativePath = relative(bundlePath, fullPath);
25
- const ext = extname(entry.name);
26
- files.push({
27
- path: relativePath,
28
- size: stats.size,
29
- type: ext,
30
- relativeSize: 0, // Will calculate after total
31
- });
32
- totalSize += stats.size;
33
- }
34
- }
35
- }
36
- scanDirectory(bundlePath);
37
- // Calculate relative sizes
38
- for (const file of files) {
39
- file.relativeSize = (file.size / totalSize) * 100;
40
- }
41
- // Find large files (>100KB)
42
- const largeFiles = files.filter((f) => f.size > 100 * 1024).sort((a, b) => b.size - a.size);
43
- return {
44
- totalSize,
45
- files,
46
- chunks: [], // Would need webpack stats for this
47
- dependencies: [],
48
- duplicates: [],
49
- largeFiles,
50
- };
51
- }
52
- /**
53
- * Format file size
54
- */
55
- export function formatSize(bytes) {
56
- if (bytes < 1024)
57
- return `${bytes} B`;
58
- if (bytes < 1024 * 1024)
59
- return `${(bytes / 1024).toFixed(2)} KB`;
60
- return `${(bytes / (1024 * 1024)).toFixed(2)} MB`;
61
- }
62
- /**
63
- * Analyze webpack stats
64
- */
65
- export function analyzeWebpackStats(statsPath) {
66
- const statsJson = JSON.parse(readFileSync(statsPath, 'utf-8'));
67
- const files = [];
68
- const chunks = [];
69
- const dependencies = new Map();
70
- let totalSize = 0;
71
- // Process assets
72
- if (statsJson.assets) {
73
- for (const asset of statsJson.assets) {
74
- files.push({
75
- path: asset.name,
76
- size: asset.size,
77
- type: extname(asset.name),
78
- relativeSize: 0,
79
- });
80
- totalSize += asset.size;
81
- }
82
- }
83
- // Calculate relative sizes
84
- for (const file of files) {
85
- file.relativeSize = (file.size / totalSize) * 100;
86
- }
87
- // Process chunks
88
- if (statsJson.chunks) {
89
- for (const chunk of statsJson.chunks) {
90
- chunks.push({
91
- name: chunk.names?.[0] || chunk.id,
92
- size: chunk.size,
93
- files: chunk.files || [],
94
- dependencies: [],
95
- });
96
- }
97
- }
98
- // Process modules for dependencies
99
- if (statsJson.modules) {
100
- for (const module of statsJson.modules) {
101
- const match = module.name?.match(/node_modules\/(@?[^/]+\/[^/]+|@?[^/]+)/);
102
- if (match) {
103
- const pkgName = match[1];
104
- const existing = dependencies.get(pkgName);
105
- if (existing) {
106
- existing.instances++;
107
- existing.size += module.size || 0;
108
- }
109
- else {
110
- dependencies.set(pkgName, {
111
- name: pkgName,
112
- version: 'unknown',
113
- size: module.size || 0,
114
- instances: 1,
115
- treeshakeable: false,
116
- });
117
- }
118
- }
119
- }
120
- }
121
- const largeFiles = files.filter((f) => f.size > 100 * 1024).sort((a, b) => b.size - a.size);
122
- return {
123
- totalSize,
124
- files,
125
- chunks,
126
- dependencies: Array.from(dependencies.values()).sort((a, b) => b.size - a.size),
127
- duplicates: [],
128
- largeFiles,
129
- };
130
- }
131
- /**
132
- * Find duplicate dependencies
133
- */
134
- export function findDuplicateDependencies(_stats) {
135
- const _modules = new Map();
136
- // This would need module resolution data
137
- // Placeholder implementation
138
- return [];
139
- }
140
- export function getOptimizationSuggestions(stats) {
141
- const suggestions = [];
142
- // Check total bundle size
143
- if (stats.totalSize > 500 * 1024) {
144
- suggestions.push({
145
- type: 'bundle-split',
146
- severity: 'critical',
147
- message: `Total bundle size (${formatSize(stats.totalSize)}) exceeds 500KB. Consider code splitting.`,
148
- potentialSavings: stats.totalSize - 500 * 1024,
149
- });
150
- }
151
- // Check for large files
152
- for (const file of stats.largeFiles) {
153
- if (file.size > 200 * 1024) {
154
- suggestions.push({
155
- type: 'dynamic-import',
156
- severity: 'warning',
157
- message: `Large file ${file.path} (${formatSize(file.size)}). Consider lazy loading.`,
158
- potentialSavings: file.size * 0.7, // Assume 70% can be deferred
159
- file: file.path,
160
- });
161
- }
162
- }
163
- // Check for duplicate dependencies
164
- if (stats.duplicates.length > 0) {
165
- for (const dup of stats.duplicates) {
166
- suggestions.push({
167
- type: 'dependency',
168
- severity: 'warning',
169
- message: `Duplicate dependency ${dup.name} found in ${dup.versions.length} versions`,
170
- potentialSavings: dup.totalSize * 0.5,
171
- });
172
- }
173
- }
174
- // Check for large dependencies
175
- for (const dep of stats.dependencies) {
176
- if (dep.size > 100 * 1024) {
177
- suggestions.push({
178
- type: 'tree-shaking',
179
- severity: 'info',
180
- message: `Large dependency ${dep.name} (${formatSize(dep.size)}). Verify tree shaking.`,
181
- });
182
- }
183
- }
184
- return suggestions.sort((a, b) => {
185
- const severityOrder = { critical: 0, warning: 1, info: 2 };
186
- return severityOrder[a.severity] - severityOrder[b.severity];
187
- });
188
- }
189
- /**
190
- * Generate bundle report
191
- */
192
- export function generateBundleReport(stats) {
193
- const suggestions = getOptimizationSuggestions(stats);
194
- let report = '# Bundle Analysis Report\n\n';
195
- report += `## Summary\n\n`;
196
- report += `- Total Size: ${formatSize(stats.totalSize)}\n`;
197
- report += `- Files: ${stats.files.length}\n`;
198
- report += `- Chunks: ${stats.chunks.length}\n`;
199
- report += `- Dependencies: ${stats.dependencies.length}\n`;
200
- report += `- Large Files: ${stats.largeFiles.length}\n\n`;
201
- if (stats.largeFiles.length > 0) {
202
- report += `## Large Files (>100KB)\n\n`;
203
- report += `| File | Size | % of Total |\n`;
204
- report += `|------|------|------------|\n`;
205
- for (const file of stats.largeFiles.slice(0, 10)) {
206
- report += `| ${file.path} | ${formatSize(file.size)} | ${file.relativeSize.toFixed(1)}% |\n`;
207
- }
208
- report += '\n';
209
- }
210
- if (stats.dependencies.length > 0) {
211
- report += `## Top Dependencies\n\n`;
212
- report += `| Package | Size | Instances |\n`;
213
- report += `|---------|------|----------|\n`;
214
- for (const dep of stats.dependencies.slice(0, 10)) {
215
- report += `| ${dep.name} | ${formatSize(dep.size)} | ${dep.instances} |\n`;
216
- }
217
- report += '\n';
218
- }
219
- if (suggestions.length > 0) {
220
- report += `## Optimization Suggestions\n\n`;
221
- for (const suggestion of suggestions) {
222
- const icon = suggestion.severity === 'critical' ? '🔴' : suggestion.severity === 'warning' ? 'âš ī¸' : 'â„šī¸';
223
- report += `${icon} **${suggestion.type}**: ${suggestion.message}\n`;
224
- if (suggestion.potentialSavings) {
225
- report += ` Potential savings: ${formatSize(suggestion.potentialSavings)}\n`;
226
- }
227
- report += '\n';
228
- }
229
- }
230
- return report;
231
- }
232
- export function compareBundles(before, after) {
233
- const sizeDiff = after.totalSize - before.totalSize;
234
- const sizeChangePercent = (sizeDiff / before.totalSize) * 100;
235
- const beforeFiles = new Set(before.files.map((f) => f.path));
236
- const afterFiles = new Set(after.files.map((f) => f.path));
237
- const filesAdded = after.files.filter((f) => !beforeFiles.has(f.path)).length;
238
- const filesRemoved = before.files.filter((f) => !afterFiles.has(f.path)).length;
239
- const filesChanged = after.files.filter((f) => {
240
- const beforeFile = before.files.find((bf) => bf.path === f.path);
241
- return beforeFile && beforeFile.size !== f.size;
242
- }).length;
243
- const newLargeFiles = after.largeFiles.filter((f) => {
244
- const beforeFile = before.files.find((bf) => bf.path === f.path);
245
- return !beforeFile || beforeFile.size < 100 * 1024;
246
- });
247
- const improvements = [];
248
- const regressions = [];
249
- if (sizeDiff < 0) {
250
- improvements.push(`Total bundle size reduced by ${formatSize(Math.abs(sizeDiff))}`);
251
- }
252
- else if (sizeDiff > 0) {
253
- regressions.push(`Total bundle size increased by ${formatSize(sizeDiff)}`);
254
- }
255
- if (after.largeFiles.length < before.largeFiles.length) {
256
- improvements.push(`${before.largeFiles.length - after.largeFiles.length} fewer large files`);
257
- }
258
- else if (after.largeFiles.length > before.largeFiles.length) {
259
- regressions.push(`${after.largeFiles.length - before.largeFiles.length} new large files`);
260
- }
261
- return {
262
- sizeDiff,
263
- sizeChangePercent,
264
- filesAdded,
265
- filesRemoved,
266
- filesChanged,
267
- newLargeFiles,
268
- improvements,
269
- regressions,
270
- };
271
- }
272
- /**
273
- * Get bundle health score (0-100)
274
- */
275
- export function getBundleHealthScore(stats) {
276
- const factors = [];
277
- // Factor 1: Total size (40% weight)
278
- let sizeScore = 100;
279
- if (stats.totalSize > 1024 * 1024) {
280
- sizeScore = Math.max(0, 100 - ((stats.totalSize - 1024 * 1024) / (1024 * 1024)) * 50);
281
- }
282
- else if (stats.totalSize > 500 * 1024) {
283
- sizeScore = 100 - ((stats.totalSize - 500 * 1024) / (500 * 1024)) * 30;
284
- }
285
- factors.push({
286
- name: 'Bundle Size',
287
- score: sizeScore,
288
- weight: 0.4,
289
- reason: `Total size: ${formatSize(stats.totalSize)}`,
290
- });
291
- // Factor 2: Large files (30% weight)
292
- const largeFileScore = Math.max(0, 100 - stats.largeFiles.length * 10);
293
- factors.push({
294
- name: 'Large Files',
295
- score: largeFileScore,
296
- weight: 0.3,
297
- reason: `${stats.largeFiles.length} files over 100KB`,
298
- });
299
- // Factor 3: Chunks (20% weight)
300
- const optimalChunks = 10;
301
- const chunkScore = 100 - Math.abs(stats.chunks.length - optimalChunks) * 5;
302
- factors.push({
303
- name: 'Code Splitting',
304
- score: Math.max(0, chunkScore),
305
- weight: 0.2,
306
- reason: `${stats.chunks.length} chunks (optimal: ~${optimalChunks})`,
307
- });
308
- // Factor 4: Duplicates (10% weight)
309
- const duplicateScore = Math.max(0, 100 - stats.duplicates.length * 20);
310
- factors.push({
311
- name: 'Dependencies',
312
- score: duplicateScore,
313
- weight: 0.1,
314
- reason: `${stats.duplicates.length} duplicate dependencies`,
315
- });
316
- // Calculate weighted score
317
- const totalScore = factors.reduce((sum, factor) => sum + factor.score * factor.weight, 0);
318
- return {
319
- score: Math.round(totalScore),
320
- factors,
321
- };
322
- }