@speedkit/cli 4.50.5 → 4.51.0-run-control.2

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 (432) hide show
  1. package/README.md +1425 -14
  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 +7 -1
  6. package/dist/commands/diff.js +9 -3
  7. package/dist/commands/login.d.ts +3 -0
  8. package/dist/commands/login.js +14 -3
  9. package/dist/commands/onboarding/browser/click.d.ts +75 -0
  10. package/dist/commands/onboarding/browser/click.js +19 -0
  11. package/dist/commands/onboarding/browser/emulate.d.ts +105 -0
  12. package/dist/commands/onboarding/browser/emulate.js +26 -0
  13. package/dist/commands/onboarding/browser/navigate.d.ts +75 -0
  14. package/dist/commands/onboarding/browser/navigate.js +19 -0
  15. package/dist/commands/onboarding/browser/panel.d.ts +63 -0
  16. package/dist/commands/onboarding/browser/panel.js +12 -0
  17. package/dist/commands/onboarding/browser/reinstall-sw.d.ts +63 -0
  18. package/dist/commands/onboarding/browser/reinstall-sw.js +14 -0
  19. package/dist/commands/onboarding/browser/reset.d.ts +71 -0
  20. package/dist/commands/onboarding/browser/reset.js +18 -0
  21. package/dist/commands/onboarding/browser/screenshot.d.ts +77 -0
  22. package/dist/commands/onboarding/browser/screenshot.js +19 -0
  23. package/dist/commands/onboarding/browser/state.d.ts +63 -0
  24. package/dist/commands/onboarding/browser/state.js +12 -0
  25. package/dist/commands/onboarding/browser/tabs.d.ts +58 -0
  26. package/dist/commands/onboarding/browser/tabs.js +16 -0
  27. package/dist/commands/onboarding/cache/clear.d.ts +58 -0
  28. package/dist/commands/onboarding/cache/clear.js +12 -0
  29. package/dist/commands/onboarding/cache/errors.d.ts +58 -0
  30. package/dist/commands/onboarding/cache/errors.js +12 -0
  31. package/dist/commands/onboarding/cache/evict.d.ts +62 -0
  32. package/dist/commands/onboarding/cache/evict.js +15 -0
  33. package/dist/commands/onboarding/cache/get.d.ts +85 -0
  34. package/dist/commands/onboarding/cache/get.js +17 -0
  35. package/dist/commands/onboarding/cache/list.d.ts +58 -0
  36. package/dist/commands/onboarding/cache/list.js +15 -0
  37. package/dist/commands/onboarding/cache/prewarm.d.ts +73 -0
  38. package/dist/commands/onboarding/cache/prewarm.js +20 -0
  39. package/dist/commands/onboarding/cache/refresh.d.ts +62 -0
  40. package/dist/commands/onboarding/cache/refresh.js +18 -0
  41. package/dist/commands/onboarding/cdp.d.ts +81 -0
  42. package/dist/commands/onboarding/cdp.js +18 -0
  43. package/dist/commands/onboarding/debug/arm.d.ts +83 -0
  44. package/dist/commands/onboarding/debug/arm.js +19 -0
  45. package/dist/commands/onboarding/debug/await.d.ts +71 -0
  46. package/dist/commands/onboarding/debug/await.js +18 -0
  47. package/dist/commands/onboarding/debug/disarm.d.ts +63 -0
  48. package/dist/commands/onboarding/debug/disarm.js +12 -0
  49. package/dist/commands/onboarding/debug/eval.d.ts +75 -0
  50. package/dist/commands/onboarding/debug/eval.js +16 -0
  51. package/dist/commands/onboarding/debug/release.d.ts +63 -0
  52. package/dist/commands/onboarding/debug/release.js +12 -0
  53. package/dist/commands/onboarding/debug/resume.d.ts +63 -0
  54. package/dist/commands/onboarding/debug/resume.js +12 -0
  55. package/dist/commands/onboarding/debug/status.d.ts +63 -0
  56. package/dist/commands/onboarding/debug/status.js +12 -0
  57. package/dist/commands/onboarding/debug/step.d.ts +67 -0
  58. package/dist/commands/onboarding/debug/step.js +15 -0
  59. package/dist/commands/onboarding/files/list.d.ts +58 -0
  60. package/dist/commands/onboarding/files/list.js +12 -0
  61. package/dist/commands/onboarding/files/read.d.ts +73 -0
  62. package/dist/commands/onboarding/files/read.js +16 -0
  63. package/dist/commands/onboarding/files/rebuild.d.ts +63 -0
  64. package/dist/commands/onboarding/files/rebuild.js +18 -0
  65. package/dist/commands/onboarding/files/validate.d.ts +58 -0
  66. package/dist/commands/onboarding/files/validate.js +12 -0
  67. package/dist/commands/onboarding/fouc.d.ts +77 -0
  68. package/dist/commands/onboarding/fouc.js +16 -0
  69. package/dist/commands/onboarding/inject/add.d.ts +89 -0
  70. package/dist/commands/onboarding/inject/add.js +17 -0
  71. package/dist/commands/onboarding/inject/clear.d.ts +63 -0
  72. package/dist/commands/onboarding/inject/clear.js +12 -0
  73. package/dist/commands/onboarding/inject/list.d.ts +63 -0
  74. package/dist/commands/onboarding/inject/list.js +12 -0
  75. package/dist/commands/onboarding/inject/read.d.ts +75 -0
  76. package/dist/commands/onboarding/inject/read.js +18 -0
  77. package/dist/commands/onboarding/inject/recipes.d.ts +63 -0
  78. package/dist/commands/onboarding/inject/recipes.js +12 -0
  79. package/dist/commands/onboarding/inject/remove.d.ts +67 -0
  80. package/dist/commands/onboarding/inject/remove.js +15 -0
  81. package/dist/commands/onboarding/list.d.ts +13 -0
  82. package/dist/commands/onboarding/list.js +12 -0
  83. package/dist/commands/onboarding/logs.d.ts +41 -0
  84. package/dist/commands/onboarding/logs.js +257 -0
  85. package/dist/commands/onboarding/navwalk.d.ts +95 -0
  86. package/dist/commands/onboarding/navwalk.js +19 -0
  87. package/dist/commands/onboarding/response.d.ts +67 -0
  88. package/dist/commands/onboarding/response.js +18 -0
  89. package/dist/commands/onboarding/rum/beacons.d.ts +75 -0
  90. package/dist/commands/onboarding/rum/beacons.js +16 -0
  91. package/dist/commands/onboarding/rum/get.d.ts +77 -0
  92. package/dist/commands/onboarding/rum/get.js +18 -0
  93. package/dist/commands/onboarding/rum/key.d.ts +67 -0
  94. package/dist/commands/onboarding/rum/key.js +13 -0
  95. package/dist/commands/onboarding/rum/previous.d.ts +63 -0
  96. package/dist/commands/onboarding/rum/previous.js +12 -0
  97. package/dist/commands/onboarding/status.d.ts +13 -0
  98. package/dist/commands/onboarding/status.js +17 -0
  99. package/dist/commands/onboarding/stop.d.ts +13 -0
  100. package/dist/commands/onboarding/stop.js +17 -0
  101. package/dist/commands/onboarding/todo.d.ts +58 -0
  102. package/dist/commands/onboarding/todo.js +12 -0
  103. package/dist/commands/onboarding/viewport.d.ts +101 -0
  104. package/dist/commands/onboarding/viewport.js +18 -0
  105. package/dist/commands/onboarding/watch.d.ts +93 -0
  106. package/dist/commands/onboarding/watch.js +16 -0
  107. package/dist/commands/onboarding.d.ts +26 -0
  108. package/dist/commands/onboarding.js +221 -4
  109. package/dist/commands/origin-request.d.ts +4 -0
  110. package/dist/commands/origin-request.js +4 -0
  111. package/dist/commands/spec/onboarding.spec.d.ts +1 -0
  112. package/dist/commands/spec/onboarding.spec.js +127 -0
  113. package/dist/services/cli/build-info.d.ts +33 -0
  114. package/dist/services/cli/build-info.js +63 -0
  115. package/dist/services/cli/cli-environment-factory.d.ts +3 -0
  116. package/dist/services/cli/cli-environment-factory.js +1 -0
  117. package/dist/services/cli/cli-service-build-context.d.ts +3 -0
  118. package/dist/services/cli/cli-service-factory.js +1 -1
  119. package/dist/services/cli/cli-service-model.d.ts +29 -10
  120. package/dist/services/cli/cli-service.d.ts +60 -11
  121. package/dist/services/cli/cli-service.js +196 -32
  122. package/dist/services/cli/index.d.ts +2 -0
  123. package/dist/services/cli/index.js +2 -0
  124. package/dist/services/cli/sink.d.ts +47 -0
  125. package/dist/services/cli/sink.js +31 -0
  126. package/dist/services/cli/spec/build-identity.spec.d.ts +1 -0
  127. package/dist/services/cli/spec/build-identity.spec.js +85 -0
  128. package/dist/services/cli/spec/build-info.spec.d.ts +1 -0
  129. package/dist/services/cli/spec/build-info.spec.js +10 -0
  130. package/dist/services/cli/spec/cli-service-log.spec.d.ts +1 -0
  131. package/dist/services/cli/spec/cli-service-log.spec.js +133 -0
  132. package/dist/services/cli/spec/cli-service.spec.js +113 -50
  133. package/dist/services/cli/spec/memory-cli.d.ts +9 -0
  134. package/dist/services/cli/spec/memory-cli.js +9 -0
  135. package/dist/services/diff/config-at-ref.d.ts +20 -0
  136. package/dist/services/diff/config-at-ref.js +33 -0
  137. package/dist/services/diff/diff-service-build-context.d.ts +12 -0
  138. package/dist/services/diff/diff-service-build-context.js +45 -1
  139. package/dist/services/diff/diff-service-factory.d.ts +2 -0
  140. package/dist/services/diff/diff-service-factory.js +65 -25
  141. package/dist/services/diff/diff-service.d.ts +11 -0
  142. package/dist/services/diff/diff-service.js +37 -11
  143. package/dist/services/diff/page-source.d.ts +12 -0
  144. package/dist/services/diff/page-source.js +16 -11
  145. package/dist/services/diff/run-runtime-config.d.ts +33 -0
  146. package/dist/services/diff/run-runtime-config.js +74 -0
  147. package/dist/services/diff/sinks/tool-diff-sink.d.ts +3 -2
  148. package/dist/services/diff/sinks/tool-diff-sink.js +3 -2
  149. package/dist/services/diff/spec/config-at-ref.spec.d.ts +1 -0
  150. package/dist/services/diff/spec/config-at-ref.spec.js +46 -0
  151. package/dist/services/diff/spec/diff-service-build-context.spec.js +19 -0
  152. package/dist/services/diff/spec/diff-service.spec.js +95 -0
  153. package/dist/services/diff/spec/run-runtime-config.spec.d.ts +1 -0
  154. package/dist/services/diff/spec/run-runtime-config.spec.js +87 -0
  155. package/dist/services/git/git-repository.d.ts +2 -0
  156. package/dist/services/git/git-repository.js +6 -0
  157. package/dist/services/integration-api/customer-config-flags.js +1 -0
  158. package/dist/services/onboarding/browse/browse-service.d.ts +13 -1
  159. package/dist/services/onboarding/browse/browse-service.js +40 -7
  160. package/dist/services/onboarding/browser/answer-dialogs.d.ts +12 -0
  161. package/dist/services/onboarding/browser/answer-dialogs.js +25 -0
  162. package/dist/services/onboarding/browser/baqend-response.d.ts +17 -1
  163. package/dist/services/onboarding/browser/baqend-response.js +23 -0
  164. package/dist/services/onboarding/browser/console-log.d.ts +9 -0
  165. package/dist/services/onboarding/browser/console-log.js +27 -0
  166. package/dist/services/onboarding/browser/emulate-device.d.ts +12 -1
  167. package/dist/services/onboarding/browser/emulate-device.js +33 -6
  168. package/dist/services/onboarding/browser/executable/executable-validator.js +4 -2
  169. package/dist/services/onboarding/browser/extension/extension-bridge.js +5 -3
  170. package/dist/services/onboarding/browser/extension/extension-downloader.js +17 -8
  171. package/dist/services/onboarding/browser/extension/extension-validator.js +9 -4
  172. package/dist/services/onboarding/browser/launch-browser.d.ts +2 -1
  173. package/dist/services/onboarding/browser/launch-browser.js +3 -1
  174. package/dist/services/onboarding/control/body-inspect.d.ts +24 -0
  175. package/dist/services/onboarding/control/body-inspect.js +106 -0
  176. package/dist/services/onboarding/control/browser-session.d.ts +535 -0
  177. package/dist/services/onboarding/control/browser-session.js +1300 -0
  178. package/dist/services/onboarding/control/config-validation.d.ts +17 -0
  179. package/dist/services/onboarding/control/config-validation.js +46 -0
  180. package/dist/services/onboarding/control/control-protocol.d.ts +1428 -0
  181. package/dist/services/onboarding/control/control-protocol.js +58 -0
  182. package/dist/services/onboarding/control/control-server.d.ts +292 -0
  183. package/dist/services/onboarding/control/control-server.js +1629 -0
  184. package/dist/services/onboarding/control/debug-session.d.ts +219 -0
  185. package/dist/services/onboarding/control/debug-session.js +897 -0
  186. package/dist/services/onboarding/control/fouc.d.ts +23 -0
  187. package/dist/services/onboarding/control/fouc.js +151 -0
  188. package/dist/services/onboarding/control/index.d.ts +4 -0
  189. package/dist/services/onboarding/control/index.js +4 -0
  190. package/dist/services/onboarding/control/navigate-wait.d.ts +33 -0
  191. package/dist/services/onboarding/control/navigate-wait.js +56 -0
  192. package/dist/services/onboarding/control/navwalk.d.ts +65 -0
  193. package/dist/services/onboarding/control/navwalk.js +248 -0
  194. package/dist/services/onboarding/control/preload-registry.d.ts +150 -0
  195. package/dist/services/onboarding/control/preload-registry.js +829 -0
  196. package/dist/services/onboarding/control/response-explainer.d.ts +24 -0
  197. package/dist/services/onboarding/control/response-explainer.js +257 -0
  198. package/dist/services/onboarding/control/rum.d.ts +8 -0
  199. package/dist/services/onboarding/control/rum.js +220 -0
  200. package/dist/services/onboarding/control/service-worker-tracker.d.ts +68 -0
  201. package/dist/services/onboarding/control/service-worker-tracker.js +120 -0
  202. package/dist/services/onboarding/control/viewport.d.ts +45 -0
  203. package/dist/services/onboarding/control/viewport.js +344 -0
  204. package/dist/services/onboarding/control/watch.d.ts +26 -0
  205. package/dist/services/onboarding/control/watch.js +157 -0
  206. package/dist/services/onboarding/dashboard/diff-against-current-page.js +3 -1
  207. package/dist/services/onboarding/dashboard/index.js +7 -2
  208. package/dist/services/onboarding/fetch-event-handler.d.ts +24 -5
  209. package/dist/services/onboarding/fetch-event-handler.js +103 -32
  210. package/dist/services/onboarding/fetch-events/speed-kit-install-js.js +11 -2
  211. package/dist/services/onboarding/fetch-events/speed-kit-rum-pi-request.d.ts +14 -0
  212. package/dist/services/onboarding/fetch-events/speed-kit-rum-pi-request.js +30 -0
  213. package/dist/services/onboarding/fetch-events/speed-kit-service-worker-js.d.ts +13 -0
  214. package/dist/services/onboarding/fetch-events/speed-kit-service-worker-js.js +28 -1
  215. package/dist/services/onboarding/file-events/file-watcher.d.ts +42 -1
  216. package/dist/services/onboarding/file-events/file-watcher.js +117 -12
  217. package/dist/services/onboarding/inject/inject-service.js +1 -1
  218. package/dist/services/onboarding/onboarding-model.d.ts +30 -0
  219. package/dist/services/onboarding/onboarding-model.js +12 -1
  220. package/dist/services/onboarding/onboarding-service-build-context.d.ts +4 -0
  221. package/dist/services/onboarding/onboarding-service-build-context.js +7 -1
  222. package/dist/services/onboarding/onboarding-service-factory.d.ts +17 -1
  223. package/dist/services/onboarding/onboarding-service-factory.js +150 -23
  224. package/dist/services/onboarding/onboarding-service.d.ts +40 -1
  225. package/dist/services/onboarding/onboarding-service.js +136 -23
  226. package/dist/services/onboarding/request-cache/asset-key.d.ts +61 -0
  227. package/dist/services/onboarding/request-cache/asset-key.js +115 -0
  228. package/dist/services/onboarding/request-cache/cache.d.ts +62 -5
  229. package/dist/services/onboarding/request-cache/cache.js +128 -17
  230. package/dist/services/onboarding/spec/browser/answer-dialogs.spec.d.ts +1 -0
  231. package/dist/services/onboarding/spec/browser/answer-dialogs.spec.js +66 -0
  232. package/dist/services/onboarding/spec/browser/console-log.spec.d.ts +1 -0
  233. package/dist/services/onboarding/spec/browser/console-log.spec.js +42 -0
  234. package/dist/services/onboarding/spec/control/browser-session.spec.d.ts +1 -0
  235. package/dist/services/onboarding/spec/control/browser-session.spec.js +651 -0
  236. package/dist/services/onboarding/spec/control/control-server.spec.d.ts +1 -0
  237. package/dist/services/onboarding/spec/control/control-server.spec.js +371 -0
  238. package/dist/services/onboarding/spec/control/debug-session.spec.d.ts +1 -0
  239. package/dist/services/onboarding/spec/control/debug-session.spec.js +751 -0
  240. package/dist/services/onboarding/spec/control/fakes.d.ts +31 -0
  241. package/dist/services/onboarding/spec/control/fakes.js +66 -0
  242. package/dist/services/onboarding/spec/control/fouc.spec.d.ts +1 -0
  243. package/dist/services/onboarding/spec/control/fouc.spec.js +167 -0
  244. package/dist/services/onboarding/spec/control/navigate-wait.spec.d.ts +1 -0
  245. package/dist/services/onboarding/spec/control/navigate-wait.spec.js +47 -0
  246. package/dist/services/onboarding/spec/control/navwalk.spec.d.ts +1 -0
  247. package/dist/services/onboarding/spec/control/navwalk.spec.js +222 -0
  248. package/dist/services/onboarding/spec/control/preload-registry.spec.d.ts +1 -0
  249. package/dist/services/onboarding/spec/control/preload-registry.spec.js +432 -0
  250. package/dist/services/onboarding/spec/control/response-explainer.spec.d.ts +1 -0
  251. package/dist/services/onboarding/spec/control/response-explainer.spec.js +324 -0
  252. package/dist/services/onboarding/spec/control/rum.spec.d.ts +1 -0
  253. package/dist/services/onboarding/spec/control/rum.spec.js +222 -0
  254. package/dist/services/onboarding/spec/control/service-worker-tracker.spec.d.ts +1 -0
  255. package/dist/services/onboarding/spec/control/service-worker-tracker.spec.js +193 -0
  256. package/dist/services/onboarding/spec/control/viewport.spec.d.ts +1 -0
  257. package/dist/services/onboarding/spec/control/viewport.spec.js +200 -0
  258. package/dist/services/onboarding/spec/control/watch.spec.d.ts +1 -0
  259. package/dist/services/onboarding/spec/control/watch.spec.js +187 -0
  260. package/dist/services/onboarding/spec/fetch-event-handler.spec.d.ts +1 -0
  261. package/dist/services/onboarding/spec/fetch-event-handler.spec.js +219 -0
  262. package/dist/services/onboarding/spec/fetch-events/speed-kit-service-worker-js.spec.d.ts +1 -0
  263. package/dist/services/onboarding/spec/fetch-events/speed-kit-service-worker-js.spec.js +41 -0
  264. package/dist/services/onboarding/spec/onboarding-model.spec.js +39 -3
  265. package/dist/services/onboarding/spec/onboarding-service-factory.spec.js +25 -1
  266. package/dist/services/onboarding/spec/request-cache/cache.spec.d.ts +1 -0
  267. package/dist/services/onboarding/spec/request-cache/cache.spec.js +107 -0
  268. package/dist/services/onboarding/spec/todo-collector.spec.d.ts +1 -0
  269. package/dist/services/onboarding/spec/todo-collector.spec.js +136 -0
  270. package/dist/services/onboarding/spec/virtual-orestes-app/virtual-orestes-app.spec.d.ts +1 -0
  271. package/dist/services/onboarding/spec/virtual-orestes-app/virtual-orestes-app.spec.js +65 -0
  272. package/dist/services/onboarding/todo-collector.d.ts +7 -2
  273. package/dist/services/onboarding/todo-collector.js +49 -12
  274. package/dist/services/onboarding/virtual-orestes-app/index.d.ts +38 -0
  275. package/dist/services/onboarding/virtual-orestes-app/index.js +113 -27
  276. package/dist/services/origin-request/asset-variations.d.ts +14 -0
  277. package/dist/services/origin-request/asset-variations.js +11 -4
  278. package/dist/services/origin-request/origin-fetcher.d.ts +7 -0
  279. package/dist/services/origin-request/origin-fetcher.js +43 -5
  280. package/dist/services/origin-request/origin-request-service-build-context.d.ts +17 -0
  281. package/dist/services/origin-request/origin-request-service-build-context.js +8 -0
  282. package/dist/services/origin-request/origin-request-service-factory.d.ts +0 -5
  283. package/dist/services/origin-request/origin-request-service-factory.js +2 -30
  284. package/dist/services/origin-request/origin-request-service.d.ts +121 -6
  285. package/dist/services/origin-request/origin-request-service.js +273 -49
  286. package/dist/services/origin-request/runtime-config-source.d.ts +6 -0
  287. package/dist/services/origin-request/runtime-config-source.js +15 -4
  288. package/dist/services/origin-request/spec/asset-variations.spec.js +20 -0
  289. package/dist/services/origin-request/spec/origin-request-service.spec.js +329 -6
  290. package/dist/services/query-builder/rules/rule-match.d.ts +35 -0
  291. package/dist/services/query-builder/rules/rule-match.js +70 -0
  292. package/dist/services/query-builder/spec/rules/rule-match.spec.d.ts +1 -0
  293. package/dist/services/query-builder/spec/rules/rule-match.spec.js +121 -0
  294. package/dist/services/run-control/browser/run-browser-contexts.d.ts +557 -0
  295. package/dist/services/run-control/browser/run-browser-contexts.js +91 -0
  296. package/dist/services/run-control/browser/run-browser-service-factory.d.ts +5 -0
  297. package/dist/services/run-control/browser/run-browser-service-factory.js +7 -0
  298. package/dist/services/run-control/browser/run-browser-service.d.ts +68 -0
  299. package/dist/services/run-control/browser/run-browser-service.js +206 -0
  300. package/dist/services/run-control/cache/run-cache-contexts.d.ts +349 -0
  301. package/dist/services/run-control/cache/run-cache-contexts.js +51 -0
  302. package/dist/services/run-control/cache/run-cache-service-factory.d.ts +6 -0
  303. package/dist/services/run-control/cache/run-cache-service-factory.js +12 -0
  304. package/dist/services/run-control/cache/run-cache-service.d.ts +35 -0
  305. package/dist/services/run-control/cache/run-cache-service.js +151 -0
  306. package/dist/services/run-control/control-client.d.ts +36 -0
  307. package/dist/services/run-control/control-client.js +147 -0
  308. package/dist/services/run-control/debug/run-debug-contexts.d.ts +416 -0
  309. package/dist/services/run-control/debug/run-debug-contexts.js +47 -0
  310. package/dist/services/run-control/debug/run-debug-service-factory.d.ts +5 -0
  311. package/dist/services/run-control/debug/run-debug-service-factory.js +7 -0
  312. package/dist/services/run-control/debug/run-debug-service.d.ts +39 -0
  313. package/dist/services/run-control/debug/run-debug-service.js +164 -0
  314. package/dist/services/run-control/files/run-files-contexts.d.ts +238 -0
  315. package/dist/services/run-control/files/run-files-contexts.js +26 -0
  316. package/dist/services/run-control/files/run-files-service-factory.d.ts +5 -0
  317. package/dist/services/run-control/files/run-files-service-factory.js +7 -0
  318. package/dist/services/run-control/files/run-files-service.d.ts +29 -0
  319. package/dist/services/run-control/files/run-files-service.js +120 -0
  320. package/dist/services/run-control/index.d.ts +32 -0
  321. package/dist/services/run-control/index.js +31 -0
  322. package/dist/services/run-control/inject/run-inject-contexts.d.ts +319 -0
  323. package/dist/services/run-control/inject/run-inject-contexts.js +38 -0
  324. package/dist/services/run-control/inject/run-inject-service-factory.d.ts +5 -0
  325. package/dist/services/run-control/inject/run-inject-service-factory.js +7 -0
  326. package/dist/services/run-control/inject/run-inject-service.d.ts +31 -0
  327. package/dist/services/run-control/inject/run-inject-service.js +227 -0
  328. package/dist/services/run-control/live-run.d.ts +37 -0
  329. package/dist/services/run-control/live-run.js +56 -0
  330. package/dist/services/run-control/probe/run-probe-contexts.d.ts +333 -0
  331. package/dist/services/run-control/probe/run-probe-contexts.js +73 -0
  332. package/dist/services/run-control/probe/run-probe-service-factory.d.ts +5 -0
  333. package/dist/services/run-control/probe/run-probe-service-factory.js +7 -0
  334. package/dist/services/run-control/probe/run-probe-service.d.ts +54 -0
  335. package/dist/services/run-control/probe/run-probe-service.js +194 -0
  336. package/dist/services/run-control/rum/run-rum-contexts.d.ts +216 -0
  337. package/dist/services/run-control/rum/run-rum-contexts.js +34 -0
  338. package/dist/services/run-control/rum/run-rum-service-factory.d.ts +5 -0
  339. package/dist/services/run-control/rum/run-rum-service-factory.js +7 -0
  340. package/dist/services/run-control/rum/run-rum-service.d.ts +36 -0
  341. package/dist/services/run-control/rum/run-rum-service.js +122 -0
  342. package/dist/services/run-control/run-answer.d.ts +28 -0
  343. package/dist/services/run-control/run-answer.js +58 -0
  344. package/dist/services/run-control/run-control-context.d.ts +102 -0
  345. package/dist/services/run-control/run-control-context.js +36 -0
  346. package/dist/services/run-control/run-control-flags.d.ts +12 -0
  347. package/dist/services/run-control/run-control-flags.js +22 -0
  348. package/dist/services/run-control/run-control-model.d.ts +9 -0
  349. package/dist/services/run-control/run-control-model.js +1 -0
  350. package/dist/services/run-control/run-control-service-factory.d.ts +14 -0
  351. package/dist/services/run-control/run-control-service-factory.js +26 -0
  352. package/dist/services/run-control/session/run-session-contexts.d.ts +25 -0
  353. package/dist/services/run-control/session/run-session-contexts.js +20 -0
  354. package/dist/services/run-control/session/run-session-service-factory.d.ts +8 -0
  355. package/dist/services/run-control/session/run-session-service-factory.js +18 -0
  356. package/dist/services/run-control/session/run-session-service.d.ts +32 -0
  357. package/dist/services/run-control/session/run-session-service.js +151 -0
  358. package/dist/services/run-control/spec/browser/run-browser-service.spec.d.ts +1 -0
  359. package/dist/services/run-control/spec/browser/run-browser-service.spec.js +327 -0
  360. package/dist/services/run-control/spec/cache/run-cache-service.spec.d.ts +1 -0
  361. package/dist/services/run-control/spec/cache/run-cache-service.spec.js +454 -0
  362. package/dist/services/run-control/spec/debug/run-debug-service.spec.d.ts +1 -0
  363. package/dist/services/run-control/spec/debug/run-debug-service.spec.js +113 -0
  364. package/dist/services/run-control/spec/files/run-files-service.spec.d.ts +1 -0
  365. package/dist/services/run-control/spec/files/run-files-service.spec.js +234 -0
  366. package/dist/services/run-control/spec/inject/run-inject-service.spec.d.ts +1 -0
  367. package/dist/services/run-control/spec/inject/run-inject-service.spec.js +251 -0
  368. package/dist/services/run-control/spec/live-run-fixture.d.ts +32 -0
  369. package/dist/services/run-control/spec/live-run-fixture.js +109 -0
  370. package/dist/services/run-control/spec/probe/run-probe-service.spec.d.ts +1 -0
  371. package/dist/services/run-control/spec/probe/run-probe-service.spec.js +108 -0
  372. package/dist/services/run-control/spec/rum/run-rum-service.spec.d.ts +1 -0
  373. package/dist/services/run-control/spec/rum/run-rum-service.spec.js +47 -0
  374. package/dist/services/run-control/spec/run-answer.spec.d.ts +1 -0
  375. package/dist/services/run-control/spec/run-answer.spec.js +57 -0
  376. package/dist/services/run-control/spec/session/run-session-service.spec.d.ts +1 -0
  377. package/dist/services/run-control/spec/session/run-session-service.spec.js +150 -0
  378. package/dist/services/run-log/crash-mirror.d.ts +31 -0
  379. package/dist/services/run-log/crash-mirror.js +69 -0
  380. package/dist/services/run-log/index.d.ts +11 -0
  381. package/dist/services/run-log/index.js +11 -0
  382. package/dist/services/run-log/jsonl-appender.d.ts +46 -0
  383. package/dist/services/run-log/jsonl-appender.js +91 -0
  384. package/dist/services/run-log/log-event-model.d.ts +104 -0
  385. package/dist/services/run-log/log-event-model.js +56 -0
  386. package/dist/services/run-log/log-query-service-factory.d.ts +11 -0
  387. package/dist/services/run-log/log-query-service-factory.js +14 -0
  388. package/dist/services/run-log/log-query-service.d.ts +59 -0
  389. package/dist/services/run-log/log-query-service.js +111 -0
  390. package/dist/services/run-log/log-reader.d.ts +84 -0
  391. package/dist/services/run-log/log-reader.js +180 -0
  392. package/dist/services/run-log/log-summary.d.ts +72 -0
  393. package/dist/services/run-log/log-summary.js +208 -0
  394. package/dist/services/run-log/redaction.d.ts +34 -0
  395. package/dist/services/run-log/redaction.js +124 -0
  396. package/dist/services/run-log/request-log.d.ts +82 -0
  397. package/dist/services/run-log/request-log.js +69 -0
  398. package/dist/services/run-log/request-summary.d.ts +76 -0
  399. package/dist/services/run-log/request-summary.js +0 -0
  400. package/dist/services/run-log/run-log.d.ts +61 -0
  401. package/dist/services/run-log/run-log.js +102 -0
  402. package/dist/services/run-log/spec/log-query-service.spec.d.ts +1 -0
  403. package/dist/services/run-log/spec/log-query-service.spec.js +197 -0
  404. package/dist/services/run-log/spec/log-reader.spec.d.ts +1 -0
  405. package/dist/services/run-log/spec/log-reader.spec.js +109 -0
  406. package/dist/services/run-log/spec/log-summary.spec.d.ts +1 -0
  407. package/dist/services/run-log/spec/log-summary.spec.js +153 -0
  408. package/dist/services/run-log/spec/redaction.spec.d.ts +1 -0
  409. package/dist/services/run-log/spec/redaction.spec.js +61 -0
  410. package/dist/services/run-log/spec/request-log.spec.d.ts +1 -0
  411. package/dist/services/run-log/spec/request-log.spec.js +101 -0
  412. package/dist/services/run-log/spec/request-summary.spec.d.ts +1 -0
  413. package/dist/services/run-log/spec/request-summary.spec.js +171 -0
  414. package/dist/services/run-log/spec/run-log.spec.d.ts +1 -0
  415. package/dist/services/run-log/spec/run-log.spec.js +122 -0
  416. package/dist/services/run-registry/exit-classification.d.ts +39 -0
  417. package/dist/services/run-registry/exit-classification.js +42 -0
  418. package/dist/services/run-registry/index.d.ts +3 -0
  419. package/dist/services/run-registry/index.js +3 -0
  420. package/dist/services/run-registry/process-identity.d.ts +28 -0
  421. package/dist/services/run-registry/process-identity.js +80 -0
  422. package/dist/services/run-registry/run-registry-model.d.ts +128 -0
  423. package/dist/services/run-registry/run-registry-model.js +16 -0
  424. package/dist/services/run-registry/run-registry.d.ts +155 -0
  425. package/dist/services/run-registry/run-registry.js +430 -0
  426. package/dist/services/run-registry/spec/exit-classification.spec.d.ts +1 -0
  427. package/dist/services/run-registry/spec/exit-classification.spec.js +82 -0
  428. package/dist/services/run-registry/spec/run-registry.spec.d.ts +1 -0
  429. package/dist/services/run-registry/spec/run-registry.spec.js +526 -0
  430. package/dist/services/setup/os/tool-registry.js +2 -2
  431. package/oclif.manifest.json +3409 -288
  432. package/package.json +20 -2
@@ -0,0 +1,24 @@
1
+ import { ParsedRuleSets } from "../../query-builder/rules/rule-model.js";
2
+ import { ResponseExplainData, ResponseCacheFacts, ResponsePageFacts } from "./control-protocol.js";
3
+ export interface ExplainInput {
4
+ url: URL;
5
+ rules: ParsedRuleSets;
6
+ cache?: ResponseCacheFacts;
7
+ page?: ResponsePageFacts;
8
+ }
9
+ /**
10
+ * Why did this URL come back the way it did.
11
+ *
12
+ * The question a config raises is never "what is in the cache", it is "why was
13
+ * this page not accelerated" — and the answer is scattered across the rule
14
+ * sets, the cache, and what Speed Kit reported on the page. Each of those is
15
+ * reachable on its own already; none of them answers the question alone, and
16
+ * putting them side by side is most of the work.
17
+ *
18
+ * Nothing here guesses. Where a rule carries a criterion outside the URL, or
19
+ * where the page was not observed, the result says so rather than filling the
20
+ * gap.
21
+ */
22
+ export declare function explainResponse(input: ExplainInput): ResponseExplainData;
23
+ /** Whether a cached body carries the documentHandler's asset list. */
24
+ export declare function hasAssetList(body: string): boolean;
@@ -0,0 +1,257 @@
1
+ import { matchRules } from "../../query-builder/rules/rule-match.js";
2
+ import { DOCUMENT_CONTENT_TYPES, } from "../../query-builder/rules/rule-model.js";
3
+ /**
4
+ * The marker the documentHandler bakes into the HTML it transforms.
5
+ *
6
+ * Change detection compares the *cached* asset list against the live one, and
7
+ * the cached side is not read from the DOM — it comes from this call. If the
8
+ * DH never ran, the call is absent and the comparison returns early with
9
+ * nothing, which reads exactly like "no changes" and is not the same thing.
10
+ */
11
+ const ASSET_LIST_MARKER = "setAssetList(";
12
+ /**
13
+ * Why did this URL come back the way it did.
14
+ *
15
+ * The question a config raises is never "what is in the cache", it is "why was
16
+ * this page not accelerated" — and the answer is scattered across the rule
17
+ * sets, the cache, and what Speed Kit reported on the page. Each of those is
18
+ * reachable on its own already; none of them answers the question alone, and
19
+ * putting them side by side is most of the work.
20
+ *
21
+ * Nothing here guesses. Where a rule carries a criterion outside the URL, or
22
+ * where the page was not observed, the result says so rather than filling the
23
+ * gap.
24
+ */
25
+ export function explainResponse(input) {
26
+ const rules = judgeRules(input.url, input.rules);
27
+ // Resolved once and handed to both. The explanation and the notes used to
28
+ // re-derive it from `responseSource` themselves, so a page whose source was
29
+ // not the literal string `Origin` took the cache branch in three places
30
+ // independently — and a bfcached origin page took it in all three.
31
+ const served = servedFrom(input);
32
+ const notes = collectNotes(input, rules, served);
33
+ return {
34
+ url: input.url.href,
35
+ servedFrom: served,
36
+ replayedFromBfCache: replayedFromBfCache(input),
37
+ rules,
38
+ cache: input.cache,
39
+ page: input.page,
40
+ explanation: explain(input, rules, served),
41
+ notes,
42
+ };
43
+ }
44
+ /**
45
+ * Rules that can apply to a navigation.
46
+ *
47
+ * A rule restricted to `script`, `style` or `font` never decides a document
48
+ * request, and the runtime passes `contentType` into every `RuleSet.matches`
49
+ * call. Reading the sets without it reports a font rule as matching a page —
50
+ * and, the way round that actually bit, a `contentType: ["navigate"]`
51
+ * whitelist entry as matching a script. Mirrors the same test in
52
+ * `keepRelevantRules`.
53
+ */
54
+ function forNavigation(rules) {
55
+ return rules.filter((rule) => !rule.contentTypes ||
56
+ rule.contentTypes.some((type) => DOCUMENT_CONTENT_TYPES.includes(type)));
57
+ }
58
+ /**
59
+ * Which rule set decided, in the order Speed Kit applies them.
60
+ *
61
+ * `disabledScopes` first because it is not a rule set at all — it is a list of
62
+ * path prefixes the service worker never claims, so nothing downstream of it
63
+ * runs. Then the page sets, then the resource sets.
64
+ *
65
+ * **This judges the url as a navigation**, which is what `appliesAs` reports.
66
+ * The runtime splits on it: `Application.checkWhitelist` returns before
67
+ * `enabledSites` for anything that is not a navigate request, and
68
+ * `disabledSites` is gated the same way, so both sets decide pages only. A
69
+ * reading that applied them to every url answered "excluded by enabledSites"
70
+ * for a script the runtime excludes by `whitelist` — or, where the whitelist
71
+ * carries no content type, for one it accelerates.
72
+ */
73
+ function judgeRules(url, sets) {
74
+ const disabledScopes = matchRules(sets.disabledScopes, url);
75
+ const enabledSites = matchRules(forNavigation(sets.enabledSites), url);
76
+ const disabledSites = matchRules(forNavigation(sets.disabledSites), url);
77
+ const whitelist = matchRules(forNavigation(sets.whitelist), url);
78
+ const blacklist = matchRules(forNavigation(sets.blacklist), url);
79
+ const verdict = {
80
+ disabledScopes: sources(disabledScopes),
81
+ enabledSites: sources(enabledSites),
82
+ disabledSites: sources(disabledSites),
83
+ whitelist: sources(whitelist),
84
+ blacklist: sources(blacklist),
85
+ // A set that is empty in the config means "no restriction", which is a
86
+ // different thing from "restricts nothing here" and changes how every
87
+ // other line reads.
88
+ enabledSitesConfigured: sets.enabledSites.length > 0,
89
+ whitelistConfigured: sets.whitelist.length > 0,
90
+ uncertain: [
91
+ ...disabledScopes,
92
+ ...enabledSites,
93
+ ...disabledSites,
94
+ ...whitelist,
95
+ ...blacklist,
96
+ ]
97
+ .filter((hit) => hit.uncertain)
98
+ .map((hit) => hit.source),
99
+ appliesAs: "navigate",
100
+ navigationOnlySets: ["enabledSites", "disabledSites"],
101
+ };
102
+ if (disabledScopes.length > 0) {
103
+ return { ...verdict, decision: "excluded", decidedBy: "disabledScopes" };
104
+ }
105
+ if (sets.enabledSites.length > 0 && enabledSites.length === 0) {
106
+ return { ...verdict, decision: "excluded", decidedBy: "enabledSites" };
107
+ }
108
+ if (disabledSites.length > 0) {
109
+ return { ...verdict, decision: "excluded", decidedBy: "disabledSites" };
110
+ }
111
+ if (blacklist.length > 0) {
112
+ return { ...verdict, decision: "excluded", decidedBy: "blacklist" };
113
+ }
114
+ if (sets.whitelist.length > 0 && whitelist.length === 0) {
115
+ return { ...verdict, decision: "excluded", decidedBy: "whitelist" };
116
+ }
117
+ return { ...verdict, decision: "included", decidedBy: null };
118
+ }
119
+ function sources(hits) {
120
+ return hits.map((hit) => hit.source);
121
+ }
122
+ /**
123
+ * The response sources that mean Speed Kit served the bytes.
124
+ *
125
+ * Enumerated rather than derived by exclusion, because the two are not the same
126
+ * thing and the difference is the whole of this function's history. Speed Kit
127
+ * ships fifteen `ResponseSource` values and `fromAssetAPI()` is the authority
128
+ * for nine of them; `SwCache`, `SDN` and `Recompress` are the three more that
129
+ * still came from Speed Kit. `Generated`, `Origin` and `BfCache` did not, and
130
+ * each of those is handled on its own below.
131
+ */
132
+ const SPEED_KIT_SOURCES = new Set([
133
+ // fromAssetAPI(), in the order speed-kit lists it.
134
+ "Edge",
135
+ "AssetAPI",
136
+ "Stream",
137
+ "Collapsed",
138
+ "Shield",
139
+ "Storage",
140
+ "PendingAsset",
141
+ "MissingCachingHeader",
142
+ "Prerender",
143
+ // Speed Kit's own, outside the asset API.
144
+ "SwCache",
145
+ "SDN",
146
+ "Recompress",
147
+ ]);
148
+ /**
149
+ * What actually served it, as opposed to what the rules permit.
150
+ *
151
+ * `unknown` is a real answer here and the common one: the tool is usually asked
152
+ * about a URL that is not the page in front of it, and a cache entry proves the
153
+ * documentHandler handled it once, not that this response came from there.
154
+ *
155
+ * It is also the answer for a source this does not recognise. That is the
156
+ * correction: this used to read `responseSource === "Origin" ? "origin" :
157
+ * "cache"`, which made `cache` the default for fourteen of the fifteen sources
158
+ * and for anything Speed Kit adds later. An unrecognised source is something we
159
+ * do not know about, and saying so costs a reader one lookup — saying `cache`
160
+ * costs them the whole origin half of the explanation.
161
+ */
162
+ function servedFrom(input) {
163
+ const source = input.page?.responseSource;
164
+ if (!source) {
165
+ return "unknown";
166
+ }
167
+ if (source === "BfCache") {
168
+ // The browser replayed a page it had already loaded, so the source that
169
+ // matters is where those bytes came from the first time — which is exactly
170
+ // what `BfCacheResponseCause` records. Reported as the underlying source,
171
+ // with `replayedFromBfCache` saying how it got here, so an origin-served
172
+ // page that came back through the bfcache still reaches the origin branch
173
+ // of the explanation and its notes.
174
+ if (input.page.responseCause === "Origin") {
175
+ return "origin";
176
+ }
177
+ return input.page.responseCause === "AssetAPI" ? "cache" : "unknown";
178
+ }
179
+ if (source === "Generated") {
180
+ // Speed Kit synthesised this — an error page, a redirect. Neither the
181
+ // origin's bytes nor a cached copy of them, and calling it either is how a
182
+ // reader ends up debugging a cache that was never involved.
183
+ return "generated";
184
+ }
185
+ if (source === "Origin") {
186
+ return "origin";
187
+ }
188
+ return SPEED_KIT_SOURCES.has(source) ? "cache" : "unknown";
189
+ }
190
+ /** Whether the browser replayed this from its back/forward cache. */
191
+ function replayedFromBfCache(input) {
192
+ return input.page?.responseSource === "BfCache" ? true : undefined;
193
+ }
194
+ function explain(input, rules, served) {
195
+ if (rules.decision === "excluded") {
196
+ const named = rules[rules.decidedBy];
197
+ const by = named.length > 0
198
+ ? `${rules.decidedBy} (${named.join(", ")})`
199
+ : `${rules.decidedBy}, which is configured and matches nothing here`;
200
+ return `Speed Kit does not handle this url: ${by}.`;
201
+ }
202
+ if (served === "origin") {
203
+ const replayed = replayedFromBfCache(input)
204
+ ? ", replayed from the browser's back/forward cache"
205
+ : "";
206
+ return `The rules allow this url, but it was served from origin${replayed} (${input.page.responseCause ?? "no responseCause reported"}).`;
207
+ }
208
+ if (served === "generated") {
209
+ return `The rules allow this url, but Speed Kit generated this response itself rather than serving the page — an error or a redirect (${input.page.responseCause ?? "no responseCause reported"}).`;
210
+ }
211
+ if (served === "unknown" && input.page) {
212
+ // Observed, but by a source this build does not know. Saying so is the
213
+ // point: a newer Speed Kit can report one, and a confident wrong branch
214
+ // here is worse than an honest gap.
215
+ return `The rules allow this url. It was served from \`${input.page.responseSource}\`, which this build does not recognise, so whether Speed Kit or the origin answered is not decided here.`;
216
+ }
217
+ if (input.cache) {
218
+ return "The rules allow this url and the documentHandler has a cached entry for it.";
219
+ }
220
+ return "The rules allow this url. Nothing has been cached for it yet, so no page has gone through the local documentHandler.";
221
+ }
222
+ /**
223
+ * The traps, stated only when the observations actually support them.
224
+ *
225
+ * Each of these has cost a debugging session, and each reads as a broken config
226
+ * when it is not one.
227
+ */
228
+ function collectNotes(input, rules, served) {
229
+ const notes = [];
230
+ // Stated on every answer, because it is an assumption and not an
231
+ // observation: a url does not say whether it was fetched as a document, a
232
+ // script or an image, and the runtime decides partly on that. Left unsaid,
233
+ // every verdict here reads as though it covered sub-resources too.
234
+ notes.push(rules.navigationOnlySets.includes(rules.decidedBy)
235
+ ? `Judged as a navigation, and ${rules.decidedBy} decided it — a set the runtime consults for pages only. The same url fetched as a script, image or font is not excluded by it.`
236
+ : `Judged as a navigation. ${rules.navigationOnlySets.join(" and ")} decide pages only, and rules restricted to another content type were left out, so the verdict for the same url fetched as a script, image or font can differ.`);
237
+ if (served === "origin") {
238
+ notes.push("On an origin-served page the dynamic fetcher never runs, so change detection compares nothing and its output is empty. That is not a broken config — the first load after a start often serves from origin, so reload once and ask again.");
239
+ }
240
+ if (replayedFromBfCache(input)) {
241
+ notes.push("The browser replayed this from its back/forward cache, so nothing was fetched for it now. `servedFrom` names where the bytes came from when the page was first loaded, which is what `responseCause` records for a bfcache hit — measure again on a fresh navigation before concluding anything about the current config.");
242
+ }
243
+ if (input.cache && !input.cache.assetList) {
244
+ notes.push(`The cached body carries no ${ASSET_LIST_MARKER} call, so the cached side of a change-detection comparison is empty and the comparison returns early. The asset list is baked into the HTML by the documentHandler, not read from the DOM.`);
245
+ }
246
+ if (rules.uncertain.length > 0) {
247
+ notes.push(`These rules carry a criterion outside the url — a cookie, a device, a storage value — so their verdict here is a maximum rather than an answer: ${rules.uncertain.join(", ")}.`);
248
+ }
249
+ if (!input.page) {
250
+ notes.push("This url is not the page in front of the run, so nothing observed it being served. The rule verdict stands on its own; `servedFrom` does not.");
251
+ }
252
+ return notes;
253
+ }
254
+ /** Whether a cached body carries the documentHandler's asset list. */
255
+ export function hasAssetList(body) {
256
+ return body.includes(ASSET_LIST_MARKER);
257
+ }
@@ -0,0 +1,8 @@
1
+ import { PageEvaluator } from "./browser-session.js";
2
+ import { RumData } from "./control-protocol.js";
3
+ export declare function readRum(session: PageEvaluator, request: {
4
+ keys?: string[];
5
+ flush?: boolean;
6
+ key?: string;
7
+ previous?: boolean;
8
+ }): Promise<RumData>;
@@ -0,0 +1,220 @@
1
+ /**
2
+ * Speed Kit's globals, read defensively.
3
+ *
4
+ * They are not always there, and the reasons are worth distinguishing from a
5
+ * bug: the page is **still booting** — much the commonest, and the only one that
6
+ * fixes itself — an older Speed Kit build, or a customer whose own JS strips the
7
+ * globals after merge. The last is a customer-specific anomaly rather than
8
+ * anything general about SSR. Every one of them is a reportable condition with a
9
+ * named cause, not a failure.
10
+ *
11
+ * All five booleans are reported to the caller as {@link RumData.globals}. They
12
+ * are measurements; the reason string is an inference from one of them, and a
13
+ * reader who needs to tell "absent" from "half-built" should not have to parse
14
+ * prose to do it.
15
+ */
16
+ const PRESENCE = `(() => {
17
+ const sk = window.SpeedKit;
18
+ const controller = sk && sk.rumController;
19
+ const impression = controller && controller.currentRumImpression;
20
+ return {
21
+ present: Boolean(sk),
22
+ trackedData: Boolean(sk && typeof sk.getTrackedData === "function"),
23
+ rumController: Boolean(controller),
24
+ impression: Boolean(impression),
25
+ dataByKey: Boolean(impression && typeof impression.getDataByKey === "function"),
26
+ };
27
+ })()`;
28
+ /**
29
+ * What `getTrackedData()` returns is `init` plus `sentTracking` — **the unsent
30
+ * data is not in it**.
31
+ *
32
+ * `sentTracking` is `Object.create(this.init)` and `getTrackedData` copies own
33
+ * properties of each; `unsentTracking` is never consulted. So anything tracked
34
+ * since the last beacon is invisible here — which is exactly the state you are
35
+ * in right after triggering the interaction you were trying to verify.
36
+ *
37
+ * Hence `flushed` on every result. Silently returning stale data is how this
38
+ * would produce confident wrong answers.
39
+ */
40
+ const TRACKED_DATA = `(() => {
41
+ const sk = window.SpeedKit;
42
+ if (!sk || typeof sk.getTrackedData !== "function") return null;
43
+ return sk.getTrackedData();
44
+ })()`;
45
+ /** Forces a send so the read sees everything — at the cost of ending an impression. */
46
+ const FLUSH = `(() => {
47
+ const sk = window.SpeedKit;
48
+ if (sk && sk.rumController && typeof sk.rumController.sendCollapsed === "function") {
49
+ sk.rumController.sendCollapsed();
50
+ return true;
51
+ }
52
+ return false;
53
+ })()`;
54
+ /**
55
+ * `getDataByKey` **does** merge unsent with sent, concatenating when both are
56
+ * arrays.
57
+ *
58
+ * That makes it the targeted "did my custom dimension land" check, and it works
59
+ * without forcing a send — which matters when forcing one would end the
60
+ * impression being measured.
61
+ *
62
+ * It is a method of **RumImpression**, not of the controller. Reading it off
63
+ * `rumController` returns undefined on every build, and guarding that with a
64
+ * bare `return null` made a missing method indistinguishable from an absent
65
+ * value — so the tool answered "your dimension did not land" for every field,
66
+ * which is the worst answer it could give. The result is now tagged, and the
67
+ * presence probe reports which of the two it is.
68
+ */
69
+ const dataByKey = (name) => `(() => {
70
+ const controller = window.SpeedKit && window.SpeedKit.rumController;
71
+ const impression = controller && controller.currentRumImpression;
72
+ if (!impression || typeof impression.getDataByKey !== "function") {
73
+ return { status: "no-method" };
74
+ }
75
+ return { status: "ok", value: impression.getDataByKey(${JSON.stringify(name)}) };
76
+ })()`;
77
+ /**
78
+ * The previous page impression.
79
+ *
80
+ * `getTrackedData` forwards to `currentRumImpression`, and on a soft navigation
81
+ * that is not the hard nav — the two can be different instances. On an SPA
82
+ * customer the current impression is not the one that loaded the page.
83
+ */
84
+ const PREVIOUS = `(() => {
85
+ const sk = window.SpeedKit;
86
+ if (!sk || !sk.rumController || typeof sk.rumController.getPreviousRumImpression !== "function") return null;
87
+ const previous = sk.rumController.getPreviousRumImpression();
88
+ return previous ? previous.getTrackedData() : null;
89
+ })()`;
90
+ const NO_PRESENCE = {
91
+ present: false,
92
+ trackedData: false,
93
+ rumController: false,
94
+ impression: false,
95
+ dataByKey: false,
96
+ };
97
+ /**
98
+ * Why the globals cannot be read, hedged in the order the causes are likely.
99
+ *
100
+ * The wording matters more than it looks. This used to open with "SpeedKit is
101
+ * not on this page", which reads as a settled finding, and put "may not have
102
+ * installed yet" behind it — so a reader mid-page-load was told the conclusion
103
+ * first and the true cause second. A test session duly read it, concluded the
104
+ * page had no Speed Kit, and abandoned a check that needed only another minute.
105
+ * Booting now leads, because it is both the commonest cause and the only one
106
+ * that resolves on its own.
107
+ *
108
+ * The second branch could not name booting at all: a page a few hundred ms in,
109
+ * with `window.SpeedKit` up but `getTrackedData` not yet attached, was told it
110
+ * was running an older build or that the customer strips globals. Both wrong,
111
+ * and neither hedged.
112
+ */
113
+ function absent(globals) {
114
+ return {
115
+ available: false,
116
+ reason: globals.present
117
+ ? "Speed Kit is on the page but exposes no getTrackedData yet — it may still be booting, or this is an older build, or a customer whose own JS strips the globals after merge."
118
+ : "no window.SpeedKit on the page yet — it may still be booting, the page may be served from origin, or Speed Kit may not be installed on it.",
119
+ globals,
120
+ flushed: false,
121
+ url: null,
122
+ };
123
+ }
124
+ export async function readRum(session, request) {
125
+ const presence = await session.evaluate(PRESENCE);
126
+ if (!presence?.trackedData) {
127
+ return {
128
+ ...absent(presence ?? NO_PRESENCE),
129
+ url: session.url(),
130
+ };
131
+ }
132
+ if (request.key) {
133
+ if (!presence.impression) {
134
+ return {
135
+ available: false,
136
+ reason: "Speed Kit has no current page impression yet — nothing has been tracked on this page.",
137
+ globals: presence,
138
+ flushed: false,
139
+ url: session.url(),
140
+ };
141
+ }
142
+ if (!presence.dataByKey) {
143
+ return {
144
+ available: false,
145
+ reason: "This Speed Kit build's RumImpression has no getDataByKey. Use `get` instead, which reads sent data.",
146
+ globals: presence,
147
+ flushed: false,
148
+ url: session.url(),
149
+ };
150
+ }
151
+ // No flush: this path already sees unsent data, and forcing a send would
152
+ // end the impression the caller is measuring.
153
+ const answer = await session.evaluate(dataByKey(request.key));
154
+ if (answer?.status !== "ok") {
155
+ return {
156
+ available: false,
157
+ reason: "getDataByKey vanished between the probe and the read — the page probably navigated.",
158
+ globals: presence,
159
+ flushed: false,
160
+ url: session.url(),
161
+ };
162
+ }
163
+ return {
164
+ available: true,
165
+ flushed: false,
166
+ url: session.url(),
167
+ key: request.key,
168
+ // Explicitly null rather than omitted: an absent key is a real answer,
169
+ // and dropping the field made the summary read "undefined".
170
+ value: answer.value ?? null,
171
+ mergesUnsent: true,
172
+ };
173
+ }
174
+ if (request.previous) {
175
+ const data = await session.evaluate(PREVIOUS);
176
+ return {
177
+ available: true,
178
+ flushed: false,
179
+ url: session.url(),
180
+ ofPreviousImpression: true,
181
+ data: data ?? null,
182
+ };
183
+ }
184
+ const flushed = request.flush
185
+ ? await session.evaluate(FLUSH)
186
+ : false;
187
+ const data = await session.evaluate(TRACKED_DATA);
188
+ const picked = pick(data, request.keys);
189
+ return {
190
+ available: true,
191
+ flushed,
192
+ url: session.url(),
193
+ data: picked.data,
194
+ keys: data ? Object.keys(data) : [],
195
+ notTracked: picked.notTracked,
196
+ };
197
+ }
198
+ /**
199
+ * Narrow the tracked object to the fields that were asked for.
200
+ *
201
+ * A key that is not there comes back as `null` rather than being dropped, and
202
+ * every such key is named in `notTracked`. Filtering them out meant six keys in
203
+ * and five fields out with nothing said about the sixth, so a reader had to
204
+ * diff the request against the response to notice — and three test sessions in
205
+ * a row did not. It is the same rule the single-key path already follows: an
206
+ * absent key is an answer, not a gap.
207
+ *
208
+ * This reads sent data only, so `null` here means "not sent yet or not tracked".
209
+ * `key` is the one that can tell those apart.
210
+ */
211
+ function pick(data, keys) {
212
+ if (!data || !keys?.length) {
213
+ return { data };
214
+ }
215
+ const notTracked = keys.filter((key) => !(key in data));
216
+ return {
217
+ data: Object.fromEntries(keys.map((key) => [key, key in data ? data[key] : null])),
218
+ notTracked: notTracked.length ? notTracked : undefined,
219
+ };
220
+ }
@@ -0,0 +1,68 @@
1
+ import type { Protocol } from "puppeteer";
2
+ import { ServiceWorkerState } from "./control-protocol.js";
3
+ /**
4
+ * What service workers the run has seen, kept because nothing can ask.
5
+ *
6
+ * CDP has no "list the registrations" command — `ServiceWorker.enable` starts a
7
+ * stream of `workerRegistrationUpdated` and `workerVersionUpdated` events and
8
+ * that is the only source. A reader arriving later, which every run command is,
9
+ * has missed them. So the run keeps the latest state as it goes.
10
+ *
11
+ * Asking the page instead (`navigator.serviceWorker.getRegistrations()`) looks
12
+ * simpler and answers a different question: it reports scope and script url but
13
+ * no version id and no history, so it cannot tell a locally installed worker
14
+ * from the deployed one that replaced it. That distinction is the reason this
15
+ * exists — a takeover is silent, and with static routing it freezes the routes
16
+ * from the *deployed* config, so locally enabled pages bypass the worker
17
+ * entirely and every navigation reports `SwBooting`. Hours have gone into
18
+ * diagnosing that from the symptom.
19
+ */
20
+ export declare class ServiceWorkerTracker {
21
+ private readonly registrations;
22
+ private readonly versions;
23
+ private takeovers;
24
+ private lastTakeoverAt?;
25
+ /** From `ServiceWorker.workerRegistrationUpdated`. */
26
+ recordRegistrations(registrations: Protocol.ServiceWorker.ServiceWorkerRegistration[]): void;
27
+ /** From `ServiceWorker.workerVersionUpdated`. */
28
+ recordVersions(versions: Protocol.ServiceWorker.ServiceWorkerVersion[]): void;
29
+ /**
30
+ * The run decided a deployed worker took over.
31
+ *
32
+ * Recorded rather than derived: the decision needs `lastServedAt` from the
33
+ * local sw.js route, which lives in the run and not here. This only keeps the
34
+ * verdict so a reader can see it after the fact.
35
+ */
36
+ recordTakeover(versionId: string): void;
37
+ /**
38
+ * What is installed, and which of it is in charge of `pageUrl`.
39
+ *
40
+ * The active version has to be chosen against the page, not off the top of
41
+ * the list. This used to be `versions.find(v => v.status === "activated")` —
42
+ * the first activated version in insertion order, across every registration
43
+ * — and on a shop with scoped workers that is never the page's own. atida
44
+ * registers six (`/basket`, `/checkout`, `/login`, …) and the answer was
45
+ * always the customer's empty `wrapper-sw.js` on `/basket`, through two
46
+ * reinstalls that each replaced the worker actually serving the page.
47
+ *
48
+ * `foreign` is read off this version, so picking the wrong one hid the
49
+ * takeover this tracker exists to report: the run marks the right version in
50
+ * {@link recordTakeover}, and the flag was then read from a different one
51
+ * that nobody had marked. `takeovers` still counted, which is the only
52
+ * reason it was visible at all.
53
+ */
54
+ state(pageUrl?: string | null): ServiceWorkerState;
55
+ /**
56
+ * The activated worker controlling this url.
57
+ *
58
+ * A registration controls a url when its scope is a prefix of it, and the
59
+ * narrowest matching scope wins — the rule the browser itself applies, so a
60
+ * page under `/basket` is answered by the `/basket` worker and the homepage
61
+ * by the root one. A deleted registration controls nothing.
62
+ *
63
+ * `undefined` is a real answer: mid-reinstall the new version is still
64
+ * `activating` and no activated worker controls the page. Falling back to
65
+ * "any activated version" would put the original bug back, quietly.
66
+ */
67
+ private activeVersionFor;
68
+ }