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

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,125 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.HOSTILE = void 0;
37
+ exports.pollUntilResult = pollUntilResult;
38
+ exports.closeAllEditors = closeAllEditors;
39
+ exports.removeTestDir = removeTestDir;
40
+ exports.profileResult = profileResult;
41
+ exports.assertHtml = assertHtml;
42
+ exports.assertHardened = assertHardened;
43
+ exports.dashboardSnapshot = dashboardSnapshot;
44
+ // Implements [PROF-TESTING]. One fixture and assertion contract for every real host.
45
+ const assert = __importStar(require("node:assert"));
46
+ const fs = __importStar(require("node:fs"));
47
+ const vscode = __importStar(require("vscode"));
48
+ const timeouts_1 = require("../timeouts");
49
+ const DEFAULT_POLL_INTERVAL_MS = 100;
50
+ /** The budget of the two-argument `pollUntilResult`. */
51
+ const DEFAULT_POLL_TIMEOUT_MS = 10_000;
52
+ /** A payload that closes the surrounding <script> if embedding is unescaped. */
53
+ exports.HOSTILE = '</script><img src=x onerror=alert(1)>';
54
+ async function pollUntilResult(first, until) {
55
+ const options = typeof first === 'function'
56
+ ? { fn: first, until: until ?? (() => true), timeoutMs: DEFAULT_POLL_TIMEOUT_MS }
57
+ : first;
58
+ return pollFor(options, Date.now() + options.timeoutMs);
59
+ }
60
+ /** Poll `options.fn` until `options.until` accepts a value or `deadline` passes. */
61
+ async function pollFor(options, deadline) {
62
+ const last = await options.fn();
63
+ if (options.until(last)) {
64
+ return last;
65
+ }
66
+ if (Date.now() >= deadline) {
67
+ throw new Error(`${options.description ?? 'condition'} not met within ${String(options.timeoutMs)}ms (last: ${JSON.stringify(last)})`);
68
+ }
69
+ await (0, timeouts_1.delay)(options.intervalMs ?? DEFAULT_POLL_INTERVAL_MS);
70
+ return pollFor(options, deadline);
71
+ }
72
+ async function closeAllEditors() {
73
+ await vscode.commands.executeCommand("workbench.action.closeAllEditors");
74
+ }
75
+ async function removeTestDir(dir) {
76
+ if (dir === '') {
77
+ return;
78
+ }
79
+ await fs.promises.rm(dir, { recursive: true, force: true, maxRetries: 5, retryDelay: 100 });
80
+ }
81
+ /** A CPU result, overriding the fields a test cares about. */
82
+ function profileResult(overrides = {}) {
83
+ return {
84
+ sessionId: 's-1',
85
+ duration: 2.5,
86
+ totalSamples: 250,
87
+ outputFile: '/tmp/profile.speedscope.json',
88
+ hotFunctions: [],
89
+ hotLines: [],
90
+ ...overrides,
91
+ };
92
+ }
93
+ /** Assert `html` contains every key (or, with `present` false, none), failing with its reason. */
94
+ function assertHtml(html, checks, present = true) {
95
+ for (const [needle, why] of Object.entries(checks)) {
96
+ assert.equal(html.includes(needle), present, why);
97
+ }
98
+ }
99
+ /** Assert a webview declares a CSP, nonce-gates its script, and kept hostile data inert. */
100
+ function assertHardened(html, what) {
101
+ assert.ok(html.includes('Content-Security-Policy'), `${what} must declare a CSP`);
102
+ assert.ok(/script-src 'nonce-[^']+'/u.test(html), `${what}: the inline script must be nonce-gated`);
103
+ assert.ok(!html.includes('</script><img'), `${what}: untrusted data must not close the <script>`);
104
+ }
105
+ // ── Dashboard snapshots ────────────────────────────────────────────
106
+ /** Sample collection counts for three heap generations, used by the fixture. */
107
+ const GENERATION_0_COLLECTIONS = 700;
108
+ const GENERATION_1_COLLECTIONS = 12;
109
+ const GENERATION_2_COLLECTIONS = 3;
110
+ /** A minimal dashboard snapshot (fresh session: one capture, no diff yet). */
111
+ function dashboardSnapshot(overrides = {}) {
112
+ return {
113
+ memorySessionId: 'mem-1',
114
+ snapshotId: 'snap-1',
115
+ currentMemory: 1_048_576,
116
+ peakMemory: 2_097_152,
117
+ gcObjects: 1200,
118
+ gcCounts: [GENERATION_0_COLLECTIONS, GENERATION_1_COLLECTIONS, GENERATION_2_COLLECTIONS],
119
+ topAllocations: [{ file: '/app/Program.cs', line: 10, size: 4096, count: 8 }],
120
+ timeline: [],
121
+ heapProfilePath: '',
122
+ ...overrides,
123
+ };
124
+ }
125
+ //# sourceMappingURL=webview-contract-helpers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"webview-contract-helpers.js","sourceRoot":"","sources":["../../../src/testing/webview-contract-helpers.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qFAAqF;AACrF,MAAY,MAAM,wCAAoB;AACtC,MAAY,EAAE,oCAAgB;AAC9B,MAAY,MAAM,mCAAe;AACjC,0CAAoC;AAIpC,MAAM,wBAAwB,GAAG,GAAG,CAAC;AACrC,wDAAwD;AACxD,MAAM,uBAAuB,GAAG,MAAM,CAAC;AAEvC,gFAAgF;AACnE,QAAA,OAAO,GAAG,uCAAuC,CAAC;AAkBxD,KAAK,0BACV,KAA0D,EAC1D,KAAiC;IAEjC,MAAM,OAAO,GAAuB,OAAO,KAAK,KAAK,UAAU;QAC7D,CAAC,CAAC,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,IAAI,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,EAAE,SAAS,EAAE,uBAAuB,EAAE;QACjF,CAAC,CAAC,KAAK,CAAC;IACV,OAAO,OAAO,CAAC,OAAO,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC;AAC1D,CAAC;AAED,oFAAoF;AACpF,KAAK,UAAU,OAAO,C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AG,SAAS;KACb,CAAC;AACJ,CAAC"}
@@ -0,0 +1,2 @@
1
+ /** Every leak confidence is painted in a colour the host palette actually declares. */
2
+ export declare function leakDecorationsWearTheHostPalette(): Promise<void>;
@@ -0,0 +1,80 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ var __importDefault = (this && this.__importDefault) || function (mod) {
36
+ return (mod && mod.__esModule) ? mod : { "default": mod };
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.leakDecorationsWearTheHostPalette = leakDecorationsWearTheHostPalette;
40
+ // Implements [PROF-UI-PALETTE]. See docs/specs/LSP-PROFILER-SPEC.md
41
+ const assert = __importStar(require("node:assert"));
42
+ const fs = __importStar(require("node:fs"));
43
+ const os = __importStar(require("node:os"));
44
+ const node_path_1 = __importDefault(require("node:path"));
45
+ const vscode = __importStar(require("vscode"));
46
+ const memory_decorations_1 = require("../memory-decorations");
47
+ const palette_1 = require("../palette");
48
+ const webview_contract_helpers_1 = require("./webview-contract-helpers");
49
+ const editor_path_key_1 = require("../editor-path-key");
50
+ const CONFIDENCES = ['DEFINITE', 'HIGH', 'MEDIUM', 'LOW'];
51
+ /** Paint one leak of each confidence on an open file and return the colours the editor got. */
52
+ async function leakColours() {
53
+ const dir = await fs.promises.mkdtemp(node_path_1.default.join(os.tmpdir(), 'lspui-leak-palette-'));
54
+ const file = node_path_1.default.join(dir, 'leaks.txt');
55
+ await fs.promises.writeFile(file, 'definite\nhigh\nmedium\nlow\n');
56
+ try {
57
+ await vscode.window.showTextDocument(vscode.Uri.file(file));
58
+ await (0, memory_decorations_1.applyLeakDecorations)({ totalGrowth: 0, totalFreed: 0, netGrowth: 0, suspectedLeaks: CONFIDENCES.map((confidence, i) => ({
59
+ file, line: i + 1, sizeGrowth: 1024, countGrowth: 1, currentSize: 2048, confidence, reason: 'grows', typeName: ''
60
+ })) });
61
+ const applied = (0, memory_decorations_1.appliedMemoryDecorations)();
62
+ const keyOf = await (0, editor_path_key_1.pathKeyer)([file, ...applied.map((entry) => entry.file)]);
63
+ return applied.filter((entry) => keyOf(entry.file) === keyOf(file)).map((entry) => entry.color);
64
+ }
65
+ finally {
66
+ (0, memory_decorations_1.clearMemoryDecorations)();
67
+ await (0, webview_contract_helpers_1.closeAllEditors)();
68
+ await (0, webview_contract_helpers_1.removeTestDir)(dir);
69
+ }
70
+ }
71
+ /** Every leak confidence is painted in a colour the host palette actually declares. */
72
+ async function leakDecorationsWearTheHostPalette() {
73
+ const hostColours = Object.values((0, palette_1.profilerPalette)());
74
+ const colours = await leakColours();
75
+ assert.strictEqual(colours.length, CONFIDENCES.length, 'every leak is painted');
76
+ for (const colour of colours) {
77
+ assert.ok(hostColours.includes(colour), `a leak decoration draws ${colour}, which the host palette does not have`);
78
+ }
79
+ }
80
+ //# sourceMappingURL=webview-contract-leak.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"webview-contract-leak.js","sourceRoot":"","sources":["../../../src/testing/webview-contract-leak.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,oEAAoE;AACpE,MAAY,MAAM,wCAAoB;AACtC,MAAY,EAAE,oCAAgB;AAC9B,MAAY,EAAE,oCAAgB;AAC9B,0DAA6B;AAC7B,MAAY,MAAM,mCAAe;AAEjC,8DAA+G;AAC/G,wCAA6C;AAC7C,yEAA4E;AAC5E,wDAA+C;AAE/C,MAAM,WAAW,GAA8B,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,CAAC,CAAC;AAErF,+FAA+F;AAC/F,KAAK,UAAU,WAAW;IACtB,MAAM,GAAG,GAAG,MAAM,EAAE,CAAC,QAAQ,CAAC,OAAO,CAAC,mBAAI,CAAC,IAAI,CAAC,EAAE,CAAC,MAAM,EAAE,EAAE,qBAAqB,CAAC,CAAC,CAAC;IACrF,MAAM,IAAI,GAAG,mBAAI,CAAC,IAAI,CAAC,GAAG,EAAE,WAAW,CAAC,CAAC;IACzC,MAAM,EAAE,CAAC,QAAQ,CAAC,SAAS,CAAC,IAAI,EAAE,+BAA+B,CAAC,CAAC;IACnE,IAAI,CAAC;QACD,MAAM,MAAM,CAAC,MAAM,CAAC,gBAAgB,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;QAC5D,MAAM,IAAA,yCAAoB,EAAC,EAAE,WAAW,EAAE,CAAC,EAAE,UAAU,EAAE,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,cAAc,EAAE,WAAW,CAAC,GAAG,CAAC,CAAC,UAAU,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;gBAC1H,IAAI,EAAE,IAAI,EAA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 -0,0 +1,5 @@
1
+ /**
2
+ * The memory dashboard and the retention graph are CSP-locked, keep
3
+ * profiled-program data inert, and say plainly what they could not show.
4
+ */
5
+ export {};
@@ -0,0 +1,221 @@
1
+ "use strict";
2
+ // Implements [PROF-UI-WEBVIEW] + [PROF-UI-REFGRAPH]. See docs/specs/LSP-PROFILER-SPEC.md
3
+ /**
4
+ * The memory dashboard and the retention graph are CSP-locked, keep
5
+ * profiled-program data inert, and say plainly what they could not show.
6
+ */
7
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
8
+ if (k2 === undefined) k2 = k;
9
+ var desc = Object.getOwnPropertyDescriptor(m, k);
10
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
11
+ desc = { enumerable: true, get: function() { return m[k]; } };
12
+ }
13
+ Object.defineProperty(o, k2, desc);
14
+ }) : (function(o, m, k, k2) {
15
+ if (k2 === undefined) k2 = k;
16
+ o[k2] = m[k];
17
+ }));
18
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
19
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
20
+ }) : function(o, v) {
21
+ o["default"] = v;
22
+ });
23
+ var __importStar = (this && this.__importStar) || (function () {
24
+ var ownKeys = function(o) {
25
+ ownKeys = Object.getOwnPropertyNames || function (o) {
26
+ var ar = [];
27
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
28
+ return ar;
29
+ };
30
+ return ownKeys(o);
31
+ };
32
+ return function (mod) {
33
+ if (mod && mod.__esModule) return mod;
34
+ var result = {};
35
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
36
+ __setModuleDefault(result, mod);
37
+ return result;
38
+ };
39
+ })();
40
+ Object.defineProperty(exports, "__esModule", { value: true });
41
+ const assert = __importStar(require("node:assert"));
42
+ const vm = __importStar(require("node:vm"));
43
+ const memory_dashboard_1 = require("../memory-dashboard");
44
+ const memory_ref_graph_1 = require("../memory-ref-graph");
45
+ const profiler_flamegraph_html_1 = require("../profiler-flamegraph-html");
46
+ const profiler_webview_1 = require("../profiler-webview");
47
+ const unknown_shape_1 = require("../unknown-shape");
48
+ const webview_contract_helpers_1 = require("./webview-contract-helpers");
49
+ /** A no-op for canvas methods the recording mock does not implement. */
50
+ function noopCanvasMethod() {
51
+ // Recording mocks only implement the methods the graph script draws with.
52
+ }
53
+ /** A getComputedStyle stand-in: every CSS variable resolves to its own name. */
54
+ const mockGetComputedStyle = () => ({
55
+ getPropertyValue: (name) => name,
56
+ });
57
+ /**
58
+ * Run a retention graph's inline script against a recording canvas and return
59
+ * every text it draws, with where and in which colour: the panel as a reader
60
+ * sees it. Each CSS variable resolves to its own name, so two different
61
+ * variables are two different colours.
62
+ */
63
+ function drawnTexts(html) {
64
+ const script = /<script nonce="[^"]+">(?<body>[\s\S]*)<\/script>/u.exec(html)?.groups?.body ?? '';
65
+ const texts = [];
66
+ const pen = {
67
+ fillStyle: '',
68
+ fillText: (text, _x, y) => { texts.push({ text, y, fill: pen.fillStyle }); },
69
+ };
70
+ const ctx = recordingCtx(pen);
71
+ const canvas = recordingCanvas(ctx);
72
+ const document = recordingDocument(canvas);
73
+ vm.runInNewContext(script, { document, getComputedStyle: mockGetComputedStyle, window: { addEventListener: noopCanvasMethod } });
74
+ return texts;
75
+ }
76
+ function recordingCtx(pen) {
77
+ return new Proxy(pen, {
78
+ get: (target, key) => {
79
+ if (typeof key !== 'string') {
80
+ return noopCanvasMethod;
81
+ }
82
+ return key in target ? target[key] : noopCanvasMethod;
83
+ },
84
+ });
85
+ }
86
+ function recordingCanvas(ctx) {
87
+ return {
88
+ width: 800, height: 500, clientWidth: 900, parentElement: {}, style: {},
89
+ getContext: () => ctx,
90
+ };
91
+ }
92
+ function recordingDocument(canvas) {
93
+ return {
94
+ getElementById: () => canvas,
95
+ documentElement: {},
96
+ createElement: () => ({ style: {} }),
97
+ body: { appendChild: noopCanvasMethod },
98
+ };
99
+ }
100
+ function hostileDashboardIsInert() {
101
+ const snapshot = (0, webview_contract_helpers_1.dashboardSnapshot)({ topAllocations: [{ file: webview_contract_helpers_1.HOSTILE, line: 1, size: 1024, count: 2 }] });
102
+ const diff = {
103
+ totalGrowth: 2048, totalFreed: 0, netGrowth: 2048, grownAllocations: [],
104
+ suspectedLeaks: [{
105
+ file: webview_contract_helpers_1.HOSTILE, line: 1, sizeGrowth: 2048, countGrowth: 2,
106
+ currentSize: 4096, currentCount: 4, confidence: 'high', reason: webview_contract_helpers_1.HOSTILE,
107
+ }],
108
+ };
109
+ const html = (0, memory_dashboard_1.buildMemoryDashboardHtml)(snapshot, diff);
110
+ assert.ok(html.includes('Content-Security-Policy'), 'the dashboard must declare a CSP');
111
+ assert.ok(/script-src 'nonce-[^']+'/u.test(html), 'the inline script must be nonce-gated');
112
+ assert.ok(!html.includes('</script><img'), 'profiled-program data must not close the inline <script> element early');
113
+ assert.ok(html.includes('escapeHtml(basename(a.file))'), 'allocation paths must be escaped before innerHTML');
114
+ assert.ok(html.includes('escapeHtml(lk.reason)'), 'leak reasons must be escaped before innerHTML');
115
+ }
116
+ function heapProfileButtonsOnlyWithATrace() {
117
+ const withTrace = (0, memory_dashboard_1.buildMemoryDashboardHtml)((0, webview_contract_helpers_1.dashboardSnapshot)({ heapProfilePath: '/tmp/lspui-mem-1.heapprofile' }));
118
+ assert.ok(withTrace.includes('Open Heap Profile in VS Code Viewer'), 'the dashboard must offer opening the native .heapprofile viewer');
119
+ assert.ok(withTrace.includes('openHeapProfile'), 'the heap-profile button must post a message the extension handles');
120
+ assert.ok(withTrace.includes('Open in Speedscope (external)'), 'the dashboard must offer the speedscope deep link (speedscope imports .heapprofile)');
121
+ assert.ok(withTrace.includes('openSpeedscope'), 'the speedscope button must post a message the extension handles');
122
+ // The action script always references the ids defensively; only the
123
+ // BUTTON ELEMENTS (their visible labels) must be absent without a trace.
124
+ const withoutTrace = (0, memory_dashboard_1.buildMemoryDashboardHtml)((0, webview_contract_helpers_1.dashboardSnapshot)());
125
+ assert.ok(!withoutTrace.includes('Open Heap Profile in VS Code Viewer'), 'no heap-profile button may render when no .heapprofile was written');
126
+ assert.ok(!withoutTrace.includes('Open in Speedscope (external)'), 'no speedscope button may render when no .heapprofile was written');
127
+ }
128
+ function hostileRetentionGraphIsInert() {
129
+ const result = {
130
+ targetType: webview_contract_helpers_1.HOSTILE, maxDepth: 5, maxNodes: 200, script: '',
131
+ graph: {
132
+ nodes: [{ id: 1, type: webview_contract_helpers_1.HOSTILE, size: 64, repr: webview_contract_helpers_1.HOSTILE, depth: 0, isTarget: true }],
133
+ edges: [{ from: 1, to: 1, label: webview_contract_helpers_1.HOSTILE }], cycles: [], retentionPath: [webview_contract_helpers_1.HOSTILE],
134
+ },
135
+ };
136
+ const html = (0, memory_ref_graph_1.buildRefGraphHtml)(result);
137
+ assert.ok(html.includes('Content-Security-Policy'), 'the retention graph must declare a CSP');
138
+ assert.ok(/script-src 'nonce-[^']+'/u.test(html), 'the inline script must be nonce-gated');
139
+ assert.ok(!html.includes('</script><img'), 'node reprs / retention path steps must not close the inline <script> early');
140
+ assert.ok(html.includes('&lt;/script&gt;'), 'the target type in the heading must be HTML-escaped');
141
+ }
142
+ /** A static root holding an entry array that keeps two sessions alive. */
143
+ const ROOTED_SESSIONS = {
144
+ targetType: 'Shop.Session', maxDepth: 8, maxNodes: 60, script: '',
145
+ graph: {
146
+ nodes: [
147
+ { id: 0, type: 'Shop.Session', size: 40, repr: '0x1', depth: 0, isTarget: true },
148
+ { id: 1, type: 'Shop.Session', size: 40, repr: '0x2', depth: 0, isTarget: true },
149
+ { id: 2, type: 'Entry[]', size: 4096, repr: '0x3', depth: 1, isTarget: false },
150
+ { id: 3, type: 'Dictionary`2[Int32,Shop.Session]', size: 80, repr: 'static sessions', depth: 2, isTarget: false, isRoot: true, rootKind: 'Static' },
151
+ ],
152
+ edges: [{ from: 3, to: 2, label: '_entries' }, { from: 2, to: 0, label: '[0]' }, { from: 2, to: 1, label: '[1]' }],
153
+ cycles: [],
154
+ },
155
+ };
156
+ // [PROF-UI-REFGRAPH]: a root is named by its label and drawn apart from the
157
+ // objects it holds, so a module value or a static field reads as written.
158
+ function rootsAreNamedAboveWhatTheyHold() {
159
+ const texts = drawnTexts((0, memory_ref_graph_1.buildRefGraphHtml)(ROOTED_SESSIONS));
160
+ const drawn = (text) => texts.find((item) => item.text === text);
161
+ const root = drawn('static sessions');
162
+ const holder = drawn('Entry[]');
163
+ const target = drawn('Shop.Session');
164
+ assert.ok(root !== undefined, `the root is named by its label: ${JSON.stringify(texts.map((item) => item.text))}`);
165
+ assert.ok(drawn('Dictionary`2[Int32,Shop.Session]') !== undefined, 'the root still shows its type');
166
+ assert.ok(holder !== undefined && target !== undefined, 'the holder and the targets are labelled');
167
+ assert.ok(root.y < holder.y && holder.y < target.y, 'roots sit above their holders, and holders above the targets');
168
+ assert.notStrictEqual(root.fill, holder.fill, 'a root is drawn apart from an intermediate holder');
169
+ }
170
+ function decodingKeepsRoots() {
171
+ const graph = (0, memory_ref_graph_1.decodeRefGraph)({
172
+ nodes: [
173
+ { id: 3, type: 'Dictionary', size: 80, repr: 'static sessions', depth: 2, isTarget: false, isRoot: true, rootKind: 'Static' },
174
+ { id: 2, type: 'Entry[]', size: 4096, repr: '0x3', depth: 1, isTarget: false, isRoot: false },
175
+ ],
176
+ edges: [],
177
+ cycles: [],
178
+ });
179
+ const nodes = graph?.nodes ?? [];
180
+ const root = nodes.at(0);
181
+ const holder = nodes.at(1);
182
+ assert.strictEqual(root?.isRoot, true, 'the root survives decoding');
183
+ assert.strictEqual(root.rootKind, 'Static', 'and so does its kind');
184
+ assert.strictEqual(root.repr, 'static sessions', 'and its label');
185
+ assert.strictEqual(holder?.isRoot, false, 'a holder is not a root');
186
+ }
187
+ function anEmptyWalkSaysSo() {
188
+ const html = (0, memory_ref_graph_1.buildRefGraphHtml)({ targetType: 'Widget', maxDepth: 5, maxNodes: 200, script: '', graph: undefined });
189
+ assert.ok(html.includes('No reference graph data available'), 'an empty walk must say so, never show a blank canvas');
190
+ }
191
+ async function viewsFollowTheEditorTheme() {
192
+ const surfaces = [
193
+ (0, memory_dashboard_1.buildMemoryDashboardHtml)((0, webview_contract_helpers_1.dashboardSnapshot)()),
194
+ (0, memory_ref_graph_1.buildRefGraphHtml)({ targetType: 'W', maxDepth: 5, maxNodes: 200, script: '' }),
195
+ await (0, profiler_flamegraph_html_1.buildFlamegraphHtml)((0, webview_contract_helpers_1.profileResult)()),
196
+ ];
197
+ for (const html of surfaces) {
198
+ assert.ok(html.includes('var(--vscode-editor-background'), 'panel background must track the active VS Code theme');
199
+ assert.ok(html.includes('var(--vscode-editor-foreground'), 'panel text must track the active VS Code theme');
200
+ }
201
+ }
202
+ function embeddedJsonStaysInert() {
203
+ const embedded = (0, profiler_webview_1.embedJson)({ name: webview_contract_helpers_1.HOSTILE });
204
+ assert.ok(!embedded.includes('</script>'), 'embedJson must escape < so the script cannot be closed');
205
+ const roundTripped = JSON.parse(embedded);
206
+ assert.strictEqual((0, unknown_shape_1.stringField)(roundTripped, 'name'), webview_contract_helpers_1.HOSTILE, 'escaping must not corrupt the payload');
207
+ }
208
+ suite('Profiler webviews — shared host hardening', () => {
209
+ test('memory dashboard HTML is CSP-locked and hostile allocation data cannot escape the script', hostileDashboardIsInert);
210
+ // [PROF-CPU-START] The dashboard is the landing view for memory results;
211
+ // the raw V8 .heapprofile opens on demand from its own button, and no
212
+ // button is rendered when no trace was written.
213
+ test('the dashboard offers the raw heap profile via a button only when one exists', heapProfileButtonsOnlyWithATrace);
214
+ test('retention graph HTML is CSP-locked and hostile type names/reprs cannot escape', hostileRetentionGraphIsInert);
215
+ test('retention graph names each root by its label, above the holders and the targets they keep alive', rootsAreNamedAboveWhatTheyHold);
216
+ test('a decoded retention graph keeps each root, its kind and its label', decodingKeepsRoots);
217
+ test('retention graph renders an honest empty state when the walk found nothing', anEmptyWalkSaysSo);
218
+ test('profiler webviews follow the editor theme instead of hardcoding a dark palette', viewsFollowTheEditorTheme);
219
+ test('embedJson keeps a </script> payload inert inside an inline script', embeddedJsonStaysInert);
220
+ });
221
+ //# sourceMappingURL=webview-contract-memory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"webview-contract-memory.js","sourceRoot":"","sources":["../../../src/testing/webview-contract-memory.ts"],"names":[],"mappings":";AAAA,yFAAyF;AACzF;;;GAGG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,MAAY,MAAM,wCAAoB;AACtC,MAAY,EAAE,oCAAgB;AAE9B,0DAA+D;AAE/D,0DAAwE;AACxE,0EAAkE;AAClE,0DAAgD;AAChD,oDAA+C;AAC/C,yEAAuF;AAQvF,wEAAwE;AACxE,SAAS,gBAAgB;IACrB,0EAA0E;AAC9E,CAAC;AAED,gFAAgF;AAChF,MAAM,oBAAoB,GAAG,GAAmD,EAAE,CAAC,CAAC;IAChF,gBAAgB,EAAE,CAAC,IAAY,EAAU,EAAE,CAAC,IAAI;CACnD,CAAC,CAAC;AA2BH;;;;;GAKG;AACH,SAAS,UAAU,CAAC,IAAY;IAC5B,MAAM,MAAM,GAAG,mDAAmD,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,IAAI,IAAI,EAAE,CAAC;IAClG,MAAM,KAAK,GAAgB,EAAE,CAAC;IAC9B,MAAM,GAAG,GAAiB;QACtB,SAAS,EAAE,EAAE;QACb,QAAQ,EAAE,CAAC,IAAY,EAAE,EAAU,EAAE,CAAS,EAAQ,EAAE,GAAG,KAAK,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,GAAG,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC,CAAC;KAC7G,CAAC;IACF,MAAM,GAAG,GAAG,YAAY,CAAC,GAAG,CAAC,CAAC;IAC9B,MAAM,MAAM,GAAG,eAAe,CAAC,GAAG,CAAC,CAAC;IACpC,MAAM,QAAQ,GAAG,iBA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IACnD,MAAM,CAAC,WAAW,CAAC,IAAA,2BAAW,EAAC,YAAY,EAAE,MAAM,CAAC,EAAE,kCAAO,EAAE,uCAAuC,CAAC,CAAC;AAC5G,CAAC;AAED,KAAK,CAAC,2CAA2C,EAAE,GAAG,EAAE;IACpD,IAAI,CAAC,0FAA0F,EAAE,uBAAuB,CAAC,CAAC;IAC1H,yEAAyE;IACzE,sEAAsE;IACtE,gDAAgD;IAChD,IAAI,CAAC,6EAA6E,EAAE,gCAAgC,CAAC,CAAC;IACtH,IAAI,CAAC,+EAA+E,EAAE,4BAA4B,CAAC,CAAC;IACpH,IAAI,CAAC,iGAAiG,EAAE,8BAA8B,CAAC,CAAC;IACxI,IAAI,CAAC,mEAAmE,EAAE,kBAAkB,CAAC,CAAC;IAC9F,IAAI,CAAC,2EAA2E,EAAE,iBAAiB,CAAC,CAAC;IACrG,IAAI,CAAC,gFAAgF,EAAE,yBAAyB,CAAC,CAAC;IAClH,IAAI,CAAC,mEAAmE,EAAE,sBAAsB,CAAC,CAAC;AACtG,CAAC,CAAC,CAAC"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Every profiler view draws its heat, memory and leak accents in the host's
3
+ * palette: a host that supplies green never shows a purple bar, a label that
4
+ * names a colour it does not draw, or dark text on a dark accent.
5
+ */
6
+ export {};
@@ -0,0 +1,121 @@
1
+ "use strict";
2
+ // Implements [PROF-UI-PALETTE]. See docs/specs/LSP-PROFILER-SPEC.md
3
+ /**
4
+ * Every profiler view draws its heat, memory and leak accents in the host's
5
+ * palette: a host that supplies green never shows a purple bar, a label that
6
+ * names a colour it does not draw, or dark text on a dark accent.
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
+ const assert = __importStar(require("node:assert"));
43
+ const vscode = __importStar(require("vscode"));
44
+ const ids_1 = require("../ids");
45
+ const memory_dashboard_1 = require("../memory-dashboard");
46
+ const memory_ref_graph_1 = require("../memory-ref-graph");
47
+ const palette_1 = require("../palette");
48
+ const flame_script_1 = require("../flame-script");
49
+ const profiler_flamegraph_html_1 = require("../profiler-flamegraph-html");
50
+ const webview_contract_helpers_1 = require("./webview-contract-helpers");
51
+ const webview_contract_leak_1 = require("./webview-contract-leak");
52
+ /** A dark host palette that shares no colour with the default one. */
53
+ const DARK_PALETTE = {
54
+ critical: '#1b4d2e', hot: '#235c37', warm: '#2e6b41', memory: '#14324a', memoryHot: '#1c4060',
55
+ memoryWarm: '#244d72', memoryCool: '#2c5a84', leak: '#5a1c1c', success: '#1c5a3c',
56
+ };
57
+ const LEAKING_DIFF = {
58
+ totalGrowth: 2048, totalFreed: 0, netGrowth: 2048, grownAllocations: [],
59
+ suspectedLeaks: ['definite', 'high', 'medium', 'low'].map((confidence) => ({
60
+ file: '/app/leak.py', line: 4, sizeGrowth: 2048, countGrowth: 2,
61
+ currentSize: 4096, currentCount: 4, confidence, reason: 'grows on every pass',
62
+ })),
63
+ };
64
+ /** Every profiler view, rendered under whatever palette is configured now. */
65
+ async function everyView() {
66
+ return {
67
+ 'memory dashboard': (0, memory_dashboard_1.buildMemoryDashboardHtml)((0, webview_contract_helpers_1.dashboardSnapshot)(), LEAKING_DIFF),
68
+ 'retention graph': (0, memory_ref_graph_1.buildRefGraphHtml)({ targetType: 'W', maxDepth: 5, maxNodes: 200, script: '' }),
69
+ 'results panel': await (0, profiler_flamegraph_html_1.buildFlamegraphHtml)((0, webview_contract_helpers_1.profileResult)()),
70
+ };
71
+ }
72
+ /** Render every view with `palette` as the user's override, then restore the setting. */
73
+ async function viewsUnder(palette) {
74
+ const config = vscode.workspace.getConfiguration((0, ids_1.configSection)());
75
+ const previous = config.inspect('profiler.palette')?.globalValue;
76
+ await config.update('profiler.palette', palette, vscode.ConfigurationTarget.Global);
77
+ try {
78
+ return await everyView();
79
+ }
80
+ finally {
81
+ await config.update('profiler.palette', previous, vscode.ConfigurationTarget.Global);
82
+ }
83
+ }
84
+ async function noViewKeepsADefaultAccent() {
85
+ for (const [view, html] of Object.entries(await viewsUnder(DARK_PALETTE))) {
86
+ assert.ok(html.includes((0, palette_1.paletteCss)(DARK_PALETTE)), `the ${view} declares the host palette`);
87
+ for (const [role, hex] of Object.entries(palette_1.DEFAULT_PALETTE)) {
88
+ assert.ok(!html.toLowerCase().includes(String(hex)), `the ${view} draws the default ${role} ${String(hex)} under a host palette`);
89
+ }
90
+ }
91
+ }
92
+ function inkContrastsWithItsFill() {
93
+ assert.equal((0, palette_1.inkFor)(DARK_PALETTE.hot), (0, palette_1.inkFor)('#000000'), 'a dark accent carries light ink');
94
+ assert.equal((0, palette_1.inkFor)(palette_1.DEFAULT_PALETTE.warm), (0, palette_1.inkFor)('#ffffff'), 'a light accent carries dark ink');
95
+ assert.notEqual((0, palette_1.inkFor)('#000000'), (0, palette_1.inkFor)('#ffffff'));
96
+ assert.ok((0, palette_1.paletteCss)(DARK_PALETTE).includes(`--prof-hot-ink: ${(0, palette_1.inkFor)(DARK_PALETTE.hot)};`), 'the hot accent declares its ink');
97
+ }
98
+ /** The body of every `.toggle.active` rule, read up to its closing brace. A plain split, not a regex, keeps the scan linear (CodeQL js/polynomial-redos). */
99
+ function activeToggleRules(css) {
100
+ return css.split('.toggle.active {').slice(1).map((rest) => rest.split('}')[0] ?? '');
101
+ }
102
+ async function textOnAnAccentReadsItsInk() {
103
+ const views = await viewsUnder(DARK_PALETTE);
104
+ const results = views['results panel'] ?? '';
105
+ assert.ok(activeToggleRules(results).some((rule) => rule.includes('color: var(--prof-hot-ink)')), 'the active toggle writes in the hot accent\'s ink');
106
+ assert.ok(flame_script_1.FLAME_SCRIPT.includes('ctx.fillStyle = inkFor(model.frames[r.frameIdx].color)'), 'a slab label is inked against its own slab');
107
+ assert.ok(flame_script_1.FLAME_SCRIPT.includes(palette_1.inkFor.toString()), 'the canvas runs the tested ink rule');
108
+ }
109
+ function labelsNameNoColour() {
110
+ const dashboard = (0, memory_dashboard_1.buildMemoryDashboardHtml)((0, webview_contract_helpers_1.dashboardSnapshot)());
111
+ assert.ok(dashboard.includes('id="btn-mem">Memory</button>'), 'the memory heat toggle names its metric, not a colour');
112
+ assert.ok(dashboard.includes('id="btn-cpu">CPU</button>'), 'the CPU heat toggle names its metric, not a colour');
113
+ }
114
+ suite('Profiler webviews — host palette', () => {
115
+ test('no view draws a default accent under a host palette', noViewKeepsADefaultAccent);
116
+ test('ink contrasts with the accent it is written on', inkContrastsWithItsFill);
117
+ test('text on an accent is written in that accent\'s ink', textOnAnAccentReadsItsInk);
118
+ test('a heat toggle names its metric, never a colour', labelsNameNoColour);
119
+ test('editor leak decorations wear the host palette at every confidence', webview_contract_leak_1.leakDecorationsWearTheHostPalette);
120
+ });
121
+ //# sourceMappingURL=webview-contract-palette.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"webview-contract-palette.js","sourceRoot":"","sources":["../../../src/testing/webview-contract-palette.ts"],"names":[],"mappings":";AAAA,oEAAoE;AACpE;;;;GAIG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,MAAY,MAAM,wCAAoB;AACtC,MAAY,MAAM,mCAAe;AACjC,gCAAuC;AAEvC,0DAA+D;AAC/D,0DAAwD;AACxD,wCAAiE;AAEjE,kDAA+C;AAC/C,0EAAkE;AAClE,yEAA8E;AAC9E,mEAA4E;AAE5E,sEAAsE;AACtE,MAAM,YAAY,GAA8B;IAC5C,QAAQ,EAAE,SAAS,EAAE,GAAG,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS;IAC7F,UAAU,EAAE,SAAS,EAAE,UAAU,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,SAAS;CACpF,CAAC;AAEF,MAAM,YAAY,GAAmB;IACjC,WAAW,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,gBAAgB,EAAE,EAAE;IACvE,cAAc,EAAG,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,CAAW,CAAC,GAAG,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;QAClF,IAAI,EAAE,cAAc,EAAE,IAAI,EAAE,CAAC,EAAE,UAAU,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC;QAC/D,WAAW,EAAE,IAAI,EAAE,YAAY,EAAE,CAAC,EAAE,UAAU,EAAE,MAAM,EAAE,qBAAqB;KAChF,CAAC,CAAC;CACN,CAAC;AAEF,8EAA8E;AAC9E,KAAK,UAAU,SAAS;IACpB,OAAO;QACH,kBAAkB,EAAE,IAAA,2CAAwB,EAAC,IAAA,4CAAiB,GAAE,EAAE,YAAY,CAAC;Q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,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,4BAA4B,CAAC,CAAC,EAAE,mDAAmD,CAAC,CAAC;IACvJ,MAAM,CAAC,EAAE,CAAC,2BAAY,CAAC,QAAQ,CAAC,wDAAwD,CAAC,EAAE,4CAA4C,CAAC,CAAC;IACzI,MAAM,CAAC,EAAE,CAAC,2BAAY,CAAC,QAAQ,CAAC,gBAAM,CAAC,QAAQ,EAAE,CAAC,EAAE,qCAAqC,CAAC,CAAC;AAC/F,CAAC;AAED,SAAS,kBAAkB;IACvB,MAAM,SAAS,GAAG,IAAA,2CAAwB,EAAC,IAAA,4CAAiB,GAAE,CAAC,CAAC;IAChE,MAAM,CAAC,EAAE,CAAC,SAAS,CAAC,QAAQ,CAAC,8BAA8B,CAAC,EAAE,uDAAuD,CAAC,CAAC;IACvH,MAAM,CAAC,EAAE,CAAC,SAAS,CAAC,QAAQ,CAAC,2BAA2B,CAAC,EAAE,oDAAoD,CAAC,CAAC;AACrH,CAAC;AAED,KAAK,CAAC,kCAAkC,EAAE,GAAG,EAAE;IAC3C,IAAI,CAAC,qDAAqD,EAAE,yBAAyB,CAAC,CAAC;IACvF,IAAI,CAAC,gDAAgD,EAAE,uBAAuB,CAAC,CAAC;IAChF,IAAI,CAAC,oDAAoD,EAAE,yBAAyB,CAAC,CAAC;IACtF,IAAI,CAAC,gDAAgD,EAAE,kBAAkB,CAAC,CAAC;IAC3E,IAAI,CAAC,mEAAmE,EAAE,yDAAiC,CAAC,CAAC;AACjH,CAAC,CAAC,CAAC"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * A singleton panel binds its message handler once, however often it is
3
+ * re-rendered, and drops a posted message that is not a profiler message.
4
+ * A webview delivers its posts in order, so a closing marker post tells the
5
+ * test every earlier post has been delivered or dropped: nothing waits on time.
6
+ */
7
+ export {};