@atlaspack/inspector 0.0.19-canary.3998

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 (235) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +126 -0
  3. package/bin/atlaspack-inspector.js +2 -0
  4. package/lib/backend/cli.js +4 -0
  5. package/lib/backend/config/logger.js +16 -0
  6. package/lib/backend/config/middleware/cacheDataMiddleware.js +60 -0
  7. package/lib/backend/config/middleware/errorHandlingMiddleware.js +17 -0
  8. package/lib/backend/config/middleware/errorHandlingMiddleware.test.js +44 -0
  9. package/lib/backend/config/middleware/loggingMiddleware.js +22 -0
  10. package/lib/backend/controllers/BundleGraphController.js +42 -0
  11. package/lib/backend/controllers/CacheDataController.js +143 -0
  12. package/lib/backend/controllers/FrontendAssetsController.js +61 -0
  13. package/lib/backend/controllers/TreeMapController.js +108 -0
  14. package/lib/backend/controllers/mcp/InspectorMCP.js +231 -0
  15. package/lib/backend/controllers/mcp/InspectorMCPController.js +16 -0
  16. package/lib/backend/errors/HTTPError.js +16 -0
  17. package/lib/backend/errors/HTTPError.test.js +21 -0
  18. package/lib/backend/index.js +177 -0
  19. package/lib/backend/services/AnalyticsService.js +86 -0
  20. package/lib/backend/services/LazyValue.js +33 -0
  21. package/lib/backend/services/LazyValue.test.js +12 -0
  22. package/lib/backend/services/buildJsonGraph.js +86 -0
  23. package/lib/backend/services/buildTreemap.js +140 -0
  24. package/lib/backend/services/buildTreemapBundle.test.js +298 -0
  25. package/lib/backend/services/findSourceCodeUrl.js +107 -0
  26. package/lib/backend/services/findSourceCodeUrl.test.js +216 -0
  27. package/lib/backend/services/getCacheStats.js +36 -0
  28. package/lib/backend/services/getCacheStats.test.js +162 -0
  29. package/lib/backend/services/getDisplayName.js +18 -0
  30. package/lib/backend/services/getDisplayName.test.js +71 -0
  31. package/lib/backend/services/loadCacheData.js +209 -0
  32. package/lib/backend/services/loadCacheData.test.js +79 -0
  33. package/lib/backend/testing/TemporaryDirectory.js +46 -0
  34. package/lib/frontend/node_modules/@atlaspack/packager-js/lib/dev-prelude.js +145 -0
  35. package/lib/frontend/node_modules/@atlaspack/packager-js/src/dev-prelude.js +145 -0
  36. package/package.json +75 -0
  37. package/screenshots/bottom-up.png +0 -0
  38. package/screenshots/cache-inspector.png +0 -0
  39. package/screenshots/treemap.png +0 -0
  40. package/src/backend/README.md +14 -0
  41. package/src/backend/cli.ts +3 -0
  42. package/src/backend/config/logger.ts +14 -0
  43. package/src/backend/config/middleware/cacheDataMiddleware.ts +94 -0
  44. package/src/backend/config/middleware/errorHandlingMiddleware.test.ts +52 -0
  45. package/src/backend/config/middleware/errorHandlingMiddleware.ts +20 -0
  46. package/src/backend/config/middleware/loggingMiddleware.ts +24 -0
  47. package/src/backend/controllers/BundleGraphController.ts +73 -0
  48. package/src/backend/controllers/CacheDataController.ts +187 -0
  49. package/src/backend/controllers/FrontendAssetsController.ts +28 -0
  50. package/src/backend/controllers/TreeMapController.ts +143 -0
  51. package/src/backend/controllers/mcp/InspectorMCP.ts +311 -0
  52. package/src/backend/controllers/mcp/InspectorMCPController.ts +17 -0
  53. package/src/backend/errors/HTTPError.test.ts +19 -0
  54. package/src/backend/errors/HTTPError.ts +14 -0
  55. package/src/backend/globals.d.ts +9 -0
  56. package/src/backend/index.ts +271 -0
  57. package/src/backend/services/AnalyticsService.ts +118 -0
  58. package/src/backend/services/LazyValue.test.ts +13 -0
  59. package/src/backend/services/LazyValue.ts +29 -0
  60. package/src/backend/services/buildJsonGraph.ts +124 -0
  61. package/src/backend/services/buildTreemap.ts +273 -0
  62. package/src/backend/services/buildTreemapBundle.test.ts +348 -0
  63. package/src/backend/services/findSourceCodeUrl.test.ts +228 -0
  64. package/src/backend/services/findSourceCodeUrl.ts +146 -0
  65. package/src/backend/services/getCacheStats.test.ts +169 -0
  66. package/src/backend/services/getCacheStats.ts +46 -0
  67. package/src/backend/services/getDisplayName.test.ts +84 -0
  68. package/src/backend/services/getDisplayName.ts +20 -0
  69. package/src/backend/services/loadCacheData.test.ts +101 -0
  70. package/src/backend/services/loadCacheData.ts +294 -0
  71. package/src/backend/testing/TemporaryDirectory.ts +50 -0
  72. package/src/frontend/.atlaspackrc +4 -0
  73. package/src/frontend/.eslintrc.json +19 -0
  74. package/src/frontend/dist/atlassian-dark-brand-refresh.91b786da.js +2 -0
  75. package/src/frontend/dist/atlassian-dark-brand-refresh.91b786da.js.map +1 -0
  76. package/src/frontend/dist/atlassian-dark-future.59ebadca.js +2 -0
  77. package/src/frontend/dist/atlassian-dark-future.59ebadca.js.map +1 -0
  78. package/src/frontend/dist/atlassian-dark-increased-contrast.ff6775f2.js +2 -0
  79. package/src/frontend/dist/atlassian-dark-increased-contrast.ff6775f2.js.map +1 -0
  80. package/src/frontend/dist/atlassian-dark.ad679134.js +2 -0
  81. package/src/frontend/dist/atlassian-dark.ad679134.js.map +1 -0
  82. package/src/frontend/dist/atlassian-legacy-dark.8aa27f7f.js +2 -0
  83. package/src/frontend/dist/atlassian-legacy-dark.8aa27f7f.js.map +1 -0
  84. package/src/frontend/dist/atlassian-legacy-light.2eb372ce.js +2 -0
  85. package/src/frontend/dist/atlassian-legacy-light.2eb372ce.js.map +1 -0
  86. package/src/frontend/dist/atlassian-light-brand-refresh.fadcab0a.js +2 -0
  87. package/src/frontend/dist/atlassian-light-brand-refresh.fadcab0a.js.map +1 -0
  88. package/src/frontend/dist/atlassian-light-future.612afe8a.js +2 -0
  89. package/src/frontend/dist/atlassian-light-future.612afe8a.js.map +1 -0
  90. package/src/frontend/dist/atlassian-light-increased-contrast.7161cd79.js +2 -0
  91. package/src/frontend/dist/atlassian-light-increased-contrast.7161cd79.js.map +1 -0
  92. package/src/frontend/dist/atlassian-light.bc343d4c.js +2 -0
  93. package/src/frontend/dist/atlassian-light.bc343d4c.js.map +1 -0
  94. package/src/frontend/dist/atlassian-shape.b92d69c0.js +2 -0
  95. package/src/frontend/dist/atlassian-shape.b92d69c0.js.map +1 -0
  96. package/src/frontend/dist/atlassian-spacing.60ddd8e7.js +2 -0
  97. package/src/frontend/dist/atlassian-spacing.60ddd8e7.js.map +1 -0
  98. package/src/frontend/dist/atlassian-typography-adg3.f88947f6.js +2 -0
  99. package/src/frontend/dist/atlassian-typography-adg3.f88947f6.js.map +1 -0
  100. package/src/frontend/dist/atlassian-typography-modernized.42016c51.js +2 -0
  101. package/src/frontend/dist/atlassian-typography-modernized.42016c51.js.map +1 -0
  102. package/src/frontend/dist/atlassian-typography-refreshed.ec0d111b.js +2 -0
  103. package/src/frontend/dist/atlassian-typography-refreshed.ec0d111b.js.map +1 -0
  104. package/src/frontend/dist/atlassian-typography.66d7e8f4.js +2 -0
  105. package/src/frontend/dist/atlassian-typography.66d7e8f4.js.map +1 -0
  106. package/src/frontend/dist/badge-light.7e55986a.png +0 -0
  107. package/src/frontend/dist/custom-theme.4680282a.js +2 -0
  108. package/src/frontend/dist/custom-theme.4680282a.js.map +1 -0
  109. package/src/frontend/dist/drag-handle.136830d3.js +2 -0
  110. package/src/frontend/dist/drag-handle.136830d3.js.map +1 -0
  111. package/src/frontend/dist/drag-handle.63bdb345.css +2 -0
  112. package/src/frontend/dist/drag-handle.63bdb345.css.map +1 -0
  113. package/src/frontend/dist/index.a41fafce.css +2 -0
  114. package/src/frontend/dist/index.a41fafce.css.map +1 -0
  115. package/src/frontend/dist/index.a4ce2b12.js +28 -0
  116. package/src/frontend/dist/index.a4ce2b12.js.map +1 -0
  117. package/src/frontend/dist/index.html +1 -0
  118. package/src/frontend/dist/index.runtime.a729d997.js +2 -0
  119. package/src/frontend/dist/index.runtime.a729d997.js.map +1 -0
  120. package/src/frontend/dist/refractor.2c1fd9a1.js +2 -0
  121. package/src/frontend/dist/refractor.2c1fd9a1.js.map +1 -0
  122. package/src/frontend/index.html +11 -0
  123. package/src/frontend/jest.config.js +16 -0
  124. package/src/frontend/package.json +64 -0
  125. package/src/frontend/src/APIError.test.ts +72 -0
  126. package/src/frontend/src/APIError.tsx +29 -0
  127. package/src/frontend/src/AppRoutes.tsx +56 -0
  128. package/src/frontend/src/hack-feature-flags.ts +6 -0
  129. package/src/frontend/src/main.tsx +50 -0
  130. package/src/frontend/src/test/stubCssModule.js +1 -0
  131. package/src/frontend/src/ui/App.module.css +122 -0
  132. package/src/frontend/src/ui/App.module.css.d.ts +8 -0
  133. package/src/frontend/src/ui/AppLayout/AppLayout.tsx +26 -0
  134. package/src/frontend/src/ui/AppLayout/SidebarNavigation/LinkItem.tsx +26 -0
  135. package/src/frontend/src/ui/AppLayout/SidebarNavigation/SidebarNavigation.tsx +45 -0
  136. package/src/frontend/src/ui/AppLayout/TopNavigation/Logo.module.css +12 -0
  137. package/src/frontend/src/ui/AppLayout/TopNavigation/Logo.module.css.d.ts +4 -0
  138. package/src/frontend/src/ui/AppLayout/TopNavigation/Logo.tsx +11 -0
  139. package/src/frontend/src/ui/AppLayout/TopNavigation/TopNavigation.module.css +14 -0
  140. package/src/frontend/src/ui/AppLayout/TopNavigation/TopNavigation.module.css.d.ts +3 -0
  141. package/src/frontend/src/ui/AppLayout/TopNavigation/TopNavigation.tsx +45 -0
  142. package/src/frontend/src/ui/AppLayout/TopNavigation/badge-light.png +0 -0
  143. package/src/frontend/src/ui/AppLayout/TopNavigation/logo-light.png +0 -0
  144. package/src/frontend/src/ui/DefaultLoadingIndicator/DefaultLoadingIndicator.module.css +9 -0
  145. package/src/frontend/src/ui/DefaultLoadingIndicator/DefaultLoadingIndicator.module.css.d.ts +3 -0
  146. package/src/frontend/src/ui/DefaultLoadingIndicator/DefaultLoadingIndicator.test.tsx +15 -0
  147. package/src/frontend/src/ui/DefaultLoadingIndicator/DefaultLoadingIndicator.tsx +14 -0
  148. package/src/frontend/src/ui/app/StatsPage.tsx +77 -0
  149. package/src/frontend/src/ui/app/cache/CacheKeysIndexPage.tsx +13 -0
  150. package/src/frontend/src/ui/app/cache/CacheKeysPage.module.css +11 -0
  151. package/src/frontend/src/ui/app/cache/CacheKeysPage.module.css.d.ts +4 -0
  152. package/src/frontend/src/ui/app/cache/CacheKeysPage.tsx +23 -0
  153. package/src/frontend/src/ui/app/cache/[key]/CacheValuePage.tsx +40 -0
  154. package/src/frontend/src/ui/app/cache/ui/CacheKeyList.module.css +40 -0
  155. package/src/frontend/src/ui/app/cache/ui/CacheKeyList.module.css.d.ts +7 -0
  156. package/src/frontend/src/ui/app/cache/ui/CacheKeyList.tsx +187 -0
  157. package/src/frontend/src/ui/app/cache-invalidation/CacheInvalidationPage.tsx +22 -0
  158. package/src/frontend/src/ui/app/cache-invalidation/[fileId]/CacheInvalidationFilePage.tsx +22 -0
  159. package/src/frontend/src/ui/app/cache-invalidation/ui/CacheFileList.module.css +40 -0
  160. package/src/frontend/src/ui/app/cache-invalidation/ui/CacheFileList.module.css.d.ts +7 -0
  161. package/src/frontend/src/ui/app/cache-invalidation/ui/CacheFileList.tsx +185 -0
  162. package/src/frontend/src/ui/app/treemap/BottomPanelResizeState.test.ts +25 -0
  163. package/src/frontend/src/ui/app/treemap/BottomPanelResizeState.tsx +48 -0
  164. package/src/frontend/src/ui/app/treemap/FoamTreemapPage.module.css +24 -0
  165. package/src/frontend/src/ui/app/treemap/FoamTreemapPage.module.css.d.ts +6 -0
  166. package/src/frontend/src/ui/app/treemap/FoamTreemapPage.tsx +47 -0
  167. package/src/frontend/src/ui/app/treemap/controllers/RelatedBundlesController.tsx +41 -0
  168. package/src/frontend/src/ui/app/treemap/controllers/UrlFocusController.tsx +33 -0
  169. package/src/frontend/src/ui/app/treemap/ui/BottomPanel/BottomPanel.module.css +24 -0
  170. package/src/frontend/src/ui/app/treemap/ui/BottomPanel/BottomPanel.module.css.d.ts +5 -0
  171. package/src/frontend/src/ui/app/treemap/ui/BottomPanel/BottomPanel.tsx +24 -0
  172. package/src/frontend/src/ui/app/treemap/ui/BottomPanel/FocusedGroupInfo/AdvancedSettings.module.css +13 -0
  173. package/src/frontend/src/ui/app/treemap/ui/BottomPanel/FocusedGroupInfo/AdvancedSettings.module.css.d.ts +5 -0
  174. package/src/frontend/src/ui/app/treemap/ui/BottomPanel/FocusedGroupInfo/AdvancedSettings.tsx +53 -0
  175. package/src/frontend/src/ui/app/treemap/ui/BottomPanel/FocusedGroupInfo/AssetTable/AssetTable.tsx +135 -0
  176. package/src/frontend/src/ui/app/treemap/ui/BottomPanel/FocusedGroupInfo/AssetTable/CollapsibleTable/CollapsibleTable.module.css +7 -0
  177. package/src/frontend/src/ui/app/treemap/ui/BottomPanel/FocusedGroupInfo/AssetTable/CollapsibleTable/CollapsibleTable.module.css.d.ts +3 -0
  178. package/src/frontend/src/ui/app/treemap/ui/BottomPanel/FocusedGroupInfo/AssetTable/CollapsibleTable/CollapsibleTable.tsx +123 -0
  179. package/src/frontend/src/ui/app/treemap/ui/BottomPanel/FocusedGroupInfo/AssetTable/CollapsibleTable/CollapsibleTableModel.tsx +18 -0
  180. package/src/frontend/src/ui/app/treemap/ui/BottomPanel/FocusedGroupInfo/AssetTable/CollapsibleTable/CollapsibleTableRow.module.css +20 -0
  181. package/src/frontend/src/ui/app/treemap/ui/BottomPanel/FocusedGroupInfo/AssetTable/CollapsibleTable/CollapsibleTableRow.module.css.d.ts +6 -0
  182. package/src/frontend/src/ui/app/treemap/ui/BottomPanel/FocusedGroupInfo/AssetTable/CollapsibleTable/CollapsibleTableRow.tsx +79 -0
  183. package/src/frontend/src/ui/app/treemap/ui/BottomPanel/FocusedGroupInfo/AssetTable/getFileURL.test.ts +19 -0
  184. package/src/frontend/src/ui/app/treemap/ui/BottomPanel/FocusedGroupInfo/AssetTable/getFileURL.ts +24 -0
  185. package/src/frontend/src/ui/app/treemap/ui/BottomPanel/FocusedGroupInfo/FocusedGroupInfo.module.css +20 -0
  186. package/src/frontend/src/ui/app/treemap/ui/BottomPanel/FocusedGroupInfo/FocusedGroupInfo.module.css.d.ts +5 -0
  187. package/src/frontend/src/ui/app/treemap/ui/BottomPanel/FocusedGroupInfo/FocusedGroupInfo.tsx +42 -0
  188. package/src/frontend/src/ui/app/treemap/ui/BottomPanel/FocusedGroupInfo/FocusedGroupInfoInner.module.css +29 -0
  189. package/src/frontend/src/ui/app/treemap/ui/BottomPanel/FocusedGroupInfo/FocusedGroupInfoInner.module.css.d.ts +6 -0
  190. package/src/frontend/src/ui/app/treemap/ui/BottomPanel/FocusedGroupInfo/FocusedGroupInfoInner.tsx +107 -0
  191. package/src/frontend/src/ui/app/treemap/ui/BottomPanel/FocusedGroupInfo/GraphContainer.module.css +7 -0
  192. package/src/frontend/src/ui/app/treemap/ui/BottomPanel/FocusedGroupInfo/GraphContainer.module.css.d.ts +3 -0
  193. package/src/frontend/src/ui/app/treemap/ui/BottomPanel/FocusedGroupInfo/GraphContainer.tsx +20 -0
  194. package/src/frontend/src/ui/app/treemap/ui/BottomPanel/FocusedGroupInfo/SourceCodeURL.tsx +5 -0
  195. package/src/frontend/src/ui/app/treemap/ui/BundleGraphRenderer.module.css +13 -0
  196. package/src/frontend/src/ui/app/treemap/ui/BundleGraphRenderer.module.css.d.ts +4 -0
  197. package/src/frontend/src/ui/app/treemap/ui/BundleGraphRenderer.tsx +95 -0
  198. package/src/frontend/src/ui/app/treemap/ui/FocusBreadcrumbs/FocusBreadcrumbs.module.css +6 -0
  199. package/src/frontend/src/ui/app/treemap/ui/FocusBreadcrumbs/FocusBreadcrumbs.module.css.d.ts +3 -0
  200. package/src/frontend/src/ui/app/treemap/ui/FocusBreadcrumbs/FocusBreadcrumbs.tsx +49 -0
  201. package/src/frontend/src/ui/app/treemap/ui/SigmaGraph.module.css +5 -0
  202. package/src/frontend/src/ui/app/treemap/ui/SigmaGraph.module.css.d.ts +3 -0
  203. package/src/frontend/src/ui/app/treemap/ui/SigmaGraph.tsx +80 -0
  204. package/src/frontend/src/ui/app/treemap/ui/Treemap.tsx +14 -0
  205. package/src/frontend/src/ui/app/treemap/ui/TreemapRenderer/ImpactScore.module.css +32 -0
  206. package/src/frontend/src/ui/app/treemap/ui/TreemapRenderer/ImpactScore.module.css.d.ts +5 -0
  207. package/src/frontend/src/ui/app/treemap/ui/TreemapRenderer/ImpactScore.tsx +24 -0
  208. package/src/frontend/src/ui/app/treemap/ui/TreemapRenderer/TreemapRenderer.module.css +14 -0
  209. package/src/frontend/src/ui/app/treemap/ui/TreemapRenderer/TreemapRenderer.module.css.d.ts +4 -0
  210. package/src/frontend/src/ui/app/treemap/ui/TreemapRenderer/TreemapRenderer.tsx +271 -0
  211. package/src/frontend/src/ui/app/treemap/ui/TreemapRenderer/TreemapTooltip.module.css +15 -0
  212. package/src/frontend/src/ui/app/treemap/ui/TreemapRenderer/TreemapTooltip.module.css.d.ts +4 -0
  213. package/src/frontend/src/ui/app/treemap/ui/TreemapRenderer/TreemapTooltip.tsx +111 -0
  214. package/src/frontend/src/ui/app/treemap/ui/TreemapRenderer/controllers/useStableCallback.test.ts +27 -0
  215. package/src/frontend/src/ui/app/treemap/ui/TreemapRenderer/controllers/useStableCallback.ts +21 -0
  216. package/src/frontend/src/ui/app/treemap/ui/TreemapRenderer/useMouseMoveController.ts +20 -0
  217. package/src/frontend/src/ui/globals.css +26 -0
  218. package/src/frontend/src/ui/globals.css.d.ts +1 -0
  219. package/src/frontend/src/ui/globals.d.ts +9 -0
  220. package/src/frontend/src/ui/model/ViewModel.test.ts +31 -0
  221. package/src/frontend/src/ui/model/ViewModel.ts +62 -0
  222. package/src/frontend/src/ui/not-found/NotFoundPage.module.css +7 -0
  223. package/src/frontend/src/ui/not-found/NotFoundPage.module.css.d.ts +3 -0
  224. package/src/frontend/src/ui/not-found/NotFoundPage.tsx +9 -0
  225. package/src/frontend/src/ui/types/Graph.tsx +12 -0
  226. package/src/frontend/src/ui/util/ErrorBoundary.module.css +3 -0
  227. package/src/frontend/src/ui/util/ErrorBoundary.module.css.d.ts +3 -0
  228. package/src/frontend/src/ui/util/ErrorBoundary.test.tsx +65 -0
  229. package/src/frontend/src/ui/util/ErrorBoundary.tsx +75 -0
  230. package/src/frontend/src/ui/util/colorPalette.tsx +122 -0
  231. package/src/frontend/src/ui/util/formatBytes.test.ts +13 -0
  232. package/src/frontend/src/ui/util/formatBytes.tsx +9 -0
  233. package/src/frontend/src/ui/util/getRandomDarkerColor.tsx +31 -0
  234. package/src/frontend/tsconfig.json +12 -0
  235. package/src/frontend/yarn.lock +0 -0
@@ -0,0 +1,145 @@
1
+ // modules are defined as an array
2
+ // [ module function, map of requires ]
3
+ //
4
+ // map of requires is short require name -> numeric require
5
+ //
6
+ // anything defined in a previous bundle is accessed via the
7
+ // orig method which is the require for previous bundles
8
+
9
+ (function (modules, entry, mainEntry, parcelRequireName, globalName) {
10
+ /* eslint-disable no-undef */
11
+ var globalObject =
12
+ typeof globalThis !== 'undefined'
13
+ ? globalThis
14
+ : typeof self !== 'undefined'
15
+ ? self
16
+ : typeof window !== 'undefined'
17
+ ? window
18
+ : typeof global !== 'undefined'
19
+ ? global
20
+ : {};
21
+ /* eslint-enable no-undef */
22
+
23
+ // Save the require from previous bundle to this closure if any
24
+ var previousRequire =
25
+ typeof globalObject[parcelRequireName] === 'function' &&
26
+ globalObject[parcelRequireName];
27
+
28
+ var cache = previousRequire.cache || {};
29
+ // Do not use `require` to prevent Webpack from trying to bundle this call
30
+ var nodeRequire =
31
+ typeof module !== 'undefined' &&
32
+ typeof module.require === 'function' &&
33
+ module.require.bind(module);
34
+
35
+ function newRequire(name, jumped) {
36
+ if (!cache[name]) {
37
+ if (!modules[name]) {
38
+ // if we cannot find the module within our internal map or
39
+ // cache jump to the current global require ie. the last bundle
40
+ // that was added to the page.
41
+ var currentRequire =
42
+ typeof globalObject[parcelRequireName] === 'function' &&
43
+ globalObject[parcelRequireName];
44
+ if (!jumped && currentRequire) {
45
+ return currentRequire(name, true);
46
+ }
47
+
48
+ // If there are other bundles on this page the require from the
49
+ // previous one is saved to 'previousRequire'. Repeat this as
50
+ // many times as there are bundles until the module is found or
51
+ // we exhaust the require chain.
52
+ if (previousRequire) {
53
+ return previousRequire(name, true);
54
+ }
55
+
56
+ // Try the node require function if it exists.
57
+ if (nodeRequire && typeof name === 'string') {
58
+ return nodeRequire(name);
59
+ }
60
+
61
+ var err = new Error("Cannot find module '" + name + "'");
62
+ err.code = 'MODULE_NOT_FOUND';
63
+ throw err;
64
+ }
65
+
66
+ localRequire.resolve = resolve;
67
+ localRequire.cache = {};
68
+
69
+ var module = (cache[name] = new newRequire.Module(name));
70
+
71
+ modules[name][0].call(
72
+ module.exports,
73
+ localRequire,
74
+ module,
75
+ module.exports,
76
+ globalObject
77
+ );
78
+ }
79
+
80
+ return cache[name].exports;
81
+
82
+ function localRequire(x) {
83
+ var res = localRequire.resolve(x);
84
+ return res === false ? {} : newRequire(res);
85
+ }
86
+
87
+ function resolve(x) {
88
+ var id = modules[name][1][x];
89
+ return id != null ? id : x;
90
+ }
91
+ }
92
+
93
+ function Module(moduleName) {
94
+ this.id = moduleName;
95
+ this.bundle = newRequire;
96
+ this.exports = {};
97
+ }
98
+
99
+ newRequire.isParcelRequire = true;
100
+ newRequire.Module = Module;
101
+ newRequire.modules = modules;
102
+ newRequire.cache = cache;
103
+ newRequire.parent = previousRequire;
104
+ newRequire.register = function (id, exports) {
105
+ modules[id] = [
106
+ function (require, module) {
107
+ module.exports = exports;
108
+ },
109
+ {},
110
+ ];
111
+ };
112
+
113
+ Object.defineProperty(newRequire, 'root', {
114
+ get: function () {
115
+ return globalObject[parcelRequireName];
116
+ },
117
+ });
118
+
119
+ globalObject[parcelRequireName] = newRequire;
120
+
121
+ for (var i = 0; i < entry.length; i++) {
122
+ newRequire(entry[i]);
123
+ }
124
+
125
+ if (mainEntry) {
126
+ // Expose entry point to Node, AMD or browser globals
127
+ // Based on https://github.com/ForbesLindesay/umd/blob/master/template.js
128
+ var mainExports = newRequire(mainEntry);
129
+
130
+ // CommonJS
131
+ if (typeof exports === 'object' && typeof module !== 'undefined') {
132
+ module.exports = mainExports;
133
+
134
+ // RequireJS
135
+ } else if (typeof define === 'function' && define.amd) {
136
+ define(function () {
137
+ return mainExports;
138
+ });
139
+
140
+ // <script>
141
+ } else if (globalName) {
142
+ this[globalName] = mainExports;
143
+ }
144
+ }
145
+ });
@@ -0,0 +1,145 @@
1
+ // modules are defined as an array
2
+ // [ module function, map of requires ]
3
+ //
4
+ // map of requires is short require name -> numeric require
5
+ //
6
+ // anything defined in a previous bundle is accessed via the
7
+ // orig method which is the require for previous bundles
8
+
9
+ (function (modules, entry, mainEntry, parcelRequireName, globalName) {
10
+ /* eslint-disable no-undef */
11
+ var globalObject =
12
+ typeof globalThis !== 'undefined'
13
+ ? globalThis
14
+ : typeof self !== 'undefined'
15
+ ? self
16
+ : typeof window !== 'undefined'
17
+ ? window
18
+ : typeof global !== 'undefined'
19
+ ? global
20
+ : {};
21
+ /* eslint-enable no-undef */
22
+
23
+ // Save the require from previous bundle to this closure if any
24
+ var previousRequire =
25
+ typeof globalObject[parcelRequireName] === 'function' &&
26
+ globalObject[parcelRequireName];
27
+
28
+ var cache = previousRequire.cache || {};
29
+ // Do not use `require` to prevent Webpack from trying to bundle this call
30
+ var nodeRequire =
31
+ typeof module !== 'undefined' &&
32
+ typeof module.require === 'function' &&
33
+ module.require.bind(module);
34
+
35
+ function newRequire(name, jumped) {
36
+ if (!cache[name]) {
37
+ if (!modules[name]) {
38
+ // if we cannot find the module within our internal map or
39
+ // cache jump to the current global require ie. the last bundle
40
+ // that was added to the page.
41
+ var currentRequire =
42
+ typeof globalObject[parcelRequireName] === 'function' &&
43
+ globalObject[parcelRequireName];
44
+ if (!jumped && currentRequire) {
45
+ return currentRequire(name, true);
46
+ }
47
+
48
+ // If there are other bundles on this page the require from the
49
+ // previous one is saved to 'previousRequire'. Repeat this as
50
+ // many times as there are bundles until the module is found or
51
+ // we exhaust the require chain.
52
+ if (previousRequire) {
53
+ return previousRequire(name, true);
54
+ }
55
+
56
+ // Try the node require function if it exists.
57
+ if (nodeRequire && typeof name === 'string') {
58
+ return nodeRequire(name);
59
+ }
60
+
61
+ var err = new Error("Cannot find module '" + name + "'");
62
+ err.code = 'MODULE_NOT_FOUND';
63
+ throw err;
64
+ }
65
+
66
+ localRequire.resolve = resolve;
67
+ localRequire.cache = {};
68
+
69
+ var module = (cache[name] = new newRequire.Module(name));
70
+
71
+ modules[name][0].call(
72
+ module.exports,
73
+ localRequire,
74
+ module,
75
+ module.exports,
76
+ globalObject
77
+ );
78
+ }
79
+
80
+ return cache[name].exports;
81
+
82
+ function localRequire(x) {
83
+ var res = localRequire.resolve(x);
84
+ return res === false ? {} : newRequire(res);
85
+ }
86
+
87
+ function resolve(x) {
88
+ var id = modules[name][1][x];
89
+ return id != null ? id : x;
90
+ }
91
+ }
92
+
93
+ function Module(moduleName) {
94
+ this.id = moduleName;
95
+ this.bundle = newRequire;
96
+ this.exports = {};
97
+ }
98
+
99
+ newRequire.isParcelRequire = true;
100
+ newRequire.Module = Module;
101
+ newRequire.modules = modules;
102
+ newRequire.cache = cache;
103
+ newRequire.parent = previousRequire;
104
+ newRequire.register = function (id, exports) {
105
+ modules[id] = [
106
+ function (require, module) {
107
+ module.exports = exports;
108
+ },
109
+ {},
110
+ ];
111
+ };
112
+
113
+ Object.defineProperty(newRequire, 'root', {
114
+ get: function () {
115
+ return globalObject[parcelRequireName];
116
+ },
117
+ });
118
+
119
+ globalObject[parcelRequireName] = newRequire;
120
+
121
+ for (var i = 0; i < entry.length; i++) {
122
+ newRequire(entry[i]);
123
+ }
124
+
125
+ if (mainEntry) {
126
+ // Expose entry point to Node, AMD or browser globals
127
+ // Based on https://github.com/ForbesLindesay/umd/blob/master/template.js
128
+ var mainExports = newRequire(mainEntry);
129
+
130
+ // CommonJS
131
+ if (typeof exports === 'object' && typeof module !== 'undefined') {
132
+ module.exports = mainExports;
133
+
134
+ // RequireJS
135
+ } else if (typeof define === 'function' && define.amd) {
136
+ define(function () {
137
+ return mainExports;
138
+ });
139
+
140
+ // <script>
141
+ } else if (globalName) {
142
+ this[globalName] = mainExports;
143
+ }
144
+ }
145
+ });
package/package.json ADDED
@@ -0,0 +1,75 @@
1
+ {
2
+ "name": "@atlaspack/inspector",
3
+ "version": "0.0.19-canary.3998+35dd7a9e2",
4
+ "license": "(MIT OR Apache-2.0)",
5
+ "authors": [
6
+ "Pedro Tacla Yamada"
7
+ ],
8
+ "publishConfig": {
9
+ "access": "public"
10
+ },
11
+ "scripts": {
12
+ "prepack": "yarn run build",
13
+ "build": "tsc --project . && cd .. && yarn workspace @atlaspack/inspector-frontend build",
14
+ "dev": "PINO_LEVEL=debug node --max-old-space-size=32768 --watch --require esbuild-register ./src/backend/cli.ts",
15
+ "docs": "npx typedoc --readme src/backend/README.md --entryPointStrategy Expand --out docs src/backend",
16
+ "lint": "oxlint",
17
+ "test": "yarn test:unit && yarn test:e2e",
18
+ "test:frontend": "yarn workspace @atlaspack/inspector-frontend test",
19
+ "test:unit": "jest ./src/backend",
20
+ "test:e2e": "yarn build && playwright test --update-snapshots missing ./test/e2e-tests/index.test.ts",
21
+ "test:e2e:debug": "playwright test ./test/e2e-tests/index.test.ts --debug"
22
+ },
23
+ "repository": {
24
+ "type": "git",
25
+ "url": "https://github.com/atlassian-labs/atlaspack.git"
26
+ },
27
+ "bin": {
28
+ "atlaspack-inspector": "bin/atlaspack-inspector.js"
29
+ },
30
+ "main": "lib/backend/index.js",
31
+ "files": [
32
+ "bin",
33
+ "lib",
34
+ "src",
35
+ "README.md",
36
+ "screenshots",
37
+ "frontend/dist"
38
+ ],
39
+ "dependencies": {
40
+ "@atlaspack/build-cache": "2.13.5",
41
+ "@atlaspack/cache": "3.2.21",
42
+ "@atlaspack/cli": "2.14.4",
43
+ "@atlaspack/core": "2.23.2",
44
+ "@atlaspack/feature-flags": "2.23.1",
45
+ "@modelcontextprotocol/sdk": "^1.13.0",
46
+ "commander": "^7.0.0",
47
+ "cors": "^2.8.5",
48
+ "express": "^5.1.0",
49
+ "pino": "^9.7.0",
50
+ "pino-http": "^10.5.0",
51
+ "pino-pretty": "^13.0.0",
52
+ "supertest": "^7.1.1",
53
+ "zod": "^3"
54
+ },
55
+ "devDependencies": {
56
+ "@playwright/test": "1.50.0",
57
+ "@types/cors": "^2.8.19",
58
+ "@types/express": "^4.17.21",
59
+ "@types/jest": "^30.0.0",
60
+ "@types/node": "^22.13.10",
61
+ "@types/sinon": "^17.0.4",
62
+ "@types/supertest": "^6.0.3",
63
+ "esbuild": "^0.25.5",
64
+ "esbuild-register": "^3.6.0",
65
+ "jest": "^30.0.0",
66
+ "oxlint": "^1.2.0",
67
+ "path-browserify": "^1.0.0",
68
+ "playwright": "1.50.0",
69
+ "prettier": "^3.5.3",
70
+ "sinon": "^20.0.0",
71
+ "ts-jest": "^29.3.4",
72
+ "typescript": "^5.8.3"
73
+ },
74
+ "gitHead": "35dd7a9e2b9c0817ef370addc55d0e91531b0722"
75
+ }
Binary file
Binary file
Binary file
@@ -0,0 +1,14 @@
1
+ API and HTTP server for `@atlaspack/inspector`.
2
+
3
+ Uses:
4
+
5
+ - `express`
6
+ - `pino`
7
+ - `@atlaspack/core`
8
+ - `@atlaspack/query`
9
+ - `@atlaspack/graph`
10
+
11
+ Exposes data from the `atlaspack` cache through a HTTP API.
12
+
13
+ Serves the front-end when in production mode. The front-end is bundled and published
14
+ with this package.
@@ -0,0 +1,3 @@
1
+ import {main} from './index';
2
+
3
+ main();
@@ -0,0 +1,14 @@
1
+ import pino from 'pino';
2
+ import pinoPretty from 'pino-pretty';
3
+
4
+ /**
5
+ * Pino is used for logging.
6
+ *
7
+ * - https://github.com/pinojs/pino
8
+ */
9
+ export const logger = pino(
10
+ {
11
+ level: process.env.PINO_LEVEL ?? 'info',
12
+ },
13
+ pinoPretty(),
14
+ );
@@ -0,0 +1,94 @@
1
+ /* eslint-disable monorepo/no-internal-import */
2
+ import {Request, Response, NextFunction} from 'express';
3
+ import {CacheData} from '../../services/loadCacheData';
4
+ import {HTTPError} from '../../errors/HTTPError';
5
+ // @ts-expect-error TS2749
6
+ import BundleGraph from '@atlaspack/core/lib/BundleGraph.js';
7
+ import {Treemap} from '../../services/buildTreemap';
8
+ // @ts-expect-error TS2749
9
+ import RequestTracker from '@atlaspack/core/lib/RequestTracker.js';
10
+ // @ts-expect-error TS2749
11
+ import AssetGraph from '@atlaspack/core/lib/AssetGraph.js';
12
+ import {LMDBLiteCache} from '@atlaspack/cache';
13
+
14
+ export function getCacheDataKey<K extends keyof CacheData>(
15
+ res: Response,
16
+ key: K,
17
+ missingKeyError?: string,
18
+ ): NonNullable<CacheData[K]> {
19
+ const cacheData: CacheData = res.locals.cacheData;
20
+ if (!cacheData[key]) {
21
+ throw new HTTPError(missingKeyError ?? `${key} not found`, 500);
22
+ }
23
+ return cacheData[key];
24
+ }
25
+
26
+ export const getCache = (res: Response): LMDBLiteCache =>
27
+ getCacheDataKey(res, 'cache');
28
+
29
+ let missingErrorHelp = `
30
+ Please make sure to run "atlaspack build --feature-flag cachePerformanceImprovements=true" before running the inspector.
31
+ Or your application's build command.
32
+ `.trim();
33
+
34
+ export const getBundleGraph = (res: Response): BundleGraph =>
35
+ getCacheDataKey(
36
+ res,
37
+ 'bundleGraph',
38
+ `
39
+ BundleGraph not found in cache. The bundle graph is the data structure that contains all the information about the
40
+ bundles in the application.
41
+
42
+ This could happen if you are trying to run the inspector against a cache which has no builds or where a build terminated
43
+ with errors before bundling.
44
+
45
+ ${missingErrorHelp}`.trim(),
46
+ );
47
+
48
+ export const getTreemap = (res: Response): Treemap =>
49
+ getCacheDataKey(
50
+ res,
51
+ 'treemap',
52
+ `
53
+ Treemap not found in cache. The treemap data can only be generated if the cache contains a bundle graph and request tracker.
54
+
55
+ This could happen if you are trying to run the inspector against a cache which has no builds or where a build terminated
56
+ with errors before writing the cache or finishing bundling.
57
+
58
+ ${missingErrorHelp}`.trim(),
59
+ );
60
+
61
+ export const getRequestTracker = (res: Response): RequestTracker =>
62
+ getCacheDataKey(
63
+ res,
64
+ 'requestTracker',
65
+ `
66
+ RequestTracker not found in cache. The request tracker is the data structure that contains all the information about the
67
+ build tasks made during the build.
68
+
69
+ This could happen if you are trying to run the inspector against a cache which has no builds or where a build terminated
70
+ with errors before writing the cache.
71
+
72
+ ${missingErrorHelp}`.trim(),
73
+ );
74
+
75
+ export const getAssetGraph = (res: Response): AssetGraph =>
76
+ getCacheDataKey(
77
+ res,
78
+ 'assetGraph',
79
+ `
80
+ AssetGraph not found in cache. The asset graph is the data structure that contains all the information about the
81
+ assets in the application.
82
+
83
+ This could happen if you are trying to run the inspector against a cache which has no builds or where a build terminated
84
+ with errors before transforming and resolving assets.
85
+
86
+ ${missingErrorHelp}`.trim(),
87
+ );
88
+
89
+ export function cacheDataMiddleware(cacheData: Promise<CacheData>) {
90
+ return async (_req: Request, res: Response, next: NextFunction) => {
91
+ res.locals.cacheData = await cacheData;
92
+ next();
93
+ };
94
+ }
@@ -0,0 +1,52 @@
1
+ import assert from 'assert';
2
+ import express from 'express';
3
+ import request from 'supertest';
4
+ import {errorHandlingMiddleware} from './errorHandlingMiddleware';
5
+ import {HTTPError} from '../../errors/HTTPError';
6
+
7
+ jest.mock('../logger');
8
+
9
+ describe('errorHandlingMiddleware integration', function () {
10
+ let app: express.Express;
11
+
12
+ beforeEach(() => {
13
+ app = express();
14
+
15
+ // Add test routes that throw errors
16
+ app.get('/http-error', (req, res, next) => {
17
+ next(new HTTPError('Custom not found', 404));
18
+ });
19
+
20
+ app.get('/server-error', (req, res, next) => {
21
+ next(new Error('Something went wrong'));
22
+ });
23
+
24
+ app.get('/bad-request', (req, res, next) => {
25
+ next(new HTTPError('Bad request error', 400));
26
+ });
27
+
28
+ // Add error handling middleware
29
+ app.use(errorHandlingMiddleware);
30
+ });
31
+
32
+ it('should handle HTTPError with custom status and message', async () => {
33
+ const response = await request(app).get('/http-error').expect(404);
34
+
35
+ assert.deepEqual(response.body, {error: 'Custom not found', status: 404});
36
+ });
37
+
38
+ it('should handle regular Error as 500 internal server error', async () => {
39
+ const response = await request(app).get('/server-error').expect(500);
40
+
41
+ assert.deepEqual(response.body, {
42
+ error: 'Internal server error',
43
+ status: 500,
44
+ });
45
+ });
46
+
47
+ it('should handle different HTTPError status codes', async () => {
48
+ const response = await request(app).get('/bad-request').expect(400);
49
+
50
+ assert.deepEqual(response.body, {error: 'Bad request error', status: 400});
51
+ });
52
+ });
@@ -0,0 +1,20 @@
1
+ import {NextFunction, Request, Response} from 'express';
2
+ import {HTTPError} from '../../errors/HTTPError';
3
+ import {logger} from '../logger';
4
+
5
+ /**
6
+ * A middleware that sets status codes for {@link HTTPError} instances.
7
+ */
8
+ export function errorHandlingMiddleware(
9
+ err: Error,
10
+ _req: Request,
11
+ res: Response,
12
+ _next: NextFunction,
13
+ ) {
14
+ if (err instanceof HTTPError) {
15
+ res.status(err.status).json({error: err.message, status: err.status});
16
+ } else {
17
+ logger.error(err, 'Internal server error');
18
+ res.status(500).json({error: 'Internal server error', status: 500});
19
+ }
20
+ }
@@ -0,0 +1,24 @@
1
+ import {logger} from '../logger';
2
+ import {Request, Response, RequestHandler, NextFunction} from 'express';
3
+
4
+ /**
5
+ * Log HTTP status codes and durations with `pino`.
6
+ */
7
+ export function loggingMiddleware(): RequestHandler {
8
+ return (req: Request, res: Response, next: NextFunction) => {
9
+ const start = Date.now();
10
+ next();
11
+ res.on('finish', () => {
12
+ const duration = Date.now() - start;
13
+ logger.debug(
14
+ {
15
+ method: req.method,
16
+ statusCode: res.statusCode,
17
+ url: req.url,
18
+ duration,
19
+ },
20
+ `[${res.statusCode}] ${req.method} ${req.url} ${duration}ms`,
21
+ );
22
+ });
23
+ };
24
+ }
@@ -0,0 +1,73 @@
1
+ /* eslint-disable monorepo/no-internal-import */
2
+ import {Router} from 'express';
3
+ // @ts-expect-error TS2749
4
+ import {Node} from '@atlaspack/core/lib/types.js';
5
+
6
+ import {buildJsonGraph} from '../services/buildJsonGraph';
7
+ import {
8
+ getBundleGraph,
9
+ getRequestTracker,
10
+ } from '../config/middleware/cacheDataMiddleware';
11
+ import {
12
+ findBundleInfo,
13
+ getWriteBundleRequestsByBundleId,
14
+ } from '../services/buildTreemap';
15
+
16
+ export interface BundleGraphControllerParams {
17
+ projectRoot: string;
18
+ repositoryRoot: string;
19
+ }
20
+
21
+ export function makeBundleGraphController({
22
+ projectRoot,
23
+ repositoryRoot,
24
+ }: BundleGraphControllerParams): Router {
25
+ const router = Router();
26
+
27
+ router.get('/api/bundle-graph', (req, res) => {
28
+ const bundleGraph = getBundleGraph(res);
29
+ const requestTracker = getRequestTracker(res);
30
+
31
+ const writeBundleRequestsByBundleId =
32
+ getWriteBundleRequestsByBundleId(requestTracker);
33
+
34
+ const jsonGraph = buildJsonGraph(
35
+ bundleGraph._graph,
36
+ typeof req.query.rootNodeId === 'string' ? req.query.rootNodeId : null,
37
+ (node: Node) => node.type !== 'asset' && node.type !== 'dependency',
38
+ (node: Node) => {
39
+ const writeBundleRequest = writeBundleRequestsByBundleId.get(node.id);
40
+ const {size, filePath} = findBundleInfo({
41
+ writeBundleRequest,
42
+ projectRoot,
43
+ repositoryRoot,
44
+ node,
45
+ });
46
+ return {
47
+ size,
48
+ filePath,
49
+ };
50
+ },
51
+ );
52
+
53
+ res.json(jsonGraph);
54
+ });
55
+
56
+ router.get('/api/bundle-graph/related-bundles', (req, res) => {
57
+ const bundleGraph = getBundleGraph(res);
58
+ const bundleId = req.query.bundle as string;
59
+
60
+ const bundle = bundleGraph._graph.getNode(
61
+ bundleGraph._graph.getNodeIdByContentKey(bundleId),
62
+ );
63
+ const childBundles = bundleGraph.getChildBundles(bundle).map((b: any) => ({
64
+ id: b.id,
65
+ }));
66
+
67
+ res.json({
68
+ childBundles,
69
+ });
70
+ });
71
+
72
+ return router;
73
+ }