@verdaccio/ui-components 5.0.0-next-9.20 → 5.0.0-next-9.21

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 (274) hide show
  1. package/build/api/use-data-mutation.js +1 -4
  2. package/build/api/use-data-mutation.js.map +1 -1
  3. package/build/api/use-data-mutation.mjs +1 -4
  4. package/build/api/use-data-mutation.mjs.map +1 -1
  5. package/build/api/use-data.d.ts +1 -0
  6. package/build/api/use-data.js +3 -2
  7. package/build/api/use-data.js.map +1 -1
  8. package/build/api/use-data.mjs +3 -3
  9. package/build/api/use-data.mjs.map +1 -1
  10. package/build/components/ActionBar/ActionBar.js +4 -2
  11. package/build/components/ActionBar/ActionBar.js.map +1 -1
  12. package/build/components/ActionBar/ActionBar.mjs +4 -2
  13. package/build/components/ActionBar/ActionBar.mjs.map +1 -1
  14. package/build/components/ActionBar/ActionBarAction.js +1 -1
  15. package/build/components/ActionBar/ActionBarAction.mjs +1 -1
  16. package/build/components/Author/Author.js +1 -1
  17. package/build/components/Author/Author.mjs +1 -1
  18. package/build/components/CopyClipboard/CopyToClipBoard.js +5 -0
  19. package/build/components/CopyClipboard/CopyToClipBoard.js.map +1 -1
  20. package/build/components/CopyClipboard/CopyToClipBoard.mjs +5 -0
  21. package/build/components/CopyClipboard/CopyToClipBoard.mjs.map +1 -1
  22. package/build/components/CopyClipboard/utils.js +14 -1
  23. package/build/components/CopyClipboard/utils.js.map +1 -1
  24. package/build/components/CopyClipboard/utils.mjs +14 -1
  25. package/build/components/CopyClipboard/utils.mjs.map +1 -1
  26. package/build/components/Dependencies/Dependencies.js +2 -1
  27. package/build/components/Dependencies/Dependencies.js.map +1 -1
  28. package/build/components/Dependencies/Dependencies.mjs +2 -1
  29. package/build/components/Dependencies/Dependencies.mjs.map +1 -1
  30. package/build/components/Dependencies/DependencyBlock.js +1 -1
  31. package/build/components/Dependencies/DependencyBlock.mjs +1 -1
  32. package/build/components/Developers/Title.js +1 -1
  33. package/build/components/Developers/Title.mjs +1 -1
  34. package/build/components/Developers/get-unique-developer-values.js +2 -1
  35. package/build/components/Developers/get-unique-developer-values.js.map +1 -1
  36. package/build/components/Developers/get-unique-developer-values.mjs +2 -1
  37. package/build/components/Developers/get-unique-developer-values.mjs.map +1 -1
  38. package/build/components/Distribution/Dist.js +3 -3
  39. package/build/components/Distribution/Dist.js.map +1 -1
  40. package/build/components/Distribution/Dist.mjs +3 -3
  41. package/build/components/Distribution/Dist.mjs.map +1 -1
  42. package/build/components/Engines/Engines.js +1 -1
  43. package/build/components/Engines/Engines.mjs +1 -1
  44. package/build/components/Forbidden/Forbidden.js +1 -1
  45. package/build/components/Forbidden/Forbidden.mjs +1 -1
  46. package/build/components/FundButton/FundButton.js +4 -3
  47. package/build/components/FundButton/FundButton.js.map +1 -1
  48. package/build/components/FundButton/FundButton.mjs +4 -3
  49. package/build/components/FundButton/FundButton.mjs.map +1 -1
  50. package/build/components/GenericError/GenericError.d.ts +3 -0
  51. package/build/components/GenericError/GenericError.js +60 -0
  52. package/build/components/GenericError/GenericError.js.map +1 -0
  53. package/build/components/GenericError/GenericError.mjs +54 -0
  54. package/build/components/GenericError/GenericError.mjs.map +1 -0
  55. package/build/components/GenericError/index.d.ts +1 -0
  56. package/build/components/GenericError/index.js +2 -0
  57. package/build/components/GenericError/index.mjs +2 -0
  58. package/build/components/Help/Help.js +1 -1
  59. package/build/components/Help/Help.mjs +1 -1
  60. package/build/components/Install/Install.js +1 -1
  61. package/build/components/Install/Install.mjs +1 -1
  62. package/build/components/Install/InstallListItem.js +2 -2
  63. package/build/components/Install/InstallListItem.js.map +1 -1
  64. package/build/components/Install/InstallListItem.mjs +2 -2
  65. package/build/components/Install/InstallListItem.mjs.map +1 -1
  66. package/build/components/Keywords/KeywordListItems.js +1 -1
  67. package/build/components/Keywords/KeywordListItems.js.map +1 -1
  68. package/build/components/Keywords/KeywordListItems.mjs +1 -1
  69. package/build/components/Keywords/KeywordListItems.mjs.map +1 -1
  70. package/build/components/Keywords/Keywords.js +2 -2
  71. package/build/components/Keywords/Keywords.js.map +1 -1
  72. package/build/components/Keywords/Keywords.mjs +2 -2
  73. package/build/components/Keywords/Keywords.mjs.map +1 -1
  74. package/build/components/LoginDialog/LoginDialogCloseButton.js +1 -1
  75. package/build/components/LoginDialog/LoginDialogCloseButton.mjs +1 -1
  76. package/build/components/LoginDialog/LoginDialogForm.js +2 -1
  77. package/build/components/LoginDialog/LoginDialogForm.js.map +1 -1
  78. package/build/components/LoginDialog/LoginDialogForm.mjs +2 -1
  79. package/build/components/LoginDialog/LoginDialogForm.mjs.map +1 -1
  80. package/build/components/LoginForm/Login.d.ts +1 -0
  81. package/build/components/LoginForm/Login.js +6 -4
  82. package/build/components/LoginForm/Login.js.map +1 -1
  83. package/build/components/LoginForm/Login.mjs +9 -7
  84. package/build/components/LoginForm/Login.mjs.map +1 -1
  85. package/build/components/LoginForm/PasswordField.js +4 -6
  86. package/build/components/LoginForm/PasswordField.js.map +1 -1
  87. package/build/components/LoginForm/PasswordField.mjs +4 -6
  88. package/build/components/LoginForm/PasswordField.mjs.map +1 -1
  89. package/build/components/LoginForm/UsernameField.js +4 -6
  90. package/build/components/LoginForm/UsernameField.js.map +1 -1
  91. package/build/components/LoginForm/UsernameField.mjs +4 -6
  92. package/build/components/LoginForm/UsernameField.mjs.map +1 -1
  93. package/build/components/LoginForm/styles.js +1 -1
  94. package/build/components/LoginForm/styles.mjs +1 -1
  95. package/build/components/LoginForm/useLoginForm.js +13 -3
  96. package/build/components/LoginForm/useLoginForm.js.map +1 -1
  97. package/build/components/LoginForm/useLoginForm.mjs +14 -4
  98. package/build/components/LoginForm/useLoginForm.mjs.map +1 -1
  99. package/build/components/NoItems/NoItems.js +2 -2
  100. package/build/components/NoItems/NoItems.mjs +1 -1
  101. package/build/components/NotFound/NotFound.js +1 -1
  102. package/build/components/NotFound/NotFound.mjs +1 -1
  103. package/build/components/Package/Package.d.ts +1 -1
  104. package/build/components/Package/Package.js +28 -29
  105. package/build/components/Package/Package.js.map +1 -1
  106. package/build/components/Package/Package.mjs +29 -30
  107. package/build/components/Package/Package.mjs.map +1 -1
  108. package/build/components/Person/Person.js +1 -1
  109. package/build/components/Person/Person.js.map +1 -1
  110. package/build/components/Person/Person.mjs +1 -1
  111. package/build/components/Person/Person.mjs.map +1 -1
  112. package/build/components/RawViewer/RawViewer.js +1 -1
  113. package/build/components/RawViewer/RawViewer.mjs +1 -1
  114. package/build/components/RegistryInfoDialog/RegistryInfoDialog.js +1 -1
  115. package/build/components/RegistryInfoDialog/RegistryInfoDialog.mjs +1 -1
  116. package/build/components/Repository/Repository.js +5 -8
  117. package/build/components/Repository/Repository.js.map +1 -1
  118. package/build/components/Repository/Repository.mjs +5 -8
  119. package/build/components/Repository/Repository.mjs.map +1 -1
  120. package/build/components/Search/AutoComplete/AutoComplete.d.ts +1 -0
  121. package/build/components/Search/AutoComplete/AutoComplete.js +4 -4
  122. package/build/components/Search/AutoComplete/AutoComplete.js.map +1 -1
  123. package/build/components/Search/AutoComplete/AutoComplete.mjs +4 -4
  124. package/build/components/Search/AutoComplete/AutoComplete.mjs.map +1 -1
  125. package/build/components/Search/Search.js +12 -4
  126. package/build/components/Search/Search.js.map +1 -1
  127. package/build/components/Search/Search.mjs +13 -5
  128. package/build/components/Search/Search.mjs.map +1 -1
  129. package/build/components/Search/SearchItem.js +1 -1
  130. package/build/components/Search/SearchItem.mjs +1 -1
  131. package/build/components/SettingsMenu/SettingsMenu.js +1 -1
  132. package/build/components/SettingsMenu/SettingsMenu.mjs +1 -1
  133. package/build/components/SideBarTitle/SideBarTitle.js +2 -2
  134. package/build/components/SideBarTitle/SideBarTitle.js.map +1 -1
  135. package/build/components/SideBarTitle/SideBarTitle.mjs +2 -2
  136. package/build/components/SideBarTitle/SideBarTitle.mjs.map +1 -1
  137. package/build/components/UpLinks/UpLinks.js +1 -1
  138. package/build/components/UpLinks/UpLinks.mjs +1 -1
  139. package/build/components/Versions/HistoryList.js +2 -2
  140. package/build/components/Versions/HistoryList.js.map +1 -1
  141. package/build/components/Versions/HistoryList.mjs +2 -2
  142. package/build/components/Versions/HistoryList.mjs.map +1 -1
  143. package/build/components/Versions/Versions.js +22 -21
  144. package/build/components/Versions/Versions.js.map +1 -1
  145. package/build/components/Versions/Versions.mjs +22 -21
  146. package/build/components/Versions/Versions.mjs.map +1 -1
  147. package/build/index.d.ts +1 -0
  148. package/build/index.js +4 -0
  149. package/build/index.mjs +4 -2
  150. package/build/pages/Version/Version.js +4 -1
  151. package/build/pages/Version/Version.js.map +1 -1
  152. package/build/pages/Version/Version.mjs +4 -1
  153. package/build/pages/Version/Version.mjs.map +1 -1
  154. package/build/providers/AuthProvider/AuthProvider.js +9 -7
  155. package/build/providers/AuthProvider/AuthProvider.js.map +1 -1
  156. package/build/providers/AuthProvider/AuthProvider.mjs +10 -8
  157. package/build/providers/AuthProvider/AuthProvider.mjs.map +1 -1
  158. package/build/providers/AuthProvider/utils.d.ts +12 -0
  159. package/build/providers/AuthProvider/utils.js +22 -0
  160. package/build/providers/AuthProvider/utils.js.map +1 -1
  161. package/build/providers/AuthProvider/utils.mjs +21 -2
  162. package/build/providers/AuthProvider/utils.mjs.map +1 -1
  163. package/build/providers/DownloadProvider/DownloadProvider.d.ts +1 -0
  164. package/build/providers/DownloadProvider/DownloadProvider.js +27 -4
  165. package/build/providers/DownloadProvider/DownloadProvider.js.map +1 -1
  166. package/build/providers/DownloadProvider/DownloadProvider.mjs +27 -6
  167. package/build/providers/DownloadProvider/DownloadProvider.mjs.map +1 -1
  168. package/build/providers/ManifestsProvider/ManifestsProvider.js +1 -1
  169. package/build/providers/ManifestsProvider/ManifestsProvider.js.map +1 -1
  170. package/build/providers/ManifestsProvider/ManifestsProvider.mjs +1 -1
  171. package/build/providers/ManifestsProvider/ManifestsProvider.mjs.map +1 -1
  172. package/build/providers/SearchProvider/SearchProvider.d.ts +1 -0
  173. package/build/providers/SearchProvider/SearchProvider.js +8 -6
  174. package/build/providers/SearchProvider/SearchProvider.js.map +1 -1
  175. package/build/providers/SearchProvider/SearchProvider.mjs +8 -6
  176. package/build/providers/SearchProvider/SearchProvider.mjs.map +1 -1
  177. package/build/providers/TranslatorProvider/TranslatorProvider.js +5 -3
  178. package/build/providers/TranslatorProvider/TranslatorProvider.js.map +1 -1
  179. package/build/providers/TranslatorProvider/TranslatorProvider.mjs +5 -3
  180. package/build/providers/TranslatorProvider/TranslatorProvider.mjs.map +1 -1
  181. package/build/providers/VersionProvider/VersionProvider.js +3 -3
  182. package/build/providers/VersionProvider/VersionProvider.js.map +1 -1
  183. package/build/providers/VersionProvider/VersionProvider.mjs +3 -3
  184. package/build/providers/VersionProvider/VersionProvider.mjs.map +1 -1
  185. package/build/sections/Detail/Tabs.js +1 -1
  186. package/build/sections/Detail/Tabs.mjs +1 -1
  187. package/build/sections/Footer/Footer.js +1 -1
  188. package/build/sections/Footer/Footer.mjs +1 -1
  189. package/build/sections/Header/Header.d.ts +0 -1
  190. package/build/sections/Header/Header.js +16 -14
  191. package/build/sections/Header/Header.js.map +1 -1
  192. package/build/sections/Header/Header.mjs +17 -15
  193. package/build/sections/Header/Header.mjs.map +1 -1
  194. package/build/sections/Header/HeaderGreetings.js +1 -1
  195. package/build/sections/Header/HeaderGreetings.mjs +1 -1
  196. package/build/sections/Header/HeaderMenu.js +1 -1
  197. package/build/sections/Header/HeaderMenu.mjs +1 -1
  198. package/build/sections/Header/HeaderRight.js +1 -1
  199. package/build/sections/Header/HeaderRight.mjs +1 -1
  200. package/build/sections/Header/HeaderSettingsDialog.js +1 -1
  201. package/build/sections/Header/HeaderSettingsDialog.mjs +1 -1
  202. package/build/sections/Header/LanguageSwitch.js +1 -1
  203. package/build/sections/Header/LanguageSwitch.mjs +1 -1
  204. package/build/sections/Header/RegistryInfoContent/RegistryInfoContent.js +1 -1
  205. package/build/sections/Header/RegistryInfoContent/RegistryInfoContent.mjs +1 -1
  206. package/build/sections/Home/Home.js +4 -3
  207. package/build/sections/Home/Home.js.map +1 -1
  208. package/build/sections/Home/Home.mjs +5 -4
  209. package/build/sections/Home/Home.mjs.map +1 -1
  210. package/build/sections/Security/AddUser.js +33 -18
  211. package/build/sections/Security/AddUser.js.map +1 -1
  212. package/build/sections/Security/AddUser.mjs +37 -22
  213. package/build/sections/Security/AddUser.mjs.map +1 -1
  214. package/build/sections/Security/ChangePassword.js +17 -15
  215. package/build/sections/Security/ChangePassword.js.map +1 -1
  216. package/build/sections/Security/ChangePassword.mjs +19 -17
  217. package/build/sections/Security/ChangePassword.mjs.map +1 -1
  218. package/build/sections/Security/Login.js +51 -35
  219. package/build/sections/Security/Login.js.map +1 -1
  220. package/build/sections/Security/Login.mjs +54 -38
  221. package/build/sections/Security/Login.mjs.map +1 -1
  222. package/build/sections/Security/Success.js +28 -24
  223. package/build/sections/Security/Success.js.map +1 -1
  224. package/build/sections/Security/Success.mjs +29 -25
  225. package/build/sections/Security/Success.mjs.map +1 -1
  226. package/build/sections/Stage/StageActions.js +1 -1
  227. package/build/sections/Stage/StageActions.mjs +1 -1
  228. package/build/sections/Stage/StageDetail.js +1 -1
  229. package/build/sections/Stage/StageDetail.mjs +1 -1
  230. package/build/sections/Stage/StageList.js +15 -2
  231. package/build/sections/Stage/StageList.js.map +1 -1
  232. package/build/sections/Stage/StageList.mjs +15 -2
  233. package/build/sections/Stage/StageList.mjs.map +1 -1
  234. package/build/store/api.js +7 -4
  235. package/build/store/api.js.map +1 -1
  236. package/build/store/api.mjs +7 -4
  237. package/build/store/api.mjs.map +1 -1
  238. package/build/types/packageMeta.d.ts +3 -2
  239. package/build/utils/cli-utils.js +2 -2
  240. package/build/utils/cli-utils.js.map +1 -1
  241. package/build/utils/cli-utils.mjs +2 -2
  242. package/build/utils/cli-utils.mjs.map +1 -1
  243. package/build/utils/index.js +1 -0
  244. package/build/utils/index.mjs +2 -2
  245. package/build/utils/routes.d.ts +1 -0
  246. package/build/utils/routes.js +1 -0
  247. package/build/utils/routes.js.map +1 -1
  248. package/build/utils/routes.mjs +1 -0
  249. package/build/utils/routes.mjs.map +1 -1
  250. package/build/utils/schemas.d.ts +1 -0
  251. package/build/utils/schemas.js +4 -4
  252. package/build/utils/schemas.js.map +1 -1
  253. package/build/utils/schemas.mjs +4 -4
  254. package/build/utils/schemas.mjs.map +1 -1
  255. package/build/utils/session-id.d.ts +8 -0
  256. package/build/utils/session-id.js +26 -0
  257. package/build/utils/session-id.js.map +1 -0
  258. package/build/utils/session-id.mjs +26 -0
  259. package/build/utils/session-id.mjs.map +1 -0
  260. package/build/utils/token.d.ts +1 -0
  261. package/build/utils/token.js +12 -8
  262. package/build/utils/token.js.map +1 -1
  263. package/build/utils/token.mjs +12 -9
  264. package/build/utils/token.mjs.map +1 -1
  265. package/build/utils/url.js +1 -1
  266. package/build/utils/url.js.map +1 -1
  267. package/build/utils/url.mjs +1 -1
  268. package/build/utils/url.mjs.map +1 -1
  269. package/build/utils/utils.d.ts +10 -0
  270. package/build/utils/utils.js +26 -0
  271. package/build/utils/utils.js.map +1 -1
  272. package/build/utils/utils.mjs +25 -1
  273. package/build/utils/utils.mjs.map +1 -1
  274. package/package.json +6 -6
@@ -1,4 +1,5 @@
1
1
  const require_runtime = require("../_virtual/_rolldown/runtime.js");
2
+ const require_url = require("./url.js");
2
3
  let dayjs = require("dayjs");
3
4
  dayjs = require_runtime.__toESM(dayjs);
4
5
  let dayjs_plugin_localizedFormat = require("dayjs/plugin/localizedFormat");
@@ -16,6 +17,8 @@ var utils_exports = /* @__PURE__ */ require_runtime.__exportAll({
16
17
  formatLicense: () => formatLicense,
17
18
  formatRepository: () => formatRepository,
18
19
  getAuthorName: () => getAuthorName,
20
+ getBugsUrl: () => getBugsUrl,
21
+ getFundingUrl: () => getFundingUrl,
19
22
  getLastUpdatedPackageTime: () => getLastUpdatedPackageTime,
20
23
  getRecentReleases: () => getRecentReleases,
21
24
  getUplink: () => getUplink
@@ -40,6 +43,27 @@ function formatRepository(repository) {
40
43
  if (repository && typeof repository === "object" && "url" in repository && typeof repository.url === "string") return repository.url;
41
44
  return null;
42
45
  }
46
+ /**
47
+ * Normalizes the `bugs` field to its url.
48
+ * @see https://docs.npmjs.com/cli/configuring-npm/package-json#bugs
49
+ */
50
+ function getBugsUrl(bugs) {
51
+ if (typeof bugs === "string") return bugs;
52
+ if (bugs && typeof bugs === "object" && "url" in bugs && typeof bugs.url === "string") return bugs.url;
53
+ return null;
54
+ }
55
+ /**
56
+ * Normalizes the `funding` field (string, object or array of both) to a url.
57
+ * @see https://docs.npmjs.com/cli/configuring-npm/package-json#funding
58
+ */
59
+ function getFundingUrl(funding) {
60
+ const entries = Array.isArray(funding) ? funding : [funding];
61
+ for (const entry of entries) {
62
+ if (typeof entry === "string" && require_url.isURL(entry)) return entry;
63
+ if (entry && typeof entry === "object" && "url" in entry && typeof entry.url === "string" && require_url.isURL(entry.url)) return entry.url;
64
+ }
65
+ return null;
66
+ }
43
67
  function formatDate(lastUpdate) {
44
68
  return (0, dayjs.default)(new Date(lastUpdate)).format(TIMEFORMAT);
45
69
  }
@@ -98,6 +122,8 @@ exports.formatDateDistance = formatDateDistance;
98
122
  exports.formatLicense = formatLicense;
99
123
  exports.formatRepository = formatRepository;
100
124
  exports.getAuthorName = getAuthorName;
125
+ exports.getBugsUrl = getBugsUrl;
126
+ exports.getFundingUrl = getFundingUrl;
101
127
  exports.getLastUpdatedPackageTime = getLastUpdatedPackageTime;
102
128
  exports.getRecentReleases = getRecentReleases;
103
129
  exports.getUplink = getUplink;
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","names":[],"sources":["../../src/utils/utils.ts"],"sourcesContent":["import dayjs from 'dayjs';\nimport localizedFormat from 'dayjs/plugin/localizedFormat';\nimport relativeTime from 'dayjs/plugin/relativeTime';\nimport i18next from 'i18next';\n\nimport type { UpLinks } from '@verdaccio/types';\n\nimport type { Time } from '../types/packageMeta';\n\nexport const TIMEFORMAT = 'L LTS';\n\ndayjs.extend(relativeTime);\ndayjs.extend(localizedFormat);\n\n/**\n * Formats license field for webui.\n * @see https://docs.npmjs.com/files/package.json#license\n */\nexport function formatLicense(license: string | { type?: string } | unknown): string | undefined {\n if (typeof license === 'string') {\n return license;\n }\n\n if (\n license &&\n typeof license === 'object' &&\n 'type' in license &&\n typeof license.type === 'string'\n ) {\n return license.type;\n }\n\n return undefined;\n}\n\nexport interface Repository {\n readonly type: string;\n readonly url: string;\n}\n\n/**\n * Formats repository field for webui.\n * @see https://docs.npmjs.com/files/package.json#repository\n */\nexport function formatRepository(repository: string | { url?: string } | unknown): string | null {\n if (typeof repository === 'string') {\n return repository;\n }\n\n if (\n repository &&\n typeof repository === 'object' &&\n 'url' in repository &&\n typeof repository.url === 'string'\n ) {\n return repository.url;\n }\n\n return null;\n}\n\nexport function formatDate(lastUpdate: string | number): string {\n return dayjs(new Date(lastUpdate)).format(TIMEFORMAT);\n}\n\nexport function formatDateDistance(lastUpdate: Date | string | number): string {\n return dayjs(new Date(lastUpdate)).fromNow();\n}\n\n/**\n * For <LastSync /> component\n * @param {array} uplinks\n */\nexport function getLastUpdatedPackageTime(uplinks: UpLinks = {}): string {\n let lastUpdate = 0;\n Object.keys(uplinks).forEach(function computeUplink(upLinkName): void {\n const status = uplinks[upLinkName];\n if (status.fetched > lastUpdate) {\n lastUpdate = status.fetched;\n }\n });\n\n return lastUpdate ? formatDate(lastUpdate) : '';\n}\n\n/**\n * For <LastSync /> component\n * @param {Object} time\n * @returns {Array} last 3 releases\n */\nexport function getRecentReleases(time: Time = {}): Time[] {\n const recent = Object.keys(time).map((version) => ({\n version,\n time: formatDate(time[version]),\n }));\n\n return recent.slice(recent.length - 3, recent.length).reverse();\n}\n\nexport function getAuthorName(authorName?: string): string {\n if (!authorName) {\n return i18next.t('author-unknown');\n }\n\n if (authorName.toLowerCase() === 'anonymous') {\n return i18next.t('author-anonymous');\n }\n\n return authorName;\n}\n\nexport function getUplink(upLinkName: string, packageName: string): string | null {\n // TODO: make this a config like \"uplinks: npmjs: web: https://www.npmjs.com/package/\"\n switch (upLinkName) {\n case 'npmjs':\n return `https://www.npmjs.com/package/${packageName}`;\n }\n return null;\n}\n\nexport function fileSizeSI(\n a: number,\n b?: typeof Math,\n c?: (p: number) => number,\n d?: number,\n e?: number\n): string {\n b = Math;\n c = b.log;\n d = 1e3;\n e = (c(a) / c(d)) | 0;\n const size = a / b.pow(d, e);\n // no decimals for Bytes\n if (e === 0) {\n return Math.floor(size) + ' Bytes';\n } else {\n return size.toFixed(1) + ' ' + 'kMGTPEZY'[--e] + 'B';\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AASA,IAAa,aAAa;AAE1B,MAAA,QAAM,OAAO,0BAAA,OAAY;AACzB,MAAA,QAAM,OAAO,6BAAA,OAAe;;;;;AAM5B,SAAgB,cAAc,SAAmE;CAC/F,IAAI,OAAO,YAAY,UACrB,OAAO;CAGT,IACE,WACA,OAAO,YAAY,YACnB,UAAU,WACV,OAAO,QAAQ,SAAS,UAExB,OAAO,QAAQ;AAInB;;;;;AAWA,SAAgB,iBAAiB,YAAgE;CAC/F,IAAI,OAAO,eAAe,UACxB,OAAO;CAGT,IACE,cACA,OAAO,eAAe,YACtB,SAAS,cACT,OAAO,WAAW,QAAQ,UAE1B,OAAO,WAAW;CAGpB,OAAO;AACT;AAEA,SAAgB,WAAW,YAAqC;CAC9D,QAAA,GAAO,MAAA,QAAA,CAAM,IAAI,KAAK,UAAU,CAAC,CAAC,CAAC,OAAO,UAAU;AACtD;AAEA,SAAgB,mBAAmB,YAA4C;CAC7E,QAAA,GAAO,MAAA,QAAA,CAAM,IAAI,KAAK,UAAU,CAAC,CAAC,CAAC,QAAQ;AAC7C;;;;;AAMA,SAAgB,0BAA0B,UAAmB,CAAC,GAAW;CACvE,IAAI,aAAa;CACjB,OAAO,KAAK,OAAO,CAAC,CAAC,QAAQ,SAAS,cAAc,YAAkB;EACpE,MAAM,SAAS,QAAQ;EACvB,IAAI,OAAO,UAAU,YACnB,aAAa,OAAO;CAExB,CAAC;CAED,OAAO,aAAa,WAAW,UAAU,IAAI;AAC/C;;;;;;AAOA,SAAgB,kBAAkB,OAAa,CAAC,GAAW;CACzD,MAAM,SAAS,OAAO,KAAK,IAAI,CAAC,CAAC,KAAK,aAAa;EACjD;EACA,MAAM,WAAW,KAAK,QAAQ;CAChC,EAAE;CAEF,OAAO,OAAO,MAAM,OAAO,SAAS,GAAG,OAAO,MAAM,CAAC,CAAC,QAAQ;AAChE;AAEA,SAAgB,cAAc,YAA6B;CACzD,IAAI,CAAC,YACH,OAAO,QAAA,QAAQ,EAAE,gBAAgB;CAGnC,IAAI,WAAW,YAAY,MAAM,aAC/B,OAAO,QAAA,QAAQ,EAAE,kBAAkB;CAGrC,OAAO;AACT;AAEA,SAAgB,UAAU,YAAoB,aAAoC;CAEhF,QAAQ,YAAR;EACE,KAAK,SACH,OAAO,iCAAiC;CAC5C;CACA,OAAO;AACT;AAEA,SAAgB,WACd,GACA,GACA,GACA,GACA,GACQ;CACR,IAAI;CACJ,IAAI,EAAE;CACN,IAAI;CACJ,IAAK,EAAE,CAAC,IAAI,EAAE,CAAC,IAAK;CACpB,MAAM,OAAO,IAAI,EAAE,IAAI,GAAG,CAAC;CAE3B,IAAI,MAAM,GACR,OAAO,KAAK,MAAM,IAAI,IAAI;MAE1B,OAAO,KAAK,QAAQ,CAAC,IAAI,MAAM,WAAW,EAAE,KAAK;AAErD"}
1
+ {"version":3,"file":"utils.js","names":[],"sources":["../../src/utils/utils.ts"],"sourcesContent":["import dayjs from 'dayjs';\nimport localizedFormat from 'dayjs/plugin/localizedFormat';\nimport relativeTime from 'dayjs/plugin/relativeTime';\nimport i18next from 'i18next';\n\nimport type { UpLinks } from '@verdaccio/types';\n\nimport type { Time } from '../types/packageMeta';\nimport { isURL } from './url';\n\nexport const TIMEFORMAT = 'L LTS';\n\ndayjs.extend(relativeTime);\ndayjs.extend(localizedFormat);\n\n/**\n * Formats license field for webui.\n * @see https://docs.npmjs.com/files/package.json#license\n */\nexport function formatLicense(license: string | { type?: string } | unknown): string | undefined {\n if (typeof license === 'string') {\n return license;\n }\n\n if (\n license &&\n typeof license === 'object' &&\n 'type' in license &&\n typeof license.type === 'string'\n ) {\n return license.type;\n }\n\n return undefined;\n}\n\nexport interface Repository {\n readonly type: string;\n readonly url: string;\n}\n\n/**\n * Formats repository field for webui.\n * @see https://docs.npmjs.com/files/package.json#repository\n */\nexport function formatRepository(repository: string | { url?: string } | unknown): string | null {\n if (typeof repository === 'string') {\n return repository;\n }\n\n if (\n repository &&\n typeof repository === 'object' &&\n 'url' in repository &&\n typeof repository.url === 'string'\n ) {\n return repository.url;\n }\n\n return null;\n}\n\n/**\n * Normalizes the `bugs` field to its url.\n * @see https://docs.npmjs.com/cli/configuring-npm/package-json#bugs\n */\nexport function getBugsUrl(bugs: unknown): string | null {\n if (typeof bugs === 'string') {\n return bugs;\n }\n\n if (bugs && typeof bugs === 'object' && 'url' in bugs && typeof bugs.url === 'string') {\n return bugs.url;\n }\n\n return null;\n}\n\n/**\n * Normalizes the `funding` field (string, object or array of both) to a url.\n * @see https://docs.npmjs.com/cli/configuring-npm/package-json#funding\n */\nexport function getFundingUrl(funding: unknown): string | null {\n const entries = Array.isArray(funding) ? funding : [funding];\n // first *valid* url wins: a malformed entry must not hide a later valid one\n for (const entry of entries) {\n if (typeof entry === 'string' && isURL(entry)) {\n return entry;\n }\n if (\n entry &&\n typeof entry === 'object' &&\n 'url' in entry &&\n typeof entry.url === 'string' &&\n isURL(entry.url)\n ) {\n return entry.url;\n }\n }\n\n return null;\n}\n\nexport function formatDate(lastUpdate: string | number): string {\n return dayjs(new Date(lastUpdate)).format(TIMEFORMAT);\n}\n\nexport function formatDateDistance(lastUpdate: Date | string | number): string {\n return dayjs(new Date(lastUpdate)).fromNow();\n}\n\n/**\n * For <LastSync /> component\n * @param {array} uplinks\n */\nexport function getLastUpdatedPackageTime(uplinks: UpLinks = {}): string {\n let lastUpdate = 0;\n Object.keys(uplinks).forEach(function computeUplink(upLinkName): void {\n const status = uplinks[upLinkName];\n if (status.fetched > lastUpdate) {\n lastUpdate = status.fetched;\n }\n });\n\n return lastUpdate ? formatDate(lastUpdate) : '';\n}\n\n/**\n * For <LastSync /> component\n * @param {Object} time\n * @returns {Array} last 3 releases\n */\nexport function getRecentReleases(time: Time = {}): Time[] {\n const recent = Object.keys(time).map((version) => ({\n version,\n time: formatDate(time[version]),\n }));\n\n return recent.slice(recent.length - 3, recent.length).reverse();\n}\n\nexport function getAuthorName(authorName?: string): string {\n if (!authorName) {\n return i18next.t('author-unknown');\n }\n\n if (authorName.toLowerCase() === 'anonymous') {\n return i18next.t('author-anonymous');\n }\n\n return authorName;\n}\n\nexport function getUplink(upLinkName: string, packageName: string): string | null {\n // TODO: make this a config like \"uplinks: npmjs: web: https://www.npmjs.com/package/\"\n switch (upLinkName) {\n case 'npmjs':\n return `https://www.npmjs.com/package/${packageName}`;\n }\n return null;\n}\n\nexport function fileSizeSI(\n a: number,\n b?: typeof Math,\n c?: (p: number) => number,\n d?: number,\n e?: number\n): string {\n b = Math;\n c = b.log;\n d = 1e3;\n e = (c(a) / c(d)) | 0;\n const size = a / b.pow(d, e);\n // no decimals for Bytes\n if (e === 0) {\n return Math.floor(size) + ' Bytes';\n } else {\n return size.toFixed(1) + ' ' + 'kMGTPEZY'[--e] + 'B';\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAUA,IAAa,aAAa;AAE1B,MAAA,QAAM,OAAO,0BAAA,OAAY;AACzB,MAAA,QAAM,OAAO,6BAAA,OAAe;;;;;AAM5B,SAAgB,cAAc,SAAmE;CAC/F,IAAI,OAAO,YAAY,UACrB,OAAO;CAGT,IACE,WACA,OAAO,YAAY,YACnB,UAAU,WACV,OAAO,QAAQ,SAAS,UAExB,OAAO,QAAQ;AAInB;;;;;AAWA,SAAgB,iBAAiB,YAAgE;CAC/F,IAAI,OAAO,eAAe,UACxB,OAAO;CAGT,IACE,cACA,OAAO,eAAe,YACtB,SAAS,cACT,OAAO,WAAW,QAAQ,UAE1B,OAAO,WAAW;CAGpB,OAAO;AACT;;;;;AAMA,SAAgB,WAAW,MAA8B;CACvD,IAAI,OAAO,SAAS,UAClB,OAAO;CAGT,IAAI,QAAQ,OAAO,SAAS,YAAY,SAAS,QAAQ,OAAO,KAAK,QAAQ,UAC3E,OAAO,KAAK;CAGd,OAAO;AACT;;;;;AAMA,SAAgB,cAAc,SAAiC;CAC7D,MAAM,UAAU,MAAM,QAAQ,OAAO,IAAI,UAAU,CAAC,OAAO;CAE3D,KAAK,MAAM,SAAS,SAAS;EAC3B,IAAI,OAAO,UAAU,YAAY,YAAA,MAAM,KAAK,GAC1C,OAAO;EAET,IACE,SACA,OAAO,UAAU,YACjB,SAAS,SACT,OAAO,MAAM,QAAQ,YACrB,YAAA,MAAM,MAAM,GAAG,GAEf,OAAO,MAAM;CAEjB;CAEA,OAAO;AACT;AAEA,SAAgB,WAAW,YAAqC;CAC9D,QAAA,GAAO,MAAA,QAAA,CAAM,IAAI,KAAK,UAAU,CAAC,CAAC,CAAC,OAAO,UAAU;AACtD;AAEA,SAAgB,mBAAmB,YAA4C;CAC7E,QAAA,GAAO,MAAA,QAAA,CAAM,IAAI,KAAK,UAAU,CAAC,CAAC,CAAC,QAAQ;AAC7C;;;;;AAMA,SAAgB,0BAA0B,UAAmB,CAAC,GAAW;CACvE,IAAI,aAAa;CACjB,OAAO,KAAK,OAAO,CAAC,CAAC,QAAQ,SAAS,cAAc,YAAkB;EACpE,MAAM,SAAS,QAAQ;EACvB,IAAI,OAAO,UAAU,YACnB,aAAa,OAAO;CAExB,CAAC;CAED,OAAO,aAAa,WAAW,UAAU,IAAI;AAC/C;;;;;;AAOA,SAAgB,kBAAkB,OAAa,CAAC,GAAW;CACzD,MAAM,SAAS,OAAO,KAAK,IAAI,CAAC,CAAC,KAAK,aAAa;EACjD;EACA,MAAM,WAAW,KAAK,QAAQ;CAChC,EAAE;CAEF,OAAO,OAAO,MAAM,OAAO,SAAS,GAAG,OAAO,MAAM,CAAC,CAAC,QAAQ;AAChE;AAEA,SAAgB,cAAc,YAA6B;CACzD,IAAI,CAAC,YACH,OAAO,QAAA,QAAQ,EAAE,gBAAgB;CAGnC,IAAI,WAAW,YAAY,MAAM,aAC/B,OAAO,QAAA,QAAQ,EAAE,kBAAkB;CAGrC,OAAO;AACT;AAEA,SAAgB,UAAU,YAAoB,aAAoC;CAEhF,QAAQ,YAAR;EACE,KAAK,SACH,OAAO,iCAAiC;CAC5C;CACA,OAAO;AACT;AAEA,SAAgB,WACd,GACA,GACA,GACA,GACA,GACQ;CACR,IAAI;CACJ,IAAI,EAAE;CACN,IAAI;CACJ,IAAK,EAAE,CAAC,IAAI,EAAE,CAAC,IAAK;CACpB,MAAM,OAAO,IAAI,EAAE,IAAI,GAAG,CAAC;CAE3B,IAAI,MAAM,GACR,OAAO,KAAK,MAAM,IAAI,IAAI;MAE1B,OAAO,KAAK,QAAQ,CAAC,IAAI,MAAM,WAAW,EAAE,KAAK;AAErD"}
@@ -1,4 +1,5 @@
1
1
  import { __exportAll } from "../_virtual/_rolldown/runtime.mjs";
2
+ import { isURL } from "./url.mjs";
2
3
  import dayjs from "dayjs";
3
4
  import localizedFormat from "dayjs/plugin/localizedFormat";
4
5
  import relativeTime from "dayjs/plugin/relativeTime";
@@ -12,6 +13,8 @@ var utils_exports = /* @__PURE__ */ __exportAll({
12
13
  formatLicense: () => formatLicense,
13
14
  formatRepository: () => formatRepository,
14
15
  getAuthorName: () => getAuthorName,
16
+ getBugsUrl: () => getBugsUrl,
17
+ getFundingUrl: () => getFundingUrl,
15
18
  getLastUpdatedPackageTime: () => getLastUpdatedPackageTime,
16
19
  getRecentReleases: () => getRecentReleases,
17
20
  getUplink: () => getUplink
@@ -36,6 +39,27 @@ function formatRepository(repository) {
36
39
  if (repository && typeof repository === "object" && "url" in repository && typeof repository.url === "string") return repository.url;
37
40
  return null;
38
41
  }
42
+ /**
43
+ * Normalizes the `bugs` field to its url.
44
+ * @see https://docs.npmjs.com/cli/configuring-npm/package-json#bugs
45
+ */
46
+ function getBugsUrl(bugs) {
47
+ if (typeof bugs === "string") return bugs;
48
+ if (bugs && typeof bugs === "object" && "url" in bugs && typeof bugs.url === "string") return bugs.url;
49
+ return null;
50
+ }
51
+ /**
52
+ * Normalizes the `funding` field (string, object or array of both) to a url.
53
+ * @see https://docs.npmjs.com/cli/configuring-npm/package-json#funding
54
+ */
55
+ function getFundingUrl(funding) {
56
+ const entries = Array.isArray(funding) ? funding : [funding];
57
+ for (const entry of entries) {
58
+ if (typeof entry === "string" && isURL(entry)) return entry;
59
+ if (entry && typeof entry === "object" && "url" in entry && typeof entry.url === "string" && isURL(entry.url)) return entry.url;
60
+ }
61
+ return null;
62
+ }
39
63
  function formatDate(lastUpdate) {
40
64
  return dayjs(new Date(lastUpdate)).format(TIMEFORMAT);
41
65
  }
@@ -87,6 +111,6 @@ function fileSizeSI(a, b, c, d, e) {
87
111
  else return size.toFixed(1) + " " + "kMGTPEZY"[--e] + "B";
88
112
  }
89
113
  //#endregion
90
- export { TIMEFORMAT, fileSizeSI, formatDate, formatDateDistance, formatLicense, formatRepository, getAuthorName, getLastUpdatedPackageTime, getRecentReleases, getUplink, utils_exports };
114
+ export { TIMEFORMAT, fileSizeSI, formatDate, formatDateDistance, formatLicense, formatRepository, getAuthorName, getBugsUrl, getFundingUrl, getLastUpdatedPackageTime, getRecentReleases, getUplink, utils_exports };
91
115
 
92
116
  //# sourceMappingURL=utils.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.mjs","names":[],"sources":["../../src/utils/utils.ts"],"sourcesContent":["import dayjs from 'dayjs';\nimport localizedFormat from 'dayjs/plugin/localizedFormat';\nimport relativeTime from 'dayjs/plugin/relativeTime';\nimport i18next from 'i18next';\n\nimport type { UpLinks } from '@verdaccio/types';\n\nimport type { Time } from '../types/packageMeta';\n\nexport const TIMEFORMAT = 'L LTS';\n\ndayjs.extend(relativeTime);\ndayjs.extend(localizedFormat);\n\n/**\n * Formats license field for webui.\n * @see https://docs.npmjs.com/files/package.json#license\n */\nexport function formatLicense(license: string | { type?: string } | unknown): string | undefined {\n if (typeof license === 'string') {\n return license;\n }\n\n if (\n license &&\n typeof license === 'object' &&\n 'type' in license &&\n typeof license.type === 'string'\n ) {\n return license.type;\n }\n\n return undefined;\n}\n\nexport interface Repository {\n readonly type: string;\n readonly url: string;\n}\n\n/**\n * Formats repository field for webui.\n * @see https://docs.npmjs.com/files/package.json#repository\n */\nexport function formatRepository(repository: string | { url?: string } | unknown): string | null {\n if (typeof repository === 'string') {\n return repository;\n }\n\n if (\n repository &&\n typeof repository === 'object' &&\n 'url' in repository &&\n typeof repository.url === 'string'\n ) {\n return repository.url;\n }\n\n return null;\n}\n\nexport function formatDate(lastUpdate: string | number): string {\n return dayjs(new Date(lastUpdate)).format(TIMEFORMAT);\n}\n\nexport function formatDateDistance(lastUpdate: Date | string | number): string {\n return dayjs(new Date(lastUpdate)).fromNow();\n}\n\n/**\n * For <LastSync /> component\n * @param {array} uplinks\n */\nexport function getLastUpdatedPackageTime(uplinks: UpLinks = {}): string {\n let lastUpdate = 0;\n Object.keys(uplinks).forEach(function computeUplink(upLinkName): void {\n const status = uplinks[upLinkName];\n if (status.fetched > lastUpdate) {\n lastUpdate = status.fetched;\n }\n });\n\n return lastUpdate ? formatDate(lastUpdate) : '';\n}\n\n/**\n * For <LastSync /> component\n * @param {Object} time\n * @returns {Array} last 3 releases\n */\nexport function getRecentReleases(time: Time = {}): Time[] {\n const recent = Object.keys(time).map((version) => ({\n version,\n time: formatDate(time[version]),\n }));\n\n return recent.slice(recent.length - 3, recent.length).reverse();\n}\n\nexport function getAuthorName(authorName?: string): string {\n if (!authorName) {\n return i18next.t('author-unknown');\n }\n\n if (authorName.toLowerCase() === 'anonymous') {\n return i18next.t('author-anonymous');\n }\n\n return authorName;\n}\n\nexport function getUplink(upLinkName: string, packageName: string): string | null {\n // TODO: make this a config like \"uplinks: npmjs: web: https://www.npmjs.com/package/\"\n switch (upLinkName) {\n case 'npmjs':\n return `https://www.npmjs.com/package/${packageName}`;\n }\n return null;\n}\n\nexport function fileSizeSI(\n a: number,\n b?: typeof Math,\n c?: (p: number) => number,\n d?: number,\n e?: number\n): string {\n b = Math;\n c = b.log;\n d = 1e3;\n e = (c(a) / c(d)) | 0;\n const size = a / b.pow(d, e);\n // no decimals for Bytes\n if (e === 0) {\n return Math.floor(size) + ' Bytes';\n } else {\n return size.toFixed(1) + ' ' + 'kMGTPEZY'[--e] + 'B';\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AASA,IAAa,aAAa;AAE1B,MAAM,OAAO,YAAY;AACzB,MAAM,OAAO,eAAe;;;;;AAM5B,SAAgB,cAAc,SAAmE;CAC/F,IAAI,OAAO,YAAY,UACrB,OAAO;CAGT,IACE,WACA,OAAO,YAAY,YACnB,UAAU,WACV,OAAO,QAAQ,SAAS,UAExB,OAAO,QAAQ;AAInB;;;;;AAWA,SAAgB,iBAAiB,YAAgE;CAC/F,IAAI,OAAO,eAAe,UACxB,OAAO;CAGT,IACE,cACA,OAAO,eAAe,YACtB,SAAS,cACT,OAAO,WAAW,QAAQ,UAE1B,OAAO,WAAW;CAGpB,OAAO;AACT;AAEA,SAAgB,WAAW,YAAqC;CAC9D,OAAO,MAAM,IAAI,KAAK,UAAU,CAAC,CAAC,CAAC,OAAO,UAAU;AACtD;AAEA,SAAgB,mBAAmB,YAA4C;CAC7E,OAAO,MAAM,IAAI,KAAK,UAAU,CAAC,CAAC,CAAC,QAAQ;AAC7C;;;;;AAMA,SAAgB,0BAA0B,UAAmB,CAAC,GAAW;CACvE,IAAI,aAAa;CACjB,OAAO,KAAK,OAAO,CAAC,CAAC,QAAQ,SAAS,cAAc,YAAkB;EACpE,MAAM,SAAS,QAAQ;EACvB,IAAI,OAAO,UAAU,YACnB,aAAa,OAAO;CAExB,CAAC;CAED,OAAO,aAAa,WAAW,UAAU,IAAI;AAC/C;;;;;;AAOA,SAAgB,kBAAkB,OAAa,CAAC,GAAW;CACzD,MAAM,SAAS,OAAO,KAAK,IAAI,CAAC,CAAC,KAAK,aAAa;EACjD;EACA,MAAM,WAAW,KAAK,QAAQ;CAChC,EAAE;CAEF,OAAO,OAAO,MAAM,OAAO,SAAS,GAAG,OAAO,MAAM,CAAC,CAAC,QAAQ;AAChE;AAEA,SAAgB,cAAc,YAA6B;CACzD,IAAI,CAAC,YACH,OAAO,QAAQ,EAAE,gBAAgB;CAGnC,IAAI,WAAW,YAAY,MAAM,aAC/B,OAAO,QAAQ,EAAE,kBAAkB;CAGrC,OAAO;AACT;AAEA,SAAgB,UAAU,YAAoB,aAAoC;CAEhF,QAAQ,YAAR;EACE,KAAK,SACH,OAAO,iCAAiC;CAC5C;CACA,OAAO;AACT;AAEA,SAAgB,WACd,GACA,GACA,GACA,GACA,GACQ;CACR,IAAI;CACJ,IAAI,EAAE;CACN,IAAI;CACJ,IAAK,EAAE,CAAC,IAAI,EAAE,CAAC,IAAK;CACpB,MAAM,OAAO,IAAI,EAAE,IAAI,GAAG,CAAC;CAE3B,IAAI,MAAM,GACR,OAAO,KAAK,MAAM,IAAI,IAAI;MAE1B,OAAO,KAAK,QAAQ,CAAC,IAAI,MAAM,WAAW,EAAE,KAAK;AAErD"}
1
+ {"version":3,"file":"utils.mjs","names":[],"sources":["../../src/utils/utils.ts"],"sourcesContent":["import dayjs from 'dayjs';\nimport localizedFormat from 'dayjs/plugin/localizedFormat';\nimport relativeTime from 'dayjs/plugin/relativeTime';\nimport i18next from 'i18next';\n\nimport type { UpLinks } from '@verdaccio/types';\n\nimport type { Time } from '../types/packageMeta';\nimport { isURL } from './url';\n\nexport const TIMEFORMAT = 'L LTS';\n\ndayjs.extend(relativeTime);\ndayjs.extend(localizedFormat);\n\n/**\n * Formats license field for webui.\n * @see https://docs.npmjs.com/files/package.json#license\n */\nexport function formatLicense(license: string | { type?: string } | unknown): string | undefined {\n if (typeof license === 'string') {\n return license;\n }\n\n if (\n license &&\n typeof license === 'object' &&\n 'type' in license &&\n typeof license.type === 'string'\n ) {\n return license.type;\n }\n\n return undefined;\n}\n\nexport interface Repository {\n readonly type: string;\n readonly url: string;\n}\n\n/**\n * Formats repository field for webui.\n * @see https://docs.npmjs.com/files/package.json#repository\n */\nexport function formatRepository(repository: string | { url?: string } | unknown): string | null {\n if (typeof repository === 'string') {\n return repository;\n }\n\n if (\n repository &&\n typeof repository === 'object' &&\n 'url' in repository &&\n typeof repository.url === 'string'\n ) {\n return repository.url;\n }\n\n return null;\n}\n\n/**\n * Normalizes the `bugs` field to its url.\n * @see https://docs.npmjs.com/cli/configuring-npm/package-json#bugs\n */\nexport function getBugsUrl(bugs: unknown): string | null {\n if (typeof bugs === 'string') {\n return bugs;\n }\n\n if (bugs && typeof bugs === 'object' && 'url' in bugs && typeof bugs.url === 'string') {\n return bugs.url;\n }\n\n return null;\n}\n\n/**\n * Normalizes the `funding` field (string, object or array of both) to a url.\n * @see https://docs.npmjs.com/cli/configuring-npm/package-json#funding\n */\nexport function getFundingUrl(funding: unknown): string | null {\n const entries = Array.isArray(funding) ? funding : [funding];\n // first *valid* url wins: a malformed entry must not hide a later valid one\n for (const entry of entries) {\n if (typeof entry === 'string' && isURL(entry)) {\n return entry;\n }\n if (\n entry &&\n typeof entry === 'object' &&\n 'url' in entry &&\n typeof entry.url === 'string' &&\n isURL(entry.url)\n ) {\n return entry.url;\n }\n }\n\n return null;\n}\n\nexport function formatDate(lastUpdate: string | number): string {\n return dayjs(new Date(lastUpdate)).format(TIMEFORMAT);\n}\n\nexport function formatDateDistance(lastUpdate: Date | string | number): string {\n return dayjs(new Date(lastUpdate)).fromNow();\n}\n\n/**\n * For <LastSync /> component\n * @param {array} uplinks\n */\nexport function getLastUpdatedPackageTime(uplinks: UpLinks = {}): string {\n let lastUpdate = 0;\n Object.keys(uplinks).forEach(function computeUplink(upLinkName): void {\n const status = uplinks[upLinkName];\n if (status.fetched > lastUpdate) {\n lastUpdate = status.fetched;\n }\n });\n\n return lastUpdate ? formatDate(lastUpdate) : '';\n}\n\n/**\n * For <LastSync /> component\n * @param {Object} time\n * @returns {Array} last 3 releases\n */\nexport function getRecentReleases(time: Time = {}): Time[] {\n const recent = Object.keys(time).map((version) => ({\n version,\n time: formatDate(time[version]),\n }));\n\n return recent.slice(recent.length - 3, recent.length).reverse();\n}\n\nexport function getAuthorName(authorName?: string): string {\n if (!authorName) {\n return i18next.t('author-unknown');\n }\n\n if (authorName.toLowerCase() === 'anonymous') {\n return i18next.t('author-anonymous');\n }\n\n return authorName;\n}\n\nexport function getUplink(upLinkName: string, packageName: string): string | null {\n // TODO: make this a config like \"uplinks: npmjs: web: https://www.npmjs.com/package/\"\n switch (upLinkName) {\n case 'npmjs':\n return `https://www.npmjs.com/package/${packageName}`;\n }\n return null;\n}\n\nexport function fileSizeSI(\n a: number,\n b?: typeof Math,\n c?: (p: number) => number,\n d?: number,\n e?: number\n): string {\n b = Math;\n c = b.log;\n d = 1e3;\n e = (c(a) / c(d)) | 0;\n const size = a / b.pow(d, e);\n // no decimals for Bytes\n if (e === 0) {\n return Math.floor(size) + ' Bytes';\n } else {\n return size.toFixed(1) + ' ' + 'kMGTPEZY'[--e] + 'B';\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAUA,IAAa,aAAa;AAE1B,MAAM,OAAO,YAAY;AACzB,MAAM,OAAO,eAAe;;;;;AAM5B,SAAgB,cAAc,SAAmE;CAC/F,IAAI,OAAO,YAAY,UACrB,OAAO;CAGT,IACE,WACA,OAAO,YAAY,YACnB,UAAU,WACV,OAAO,QAAQ,SAAS,UAExB,OAAO,QAAQ;AAInB;;;;;AAWA,SAAgB,iBAAiB,YAAgE;CAC/F,IAAI,OAAO,eAAe,UACxB,OAAO;CAGT,IACE,cACA,OAAO,eAAe,YACtB,SAAS,cACT,OAAO,WAAW,QAAQ,UAE1B,OAAO,WAAW;CAGpB,OAAO;AACT;;;;;AAMA,SAAgB,WAAW,MAA8B;CACvD,IAAI,OAAO,SAAS,UAClB,OAAO;CAGT,IAAI,QAAQ,OAAO,SAAS,YAAY,SAAS,QAAQ,OAAO,KAAK,QAAQ,UAC3E,OAAO,KAAK;CAGd,OAAO;AACT;;;;;AAMA,SAAgB,cAAc,SAAiC;CAC7D,MAAM,UAAU,MAAM,QAAQ,OAAO,IAAI,UAAU,CAAC,OAAO;CAE3D,KAAK,MAAM,SAAS,SAAS;EAC3B,IAAI,OAAO,UAAU,YAAY,MAAM,KAAK,GAC1C,OAAO;EAET,IACE,SACA,OAAO,UAAU,YACjB,SAAS,SACT,OAAO,MAAM,QAAQ,YACrB,MAAM,MAAM,GAAG,GAEf,OAAO,MAAM;CAEjB;CAEA,OAAO;AACT;AAEA,SAAgB,WAAW,YAAqC;CAC9D,OAAO,MAAM,IAAI,KAAK,UAAU,CAAC,CAAC,CAAC,OAAO,UAAU;AACtD;AAEA,SAAgB,mBAAmB,YAA4C;CAC7E,OAAO,MAAM,IAAI,KAAK,UAAU,CAAC,CAAC,CAAC,QAAQ;AAC7C;;;;;AAMA,SAAgB,0BAA0B,UAAmB,CAAC,GAAW;CACvE,IAAI,aAAa;CACjB,OAAO,KAAK,OAAO,CAAC,CAAC,QAAQ,SAAS,cAAc,YAAkB;EACpE,MAAM,SAAS,QAAQ;EACvB,IAAI,OAAO,UAAU,YACnB,aAAa,OAAO;CAExB,CAAC;CAED,OAAO,aAAa,WAAW,UAAU,IAAI;AAC/C;;;;;;AAOA,SAAgB,kBAAkB,OAAa,CAAC,GAAW;CACzD,MAAM,SAAS,OAAO,KAAK,IAAI,CAAC,CAAC,KAAK,aAAa;EACjD;EACA,MAAM,WAAW,KAAK,QAAQ;CAChC,EAAE;CAEF,OAAO,OAAO,MAAM,OAAO,SAAS,GAAG,OAAO,MAAM,CAAC,CAAC,QAAQ;AAChE;AAEA,SAAgB,cAAc,YAA6B;CACzD,IAAI,CAAC,YACH,OAAO,QAAQ,EAAE,gBAAgB;CAGnC,IAAI,WAAW,YAAY,MAAM,aAC/B,OAAO,QAAQ,EAAE,kBAAkB;CAGrC,OAAO;AACT;AAEA,SAAgB,UAAU,YAAoB,aAAoC;CAEhF,QAAQ,YAAR;EACE,KAAK,SACH,OAAO,iCAAiC;CAC5C;CACA,OAAO;AACT;AAEA,SAAgB,WACd,GACA,GACA,GACA,GACA,GACQ;CACR,IAAI;CACJ,IAAI,EAAE;CACN,IAAI;CACJ,IAAK,EAAE,CAAC,IAAI,EAAE,CAAC,IAAK;CACpB,MAAM,OAAO,IAAI,EAAE,IAAI,GAAG,CAAC;CAE3B,IAAI,MAAM,GACR,OAAO,KAAK,MAAM,IAAI,IAAI;MAE1B,OAAO,KAAK,QAAQ,CAAC,IAAI,MAAM,WAAW,EAAE,KAAK;AAErD"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@verdaccio/ui-components",
3
- "version": "5.0.0-next-9.20",
3
+ "version": "5.0.0-next-9.21",
4
4
  "description": "Verdaccio UI Components",
5
5
  "author": "Juan Picado <juanpicado19@gmail.com>",
6
6
  "license": "MIT",
@@ -41,7 +41,7 @@
41
41
  "@mui/icons-material": "7.3.11",
42
42
  "@mui/material": "7.3.11",
43
43
  "@mui/system": "7.3.11",
44
- "@verdaccio/ui-i18n": "10.0.0-next-9.4",
44
+ "@verdaccio/ui-i18n": "10.0.0-next-9.5",
45
45
  "country-flag-icons": "1.6.20",
46
46
  "dayjs": "1.11.23",
47
47
  "debug": "4.4.3",
@@ -56,7 +56,7 @@
56
56
  "normalize.css": "8.0.1",
57
57
  "react": "19.2.8",
58
58
  "react-dom": "19.2.8",
59
- "react-hook-form": "7.85.0",
59
+ "react-hook-form": "7.86.0",
60
60
  "react-i18next": "16.6.6",
61
61
  "react-markdown": "10.1.0",
62
62
  "react-router": "8.3.0",
@@ -75,7 +75,7 @@
75
75
  "@testing-library/react": "16.3.2",
76
76
  "@types/lodash-es": "4.17.12",
77
77
  "@types/node": "24.13.2",
78
- "@verdaccio/types": "14.0.0-next-9.13",
78
+ "@verdaccio/types": "14.0.0-next-9.14",
79
79
  "@vitejs/plugin-react": "6.0.5",
80
80
  "cross-env": "10.1.0",
81
81
  "generate-github-markdown-css": "6.6.0",
@@ -86,7 +86,7 @@
86
86
  "mutationobserver-shim": "0.3.7",
87
87
  "rimraf": "6.1.3",
88
88
  "storybook": "10.2.17",
89
- "vite": "8.2.1",
89
+ "vite": "8.2.2",
90
90
  "vitest": "4.1.10",
91
91
  "whatwg-fetch": "3.6.20"
92
92
  },
@@ -100,7 +100,7 @@
100
100
  "clean": "rimraf ./build",
101
101
  "type-check": "tsc --noEmit -p tsconfig.build.json",
102
102
  "watch": "vite build --watch",
103
- "build": "node tools/generate-github-markdown.mjs && vite build",
103
+ "build": "vite build",
104
104
  "start": "cross-env BROWSER=none storybook dev -p 6006",
105
105
  "build-storybook": "storybook build",
106
106
  "generate:github-markdown-css": "node tools/generate-github-markdown.mjs"