@nimblesite/lsp-profiler-ui 0.0.0-stage → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (352) hide show
  1. package/LICENSE +21 -0
  2. package/out/src/bind-host.d.ts +3 -0
  3. package/out/src/bind-host.js +52 -0
  4. package/out/src/bind-host.js.map +1 -0
  5. package/out/src/context-keys.d.ts +4 -0
  6. package/out/src/context-keys.js +54 -0
  7. package/out/src/context-keys.js.map +1 -0
  8. package/out/src/dap-evaluate.d.ts +84 -0
  9. package/out/src/dap-evaluate.js +442 -0
  10. package/out/src/dap-evaluate.js.map +1 -0
  11. package/out/src/dap-output.d.ts +50 -0
  12. package/out/src/dap-output.js +177 -0
  13. package/out/src/dap-output.js.map +1 -0
  14. package/out/src/debug/adapter-resolution.d.ts +56 -0
  15. package/out/src/debug/adapter-resolution.js +112 -0
  16. package/out/src/debug/adapter-resolution.js.map +1 -0
  17. package/out/src/debug/dap-messages.d.ts +18 -0
  18. package/out/src/debug/dap-messages.js +71 -0
  19. package/out/src/debug/dap-messages.js.map +1 -0
  20. package/out/src/debug/index.d.ts +7 -0
  21. package/out/src/debug/index.js +27 -0
  22. package/out/src/debug/index.js.map +1 -0
  23. package/out/src/debug/launch-config.d.ts +42 -0
  24. package/out/src/debug/launch-config.js +73 -0
  25. package/out/src/debug/launch-config.js.map +1 -0
  26. package/out/src/debug/launch-lifecycle.d.ts +29 -0
  27. package/out/src/debug/launch-lifecycle.js +40 -0
  28. package/out/src/debug/launch-lifecycle.js.map +1 -0
  29. package/out/src/debug/poll.d.ts +25 -0
  30. package/out/src/debug/poll.js +70 -0
  31. package/out/src/debug/poll.js.map +1 -0
  32. package/out/src/debug/profiling.d.ts +34 -0
  33. package/out/src/debug/profiling.js +81 -0
  34. package/out/src/debug/profiling.js.map +1 -0
  35. package/out/src/debug/testing/assertions.d.ts +27 -0
  36. package/out/src/debug/testing/assertions.js +111 -0
  37. package/out/src/debug/testing/assertions.js.map +1 -0
  38. package/out/src/debug/testing/dap-client.d.ts +86 -0
  39. package/out/src/debug/testing/dap-client.js +204 -0
  40. package/out/src/debug/testing/dap-client.js.map +1 -0
  41. package/out/src/debug/testing/index.d.ts +7 -0
  42. package/out/src/debug/testing/index.js +31 -0
  43. package/out/src/debug/testing/index.js.map +1 -0
  44. package/out/src/debug/testing/vscode-harness.d.ts +44 -0
  45. package/out/src/debug/testing/vscode-harness.js +81 -0
  46. package/out/src/debug/testing/vscode-harness.js.map +1 -0
  47. package/out/src/debug/ui-stubs.d.ts +26 -0
  48. package/out/src/debug/ui-stubs.js +88 -0
  49. package/out/src/debug/ui-stubs.js.map +1 -0
  50. package/out/src/debug-link-setup.d.ts +4 -0
  51. package/out/src/debug-link-setup.js +19 -0
  52. package/out/src/debug-link-setup.js.map +1 -0
  53. package/out/src/debug-link-view.d.ts +4 -0
  54. package/out/src/debug-link-view.js +49 -0
  55. package/out/src/debug-link-view.js.map +1 -0
  56. package/out/src/debug-link.d.ts +6 -0
  57. package/out/src/debug-link.js +95 -0
  58. package/out/src/debug-link.js.map +1 -0
  59. package/out/src/debug-selection.d.ts +14 -0
  60. package/out/src/debug-selection.js +33 -0
  61. package/out/src/debug-selection.js.map +1 -0
  62. package/out/src/debuggee-pause.d.ts +11 -0
  63. package/out/src/debuggee-pause.js +109 -0
  64. package/out/src/debuggee-pause.js.map +1 -0
  65. package/out/src/editor-path-key.d.ts +52 -0
  66. package/out/src/editor-path-key.js +105 -0
  67. package/out/src/editor-path-key.js.map +1 -0
  68. package/out/src/failure.d.ts +5 -0
  69. package/out/src/failure.js +53 -0
  70. package/out/src/failure.js.map +1 -0
  71. package/out/src/file-log-sink.d.ts +20 -0
  72. package/out/src/file-log-sink.js +74 -0
  73. package/out/src/file-log-sink.js.map +1 -0
  74. package/out/src/flame-html.d.ts +8 -0
  75. package/out/src/flame-html.js +104 -0
  76. package/out/src/flame-html.js.map +1 -0
  77. package/out/src/flame-model.d.ts +93 -0
  78. package/out/src/flame-model.js +242 -0
  79. package/out/src/flame-model.js.map +1 -0
  80. package/out/src/flame-script-helpers.d.ts +26 -0
  81. package/out/src/flame-script-helpers.js +71 -0
  82. package/out/src/flame-script-helpers.js.map +1 -0
  83. package/out/src/flame-script.d.ts +1 -0
  84. package/out/src/flame-script.js +332 -0
  85. package/out/src/flame-script.js.map +1 -0
  86. package/out/src/flame-time-order.d.ts +14 -0
  87. package/out/src/flame-time-order.js +112 -0
  88. package/out/src/flame-time-order.js.map +1 -0
  89. package/out/src/flamegraph-artifact.d.ts +9 -0
  90. package/out/src/flamegraph-artifact.js +45 -0
  91. package/out/src/flamegraph-artifact.js.map +1 -0
  92. package/out/src/host.d.ts +31 -0
  93. package/out/src/host.js +6 -0
  94. package/out/src/host.js.map +1 -0
  95. package/out/src/ids.d.ts +27 -0
  96. package/out/src/ids.js +63 -0
  97. package/out/src/ids.js.map +1 -0
  98. package/out/src/index.d.ts +42 -0
  99. package/out/src/index.js +98 -0
  100. package/out/src/index.js.map +1 -0
  101. package/out/src/logger.d.ts +50 -0
  102. package/out/src/logger.js +86 -0
  103. package/out/src/logger.js.map +1 -0
  104. package/out/src/memory-autopilot.d.ts +64 -0
  105. package/out/src/memory-autopilot.js +306 -0
  106. package/out/src/memory-autopilot.js.map +1 -0
  107. package/out/src/memory-capture-ids.d.ts +17 -0
  108. package/out/src/memory-capture-ids.js +45 -0
  109. package/out/src/memory-capture-ids.js.map +1 -0
  110. package/out/src/memory-capture-ingest.d.ts +15 -0
  111. package/out/src/memory-capture-ingest.js +84 -0
  112. package/out/src/memory-capture-ingest.js.map +1 -0
  113. package/out/src/memory-capture-legs.d.ts +4 -0
  114. package/out/src/memory-capture-legs.js +55 -0
  115. package/out/src/memory-capture-legs.js.map +1 -0
  116. package/out/src/memory-capture-present.d.ts +32 -0
  117. package/out/src/memory-capture-present.js +71 -0
  118. package/out/src/memory-capture-present.js.map +1 -0
  119. package/out/src/memory-capture-roundtrip.d.ts +17 -0
  120. package/out/src/memory-capture-roundtrip.js +75 -0
  121. package/out/src/memory-capture-roundtrip.js.map +1 -0
  122. package/out/src/memory-capture-state.d.ts +23 -0
  123. package/out/src/memory-capture-state.js +89 -0
  124. package/out/src/memory-capture-state.js.map +1 -0
  125. package/out/src/memory-capture-types.d.ts +28 -0
  126. package/out/src/memory-capture-types.js +70 -0
  127. package/out/src/memory-capture-types.js.map +1 -0
  128. package/out/src/memory-capture.d.ts +24 -0
  129. package/out/src/memory-capture.js +51 -0
  130. package/out/src/memory-capture.js.map +1 -0
  131. package/out/src/memory-dashboard-html.d.ts +3 -0
  132. package/out/src/memory-dashboard-html.js +327 -0
  133. package/out/src/memory-dashboard-html.js.map +1 -0
  134. package/out/src/memory-dashboard-mapping.d.ts +34 -0
  135. package/out/src/memory-dashboard-mapping.js +135 -0
  136. package/out/src/memory-dashboard-mapping.js.map +1 -0
  137. package/out/src/memory-dashboard.d.ts +82 -0
  138. package/out/src/memory-dashboard.js +142 -0
  139. package/out/src/memory-dashboard.js.map +1 -0
  140. package/out/src/memory-decorations.d.ts +61 -0
  141. package/out/src/memory-decorations.js +247 -0
  142. package/out/src/memory-decorations.js.map +1 -0
  143. package/out/src/memory-finalize.d.ts +25 -0
  144. package/out/src/memory-finalize.js +207 -0
  145. package/out/src/memory-finalize.js.map +1 -0
  146. package/out/src/memory-guidance.d.ts +14 -0
  147. package/out/src/memory-guidance.js +36 -0
  148. package/out/src/memory-guidance.js.map +1 -0
  149. package/out/src/memory-inspect-commands.d.ts +20 -0
  150. package/out/src/memory-inspect-commands.js +114 -0
  151. package/out/src/memory-inspect-commands.js.map +1 -0
  152. package/out/src/memory-launch-direct.d.ts +12 -0
  153. package/out/src/memory-launch-direct.js +74 -0
  154. package/out/src/memory-launch-direct.js.map +1 -0
  155. package/out/src/memory-launch.d.ts +4 -0
  156. package/out/src/memory-launch.js +92 -0
  157. package/out/src/memory-launch.js.map +1 -0
  158. package/out/src/memory-leak-offer.d.ts +18 -0
  159. package/out/src/memory-leak-offer.js +51 -0
  160. package/out/src/memory-leak-offer.js.map +1 -0
  161. package/out/src/memory-profiler.d.ts +27 -0
  162. package/out/src/memory-profiler.js +71 -0
  163. package/out/src/memory-profiler.js.map +1 -0
  164. package/out/src/memory-ref-graph.d.ts +62 -0
  165. package/out/src/memory-ref-graph.js +248 -0
  166. package/out/src/memory-ref-graph.js.map +1 -0
  167. package/out/src/memory-ref-picker.d.ts +21 -0
  168. package/out/src/memory-ref-picker.js +103 -0
  169. package/out/src/memory-ref-picker.js.map +1 -0
  170. package/out/src/memory-registration.d.ts +4 -0
  171. package/out/src/memory-registration.js +63 -0
  172. package/out/src/memory-registration.js.map +1 -0
  173. package/out/src/memory-start-core.d.ts +8 -0
  174. package/out/src/memory-start-core.js +165 -0
  175. package/out/src/memory-start-core.js.map +1 -0
  176. package/out/src/memory-start-stop-commands.d.ts +10 -0
  177. package/out/src/memory-start-stop-commands.js +75 -0
  178. package/out/src/memory-start-stop-commands.js.map +1 -0
  179. package/out/src/memory-start.d.ts +6 -0
  180. package/out/src/memory-start.js +13 -0
  181. package/out/src/memory-start.js.map +1 -0
  182. package/out/src/memory-status.d.ts +24 -0
  183. package/out/src/memory-status.js +135 -0
  184. package/out/src/memory-status.js.map +1 -0
  185. package/out/src/palette-vscode.d.ts +2 -0
  186. package/out/src/palette-vscode.js +50 -0
  187. package/out/src/palette-vscode.js.map +1 -0
  188. package/out/src/palette.d.ts +70 -0
  189. package/out/src/palette.js +150 -0
  190. package/out/src/palette.js.map +1 -0
  191. package/out/src/process-bind-panel.d.ts +11 -0
  192. package/out/src/process-bind-panel.js +65 -0
  193. package/out/src/process-bind-panel.js.map +1 -0
  194. package/out/src/process-commands.d.ts +5 -0
  195. package/out/src/process-commands.js +112 -0
  196. package/out/src/process-commands.js.map +1 -0
  197. package/out/src/process-context-keys.d.ts +11 -0
  198. package/out/src/process-context-keys.js +48 -0
  199. package/out/src/process-context-keys.js.map +1 -0
  200. package/out/src/process-decoration.d.ts +18 -0
  201. package/out/src/process-decoration.js +76 -0
  202. package/out/src/process-decoration.js.map +1 -0
  203. package/out/src/process-explorer-rows.d.ts +59 -0
  204. package/out/src/process-explorer-rows.js +47 -0
  205. package/out/src/process-explorer-rows.js.map +1 -0
  206. package/out/src/process-explorer.d.ts +66 -0
  207. package/out/src/process-explorer.js +241 -0
  208. package/out/src/process-explorer.js.map +1 -0
  209. package/out/src/process-group-item.d.ts +8 -0
  210. package/out/src/process-group-item.js +55 -0
  211. package/out/src/process-group-item.js.map +1 -0
  212. package/out/src/process-launch-item.d.ts +12 -0
  213. package/out/src/process-launch-item.js +57 -0
  214. package/out/src/process-launch-item.js.map +1 -0
  215. package/out/src/process-launch.d.ts +47 -0
  216. package/out/src/process-launch.js +205 -0
  217. package/out/src/process-launch.js.map +1 -0
  218. package/out/src/process-message-item.d.ts +10 -0
  219. package/out/src/process-message-item.js +53 -0
  220. package/out/src/process-message-item.js.map +1 -0
  221. package/out/src/process-poll.d.ts +26 -0
  222. package/out/src/process-poll.js +125 -0
  223. package/out/src/process-poll.js.map +1 -0
  224. package/out/src/process-reactivity.d.ts +55 -0
  225. package/out/src/process-reactivity.js +188 -0
  226. package/out/src/process-reactivity.js.map +1 -0
  227. package/out/src/process-registration.d.ts +11 -0
  228. package/out/src/process-registration.js +55 -0
  229. package/out/src/process-registration.js.map +1 -0
  230. package/out/src/process-tree-item.d.ts +18 -0
  231. package/out/src/process-tree-item.js +219 -0
  232. package/out/src/process-tree-item.js.map +1 -0
  233. package/out/src/processes-state.d.ts +75 -0
  234. package/out/src/processes-state.js +76 -0
  235. package/out/src/processes-state.js.map +1 -0
  236. package/out/src/profile-on-launch.d.ts +4 -0
  237. package/out/src/profile-on-launch.js +16 -0
  238. package/out/src/profile-on-launch.js.map +1 -0
  239. package/out/src/profile-server.d.ts +24 -0
  240. package/out/src/profile-server.js +170 -0
  241. package/out/src/profile-server.js.map +1 -0
  242. package/out/src/profiler-attach.d.ts +19 -0
  243. package/out/src/profiler-attach.js +129 -0
  244. package/out/src/profiler-attach.js.map +1 -0
  245. package/out/src/profiler-commands.d.ts +8 -0
  246. package/out/src/profiler-commands.js +110 -0
  247. package/out/src/profiler-commands.js.map +1 -0
  248. package/out/src/profiler-decorations.d.ts +74 -0
  249. package/out/src/profiler-decorations.js +237 -0
  250. package/out/src/profiler-decorations.js.map +1 -0
  251. package/out/src/profiler-dispose.d.ts +6 -0
  252. package/out/src/profiler-dispose.js +20 -0
  253. package/out/src/profiler-dispose.js.map +1 -0
  254. package/out/src/profiler-flamegraph-html.d.ts +61 -0
  255. package/out/src/profiler-flamegraph-html.js +366 -0
  256. package/out/src/profiler-flamegraph-html.js.map +1 -0
  257. package/out/src/profiler-format.d.ts +10 -0
  258. package/out/src/profiler-format.js +28 -0
  259. package/out/src/profiler-format.js.map +1 -0
  260. package/out/src/profiler-launch-cooperative.d.ts +16 -0
  261. package/out/src/profiler-launch-cooperative.js +167 -0
  262. package/out/src/profiler-launch-cooperative.js.map +1 -0
  263. package/out/src/profiler-launch.d.ts +29 -0
  264. package/out/src/profiler-launch.js +123 -0
  265. package/out/src/profiler-launch.js.map +1 -0
  266. package/out/src/profiler-results.d.ts +22 -0
  267. package/out/src/profiler-results.js +104 -0
  268. package/out/src/profiler-results.js.map +1 -0
  269. package/out/src/profiler-session-core.d.ts +42 -0
  270. package/out/src/profiler-session-core.js +116 -0
  271. package/out/src/profiler-session-core.js.map +1 -0
  272. package/out/src/profiler-state.d.ts +87 -0
  273. package/out/src/profiler-state.js +83 -0
  274. package/out/src/profiler-state.js.map +1 -0
  275. package/out/src/profiler-status.d.ts +38 -0
  276. package/out/src/profiler-status.js +163 -0
  277. package/out/src/profiler-status.js.map +1 -0
  278. package/out/src/profiler-styles.d.ts +21 -0
  279. package/out/src/profiler-styles.js +160 -0
  280. package/out/src/profiler-styles.js.map +1 -0
  281. package/out/src/profiler-webview.d.ts +95 -0
  282. package/out/src/profiler-webview.js +243 -0
  283. package/out/src/profiler-webview.js.map +1 -0
  284. package/out/src/profiler.d.ts +23 -0
  285. package/out/src/profiler.js +113 -0
  286. package/out/src/profiler.js.map +1 -0
  287. package/out/src/progress-ops.d.ts +24 -0
  288. package/out/src/progress-ops.js +135 -0
  289. package/out/src/progress-ops.js.map +1 -0
  290. package/out/src/reactive-refresh.d.ts +24 -0
  291. package/out/src/reactive-refresh.js +33 -0
  292. package/out/src/reactive-refresh.js.map +1 -0
  293. package/out/src/sample-summary.d.ts +39 -0
  294. package/out/src/sample-summary.js +32 -0
  295. package/out/src/sample-summary.js.map +1 -0
  296. package/out/src/sampled-view.d.ts +15 -0
  297. package/out/src/sampled-view.js +56 -0
  298. package/out/src/sampled-view.js.map +1 -0
  299. package/out/src/server-command.d.ts +4 -0
  300. package/out/src/server-command.js +14 -0
  301. package/out/src/server-command.js.map +1 -0
  302. package/out/src/settings.d.ts +1 -0
  303. package/out/src/settings.js +22 -0
  304. package/out/src/settings.js.map +1 -0
  305. package/out/src/store.d.ts +34 -0
  306. package/out/src/store.js +64 -0
  307. package/out/src/store.js.map +1 -0
  308. package/out/src/testing/cpu-capture-assertions.d.ts +8 -0
  309. package/out/src/testing/cpu-capture-assertions.js +71 -0
  310. package/out/src/testing/cpu-capture-assertions.js.map +1 -0
  311. package/out/src/testing/cpu-capture-contract.d.ts +8 -0
  312. package/out/src/testing/cpu-capture-contract.js +123 -0
  313. package/out/src/testing/cpu-capture-contract.js.map +1 -0
  314. package/out/src/testing/webview-contract-helpers.d.ts +24 -0
  315. package/out/src/testing/webview-contract-helpers.js +125 -0
  316. package/out/src/testing/webview-contract-helpers.js.map +1 -0
  317. package/out/src/testing/webview-contract-leak.d.ts +2 -0
  318. package/out/src/testing/webview-contract-leak.js +80 -0
  319. package/out/src/testing/webview-contract-leak.js.map +1 -0
  320. package/out/src/testing/webview-contract-memory.d.ts +5 -0
  321. package/out/src/testing/webview-contract-memory.js +221 -0
  322. package/out/src/testing/webview-contract-memory.js.map +1 -0
  323. package/out/src/testing/webview-contract-palette.d.ts +6 -0
  324. package/out/src/testing/webview-contract-palette.js +121 -0
  325. package/out/src/testing/webview-contract-palette.js.map +1 -0
  326. package/out/src/testing/webview-contract-panel.d.ts +7 -0
  327. package/out/src/testing/webview-contract-panel.js +100 -0
  328. package/out/src/testing/webview-contract-panel.js.map +1 -0
  329. package/out/src/testing/webview-contract-results.d.ts +6 -0
  330. package/out/src/testing/webview-contract-results.js +136 -0
  331. package/out/src/testing/webview-contract-results.js.map +1 -0
  332. package/out/src/testing/webview-contract.d.ts +18 -0
  333. package/out/src/testing/webview-contract.js +23 -0
  334. package/out/src/testing/webview-contract.js.map +1 -0
  335. package/out/src/timeouts.d.ts +21 -0
  336. package/out/src/timeouts.js +30 -0
  337. package/out/src/timeouts.js.map +1 -0
  338. package/out/src/trace-actions.d.ts +33 -0
  339. package/out/src/trace-actions.js +135 -0
  340. package/out/src/trace-actions.js.map +1 -0
  341. package/out/src/unknown-shape.d.ts +58 -0
  342. package/out/src/unknown-shape.js +110 -0
  343. package/out/src/unknown-shape.js.map +1 -0
  344. package/out/src/wire-adapters.d.ts +18 -0
  345. package/out/src/wire-adapters.js +160 -0
  346. package/out/src/wire-adapters.js.map +1 -0
  347. package/out/src/wire-generated.d.ts +760 -0
  348. package/out/src/wire-generated.js +38 -0
  349. package/out/src/wire-generated.js.map +1 -0
  350. package/package.json +53 -4
  351. package/scripts/contributions.mjs +187 -0
  352. package/README.md +0 -3
@@ -0,0 +1,332 @@
1
+ "use strict";
2
+ // The inline <script> for the flame-graph webview ([PROF-UI-SAMPLED]).
3
+ // Kept as a template string so flame-html.ts stays a pure string builder; the
4
+ // script reads its data from the <script type="application/json"> blob (no
5
+ // eval, no external resources — CSP-safe). Interactions: wheel = zoom about
6
+ // the cursor, drag = pan, hover = tooltip + highlight, click = select +
7
+ // postMessage to open the source, double-click = zoom to frame, search dims
8
+ // non-matching frames, Esc clears the search, 0 resets zoom.
9
+ // NOTE: the only interpolation is EMBEDDED, the palette and flame-script-helpers
10
+ // function sources (type-checked + unit-tested TS, embedded verbatim via
11
+ // toString); the rest is one literal with no backticks or dollar-brace sequences.
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ exports.FLAME_SCRIPT = void 0;
14
+ const palette_1 = require("./palette");
15
+ const flame_script_helpers_1 = require("./flame-script-helpers");
16
+ /** The type-checked, unit-tested functions the webview runs, as source. */
17
+ const EMBEDDED = [palette_1.hasSourceFile, palette_1.byFrameKeyThenIndex, palette_1.frameRanks, palette_1.framePaletteColor, palette_1.paletteFrames, palette_1.inkFor, flame_script_helpers_1.fitLabelText, flame_script_helpers_1.searchMatches, flame_script_helpers_1.coveredSpan, flame_script_helpers_1.clampViewRange].map((fn) => fn.toString()).join("\n");
18
+ exports.FLAME_SCRIPT = `(function () {
19
+ "use strict";
20
+ ${EMBEDDED}
21
+ var vscode = globalThis.profilerVsCodeApi || (globalThis.profilerVsCodeApi =
22
+ typeof acquireVsCodeApi === "function" ? acquireVsCodeApi() : { postMessage: function () {} });
23
+ var data = JSON.parse(document.getElementById("flame-data").textContent);
24
+ var model = data.model;
25
+ var ROW_H = 18;
26
+ var MIN_SPAN = 0.00001;
27
+ var LABEL_PAD = 4;
28
+ var DIM_ALPHA = 0.22;
29
+ var canvas = document.getElementById("flame");
30
+ var ctx = canvas.getContext("2d");
31
+ var tooltip = document.getElementById("tooltip");
32
+ var searchBox = document.getElementById("search");
33
+ var matchLabel = document.getElementById("match-label");
34
+ var fiberSelect = document.getElementById("fiber-select");
35
+ var btnLeft = document.getElementById("btn-left");
36
+ var btnTime = document.getElementById("btn-time");
37
+ var hiddenLabel = document.getElementById("hidden-label");
38
+ var measures = {};
39
+ var labelCache = {};
40
+ var rowsCache = {};
41
+ var matchSet = null;
42
+ var drag = null;
43
+ var state = { view: "left", fiber: 0, x0: 0, x1: 1, selected: -1, hover: null };
44
+
45
+ model.fibers.forEach(function (f, i) {
46
+ if (f.totalWeight > model.fibers[state.fiber].totalWeight) { state.fiber = i; }
47
+ });
48
+
49
+ function fiber() { return model.fibers[state.fiber]; }
50
+ function rects() { return state.view === "left" ? fiber().leftHeavy : fiber().timeOrder; }
51
+ function depthCount() {
52
+ var d = state.view === "left" ? fiber().maxDepthLeft : fiber().maxDepthTime;
53
+ return Math.max(d, 3);
54
+ }
55
+ function span() { return state.x1 - state.x0; }
56
+
57
+ function rowsByDepth() {
58
+ var key = state.fiber + ":" + state.view;
59
+ if (!rowsCache[key]) {
60
+ var byDepth = [];
61
+ rects().forEach(function (r) {
62
+ (byDepth[r.depth] || (byDepth[r.depth] = [])).push(r);
63
+ });
64
+ rowsCache[key] = byDepth;
65
+ }
66
+ return rowsCache[key];
67
+ }
68
+
69
+ function cssVar(name, fallback) {
70
+ var value = getComputedStyle(document.body).getPropertyValue(name).trim();
71
+ return value || fallback;
72
+ }
73
+
74
+ function resize() {
75
+ var dpr = window.devicePixelRatio || 1;
76
+ var width = canvas.parentElement.clientWidth;
77
+ var height = depthCount() * ROW_H + 2;
78
+ canvas.style.width = width + "px";
79
+ canvas.style.height = height + "px";
80
+ canvas.width = Math.round(width * dpr);
81
+ canvas.height = Math.round(height * dpr);
82
+ ctx.setTransform(dpr, 0, 0, dpr, 0, 0);
83
+ render();
84
+ }
85
+
86
+ function measure(text) {
87
+ if (!(text in measures)) { measures[text] = ctx.measureText(text).width; }
88
+ return measures[text];
89
+ }
90
+
91
+ // Labels are cached per 8px of width and fitted to the narrowest width they
92
+ // are cached for, so a cached label never overflows its slab.
93
+ function fitLabel(name, avail) {
94
+ var bucket = Math.floor(avail / 8);
95
+ var key = name + "|" + bucket;
96
+ if (!(key in labelCache)) { labelCache[key] = fitLabelText(name, bucket * 8, measure); }
97
+ return labelCache[key];
98
+ }
99
+
100
+ function drawRect(r, width) {
101
+ var px0 = ((r.x0 - state.x0) / span()) * width;
102
+ var px1 = ((r.x1 - state.x0) / span()) * width;
103
+ if (px1 < 0 || px0 > width || px1 - px0 < 0.3) { return; }
104
+ var y = r.depth * ROW_H;
105
+ var w = Math.max(px1 - px0 - 1, 0.4);
106
+ ctx.globalAlpha = matchSet !== null && !matchSet.has(r.frameIdx) ? DIM_ALPHA : 1;
107
+ ctx.fillStyle = model.frames[r.frameIdx].color;
108
+ ctx.fillRect(px0, y, w, ROW_H - 1);
109
+ if (state.selected === r.frameIdx || state.hover === r) {
110
+ ctx.strokeStyle = cssVar("--vscode-focusBorder", "#3794ff");
111
+ ctx.strokeRect(px0 + 0.5, y + 0.5, Math.max(w - 1, 0.5), ROW_H - 2);
112
+ }
113
+ var vis0 = Math.max(px0, 0);
114
+ var avail = Math.min(px1 - 1, width) - vis0 - 2 * LABEL_PAD;
115
+ if (avail > measure("\\u2026") + 2) {
116
+ ctx.fillStyle = inkFor(model.frames[r.frameIdx].color);
117
+ ctx.fillText(fitLabel(model.frames[r.frameIdx].name, avail), vis0 + LABEL_PAD, y + ROW_H / 2);
118
+ }
119
+ ctx.globalAlpha = 1;
120
+ }
121
+
122
+ function render() {
123
+ var width = canvas.clientWidth;
124
+ ctx.fillStyle = cssVar("--vscode-editor-background", "#1e1e1e");
125
+ ctx.fillRect(0, 0, width, canvas.clientHeight);
126
+ ctx.font = "11px " + cssVar("--vscode-font-family", "sans-serif");
127
+ ctx.textBaseline = "middle";
128
+ rects().forEach(function (r) { drawRect(r, width); });
129
+ hiddenNote();
130
+ }
131
+
132
+ // The slab budget drops a long recording's narrowest frames: say so, never silently.
133
+ function hiddenNote() {
134
+ var hidden = state.view === "left" ? fiber().leftHeavyHidden : fiber().timeOrderHidden;
135
+ hiddenLabel.textContent = hidden > 0 ? hidden.toLocaleString() + " narrow frames not drawn \u2014 Speedscope has them all" : "";
136
+ }
137
+
138
+ function rectAt(offsetX, offsetY) {
139
+ var row = rowsByDepth()[Math.floor(offsetY / ROW_H)];
140
+ if (!row) { return null; }
141
+ var x = state.x0 + (offsetX / canvas.clientWidth) * span();
142
+ var lo = 0;
143
+ var hi = row.length - 1;
144
+ while (lo <= hi) {
145
+ var mid = (lo + hi) >> 1;
146
+ if (row[mid].x1 < x) { lo = mid + 1; }
147
+ else if (row[mid].x0 > x) { hi = mid - 1; }
148
+ else { return row[mid]; }
149
+ }
150
+ return null;
151
+ }
152
+
153
+ function fmtMs(seconds) { return (seconds * 1000).toFixed(1) + "ms"; }
154
+ function fmtPct(part) {
155
+ var total = fiber().totalWeight;
156
+ return (total > 0 ? ((100 * part) / total).toFixed(1) : "0.0") + "%";
157
+ }
158
+
159
+ function tooltipLine(className, text) {
160
+ var el = document.createElement("div");
161
+ el.className = className;
162
+ el.textContent = text;
163
+ tooltip.appendChild(el);
164
+ }
165
+
166
+ function showTooltip(r, clientX, clientY) {
167
+ var frame = model.frames[r.frameIdx];
168
+ var stats = fiber().stats;
169
+ tooltip.innerHTML = "";
170
+ tooltipLine("tt-name", frame.name);
171
+ tooltipLine("tt-loc", frame.file ? frame.file + ":" + frame.line : "(runtime)");
172
+ tooltipLine("tt-nums",
173
+ "self " + fmtMs(stats.self[r.frameIdx]) + " (" + fmtPct(stats.self[r.frameIdx]) + ") \\u00b7 " +
174
+ "total " + fmtMs(stats.total[r.frameIdx]) + " (" + fmtPct(stats.total[r.frameIdx]) + ") \\u00b7 " +
175
+ stats.count[r.frameIdx] + " samples");
176
+ tooltip.style.display = "block";
177
+ var maxLeft = document.body.clientWidth - tooltip.offsetWidth - 8;
178
+ tooltip.style.left = Math.min(clientX + 14, Math.max(maxLeft, 0)) + "px";
179
+ tooltip.style.top = (clientY + 14) + "px";
180
+ }
181
+
182
+ function clampView() {
183
+ var next = clampViewRange(state.x0, state.x1, MIN_SPAN);
184
+ state.x0 = next.x0;
185
+ state.x1 = next.x1;
186
+ }
187
+
188
+ function resetZoom() {
189
+ state.x0 = 0;
190
+ state.x1 = 1;
191
+ render();
192
+ }
193
+
194
+ function selectFrame(frameIdx) {
195
+ state.selected = frameIdx;
196
+ var frame = model.frames[frameIdx];
197
+ if (frame.file) { vscode.postMessage({ type: "select", file: frame.file, line: frame.line }); }
198
+ render();
199
+ }
200
+
201
+ canvas.addEventListener("wheel", function (e) {
202
+ e.preventDefault();
203
+ var anchor = state.x0 + (e.offsetX / canvas.clientWidth) * span();
204
+ var frac = (anchor - state.x0) / span();
205
+ var next = Math.min(Math.max(span() * Math.pow(1.0018, e.deltaY), MIN_SPAN), 1);
206
+ state.x0 = anchor - frac * next;
207
+ state.x1 = state.x0 + next;
208
+ clampView();
209
+ render();
210
+ }, { passive: false });
211
+
212
+ canvas.addEventListener("mousedown", function (e) {
213
+ drag = { startX: e.clientX, x0: state.x0, span: span(), moved: false };
214
+ });
215
+
216
+ window.addEventListener("mousemove", function (e) {
217
+ if (!drag) { return; }
218
+ var dx = e.clientX - drag.startX;
219
+ if (Math.abs(dx) > 3) { drag.moved = true; }
220
+ state.x0 = drag.x0 - (dx / canvas.clientWidth) * drag.span;
221
+ state.x1 = state.x0 + drag.span;
222
+ clampView();
223
+ render();
224
+ });
225
+
226
+ window.addEventListener("mouseup", function (e) {
227
+ if (!drag) { return; }
228
+ var wasDrag = drag.moved;
229
+ drag = null;
230
+ if (wasDrag || e.target !== canvas) { return; }
231
+ var r = rectAt(e.offsetX, e.offsetY);
232
+ if (r) { selectFrame(r.frameIdx); }
233
+ });
234
+
235
+ canvas.addEventListener("mousemove", function (e) {
236
+ if (drag) { return; }
237
+ var r = rectAt(e.offsetX, e.offsetY);
238
+ if (r !== state.hover) {
239
+ state.hover = r;
240
+ render();
241
+ }
242
+ if (r) {
243
+ showTooltip(r, e.clientX, e.clientY);
244
+ canvas.style.cursor = "pointer";
245
+ } else {
246
+ tooltip.style.display = "none";
247
+ canvas.style.cursor = "default";
248
+ }
249
+ });
250
+
251
+ canvas.addEventListener("mouseleave", function () {
252
+ state.hover = null;
253
+ tooltip.style.display = "none";
254
+ render();
255
+ });
256
+
257
+ canvas.addEventListener("dblclick", function (e) {
258
+ var r = rectAt(e.offsetX, e.offsetY);
259
+ if (!r) { return; }
260
+ state.x0 = r.x0;
261
+ state.x1 = Math.max(r.x1, r.x0 + MIN_SPAN);
262
+ clampView();
263
+ render();
264
+ });
265
+
266
+ // The matched share of the profile, each instant counted once however many
267
+ // nested matches cover it (speedscope-style).
268
+ function matchedTotalPct() {
269
+ var slabs = rects().filter(function (r) { return matchSet.has(r.frameIdx); })
270
+ .map(function (r) { return [r.x0, r.x1]; });
271
+ return 100 * coveredSpan(slabs);
272
+ }
273
+
274
+ function applySearch(query) {
275
+ var hits = searchMatches(model.frames, query);
276
+ matchSet = query.trim() === "" ? null : hits;
277
+ matchLabel.textContent = matchSet === null ? ""
278
+ : matchSet.size + " frames \\u00b7 " + matchedTotalPct().toFixed(1) + "% of total";
279
+ render();
280
+ }
281
+
282
+ searchBox.addEventListener("input", function () { applySearch(searchBox.value); });
283
+
284
+ window.addEventListener("keydown", function (e) {
285
+ if (e.key === "Escape") {
286
+ searchBox.value = "";
287
+ applySearch("");
288
+ } else if (e.key === "0" && e.target !== searchBox) {
289
+ resetZoom();
290
+ }
291
+ });
292
+
293
+ function setView(view) {
294
+ state.view = view;
295
+ state.hover = null;
296
+ btnLeft.classList.toggle("active", view === "left");
297
+ btnTime.classList.toggle("active", view === "time");
298
+ resize();
299
+ }
300
+ btnLeft.addEventListener("click", function () { setView("left"); });
301
+ btnTime.addEventListener("click", function () { setView("time"); });
302
+
303
+ function setFiber(index) {
304
+ if (index < 0 || index >= model.fibers.length) { return; }
305
+ state.fiber = index;
306
+ state.hover = null;
307
+ fiberSelect.value = String(index);
308
+ document.querySelectorAll(".chip").forEach(function (chip) {
309
+ chip.classList.toggle("active", chip.getAttribute("data-fiber") === String(index));
310
+ });
311
+ state.x0 = 0;
312
+ state.x1 = 1;
313
+ applySearch(searchBox.value);
314
+ resize();
315
+ }
316
+ fiberSelect.addEventListener("change", function () { setFiber(Number(fiberSelect.value)); });
317
+ document.querySelectorAll(".chip").forEach(function (chip) {
318
+ chip.addEventListener("click", function () { setFiber(Number(chip.getAttribute("data-fiber"))); });
319
+ });
320
+ document.getElementById("btn-reset").addEventListener("click", resetZoom);
321
+
322
+ window.addEventListener("message", function (event) {
323
+ if (event.data.type === "profilerPalette") {
324
+ model.frames = paletteFrames(model.frames, event.data.palette);
325
+ resize();
326
+ }
327
+ });
328
+ window.addEventListener("resize", resize);
329
+ setFiber(state.fiber);
330
+ })();
331
+ `;
332
+ //# sourceMappingURL=flame-script.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"flame-script.js","sourceRoot":"","sources":["../../src/flame-script.ts"],"names":[],"mappings":";AAAA,uEAAuE;AACvE,8EAA8E;AAC9E,2EAA2E;AAC3E,4EAA4E;AAC5E,wEAAwE;AACxE,4EAA4E;AAC5E,6DAA6D;AAC7D,iFAAiF;AACjF,yEAAyE;AACzE,kFAAkF;;;AAElF,uCAAqH;AACrH,iEAAkG;AAElG,2EAA2E;AAC3E,MAAM,QAAQ,GAAG,CAAC,uBAAa,EAAE,6BAAmB,EAAE,oBAAU,EAAE,2BAAiB,EAAE,uBAAa,EAAE,gBAAM,EACxG,mCAAY,EAAE,oCAAa,EAAE,kCAAW,EAAE,qCAAc,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,QAAQ,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAErF,QAAA,YAAY,GAAG;;IAExB,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAuTX,CAAC"}
@@ -0,0 +1,14 @@
1
+ import type { RenderRect, SpeedscopeProfile } from "./flame-model";
2
+ /** The most slabs one layout embeds: about 20 MB of JSON, well inside a webview. */
3
+ export declare const FLAME_RECT_BUDGET = 150000;
4
+ /** A layout and how many of its narrowest slabs the budget left out. */
5
+ export interface BoundedRects {
6
+ readonly rects: RenderRect[];
7
+ readonly hidden: number;
8
+ }
9
+ /** `rects`, an already built layout over `total` weight, within the budget. */
10
+ export declare function boundedRects(rects: readonly RenderRect[], total: number, budget?: number): BoundedRects;
11
+ /** Flame-chart layout: x = time; adjacent identical stacks merge into slabs. */
12
+ export declare function timeOrderRects(profile: SpeedscopeProfile): RenderRect[];
13
+ /** The time-order layout within the slab budget, as the panel embeds it. */
14
+ export declare function boundedTimeOrder(profile: SpeedscopeProfile, budget?: number): BoundedRects;
@@ -0,0 +1,112 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FLAME_RECT_BUDGET = void 0;
4
+ exports.boundedRects = boundedRects;
5
+ exports.timeOrderRects = timeOrderRects;
6
+ exports.boundedTimeOrder = boundedTimeOrder;
7
+ /** The most slabs one layout embeds: about 20 MB of JSON, well inside a webview. */
8
+ exports.FLAME_RECT_BUDGET = 150_000;
9
+ /** Width buckets: bucket b holds slabs wider than total / 2^(b+1), up to total / 2^b. */
10
+ const BUCKETS = 64;
11
+ const bucketOf = (width, total) => Math.min(BUCKETS - 1, Math.floor(Math.log2(total / width)));
12
+ const KEEP_ALL = { bucket: BUCKETS, depth: 0 };
13
+ function cutoffFor(counts, budget) {
14
+ let kept = 0;
15
+ for (let bucket = 0; bucket < counts.length; bucket += 1) {
16
+ const row = counts[bucket] ?? [];
17
+ for (let depth = 0; depth < row.length; depth += 1) {
18
+ kept += row[depth] ?? 0;
19
+ if (kept > budget) {
20
+ return { bucket, depth: depth - 1 };
21
+ }
22
+ }
23
+ }
24
+ return KEEP_ALL;
25
+ }
26
+ const keeps = (cutoff, bucket, depth) => bucket < cutoff.bucket || (bucket === cutoff.bucket && depth <= cutoff.depth);
27
+ /** Walk a layout's slabs twice: once to count them by width and depth, once to keep those within the budget. */
28
+ function bounded(walk, total, budget) {
29
+ const counts = [];
30
+ walk((rect) => {
31
+ const bucket = bucketOf(rect.totalWeight, total);
32
+ const row = counts[bucket] ?? [];
33
+ counts[bucket] = row;
34
+ row[rect.depth] = (row[rect.depth] ?? 0) + 1;
35
+ });
36
+ const cutoff = cutoffFor(counts, budget);
37
+ const rects = [];
38
+ let hidden = 0;
39
+ walk((rect) => {
40
+ if (keeps(cutoff, bucketOf(rect.totalWeight, total), rect.depth)) {
41
+ rects.push(rect);
42
+ }
43
+ else {
44
+ hidden += 1;
45
+ }
46
+ });
47
+ return { rects, hidden };
48
+ }
49
+ /** `rects`, an already built layout over `total` weight, within the budget. */
50
+ function boundedRects(rects, total, budget = exports.FLAME_RECT_BUDGET) {
51
+ return bounded((emit) => {
52
+ for (const rect of rects) {
53
+ emit(rect);
54
+ }
55
+ }, total, budget);
56
+ }
57
+ function commonPrefixLength(open, stack) {
58
+ let lcp = 0;
59
+ while (lcp < open.length && lcp < stack.length && open[lcp].frameIdx === stack[lcp]) {
60
+ lcp += 1;
61
+ }
62
+ return lcp;
63
+ }
64
+ function closeFramesAbove(open, target, emit) {
65
+ while (open.length > target.keep) {
66
+ const frame = open.pop();
67
+ if (frame !== undefined) {
68
+ emit({ x0: frame.x0, x1: target.cursor, depth: open.length, frameIdx: frame.frameIdx,
69
+ selfWeight: frame.self, totalWeight: target.cursor - frame.x0 });
70
+ }
71
+ }
72
+ }
73
+ /** Add a sample's weight to the top open frame's self time, when a frame is open. */
74
+ function accrueSelf(open, weight) {
75
+ const top = open.at(-1);
76
+ if (top !== undefined) {
77
+ top.self += weight;
78
+ }
79
+ }
80
+ /** Every time-order slab in weight units, closed in the order the samples end them. */
81
+ function walkTimeOrder(profile, emit) {
82
+ const open = [];
83
+ let cursor = 0;
84
+ for (const [i, stack] of profile.samples.entries()) {
85
+ closeFramesAbove(open, { keep: commonPrefixLength(open, stack), cursor }, emit);
86
+ for (let depth = open.length; depth < stack.length; depth += 1) {
87
+ open.push({ frameIdx: stack[depth], x0: cursor, self: 0 });
88
+ }
89
+ accrueSelf(open, profile.weights[i]);
90
+ cursor += profile.weights[i];
91
+ }
92
+ closeFramesAbove(open, { keep: 0, cursor }, emit);
93
+ }
94
+ function normalizeRects(rects, total) {
95
+ return rects
96
+ .map((rect) => ({ ...rect, x0: rect.x0 / total, x1: rect.x1 / total }))
97
+ .toSorted((left, right) => left.depth - right.depth || left.x0 - right.x0);
98
+ }
99
+ /** Flame-chart layout: x = time; adjacent identical stacks merge into slabs. */
100
+ function timeOrderRects(profile) {
101
+ return boundedTimeOrder(profile, Infinity).rects;
102
+ }
103
+ /** The time-order layout within the slab budget, as the panel embeds it. */
104
+ function boundedTimeOrder(profile, budget = exports.FLAME_RECT_BUDGET) {
105
+ const total = profile.weights.reduce((sum, weight) => sum + weight, 0);
106
+ if (total <= 0) {
107
+ return { rects: [], hidden: 0 };
108
+ }
109
+ const kept = bounded((emit) => { walkTimeOrder(profile, emit); }, total, budget);
110
+ return { rects: normalizeRects(kept.rects, total), hidden: kept.hidden };
111
+ }
112
+ //# sourceMappingURL=flame-time-order.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"flame-time-order.js","sourceRoot":"","sources":["../../src/flame-time-order.ts"],"names":[],"mappings":";;;;;;AAUA,oFAAoF;AACvE,QAAA,iBAAiB,GAAG,OAAO,CAAC;AAQzC,yFAAyF;AACzF,MAAM,OAAO,GAAG,EAAE,CAAC;AAEnB,MAAM,QAAQ,GAAG,CAAC,KAAa,EAAE,KAAa,EAAU,EAAE,CACxD,IAAI,CAAC,GAAG,CAAC,OAAO,GAAG,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;AAQ9D,MAAM,QAAQ,GAAW,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC;AAEvD,SAAS,SAAS,CAAC,MAAkB,EAAE,MA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ACpD,MAAM,IAAI,GAAG,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE,GAAG,aAAa,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC;IACjF,OAAO,EAAE,KAAK,EAAE,cAAc,CAAC,IAAI,CAAC,KAAK,EAAE,KAAK,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC;AAC3E,CAAC"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Inline the LSP-exported flame graph SVG as a `data:` URI so the CSP-locked
3
+ * webview (`img-src data:`) can render it without running its embedded script.
4
+ * Returns undefined when there is no SVG, it cannot be read, or it is too large
5
+ * to inline — the panel then simply omits the hero (the tables still work).
6
+ */
7
+ export declare function loadFlamegraphSvgDataUri(flamegraphPath: string | undefined): Promise<string | undefined>;
8
+ /** The flame graph hero markup, or an empty string when no SVG is available. */
9
+ export declare function flamegraphHeroHtml(svgDataUri: string | undefined): string;
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.loadFlamegraphSvgDataUri = loadFlamegraphSvgDataUri;
4
+ exports.flamegraphHeroHtml = flamegraphHeroHtml;
5
+ // Implements [PROF-UI-CPU]. Existing SVG export preview.
6
+ const promises_1 = require("node:fs/promises");
7
+ const logger_1 = require("./logger");
8
+ const MAX_INLINE_SVG_BYTES = 4_194_304;
9
+ /**
10
+ * Inline the LSP-exported flame graph SVG as a `data:` URI so the CSP-locked
11
+ * webview (`img-src data:`) can render it without running its embedded script.
12
+ * Returns undefined when there is no SVG, it cannot be read, or it is too large
13
+ * to inline — the panel then simply omits the hero (the tables still work).
14
+ */
15
+ async function loadFlamegraphSvgDataUri(flamegraphPath) {
16
+ if (flamegraphPath === undefined || flamegraphPath === "") {
17
+ return undefined;
18
+ }
19
+ try {
20
+ const svg = await (0, promises_1.readFile)(flamegraphPath);
21
+ if (svg.byteLength === 0 || svg.byteLength > MAX_INLINE_SVG_BYTES) {
22
+ return undefined;
23
+ }
24
+ return `data:image/svg+xml;base64,${svg.toString("base64")}`;
25
+ }
26
+ catch (error) {
27
+ logger_1.Logger.warn(`Flame graph SVG could not be inlined (${error instanceof Error ? error.message : String(error)})`);
28
+ return undefined;
29
+ }
30
+ }
31
+ /** The flame graph hero markup, or an empty string when no SVG is available. */
32
+ function flamegraphHeroHtml(svgDataUri) {
33
+ if (svgDataUri === undefined) {
34
+ return "";
35
+ }
36
+ return `
37
+ <h2>Flame Graph</h2>
38
+ <div class="flame-hero">
39
+ <img id="flame-svg" alt="CPU flame graph" src="${svgDataUri}">
40
+ <button class="action-link" id="open-flame-svg" title="Open the interactive flame graph (zoom and search) in your default viewer">
41
+ Open Interactive Flame Graph
42
+ </button>
43
+ </div>`;
44
+ }
45
+ //# sourceMappingURL=flamegraph-artifact.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"flamegraph-artifact.js","sourceRoot":"","sources":["../../src/flamegraph-artifact.ts"],"names":[],"mappings":";;;;AAAA,yDAAyD;AACzD,+CAA4C;AAC5C,qCAAkC;AAElC,MAAM,oBAAoB,GAAG,SAAS,CAAC;AAEvC;;;;;GAKG;AACI,KAAK,mCAAmC,cAAkC;IAC/E,IAAI,cAAc,KAAK,SAAS,IAAI,cAAc,KAAK,EAAE,EAAE,CAAC;QAC1D,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,MAAM,IAAA,mBAAQ,EAAC,cAAc,CAAC,CAAC;QAC3C,IAAI,GAAG,CAAC,UAAU,KAAK,CAAC,IAAI,GAAG,CAAC,UAAU,GAAG,oBAAoB,EAAE,CAAC;YAClE,OAAO,SAAS,CAAC;QACnB,CAAC;QACD,OAAO,6BAA6B,GAAG,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC;IAC/D,CAAC;IAAC,OAAO,KAAc,EAAE,CAAC;QACxB,eAAM,CAAC,IAAI,CACT,yCAAyC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CACnG,CAAC;QACF,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC;AAED,gFAAgF;AAChF,4BAAmC,UAA8B;IAC/D,IAAI,UAAU,KAAK,SAAS,EAAE,CAAC;QAC7B,OAAO,EAAE,CAAC;IACZ,CAAC;IACD,OAAO;;;qDAG4C,UAAU;;;;SAItD,CAAC;AACV,CAAC"}
@@ -0,0 +1,31 @@
1
+ import type { ReadonlySignal } from "@preact/signals-core";
2
+ import type * as vscode from "vscode";
3
+ import type { LanguageClient } from "vscode-languageclient/node";
4
+ import type { LogSink } from "./logger";
5
+ import type { ProfilerPalette } from "./palette";
6
+ /** Which metric a "run the current file" launch collects. */
7
+ export type LaunchMetric = "cpu" | "memory";
8
+ export interface ProfilerHost {
9
+ /** The host's colours ([PROF-UI-PALETTE]); the original orange/purple when omitted. */
10
+ readonly palette?: ProfilerPalette;
11
+ /** Command/context/view prefix, e.g. `sharplsp`. */
12
+ readonly idPrefix: string;
13
+ /** Product name for messages, e.g. `SharpLsp`. */
14
+ readonly brand: string;
15
+ /** Settings section holding `profiler.*` keys, e.g. `sharplsp`. */
16
+ readonly configSection: string;
17
+ /** The host's debug adapter type; `""` when the host has none. */
18
+ readonly debugType: string;
19
+ /** Language IDs of files the host can "run & profile". */
20
+ readonly languageIds: readonly string[];
21
+ /** Those languages as a message names them to a user, e.g. `F#`, `C#`. */
22
+ readonly languageNames: readonly string[];
23
+ /** The live language client; `undefined` until the server starts. */
24
+ readonly client: ReadonlySignal<LanguageClient | undefined>;
25
+ /** Where the library logs. */
26
+ readonly logger: LogSink;
27
+ /** Debuggee PIDs by debug session ID, as the host learns them from DAP. */
28
+ readonly sessionIdToPid: ReadonlySignal<ReadonlyMap<string, number>>;
29
+ /** A launch configuration that runs `program` for profiling, or `undefined` when unsupported. */
30
+ readonly launchConfig: (metric: LaunchMetric, program: string) => vscode.DebugConfiguration | undefined;
31
+ }
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ // Implements [PROF-UI-HOST]. The host extension injects everything that is
3
+ // its own — identity, the language client, logging, the debug adapter — and
4
+ // the library never imports a product.
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ //# sourceMappingURL=host.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"host.js","sourceRoot":"","sources":["../../src/host.ts"],"names":[],"mappings":";AAAA,2EAA2E;AAC3E,4EAA4E;AAC5E,uCAAuC"}
@@ -0,0 +1,27 @@
1
+ /** Install the host's identity. Called once by `createProfilerStore`. */
2
+ export declare function installIds(ids: {
3
+ readonly idPrefix: string;
4
+ readonly brand: string;
5
+ readonly configSection: string;
6
+ readonly debugType: string;
7
+ }): void;
8
+ /** The host's product name for user-facing messages, e.g. `SharpLsp`. */
9
+ export declare function brand(): string;
10
+ /** The settings section the profiler reads, e.g. `sharplsp` → `sharplsp.profiler.sampleRate`. */
11
+ export declare function configSection(): string;
12
+ /** The host's debug adapter type, used to recognise its own debug sessions. */
13
+ export declare function debugType(): string;
14
+ /** A client-side command the library registers: `<prefix>.profiler.<name>`. */
15
+ export declare function cmd(name: string): string;
16
+ /** A context key the library sets: `<prefix>.profiler.<name>`. */
17
+ export declare function ctx(name: string): string;
18
+ /** The processes view ID: `<prefix>.profiler.processes`. */
19
+ export declare function viewId(): string;
20
+ /** A server command of the shared protocol: `<prefix>.lspProfiler.<area>.<action>`. */
21
+ export declare function lsp(name: string): string;
22
+ /** An object whose properties resolve `lsp(name)` on read, so a module-level table follows the installed prefix. */
23
+ export declare function lspTable<const Names extends Record<string, string>>(names: Names): {
24
+ readonly [Key in keyof Names]: string;
25
+ };
26
+ /** The URI scheme of process rows (file decorations). */
27
+ export declare function processUriScheme(): string;
package/out/src/ids.js ADDED
@@ -0,0 +1,63 @@
1
+ "use strict";
2
+ // Implements [PROF-UI-IDS]. Every identifier the library registers or sends is
3
+ // derived from the host's prefix, so two hosts (two language servers) coexist
4
+ // in one window without a clash and the library never names a product.
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.installIds = installIds;
7
+ exports.brand = brand;
8
+ exports.configSection = configSection;
9
+ exports.debugType = debugType;
10
+ exports.cmd = cmd;
11
+ exports.ctx = ctx;
12
+ exports.viewId = viewId;
13
+ exports.lsp = lsp;
14
+ exports.lspTable = lspTable;
15
+ exports.processUriScheme = processUriScheme;
16
+ let prefix = "lspProfiler";
17
+ let brandName = "Profiler";
18
+ let section = "lspProfiler";
19
+ let debuggerType = "";
20
+ /** Install the host's identity. Called once by `createProfilerStore`. */
21
+ function installIds(ids) {
22
+ prefix = ids.idPrefix;
23
+ brandName = ids.brand;
24
+ section = ids.configSection;
25
+ debuggerType = ids.debugType;
26
+ }
27
+ /** The host's product name for user-facing messages, e.g. `SharpLsp`. */
28
+ function brand() {
29
+ return brandName;
30
+ }
31
+ /** The settings section the profiler reads, e.g. `sharplsp` → `sharplsp.profiler.sampleRate`. */
32
+ function configSection() {
33
+ return section;
34
+ }
35
+ /** The host's debug adapter type, used to recognise its own debug sessions. */
36
+ function debugType() {
37
+ return debuggerType;
38
+ }
39
+ /** A client-side command the library registers: `<prefix>.profiler.<name>`. */
40
+ function cmd(name) {
41
+ return `${prefix}.profiler.${name}`;
42
+ }
43
+ /** A context key the library sets: `<prefix>.profiler.<name>`. */
44
+ function ctx(name) {
45
+ return `${prefix}.profiler.${name}`;
46
+ }
47
+ /** The processes view ID: `<prefix>.profiler.processes`. */
48
+ function viewId() {
49
+ return `${prefix}.profiler.processes`;
50
+ }
51
+ /** A server command of the shared protocol: `<prefix>.lspProfiler.<area>.<action>`. */
52
+ function lsp(name) {
53
+ return `${prefix}.lspProfiler.${name}`;
54
+ }
55
+ /** An object whose properties resolve `lsp(name)` on read, so a module-level table follows the installed prefix. */
56
+ function lspTable(names) {
57
+ return new Proxy(names, { get: (target, key) => (typeof key === "string" && key in target ? lsp(target[key]) : undefined) });
58
+ }
59
+ /** The URI scheme of process rows (file decorations). */
60
+ function processUriScheme() {
61
+ return `${prefix}-process`;
62
+ }
63
+ //# sourceMappingURL=ids.js.map