@speedkit/cli 4.50.4 → 4.51.0-run-control.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 (416) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/README.md +1369 -10
  3. package/dist/base/run-control-command.d.ts +15 -0
  4. package/dist/base/run-control-command.js +20 -0
  5. package/dist/build-info.json +6 -0
  6. package/dist/commands/diff.d.ts +6 -1
  7. package/dist/commands/diff.js +9 -3
  8. package/dist/commands/onboarding/browser/click.d.ts +75 -0
  9. package/dist/commands/onboarding/browser/click.js +19 -0
  10. package/dist/commands/onboarding/browser/emulate.d.ts +93 -0
  11. package/dist/commands/onboarding/browser/emulate.js +23 -0
  12. package/dist/commands/onboarding/browser/navigate.d.ts +67 -0
  13. package/dist/commands/onboarding/browser/navigate.js +18 -0
  14. package/dist/commands/onboarding/browser/panel.d.ts +63 -0
  15. package/dist/commands/onboarding/browser/panel.js +12 -0
  16. package/dist/commands/onboarding/browser/reinstall-sw.d.ts +63 -0
  17. package/dist/commands/onboarding/browser/reinstall-sw.js +14 -0
  18. package/dist/commands/onboarding/browser/reset.d.ts +71 -0
  19. package/dist/commands/onboarding/browser/reset.js +18 -0
  20. package/dist/commands/onboarding/browser/screenshot.d.ts +77 -0
  21. package/dist/commands/onboarding/browser/screenshot.js +19 -0
  22. package/dist/commands/onboarding/browser/state.d.ts +63 -0
  23. package/dist/commands/onboarding/browser/state.js +12 -0
  24. package/dist/commands/onboarding/browser/tabs.d.ts +58 -0
  25. package/dist/commands/onboarding/browser/tabs.js +16 -0
  26. package/dist/commands/onboarding/cache/clear.d.ts +58 -0
  27. package/dist/commands/onboarding/cache/clear.js +12 -0
  28. package/dist/commands/onboarding/cache/errors.d.ts +58 -0
  29. package/dist/commands/onboarding/cache/errors.js +12 -0
  30. package/dist/commands/onboarding/cache/evict.d.ts +62 -0
  31. package/dist/commands/onboarding/cache/evict.js +15 -0
  32. package/dist/commands/onboarding/cache/get.d.ts +85 -0
  33. package/dist/commands/onboarding/cache/get.js +17 -0
  34. package/dist/commands/onboarding/cache/list.d.ts +58 -0
  35. package/dist/commands/onboarding/cache/list.js +15 -0
  36. package/dist/commands/onboarding/cache/prewarm.d.ts +73 -0
  37. package/dist/commands/onboarding/cache/prewarm.js +20 -0
  38. package/dist/commands/onboarding/cache/refresh.d.ts +62 -0
  39. package/dist/commands/onboarding/cache/refresh.js +18 -0
  40. package/dist/commands/onboarding/cdp.d.ts +81 -0
  41. package/dist/commands/onboarding/cdp.js +18 -0
  42. package/dist/commands/onboarding/debug/arm.d.ts +77 -0
  43. package/dist/commands/onboarding/debug/arm.js +18 -0
  44. package/dist/commands/onboarding/debug/await.d.ts +71 -0
  45. package/dist/commands/onboarding/debug/await.js +18 -0
  46. package/dist/commands/onboarding/debug/disarm.d.ts +63 -0
  47. package/dist/commands/onboarding/debug/disarm.js +12 -0
  48. package/dist/commands/onboarding/debug/eval.d.ts +75 -0
  49. package/dist/commands/onboarding/debug/eval.js +16 -0
  50. package/dist/commands/onboarding/debug/release.d.ts +63 -0
  51. package/dist/commands/onboarding/debug/release.js +12 -0
  52. package/dist/commands/onboarding/debug/resume.d.ts +63 -0
  53. package/dist/commands/onboarding/debug/resume.js +12 -0
  54. package/dist/commands/onboarding/debug/status.d.ts +63 -0
  55. package/dist/commands/onboarding/debug/status.js +12 -0
  56. package/dist/commands/onboarding/debug/step.d.ts +67 -0
  57. package/dist/commands/onboarding/debug/step.js +15 -0
  58. package/dist/commands/onboarding/files/list.d.ts +58 -0
  59. package/dist/commands/onboarding/files/list.js +12 -0
  60. package/dist/commands/onboarding/files/read.d.ts +73 -0
  61. package/dist/commands/onboarding/files/read.js +16 -0
  62. package/dist/commands/onboarding/files/rebuild.d.ts +63 -0
  63. package/dist/commands/onboarding/files/rebuild.js +18 -0
  64. package/dist/commands/onboarding/files/validate.d.ts +58 -0
  65. package/dist/commands/onboarding/files/validate.js +12 -0
  66. package/dist/commands/onboarding/fouc.d.ts +77 -0
  67. package/dist/commands/onboarding/fouc.js +16 -0
  68. package/dist/commands/onboarding/inject/add.d.ts +89 -0
  69. package/dist/commands/onboarding/inject/add.js +17 -0
  70. package/dist/commands/onboarding/inject/clear.d.ts +63 -0
  71. package/dist/commands/onboarding/inject/clear.js +12 -0
  72. package/dist/commands/onboarding/inject/list.d.ts +63 -0
  73. package/dist/commands/onboarding/inject/list.js +12 -0
  74. package/dist/commands/onboarding/inject/read.d.ts +75 -0
  75. package/dist/commands/onboarding/inject/read.js +18 -0
  76. package/dist/commands/onboarding/inject/recipes.d.ts +63 -0
  77. package/dist/commands/onboarding/inject/recipes.js +12 -0
  78. package/dist/commands/onboarding/inject/remove.d.ts +67 -0
  79. package/dist/commands/onboarding/inject/remove.js +15 -0
  80. package/dist/commands/onboarding/list.d.ts +13 -0
  81. package/dist/commands/onboarding/list.js +12 -0
  82. package/dist/commands/onboarding/logs.d.ts +41 -0
  83. package/dist/commands/onboarding/logs.js +256 -0
  84. package/dist/commands/onboarding/navwalk.d.ts +95 -0
  85. package/dist/commands/onboarding/navwalk.js +19 -0
  86. package/dist/commands/onboarding/response.d.ts +67 -0
  87. package/dist/commands/onboarding/response.js +18 -0
  88. package/dist/commands/onboarding/rum/beacons.d.ts +75 -0
  89. package/dist/commands/onboarding/rum/beacons.js +16 -0
  90. package/dist/commands/onboarding/rum/get.d.ts +77 -0
  91. package/dist/commands/onboarding/rum/get.js +18 -0
  92. package/dist/commands/onboarding/rum/key.d.ts +67 -0
  93. package/dist/commands/onboarding/rum/key.js +13 -0
  94. package/dist/commands/onboarding/rum/previous.d.ts +63 -0
  95. package/dist/commands/onboarding/rum/previous.js +12 -0
  96. package/dist/commands/onboarding/status.d.ts +13 -0
  97. package/dist/commands/onboarding/status.js +17 -0
  98. package/dist/commands/onboarding/todo.d.ts +58 -0
  99. package/dist/commands/onboarding/todo.js +12 -0
  100. package/dist/commands/onboarding/viewport.d.ts +101 -0
  101. package/dist/commands/onboarding/viewport.js +18 -0
  102. package/dist/commands/onboarding/watch.d.ts +93 -0
  103. package/dist/commands/onboarding/watch.js +16 -0
  104. package/dist/commands/onboarding.d.ts +26 -0
  105. package/dist/commands/onboarding.js +220 -3
  106. package/dist/commands/origin-request.d.ts +4 -0
  107. package/dist/commands/origin-request.js +4 -0
  108. package/dist/commands/spec/onboarding.spec.d.ts +1 -0
  109. package/dist/commands/spec/onboarding.spec.js +127 -0
  110. package/dist/services/cli/build-info.d.ts +33 -0
  111. package/dist/services/cli/build-info.js +63 -0
  112. package/dist/services/cli/cli-environment-factory.d.ts +3 -0
  113. package/dist/services/cli/cli-environment-factory.js +1 -0
  114. package/dist/services/cli/cli-service-build-context.d.ts +3 -0
  115. package/dist/services/cli/cli-service-factory.js +1 -1
  116. package/dist/services/cli/cli-service-model.d.ts +29 -10
  117. package/dist/services/cli/cli-service.d.ts +60 -11
  118. package/dist/services/cli/cli-service.js +196 -32
  119. package/dist/services/cli/index.d.ts +2 -0
  120. package/dist/services/cli/index.js +2 -0
  121. package/dist/services/cli/sink.d.ts +47 -0
  122. package/dist/services/cli/sink.js +31 -0
  123. package/dist/services/cli/spec/build-identity.spec.d.ts +1 -0
  124. package/dist/services/cli/spec/build-identity.spec.js +85 -0
  125. package/dist/services/cli/spec/build-info.spec.d.ts +1 -0
  126. package/dist/services/cli/spec/build-info.spec.js +10 -0
  127. package/dist/services/cli/spec/cli-service-log.spec.d.ts +1 -0
  128. package/dist/services/cli/spec/cli-service-log.spec.js +133 -0
  129. package/dist/services/cli/spec/cli-service.spec.js +113 -50
  130. package/dist/services/cli/spec/memory-cli.d.ts +9 -0
  131. package/dist/services/cli/spec/memory-cli.js +9 -0
  132. package/dist/services/diff/config-at-ref.d.ts +20 -0
  133. package/dist/services/diff/config-at-ref.js +33 -0
  134. package/dist/services/diff/diff-service-build-context.d.ts +8 -0
  135. package/dist/services/diff/diff-service-build-context.js +40 -1
  136. package/dist/services/diff/diff-service-factory.d.ts +2 -0
  137. package/dist/services/diff/diff-service-factory.js +48 -20
  138. package/dist/services/diff/diff-service.d.ts +11 -0
  139. package/dist/services/diff/diff-service.js +37 -11
  140. package/dist/services/diff/page-source.d.ts +12 -0
  141. package/dist/services/diff/page-source.js +16 -11
  142. package/dist/services/diff/sinks/tool-diff-sink.d.ts +3 -2
  143. package/dist/services/diff/sinks/tool-diff-sink.js +3 -2
  144. package/dist/services/diff/spec/config-at-ref.spec.d.ts +1 -0
  145. package/dist/services/diff/spec/config-at-ref.spec.js +46 -0
  146. package/dist/services/diff/spec/diff-service-build-context.spec.js +19 -0
  147. package/dist/services/diff/spec/diff-service.spec.js +95 -0
  148. package/dist/services/git/git-repository.d.ts +2 -0
  149. package/dist/services/git/git-repository.js +6 -0
  150. package/dist/services/integration-api/customer-config-flags.js +1 -0
  151. package/dist/services/onboarding/browser/baqend-response.d.ts +17 -1
  152. package/dist/services/onboarding/browser/baqend-response.js +23 -0
  153. package/dist/services/onboarding/browser/console-log.d.ts +9 -0
  154. package/dist/services/onboarding/browser/console-log.js +27 -0
  155. package/dist/services/onboarding/browser/executable/executable-validator.js +4 -2
  156. package/dist/services/onboarding/browser/extension/extension-bridge.js +5 -3
  157. package/dist/services/onboarding/browser/extension/extension-downloader.js +17 -8
  158. package/dist/services/onboarding/browser/extension/extension-validator.js +9 -4
  159. package/dist/services/onboarding/control/body-inspect.d.ts +24 -0
  160. package/dist/services/onboarding/control/body-inspect.js +106 -0
  161. package/dist/services/onboarding/control/browser-session.d.ts +521 -0
  162. package/dist/services/onboarding/control/browser-session.js +1273 -0
  163. package/dist/services/onboarding/control/config-validation.d.ts +17 -0
  164. package/dist/services/onboarding/control/config-validation.js +46 -0
  165. package/dist/services/onboarding/control/control-protocol.d.ts +1390 -0
  166. package/dist/services/onboarding/control/control-protocol.js +69 -0
  167. package/dist/services/onboarding/control/control-server.d.ts +284 -0
  168. package/dist/services/onboarding/control/control-server.js +1609 -0
  169. package/dist/services/onboarding/control/debug-session.d.ts +190 -0
  170. package/dist/services/onboarding/control/debug-session.js +801 -0
  171. package/dist/services/onboarding/control/fouc.d.ts +23 -0
  172. package/dist/services/onboarding/control/fouc.js +151 -0
  173. package/dist/services/onboarding/control/index.d.ts +4 -0
  174. package/dist/services/onboarding/control/index.js +4 -0
  175. package/dist/services/onboarding/control/navwalk.d.ts +65 -0
  176. package/dist/services/onboarding/control/navwalk.js +248 -0
  177. package/dist/services/onboarding/control/preload-registry.d.ts +150 -0
  178. package/dist/services/onboarding/control/preload-registry.js +829 -0
  179. package/dist/services/onboarding/control/response-explainer.d.ts +24 -0
  180. package/dist/services/onboarding/control/response-explainer.js +257 -0
  181. package/dist/services/onboarding/control/rum.d.ts +8 -0
  182. package/dist/services/onboarding/control/rum.js +220 -0
  183. package/dist/services/onboarding/control/service-worker-tracker.d.ts +68 -0
  184. package/dist/services/onboarding/control/service-worker-tracker.js +119 -0
  185. package/dist/services/onboarding/control/viewport.d.ts +45 -0
  186. package/dist/services/onboarding/control/viewport.js +344 -0
  187. package/dist/services/onboarding/control/watch.d.ts +26 -0
  188. package/dist/services/onboarding/control/watch.js +149 -0
  189. package/dist/services/onboarding/dashboard/diff-against-current-page.js +3 -1
  190. package/dist/services/onboarding/dashboard/index.js +7 -2
  191. package/dist/services/onboarding/fetch-event-handler.d.ts +24 -5
  192. package/dist/services/onboarding/fetch-event-handler.js +94 -32
  193. package/dist/services/onboarding/fetch-events/customer-domain-document-response.js +4 -25
  194. package/dist/services/onboarding/fetch-events/speed-kit-install-js.js +11 -2
  195. package/dist/services/onboarding/fetch-events/speed-kit-rum-pi-request.d.ts +14 -0
  196. package/dist/services/onboarding/fetch-events/speed-kit-rum-pi-request.js +30 -0
  197. package/dist/services/onboarding/fetch-events/speed-kit-service-worker-js.d.ts +13 -0
  198. package/dist/services/onboarding/fetch-events/speed-kit-service-worker-js.js +28 -1
  199. package/dist/services/onboarding/file-events/file-watcher.d.ts +42 -1
  200. package/dist/services/onboarding/file-events/file-watcher.js +117 -12
  201. package/dist/services/onboarding/html-charset.d.ts +28 -0
  202. package/dist/services/onboarding/html-charset.js +57 -0
  203. package/dist/services/onboarding/onboarding-model.d.ts +30 -1
  204. package/dist/services/onboarding/onboarding-model.js +10 -1
  205. package/dist/services/onboarding/onboarding-service-build-context.d.ts +4 -0
  206. package/dist/services/onboarding/onboarding-service-build-context.js +6 -0
  207. package/dist/services/onboarding/onboarding-service-factory.d.ts +17 -1
  208. package/dist/services/onboarding/onboarding-service-factory.js +131 -17
  209. package/dist/services/onboarding/onboarding-service.d.ts +40 -1
  210. package/dist/services/onboarding/onboarding-service.js +135 -22
  211. package/dist/services/onboarding/request-cache/asset-key.d.ts +61 -0
  212. package/dist/services/onboarding/request-cache/asset-key.js +115 -0
  213. package/dist/services/onboarding/request-cache/cache.d.ts +62 -5
  214. package/dist/services/onboarding/request-cache/cache.js +128 -17
  215. package/dist/services/onboarding/spec/browser/console-log.spec.d.ts +1 -0
  216. package/dist/services/onboarding/spec/browser/console-log.spec.js +42 -0
  217. package/dist/services/onboarding/spec/control/browser-session.spec.d.ts +1 -0
  218. package/dist/services/onboarding/spec/control/browser-session.spec.js +526 -0
  219. package/dist/services/onboarding/spec/control/control-server.spec.d.ts +1 -0
  220. package/dist/services/onboarding/spec/control/control-server.spec.js +338 -0
  221. package/dist/services/onboarding/spec/control/debug-session.spec.d.ts +1 -0
  222. package/dist/services/onboarding/spec/control/debug-session.spec.js +693 -0
  223. package/dist/services/onboarding/spec/control/fakes.d.ts +31 -0
  224. package/dist/services/onboarding/spec/control/fakes.js +66 -0
  225. package/dist/services/onboarding/spec/control/fouc.spec.d.ts +1 -0
  226. package/dist/services/onboarding/spec/control/fouc.spec.js +167 -0
  227. package/dist/services/onboarding/spec/control/navwalk.spec.d.ts +1 -0
  228. package/dist/services/onboarding/spec/control/navwalk.spec.js +222 -0
  229. package/dist/services/onboarding/spec/control/preload-registry.spec.d.ts +1 -0
  230. package/dist/services/onboarding/spec/control/preload-registry.spec.js +432 -0
  231. package/dist/services/onboarding/spec/control/response-explainer.spec.d.ts +1 -0
  232. package/dist/services/onboarding/spec/control/response-explainer.spec.js +324 -0
  233. package/dist/services/onboarding/spec/control/rum.spec.d.ts +1 -0
  234. package/dist/services/onboarding/spec/control/rum.spec.js +222 -0
  235. package/dist/services/onboarding/spec/control/service-worker-tracker.spec.d.ts +1 -0
  236. package/dist/services/onboarding/spec/control/service-worker-tracker.spec.js +193 -0
  237. package/dist/services/onboarding/spec/control/viewport.spec.d.ts +1 -0
  238. package/dist/services/onboarding/spec/control/viewport.spec.js +200 -0
  239. package/dist/services/onboarding/spec/control/watch.spec.d.ts +1 -0
  240. package/dist/services/onboarding/spec/control/watch.spec.js +172 -0
  241. package/dist/services/onboarding/spec/fetch-event-handler.spec.d.ts +1 -0
  242. package/dist/services/onboarding/spec/fetch-event-handler.spec.js +202 -0
  243. package/dist/services/onboarding/spec/fetch-events/customer-domain-document-response.spec.d.ts +1 -0
  244. package/dist/services/onboarding/spec/fetch-events/customer-domain-document-response.spec.js +39 -0
  245. package/dist/services/onboarding/spec/fetch-events/speed-kit-service-worker-js.spec.d.ts +1 -0
  246. package/dist/services/onboarding/spec/fetch-events/speed-kit-service-worker-js.spec.js +41 -0
  247. package/dist/services/onboarding/spec/html-charset.spec.d.ts +1 -0
  248. package/dist/services/onboarding/spec/html-charset.spec.js +58 -0
  249. package/dist/services/onboarding/spec/onboarding-model.spec.js +37 -0
  250. package/dist/services/onboarding/spec/onboarding-service-factory.spec.js +1 -0
  251. package/dist/services/onboarding/spec/request-cache/cache.spec.d.ts +1 -0
  252. package/dist/services/onboarding/spec/request-cache/cache.spec.js +107 -0
  253. package/dist/services/onboarding/spec/todo-collector.spec.d.ts +1 -0
  254. package/dist/services/onboarding/spec/todo-collector.spec.js +136 -0
  255. package/dist/services/onboarding/spec/virtual-orestes-app/index.spec.d.ts +1 -0
  256. package/dist/services/onboarding/spec/virtual-orestes-app/index.spec.js +19 -0
  257. package/dist/services/onboarding/todo-collector.d.ts +7 -2
  258. package/dist/services/onboarding/todo-collector.js +49 -12
  259. package/dist/services/onboarding/virtual-orestes-app/index.d.ts +34 -0
  260. package/dist/services/onboarding/virtual-orestes-app/index.js +85 -53
  261. package/dist/services/origin-request/asset-variations.d.ts +14 -0
  262. package/dist/services/origin-request/asset-variations.js +11 -4
  263. package/dist/services/origin-request/origin-fetcher.d.ts +7 -0
  264. package/dist/services/origin-request/origin-fetcher.js +43 -5
  265. package/dist/services/origin-request/origin-request-service-build-context.d.ts +17 -0
  266. package/dist/services/origin-request/origin-request-service-build-context.js +8 -0
  267. package/dist/services/origin-request/origin-request-service-factory.d.ts +0 -5
  268. package/dist/services/origin-request/origin-request-service-factory.js +2 -30
  269. package/dist/services/origin-request/origin-request-service.d.ts +121 -6
  270. package/dist/services/origin-request/origin-request-service.js +273 -49
  271. package/dist/services/origin-request/runtime-config-source.js +9 -4
  272. package/dist/services/origin-request/spec/asset-variations.spec.js +20 -0
  273. package/dist/services/origin-request/spec/origin-request-service.spec.js +329 -6
  274. package/dist/services/query-builder/rules/rule-match.d.ts +35 -0
  275. package/dist/services/query-builder/rules/rule-match.js +70 -0
  276. package/dist/services/query-builder/spec/rules/rule-match.spec.d.ts +1 -0
  277. package/dist/services/query-builder/spec/rules/rule-match.spec.js +121 -0
  278. package/dist/services/run-control/browser/run-browser-contexts.d.ts +541 -0
  279. package/dist/services/run-control/browser/run-browser-contexts.js +78 -0
  280. package/dist/services/run-control/browser/run-browser-service-factory.d.ts +5 -0
  281. package/dist/services/run-control/browser/run-browser-service-factory.js +7 -0
  282. package/dist/services/run-control/browser/run-browser-service.d.ts +64 -0
  283. package/dist/services/run-control/browser/run-browser-service.js +199 -0
  284. package/dist/services/run-control/cache/run-cache-contexts.d.ts +349 -0
  285. package/dist/services/run-control/cache/run-cache-contexts.js +51 -0
  286. package/dist/services/run-control/cache/run-cache-service-factory.d.ts +6 -0
  287. package/dist/services/run-control/cache/run-cache-service-factory.js +12 -0
  288. package/dist/services/run-control/cache/run-cache-service.d.ts +35 -0
  289. package/dist/services/run-control/cache/run-cache-service.js +151 -0
  290. package/dist/services/run-control/control-client.d.ts +36 -0
  291. package/dist/services/run-control/control-client.js +147 -0
  292. package/dist/services/run-control/debug/run-debug-contexts.d.ts +411 -0
  293. package/dist/services/run-control/debug/run-debug-contexts.js +44 -0
  294. package/dist/services/run-control/debug/run-debug-service-factory.d.ts +5 -0
  295. package/dist/services/run-control/debug/run-debug-service-factory.js +7 -0
  296. package/dist/services/run-control/debug/run-debug-service.d.ts +38 -0
  297. package/dist/services/run-control/debug/run-debug-service.js +161 -0
  298. package/dist/services/run-control/files/run-files-contexts.d.ts +238 -0
  299. package/dist/services/run-control/files/run-files-contexts.js +26 -0
  300. package/dist/services/run-control/files/run-files-service-factory.d.ts +5 -0
  301. package/dist/services/run-control/files/run-files-service-factory.js +7 -0
  302. package/dist/services/run-control/files/run-files-service.d.ts +29 -0
  303. package/dist/services/run-control/files/run-files-service.js +120 -0
  304. package/dist/services/run-control/index.d.ts +32 -0
  305. package/dist/services/run-control/index.js +31 -0
  306. package/dist/services/run-control/inject/run-inject-contexts.d.ts +319 -0
  307. package/dist/services/run-control/inject/run-inject-contexts.js +32 -0
  308. package/dist/services/run-control/inject/run-inject-service-factory.d.ts +5 -0
  309. package/dist/services/run-control/inject/run-inject-service-factory.js +7 -0
  310. package/dist/services/run-control/inject/run-inject-service.d.ts +31 -0
  311. package/dist/services/run-control/inject/run-inject-service.js +203 -0
  312. package/dist/services/run-control/live-run.d.ts +37 -0
  313. package/dist/services/run-control/live-run.js +56 -0
  314. package/dist/services/run-control/probe/run-probe-contexts.d.ts +333 -0
  315. package/dist/services/run-control/probe/run-probe-contexts.js +73 -0
  316. package/dist/services/run-control/probe/run-probe-service-factory.d.ts +5 -0
  317. package/dist/services/run-control/probe/run-probe-service-factory.js +7 -0
  318. package/dist/services/run-control/probe/run-probe-service.d.ts +54 -0
  319. package/dist/services/run-control/probe/run-probe-service.js +193 -0
  320. package/dist/services/run-control/rum/run-rum-contexts.d.ts +216 -0
  321. package/dist/services/run-control/rum/run-rum-contexts.js +34 -0
  322. package/dist/services/run-control/rum/run-rum-service-factory.d.ts +5 -0
  323. package/dist/services/run-control/rum/run-rum-service-factory.js +7 -0
  324. package/dist/services/run-control/rum/run-rum-service.d.ts +36 -0
  325. package/dist/services/run-control/rum/run-rum-service.js +122 -0
  326. package/dist/services/run-control/run-answer.d.ts +28 -0
  327. package/dist/services/run-control/run-answer.js +58 -0
  328. package/dist/services/run-control/run-control-context.d.ts +102 -0
  329. package/dist/services/run-control/run-control-context.js +36 -0
  330. package/dist/services/run-control/run-control-flags.d.ts +12 -0
  331. package/dist/services/run-control/run-control-flags.js +22 -0
  332. package/dist/services/run-control/run-control-model.d.ts +9 -0
  333. package/dist/services/run-control/run-control-model.js +1 -0
  334. package/dist/services/run-control/run-control-service-factory.d.ts +14 -0
  335. package/dist/services/run-control/run-control-service-factory.js +26 -0
  336. package/dist/services/run-control/session/run-session-contexts.d.ts +25 -0
  337. package/dist/services/run-control/session/run-session-contexts.js +20 -0
  338. package/dist/services/run-control/session/run-session-service-factory.d.ts +8 -0
  339. package/dist/services/run-control/session/run-session-service-factory.js +18 -0
  340. package/dist/services/run-control/session/run-session-service.d.ts +25 -0
  341. package/dist/services/run-control/session/run-session-service.js +95 -0
  342. package/dist/services/run-control/spec/browser/run-browser-service.spec.d.ts +1 -0
  343. package/dist/services/run-control/spec/browser/run-browser-service.spec.js +327 -0
  344. package/dist/services/run-control/spec/cache/run-cache-service.spec.d.ts +1 -0
  345. package/dist/services/run-control/spec/cache/run-cache-service.spec.js +454 -0
  346. package/dist/services/run-control/spec/debug/run-debug-service.spec.d.ts +1 -0
  347. package/dist/services/run-control/spec/debug/run-debug-service.spec.js +113 -0
  348. package/dist/services/run-control/spec/files/run-files-service.spec.d.ts +1 -0
  349. package/dist/services/run-control/spec/files/run-files-service.spec.js +234 -0
  350. package/dist/services/run-control/spec/inject/run-inject-service.spec.d.ts +1 -0
  351. package/dist/services/run-control/spec/inject/run-inject-service.spec.js +224 -0
  352. package/dist/services/run-control/spec/live-run-fixture.d.ts +32 -0
  353. package/dist/services/run-control/spec/live-run-fixture.js +109 -0
  354. package/dist/services/run-control/spec/probe/run-probe-service.spec.d.ts +1 -0
  355. package/dist/services/run-control/spec/probe/run-probe-service.spec.js +108 -0
  356. package/dist/services/run-control/spec/rum/run-rum-service.spec.d.ts +1 -0
  357. package/dist/services/run-control/spec/rum/run-rum-service.spec.js +47 -0
  358. package/dist/services/run-control/spec/run-answer.spec.d.ts +1 -0
  359. package/dist/services/run-control/spec/run-answer.spec.js +57 -0
  360. package/dist/services/run-control/spec/session/run-session-service.spec.d.ts +1 -0
  361. package/dist/services/run-control/spec/session/run-session-service.spec.js +101 -0
  362. package/dist/services/run-log/crash-mirror.d.ts +31 -0
  363. package/dist/services/run-log/crash-mirror.js +69 -0
  364. package/dist/services/run-log/index.d.ts +11 -0
  365. package/dist/services/run-log/index.js +11 -0
  366. package/dist/services/run-log/jsonl-appender.d.ts +46 -0
  367. package/dist/services/run-log/jsonl-appender.js +91 -0
  368. package/dist/services/run-log/log-event-model.d.ts +104 -0
  369. package/dist/services/run-log/log-event-model.js +56 -0
  370. package/dist/services/run-log/log-query-service-factory.d.ts +11 -0
  371. package/dist/services/run-log/log-query-service-factory.js +14 -0
  372. package/dist/services/run-log/log-query-service.d.ts +59 -0
  373. package/dist/services/run-log/log-query-service.js +111 -0
  374. package/dist/services/run-log/log-reader.d.ts +84 -0
  375. package/dist/services/run-log/log-reader.js +180 -0
  376. package/dist/services/run-log/log-summary.d.ts +72 -0
  377. package/dist/services/run-log/log-summary.js +208 -0
  378. package/dist/services/run-log/redaction.d.ts +34 -0
  379. package/dist/services/run-log/redaction.js +124 -0
  380. package/dist/services/run-log/request-log.d.ts +80 -0
  381. package/dist/services/run-log/request-log.js +69 -0
  382. package/dist/services/run-log/request-summary.d.ts +76 -0
  383. package/dist/services/run-log/request-summary.js +0 -0
  384. package/dist/services/run-log/run-log.d.ts +61 -0
  385. package/dist/services/run-log/run-log.js +102 -0
  386. package/dist/services/run-log/spec/log-query-service.spec.d.ts +1 -0
  387. package/dist/services/run-log/spec/log-query-service.spec.js +197 -0
  388. package/dist/services/run-log/spec/log-reader.spec.d.ts +1 -0
  389. package/dist/services/run-log/spec/log-reader.spec.js +109 -0
  390. package/dist/services/run-log/spec/log-summary.spec.d.ts +1 -0
  391. package/dist/services/run-log/spec/log-summary.spec.js +153 -0
  392. package/dist/services/run-log/spec/redaction.spec.d.ts +1 -0
  393. package/dist/services/run-log/spec/redaction.spec.js +61 -0
  394. package/dist/services/run-log/spec/request-log.spec.d.ts +1 -0
  395. package/dist/services/run-log/spec/request-log.spec.js +101 -0
  396. package/dist/services/run-log/spec/request-summary.spec.d.ts +1 -0
  397. package/dist/services/run-log/spec/request-summary.spec.js +171 -0
  398. package/dist/services/run-log/spec/run-log.spec.d.ts +1 -0
  399. package/dist/services/run-log/spec/run-log.spec.js +122 -0
  400. package/dist/services/run-registry/exit-classification.d.ts +39 -0
  401. package/dist/services/run-registry/exit-classification.js +42 -0
  402. package/dist/services/run-registry/index.d.ts +3 -0
  403. package/dist/services/run-registry/index.js +3 -0
  404. package/dist/services/run-registry/process-identity.d.ts +28 -0
  405. package/dist/services/run-registry/process-identity.js +80 -0
  406. package/dist/services/run-registry/run-registry-model.d.ts +128 -0
  407. package/dist/services/run-registry/run-registry-model.js +16 -0
  408. package/dist/services/run-registry/run-registry.d.ts +150 -0
  409. package/dist/services/run-registry/run-registry.js +409 -0
  410. package/dist/services/run-registry/spec/exit-classification.spec.d.ts +1 -0
  411. package/dist/services/run-registry/spec/exit-classification.spec.js +82 -0
  412. package/dist/services/run-registry/spec/run-registry.spec.d.ts +1 -0
  413. package/dist/services/run-registry/spec/run-registry.spec.js +509 -0
  414. package/dist/services/setup/os/tool-registry.js +2 -2
  415. package/oclif.manifest.json +3293 -272
  416. package/package.json +21 -3
@@ -0,0 +1,801 @@
1
+ /** How long `await` waits when the caller names nothing. */
2
+ const DEFAULT_AWAIT_MS = 15_000;
3
+ /**
4
+ * Every devtools-panel breakpoint key starts with this.
5
+ *
6
+ * The panel has one more breakpoint than this run numbers (`bp-config`), and
7
+ * may grow others. A release matches the prefix so a switch this side does not
8
+ * know about still comes out of the page.
9
+ */
10
+ const PANEL_FLAG_PREFIX = "sk-devtools-bp";
11
+ /**
12
+ * How long `Page.navigate` may take. It answers on commit, not on load — which
13
+ * is also why it is used: a breakpoint pauses the document before its load
14
+ * event, and a navigation that waited for load would wait out the pause.
15
+ */
16
+ const NAVIGATE_ANSWER_MS = 15_000;
17
+ /** How long a resumed page gets before the release looks at it again. */
18
+ const SETTLE_AFTER_RESUME_MS = 250;
19
+ /** The console marker the arming script uses to report a skipped comparison. */
20
+ const SKIP_PREFIX = "__SK_DEBUG_CD_SKIPPED__";
21
+ /**
22
+ * The four anchors, and what each one is for.
23
+ *
24
+ * Every one is a `performance.mark` Speed Kit emits, so a single wrapper covers
25
+ * the whole lifecycle — which is why this works with no source maps, no script
26
+ * ids and nothing to re-resolve when a build changes.
27
+ */
28
+ const BREAKPOINTS = [
29
+ {
30
+ bp: 1,
31
+ mark: "baqend-blocking-script-start",
32
+ description: "before the merge, before any page JS has run",
33
+ flagKey: "sk-devtools-bp1",
34
+ },
35
+ {
36
+ bp: 2,
37
+ mark: "baqend-blocking-script-end",
38
+ description: "after the merge, still before page JS",
39
+ flagKey: "sk-devtools-bp2",
40
+ },
41
+ {
42
+ bp: 3,
43
+ mark: "sk-prerender-change-detection-end",
44
+ ssrOnly: true,
45
+ description: "the SSR comparison ran, before the switch hook",
46
+ flagKey: "sk-devtools-bp3",
47
+ },
48
+ {
49
+ bp: 4,
50
+ mark: "sk-prerender-observe-end",
51
+ ssrOnly: true,
52
+ description: "after the SSR containers were removed",
53
+ flagKey: "sk-devtools-bp4",
54
+ },
55
+ ];
56
+ export class NotPausedError extends Error {
57
+ code = "NOT_PAUSED";
58
+ }
59
+ export class NotArmedError extends Error {
60
+ code = "NOT_ARMED";
61
+ }
62
+ export class NoSuchBreakpointError extends Error {
63
+ breakpoints;
64
+ code = "NO_SUCH_BREAKPOINT";
65
+ constructor(message, breakpoints) {
66
+ super(message);
67
+ this.breakpoints = breakpoints;
68
+ }
69
+ }
70
+ /**
71
+ * Breakpoints in Speed Kit's page lifecycle, and control of the pause.
72
+ *
73
+ * `tools/sk-debug.mjs` promoted. The script attaches over `:9222` and exposes
74
+ * its controls on an HTTP port of its own; this is the same surface owned by
75
+ * the run that already holds the page, which is what lets it work with DevTools
76
+ * closed: a CDP client holding `Debugger.enable` *is* an attached debugger, so
77
+ * an injected `debugger;` traps whether or not anyone has the Sources panel
78
+ * open.
79
+ *
80
+ * Arming here is the mark-wrapper tier. The devtools extension has a better one
81
+ * — it can put the pause inside Speed Kit's own frame, with diagnostics — and
82
+ * when that bridge lands it becomes the arming backend and this stays as the
83
+ * fallback. Pause control does not change either way: `Debugger.resume` works
84
+ * on any pause, whoever caused it.
85
+ */
86
+ export class DebugSession {
87
+ transport;
88
+ preloads;
89
+ extensionArms;
90
+ onRelease;
91
+ armed = [];
92
+ attached = false;
93
+ paused = false;
94
+ lastPause = null;
95
+ skipReason = null;
96
+ /**
97
+ * Breakpoints that have paused on the document loaded now.
98
+ *
99
+ * Reset on navigation, because "already done its job" is a fact about one
100
+ * document. Without it a breakpoint that fired and was resumed looks exactly
101
+ * like one whose hook was never installed — mark written, nothing paused —
102
+ * and the diagnosis blamed the two that had just worked.
103
+ */
104
+ firedThisDocument = new Set();
105
+ /** Resolvers waiting on the next pause, from `await`. */
106
+ waiting = [];
107
+ subscribed = false;
108
+ constructor(transport, preloads,
109
+ /**
110
+ * Whether the devtools extension is loaded and will do the arming.
111
+ *
112
+ * Not a preference — a division of labour. The extension rewrites the mark
113
+ * call in the script source, so its `debugger;` lands inside Speed Kit's
114
+ * own frame; the wrapper below can only stop beside it. Installing both
115
+ * gets two pauses for one breakpoint and reports the second one's frame
116
+ * for the first.
117
+ */
118
+ extensionArms = () => false,
119
+ /**
120
+ * Told when a release has run, so the panel hears to drop its switches.
121
+ * Clearing the page alone does not last: the panel writes every lit
122
+ * switch back into sessionStorage on the next page start.
123
+ */
124
+ onRelease = () => undefined) {
125
+ this.transport = transport;
126
+ this.preloads = preloads;
127
+ this.extensionArms = extensionArms;
128
+ this.onRelease = onRelease;
129
+ }
130
+ get isArmed() {
131
+ return this.armed.length > 0;
132
+ }
133
+ /** What is armed, for the report the devtools panel mirrors. */
134
+ get armedBreakpoints() {
135
+ return [...this.armed];
136
+ }
137
+ async arm(bps, then = "none") {
138
+ const wanted = bps?.length ? bps : BREAKPOINTS.map(({ bp }) => bp);
139
+ const unknown = wanted.filter((bp) => !BREAKPOINTS.some((breakpoint) => breakpoint.bp === bp));
140
+ if (unknown.length > 0) {
141
+ throw new NoSuchBreakpointError(`no breakpoint ${unknown.join(", ")} — this run has 1 to 4`, BREAKPOINTS.map(({ bp }) => bp));
142
+ }
143
+ // What this run had armed and is now giving up. Computed before `armed` is
144
+ // replaced, because it is the difference between the two that has to be
145
+ // unwritten from the page.
146
+ const release = this.armed.filter((bp) => !wanted.includes(bp));
147
+ this.subscribe();
148
+ // Held from here until disarm. This is what makes the injected `debugger;`
149
+ // trap at all: without an attached debugger the statement is a no-op.
150
+ await this.transport.send("Debugger.enable");
151
+ // A previous disarm skipped all pauses on its way out; undone explicitly
152
+ // rather than trusting `Debugger.disable` to have reset it.
153
+ await this.transport.send("Debugger.setSkipAllPauses", { skip: false });
154
+ await this.transport.send("Runtime.enable");
155
+ this.attached = true;
156
+ this.armed = [...new Set(wanted)].sort();
157
+ this.skipReason = null;
158
+ await this.preloads.reserve("debug", armingScript(this.armed, this.extensionArms(), release));
159
+ if (then === "reload") {
160
+ // A navigation to the same url, not a reload. Speed Kit's worker treats a
161
+ // reload as the user asking for fresh content: it revalidates its Bloom
162
+ // filter on a soft one and skips its cache on a hard one
163
+ // (`NavigateHandler`, `SWCachingService` in speed-kit2). A reload is
164
+ // therefore not the accelerated load the breakpoints are for, and an
165
+ // arm that reloaded kept landing on an origin-served document with
166
+ // nothing to pause on.
167
+ const url = this.transport.url?.();
168
+ if (url) {
169
+ await this.transport.send("Page.navigate", { url }, NAVIGATE_ANSWER_MS);
170
+ }
171
+ else {
172
+ await this.transport.send("Page.reload");
173
+ }
174
+ }
175
+ return this.status();
176
+ }
177
+ async disarm() {
178
+ // The pause first. Releasing the preload switches off the copy running in
179
+ // the page through an awaited evaluation, and a paused V8 never settles
180
+ // one: the release sat out its full 5s timeout, the client gave up at the
181
+ // same moment, and only then did the resume below run. Skipping pauses
182
+ // before resuming keeps the page from trapping on the next armed mark
183
+ // before the flags below are cleared.
184
+ if (this.attached) {
185
+ await this.transport
186
+ .send("Debugger.setSkipAllPauses", { skip: true })
187
+ .catch(() => undefined);
188
+ // Sent whether or not this session saw the pause: V8 has one pause per
189
+ // page, whoever caused it, and a stale `paused` must not be the reason
190
+ // a page is left stopped.
191
+ await this.transport.send("Debugger.resume").catch(() => undefined);
192
+ }
193
+ this.paused = false;
194
+ this.pausedFrameId = null;
195
+ this.lastPause = null;
196
+ // Then the live document. Releasing the preload only stops the *next* load
197
+ // being armed: with the extension tier the arming lives in the page's
198
+ // sessionStorage, which survives reloads and same-origin navigations for
199
+ // the life of the tab, so without this the injector goes on re-arming
200
+ // every load for ever and the server's `armed: []` is simply wrong.
201
+ //
202
+ // Emptied before the release, not after: releasing is what reports the
203
+ // armed set to the panel, and a report still naming the old set leaves
204
+ // its switches lit. The panel writes a lit switch back into sessionStorage
205
+ // on every page start, so the next load would arm again behind a status
206
+ // that says nothing is armed. Nothing reports after this one.
207
+ const had = this.armed;
208
+ this.armed = [];
209
+ await this.clearLiveDocument(had);
210
+ await this.preloads.release("debug");
211
+ if (this.attached) {
212
+ await this.transport.send("Debugger.disable").catch(() => undefined);
213
+ this.attached = false;
214
+ }
215
+ return {
216
+ paused: false,
217
+ did: had.length
218
+ ? `disarmed BP${had.join(", BP")} and removed the hooks`
219
+ : "nothing was armed",
220
+ };
221
+ }
222
+ /**
223
+ * Get the page running, whoever stopped it, and keep it running.
224
+ *
225
+ * A disarm undoes what this run did; a release undoes what anyone did —
226
+ * a switch a developer left lit in the devtools panel pauses every load
227
+ * with DevTools open, and an agent that cannot evaluate anything cannot
228
+ * find that out. So: this run's arming comes out, every panel switch comes
229
+ * out of the page, a pause held elsewhere is resumed, and the panel is told
230
+ * to drop its switches, which is the part that makes it last.
231
+ *
232
+ * A breakpoint set in DevTools' Sources panel is beyond it. It lives in that
233
+ * DevTools session, and V8 keeps breakpoints per session. The result says so
234
+ * when the page stopped again.
235
+ */
236
+ async release() {
237
+ const disarmed = this.armed;
238
+ if (disarmed.length > 0 || this.attached) {
239
+ await this.disarm();
240
+ }
241
+ // First, and synchronous: a plain evaluation still runs on a paused page,
242
+ // so the switches are out before the page moves on to hit one.
243
+ const cleared = await this.clearPanelFlags();
244
+ let resumedForeignPause = false;
245
+ if ((await this.threadState()) === "paused") {
246
+ // One pause per page, and any session may end it. Attached just long
247
+ // enough to say so; holding `Debugger.enable` any longer would make every
248
+ // `debugger;` in the page trap for this session too.
249
+ await this.transport.send("Debugger.enable").catch(() => undefined);
250
+ resumedForeignPause = await this.transport
251
+ .send("Debugger.resume")
252
+ .then(() => true)
253
+ .catch(() => false);
254
+ await this.transport.send("Debugger.disable").catch(() => undefined);
255
+ await new Promise((resolve) => setTimeout(resolve, SETTLE_AFTER_RESUME_MS).unref());
256
+ }
257
+ this.paused = false;
258
+ this.pausedFrameId = null;
259
+ this.lastPause = null;
260
+ this.onRelease();
261
+ const thread = await this.threadState();
262
+ const did = [
263
+ disarmed.length ? `disarmed BP${disarmed.join(", BP")}` : null,
264
+ cleared.length ? `cleared ${cleared.join(", ")} from the page` : null,
265
+ resumedForeignPause ? "resumed a pause held elsewhere" : null,
266
+ ].filter(Boolean);
267
+ return {
268
+ disarmed,
269
+ cleared,
270
+ resumedForeignPause,
271
+ thread,
272
+ did: thread === "paused"
273
+ ? `${did.length ? `${did.join("; ")} — but ` : ""}the page stopped again. That is a breakpoint in DevTools' Sources panel, or "pause on exceptions": both belong to that DevTools session, which this run cannot reach. Deactivate breakpoints there (Ctrl+F8).`
274
+ : did.length
275
+ ? `${did.join("; ")} — the page is ${thread ?? "not readable"}`
276
+ : `nothing was holding the page — it is ${thread ?? "not readable"}`,
277
+ };
278
+ }
279
+ async status() {
280
+ const { marks, prerendered, navigationType } = await this.probeDocument();
281
+ const [thread, pageArmed] = await Promise.all([
282
+ this.threadState(),
283
+ this.readPanelFlags(),
284
+ ]);
285
+ const pausedHere = this.attached && this.paused;
286
+ const paused = pausedHere || thread === "paused"
287
+ ? true
288
+ : thread === "running" || this.attached
289
+ ? false
290
+ : // Detached and not measured: a pause held elsewhere would not
291
+ // show, and `false` would claim to know.
292
+ null;
293
+ return {
294
+ attached: this.attached,
295
+ armed: this.armed,
296
+ paused,
297
+ // Only the live pause. The last one stays for `eval`'s frame, but
298
+ // reported after a resume it reads exactly like a page still stopped.
299
+ pause: pausedHere ? this.lastPause : null,
300
+ thread,
301
+ pausedBy: pausedHere ? "this-run" : paused ? "elsewhere" : null,
302
+ pageArmed,
303
+ prerendered,
304
+ navigationType: navigationType ?? null,
305
+ changeDetectionSkipped: this.skipReason,
306
+ breakpoints: BREAKPOINTS.map(({ bp, mark, description, ssrOnly }) => ({
307
+ bp,
308
+ mark,
309
+ description,
310
+ armed: this.armed.includes(bp),
311
+ seen: marks.includes(mark),
312
+ fired: this.firedThisDocument.has(bp),
313
+ ssrOnly: Boolean(ssrOnly),
314
+ })),
315
+ };
316
+ }
317
+ /**
318
+ * Wait for the next pause, and answer either way.
319
+ *
320
+ * A bare timeout is the wrong answer here. "Armed but silent" has three
321
+ * causes that mean opposite things — legitimately skipped, injection failed,
322
+ * never reached — and an agent handed only `timedOut` will pick the wrong
323
+ * one. So a timeout comes back with the mark census and a reading of it.
324
+ */
325
+ async awaitPause(timeoutMs = DEFAULT_AWAIT_MS) {
326
+ if (!this.isArmed) {
327
+ throw new NotArmedError('nothing is armed on this run — call `arm` first, with `then: "reload"` to catch the load you are asking about');
328
+ }
329
+ const startedAt = Date.now();
330
+ if (this.paused && this.lastPause) {
331
+ return {
332
+ ...(await this.status()),
333
+ fired: true,
334
+ timedOut: false,
335
+ waitedMs: 0,
336
+ };
337
+ }
338
+ const pause = await new Promise((resolve) => {
339
+ const timer = setTimeout(() => {
340
+ this.waiting = this.waiting.filter((one) => one !== settle);
341
+ resolve(null);
342
+ }, timeoutMs);
343
+ timer.unref();
344
+ const settle = (fired) => {
345
+ clearTimeout(timer);
346
+ resolve(fired);
347
+ };
348
+ this.waiting.push(settle);
349
+ });
350
+ const status = await this.status();
351
+ return {
352
+ ...status,
353
+ fired: Boolean(pause),
354
+ timedOut: !pause,
355
+ waitedMs: Date.now() - startedAt,
356
+ ...(pause ? {} : { diagnosis: diagnose(status) }),
357
+ };
358
+ }
359
+ async resume() {
360
+ this.requirePaused();
361
+ await this.transport.send("Debugger.resume");
362
+ this.paused = false;
363
+ return { paused: false, did: "resumed" };
364
+ }
365
+ async step(kind) {
366
+ this.requirePaused();
367
+ const method = kind === "over"
368
+ ? "Debugger.stepOver"
369
+ : kind === "into"
370
+ ? "Debugger.stepInto"
371
+ : "Debugger.stepOut";
372
+ await this.transport.send(method);
373
+ return { paused: true, did: `stepped ${kind}` };
374
+ }
375
+ /**
376
+ * Evaluate, on the paused frame when there is one.
377
+ *
378
+ * `Runtime.evaluate` against a paused page answers about globals and cannot
379
+ * see a single local, which is most of the reason to have paused. The
380
+ * call-frame path is why `tools/sk-eval.mjs` exists at all — chrome-devtools
381
+ * MCP's own evaluation fails here with "Promise was collected".
382
+ */
383
+ async evaluate(expression) {
384
+ const frame = this.paused ? this.lastPause : null;
385
+ const callFrameId = this.pausedFrameId;
386
+ if (frame && callFrameId) {
387
+ if (usesAwait(expression)) {
388
+ // Not a limitation to work around: while the inspector is paused the
389
+ // microtask queue is frozen, so an awaited promise can never settle and
390
+ // wrapping this would hang instead of failing. Resuming first is the
391
+ // only thing that can work, and saying so beats a SyntaxError.
392
+ return {
393
+ onCallFrame: true,
394
+ value: null,
395
+ exception: "`await` cannot be evaluated on a paused frame — the page is stopped, so nothing will settle. `resume` first, or read the promise itself.",
396
+ };
397
+ }
398
+ const result = await this.transport.send("Debugger.evaluateOnCallFrame", { callFrameId, expression, returnByValue: true });
399
+ return shapeEval(result, true);
400
+ }
401
+ const result = await this.transport.send("Runtime.evaluate", {
402
+ // A classic script has no top-level await, so `await x` comes back as
403
+ // a SyntaxError rather than a slow answer — which reads as a broken
404
+ // tool rather than as "wrap it yourself". REPL mode allows it, as in
405
+ // the devtools console, and still takes statements: a probe file that
406
+ // ends with `;` broke the async wrapper this used before.
407
+ expression,
408
+ replMode: usesAwait(expression),
409
+ returnByValue: true,
410
+ awaitPromise: true,
411
+ });
412
+ return shapeEval(result, false);
413
+ }
414
+ /** The run is over, or its page has gone. */
415
+ dispose() {
416
+ this.armed = [];
417
+ this.attached = false;
418
+ this.paused = false;
419
+ this.waiting = [];
420
+ this.firedThisDocument.clear();
421
+ }
422
+ pausedFrameId = null;
423
+ requirePaused() {
424
+ if (!this.paused) {
425
+ throw new NotPausedError("the page is not paused — `await` first, and check `status` for whether anything is armed");
426
+ }
427
+ }
428
+ /**
429
+ * Which of the four marks this document has written.
430
+ *
431
+ * The measurement behind {@link diagnose}. Read per call rather than tracked,
432
+ * because a navigation resets it and a stale census is worse than none.
433
+ */
434
+ /**
435
+ * Unwrite the arming from the document that is loaded now.
436
+ *
437
+ * Both tiers leak without it and only one of them visibly. The extension's
438
+ * flags keep arming every subsequent load; the fallback's
439
+ * `__SK_DEBUG_ARMED` is masked by `Debugger.disable`, because a `debugger;`
440
+ * with nothing attached is a no-op — until someone opens DevTools, at which
441
+ * point the page starts trapping again with nothing armed.
442
+ *
443
+ * Best effort by design: a disarm must not fail because the page went away,
444
+ * and a page that has gone has no flags left to clear anyway.
445
+ */
446
+ async clearLiveDocument(armed) {
447
+ if (!this.transport.pageAvailable || armed.length === 0) {
448
+ return;
449
+ }
450
+ const keys = BREAKPOINTS.filter(({ bp }) => armed.includes(bp)).map(({ flagKey }) => flagKey);
451
+ await this.transport
452
+ .send("Runtime.evaluate", {
453
+ expression: `(function () {
454
+ try {
455
+ ${JSON.stringify(keys)}.forEach(function (key) { sessionStorage.removeItem(key); });
456
+ } catch (ignored) {}
457
+ try { window.__SK_DEBUG_ARMED = {}; } catch (ignored) {}
458
+ })()`,
459
+ returnByValue: true,
460
+ })
461
+ .catch(() => undefined);
462
+ }
463
+ async threadState() {
464
+ if (!this.transport.threadState || !this.transport.pageAvailable) {
465
+ return null;
466
+ }
467
+ return this.transport.threadState().catch(() => null);
468
+ }
469
+ /** The panel switches set in the page, read without waiting on the page. */
470
+ async readPanelFlags() {
471
+ return this.panelFlags(false);
472
+ }
473
+ /** Every panel switch out of the page, returning the ones that were set. */
474
+ async clearPanelFlags() {
475
+ return (await this.panelFlags(true)) ?? [];
476
+ }
477
+ /**
478
+ * Plain `Runtime.evaluate`, never awaited: it is the one kind of evaluation
479
+ * a paused page still answers, and a paused page is when this is needed.
480
+ */
481
+ async panelFlags(clear) {
482
+ if (!this.transport.pageAvailable) {
483
+ return null;
484
+ }
485
+ try {
486
+ const result = await this.transport.send("Runtime.evaluate", {
487
+ expression: `(function () {
488
+ var set = [];
489
+ try {
490
+ for (var i = sessionStorage.length - 1; i >= 0; i--) {
491
+ var key = sessionStorage.key(i);
492
+ if (key && key.indexOf(${JSON.stringify(PANEL_FLAG_PREFIX)}) === 0 && sessionStorage.getItem(key) === "on") {
493
+ set.push(key);
494
+ ${clear ? "sessionStorage.removeItem(key);" : ""}
495
+ }
496
+ }
497
+ } catch (ignored) {
498
+ return null;
499
+ }
500
+ ${clear ? "try { window.__SK_DEBUG_ARMED = {}; } catch (ignored) {}" : ""}
501
+ return JSON.stringify(set.sort());
502
+ })()`,
503
+ returnByValue: true,
504
+ });
505
+ const value = result.result?.value;
506
+ return typeof value === "string" ? JSON.parse(value) : null;
507
+ }
508
+ catch {
509
+ return null;
510
+ }
511
+ }
512
+ async probeDocument() {
513
+ if (!this.transport.pageAvailable) {
514
+ return { marks: [], prerendered: null, navigationType: null };
515
+ }
516
+ try {
517
+ const result = await this.transport.send("Runtime.evaluate", {
518
+ // Both in one read: they are two halves of the same question, and
519
+ // taking them separately would let a navigation land between them.
520
+ expression: `JSON.stringify({
521
+ marks: (performance.getEntriesByType('mark') || []).map(function (mark) { return mark.name; }),
522
+ navigationType: ((performance.getEntriesByType('navigation') || [])[0] || {}).type || null,
523
+ prerendered: Boolean(
524
+ (document.documentElement.className || '').indexOf('speed-kit-pre-rendered') >= 0 ||
525
+ document.getElementById('sk-shadow-app-root')
526
+ )
527
+ })`,
528
+ returnByValue: true,
529
+ });
530
+ const value = result.result?.value;
531
+ return typeof value === "string"
532
+ ? JSON.parse(value)
533
+ : { marks: [], prerendered: null, navigationType: null };
534
+ }
535
+ catch {
536
+ return { marks: [], prerendered: null, navigationType: null };
537
+ }
538
+ }
539
+ subscribe() {
540
+ if (this.subscribed) {
541
+ return;
542
+ }
543
+ this.subscribed = true;
544
+ this.transport.onCdp("Debugger.paused", (payload) => {
545
+ void this.onPaused(payload);
546
+ });
547
+ this.transport.onCdp("Debugger.resumed", () => {
548
+ this.paused = false;
549
+ this.pausedFrameId = null;
550
+ });
551
+ // A new document is a new set of facts: what fired, and why a comparison
552
+ // was skipped, are both about the load that has just been replaced.
553
+ this.transport.onCdp("Page.frameNavigated", (payload) => {
554
+ const frame = payload.frame;
555
+ if (frame && !frame.parentId) {
556
+ this.firedThisDocument.clear();
557
+ this.skipReason = null;
558
+ }
559
+ });
560
+ this.transport.onCdp("Runtime.consoleAPICalled", (payload) => {
561
+ const text = payload.args?.[0]?.value;
562
+ if (typeof text === "string" && text.startsWith(SKIP_PREFIX)) {
563
+ this.skipReason = text.slice(SKIP_PREFIX.length);
564
+ }
565
+ });
566
+ }
567
+ async onPaused(payload) {
568
+ this.paused = true;
569
+ const top = payload.callFrames?.[0];
570
+ this.pausedFrameId = top?.callFrameId ?? null;
571
+ const { url, state } = await this.readPausedState(top?.callFrameId);
572
+ const pause = {
573
+ bp: "unknown",
574
+ reason: payload.reason,
575
+ // Not `top.url`: that is the url of the frame's *script*, and the
576
+ // wrapper's `debugger;` runs in a script injected without one, so CDP
577
+ // reports "" there for every pause this run arms.
578
+ url,
579
+ scriptUrl: top?.url || null,
580
+ location: top?.location,
581
+ state,
582
+ at: new Date().toISOString(),
583
+ };
584
+ pause.bp = pause.state.lastBp ?? "unknown";
585
+ const number = Number(pause.bp.replace("BP", ""));
586
+ if (Number.isInteger(number)) {
587
+ this.firedThisDocument.add(number);
588
+ }
589
+ this.lastPause = pause;
590
+ const waiting = this.waiting;
591
+ this.waiting = [];
592
+ for (const settle of waiting) {
593
+ settle(pause);
594
+ }
595
+ }
596
+ /** Read on the paused frame, because that is the only place the locals are. */
597
+ async readPausedState(callFrameId) {
598
+ const expression = `JSON.stringify({
599
+ href: location.href,
600
+ htmlClass: document.documentElement.className,
601
+ skGroup: (window.SpeedKit && window.SpeedKit.group) || null,
602
+ marks: (performance.getEntriesByType('mark') || []).map(function (mark) {
603
+ return { name: mark.name, t: Math.round(mark.startTime) };
604
+ }),
605
+ lastBp: window.__SK_DEBUG_LAST || null
606
+ })`;
607
+ try {
608
+ const result = callFrameId
609
+ ? await this.transport.send("Debugger.evaluateOnCallFrame", { callFrameId, expression, returnByValue: true })
610
+ : await this.transport.send("Runtime.evaluate", {
611
+ expression,
612
+ returnByValue: true,
613
+ });
614
+ const value = result.result?.value;
615
+ if (typeof value !== "string") {
616
+ return { url: null, state: emptyState() };
617
+ }
618
+ const { href, ...state } = JSON.parse(value);
619
+ return { url: href || null, state };
620
+ }
621
+ catch {
622
+ return { url: null, state: emptyState() };
623
+ }
624
+ }
625
+ }
626
+ /**
627
+ * Whether the expression uses `await` where a classic script cannot.
628
+ *
629
+ * Deliberately crude: a false positive costs an async wrapper around an
630
+ * expression that did not need one, which changes nothing, while a false
631
+ * negative is the SyntaxError this exists to prevent.
632
+ */
633
+ function usesAwait(expression) {
634
+ return /\bawait\b/.test(expression);
635
+ }
636
+ function emptyState() {
637
+ return { htmlClass: null, skGroup: null, marks: [], lastBp: null };
638
+ }
639
+ function shapeEval(result, onCallFrame) {
640
+ if (result.exceptionDetails) {
641
+ return {
642
+ onCallFrame,
643
+ value: null,
644
+ // Verbatim. An expression that throws is usually the answer, not an
645
+ // error: rewording it costs the caller the thing it asked for.
646
+ exception: result.exceptionDetails.exception?.description ??
647
+ result.exceptionDetails.text,
648
+ };
649
+ }
650
+ return { onCallFrame, value: result.result?.value ?? null };
651
+ }
652
+ /**
653
+ * What a silent breakpoint most likely means.
654
+ *
655
+ * The first version read "mark written, nothing paused" as a missing hook and
656
+ * was wrong in the most misleading way available: a breakpoint that had already
657
+ * paused and been resumed on that same load leaves exactly that trace, so the
658
+ * diagnosis blamed the two breakpoints that had just worked and said nothing
659
+ * about the two actually being waited on. A census has to know what has already
660
+ * happened before it can say what failed to.
661
+ *
662
+ * Ordered by how specific the reading is, because several can be true at once
663
+ * and only the sharpest is worth saying.
664
+ */
665
+ function diagnose(status) {
666
+ const armed = status.breakpoints.filter((breakpoint) => breakpoint.armed);
667
+ const fired = armed.filter((breakpoint) => breakpoint.fired);
668
+ const pending = armed.filter((breakpoint) => !breakpoint.fired);
669
+ const already = fired.length > 0 ? ` ${names(fired)} already paused on this load.` : "";
670
+ if (status.changeDetectionSkipped && pending.some((one) => one.bp === 3)) {
671
+ return `the SSR comparison did not run on this load (${status.changeDetectionSkipped}), so BP3 has nothing to pause on. That is an expected outcome, not a broken hook.${already}`;
672
+ }
673
+ // The one the caller can act on: the mark went past without stopping, and
674
+ // this breakpoint has not already had its turn.
675
+ const missing = pending.filter((breakpoint) => breakpoint.seen);
676
+ if (missing.length > 0) {
677
+ return `${names(missing)} — the mark was written and nothing paused, so the hooks are not in this document. Re-arm with \`then: "reload"\`: they only go in at document start.${already}`;
678
+ }
679
+ // The case that was silently lumped in with a broken arm. A document that was
680
+ // not pre-rendered has no SSR pass, so its anchors are never emitted and no
681
+ // amount of re-arming will change that.
682
+ const blocked = pending.filter((breakpoint) => breakpoint.ssrOnly && status.prerendered === false);
683
+ if (blocked.length > 0 && blocked.length === pending.length) {
684
+ return `this document was not pre-rendered — no \`speed-kit-pre-rendered\` class and no shadow root — so ${names(blocked)} cannot fire on this load whatever you do. Load a url the SSR pass covers.${already}`;
685
+ }
686
+ if (status.breakpoints.every((breakpoint) => !breakpoint.seen)) {
687
+ if (status.navigationType === "reload") {
688
+ return "no Speed Kit marks at all, and this document was a reload — Speed Kit's worker revalidates on a soft reload and skips its cache on a hard one, so a reload is not an accelerated load. Navigate to the url instead (`sk onboarding browser navigate`, or `sk onboarding debug arm`, whose default `--then reload` navigates).";
689
+ }
690
+ return "no Speed Kit marks at all in this document — the page was not accelerated on this load, so no breakpoint could be reached. `sk onboarding response` says why.";
691
+ }
692
+ if (pending.length === 0 && fired.length > 0) {
693
+ return `${names(fired)} paused and were resumed on this load, and nothing else is armed. Navigate to catch them again.`;
694
+ }
695
+ return `${names(pending)} — the marks have not been written on this load yet. Navigate, or wait longer.${already}`;
696
+ }
697
+ function names(breakpoints) {
698
+ return breakpoints.map((one) => `BP${one.bp}`).join(", ");
699
+ }
700
+ /**
701
+ * Arm the breakpoints, by whichever tier this run has.
702
+ *
703
+ * A body rather than a whole script: {@link PreloadRegistry.reserve} wraps it,
704
+ * so it is contained and listed like anything else injected into the page.
705
+ *
706
+ * **With the devtools extension present** this only sets the extension's own
707
+ * sessionStorage flags and supplies its pause hook. Both sides can arm and only
708
+ * one can arm in time — the panel writes flags through `inspectedWindow.eval`,
709
+ * which cannot run before the page's scripts, and BP1 is emitted early enough
710
+ * to lose that race routinely. A preload runs first by construction, so the CLI
711
+ * is the better writer while the extension stays the better arm.
712
+ *
713
+ * **Without it**, the `performance.mark` wrapper is the fallback tier, and it
714
+ * keeps an install guard of its own on top of the envelope's so the wrapper
715
+ * goes in exactly once per document however often the set is re-armed.
716
+ */
717
+ function armingScript(armed, extensionArms, release) {
718
+ const marks = Object.fromEntries(BREAKPOINTS.filter(({ bp }) => armed.includes(bp)).map(({ bp, mark }) => [
719
+ mark,
720
+ bp,
721
+ ]));
722
+ // Only the ones this run owns: those it is arming now, and those it armed
723
+ // before and no longer wants. A flag it never set belongs to whoever did —
724
+ // the panel, and therefore a person — and clearing that would be the silent
725
+ // state change every guardrail here exists to prevent.
726
+ const flags = BREAKPOINTS.filter(({ bp }) => armed.includes(bp) || release.includes(bp))
727
+ .map(({ bp, flagKey }) => {
728
+ const on = armed.includes(bp);
729
+ return ` try { sessionStorage.${on ? `setItem(${JSON.stringify(flagKey)}, "on")` : `removeItem(${JSON.stringify(flagKey)})`}; } catch (ignored) {}`;
730
+ })
731
+ .join("\n");
732
+ if (extensionArms) {
733
+ return `
734
+ // The devtools extension's own flags. Its injector arms a breakpoint when the
735
+ // key holds "on" and does not care who wrote it, which is the whole contract
736
+ // — see \`lib/breakpoint-flags.ts\` there.
737
+ ${flags}
738
+
739
+ // Its rewrite brackets the \`debugger;\` with a guarded call to this hook, so
740
+ // supplying one is how the CLI learns *which* breakpoint stopped the page
741
+ // without wrapping anything itself. Chained rather than replaced: the panel
742
+ // installs its own when it is open, and clobbering it would put out the pill
743
+ // that tells the human the same thing.
744
+ var previousHook = window.__skDevtoolsBpPause;
745
+ window.__skDevtoolsBpPause = function (id, active) {
746
+ try {
747
+ if (active) window.__SK_DEBUG_LAST = "BP" + String(id).replace("bp", "");
748
+ } catch (ignored) {
749
+ // Attribution is best effort; the pause itself is not.
750
+ }
751
+ if (typeof previousHook === "function") {
752
+ try { return previousHook.apply(this, arguments); } catch (ignored) {}
753
+ }
754
+ };`;
755
+ }
756
+ return `
757
+ // Cleared as well as set, so a re-arm that drops a breakpoint does not leave
758
+ // the extension arming it from a stale flag.
759
+ ${flags}
760
+
761
+ // Set before the install guard, so re-arming a different set reaches a
762
+ // document that already has the wrapper — the wrapper re-reads this on every
763
+ // call rather than closing over the set it was built with.
764
+ window.__SK_DEBUG_ARMED = ${JSON.stringify(marks)};
765
+ if (!window.__SK_DEBUG_INSTALLED) {
766
+ window.__SK_DEBUG_INSTALLED = true;
767
+ window.__SK_DEBUG_LAST = null;
768
+
769
+ if (typeof performance !== "undefined" && performance.mark) {
770
+ var original = performance.mark;
771
+ performance.mark = function (name) {
772
+ try {
773
+ var armed = window.__SK_DEBUG_ARMED || {};
774
+ if (Object.prototype.hasOwnProperty.call(armed, name)) {
775
+ window.__SK_DEBUG_LAST = "BP" + armed[name];
776
+ debugger;
777
+ }
778
+ } catch (ignored) {
779
+ // Never let the hook change what it is watching.
780
+ }
781
+ return original.apply(this, arguments);
782
+ };
783
+ }
784
+
785
+ // BP3 hangs off a mark Speed Kit writes only around a comparison that ran,
786
+ // so a skipped comparison leaves it armed and silent. Reported here, so that
787
+ // silence reads as the expected outcome rather than a broken hook.
788
+ document.addEventListener("speed-kit-prerender-ready", function (event) {
789
+ try {
790
+ var reason = event && event.detail && event.detail.csrChangeDetectionSkipReason;
791
+ if (!reason) return;
792
+ var marked = performance.getEntriesByName
793
+ ? performance.getEntriesByName("sk-prerender-change-detection-end").length > 0
794
+ : true;
795
+ if (!marked) console.debug("${SKIP_PREFIX}" + reason);
796
+ } catch (ignored) {
797
+ // As above.
798
+ }
799
+ });
800
+ }`;
801
+ }