@verdaccio/ui-components 4.0.0-next-8.2 → 4.0.0-next-8.4

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 (278) hide show
  1. package/.babelrc +9 -1
  2. package/CHANGELOG.md +4 -269
  3. package/build/AppTest/AppRoute.js +18 -27
  4. package/build/AppTest/pages/Front/Home.js +2 -8
  5. package/build/AppTest/pages/Front/index.js +1 -13
  6. package/build/AppTest/pages/Version/Version.js +15 -19
  7. package/build/AppTest/pages/Version/index.js +1 -13
  8. package/build/Theme/ResetStyles.js +10 -16
  9. package/build/Theme/StyleBaseline.js +6 -13
  10. package/build/Theme/ThemeProvider.js +25 -33
  11. package/build/Theme/colors.js +1 -7
  12. package/build/Theme/index.js +5 -44
  13. package/build/Theme/theme.js +26 -32
  14. package/build/components/ActionBar/ActionBar.js +26 -33
  15. package/build/components/ActionBar/ActionBarAction.js +59 -59
  16. package/build/components/ActionBar/index.js +1 -13
  17. package/build/components/Author/Author.js +17 -23
  18. package/build/components/Author/index.js +1 -13
  19. package/build/components/Author/styles.js +5 -12
  20. package/build/components/CopyClipboard/CopyToClipBoard.js +40 -40
  21. package/build/components/CopyClipboard/index.js +2 -20
  22. package/build/components/CopyClipboard/utils.js +1 -8
  23. package/build/components/Dependencies/Dependencies.js +27 -34
  24. package/build/components/Dependencies/DependencyBlock.js +29 -35
  25. package/build/components/Dependencies/index.js +1 -13
  26. package/build/components/Dependencies/types.js +1 -5
  27. package/build/components/Dependencies/utits.js +1 -7
  28. package/build/components/Deprecated/Deprecated.js +10 -16
  29. package/build/components/Deprecated/index.js +1 -13
  30. package/build/components/Developers/DeveloperType.js +1 -7
  31. package/build/components/Developers/Developers.js +29 -37
  32. package/build/components/Developers/Title.js +26 -29
  33. package/build/components/Developers/get-unique-developer-values.js +1 -7
  34. package/build/components/Developers/index.js +2 -20
  35. package/build/components/Distribution/Dist.js +29 -32
  36. package/build/components/Distribution/index.js +1 -13
  37. package/build/components/Distribution/styles.js +7 -14
  38. package/build/components/Engines/Engines.js +53 -54
  39. package/build/components/Engines/index.js +1 -13
  40. package/build/components/Engines/styles.js +5 -12
  41. package/build/components/ErrorBoundary/ErrorBoundary.js +5 -14
  42. package/build/components/ErrorBoundary/index.js +1 -13
  43. package/build/components/Forbidden/Forbidden.js +33 -35
  44. package/build/components/Forbidden/index.js +1 -13
  45. package/build/components/FundButton/FundButton.js +42 -41
  46. package/build/components/FundButton/index.js +1 -13
  47. package/build/components/HeaderInfoDialog/HeaderInfoDialog.js +39 -41
  48. package/build/components/HeaderInfoDialog/index.js +1 -13
  49. package/build/components/Heading/Heading.js +12 -17
  50. package/build/components/Heading/index.js +1 -13
  51. package/build/components/Help/Help.js +23 -31
  52. package/build/components/Help/index.js +1 -13
  53. package/build/components/Help/styles.js +3 -10
  54. package/build/components/Icons/DevsIcons/CommonJS.js +4 -11
  55. package/build/components/Icons/DevsIcons/ES6Module.js +4 -11
  56. package/build/components/Icons/DevsIcons/Git.js +4 -11
  57. package/build/components/Icons/DevsIcons/NodeJS.js +4 -11
  58. package/build/components/Icons/DevsIcons/TypeScript.js +4 -11
  59. package/build/components/Icons/DevsIcons/index.js +5 -40
  60. package/build/components/Icons/Earth.js +13 -19
  61. package/build/components/Icons/FileBinary.js +6 -12
  62. package/build/components/Icons/Law.js +6 -12
  63. package/build/components/Icons/License.js +7 -13
  64. package/build/components/Icons/License.js.map +1 -1
  65. package/build/components/Icons/Managers/Npm.js +4 -11
  66. package/build/components/Icons/Managers/Pnpm.js +4 -11
  67. package/build/components/Icons/Managers/Yarn.js +4 -11
  68. package/build/components/Icons/Managers/index.js +3 -26
  69. package/build/components/Icons/SvgIcon.js +27 -23
  70. package/build/components/Icons/Time.js +8 -14
  71. package/build/components/Icons/Version.js +6 -12
  72. package/build/components/Icons/index.js +8 -79
  73. package/build/components/Install/Install.js +32 -39
  74. package/build/components/Install/InstallListItem.js +47 -52
  75. package/build/components/Install/index.js +1 -13
  76. package/build/components/Keywords/KeywordListItems.js +11 -17
  77. package/build/components/Keywords/Keywords.js +20 -25
  78. package/build/components/Keywords/index.js +1 -13
  79. package/build/components/Label/Label.js +17 -18
  80. package/build/components/Label/index.js +1 -13
  81. package/build/components/Link/Link.js +16 -22
  82. package/build/components/Link/index.js +1 -13
  83. package/build/components/LinkExternal/LinkExternal.js +15 -19
  84. package/build/components/LinkExternal/index.js +1 -13
  85. package/build/components/Loading/Loading.js +8 -15
  86. package/build/components/Loading/Spinner/Spinner.js +41 -35
  87. package/build/components/Loading/Spinner/index.js +1 -13
  88. package/build/components/Loading/index.js +1 -13
  89. package/build/components/Loading/styles.js +15 -19
  90. package/build/components/LoginDialog/LoginDialog.js +72 -68
  91. package/build/components/LoginDialog/LoginDialogCloseButton.js +28 -31
  92. package/build/components/LoginDialog/LoginDialogForm.js +46 -45
  93. package/build/components/LoginDialog/LoginDialogFormError.js +34 -36
  94. package/build/components/LoginDialog/LoginDialogHeader.js +42 -42
  95. package/build/components/LoginDialog/index.js +1 -13
  96. package/build/components/Logo/Logo.js +44 -47
  97. package/build/components/Logo/index.js +1 -13
  98. package/build/components/MenuItem/MenuItem.js +7 -16
  99. package/build/components/MenuItem/index.js +1 -13
  100. package/build/components/NoItems/NoItems.js +16 -17
  101. package/build/components/NoItems/index.js +1 -13
  102. package/build/components/NotFound/NotFound.js +31 -35
  103. package/build/components/NotFound/index.js +1 -13
  104. package/build/components/Package/Package.js +105 -100
  105. package/build/components/Package/index.js +1 -20
  106. package/build/components/Package/styles.js +78 -73
  107. package/build/components/PackageList/PackageList.js +56 -57
  108. package/build/components/PackageList/index.js +1 -13
  109. package/build/components/Person/Person.js +22 -28
  110. package/build/components/Person/PersonTooltip.js +17 -21
  111. package/build/components/Person/index.js +1 -13
  112. package/build/components/Person/utils.js +6 -14
  113. package/build/components/RawViewer/RawViewer.js +27 -33
  114. package/build/components/RawViewer/index.js +1 -13
  115. package/build/components/Readme/Readme.js +21 -27
  116. package/build/components/Readme/Readme.js.map +1 -1
  117. package/build/components/Readme/Readme.spec.js +10 -13
  118. package/build/components/Readme/Readme.spec.js.map +1 -1
  119. package/build/components/Readme/index.js +1 -13
  120. package/build/components/Readme/types.js +1 -5
  121. package/build/components/Readme/utils.js +8 -16
  122. package/build/components/RegistryInfoDialog/RegistryInfoDialog.js +18 -24
  123. package/build/components/RegistryInfoDialog/index.js +1 -13
  124. package/build/components/RegistryInfoDialog/styles.js +34 -32
  125. package/build/components/RegistryInfoDialog/types.js +1 -5
  126. package/build/components/Repository/Repository.js +36 -41
  127. package/build/components/Repository/index.js +1 -13
  128. package/build/components/Search/AutoComplete/AutoComplete.js +22 -31
  129. package/build/components/Search/AutoComplete/index.js +1 -13
  130. package/build/components/Search/AutoComplete/styles.js +2 -9
  131. package/build/components/Search/Search.js +71 -69
  132. package/build/components/Search/SearchItem.js +87 -79
  133. package/build/components/Search/index.js +1 -13
  134. package/build/components/Search/styles.js +7 -14
  135. package/build/components/Search/utils.js +3 -9
  136. package/build/components/SettingsMenu/SettingsMenu.js +56 -57
  137. package/build/components/SettingsMenu/index.js +1 -13
  138. package/build/components/SideBarTitle/SideBarTitle.js +56 -54
  139. package/build/components/SideBarTitle/index.js +1 -13
  140. package/build/components/SideBarTitle/utils.js +6 -15
  141. package/build/components/TextField/TextField.js +22 -21
  142. package/build/components/TextField/index.js +1 -13
  143. package/build/components/UpLinks/UpLinks.js +32 -38
  144. package/build/components/UpLinks/UplinkLink.js +12 -18
  145. package/build/components/UpLinks/index.js +1 -13
  146. package/build/components/UpLinks/styles.js +28 -29
  147. package/build/components/Versions/HistoryList.js +56 -60
  148. package/build/components/Versions/TagList.js +29 -33
  149. package/build/components/Versions/Versions.js +44 -52
  150. package/build/components/Versions/index.js +1 -13
  151. package/build/components/Versions/styles.js +26 -27
  152. package/build/components/Versions/types.js +1 -5
  153. package/build/hooks/index.js +2 -20
  154. package/build/hooks/useLocalStorage.js +7 -12
  155. package/build/hooks/useOnClickOutside.js +4 -9
  156. package/build/index.js +63 -530
  157. package/build/layouts/Version/Version.js +9 -16
  158. package/build/layouts/Version/index.js +1 -13
  159. package/build/providers/AppConfigurationProvider/AppConfigurationProvider.js +24 -31
  160. package/build/providers/AppConfigurationProvider/index.js +1 -20
  161. package/build/providers/PersistenceSettingProvider/PersistenceSettingProvider.js +15 -24
  162. package/build/providers/PersistenceSettingProvider/index.js +1 -20
  163. package/build/providers/TranslatorProvider/TranslatorProvider.js +24 -30
  164. package/build/providers/TranslatorProvider/TranslatorProvider.spec.js +19 -22
  165. package/build/providers/TranslatorProvider/index.js +1 -26
  166. package/build/providers/VersionProvider/VersionProvider.js +27 -29
  167. package/build/providers/VersionProvider/index.js +1 -20
  168. package/build/providers/index.js +3 -38
  169. package/build/sections/Detail/ContainerContent.js +20 -28
  170. package/build/sections/Detail/Detail.js +22 -30
  171. package/build/sections/Detail/ReadmeSection.js +8 -14
  172. package/build/sections/Detail/Tabs.js +20 -26
  173. package/build/sections/Detail/index.js +1 -13
  174. package/build/sections/Footer/Footer.js +73 -70
  175. package/build/sections/Footer/index.js +1 -13
  176. package/build/sections/Footer/styles.js +62 -57
  177. package/build/sections/Header/Header.js +34 -42
  178. package/build/sections/Header/HeaderGreetings.js +12 -18
  179. package/build/sections/Header/HeaderLeft.js +25 -29
  180. package/build/sections/Header/HeaderMenu.js +23 -29
  181. package/build/sections/Header/HeaderRight.js +41 -49
  182. package/build/sections/Header/HeaderSettingsDialog.js +60 -58
  183. package/build/sections/Header/HeaderToolTip.js +13 -17
  184. package/build/sections/Header/HeaderToolTipIcon.js +23 -31
  185. package/build/sections/Header/LanguageSwitch.js +51 -54
  186. package/build/sections/Header/RegistryInfoContent/RegistryInfoContent.js +75 -80
  187. package/build/sections/Header/RegistryInfoContent/index.js +1 -13
  188. package/build/sections/Header/RegistryInfoContent/styles.js +12 -16
  189. package/build/sections/Header/index.js +1 -13
  190. package/build/sections/Header/styles.js +32 -36
  191. package/build/sections/Home/Home.js +14 -19
  192. package/build/sections/Home/index.js +1 -13
  193. package/build/sections/SideBar/Sidebar.js +45 -52
  194. package/build/sections/SideBar/index.js +1 -13
  195. package/build/sections/index.js +2 -20
  196. package/build/src/Theme/index.d.ts +1 -1
  197. package/build/src/components/SideBarTitle/SideBarTitle.d.ts +1 -1
  198. package/build/src/components/SideBarTitle/SideBarTitle.stories.d.ts +1 -0
  199. package/build/store/api.js +28 -29
  200. package/build/store/index.js +3 -51
  201. package/build/store/models/configuration.js +20 -22
  202. package/build/store/models/download.js +26 -27
  203. package/build/store/models/index.js +13 -19
  204. package/build/store/models/login.js +60 -63
  205. package/build/store/models/manifest.js +57 -58
  206. package/build/store/models/packages.js +29 -27
  207. package/build/store/models/routes.js +1 -7
  208. package/build/store/models/search.js +62 -61
  209. package/build/store/models/utils.js +1 -7
  210. package/build/store/storage.js +4 -11
  211. package/build/store/store.js +6 -13
  212. package/build/test/i18n-config.js +4 -11
  213. package/build/test/test-react-testing-library.js +32 -50
  214. package/build/types/index.js +1 -5
  215. package/build/types/packageMeta.js +1 -5
  216. package/build/utils/__partials__/packageMeta.js +1 -7
  217. package/build/utils/cli-utils.js +12 -32
  218. package/build/utils/index.js +8 -74
  219. package/build/utils/loadable.js +6 -14
  220. package/build/utils/routes.js +1 -7
  221. package/build/utils/token.js +11 -18
  222. package/build/utils/url.js +12 -22
  223. package/build/utils/utils.js +32 -46
  224. package/package.json +11 -9
  225. package/src/AppTest/AppRoute.test.tsx +5 -4
  226. package/src/Theme/index.ts +1 -1
  227. package/src/components/Author/Author.test.tsx +2 -1
  228. package/src/components/CopyClipboard/CopyToClipBoard.test.tsx +2 -1
  229. package/src/components/Dependencies/Dependencies.test.tsx +7 -0
  230. package/src/components/Dependencies/DependencyBlock.test.tsx +3 -2
  231. package/src/components/Engines/Engines.test.tsx +3 -2
  232. package/src/components/ErrorBoundary/ErrorBoundary.test.tsx +2 -1
  233. package/src/components/Forbidden/Forbidden.test.tsx +3 -2
  234. package/src/components/HeaderInfoDialog/HeaderInfoDialog.test.tsx +2 -1
  235. package/src/components/LoginDialog/LoginDialog.test.tsx +8 -7
  236. package/src/components/NotFound/Notfound.test.tsx +3 -2
  237. package/src/components/PackageList/Packagelist.test.tsx +2 -1
  238. package/src/components/Search/Search.test.tsx +9 -8
  239. package/src/components/SideBarTitle/SideBarTitle.stories.tsx +17 -4
  240. package/src/components/SideBarTitle/SideBarTitle.tsx +5 -3
  241. package/src/components/Versions/Versions.test.tsx +8 -8
  242. package/src/providers/TranslatorProvider/TranslatorProvider.spec.tsx +2 -1
  243. package/src/providers/VersionProvider/VersionProvider.tsx +5 -2
  244. package/src/sections/Home/Home.test.tsx +7 -3
  245. package/src/sections/SideBar/Sidebar.test.tsx +8 -7
  246. package/src/sections/SideBar/Sidebar.tsx +11 -7
  247. package/src/store/api.test.ts +8 -6
  248. package/src/store/models/login.test.ts +24 -20
  249. package/src/test/test-react-testing-library.tsx +3 -5
  250. package/src/utils/cli-utils.test.ts +10 -9
  251. package/src/utils/token.test.ts +5 -3
  252. package/tsconfig.build.json +1 -1
  253. package/vitest/api/glob-sidebar.json +12520 -0
  254. package/vitest/api/got-sidebar.json +23346 -0
  255. package/vitest/api/home-packages.json +40 -0
  256. package/vitest/api/jquery-readme.js +3 -0
  257. package/vitest/api/jquery-sidebar.json +5908 -0
  258. package/vitest/api/search-verdaccio.json +1192 -0
  259. package/vitest/api/storybook-readme.js +3 -0
  260. package/vitest/api/storybook-sidebar.json +53782 -0
  261. package/vitest/api/storybook-v.json +53782 -0
  262. package/vitest/identity.js +29 -0
  263. package/vitest/react-markdown.tsx +7 -0
  264. package/vitest/server-handlers.ts +82 -0
  265. package/vitest/server.ts +6 -0
  266. package/vitest/setup-env.ts +33 -0
  267. package/vitest/setup.ts +40 -0
  268. package/vitest/unit/components/__mocks__/token.ts +33 -0
  269. package/vitest/unit/empty-string.ts +1 -0
  270. package/vitest/unit/empty.ts +1 -0
  271. package/vitest/vitestSerializer.ts +31 -0
  272. package/vitest.config.mjs +39 -0
  273. package/build/__mocks__/react-markdown.js +0 -18
  274. package/build/__mocks__/remark-plugin.js +0 -8
  275. package/build/src/__mocks__/react-markdown.d.ts +0 -4
  276. package/build/src/__mocks__/remark-plugin.d.ts +0 -1
  277. package/src/__mocks__/react-markdown.tsx +0 -8
  278. package/src/__mocks__/remark-plugin.ts +0 -1
@@ -1,12 +1,9 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
- exports.handleResponseType = handleResponseType;
8
- var _storage = _interopRequireDefault(require("./storage"));
9
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
1
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
2
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
3
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
4
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
5
+ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
6
+ import storage from './storage';
10
7
  class CustomError extends Error {}
11
8
 
12
9
  /**
@@ -14,17 +11,17 @@ class CustomError extends Error {}
14
11
  * @param {object} response
15
12
  * @returns {promise}
16
13
  */
17
- function handleResponseType(response) {
14
+ export function handleResponseType(response) {
18
15
  if (response.headers) {
19
- const contentType = response.headers.get('Content-Type');
20
- if (contentType?.includes('application/pdf')) {
16
+ var contentType = response.headers.get('Content-Type');
17
+ if (contentType !== null && contentType !== void 0 && contentType.includes('application/pdf')) {
21
18
  return Promise.all([response.ok, response.blob()]);
22
19
  }
23
- if (contentType?.includes('application/json')) {
20
+ if (contentType !== null && contentType !== void 0 && contentType.includes('application/json')) {
24
21
  return Promise.all([response.ok, response.json()]);
25
22
  }
26
23
  // it includes all text types
27
- if (contentType?.includes('text/')) {
24
+ if (contentType !== null && contentType !== void 0 && contentType.includes('text/')) {
28
25
  return Promise.all([response.ok, response.text()]);
29
26
  }
30
27
 
@@ -37,31 +34,33 @@ function handleResponseType(response) {
37
34
  // error handling
38
35
  return Promise.all([response.ok, response]);
39
36
  }
40
- const AuthHeader = 'Authorization';
37
+ var AuthHeader = 'Authorization';
41
38
  class API {
42
- request(url, method = 'GET', options = {
43
- headers: {}
44
- }) {
45
- const token = _storage.default.getItem('token');
46
- const headers = new Headers(options.headers);
39
+ request(url) {
40
+ var method = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'GET';
41
+ var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {
42
+ headers: {}
43
+ };
44
+ var token = storage.getItem('token');
45
+ var headers = new Headers(options.headers);
47
46
  if (token && headers.has(AuthHeader) === false) {
48
- headers.set(AuthHeader, `Bearer ${token}`);
47
+ headers.set(AuthHeader, "Bearer ".concat(token));
49
48
  options.headers = headers;
50
49
  }
51
50
  headers.set('x-client', 'verdaccio-ui');
52
51
  return new Promise((resolve, reject) => {
53
- fetch(url, {
52
+ fetch(url, _objectSpread({
54
53
  method,
55
54
  credentials: 'same-origin',
56
- signal: options.signal,
57
- ...options
58
- }).then(handleResponseType).then(response => {
59
- const [ok, data] = response;
55
+ signal: options.signal
56
+ }, options)).then(handleResponseType).then(response => {
57
+ var [ok, data] = response;
60
58
  if (ok === true) {
61
59
  resolve(data);
62
60
  } else {
63
- const error = new CustomError(data?.statusText ?? 'Unknown error');
64
- error.code = data?.status ?? 500;
61
+ var _data$statusText, _data$status;
62
+ var error = new CustomError((_data$statusText = data === null || data === void 0 ? void 0 : data.statusText) !== null && _data$statusText !== void 0 ? _data$statusText : 'Unknown error');
63
+ error.code = (_data$status = data === null || data === void 0 ? void 0 : data.status) !== null && _data$status !== void 0 ? _data$status : 500;
65
64
  reject(error);
66
65
  }
67
66
  }).catch(error => {
@@ -70,5 +69,5 @@ class API {
70
69
  });
71
70
  }
72
71
  }
73
- var _default = exports.default = new API();
72
+ export default new API();
74
73
  //# sourceMappingURL=api.js.map
@@ -1,52 +1,4 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- Object.defineProperty(exports, "Dispatch", {
7
- enumerable: true,
8
- get: function () {
9
- return _store.Dispatch;
10
- }
11
- });
12
- Object.defineProperty(exports, "LoginBody", {
13
- enumerable: true,
14
- get: function () {
15
- return _login.LoginBody;
16
- }
17
- });
18
- Object.defineProperty(exports, "LoginError", {
19
- enumerable: true,
20
- get: function () {
21
- return _login.LoginError;
22
- }
23
- });
24
- Object.defineProperty(exports, "LoginResponse", {
25
- enumerable: true,
26
- get: function () {
27
- return _login.LoginResponse;
28
- }
29
- });
30
- Object.defineProperty(exports, "RootState", {
31
- enumerable: true,
32
- get: function () {
33
- return _store.RootState;
34
- }
35
- });
36
- Object.defineProperty(exports, "api", {
37
- enumerable: true,
38
- get: function () {
39
- return _api.default;
40
- }
41
- });
42
- Object.defineProperty(exports, "store", {
43
- enumerable: true,
44
- get: function () {
45
- return _store.store;
46
- }
47
- });
48
- var _store = require("./store");
49
- var _login = require("./models/login");
50
- var _api = _interopRequireDefault(require("./api"));
51
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
1
+ export { store, RootState, Dispatch } from './store';
2
+ export { LoginError, LoginBody, LoginResponse } from './models/login';
3
+ export { default as api } from './api';
52
4
  //# sourceMappingURL=index.js.map
@@ -1,18 +1,13 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.configuration = void 0;
7
- var _core = require("@rematch/core");
8
- var _isEmpty = _interopRequireDefault(require("lodash/isEmpty"));
9
- var _isNil = _interopRequireDefault(require("lodash/isNil"));
10
- var _Theme = require("../../Theme");
11
- var _api = _interopRequireDefault(require("../api"));
12
- var _routes = require("./routes");
13
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
14
- const defaultValues = {
15
- primaryColor: _Theme.colors.PRIMARY_COLOR,
1
+ function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
2
+ function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
3
+ import { createModel } from '@rematch/core';
4
+ import isEmpty from 'lodash/isEmpty';
5
+ import isNil from 'lodash/isNil';
6
+ import { colors } from '../../Theme';
7
+ import API from '../api';
8
+ import { APIRoute } from './routes';
9
+ var defaultValues = {
10
+ primaryColor: colors.PRIMARY_COLOR,
16
11
  darkMode: false,
17
12
  pkgManagers: ['yarn', 'pnpm', 'npm'],
18
13
  scope: '',
@@ -23,9 +18,10 @@ const defaultValues = {
23
18
  title: 'Verdaccio'
24
19
  };
25
20
  function getConfiguration() {
26
- const uiConfiguration = window?.__VERDACCIO_BASENAME_UI_OPTIONS ?? defaultValues;
27
- if ((0, _isNil.default)(uiConfiguration.primaryColor) || (0, _isEmpty.default)(uiConfiguration.primaryColor)) {
28
- uiConfiguration.primaryColor = _Theme.colors.PRIMARY_COLOR;
21
+ var _window$__VERDACCIO_B, _window;
22
+ var uiConfiguration = (_window$__VERDACCIO_B = (_window = window) === null || _window === void 0 ? void 0 : _window.__VERDACCIO_BASENAME_UI_OPTIONS) !== null && _window$__VERDACCIO_B !== void 0 ? _window$__VERDACCIO_B : defaultValues;
23
+ if (isNil(uiConfiguration.primaryColor) || isEmpty(uiConfiguration.primaryColor)) {
24
+ uiConfiguration.primaryColor = colors.PRIMARY_COLOR;
29
25
  }
30
26
  return uiConfiguration;
31
27
  }
@@ -34,14 +30,16 @@ function getConfiguration() {
34
30
  *
35
31
  * @category Model
36
32
  */
37
- const configuration = exports.configuration = (0, _core.createModel)()({
33
+ export var configuration = createModel()({
38
34
  state: {
39
35
  config: getConfiguration()
40
36
  },
41
37
  effects: dispatch => ({
42
- async getPackages() {
43
- const payload = await _api.default.request(_routes.APIRoute.CONFIG, 'GET');
44
- dispatch.packages.savePackages(payload);
38
+ getPackages() {
39
+ return _asyncToGenerator(function* () {
40
+ var payload = yield API.request(APIRoute.CONFIG, 'GET');
41
+ dispatch.packages.savePackages(payload);
42
+ })();
45
43
  }
46
44
  })
47
45
  });
@@ -1,38 +1,37 @@
1
- "use strict";
1
+ function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
2
+ function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
3
+ import { createModel } from '@rematch/core';
4
+ import { downloadFile, extractFileName } from '../../utils/url';
5
+ import API from '../api';
2
6
 
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.download = void 0;
7
- var _core = require("@rematch/core");
8
- var _url = require("../../utils/url");
9
- var _api = _interopRequireDefault(require("../api"));
10
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
11
7
  /**
12
8
  *
13
9
  * @category Model
14
10
  */
15
- const download = exports.download = (0, _core.createModel)()({
11
+ export var download = createModel()({
16
12
  state: {},
17
13
  reducers: {},
18
14
  effects: () => ({
19
- async getTarball({
20
- link
21
- }) {
22
- try {
23
- const fileStream = await _api.default.request(link, 'GET', {
24
- headers: {
25
- ['accept']: 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3'
26
- },
27
- credentials: 'include'
28
- });
29
- const fileName = (0, _url.extractFileName)(link);
30
- (0, _url.downloadFile)(fileStream, fileName);
31
- } catch (error) {
32
- // TODO: handle better error
33
- // eslint-disable-next-line no-console
34
- console.error('error on download', error);
35
- }
15
+ getTarball(_ref) {
16
+ return _asyncToGenerator(function* () {
17
+ var {
18
+ link
19
+ } = _ref;
20
+ try {
21
+ var fileStream = yield API.request(link, 'GET', {
22
+ headers: {
23
+ ['accept']: 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3'
24
+ },
25
+ credentials: 'include'
26
+ });
27
+ var fileName = extractFileName(link);
28
+ downloadFile(fileStream, fileName);
29
+ } catch (error) {
30
+ // TODO: handle better error
31
+ // eslint-disable-next-line no-console
32
+ console.error('error on download', error);
33
+ }
34
+ })();
36
35
  }
37
36
  })
38
37
  });
@@ -1,21 +1,15 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.models = void 0;
7
- var _configuration = require("./configuration");
8
- var _download = require("./download");
9
- var _login = require("./login");
10
- var _manifest = require("./manifest");
11
- var _packages = require("./packages");
12
- var _search = require("./search");
13
- const models = exports.models = {
14
- packages: _packages.packages,
15
- configuration: _configuration.configuration,
16
- search: _search.search,
17
- download: _download.download,
18
- login: _login.login,
19
- manifest: _manifest.manifest
1
+ import { configuration } from './configuration';
2
+ import { download } from './download';
3
+ import { login } from './login';
4
+ import { manifest } from './manifest';
5
+ import { packages } from './packages';
6
+ import { search } from './search';
7
+ export var models = {
8
+ packages,
9
+ configuration,
10
+ search,
11
+ download,
12
+ login,
13
+ manifest
20
14
  };
21
15
  //# sourceMappingURL=index.js.map
@@ -1,26 +1,24 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.HEADERS = void 0;
7
- exports.getDefaultUserState = getDefaultUserState;
8
- exports.login = void 0;
9
- var _core = require("@rematch/core");
10
- var _i18next = _interopRequireDefault(require("i18next"));
11
- var _utils = require("../../utils");
12
- var _api = _interopRequireDefault(require("../api"));
13
- var _storage = _interopRequireDefault(require("../storage"));
14
- var _routes = require("./routes");
15
- var _utils2 = require("./utils");
16
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
17
- const HEADERS = exports.HEADERS = {
1
+ function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
2
+ function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
3
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
4
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
5
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
6
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
7
+ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
8
+ import { createModel } from '@rematch/core';
9
+ import i18next from 'i18next';
10
+ import { isTokenExpire } from '../../utils';
11
+ import API from '../api';
12
+ import storage from '../storage';
13
+ import { APIRoute } from './routes';
14
+ import { stripTrailingSlash } from './utils';
15
+ export var HEADERS = {
18
16
  JSON: 'application/json'
19
17
  };
20
- function getDefaultUserState() {
21
- const token = _storage.default.getItem('token');
22
- const username = _storage.default.getItem('username');
23
- const defaultUserState = (0, _utils.isTokenExpire)(token) ? {
18
+ export function getDefaultUserState() {
19
+ var token = storage.getItem('token');
20
+ var username = storage.getItem('username');
21
+ var defaultUserState = isTokenExpire(token) ? {
24
22
  token: null,
25
23
  username: null
26
24
  } : {
@@ -29,75 +27,74 @@ function getDefaultUserState() {
29
27
  };
30
28
  return defaultUserState;
31
29
  }
32
- const defaultUserState = getDefaultUserState();
30
+ var defaultUserState = getDefaultUserState();
33
31
 
34
32
  /**
35
33
  *
36
34
  * @category Model
37
35
  */
38
- const login = exports.login = (0, _core.createModel)()({
36
+ export var login = createModel()({
39
37
  state: {
40
38
  username: defaultUserState.username,
41
39
  token: defaultUserState.token
42
40
  },
43
41
  reducers: {
44
42
  logOutUser(state) {
45
- _storage.default.removeItem('username');
46
- _storage.default.removeItem('token');
47
- return {
48
- ...state,
43
+ storage.removeItem('username');
44
+ storage.removeItem('token');
45
+ return _objectSpread(_objectSpread({}, state), {}, {
49
46
  username: null,
50
47
  token: null
51
- };
48
+ });
52
49
  },
53
50
  addError(state, error) {
54
- return {
55
- ...state,
51
+ return _objectSpread(_objectSpread({}, state), {}, {
56
52
  error
57
- };
53
+ });
58
54
  },
59
55
  clearError(state) {
60
- return {
61
- ...state,
56
+ return _objectSpread(_objectSpread({}, state), {}, {
62
57
  error: undefined
63
- };
58
+ });
64
59
  },
65
60
  logInUser(state, response) {
66
61
  // we might persist this in another way with
67
- _storage.default.setItem('username', response.username);
68
- _storage.default.setItem('token', response.token);
69
- return {
70
- ...state,
62
+ storage.setItem('username', response.username);
63
+ storage.setItem('token', response.token);
64
+ return _objectSpread(_objectSpread({}, state), {}, {
71
65
  token: response.token,
72
66
  username: response.username
73
- };
67
+ });
74
68
  }
75
69
  },
76
70
  effects: dispatch => ({
77
- async getUser({
78
- username,
79
- password
80
- }, state) {
81
- const basePath = (0, _utils2.stripTrailingSlash)(state.configuration.config.base);
82
- try {
83
- const payload = await _api.default.request(`${basePath}${_routes.APIRoute.LOGIN}`, 'POST', {
84
- body: JSON.stringify({
85
- username,
86
- password
87
- }),
88
- headers: {
89
- Accept: HEADERS.JSON,
90
- 'Content-Type': HEADERS.JSON
91
- }
92
- });
93
- dispatch.login.logInUser(payload);
94
- dispatch.packages.getPackages(undefined);
95
- } catch (error) {
96
- dispatch.login.addError({
97
- type: 'error',
98
- description: _i18next.default.t('form-validation.unable-to-sign-in')
99
- });
100
- }
71
+ getUser(_ref, state) {
72
+ return _asyncToGenerator(function* () {
73
+ var {
74
+ username,
75
+ password
76
+ } = _ref;
77
+ var basePath = stripTrailingSlash(state.configuration.config.base);
78
+ try {
79
+ var payload = yield API.request("".concat(basePath).concat(APIRoute.LOGIN), 'POST', {
80
+ body: JSON.stringify({
81
+ username,
82
+ password
83
+ }),
84
+ headers: {
85
+ Accept: HEADERS.JSON,
86
+ 'Content-Type': HEADERS.JSON
87
+ }
88
+ });
89
+ dispatch.login.logInUser(payload);
90
+ dispatch.packages.getPackages(undefined);
91
+ } catch (error) {
92
+ dispatch.login.addError({
93
+ type: 'error',
94
+ description: i18next.t('form-validation.unable-to-sign-in')
95
+ });
96
+ }
97
+ })();
101
98
  }
102
99
  })
103
100
  });
@@ -1,14 +1,14 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.manifest = void 0;
7
- var _core = require("@rematch/core");
8
- var _api = _interopRequireDefault(require("../api"));
9
- var _routes = require("./routes");
10
- var _utils = require("./utils");
11
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
1
+ function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
2
+ function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
3
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
4
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
5
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
6
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
7
+ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
8
+ import { createModel } from '@rematch/core';
9
+ import API from '../api';
10
+ import { APIRoute } from './routes';
11
+ import { stripTrailingSlash } from './utils';
12
12
  function isPackageVersionValid(packageMeta, packageVersion) {
13
13
  if (!packageVersion || typeof packageVersion === 'undefined') {
14
14
  // if is undefined, that means versions does not exist, we continue
@@ -24,40 +24,36 @@ function isPackageVersionValid(packageMeta, packageVersion) {
24
24
  *
25
25
  * @category Model
26
26
  */
27
- const manifest = exports.manifest = (0, _core.createModel)()({
27
+ export var manifest = createModel()({
28
28
  state: {},
29
29
  reducers: {
30
30
  notFound(state) {
31
- return {
32
- ...state,
31
+ return _objectSpread(_objectSpread({}, state), {}, {
33
32
  hasNotBeenFound: true,
34
33
  forbidden: false,
35
34
  manifest: undefined,
36
35
  packageName: undefined,
37
36
  packageVersion: undefined,
38
37
  readme: undefined
39
- };
38
+ });
40
39
  },
41
40
  forbidden(state) {
42
- return {
43
- ...state,
41
+ return _objectSpread(_objectSpread({}, state), {}, {
44
42
  forbidden: true,
45
43
  hasNotBeenFound: false,
46
44
  manifest: undefined,
47
45
  packageName: undefined,
48
46
  packageVersion: undefined,
49
47
  readme: undefined
50
- };
48
+ });
51
49
  },
52
50
  clearError(state) {
53
- return {
54
- ...state,
51
+ return _objectSpread(_objectSpread({}, state), {}, {
55
52
  isError: null
56
- };
53
+ });
57
54
  },
58
55
  isError(state) {
59
- return {
60
- ...state,
56
+ return _objectSpread(_objectSpread({}, state), {}, {
61
57
  isError: true,
62
58
  hasNotBeenFound: false,
63
59
  forbidden: false,
@@ -65,53 +61,56 @@ const manifest = exports.manifest = (0, _core.createModel)()({
65
61
  packageName: undefined,
66
62
  packageVersion: undefined,
67
63
  readme: undefined
68
- };
64
+ });
69
65
  },
70
- saveManifest(state, {
71
- packageName,
72
- packageVersion,
73
- manifest,
74
- readme
75
- }) {
76
- return {
77
- ...state,
66
+ saveManifest(state, _ref) {
67
+ var {
68
+ packageName,
69
+ packageVersion,
70
+ manifest,
71
+ readme
72
+ } = _ref;
73
+ return _objectSpread(_objectSpread({}, state), {}, {
78
74
  manifest,
79
75
  packageName,
80
76
  packageVersion,
81
77
  readme,
82
78
  hasNotBeenFound: false,
83
79
  forbidden: false
84
- };
80
+ });
85
81
  }
86
82
  },
87
83
  effects: dispatch => ({
88
- async getManifest({
89
- packageName,
90
- packageVersion
91
- }, state) {
92
- const basePath = (0, _utils.stripTrailingSlash)(state.configuration.config.base);
93
- try {
94
- const manifest = await _api.default.request(`${basePath}${_routes.APIRoute.SIDEBAR}${packageName}${packageVersion ? `?v=${packageVersion}` : ''}`);
95
-
96
- // FIXME: update types accordingly
97
- // @ts-ignore
98
- if (!isPackageVersionValid(manifest, packageVersion)) {
99
- throw new Error('not found');
100
- }
101
- const readme = await _api.default.request(`${basePath}${_routes.APIRoute.README}${packageName}${packageVersion ? `?v=${packageVersion}` : ''}`);
102
- dispatch.manifest.saveManifest({
84
+ getManifest(_ref2, state) {
85
+ return _asyncToGenerator(function* () {
86
+ var {
103
87
  packageName,
104
- packageVersion,
105
- manifest,
106
- readme
107
- });
108
- } catch (error) {
109
- if (error.code === 404) {
110
- dispatch.manifest.notFound();
111
- } else {
112
- dispatch.manifest.forbidden();
88
+ packageVersion
89
+ } = _ref2;
90
+ var basePath = stripTrailingSlash(state.configuration.config.base);
91
+ try {
92
+ var _manifest = yield API.request("".concat(basePath).concat(APIRoute.SIDEBAR).concat(packageName).concat(packageVersion ? "?v=".concat(packageVersion) : ''));
93
+
94
+ // FIXME: update types accordingly
95
+ // @ts-ignore
96
+ if (!isPackageVersionValid(_manifest, packageVersion)) {
97
+ throw new Error('not found');
98
+ }
99
+ var readme = yield API.request("".concat(basePath).concat(APIRoute.README).concat(packageName).concat(packageVersion ? "?v=".concat(packageVersion) : ''));
100
+ dispatch.manifest.saveManifest({
101
+ packageName,
102
+ packageVersion,
103
+ manifest: _manifest,
104
+ readme
105
+ });
106
+ } catch (error) {
107
+ if (error.code === 404) {
108
+ dispatch.manifest.notFound();
109
+ } else {
110
+ dispatch.manifest.forbidden();
111
+ }
113
112
  }
114
- }
113
+ })();
115
114
  }
116
115
  })
117
116
  });