@speedkit/cli 4.50.5 → 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 (406) hide show
  1. package/README.md +1369 -10
  2. package/dist/base/run-control-command.d.ts +15 -0
  3. package/dist/base/run-control-command.js +20 -0
  4. package/dist/build-info.json +6 -0
  5. package/dist/commands/diff.d.ts +6 -1
  6. package/dist/commands/diff.js +9 -3
  7. package/dist/commands/onboarding/browser/click.d.ts +75 -0
  8. package/dist/commands/onboarding/browser/click.js +19 -0
  9. package/dist/commands/onboarding/browser/emulate.d.ts +93 -0
  10. package/dist/commands/onboarding/browser/emulate.js +23 -0
  11. package/dist/commands/onboarding/browser/navigate.d.ts +67 -0
  12. package/dist/commands/onboarding/browser/navigate.js +18 -0
  13. package/dist/commands/onboarding/browser/panel.d.ts +63 -0
  14. package/dist/commands/onboarding/browser/panel.js +12 -0
  15. package/dist/commands/onboarding/browser/reinstall-sw.d.ts +63 -0
  16. package/dist/commands/onboarding/browser/reinstall-sw.js +14 -0
  17. package/dist/commands/onboarding/browser/reset.d.ts +71 -0
  18. package/dist/commands/onboarding/browser/reset.js +18 -0
  19. package/dist/commands/onboarding/browser/screenshot.d.ts +77 -0
  20. package/dist/commands/onboarding/browser/screenshot.js +19 -0
  21. package/dist/commands/onboarding/browser/state.d.ts +63 -0
  22. package/dist/commands/onboarding/browser/state.js +12 -0
  23. package/dist/commands/onboarding/browser/tabs.d.ts +58 -0
  24. package/dist/commands/onboarding/browser/tabs.js +16 -0
  25. package/dist/commands/onboarding/cache/clear.d.ts +58 -0
  26. package/dist/commands/onboarding/cache/clear.js +12 -0
  27. package/dist/commands/onboarding/cache/errors.d.ts +58 -0
  28. package/dist/commands/onboarding/cache/errors.js +12 -0
  29. package/dist/commands/onboarding/cache/evict.d.ts +62 -0
  30. package/dist/commands/onboarding/cache/evict.js +15 -0
  31. package/dist/commands/onboarding/cache/get.d.ts +85 -0
  32. package/dist/commands/onboarding/cache/get.js +17 -0
  33. package/dist/commands/onboarding/cache/list.d.ts +58 -0
  34. package/dist/commands/onboarding/cache/list.js +15 -0
  35. package/dist/commands/onboarding/cache/prewarm.d.ts +73 -0
  36. package/dist/commands/onboarding/cache/prewarm.js +20 -0
  37. package/dist/commands/onboarding/cache/refresh.d.ts +62 -0
  38. package/dist/commands/onboarding/cache/refresh.js +18 -0
  39. package/dist/commands/onboarding/cdp.d.ts +81 -0
  40. package/dist/commands/onboarding/cdp.js +18 -0
  41. package/dist/commands/onboarding/debug/arm.d.ts +77 -0
  42. package/dist/commands/onboarding/debug/arm.js +18 -0
  43. package/dist/commands/onboarding/debug/await.d.ts +71 -0
  44. package/dist/commands/onboarding/debug/await.js +18 -0
  45. package/dist/commands/onboarding/debug/disarm.d.ts +63 -0
  46. package/dist/commands/onboarding/debug/disarm.js +12 -0
  47. package/dist/commands/onboarding/debug/eval.d.ts +75 -0
  48. package/dist/commands/onboarding/debug/eval.js +16 -0
  49. package/dist/commands/onboarding/debug/release.d.ts +63 -0
  50. package/dist/commands/onboarding/debug/release.js +12 -0
  51. package/dist/commands/onboarding/debug/resume.d.ts +63 -0
  52. package/dist/commands/onboarding/debug/resume.js +12 -0
  53. package/dist/commands/onboarding/debug/status.d.ts +63 -0
  54. package/dist/commands/onboarding/debug/status.js +12 -0
  55. package/dist/commands/onboarding/debug/step.d.ts +67 -0
  56. package/dist/commands/onboarding/debug/step.js +15 -0
  57. package/dist/commands/onboarding/files/list.d.ts +58 -0
  58. package/dist/commands/onboarding/files/list.js +12 -0
  59. package/dist/commands/onboarding/files/read.d.ts +73 -0
  60. package/dist/commands/onboarding/files/read.js +16 -0
  61. package/dist/commands/onboarding/files/rebuild.d.ts +63 -0
  62. package/dist/commands/onboarding/files/rebuild.js +18 -0
  63. package/dist/commands/onboarding/files/validate.d.ts +58 -0
  64. package/dist/commands/onboarding/files/validate.js +12 -0
  65. package/dist/commands/onboarding/fouc.d.ts +77 -0
  66. package/dist/commands/onboarding/fouc.js +16 -0
  67. package/dist/commands/onboarding/inject/add.d.ts +89 -0
  68. package/dist/commands/onboarding/inject/add.js +17 -0
  69. package/dist/commands/onboarding/inject/clear.d.ts +63 -0
  70. package/dist/commands/onboarding/inject/clear.js +12 -0
  71. package/dist/commands/onboarding/inject/list.d.ts +63 -0
  72. package/dist/commands/onboarding/inject/list.js +12 -0
  73. package/dist/commands/onboarding/inject/read.d.ts +75 -0
  74. package/dist/commands/onboarding/inject/read.js +18 -0
  75. package/dist/commands/onboarding/inject/recipes.d.ts +63 -0
  76. package/dist/commands/onboarding/inject/recipes.js +12 -0
  77. package/dist/commands/onboarding/inject/remove.d.ts +67 -0
  78. package/dist/commands/onboarding/inject/remove.js +15 -0
  79. package/dist/commands/onboarding/list.d.ts +13 -0
  80. package/dist/commands/onboarding/list.js +12 -0
  81. package/dist/commands/onboarding/logs.d.ts +41 -0
  82. package/dist/commands/onboarding/logs.js +256 -0
  83. package/dist/commands/onboarding/navwalk.d.ts +95 -0
  84. package/dist/commands/onboarding/navwalk.js +19 -0
  85. package/dist/commands/onboarding/response.d.ts +67 -0
  86. package/dist/commands/onboarding/response.js +18 -0
  87. package/dist/commands/onboarding/rum/beacons.d.ts +75 -0
  88. package/dist/commands/onboarding/rum/beacons.js +16 -0
  89. package/dist/commands/onboarding/rum/get.d.ts +77 -0
  90. package/dist/commands/onboarding/rum/get.js +18 -0
  91. package/dist/commands/onboarding/rum/key.d.ts +67 -0
  92. package/dist/commands/onboarding/rum/key.js +13 -0
  93. package/dist/commands/onboarding/rum/previous.d.ts +63 -0
  94. package/dist/commands/onboarding/rum/previous.js +12 -0
  95. package/dist/commands/onboarding/status.d.ts +13 -0
  96. package/dist/commands/onboarding/status.js +17 -0
  97. package/dist/commands/onboarding/todo.d.ts +58 -0
  98. package/dist/commands/onboarding/todo.js +12 -0
  99. package/dist/commands/onboarding/viewport.d.ts +101 -0
  100. package/dist/commands/onboarding/viewport.js +18 -0
  101. package/dist/commands/onboarding/watch.d.ts +93 -0
  102. package/dist/commands/onboarding/watch.js +16 -0
  103. package/dist/commands/onboarding.d.ts +26 -0
  104. package/dist/commands/onboarding.js +220 -3
  105. package/dist/commands/origin-request.d.ts +4 -0
  106. package/dist/commands/origin-request.js +4 -0
  107. package/dist/commands/spec/onboarding.spec.d.ts +1 -0
  108. package/dist/commands/spec/onboarding.spec.js +127 -0
  109. package/dist/services/cli/build-info.d.ts +33 -0
  110. package/dist/services/cli/build-info.js +63 -0
  111. package/dist/services/cli/cli-environment-factory.d.ts +3 -0
  112. package/dist/services/cli/cli-environment-factory.js +1 -0
  113. package/dist/services/cli/cli-service-build-context.d.ts +3 -0
  114. package/dist/services/cli/cli-service-factory.js +1 -1
  115. package/dist/services/cli/cli-service-model.d.ts +29 -10
  116. package/dist/services/cli/cli-service.d.ts +60 -11
  117. package/dist/services/cli/cli-service.js +196 -32
  118. package/dist/services/cli/index.d.ts +2 -0
  119. package/dist/services/cli/index.js +2 -0
  120. package/dist/services/cli/sink.d.ts +47 -0
  121. package/dist/services/cli/sink.js +31 -0
  122. package/dist/services/cli/spec/build-identity.spec.d.ts +1 -0
  123. package/dist/services/cli/spec/build-identity.spec.js +85 -0
  124. package/dist/services/cli/spec/build-info.spec.d.ts +1 -0
  125. package/dist/services/cli/spec/build-info.spec.js +10 -0
  126. package/dist/services/cli/spec/cli-service-log.spec.d.ts +1 -0
  127. package/dist/services/cli/spec/cli-service-log.spec.js +133 -0
  128. package/dist/services/cli/spec/cli-service.spec.js +113 -50
  129. package/dist/services/cli/spec/memory-cli.d.ts +9 -0
  130. package/dist/services/cli/spec/memory-cli.js +9 -0
  131. package/dist/services/diff/config-at-ref.d.ts +20 -0
  132. package/dist/services/diff/config-at-ref.js +33 -0
  133. package/dist/services/diff/diff-service-build-context.d.ts +8 -0
  134. package/dist/services/diff/diff-service-build-context.js +40 -1
  135. package/dist/services/diff/diff-service-factory.d.ts +2 -0
  136. package/dist/services/diff/diff-service-factory.js +48 -20
  137. package/dist/services/diff/diff-service.d.ts +11 -0
  138. package/dist/services/diff/diff-service.js +37 -11
  139. package/dist/services/diff/page-source.d.ts +12 -0
  140. package/dist/services/diff/page-source.js +16 -11
  141. package/dist/services/diff/sinks/tool-diff-sink.d.ts +3 -2
  142. package/dist/services/diff/sinks/tool-diff-sink.js +3 -2
  143. package/dist/services/diff/spec/config-at-ref.spec.d.ts +1 -0
  144. package/dist/services/diff/spec/config-at-ref.spec.js +46 -0
  145. package/dist/services/diff/spec/diff-service-build-context.spec.js +19 -0
  146. package/dist/services/diff/spec/diff-service.spec.js +95 -0
  147. package/dist/services/git/git-repository.d.ts +2 -0
  148. package/dist/services/git/git-repository.js +6 -0
  149. package/dist/services/integration-api/customer-config-flags.js +1 -0
  150. package/dist/services/onboarding/browser/baqend-response.d.ts +17 -1
  151. package/dist/services/onboarding/browser/baqend-response.js +23 -0
  152. package/dist/services/onboarding/browser/console-log.d.ts +9 -0
  153. package/dist/services/onboarding/browser/console-log.js +27 -0
  154. package/dist/services/onboarding/browser/executable/executable-validator.js +4 -2
  155. package/dist/services/onboarding/browser/extension/extension-bridge.js +5 -3
  156. package/dist/services/onboarding/browser/extension/extension-downloader.js +17 -8
  157. package/dist/services/onboarding/browser/extension/extension-validator.js +9 -4
  158. package/dist/services/onboarding/control/body-inspect.d.ts +24 -0
  159. package/dist/services/onboarding/control/body-inspect.js +106 -0
  160. package/dist/services/onboarding/control/browser-session.d.ts +521 -0
  161. package/dist/services/onboarding/control/browser-session.js +1273 -0
  162. package/dist/services/onboarding/control/config-validation.d.ts +17 -0
  163. package/dist/services/onboarding/control/config-validation.js +46 -0
  164. package/dist/services/onboarding/control/control-protocol.d.ts +1390 -0
  165. package/dist/services/onboarding/control/control-protocol.js +69 -0
  166. package/dist/services/onboarding/control/control-server.d.ts +284 -0
  167. package/dist/services/onboarding/control/control-server.js +1609 -0
  168. package/dist/services/onboarding/control/debug-session.d.ts +190 -0
  169. package/dist/services/onboarding/control/debug-session.js +801 -0
  170. package/dist/services/onboarding/control/fouc.d.ts +23 -0
  171. package/dist/services/onboarding/control/fouc.js +151 -0
  172. package/dist/services/onboarding/control/index.d.ts +4 -0
  173. package/dist/services/onboarding/control/index.js +4 -0
  174. package/dist/services/onboarding/control/navwalk.d.ts +65 -0
  175. package/dist/services/onboarding/control/navwalk.js +248 -0
  176. package/dist/services/onboarding/control/preload-registry.d.ts +150 -0
  177. package/dist/services/onboarding/control/preload-registry.js +829 -0
  178. package/dist/services/onboarding/control/response-explainer.d.ts +24 -0
  179. package/dist/services/onboarding/control/response-explainer.js +257 -0
  180. package/dist/services/onboarding/control/rum.d.ts +8 -0
  181. package/dist/services/onboarding/control/rum.js +220 -0
  182. package/dist/services/onboarding/control/service-worker-tracker.d.ts +68 -0
  183. package/dist/services/onboarding/control/service-worker-tracker.js +119 -0
  184. package/dist/services/onboarding/control/viewport.d.ts +45 -0
  185. package/dist/services/onboarding/control/viewport.js +344 -0
  186. package/dist/services/onboarding/control/watch.d.ts +26 -0
  187. package/dist/services/onboarding/control/watch.js +149 -0
  188. package/dist/services/onboarding/dashboard/diff-against-current-page.js +3 -1
  189. package/dist/services/onboarding/dashboard/index.js +7 -2
  190. package/dist/services/onboarding/fetch-event-handler.d.ts +24 -5
  191. package/dist/services/onboarding/fetch-event-handler.js +94 -32
  192. package/dist/services/onboarding/fetch-events/speed-kit-install-js.js +11 -2
  193. package/dist/services/onboarding/fetch-events/speed-kit-rum-pi-request.d.ts +14 -0
  194. package/dist/services/onboarding/fetch-events/speed-kit-rum-pi-request.js +30 -0
  195. package/dist/services/onboarding/fetch-events/speed-kit-service-worker-js.d.ts +13 -0
  196. package/dist/services/onboarding/fetch-events/speed-kit-service-worker-js.js +28 -1
  197. package/dist/services/onboarding/file-events/file-watcher.d.ts +42 -1
  198. package/dist/services/onboarding/file-events/file-watcher.js +117 -12
  199. package/dist/services/onboarding/onboarding-model.d.ts +30 -0
  200. package/dist/services/onboarding/onboarding-model.js +10 -0
  201. package/dist/services/onboarding/onboarding-service-build-context.d.ts +4 -0
  202. package/dist/services/onboarding/onboarding-service-build-context.js +6 -0
  203. package/dist/services/onboarding/onboarding-service-factory.d.ts +17 -1
  204. package/dist/services/onboarding/onboarding-service-factory.js +131 -17
  205. package/dist/services/onboarding/onboarding-service.d.ts +40 -1
  206. package/dist/services/onboarding/onboarding-service.js +135 -22
  207. package/dist/services/onboarding/request-cache/asset-key.d.ts +61 -0
  208. package/dist/services/onboarding/request-cache/asset-key.js +115 -0
  209. package/dist/services/onboarding/request-cache/cache.d.ts +62 -5
  210. package/dist/services/onboarding/request-cache/cache.js +128 -17
  211. package/dist/services/onboarding/spec/browser/console-log.spec.d.ts +1 -0
  212. package/dist/services/onboarding/spec/browser/console-log.spec.js +42 -0
  213. package/dist/services/onboarding/spec/control/browser-session.spec.d.ts +1 -0
  214. package/dist/services/onboarding/spec/control/browser-session.spec.js +526 -0
  215. package/dist/services/onboarding/spec/control/control-server.spec.d.ts +1 -0
  216. package/dist/services/onboarding/spec/control/control-server.spec.js +338 -0
  217. package/dist/services/onboarding/spec/control/debug-session.spec.d.ts +1 -0
  218. package/dist/services/onboarding/spec/control/debug-session.spec.js +693 -0
  219. package/dist/services/onboarding/spec/control/fakes.d.ts +31 -0
  220. package/dist/services/onboarding/spec/control/fakes.js +66 -0
  221. package/dist/services/onboarding/spec/control/fouc.spec.d.ts +1 -0
  222. package/dist/services/onboarding/spec/control/fouc.spec.js +167 -0
  223. package/dist/services/onboarding/spec/control/navwalk.spec.d.ts +1 -0
  224. package/dist/services/onboarding/spec/control/navwalk.spec.js +222 -0
  225. package/dist/services/onboarding/spec/control/preload-registry.spec.d.ts +1 -0
  226. package/dist/services/onboarding/spec/control/preload-registry.spec.js +432 -0
  227. package/dist/services/onboarding/spec/control/response-explainer.spec.d.ts +1 -0
  228. package/dist/services/onboarding/spec/control/response-explainer.spec.js +324 -0
  229. package/dist/services/onboarding/spec/control/rum.spec.d.ts +1 -0
  230. package/dist/services/onboarding/spec/control/rum.spec.js +222 -0
  231. package/dist/services/onboarding/spec/control/service-worker-tracker.spec.d.ts +1 -0
  232. package/dist/services/onboarding/spec/control/service-worker-tracker.spec.js +193 -0
  233. package/dist/services/onboarding/spec/control/viewport.spec.d.ts +1 -0
  234. package/dist/services/onboarding/spec/control/viewport.spec.js +200 -0
  235. package/dist/services/onboarding/spec/control/watch.spec.d.ts +1 -0
  236. package/dist/services/onboarding/spec/control/watch.spec.js +172 -0
  237. package/dist/services/onboarding/spec/fetch-event-handler.spec.d.ts +1 -0
  238. package/dist/services/onboarding/spec/fetch-event-handler.spec.js +202 -0
  239. package/dist/services/onboarding/spec/fetch-events/speed-kit-service-worker-js.spec.d.ts +1 -0
  240. package/dist/services/onboarding/spec/fetch-events/speed-kit-service-worker-js.spec.js +41 -0
  241. package/dist/services/onboarding/spec/onboarding-model.spec.js +37 -0
  242. package/dist/services/onboarding/spec/onboarding-service-factory.spec.js +1 -0
  243. package/dist/services/onboarding/spec/request-cache/cache.spec.d.ts +1 -0
  244. package/dist/services/onboarding/spec/request-cache/cache.spec.js +107 -0
  245. package/dist/services/onboarding/spec/todo-collector.spec.d.ts +1 -0
  246. package/dist/services/onboarding/spec/todo-collector.spec.js +136 -0
  247. package/dist/services/onboarding/todo-collector.d.ts +7 -2
  248. package/dist/services/onboarding/todo-collector.js +49 -12
  249. package/dist/services/onboarding/virtual-orestes-app/index.d.ts +34 -0
  250. package/dist/services/onboarding/virtual-orestes-app/index.js +82 -27
  251. package/dist/services/origin-request/asset-variations.d.ts +14 -0
  252. package/dist/services/origin-request/asset-variations.js +11 -4
  253. package/dist/services/origin-request/origin-fetcher.d.ts +7 -0
  254. package/dist/services/origin-request/origin-fetcher.js +43 -5
  255. package/dist/services/origin-request/origin-request-service-build-context.d.ts +17 -0
  256. package/dist/services/origin-request/origin-request-service-build-context.js +8 -0
  257. package/dist/services/origin-request/origin-request-service-factory.d.ts +0 -5
  258. package/dist/services/origin-request/origin-request-service-factory.js +2 -30
  259. package/dist/services/origin-request/origin-request-service.d.ts +121 -6
  260. package/dist/services/origin-request/origin-request-service.js +273 -49
  261. package/dist/services/origin-request/runtime-config-source.js +9 -4
  262. package/dist/services/origin-request/spec/asset-variations.spec.js +20 -0
  263. package/dist/services/origin-request/spec/origin-request-service.spec.js +329 -6
  264. package/dist/services/query-builder/rules/rule-match.d.ts +35 -0
  265. package/dist/services/query-builder/rules/rule-match.js +70 -0
  266. package/dist/services/query-builder/spec/rules/rule-match.spec.d.ts +1 -0
  267. package/dist/services/query-builder/spec/rules/rule-match.spec.js +121 -0
  268. package/dist/services/run-control/browser/run-browser-contexts.d.ts +541 -0
  269. package/dist/services/run-control/browser/run-browser-contexts.js +78 -0
  270. package/dist/services/run-control/browser/run-browser-service-factory.d.ts +5 -0
  271. package/dist/services/run-control/browser/run-browser-service-factory.js +7 -0
  272. package/dist/services/run-control/browser/run-browser-service.d.ts +64 -0
  273. package/dist/services/run-control/browser/run-browser-service.js +199 -0
  274. package/dist/services/run-control/cache/run-cache-contexts.d.ts +349 -0
  275. package/dist/services/run-control/cache/run-cache-contexts.js +51 -0
  276. package/dist/services/run-control/cache/run-cache-service-factory.d.ts +6 -0
  277. package/dist/services/run-control/cache/run-cache-service-factory.js +12 -0
  278. package/dist/services/run-control/cache/run-cache-service.d.ts +35 -0
  279. package/dist/services/run-control/cache/run-cache-service.js +151 -0
  280. package/dist/services/run-control/control-client.d.ts +36 -0
  281. package/dist/services/run-control/control-client.js +147 -0
  282. package/dist/services/run-control/debug/run-debug-contexts.d.ts +411 -0
  283. package/dist/services/run-control/debug/run-debug-contexts.js +44 -0
  284. package/dist/services/run-control/debug/run-debug-service-factory.d.ts +5 -0
  285. package/dist/services/run-control/debug/run-debug-service-factory.js +7 -0
  286. package/dist/services/run-control/debug/run-debug-service.d.ts +38 -0
  287. package/dist/services/run-control/debug/run-debug-service.js +161 -0
  288. package/dist/services/run-control/files/run-files-contexts.d.ts +238 -0
  289. package/dist/services/run-control/files/run-files-contexts.js +26 -0
  290. package/dist/services/run-control/files/run-files-service-factory.d.ts +5 -0
  291. package/dist/services/run-control/files/run-files-service-factory.js +7 -0
  292. package/dist/services/run-control/files/run-files-service.d.ts +29 -0
  293. package/dist/services/run-control/files/run-files-service.js +120 -0
  294. package/dist/services/run-control/index.d.ts +32 -0
  295. package/dist/services/run-control/index.js +31 -0
  296. package/dist/services/run-control/inject/run-inject-contexts.d.ts +319 -0
  297. package/dist/services/run-control/inject/run-inject-contexts.js +32 -0
  298. package/dist/services/run-control/inject/run-inject-service-factory.d.ts +5 -0
  299. package/dist/services/run-control/inject/run-inject-service-factory.js +7 -0
  300. package/dist/services/run-control/inject/run-inject-service.d.ts +31 -0
  301. package/dist/services/run-control/inject/run-inject-service.js +203 -0
  302. package/dist/services/run-control/live-run.d.ts +37 -0
  303. package/dist/services/run-control/live-run.js +56 -0
  304. package/dist/services/run-control/probe/run-probe-contexts.d.ts +333 -0
  305. package/dist/services/run-control/probe/run-probe-contexts.js +73 -0
  306. package/dist/services/run-control/probe/run-probe-service-factory.d.ts +5 -0
  307. package/dist/services/run-control/probe/run-probe-service-factory.js +7 -0
  308. package/dist/services/run-control/probe/run-probe-service.d.ts +54 -0
  309. package/dist/services/run-control/probe/run-probe-service.js +193 -0
  310. package/dist/services/run-control/rum/run-rum-contexts.d.ts +216 -0
  311. package/dist/services/run-control/rum/run-rum-contexts.js +34 -0
  312. package/dist/services/run-control/rum/run-rum-service-factory.d.ts +5 -0
  313. package/dist/services/run-control/rum/run-rum-service-factory.js +7 -0
  314. package/dist/services/run-control/rum/run-rum-service.d.ts +36 -0
  315. package/dist/services/run-control/rum/run-rum-service.js +122 -0
  316. package/dist/services/run-control/run-answer.d.ts +28 -0
  317. package/dist/services/run-control/run-answer.js +58 -0
  318. package/dist/services/run-control/run-control-context.d.ts +102 -0
  319. package/dist/services/run-control/run-control-context.js +36 -0
  320. package/dist/services/run-control/run-control-flags.d.ts +12 -0
  321. package/dist/services/run-control/run-control-flags.js +22 -0
  322. package/dist/services/run-control/run-control-model.d.ts +9 -0
  323. package/dist/services/run-control/run-control-model.js +1 -0
  324. package/dist/services/run-control/run-control-service-factory.d.ts +14 -0
  325. package/dist/services/run-control/run-control-service-factory.js +26 -0
  326. package/dist/services/run-control/session/run-session-contexts.d.ts +25 -0
  327. package/dist/services/run-control/session/run-session-contexts.js +20 -0
  328. package/dist/services/run-control/session/run-session-service-factory.d.ts +8 -0
  329. package/dist/services/run-control/session/run-session-service-factory.js +18 -0
  330. package/dist/services/run-control/session/run-session-service.d.ts +25 -0
  331. package/dist/services/run-control/session/run-session-service.js +95 -0
  332. package/dist/services/run-control/spec/browser/run-browser-service.spec.d.ts +1 -0
  333. package/dist/services/run-control/spec/browser/run-browser-service.spec.js +327 -0
  334. package/dist/services/run-control/spec/cache/run-cache-service.spec.d.ts +1 -0
  335. package/dist/services/run-control/spec/cache/run-cache-service.spec.js +454 -0
  336. package/dist/services/run-control/spec/debug/run-debug-service.spec.d.ts +1 -0
  337. package/dist/services/run-control/spec/debug/run-debug-service.spec.js +113 -0
  338. package/dist/services/run-control/spec/files/run-files-service.spec.d.ts +1 -0
  339. package/dist/services/run-control/spec/files/run-files-service.spec.js +234 -0
  340. package/dist/services/run-control/spec/inject/run-inject-service.spec.d.ts +1 -0
  341. package/dist/services/run-control/spec/inject/run-inject-service.spec.js +224 -0
  342. package/dist/services/run-control/spec/live-run-fixture.d.ts +32 -0
  343. package/dist/services/run-control/spec/live-run-fixture.js +109 -0
  344. package/dist/services/run-control/spec/probe/run-probe-service.spec.d.ts +1 -0
  345. package/dist/services/run-control/spec/probe/run-probe-service.spec.js +108 -0
  346. package/dist/services/run-control/spec/rum/run-rum-service.spec.d.ts +1 -0
  347. package/dist/services/run-control/spec/rum/run-rum-service.spec.js +47 -0
  348. package/dist/services/run-control/spec/run-answer.spec.d.ts +1 -0
  349. package/dist/services/run-control/spec/run-answer.spec.js +57 -0
  350. package/dist/services/run-control/spec/session/run-session-service.spec.d.ts +1 -0
  351. package/dist/services/run-control/spec/session/run-session-service.spec.js +101 -0
  352. package/dist/services/run-log/crash-mirror.d.ts +31 -0
  353. package/dist/services/run-log/crash-mirror.js +69 -0
  354. package/dist/services/run-log/index.d.ts +11 -0
  355. package/dist/services/run-log/index.js +11 -0
  356. package/dist/services/run-log/jsonl-appender.d.ts +46 -0
  357. package/dist/services/run-log/jsonl-appender.js +91 -0
  358. package/dist/services/run-log/log-event-model.d.ts +104 -0
  359. package/dist/services/run-log/log-event-model.js +56 -0
  360. package/dist/services/run-log/log-query-service-factory.d.ts +11 -0
  361. package/dist/services/run-log/log-query-service-factory.js +14 -0
  362. package/dist/services/run-log/log-query-service.d.ts +59 -0
  363. package/dist/services/run-log/log-query-service.js +111 -0
  364. package/dist/services/run-log/log-reader.d.ts +84 -0
  365. package/dist/services/run-log/log-reader.js +180 -0
  366. package/dist/services/run-log/log-summary.d.ts +72 -0
  367. package/dist/services/run-log/log-summary.js +208 -0
  368. package/dist/services/run-log/redaction.d.ts +34 -0
  369. package/dist/services/run-log/redaction.js +124 -0
  370. package/dist/services/run-log/request-log.d.ts +80 -0
  371. package/dist/services/run-log/request-log.js +69 -0
  372. package/dist/services/run-log/request-summary.d.ts +76 -0
  373. package/dist/services/run-log/request-summary.js +0 -0
  374. package/dist/services/run-log/run-log.d.ts +61 -0
  375. package/dist/services/run-log/run-log.js +102 -0
  376. package/dist/services/run-log/spec/log-query-service.spec.d.ts +1 -0
  377. package/dist/services/run-log/spec/log-query-service.spec.js +197 -0
  378. package/dist/services/run-log/spec/log-reader.spec.d.ts +1 -0
  379. package/dist/services/run-log/spec/log-reader.spec.js +109 -0
  380. package/dist/services/run-log/spec/log-summary.spec.d.ts +1 -0
  381. package/dist/services/run-log/spec/log-summary.spec.js +153 -0
  382. package/dist/services/run-log/spec/redaction.spec.d.ts +1 -0
  383. package/dist/services/run-log/spec/redaction.spec.js +61 -0
  384. package/dist/services/run-log/spec/request-log.spec.d.ts +1 -0
  385. package/dist/services/run-log/spec/request-log.spec.js +101 -0
  386. package/dist/services/run-log/spec/request-summary.spec.d.ts +1 -0
  387. package/dist/services/run-log/spec/request-summary.spec.js +171 -0
  388. package/dist/services/run-log/spec/run-log.spec.d.ts +1 -0
  389. package/dist/services/run-log/spec/run-log.spec.js +122 -0
  390. package/dist/services/run-registry/exit-classification.d.ts +39 -0
  391. package/dist/services/run-registry/exit-classification.js +42 -0
  392. package/dist/services/run-registry/index.d.ts +3 -0
  393. package/dist/services/run-registry/index.js +3 -0
  394. package/dist/services/run-registry/process-identity.d.ts +28 -0
  395. package/dist/services/run-registry/process-identity.js +80 -0
  396. package/dist/services/run-registry/run-registry-model.d.ts +128 -0
  397. package/dist/services/run-registry/run-registry-model.js +16 -0
  398. package/dist/services/run-registry/run-registry.d.ts +150 -0
  399. package/dist/services/run-registry/run-registry.js +409 -0
  400. package/dist/services/run-registry/spec/exit-classification.spec.d.ts +1 -0
  401. package/dist/services/run-registry/spec/exit-classification.spec.js +82 -0
  402. package/dist/services/run-registry/spec/run-registry.spec.d.ts +1 -0
  403. package/dist/services/run-registry/spec/run-registry.spec.js +509 -0
  404. package/dist/services/setup/os/tool-registry.js +2 -2
  405. package/oclif.manifest.json +3293 -272
  406. package/package.json +20 -2
@@ -0,0 +1,202 @@
1
+ import { expect } from "chai";
2
+ import { beforeEach, describe, it } from "mocha";
3
+ import { EventEmitter } from "node:events";
4
+ import { MemoryRequestLog } from "../../run-log/index.js";
5
+ import { AbortResponse } from "../browser/abort-response.js";
6
+ import { FetchEventHandler } from "../fetch-event-handler.js";
7
+ import { BROWSER_EVENTS } from "../onboarding-model.js";
8
+ /** A CDP session that records what it was told to do and answers immediately. */
9
+ class StubSession extends EventEmitter {
10
+ sent = [];
11
+ async send(method, params) {
12
+ this.sent.push({ method, params });
13
+ return {};
14
+ }
15
+ }
16
+ /** A handler that claims one url pattern and answers it however the spec says. */
17
+ class TestHandler {
18
+ answer;
19
+ patterns = [{ urlPattern: ".*", requestStage: "Request" }];
20
+ constructor(answer) {
21
+ this.answer = answer;
22
+ }
23
+ async handle() {
24
+ return this.answer;
25
+ }
26
+ }
27
+ /** Named so a record's `handler` field has something recognisable in it. */
28
+ class SlowHandler extends TestHandler {
29
+ }
30
+ const cli = {
31
+ writeError: () => undefined,
32
+ writeWarning: () => undefined,
33
+ writeSuccess: () => undefined,
34
+ startAction: () => undefined,
35
+ successAction: () => undefined,
36
+ failAction: () => undefined,
37
+ };
38
+ const customerConfig = {
39
+ origins: [],
40
+ app: "spec",
41
+ };
42
+ function pausedEvent(patch = {}) {
43
+ return {
44
+ requestId: "1",
45
+ request: { url: "https://x.test/page", method: "GET" },
46
+ resourceType: "Document",
47
+ ...patch,
48
+ };
49
+ }
50
+ /** Drive one paused request through the handler and return what was recorded. */
51
+ async function intercept(handlers, event = pausedEvent()) {
52
+ const requestLog = new MemoryRequestLog();
53
+ const session = new StubSession();
54
+ const target = {
55
+ createCDPSession: async () => session,
56
+ url: () => "https://x.test/",
57
+ };
58
+ const fetchEventHandler = new FetchEventHandler({
59
+ browserFetchEvents: handlers,
60
+ customerConfig,
61
+ cli,
62
+ requestLog,
63
+ });
64
+ await fetchEventHandler.handleRequestFetchEvents(target);
65
+ session.emit(BROWSER_EVENTS.FETCH_REQUEST_PAUSED, event);
66
+ // The listener is async and the emit does not await it.
67
+ await new Promise((resolve) => setImmediate(resolve));
68
+ return { requestLog, session };
69
+ }
70
+ /** Drive one auth challenge through the handler and return what CDP was told. */
71
+ async function challenge(authentications) {
72
+ const session = new StubSession();
73
+ const target = {
74
+ createCDPSession: async () => session,
75
+ url: () => "https://x.test/",
76
+ };
77
+ const client = {
78
+ getServerConfig: async () => JSON.stringify({ speedKit: { authentications } }),
79
+ };
80
+ const fetchEventHandler = new FetchEventHandler({
81
+ browserFetchEvents: [],
82
+ customerConfig: {
83
+ origins: ["https://x.test"],
84
+ app: "spec",
85
+ },
86
+ cli,
87
+ client: client,
88
+ requestLog: new MemoryRequestLog(),
89
+ });
90
+ await fetchEventHandler.handleRequestFetchEvents(target);
91
+ session.emit(BROWSER_EVENTS.FETCH_AUTH_REQUIRED, {
92
+ requestId: "1",
93
+ request: { url: "https://x.test/page" },
94
+ authChallenge: { scheme: "basic", origin: "https://x.test" },
95
+ });
96
+ await new Promise((resolve) => setImmediate(resolve));
97
+ return session.sent.filter((call) => call.method === "Fetch.continueWithAuth");
98
+ }
99
+ describe("FetchEventHandler auth challenges", () => {
100
+ it("should answer a challenge exactly once when credentials are found", async () => {
101
+ // It used to send the credentials and then send `Default` for the same
102
+ // requestId. A challenge can only be answered once, so the second call
103
+ // always threw `Invalid state for continueInterceptedRequest` — logged at
104
+ // `error` level, one millisecond after the success line, and heading the
105
+ // run's problems list as though authentication had failed. It had not: the
106
+ // credentials went first.
107
+ const calls = await challenge([
108
+ {
109
+ uri: "https://x.test",
110
+ type: "basic",
111
+ user: "spec",
112
+ password: "spec-secret",
113
+ },
114
+ ]);
115
+ expect(calls).to.have.lengthOf(1);
116
+ expect(calls[0].params.authChallengeResponse.response).to.equal("ProvideCredentials");
117
+ });
118
+ it("should fall back to the default behaviour when no credential matches", async () => {
119
+ // The other origin's credential must not be offered here, and the
120
+ // challenge still has to be answered, or the request hangs.
121
+ const calls = await challenge([
122
+ { uri: "https://other.test", type: "basic", user: "u", password: "p" },
123
+ ]);
124
+ expect(calls).to.have.lengthOf(1);
125
+ expect(calls[0].params.authChallengeResponse.response).to.equal("Default");
126
+ });
127
+ });
128
+ describe("FetchEventHandler request records", () => {
129
+ let handled;
130
+ describe("a request no handler claims", () => {
131
+ beforeEach(async () => {
132
+ handled = await intercept([]);
133
+ });
134
+ it("is recorded as continued", async () => {
135
+ // The one outcome with no other trace anywhere: "what did the CLI hand
136
+ // straight back to Chrome" is exactly what a disabledScopes or blacklist
137
+ // change moves, and nothing else in the run writes it down.
138
+ expect(handled.requestLog.records).to.have.length(1);
139
+ expect(handled.requestLog.records[0]).to.include({
140
+ outcome: "continued",
141
+ url: "https://x.test/page",
142
+ method: "GET",
143
+ resourceType: "Document",
144
+ stage: "Request",
145
+ });
146
+ });
147
+ it("still reaches Chrome untouched", async () => {
148
+ expect(handled.session.sent.map((call) => call.method)).to.contain("Fetch.continueRequest");
149
+ });
150
+ });
151
+ it("records the handler that answered, and the status", async () => {
152
+ const { requestLog } = await intercept([
153
+ new SlowHandler({ responseCode: 203, body: "" }),
154
+ ]);
155
+ expect(requestLog.records[0]).to.include({
156
+ outcome: "fulfilled",
157
+ handler: "SlowHandler",
158
+ status: 203,
159
+ });
160
+ expect(requestLog.records[0].durationMs).to.be.a("number");
161
+ });
162
+ it("records a deliberate abort as failed, not as an error", async () => {
163
+ // An abort is a rule doing its job. Recording it as an error would put a
164
+ // working config at the top of the summary's problem list.
165
+ const { requestLog } = await intercept([
166
+ new TestHandler(new AbortResponse("Aborted")),
167
+ ]);
168
+ expect(requestLog.records[0].outcome).to.equal("failed");
169
+ });
170
+ it("records a handler that threw, with the reason", async () => {
171
+ const thrower = {
172
+ patterns: [{ urlPattern: ".*", requestStage: "Request" }],
173
+ handle: async () => {
174
+ throw new Error("handler blew up");
175
+ },
176
+ };
177
+ const { requestLog } = await intercept([thrower]);
178
+ expect(requestLog.records[0]).to.include({ outcome: "error" });
179
+ expect(requestLog.records[0].error).to.contain("handler blew up");
180
+ });
181
+ it("distinguishes the response stage from the request stage", async () => {
182
+ const { requestLog } = await intercept([], pausedEvent({ responseHeaders: [{ name: "x", value: "y" }] }));
183
+ expect(requestLog.records[0].stage).to.equal("Response");
184
+ });
185
+ it("works without a request log at all", async () => {
186
+ // A run started with --no-log-file, and the test harness.
187
+ const session = new StubSession();
188
+ const target = {
189
+ createCDPSession: async () => session,
190
+ url: () => "https://x.test/",
191
+ };
192
+ const handler = new FetchEventHandler({
193
+ browserFetchEvents: [],
194
+ customerConfig,
195
+ cli,
196
+ });
197
+ await handler.handleRequestFetchEvents(target);
198
+ session.emit(BROWSER_EVENTS.FETCH_REQUEST_PAUSED, pausedEvent());
199
+ await new Promise((resolve) => setImmediate(resolve));
200
+ expect(session.sent.map((call) => call.method)).to.contain("Fetch.continueRequest");
201
+ });
202
+ });
@@ -0,0 +1,41 @@
1
+ import { expect } from "chai";
2
+ import { describe, it } from "mocha";
3
+ import { createContext, runInContext } from "node:vm";
4
+ import { SpeedKitServiceWorkerJs, userAgentPrelude, } from "../../fetch-events/speed-kit-service-worker-js.js";
5
+ const MOBILE = "Mozilla/5.0 (Linux; Android 10; K) Mobile Safari/537.36";
6
+ /** A worker global whose navigator has the user agent on its prototype, as Chrome's does. */
7
+ function worker() {
8
+ const prototype = {};
9
+ Object.defineProperty(prototype, "userAgent", {
10
+ get: () => "Mozilla/5.0 (X11; Linux x86_64) Chrome/146",
11
+ configurable: true,
12
+ });
13
+ const navigator = Object.create(prototype);
14
+ const context = createContext({ self: { navigator }, navigator });
15
+ return { navigator, run: (source) => runInContext(source, context) };
16
+ }
17
+ describe("SpeedKitServiceWorkerJs under emulation", () => {
18
+ const handler = () => new SpeedKitServiceWorkerJs({ appDomain: "myapp.app.baqend.com" }, {
19
+ getContent: () => "/* speed kit */ self.ua = navigator.userAgent;",
20
+ });
21
+ const body = async (sw) => {
22
+ const response = await sw.handle();
23
+ return Buffer.from(String(response.body), "base64").toString("utf8");
24
+ };
25
+ it("should make the worker report the emulated user agent", () => {
26
+ // Speed Kit decides the device in its worker, from navigator.userAgent
27
+ // when no header says otherwise. A CDP override did not reach it.
28
+ const { navigator, run } = worker();
29
+ run(userAgentPrelude(MOBILE));
30
+ expect(navigator.userAgent).to.equal(MOBILE);
31
+ });
32
+ it("should prepend the override only while an emulation is active", async () => {
33
+ const sw = handler();
34
+ expect(await body(sw)).to.not.contain("sk onboarding browser emulate");
35
+ sw.userAgent = MOBILE;
36
+ const emulated = await body(sw);
37
+ // First, so it runs before any of Speed Kit's code reads the user agent.
38
+ expect(emulated.indexOf("sk onboarding browser emulate")).to.equal(3);
39
+ expect(emulated).to.contain("/* speed kit */");
40
+ });
41
+ });
@@ -294,4 +294,41 @@ describe("BrowserContext launch options", () => {
294
294
  expect(options.enableExtensions).to.equal(undefined);
295
295
  expect(options.pipe).to.equal(undefined);
296
296
  });
297
+ it("should keep the signals for itself", () => {
298
+ const options = newContext(false).getPuppeteerLaunchOptions();
299
+ // Puppeteer's own SIGINT handler is `kill(); process.exit(130)`, which
300
+ // would skip the run's status stamp, the control-socket unlink and the
301
+ // cache teardown — everything in the command's `finally`. The command
302
+ // registers its handlers before the browser launches and owns shutdown.
303
+ expect(options.handleSIGINT).to.equal(false);
304
+ expect(options.handleSIGTERM).to.equal(false);
305
+ expect(options.handleSIGHUP).to.equal(false);
306
+ });
307
+ it("installs extensions over the pipe on every Chromium build", () => {
308
+ const withExtensions = {
309
+ settings: {
310
+ ...environment.settings,
311
+ chromeExtensionPaths: "/ext/devtools,/ext/other",
312
+ },
313
+ };
314
+ for (const browserVersionString of [
315
+ "Google Chrome for Testing 154.0.8037.57",
316
+ "Chromium 153.0.8010.52 Arch Linux",
317
+ ]) {
318
+ const options = new BrowserContext("example.com", browserVersionString, [], withExtensions, undefined, false, false, undefined).getPuppeteerLaunchOptions();
319
+ // The pipe and Puppeteer's --enable-unsafe-extension-debugging are what
320
+ // the `Extensions` domain requires, and ExtensionBridge writes through it.
321
+ expect(options.pipe).to.equal(true);
322
+ expect(options.enableExtensions).to.deep.equal([
323
+ "/ext/devtools",
324
+ "/ext/other",
325
+ ]);
326
+ expect(options.args.filter((arg) => /extension/.test(arg))).to.deep.equal([]);
327
+ }
328
+ });
329
+ it("launches without extensions when none are configured", () => {
330
+ const options = newContext(false).getPuppeteerLaunchOptions();
331
+ expect(options.enableExtensions).to.equal(undefined);
332
+ expect(options.pipe).to.equal(undefined);
333
+ });
297
334
  });
@@ -43,6 +43,7 @@ function buildContext(values = {}) {
43
43
  browserFetch: false,
44
44
  browse: false,
45
45
  inject: false,
46
+ logFile: false,
46
47
  ...values,
47
48
  });
48
49
  }
@@ -0,0 +1,107 @@
1
+ import { expect } from "chai";
2
+ import { afterEach, beforeEach, describe, it } from "mocha";
3
+ import { existsSync, mkdtempSync, readFileSync, readdirSync, rmSync, } from "node:fs";
4
+ import { tmpdir } from "node:os";
5
+ import { join } from "node:path";
6
+ import { BaqendResponse } from "../../browser/baqend-response.js";
7
+ import { Cache } from "../../request-cache/cache.js";
8
+ import { memoryCli } from "../../../cli/spec/memory-cli.js";
9
+ const KEY = "https://myapp.app.baqend.com/v1/asset/https://shop.example.com/p?bqvariation=mobile";
10
+ const PAGE = "<html><body>hello</body></html>";
11
+ describe("Cache", () => {
12
+ let directory;
13
+ let cache;
14
+ const add = (key, body, status) => cache.addEntry(key, new BaqendResponse(body, "text/html; charset=utf-8", [], status), body);
15
+ beforeEach(() => {
16
+ directory = mkdtempSync(join(tmpdir(), "sk-cache-"));
17
+ cache = new Cache(memoryCli(), directory);
18
+ });
19
+ afterEach(() => {
20
+ rmSync(directory, { recursive: true, force: true });
21
+ });
22
+ it("should store the body decoded, so the file is simply readable", () => {
23
+ add(KEY, PAGE);
24
+ const [[, entry]] = [...cache.getAll()];
25
+ // Only Chrome's fulfillRequest needs base64; nothing else should pay for it.
26
+ expect(readFileSync(entry.path, "utf8")).to.equal(PAGE);
27
+ expect(entry.bytes).to.equal(PAGE.length);
28
+ });
29
+ it("should hand back a response Chrome can fulfil", () => {
30
+ add(KEY, PAGE);
31
+ const response = cache.getEntry(KEY);
32
+ expect(Buffer.from(response.body, "base64").toString("utf8")).to.equal(PAGE);
33
+ expect(response.responseCode).to.equal(200);
34
+ expect(response.contentLength).to.equal(PAGE.length);
35
+ });
36
+ it("should not accumulate headers, nor let a hit write back to the store", () => {
37
+ add(KEY, PAGE);
38
+ const first = cache.getEntry(KEY);
39
+ first.setHeader("x-cache", "POP, HIT");
40
+ const second = cache.getEntry(KEY);
41
+ // Rebuilding through the constructor would re-append `via` and friends on
42
+ // every hit, compounding for the life of the run.
43
+ expect(second.responseHeaders.filter((header) => header.name === "via")).to.have.lengthOf(1);
44
+ // And what one hit set must not leak into the next: the stored headers are
45
+ // copied out, not handed out.
46
+ expect(second.responseHeaders.find((header) => header.name === "x-cache")).to.equal(undefined);
47
+ });
48
+ it("should key a page apart from Speed Kit's bookkeeping on the request", () => {
49
+ // The page asks with its config and Speed Kit versions and a
50
+ // page-impression counter; `cache prewarm` builds the bare url. Keyed raw,
51
+ // the prewarmed entry was never the one the page read, and the page's own
52
+ // second request missed its first because the counter moved.
53
+ add(KEY, PAGE);
54
+ const fromPage = `${KEY}&bqcv=7f2b0065&bqsk=2.22.5&bqpi=1;sp=1&bqcache=if-cached`;
55
+ expect(cache.has(fromPage)).to.equal(true);
56
+ expect(cache.getEntry(fromPage)?.responseCode).to.equal(200);
57
+ expect([...cache.getAll()].map(([key]) => key)).to.deep.equal([KEY]);
58
+ });
59
+ it("should keep the variation and the page's own parameters in the key", () => {
60
+ add(KEY, PAGE);
61
+ expect(cache.has(KEY.replace("mobile", "tablet"))).to.equal(false);
62
+ expect(cache.has(`${KEY}&colour=red`)).to.equal(false);
63
+ });
64
+ it("should keep no body in memory", () => {
65
+ add(KEY, PAGE);
66
+ const [[, entry]] = [...cache.getAll()];
67
+ // The metadata is the whole in-memory footprint: the point of the change.
68
+ expect(Object.values(entry).join("")).to.not.contain("hello");
69
+ });
70
+ it("should treat a body that vanished as a miss, not a crash", () => {
71
+ add(KEY, PAGE);
72
+ const [[, entry]] = [...cache.getAll()];
73
+ rmSync(entry.path);
74
+ expect(cache.getEntry(KEY)).to.equal(null);
75
+ expect([...cache.getAll()]).to.have.lengthOf(0);
76
+ });
77
+ it("should give each key its own file, so evicting one keeps the other", () => {
78
+ // Content-addressing would share a file between these two and pull the body
79
+ // out from under the survivor.
80
+ add(`${KEY}&a=1`, PAGE);
81
+ add(`${KEY}&a=2`, PAGE);
82
+ cache.removeEntry("a=1");
83
+ expect([...cache.getAll()]).to.have.lengthOf(1);
84
+ expect(cache.getEntry(`${KEY}&a=2`)).to.not.equal(null);
85
+ });
86
+ it("should remove the files it wrote when cleared", () => {
87
+ add(`${KEY}&a=1`, PAGE);
88
+ add(`${KEY}&a=2`, PAGE);
89
+ cache.clear();
90
+ expect([...cache.getAll()]).to.have.lengthOf(0);
91
+ expect(readdirSync(directory)).to.deep.equal([]);
92
+ });
93
+ it("should overwrite an entry in place when it is cached again", () => {
94
+ add(KEY, PAGE);
95
+ const [[, first]] = [...cache.getAll()];
96
+ add(KEY, "<html>fresher</html>");
97
+ const [[, second]] = [...cache.getAll()];
98
+ expect(second.path).to.equal(first.path);
99
+ expect(second.sha).to.not.equal(first.sha);
100
+ expect(readdirSync(directory)).to.have.lengthOf(1);
101
+ });
102
+ it("should take the whole directory with it on destroy", () => {
103
+ add(KEY, PAGE);
104
+ cache.destroy();
105
+ expect(existsSync(directory)).to.equal(false);
106
+ });
107
+ });
@@ -0,0 +1,136 @@
1
+ import { expect } from "chai";
2
+ import { describe, it } from "mocha";
3
+ import { TodoCollector } from "../todo-collector.js";
4
+ import { FILE_TYPE } from "../../integration-api/index.js";
5
+ function resource(path, content, type = FILE_TYPE.CONFIG_FILE) {
6
+ return {
7
+ path,
8
+ type,
9
+ getContent: () => content,
10
+ };
11
+ }
12
+ describe("TodoCollector", () => {
13
+ it("should find every task in a file, not only the first", () => {
14
+ // The original matched with a non-global regex through `String.replace`,
15
+ // which calls its replacer once. A file with four open tasks reported one
16
+ // and the rest were invisible — to the devtools panel and to anything else.
17
+ const collector = new TodoCollector([
18
+ resource("/customers/x/production/config_SpeedKit.js", [
19
+ "const a = 1;",
20
+ "// TODO ask about the split test",
21
+ "one",
22
+ "two",
23
+ "three",
24
+ "const b = 2;",
25
+ "// TODO confirm the asset list",
26
+ "four",
27
+ "five",
28
+ "six",
29
+ ].join("\n")),
30
+ ]);
31
+ const tasks = collector.getOpenTasks();
32
+ expect(tasks.map((task) => task.todo.trim())).to.deep.equal([
33
+ "TODO ask about the split test",
34
+ "TODO confirm the asset list",
35
+ ]);
36
+ });
37
+ it("should give each task its own line, even when two read the same", () => {
38
+ // The line came from `indexOf(todoText)`, so a repeated task all pointed at
39
+ // the first occurrence — and the point of the line is to open the file at it.
40
+ const collector = new TodoCollector([
41
+ resource("/customers/x/production/config_documentHandler.js", [
42
+ "// TODO check this",
43
+ "a",
44
+ "b",
45
+ "c",
46
+ "// TODO check this",
47
+ "d",
48
+ "e",
49
+ "f",
50
+ ].join("\n")),
51
+ ]);
52
+ const [first, second] = collector.getOpenTasks();
53
+ expect(first.line).to.not.equal(second.line);
54
+ expect(second.line).to.be.greaterThan(first.line);
55
+ });
56
+ it("should not start one file where the last one stopped", () => {
57
+ // A shared global regex carries `lastIndex` between calls, so the second
58
+ // file would begin matching from an offset that means nothing in it.
59
+ const body = ["// TODO one", "a", "b", "c"].join("\n");
60
+ const collector = new TodoCollector([
61
+ resource("/customers/x/production/first.js", `${body}\n${body}`),
62
+ resource("/customers/x/production/second.js", body),
63
+ ]);
64
+ const files = collector.getOpenTasks().map((task) => task.file);
65
+ expect(files.filter((file) => file.endsWith("second.js"))).to.have.lengthOf(1);
66
+ });
67
+ it("should carry the file and the three lines under the task", () => {
68
+ const collector = new TodoCollector([
69
+ resource("/customers/x/production/config_SpeedKit.js", ["// TODO ask", "context one", "context two", "context three"].join("\n")),
70
+ ]);
71
+ const [task] = collector.getOpenTasks();
72
+ expect(task.file).to.equal("/customers/x/production/config_SpeedKit.js");
73
+ expect(decodeURI(task.context)).to.contain("context one");
74
+ expect(decodeURI(task.context)).to.contain("context three");
75
+ });
76
+ it("should skip virtual files, which nobody can open in an editor", () => {
77
+ const collector = new TodoCollector([
78
+ resource("bundle_install", ["// TODO generated", "a", "b", "c"].join("\n"), FILE_TYPE.VIRTUAL_FILE),
79
+ ]);
80
+ expect(collector.getOpenTasks()).to.deep.equal([]);
81
+ });
82
+ it("should find a task written inside the previous one's context", () => {
83
+ // The context used to be consumed, not looked ahead at, so `lastIndex`
84
+ // moved past the three lines under a TODO and a second one written inside
85
+ // that window was swallowed into the first one's `context` string. Two
86
+ // notes in a row is the ordinary way people write them.
87
+ const collector = new TodoCollector([
88
+ resource("/customers/x/production/config_SpeedKit.js", [
89
+ "// TODO confirm this scope with the customer",
90
+ "// TODO check the split test id",
91
+ "const a = 1;",
92
+ ].join("\n")),
93
+ ]);
94
+ expect(collector.getOpenTasks().map((task) => task.todo.trim())).to.deep.equal([
95
+ "TODO confirm this scope with the customer",
96
+ "TODO check the split test id",
97
+ ]);
98
+ });
99
+ it("should not lose a task because it or the lines under it contain parentheses", () => {
100
+ // The text and all three context lines were `[^\n\r()|]*`, so a `(`, `)`
101
+ // or `|` anywhere in them failed the whole match and the task vanished —
102
+ // and a JS config is full of them. Both of these were invisible.
103
+ const collector = new TodoCollector([
104
+ resource("/customers/x/production/config_SpeedKit.js", [
105
+ "// TODO check the split test id (ask the customer) first",
106
+ "a",
107
+ "b",
108
+ "c",
109
+ "// TODO confirm the wishlist pattern",
110
+ "/wish(-)?list/i,",
111
+ "d",
112
+ "e",
113
+ ].join("\n")),
114
+ ]);
115
+ expect(collector.getOpenTasks().map((task) => task.todo.trim())).to.deep.equal([
116
+ "TODO check the split test id (ask the customer) first",
117
+ "TODO confirm the wishlist pattern",
118
+ ]);
119
+ });
120
+ it("should report a task in the last lines of a file", () => {
121
+ // `{3}` required three lines beneath the TODO, so one written at the end
122
+ // of a file matched nothing at all.
123
+ const collector = new TodoCollector([
124
+ resource("/customers/x/production/config_SpeedKit.js", ["const a = 1;", "// TODO the last word"].join("\n")),
125
+ ]);
126
+ const [task] = collector.getOpenTasks();
127
+ expect(task.todo.trim()).to.equal("TODO the last word");
128
+ expect(task.line).to.equal(2);
129
+ });
130
+ it("should answer an empty list when nothing is open", () => {
131
+ const collector = new TodoCollector([
132
+ resource("/customers/x/production/clean.js", "const a = 1;\n"),
133
+ ]);
134
+ expect(collector.getOpenTasks()).to.deep.equal([]);
135
+ });
136
+ });
@@ -1,13 +1,18 @@
1
1
  import { InstallResourceInterface } from "../integration-api/integration-api-model.js";
2
2
  export interface task {
3
3
  todo: string;
4
+ /** The three lines beneath it, URI-encoded — see {@link TodoCollector}. */
4
5
  context: string;
5
6
  file: string;
6
7
  line: number;
7
8
  }
8
9
  /**
9
- * Represents a TodoCollector class that collects open tasks from files.
10
- * This files will then be injected to the current open page, so you or the browser-extension can access and display them
10
+ * Collects the open tasks written into a customer's config files.
11
+ *
12
+ * Read by two consumers with different needs: the devtools panel, which the
13
+ * messages are shaped for, and `sk onboarding todo` over the control socket. `context` is
14
+ * URI-encoded because the panel's transport expects it that way; the control
15
+ * handler decodes it again rather than handing an agent percent-escapes.
11
16
  */
12
17
  export declare class TodoCollector {
13
18
  private files;
@@ -1,8 +1,35 @@
1
1
  import { FILE_TYPE } from "../integration-api/index.js";
2
- const TODO_MATCH = /(todo[^\n\r()|]*)((?:(?:\r\n|\r|\n)[^\n\r()|]*){3})/i;
3
2
  /**
4
- * Represents a TodoCollector class that collects open tasks from files.
5
- * This files will then be injected to the current open page, so you or the browser-extension can access and display them
3
+ * A `TODO` and the three lines under it.
4
+ *
5
+ * Global on purpose. It used to be matched with a non-global regex through
6
+ * `String.replace`, which calls its replacer once — so a file with four open
7
+ * tasks reported one, and the other three were invisible to both the devtools
8
+ * panel and anything else that asked.
9
+ *
10
+ * Three further things that each silently dropped a task, all of them found
11
+ * against a real config:
12
+ *
13
+ * - **The context is a lookahead.** Consuming the three lines moved
14
+ * `lastIndex` past them, so a second `TODO` written inside that window was
15
+ * swallowed into the first one's context and never reported. Two notes in a
16
+ * row is the ordinary way people write them.
17
+ * - **Parentheses are allowed.** The text and the context lines used to be
18
+ * `[^\n\r()|]*`, so a `(`, `)` or `|` anywhere in the task or in the three
19
+ * lines beneath it failed the whole match and the task vanished — and a JS
20
+ * config is full of them. `// TODO confirm the wishlist pattern` sitting one
21
+ * line above `/wish(-)?list/i` was invisible.
22
+ * - **Fewer than three lines is enough.** `{3}` required them, so a `TODO` in
23
+ * the last lines of a file matched nothing.
24
+ */
25
+ const TODO_MATCH = /(todo[^\n\r]*)(?=((?:(?:\r\n|\r|\n)[^\n\r]*){0,3}))/gi;
26
+ /**
27
+ * Collects the open tasks written into a customer's config files.
28
+ *
29
+ * Read by two consumers with different needs: the devtools panel, which the
30
+ * messages are shaped for, and `sk onboarding todo` over the control socket. `context` is
31
+ * URI-encoded because the panel's transport expects it that way; the control
32
+ * handler decodes it again rather than handing an agent percent-escapes.
6
33
  */
7
34
  export class TodoCollector {
8
35
  files;
@@ -10,21 +37,31 @@ export class TodoCollector {
10
37
  this.files = files;
11
38
  }
12
39
  getOpenTasks() {
13
- const configFiles = this.files.filter((file) => {
14
- return !(file.type === FILE_TYPE.VIRTUAL_FILE);
15
- });
40
+ const configFiles = this.files.filter((file) => file.type !== FILE_TYPE.VIRTUAL_FILE);
16
41
  const tasks = [];
17
42
  for (const configFile of configFiles) {
18
43
  const content = configFile.getContent();
19
- content.replace(TODO_MATCH, (taskString, task, taskContext) => {
44
+ // A fresh regex per file: a global one carries `lastIndex` between
45
+ // calls, so sharing the constant would make every second file start
46
+ // matching from wherever the previous one stopped.
47
+ const pattern = new RegExp(TODO_MATCH.source, TODO_MATCH.flags);
48
+ let match;
49
+ while ((match = pattern.exec(content)) !== null) {
20
50
  tasks.push({
21
- todo: task,
22
- context: encodeURI(taskContext),
51
+ todo: match[1],
52
+ context: encodeURI(match[2]),
23
53
  file: configFile.path,
24
- line: this.lineNumber(task, content),
54
+ // From the match position, not from a text search. Two identical
55
+ // TODOs in one file both reported the first one's line.
56
+ line: this.lineNumberByIndex(match.index, content),
25
57
  });
26
- return taskString;
27
- });
58
+ // A zero-length match would otherwise spin here forever. The context
59
+ // is a lookahead, so `lastIndex` sits at the end of the TODO's own
60
+ // line — which is what leaves the lines beneath it open to match.
61
+ if (match.index === pattern.lastIndex) {
62
+ pattern.lastIndex += 1;
63
+ }
64
+ }
28
65
  }
29
66
  return tasks;
30
67
  }