@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,100 @@
1
+ "use strict";
2
+ // Implements [PROF-UI-WEBVIEW] (once-bound message handler). See docs/specs/LSP-PROFILER-SPEC.md
3
+ /**
4
+ * A singleton panel binds its message handler once, however often it is
5
+ * re-rendered, and drops a posted message that is not a profiler message.
6
+ * A webview delivers its posts in order, so a closing marker post tells the
7
+ * test every earlier post has been delivered or dropped: nothing waits on time.
8
+ */
9
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ var desc = Object.getOwnPropertyDescriptor(m, k);
12
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
13
+ desc = { enumerable: true, get: function() { return m[k]; } };
14
+ }
15
+ Object.defineProperty(o, k2, desc);
16
+ }) : (function(o, m, k, k2) {
17
+ if (k2 === undefined) k2 = k;
18
+ o[k2] = m[k];
19
+ }));
20
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
21
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
22
+ }) : function(o, v) {
23
+ o["default"] = v;
24
+ });
25
+ var __importStar = (this && this.__importStar) || (function () {
26
+ var ownKeys = function(o) {
27
+ ownKeys = Object.getOwnPropertyNames || function (o) {
28
+ var ar = [];
29
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
30
+ return ar;
31
+ };
32
+ return ownKeys(o);
33
+ };
34
+ return function (mod) {
35
+ if (mod && mod.__esModule) return mod;
36
+ var result = {};
37
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
38
+ __setModuleDefault(result, mod);
39
+ return result;
40
+ };
41
+ })();
42
+ Object.defineProperty(exports, "__esModule", { value: true });
43
+ const assert = __importStar(require("node:assert"));
44
+ const profiler_webview_1 = require("../profiler-webview");
45
+ const webview_contract_helpers_1 = require("./webview-contract-helpers");
46
+ /** A document whose script posts `ready` messages for `files`, in order. */
47
+ function postingDoc(files) {
48
+ const posts = files.map((file) => `api.postMessage({ type: 'ready', file: '${file}' });`).join(' ');
49
+ return (0, profiler_webview_1.buildWebviewDocument)({ title: 'handler-once probe', css: '', body: '<p>probe</p>',
50
+ script: `const api = globalThis.profilerVsCodeApi || (globalThis.profilerVsCodeApi = acquireVsCodeApi()); ${posts}` });
51
+ }
52
+ /** The files of the messages received, in arrival order. */
53
+ const filesOf = (received) => received.map((message) => message.file ?? '?');
54
+ /** How long one live-webview handler test may take before it fails. */
55
+ const HANDLER_TEST_TIMEOUT_MS = 30_000;
56
+ async function reRenderingNeverStacksAHandler() {
57
+ this.timeout(HANDLER_TEST_TIMEOUT_MS);
58
+ const received = [];
59
+ const panel = new profiler_webview_1.SingletonWebviewPanel(() => 'lspui.test.handlerOnce', (msg) => { received.push(msg); });
60
+ try {
61
+ await renderTwiceAndAssert(panel, received);
62
+ }
63
+ finally {
64
+ panel.dispose();
65
+ }
66
+ assert.ok(!panel.isOpen(), 'dispose must settle the panel closed');
67
+ }
68
+ /** Re-render one panel and assert each render delivers its posts exactly once. */
69
+ async function renderTwiceAndAssert(panel, received) {
70
+ panel.show('probe', postingDoc(['first']));
71
+ await (0, webview_contract_helpers_1.pollUntilResult)(() => received.length, (count) => count >= 1);
72
+ // With a handler re-registered per open, every post of the second
73
+ // render is delivered twice, and `second` arrives again before `end`.
74
+ panel.show('probe', postingDoc(['second', 'end']));
75
+ await (0, webview_contract_helpers_1.pollUntilResult)(() => filesOf(received).includes('end'), (ended) => ended);
76
+ assert.deepStrictEqual(filesOf(received), ['first', 'second', 'end'], 'each render must deliver its messages exactly once; a repeat means stacked handlers');
77
+ assert.ok(panel.isOpen(), 'the singleton panel must stay open across re-renders');
78
+ }
79
+ async function malformedMessagesNeverReachTheHandler() {
80
+ this.timeout(HANDLER_TEST_TIMEOUT_MS);
81
+ const received = [];
82
+ const panel = new profiler_webview_1.SingletonWebviewPanel(() => 'lspui.test.malformed', (msg) => { received.push(msg); });
83
+ const malformed = `[null, 7, 'ready', [], {}, { type: 5 }, { type: 'ready', file: 5 }, { type: 'ready', line: '3' }]`;
84
+ try {
85
+ panel.show('probe', (0, profiler_webview_1.buildWebviewDocument)({ title: 'malformed probe', css: '', body: '',
86
+ script: `const api = acquireVsCodeApi(); ${malformed}.forEach((m) => api.postMessage(m));` +
87
+ ` api.postMessage({ type: 'ready', file: 'last', line: 3 });` }));
88
+ await (0, webview_contract_helpers_1.pollUntilResult)(() => received.length, (count) => count >= 1);
89
+ assert.deepStrictEqual(received, [{ type: 'ready', file: 'last', line: 3 }]);
90
+ }
91
+ finally {
92
+ panel.dispose();
93
+ }
94
+ }
95
+ suite('Profiler webviews — singleton panel message handler', () => {
96
+ teardown(async () => { await (0, webview_contract_helpers_1.closeAllEditors)(); });
97
+ test('re-opening a panel re-renders but never stacks a second message handler', reRenderingNeverStacksAHandler);
98
+ test('a posted message that is not a well-formed profiler message never reaches the handler', malformedMessagesNeverReachTheHandler);
99
+ });
100
+ //# sourceMappingURL=webview-contract-panel.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"webview-contract-panel.js","sourceRoot":"","sources":["../../../src/testing/webview-contract-panel.ts"],"names":[],"mappings":";AAAA,iGAAiG;AACjG;;;;;GAKG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,MAAY,MAAM,wCAAoB;AACtC,0DAAkF;AAElF,yEAA8E;AAE9E,4EAA4E;AAC5E,SAAS,UAAU,CAAC,KAAwB;IACxC,MAAM,KAAK,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,2CAA2C,IAAI,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACpG,OAAO,IAAA,uCAAoB,EAAC,EAAE,KAAK,EAAE,oBAAoB,EAAE,GAAG,EAAE,EAAE,EAAE,IAAI,EAAE,cAAc;QACpF,MAAM,EAAE,oGAAoG,KAAK,EAAE,EAAE,CAAC,CAAC;AAC/H,CAAC;AAED,4DAA4D;AAC5D,MAAM,OAAO,GAAG,CAAC,QAAmC,EAAY,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,IAAI,GAAG,CAAC,CAAC;AAElH,uEAAuE;AACvE,MAAM,uBAAuB,GAAG,MAAM,CAAC;AAEvC,KAAK,UAAU,8BAA8B;IACzC,IAAI,CAAC,OAAO,CAAC,uBAAuB,CAAC,CAAC;IACtC,MAAM,QAAQ,GAAqB,EAAE,CAAC;IACtC,MAAM,KAAK,GAAG,IAA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3
+ * trace on demand, degrades to its tables without one, and keeps a debugger
4
+ * selection from another session, or a hostile one, out of it.
5
+ */
6
+ export {};
@@ -0,0 +1,136 @@
1
+ "use strict";
2
+ // Implements [PROF-EXPORT-FLAMEGRAPH] + [PROF-UI-DEBUG-LINK]. See docs/specs/LSP-PROFILER-SPEC.md
3
+ /**
4
+ * The CPU results panel leads with the exported flame graph, offers the raw
5
+ * trace on demand, degrades to its tables without one, and keeps a debugger
6
+ * selection from another session, or a hostile one, out of it.
7
+ */
8
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
9
+ if (k2 === undefined) k2 = k;
10
+ var desc = Object.getOwnPropertyDescriptor(m, k);
11
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
12
+ desc = { enumerable: true, get: function() { return m[k]; } };
13
+ }
14
+ Object.defineProperty(o, k2, desc);
15
+ }) : (function(o, m, k, k2) {
16
+ if (k2 === undefined) k2 = k;
17
+ o[k2] = m[k];
18
+ }));
19
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
20
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
21
+ }) : function(o, v) {
22
+ o["default"] = v;
23
+ });
24
+ var __importStar = (this && this.__importStar) || (function () {
25
+ var ownKeys = function(o) {
26
+ ownKeys = Object.getOwnPropertyNames || function (o) {
27
+ var ar = [];
28
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
29
+ return ar;
30
+ };
31
+ return ownKeys(o);
32
+ };
33
+ return function (mod) {
34
+ if (mod && mod.__esModule) return mod;
35
+ var result = {};
36
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
37
+ __setModuleDefault(result, mod);
38
+ return result;
39
+ };
40
+ })();
41
+ var __importDefault = (this && this.__importDefault) || function (mod) {
42
+ return (mod && mod.__esModule) ? mod : { "default": mod };
43
+ };
44
+ Object.defineProperty(exports, "__esModule", { value: true });
45
+ const assert = __importStar(require("node:assert"));
46
+ const fs = __importStar(require("node:fs"));
47
+ const os = __importStar(require("node:os"));
48
+ const node_path_1 = __importDefault(require("node:path"));
49
+ const debug_selection_1 = require("../debug-selection");
50
+ const profiler_flamegraph_html_1 = require("../profiler-flamegraph-html");
51
+ const webview_contract_helpers_1 = require("./webview-contract-helpers");
52
+ /** A result with one hot function and one hot line, overriding what a test cares about. */
53
+ function hotProfileResult(overrides = {}) {
54
+ return (0, webview_contract_helpers_1.profileResult)({
55
+ hotFunctions: [{ name: 'hot', file: '/app/main.py', line: 3, samples: 200, percentage: 80, selfPercentage: 75 }],
56
+ hotLines: [{ file: '/app/main.py', line: 5, samples: 180, percentage: 72 }],
57
+ ...overrides,
58
+ });
59
+ }
60
+ let tmpDir = '';
61
+ async function writeSvg(name, contents) {
62
+ const svgPath = node_path_1.default.join(tmpDir, name);
63
+ await fs.promises.writeFile(svgPath, contents);
64
+ return svgPath;
65
+ }
66
+ async function theFlameGraphIsTheHero() {
67
+ const svgPath = await writeSvg('profile.svg', '<svg xmlns="http://www.w3.org/2000/svg"><rect/></svg>');
68
+ const html = await (0, profiler_flamegraph_html_1.buildFlamegraphHtml)(hotProfileResult({ flamegraphPath: svgPath }));
69
+ assert.ok(html.includes('data:image/svg+xml;base64,'), 'the flame graph SVG must be inlined as a data URI (a profiler must show a flame graph)');
70
+ assert.ok(html.includes('open-flame-svg'), 'the hero must offer opening the interactive SVG externally');
71
+ assert.ok(html.includes('openFlamegraphSvg'), 'the open action must post a message the extension handles');
72
+ }
73
+ // [PROF-CPU-START] The built-in `.cpuprofile` viewer is on-demand, not the
74
+ // landing view — so the panel itself must carry the way into it. Without
75
+ // this button the raw trace is only reachable through the (dismissable)
76
+ // completion toast.
77
+ async function theRawTraceIsOneClickAway() {
78
+ const withTrace = await (0, profiler_flamegraph_html_1.buildFlamegraphHtml)(hotProfileResult({ cpuProfilePath: '/tmp/lspui-s-1.cpuprofile' }));
79
+ assert.ok(withTrace.includes('Open Trace in VS Code Viewer'), 'the panel must offer opening the native .cpuprofile viewer');
80
+ assert.ok(withTrace.includes('openCpuProfile'), 'the trace button must post a message the extension handles');
81
+ const withoutTrace = await (0, profiler_flamegraph_html_1.buildFlamegraphHtml)(hotProfileResult());
82
+ assert.ok(!withoutTrace.includes('/tmp/lspui-s-1.cpuprofile'), 'no stale trace path may be embedded when no .cpuprofile was produced');
83
+ }
84
+ async function noSvgDegradesToTheTables() {
85
+ const withoutPath = await (0, profiler_flamegraph_html_1.buildFlamegraphHtml)(hotProfileResult());
86
+ const withDeadPath = await (0, profiler_flamegraph_html_1.buildFlamegraphHtml)(hotProfileResult({ flamegraphPath: node_path_1.default.join(tmpDir, 'nope.svg') }));
87
+ for (const html of [withoutPath, withDeadPath]) {
88
+ assert.ok(!html.includes('data:image/svg+xml'), 'no hero image without a readable SVG');
89
+ assert.ok(!html.includes('<img'), 'no broken <img> element');
90
+ assert.ok(html.includes('fn-body'), 'the hot-functions table must still render');
91
+ }
92
+ }
93
+ /** The largest SVG the hero inlines, in MiB. */
94
+ const SVG_LIMIT_MIB = 5;
95
+ const MEBIBYTE = 1024;
96
+ async function unusableSvgsAreNotInlined() {
97
+ assert.strictEqual(await (0, profiler_flamegraph_html_1.loadFlamegraphSvgDataUri)(undefined), undefined);
98
+ assert.strictEqual(await (0, profiler_flamegraph_html_1.loadFlamegraphSvgDataUri)(''), undefined);
99
+ const empty = await writeSvg('empty.svg', '');
100
+ assert.strictEqual(await (0, profiler_flamegraph_html_1.loadFlamegraphSvgDataUri)(empty), undefined, 'an empty artifact is not a flame graph');
101
+ const oversized = await writeSvg('huge.svg', `<svg>${'x'.repeat(SVG_LIMIT_MIB * MEBIBYTE * MEBIBYTE)}</svg>`);
102
+ assert.strictEqual(await (0, profiler_flamegraph_html_1.loadFlamegraphSvgDataUri)(oversized), undefined, 'an oversized artifact must not be inlined (it still opens externally)');
103
+ }
104
+ // Implements [PROF-EXPORT-FLAMEGRAPH]. See docs/specs/LSP-PROFILER-SPEC.md
105
+ suite('Profiler webviews — flame graph hero', () => {
106
+ suiteSetup(async () => { tmpDir = await fs.promises.mkdtemp(node_path_1.default.join(os.tmpdir(), 'lspui-flame-hero-')); });
107
+ suiteTeardown(async () => { await (0, webview_contract_helpers_1.removeTestDir)(tmpDir); });
108
+ test('the results panel embeds the LSP-exported flame graph SVG as its hero', theFlameGraphIsTheHero);
109
+ test('the results panel offers the raw trace via an "Open Trace in VS Code Viewer" button', theRawTraceIsOneClickAway);
110
+ test('a missing or unreadable SVG degrades to the tables, never a broken image', noSvgDegradesToTheTables);
111
+ test('loadFlamegraphSvgDataUri refuses empty and oversized artifacts', unusableSvgsAreNotInlined);
112
+ });
113
+ function selectionsStayInTheirSession() {
114
+ const variable = { name: 'child', evaluateName: 'parent.child', value: '42', type: 'Record' };
115
+ const selected = (0, debug_selection_1.profileVariable)({ sessionId: 'one', variable }, 'one');
116
+ assert.equal(selected?.expression, 'parent.child');
117
+ assert.equal(selected?.type, 'Record');
118
+ assert.equal(selected?.value, '42');
119
+ assert.equal((0, debug_selection_1.profileVariable)({ sessionId: 'other', variable }, 'one'), undefined);
120
+ assert.equal((0, debug_selection_1.profileVariable)({ variable: { name: '', value: '' } }, 'one'), undefined);
121
+ }
122
+ async function hostileSelectionsStayInert() {
123
+ debug_selection_1.selectedProfileVariable.value = (0, debug_selection_1.profileVariable)({ name: webview_contract_helpers_1.HOSTILE, value: webview_contract_helpers_1.HOSTILE, type: webview_contract_helpers_1.HOSTILE }, 'one');
124
+ try {
125
+ (0, webview_contract_helpers_1.assertHardened)(await (0, profiler_flamegraph_html_1.buildFlamegraphHtml)(hotProfileResult()), 'debug variable');
126
+ }
127
+ finally {
128
+ debug_selection_1.selectedProfileVariable.value = undefined;
129
+ }
130
+ }
131
+ // Implements [PROF-UI-DEBUG-LINK]. The same session boundary is tested in each VSIX.
132
+ suite('Profiler debugger selection contract', () => {
133
+ test('preserves expressions and rejects a selection from another session', selectionsStayInTheirSession);
134
+ test('debugger values cannot escape into executable webview content', hostileSelectionsStayInert);
135
+ });
136
+ //# sourceMappingURL=webview-contract-results.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"webview-contract-results.js","sourceRoot":"","sources":["../../../src/testing/webview-contract-results.ts"],"names":[],"mappings":";AAAA,kGAAkG;AAClG;;;;GAIG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,MAAY,MAAM,wCAAoB;AACtC,MAAY,EAAE,oCAAgB;AAC9B,MAAY,EAAE,oCAAgB;AAC9B,0DAA6B;AAC7B,wDAA8E;AAC9E,0EAA4F;AAE5F,yEAAmG;AAEnG,2FAA2F;AAC3F,SAAS,gBAAgB,CAAC,SAAS,GAA2B,EAAE;IAC5D,OAAO,IAAA,wCAAa,EAAC;QACjB,YAAY,EAAE,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,cAAc,EAAE,IAAI,EAAE,CAAC,EAAE,OAAO,EAAE,GAAG,EAAE,UAAU,EAAE,EAAE,EAAE,cAAc,EAAE,EAAE,EAAE,CAAC;QAChH,QAAQ,EAAE,CAAC,EAAE,IAAI,EAAE,cAAc,EAAE,IAAI,EAAE,CAAC,EAAE,OAAO,EAAE,GAAG,EAAE,UAAU,EAAE,EAAE,EAAE,CAAC;QAC3E,GAAG,SAAS;KACf,CAAC,CAAC;AACP,CAAC;AAED,IAAI,MAAM,GAAG,EAAE,CAAC;AAEhB,KAAK,UAAU,QAAQ,CAAC,IAAY,EAAE,QAAgB;IAClD,MAAM,OAAO,GAAG,mBAAI,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IACxC,MAAM,EAAE,CAAC,QAAQ,CAAC,SAAS,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;IAC/C,OAAO,OAAO,CAAC;AACnB,CAAC;AAED,KAAK,UAAU,sBAAsB;IACjC,MAAM,OAAO,GAAG,MAAM,QAAQ,CAAC,aAAa,EAAE,uDA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CAAe,EAAC,EAAE,QAAQ,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE,EAAE,KAAK,CAAC,EAAE,SAAS,CAAC,CAAC;AAC3F,CAAC;AAED,KAAK,UAAU,0BAA0B;IACrC,yCAAuB,CAAC,KAAK,GAAG,IAAA,iCAAe,EAAC,EAAE,IAAI,EAAE,kCAAO,EAAE,KAAK,EAAE,kCAAO,EAAE,IAAI,EAAE,kCAAO,EAAE,EAAE,KAAK,CAAC,CAAC;IACzG,IAAI,CAAC;QAAC,IAAA,yCAAc,EAAC,MAAM,IAAA,8CAAmB,EAAC,gBAAgB,EAAE,CAAC,EAAE,gBAAgB,CAAC,CAAC;IAAC,CAAC;YAChF,CAAC;QAAC,yCAAuB,CAAC,KAAK,GAAG,SAAS,CAAC;IAAC,CAAC;AAC1D,CAAC;AAED,qFAAqF;AACrF,KAAK,CAAC,sCAAsC,EAAE,GAAG,EAAE;IAC/C,IAAI,CAAC,oEAAoE,EAAE,4BAA4B,CAAC,CAAC;IACzG,IAAI,CAAC,+DAA+D,EAAE,0BAA0B,CAAC,CAAC;AACtG,CAAC,CAAC,CAAC"}
@@ -0,0 +1,18 @@
1
+ /**
2
+ * PROFILER WEBVIEW HOST — hardening and honesty of every profiler results
3
+ * panel (CPU results, memory dashboard, retention graph). A host runs the whole
4
+ * contract by importing this module inside its own extension host.
5
+ *
6
+ * Why this contract exists: before the shared host, the memory dashboard and the
7
+ * retention graph shipped with NO Content-Security-Policy, embedded
8
+ * profiled-program data (allocation paths, type reprs, leak reasons) into
9
+ * their inline <script> without escaping `<` (a hostile `</script>` payload
10
+ * broke out of the script element), and re-registered their message handler on
11
+ * EVERY open — with the autopilot re-rendering the dashboard on each debugger
12
+ * pause, one row click navigated N times. These tests pin all three fixes on
13
+ * the real builders and, for the handler, on a real live webview panel.
14
+ */
15
+ import './webview-contract-memory';
16
+ import './webview-contract-results';
17
+ import './webview-contract-panel';
18
+ import './webview-contract-palette';
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ // Implements [PROF-UI-WEBVIEW] + [PROF-EXPORT-FLAMEGRAPH] + [PROF-UI-PALETTE].
3
+ // See docs/specs/LSP-PROFILER-SPEC.md
4
+ /**
5
+ * PROFILER WEBVIEW HOST — hardening and honesty of every profiler results
6
+ * panel (CPU results, memory dashboard, retention graph). A host runs the whole
7
+ * contract by importing this module inside its own extension host.
8
+ *
9
+ * Why this contract exists: before the shared host, the memory dashboard and the
10
+ * retention graph shipped with NO Content-Security-Policy, embedded
11
+ * profiled-program data (allocation paths, type reprs, leak reasons) into
12
+ * their inline <script> without escaping `<` (a hostile `</script>` payload
13
+ * broke out of the script element), and re-registered their message handler on
14
+ * EVERY open — with the autopilot re-rendering the dashboard on each debugger
15
+ * pause, one row click navigated N times. These tests pin all three fixes on
16
+ * the real builders and, for the handler, on a real live webview panel.
17
+ */
18
+ Object.defineProperty(exports, "__esModule", { value: true });
19
+ require("./webview-contract-memory");
20
+ require("./webview-contract-results");
21
+ require("./webview-contract-panel");
22
+ require("./webview-contract-palette");
23
+ //# sourceMappingURL=webview-contract.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"webview-contract.js","sourceRoot":"","sources":["../../../src/testing/webview-contract.ts"],"names":[],"mappings":";AAAA,+EAA+E;AAC/E,sCAAsC;AACtC;;;;;;;;;;;;;GAaG;;AAEH,qCAAmC;AACnC,sCAAoC;AACpC,oCAAkC;AAClC,sCAAoC"}
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Canonical timeout constants for the lsp-profiler UI library.
3
+ *
4
+ * Three knobs. No others. Anything that feels like it needs a fourth is a
5
+ * design smell — fix the underlying slowness, do not invent a new bucket.
6
+ */
7
+ /** Interval between polls. */
8
+ export declare const POLL_INTERVAL_MS = 10;
9
+ /** Max time to wait for a single command/event to settle at runtime.
10
+ * If a wait exceeds this, the operation is broken. */
11
+ export declare const WAIT_MS = 1000;
12
+ /** Startup / cold-init timeout. Anything slower than this is a bug. */
13
+ export declare const STARTUP_TIMEOUT_MS = 10000;
14
+ /**
15
+ * Resolve after `ms` milliseconds.
16
+ *
17
+ * The one place a delay is scheduled, so a timing change happens once rather
18
+ * than in fifty copies. `node:timers/promises` wraps the timer without a
19
+ * hand-rolled `new Promise` whose executor's return value would be discarded.
20
+ */
21
+ export declare function delay(ms: number): Promise<void>;
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.STARTUP_TIMEOUT_MS = exports.WAIT_MS = exports.POLL_INTERVAL_MS = void 0;
4
+ exports.delay = delay;
5
+ // Implements [PROF-UI-HOST]. See docs/specs/LSP-PROFILER-SPEC.md
6
+ const promises_1 = require("node:timers/promises");
7
+ /**
8
+ * Canonical timeout constants for the lsp-profiler UI library.
9
+ *
10
+ * Three knobs. No others. Anything that feels like it needs a fourth is a
11
+ * design smell — fix the underlying slowness, do not invent a new bucket.
12
+ */
13
+ /** Interval between polls. */
14
+ exports.POLL_INTERVAL_MS = 10;
15
+ /** Max time to wait for a single command/event to settle at runtime.
16
+ * If a wait exceeds this, the operation is broken. */
17
+ exports.WAIT_MS = 1000;
18
+ /** Startup / cold-init timeout. Anything slower than this is a bug. */
19
+ exports.STARTUP_TIMEOUT_MS = 10_000;
20
+ /**
21
+ * Resolve after `ms` milliseconds.
22
+ *
23
+ * The one place a delay is scheduled, so a timing change happens once rather
24
+ * than in fifty copies. `node:timers/promises` wraps the timer without a
25
+ * hand-rolled `new Promise` whose executor's return value would be discarded.
26
+ */
27
+ async function delay(ms) {
28
+ await (0, promises_1.setTimeout)(ms);
29
+ }
30
+ //# sourceMappingURL=timeouts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"timeouts.js","sourceRoot":"","sources":["../../src/timeouts.ts"],"names":[],"mappings":";;;;AAAA,iEAAiE;AACjE,mDAAgE;AAEhE;;;;;GAKG;AAEH,8BAA8B;AACjB,QAAA,gBAAgB,GAAG,EAAE,CAAC;AAEnC;uDACuD;AAC1C,QAAA,OAAO,GAAG,IAAI,CAAC;AAE5B,uEAAuE;AAC1D,QAAA,kBAAkB,GAAG,MAAM,CAAC;AAEzC;;;;;;GAMG;AACI,KAAK,gBAAgB,EAAU;IACpC,MAAM,IAAA,qBAAU,EAAC,EAAE,CAAC,CAAC;AACvB,CAAC"}
@@ -0,0 +1,33 @@
1
+ /**
2
+ * The ways out of a results view to the raw trace: VS Code's built-in V8
3
+ * viewer, the file itself, and speedscope.app. Shared by the CPU results panel
4
+ * and the memory dashboard; an explicit request never fails silently.
5
+ */
6
+ import type { ProfileResult } from "./profiler-decorations";
7
+ /** The on-disk trace a "Reveal" action points at: the `.cpuprofile`, else the speedscope JSON. */
8
+ export declare function traceFileFor(result: ProfileResult): string;
9
+ /**
10
+ * Open a V8 trace (`.cpuprofile` / `.heapprofile`) in VS Code's built-in viewer
11
+ * on demand — the user asked for it explicitly (toast action, results-panel
12
+ * button, or memory-dashboard button), so a viewer that cannot open
13
+ * (unavailable in the host, or no trace produced) is said out loud and the
14
+ * trace file is revealed instead; an explicit request never fails silently.
15
+ */
16
+ export declare function openNativeTraceViewer(cpuProfilePath: string, traceFile: string): Promise<void>;
17
+ /** Reveal `file` in the OS file manager; there is nothing to reveal without one. */
18
+ export declare function revealTraceFile(file: string): Promise<void>;
19
+ /**
20
+ * "Open in Speedscope": speedscope.app is served over https and cannot read
21
+ * `file://` URLs — but browsers treat loopback as a potentially-trustworthy
22
+ * origin, so the profile is served from the extension's 127.0.0.1 server and
23
+ * the deep link loads it automatically ([PROF-UI-WEBVIEW]). The value
24
+ * is left unencoded on purpose: it contains only `:` and `/` (legal raw in a
25
+ * fragment), and percent-encoding it invites `vscode.Uri` re-encoding mangling.
26
+ * A browser without the loopback mixed-content exemption still shows
27
+ * speedscope's error page, so a toast always offers the drag-and-drop path;
28
+ * a failure to serve falls back to that path directly.
29
+ *
30
+ * Shared by the CPU results panel (speedscope JSON) and the memory dashboard
31
+ * (V8 `.heapprofile` — a format speedscope also imports).
32
+ */
33
+ export declare function openSpeedscopeImport(file: string): Promise<void>;
@@ -0,0 +1,135 @@
1
+ "use strict";
2
+ // Implements [PROF-CPU-START] + [PROF-UI-WEBVIEW]. See docs/specs/LSP-PROFILER-SPEC.md
3
+ /**
4
+ * The ways out of a results view to the raw trace: VS Code's built-in V8
5
+ * viewer, the file itself, and speedscope.app. Shared by the CPU results panel
6
+ * and the memory dashboard; an explicit request never fails silently.
7
+ */
8
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
9
+ if (k2 === undefined) k2 = k;
10
+ var desc = Object.getOwnPropertyDescriptor(m, k);
11
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
12
+ desc = { enumerable: true, get: function() { return m[k]; } };
13
+ }
14
+ Object.defineProperty(o, k2, desc);
15
+ }) : (function(o, m, k, k2) {
16
+ if (k2 === undefined) k2 = k;
17
+ o[k2] = m[k];
18
+ }));
19
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
20
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
21
+ }) : function(o, v) {
22
+ o["default"] = v;
23
+ });
24
+ var __importStar = (this && this.__importStar) || (function () {
25
+ var ownKeys = function(o) {
26
+ ownKeys = Object.getOwnPropertyNames || function (o) {
27
+ var ar = [];
28
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
29
+ return ar;
30
+ };
31
+ return ownKeys(o);
32
+ };
33
+ return function (mod) {
34
+ if (mod && mod.__esModule) return mod;
35
+ var result = {};
36
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
37
+ __setModuleDefault(result, mod);
38
+ return result;
39
+ };
40
+ })();
41
+ Object.defineProperty(exports, "__esModule", { value: true });
42
+ exports.traceFileFor = traceFileFor;
43
+ exports.openNativeTraceViewer = openNativeTraceViewer;
44
+ exports.revealTraceFile = revealTraceFile;
45
+ exports.openSpeedscopeImport = openSpeedscopeImport;
46
+ const vscode = __importStar(require("vscode"));
47
+ const ids_1 = require("./ids");
48
+ const failure_1 = require("./failure");
49
+ const logger_1 = require("./logger");
50
+ const profile_server_1 = require("./profile-server");
51
+ /** The on-disk trace a "Reveal" action points at: the `.cpuprofile`, else the speedscope JSON. */
52
+ function traceFileFor(result) {
53
+ const cpu = result.cpuProfilePath ?? "";
54
+ return cpu === "" ? result.outputFile : cpu;
55
+ }
56
+ /**
57
+ * Open a generated profile artifact in VS Code's built-in viewer beside the
58
+ * source, falling back when no file was produced OR when the built-in viewer's
59
+ * open throws (unavailable in the host, or a file it rejects). Opening beside
60
+ * keeps the profiled file (and its inline decorations) visible. The CPU
61
+ * (`.cpuprofile`) and memory (`.heapprofile`) paths share it through
62
+ * `openNativeTraceViewer` so the open-beside-else-fall-back primitive lives
63
+ * once (dry-1).
64
+ */
65
+ async function openNativeProfileViewerBeside(filePath, fallback) {
66
+ if (filePath === "") {
67
+ fallback();
68
+ return;
69
+ }
70
+ try {
71
+ await vscode.commands.executeCommand("vscode.open", vscode.Uri.file(filePath), vscode.ViewColumn.Beside);
72
+ }
73
+ catch (error) {
74
+ logger_1.Logger.warn(`Built-in profile viewer failed to open (${(0, failure_1.errorText)(error)}); using the in-extension fallback`);
75
+ fallback();
76
+ }
77
+ }
78
+ /**
79
+ * Open a V8 trace (`.cpuprofile` / `.heapprofile`) in VS Code's built-in viewer
80
+ * on demand — the user asked for it explicitly (toast action, results-panel
81
+ * button, or memory-dashboard button), so a viewer that cannot open
82
+ * (unavailable in the host, or no trace produced) is said out loud and the
83
+ * trace file is revealed instead; an explicit request never fails silently.
84
+ */
85
+ async function openNativeTraceViewer(cpuProfilePath, traceFile) {
86
+ await openNativeProfileViewerBeside(cpuProfilePath, () => {
87
+ void vscode.window.showWarningMessage(`${(0, ids_1.brand)()}: VS Code's built-in trace viewer could not open the profile — revealing the trace file instead.`);
88
+ void revealTraceFile(traceFile);
89
+ });
90
+ }
91
+ /** Reveal `file` in the OS file manager; there is nothing to reveal without one. */
92
+ async function revealTraceFile(file) {
93
+ if (file !== "") {
94
+ await vscode.commands.executeCommand("revealFileInOS", vscode.Uri.file(file));
95
+ }
96
+ }
97
+ /**
98
+ * "Open in Speedscope": speedscope.app is served over https and cannot read
99
+ * `file://` URLs — but browsers treat loopback as a potentially-trustworthy
100
+ * origin, so the profile is served from the extension's 127.0.0.1 server and
101
+ * the deep link loads it automatically ([PROF-UI-WEBVIEW]). The value
102
+ * is left unencoded on purpose: it contains only `:` and `/` (legal raw in a
103
+ * fragment), and percent-encoding it invites `vscode.Uri` re-encoding mangling.
104
+ * A browser without the loopback mixed-content exemption still shows
105
+ * speedscope's error page, so a toast always offers the drag-and-drop path;
106
+ * a failure to serve falls back to that path directly.
107
+ *
108
+ * Shared by the CPU results panel (speedscope JSON) and the memory dashboard
109
+ * (V8 `.heapprofile` — a format speedscope also imports).
110
+ */
111
+ async function openSpeedscopeImport(file) {
112
+ try {
113
+ const localUrl = await (0, profile_server_1.serveProfileForBrowser)(file);
114
+ await vscode.env.openExternal(vscode.Uri.parse(`https://www.speedscope.app/#profileURL=${localUrl}`));
115
+ void offerSpeedscopeFallback(file);
116
+ }
117
+ catch (error) {
118
+ logger_1.Logger.warn(`Profile loopback serving failed (${(0, failure_1.errorText)(error)}); falling back to manual speedscope import`);
119
+ await revealTraceFile(file);
120
+ await vscode.env.openExternal(vscode.Uri.parse("https://www.speedscope.app/"));
121
+ vscode.window.showInformationMessage(`${(0, ids_1.brand)()}: Drag the revealed file into speedscope.app to view it — ${file}`);
122
+ }
123
+ }
124
+ /**
125
+ * The always-works escape hatch behind the speedscope deep link: fire-and-forget
126
+ * toast (sticky with a button — must not block) whose action reveals the JSON
127
+ * for manual drag-and-drop import.
128
+ */
129
+ async function offerSpeedscopeFallback(file) {
130
+ const choice = await vscode.window.showInformationMessage(`${(0, ids_1.brand)()}: Opened in speedscope.app — if the profile doesn't load, drag the trace file in.`, "Reveal Trace File");
131
+ if (choice === "Reveal Trace File") {
132
+ await revealTraceFile(file);
133
+ }
134
+ }
135
+ //# sourceMappingURL=trace-actions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"trace-actions.js","sourceRoot":"","sources":["../../src/trace-actions.ts"],"names":[],"mappings":";AAAA,uFAAuF;AACvF;;;;GAIG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,MAAY,MAAM,mCAAe;AACjC,+BAA8B;AAC9B,uCAAsC;AACtC,qCAAkC;AAClC,qDAA0D;AAG1D,kGAAkG;AAClG,sBAA6B,MAAqB;IAChD,MAAM,GAAG,GAAG,MAAM,CAAC,cAAc,IAAI,EAAE,CAAC;IACxC,OAAO,GAAG,KAAK,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,GAAG,CAAC;AAC9C,CAAC;AAED;;;;;;;;GAQG;AACH,KAAK,UAAU,6BAA6B,CAAC,QAAgB,EAAE,QAAoB;IACjF,IAAI,QAAQ,KAAK,EAAE,EAAE,CAAC;QACpB,QAAQ,EAAE,CAAC;QACX,OAAO;IACT,CAAC;IACD,IAAI,CAAC;QACH,MAAM,MAAM,CAAC,QAAQ,CAAC,cAAc,CAAC,aAAa,EAAE,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;IAC3G,CAAC;IAAC,OAAO,KAAc,EAAE,CAAC;QACxB,eAAM,CAAC,IAAI,CAAC,2CAA2C,IAAA,mBAAS,EAAC,KAAK,CAAC,oCAAoC,CAAC,CAAC;QAC7G,QAAQ,EAAE,CAAC;IACb,CAAC;AACH,CAAC;AAED;;;;;;GAMG;AACI,KAAK,gCAAgC,cAAsB,EAAE,SAAiB;IACnF,MAAM,6BAA6B,CAAC,cAAc,EAAE,GAAG,EAAE;QACvD,KAAK,MAAM,CAAC,MAAM,CAAC,kBAAkB,CACnC,GAAG,IAAA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,CAAC;IACF,IAAI,MAAM,KAAK,mBAAmB,EAAE,CAAC;QACnC,MAAM,eAAe,CAAC,IAAI,CAAC,CAAC;IAC9B,CAAC;AACH,CAAC"}
@@ -0,0 +1,58 @@
1
+ /**
2
+ * Runtime narrowing for values the extension does not own.
3
+ *
4
+ * DAP messages, LSP `experimental` capabilities, webview posts and
5
+ * `JSON.parse` results all arrive as `unknown`. Writing `payload as { id?:
6
+ * number }` at each read site *asserts* a shape the compiler then trusts
7
+ * forever — one protocol change and every downstream read is silently wrong
8
+ * with no error anywhere. These accessors check the shape at the moment of
9
+ * reading and return `undefined` when it does not hold, so a protocol drift
10
+ * surfaces as a missing value rather than as a lie the type system repeats.
11
+ *
12
+ * Read one field at a time. There is deliberately no `as SomeInterface`
13
+ * shortcut here — that is the very construct this module exists to replace.
14
+ */
15
+ /** Whether `value` is a non-null, non-array object with string keys. */
16
+ export declare function isRecord(value: unknown): value is Record<string, unknown>;
17
+ /**
18
+ * `value` as a keyed record, or an empty one when it is not an object.
19
+ *
20
+ * The empty fallback keeps callers free of null checks: every field read on it
21
+ * yields `undefined`, which is what an absent payload means anyway.
22
+ */
23
+ export declare function asRecord(value: unknown): Record<string, unknown>;
24
+ /**
25
+ * The raw `key` field of `value`, still `unknown`.
26
+ *
27
+ * For fields handed straight to another `unknown`-taking function, where
28
+ * narrowing here would only be undone at the other end.
29
+ */
30
+ export declare function rawField(value: unknown, key: string): unknown;
31
+ /** The `key` field of `value` when it is a string, else `undefined`. */
32
+ export declare function stringField(value: unknown, key: string): string | undefined;
33
+ /** The `key` field of `value` when it is a finite number, else `undefined`. */
34
+ export declare function numberField(value: unknown, key: string): number | undefined;
35
+ /** The `key` field of `value` when it is a boolean, else `undefined`. */
36
+ export declare function booleanField(value: unknown, key: string): boolean | undefined;
37
+ /** The `key` field of `value` when it is itself a record, else `undefined`. */
38
+ export declare function recordField(value: unknown, key: string): Record<string, unknown> | undefined;
39
+ /** The `key` field of `value` as an array of unknowns; `[]` when absent. */
40
+ export declare function arrayField(value: unknown, key: string): unknown[];
41
+ /**
42
+ * The `key` field of `value` as an array of records.
43
+ *
44
+ * Non-object elements are dropped rather than passed on as holes, so callers
45
+ * can read fields off every element without re-checking.
46
+ */
47
+ export declare function recordArrayField(value: unknown, key: string): Record<string, unknown>[];
48
+ /** The `key` field of `value` as an array of finite numbers; `[]` when absent. */
49
+ export declare function numberArrayField(value: unknown, key: string): number[];
50
+ /** The `key` field of `value` as an array of strings; `[]` when absent. */
51
+ export declare function stringArrayField(value: unknown, key: string): string[];
52
+ /**
53
+ * Walk a chain of record keys, stopping at the first link that is not a record.
54
+ *
55
+ * `nested(message, "body", "source")` replaces `(message as { body?: { source?:
56
+ * X } }).body?.source` without asserting either level.
57
+ */
58
+ export declare function nested(value: unknown, ...keys: string[]): Record<string, unknown> | undefined;