@speedkit/cli 4.51.1 → 4.52.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 (442) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/README.md +1426 -14
  3. package/dist/base/run-control-command.d.ts +15 -0
  4. package/dist/base/run-control-command.js +20 -0
  5. package/dist/build-info.json +6 -0
  6. package/dist/commands/diff.d.ts +7 -1
  7. package/dist/commands/diff.js +9 -3
  8. package/dist/commands/login.d.ts +3 -0
  9. package/dist/commands/login.js +14 -3
  10. package/dist/commands/onboarding/browser/click.d.ts +75 -0
  11. package/dist/commands/onboarding/browser/click.js +19 -0
  12. package/dist/commands/onboarding/browser/emulate.d.ts +105 -0
  13. package/dist/commands/onboarding/browser/emulate.js +26 -0
  14. package/dist/commands/onboarding/browser/navigate.d.ts +75 -0
  15. package/dist/commands/onboarding/browser/navigate.js +19 -0
  16. package/dist/commands/onboarding/browser/panel.d.ts +63 -0
  17. package/dist/commands/onboarding/browser/panel.js +12 -0
  18. package/dist/commands/onboarding/browser/reinstall-sw.d.ts +63 -0
  19. package/dist/commands/onboarding/browser/reinstall-sw.js +14 -0
  20. package/dist/commands/onboarding/browser/reset.d.ts +71 -0
  21. package/dist/commands/onboarding/browser/reset.js +18 -0
  22. package/dist/commands/onboarding/browser/screenshot.d.ts +77 -0
  23. package/dist/commands/onboarding/browser/screenshot.js +19 -0
  24. package/dist/commands/onboarding/browser/state.d.ts +63 -0
  25. package/dist/commands/onboarding/browser/state.js +12 -0
  26. package/dist/commands/onboarding/browser/tabs.d.ts +58 -0
  27. package/dist/commands/onboarding/browser/tabs.js +16 -0
  28. package/dist/commands/onboarding/cache/clear.d.ts +58 -0
  29. package/dist/commands/onboarding/cache/clear.js +12 -0
  30. package/dist/commands/onboarding/cache/errors.d.ts +58 -0
  31. package/dist/commands/onboarding/cache/errors.js +12 -0
  32. package/dist/commands/onboarding/cache/evict.d.ts +62 -0
  33. package/dist/commands/onboarding/cache/evict.js +15 -0
  34. package/dist/commands/onboarding/cache/get.d.ts +85 -0
  35. package/dist/commands/onboarding/cache/get.js +17 -0
  36. package/dist/commands/onboarding/cache/list.d.ts +58 -0
  37. package/dist/commands/onboarding/cache/list.js +15 -0
  38. package/dist/commands/onboarding/cache/prewarm.d.ts +73 -0
  39. package/dist/commands/onboarding/cache/prewarm.js +20 -0
  40. package/dist/commands/onboarding/cache/refresh.d.ts +62 -0
  41. package/dist/commands/onboarding/cache/refresh.js +18 -0
  42. package/dist/commands/onboarding/cdp.d.ts +81 -0
  43. package/dist/commands/onboarding/cdp.js +18 -0
  44. package/dist/commands/onboarding/debug/arm.d.ts +83 -0
  45. package/dist/commands/onboarding/debug/arm.js +19 -0
  46. package/dist/commands/onboarding/debug/await.d.ts +71 -0
  47. package/dist/commands/onboarding/debug/await.js +18 -0
  48. package/dist/commands/onboarding/debug/disarm.d.ts +63 -0
  49. package/dist/commands/onboarding/debug/disarm.js +12 -0
  50. package/dist/commands/onboarding/debug/eval.d.ts +75 -0
  51. package/dist/commands/onboarding/debug/eval.js +16 -0
  52. package/dist/commands/onboarding/debug/release.d.ts +63 -0
  53. package/dist/commands/onboarding/debug/release.js +12 -0
  54. package/dist/commands/onboarding/debug/resume.d.ts +63 -0
  55. package/dist/commands/onboarding/debug/resume.js +12 -0
  56. package/dist/commands/onboarding/debug/status.d.ts +63 -0
  57. package/dist/commands/onboarding/debug/status.js +12 -0
  58. package/dist/commands/onboarding/debug/step.d.ts +67 -0
  59. package/dist/commands/onboarding/debug/step.js +15 -0
  60. package/dist/commands/onboarding/files/list.d.ts +58 -0
  61. package/dist/commands/onboarding/files/list.js +12 -0
  62. package/dist/commands/onboarding/files/read.d.ts +73 -0
  63. package/dist/commands/onboarding/files/read.js +16 -0
  64. package/dist/commands/onboarding/files/rebuild.d.ts +63 -0
  65. package/dist/commands/onboarding/files/rebuild.js +18 -0
  66. package/dist/commands/onboarding/files/validate.d.ts +58 -0
  67. package/dist/commands/onboarding/files/validate.js +12 -0
  68. package/dist/commands/onboarding/fouc.d.ts +77 -0
  69. package/dist/commands/onboarding/fouc.js +16 -0
  70. package/dist/commands/onboarding/inject/add.d.ts +89 -0
  71. package/dist/commands/onboarding/inject/add.js +17 -0
  72. package/dist/commands/onboarding/inject/clear.d.ts +63 -0
  73. package/dist/commands/onboarding/inject/clear.js +12 -0
  74. package/dist/commands/onboarding/inject/list.d.ts +63 -0
  75. package/dist/commands/onboarding/inject/list.js +12 -0
  76. package/dist/commands/onboarding/inject/read.d.ts +75 -0
  77. package/dist/commands/onboarding/inject/read.js +18 -0
  78. package/dist/commands/onboarding/inject/recipes.d.ts +63 -0
  79. package/dist/commands/onboarding/inject/recipes.js +12 -0
  80. package/dist/commands/onboarding/inject/remove.d.ts +67 -0
  81. package/dist/commands/onboarding/inject/remove.js +15 -0
  82. package/dist/commands/onboarding/list.d.ts +13 -0
  83. package/dist/commands/onboarding/list.js +12 -0
  84. package/dist/commands/onboarding/logs.d.ts +41 -0
  85. package/dist/commands/onboarding/logs.js +257 -0
  86. package/dist/commands/onboarding/navwalk.d.ts +95 -0
  87. package/dist/commands/onboarding/navwalk.js +19 -0
  88. package/dist/commands/onboarding/response.d.ts +67 -0
  89. package/dist/commands/onboarding/response.js +18 -0
  90. package/dist/commands/onboarding/rum/beacons.d.ts +75 -0
  91. package/dist/commands/onboarding/rum/beacons.js +16 -0
  92. package/dist/commands/onboarding/rum/get.d.ts +77 -0
  93. package/dist/commands/onboarding/rum/get.js +18 -0
  94. package/dist/commands/onboarding/rum/key.d.ts +67 -0
  95. package/dist/commands/onboarding/rum/key.js +13 -0
  96. package/dist/commands/onboarding/rum/previous.d.ts +63 -0
  97. package/dist/commands/onboarding/rum/previous.js +12 -0
  98. package/dist/commands/onboarding/status.d.ts +13 -0
  99. package/dist/commands/onboarding/status.js +17 -0
  100. package/dist/commands/onboarding/stop.d.ts +13 -0
  101. package/dist/commands/onboarding/stop.js +17 -0
  102. package/dist/commands/onboarding/todo.d.ts +58 -0
  103. package/dist/commands/onboarding/todo.js +12 -0
  104. package/dist/commands/onboarding/viewport.d.ts +101 -0
  105. package/dist/commands/onboarding/viewport.js +18 -0
  106. package/dist/commands/onboarding/watch.d.ts +93 -0
  107. package/dist/commands/onboarding/watch.js +16 -0
  108. package/dist/commands/onboarding.d.ts +26 -0
  109. package/dist/commands/onboarding.js +221 -4
  110. package/dist/commands/origin-request.d.ts +4 -0
  111. package/dist/commands/origin-request.js +4 -0
  112. package/dist/commands/spec/onboarding.spec.d.ts +1 -0
  113. package/dist/commands/spec/onboarding.spec.js +127 -0
  114. package/dist/services/browser-fetch/device-emulation.d.ts +11 -0
  115. package/dist/services/browser-fetch/device-emulation.js +14 -0
  116. package/dist/services/cli/build-info.d.ts +33 -0
  117. package/dist/services/cli/build-info.js +63 -0
  118. package/dist/services/cli/cli-environment-factory.d.ts +3 -0
  119. package/dist/services/cli/cli-environment-factory.js +1 -0
  120. package/dist/services/cli/cli-service-build-context.d.ts +3 -0
  121. package/dist/services/cli/cli-service-factory.js +1 -1
  122. package/dist/services/cli/cli-service-model.d.ts +29 -10
  123. package/dist/services/cli/cli-service.d.ts +60 -11
  124. package/dist/services/cli/cli-service.js +196 -32
  125. package/dist/services/cli/index.d.ts +2 -0
  126. package/dist/services/cli/index.js +2 -0
  127. package/dist/services/cli/sink.d.ts +47 -0
  128. package/dist/services/cli/sink.js +31 -0
  129. package/dist/services/cli/spec/build-identity.spec.d.ts +1 -0
  130. package/dist/services/cli/spec/build-identity.spec.js +85 -0
  131. package/dist/services/cli/spec/build-info.spec.d.ts +1 -0
  132. package/dist/services/cli/spec/build-info.spec.js +10 -0
  133. package/dist/services/cli/spec/cli-service-log.spec.d.ts +1 -0
  134. package/dist/services/cli/spec/cli-service-log.spec.js +133 -0
  135. package/dist/services/cli/spec/cli-service.spec.js +113 -50
  136. package/dist/services/cli/spec/memory-cli.d.ts +9 -0
  137. package/dist/services/cli/spec/memory-cli.js +9 -0
  138. package/dist/services/diff/config-at-ref.d.ts +20 -0
  139. package/dist/services/diff/config-at-ref.js +33 -0
  140. package/dist/services/diff/diff-service-build-context.d.ts +12 -0
  141. package/dist/services/diff/diff-service-build-context.js +45 -1
  142. package/dist/services/diff/diff-service-factory.d.ts +2 -0
  143. package/dist/services/diff/diff-service-factory.js +65 -25
  144. package/dist/services/diff/diff-service.d.ts +11 -0
  145. package/dist/services/diff/diff-service.js +37 -11
  146. package/dist/services/diff/page-source.d.ts +12 -0
  147. package/dist/services/diff/page-source.js +16 -11
  148. package/dist/services/diff/run-runtime-config.d.ts +33 -0
  149. package/dist/services/diff/run-runtime-config.js +74 -0
  150. package/dist/services/diff/sinks/tool-diff-sink.d.ts +3 -2
  151. package/dist/services/diff/sinks/tool-diff-sink.js +3 -2
  152. package/dist/services/diff/spec/config-at-ref.spec.d.ts +1 -0
  153. package/dist/services/diff/spec/config-at-ref.spec.js +46 -0
  154. package/dist/services/diff/spec/diff-service-build-context.spec.js +19 -0
  155. package/dist/services/diff/spec/diff-service.spec.js +95 -0
  156. package/dist/services/diff/spec/run-runtime-config.spec.d.ts +1 -0
  157. package/dist/services/diff/spec/run-runtime-config.spec.js +87 -0
  158. package/dist/services/git/git-repository.d.ts +2 -0
  159. package/dist/services/git/git-repository.js +6 -0
  160. package/dist/services/integration-api/customer-config-flags.js +1 -0
  161. package/dist/services/onboarding/browse/browse-service.d.ts +13 -1
  162. package/dist/services/onboarding/browse/browse-service.js +43 -7
  163. package/dist/services/onboarding/browser/answer-dialogs.d.ts +12 -0
  164. package/dist/services/onboarding/browser/answer-dialogs.js +25 -0
  165. package/dist/services/onboarding/browser/baqend-response.d.ts +17 -1
  166. package/dist/services/onboarding/browser/baqend-response.js +23 -0
  167. package/dist/services/onboarding/browser/console-log.d.ts +9 -0
  168. package/dist/services/onboarding/browser/console-log.js +27 -0
  169. package/dist/services/onboarding/browser/emulate-device.d.ts +12 -1
  170. package/dist/services/onboarding/browser/emulate-device.js +68 -13
  171. package/dist/services/onboarding/browser/executable/executable-validator.js +4 -2
  172. package/dist/services/onboarding/browser/extension/extension-bridge.js +5 -3
  173. package/dist/services/onboarding/browser/extension/extension-downloader.js +17 -8
  174. package/dist/services/onboarding/browser/extension/extension-validator.js +9 -4
  175. package/dist/services/onboarding/browser/launch-browser.d.ts +2 -1
  176. package/dist/services/onboarding/browser/launch-browser.js +6 -1
  177. package/dist/services/onboarding/browser/resume-restarted-workers.d.ts +14 -0
  178. package/dist/services/onboarding/browser/resume-restarted-workers.js +26 -0
  179. package/dist/services/onboarding/control/body-inspect.d.ts +24 -0
  180. package/dist/services/onboarding/control/body-inspect.js +106 -0
  181. package/dist/services/onboarding/control/browser-session.d.ts +547 -0
  182. package/dist/services/onboarding/control/browser-session.js +1337 -0
  183. package/dist/services/onboarding/control/config-validation.d.ts +17 -0
  184. package/dist/services/onboarding/control/config-validation.js +46 -0
  185. package/dist/services/onboarding/control/control-protocol.d.ts +1430 -0
  186. package/dist/services/onboarding/control/control-protocol.js +58 -0
  187. package/dist/services/onboarding/control/control-server.d.ts +292 -0
  188. package/dist/services/onboarding/control/control-server.js +1629 -0
  189. package/dist/services/onboarding/control/debug-session.d.ts +219 -0
  190. package/dist/services/onboarding/control/debug-session.js +897 -0
  191. package/dist/services/onboarding/control/fouc.d.ts +23 -0
  192. package/dist/services/onboarding/control/fouc.js +151 -0
  193. package/dist/services/onboarding/control/index.d.ts +4 -0
  194. package/dist/services/onboarding/control/index.js +4 -0
  195. package/dist/services/onboarding/control/navigate-wait.d.ts +33 -0
  196. package/dist/services/onboarding/control/navigate-wait.js +56 -0
  197. package/dist/services/onboarding/control/navwalk.d.ts +65 -0
  198. package/dist/services/onboarding/control/navwalk.js +248 -0
  199. package/dist/services/onboarding/control/preload-registry.d.ts +150 -0
  200. package/dist/services/onboarding/control/preload-registry.js +829 -0
  201. package/dist/services/onboarding/control/response-explainer.d.ts +24 -0
  202. package/dist/services/onboarding/control/response-explainer.js +257 -0
  203. package/dist/services/onboarding/control/rum.d.ts +8 -0
  204. package/dist/services/onboarding/control/rum.js +220 -0
  205. package/dist/services/onboarding/control/service-worker-tracker.d.ts +68 -0
  206. package/dist/services/onboarding/control/service-worker-tracker.js +120 -0
  207. package/dist/services/onboarding/control/viewport.d.ts +45 -0
  208. package/dist/services/onboarding/control/viewport.js +344 -0
  209. package/dist/services/onboarding/control/watch.d.ts +26 -0
  210. package/dist/services/onboarding/control/watch.js +157 -0
  211. package/dist/services/onboarding/dashboard/diff-against-current-page.js +3 -1
  212. package/dist/services/onboarding/dashboard/index.js +7 -2
  213. package/dist/services/onboarding/fetch-event-handler.d.ts +24 -5
  214. package/dist/services/onboarding/fetch-event-handler.js +103 -32
  215. package/dist/services/onboarding/fetch-events/speed-kit-install-js.js +11 -2
  216. package/dist/services/onboarding/fetch-events/speed-kit-rum-pi-request.d.ts +14 -0
  217. package/dist/services/onboarding/fetch-events/speed-kit-rum-pi-request.js +30 -0
  218. package/dist/services/onboarding/fetch-events/speed-kit-service-worker-js.d.ts +13 -0
  219. package/dist/services/onboarding/fetch-events/speed-kit-service-worker-js.js +28 -1
  220. package/dist/services/onboarding/file-events/file-watcher.d.ts +42 -1
  221. package/dist/services/onboarding/file-events/file-watcher.js +117 -12
  222. package/dist/services/onboarding/inject/inject-service.js +1 -1
  223. package/dist/services/onboarding/onboarding-model.d.ts +40 -7
  224. package/dist/services/onboarding/onboarding-model.js +20 -9
  225. package/dist/services/onboarding/onboarding-service-build-context.d.ts +4 -0
  226. package/dist/services/onboarding/onboarding-service-build-context.js +7 -1
  227. package/dist/services/onboarding/onboarding-service-factory.d.ts +17 -1
  228. package/dist/services/onboarding/onboarding-service-factory.js +150 -23
  229. package/dist/services/onboarding/onboarding-service.d.ts +40 -1
  230. package/dist/services/onboarding/onboarding-service.js +139 -23
  231. package/dist/services/onboarding/request-cache/asset-key.d.ts +61 -0
  232. package/dist/services/onboarding/request-cache/asset-key.js +115 -0
  233. package/dist/services/onboarding/request-cache/cache.d.ts +62 -5
  234. package/dist/services/onboarding/request-cache/cache.js +128 -17
  235. package/dist/services/onboarding/spec/browser/answer-dialogs.spec.d.ts +1 -0
  236. package/dist/services/onboarding/spec/browser/answer-dialogs.spec.js +66 -0
  237. package/dist/services/onboarding/spec/browser/console-log.spec.d.ts +1 -0
  238. package/dist/services/onboarding/spec/browser/console-log.spec.js +42 -0
  239. package/dist/services/onboarding/spec/browser/resume-restarted-workers.spec.d.ts +1 -0
  240. package/dist/services/onboarding/spec/browser/resume-restarted-workers.spec.js +45 -0
  241. package/dist/services/onboarding/spec/control/browser-session.spec.d.ts +1 -0
  242. package/dist/services/onboarding/spec/control/browser-session.spec.js +753 -0
  243. package/dist/services/onboarding/spec/control/control-server.spec.d.ts +1 -0
  244. package/dist/services/onboarding/spec/control/control-server.spec.js +371 -0
  245. package/dist/services/onboarding/spec/control/debug-session.spec.d.ts +1 -0
  246. package/dist/services/onboarding/spec/control/debug-session.spec.js +751 -0
  247. package/dist/services/onboarding/spec/control/fakes.d.ts +31 -0
  248. package/dist/services/onboarding/spec/control/fakes.js +67 -0
  249. package/dist/services/onboarding/spec/control/fouc.spec.d.ts +1 -0
  250. package/dist/services/onboarding/spec/control/fouc.spec.js +167 -0
  251. package/dist/services/onboarding/spec/control/navigate-wait.spec.d.ts +1 -0
  252. package/dist/services/onboarding/spec/control/navigate-wait.spec.js +47 -0
  253. package/dist/services/onboarding/spec/control/navwalk.spec.d.ts +1 -0
  254. package/dist/services/onboarding/spec/control/navwalk.spec.js +222 -0
  255. package/dist/services/onboarding/spec/control/preload-registry.spec.d.ts +1 -0
  256. package/dist/services/onboarding/spec/control/preload-registry.spec.js +432 -0
  257. package/dist/services/onboarding/spec/control/response-explainer.spec.d.ts +1 -0
  258. package/dist/services/onboarding/spec/control/response-explainer.spec.js +324 -0
  259. package/dist/services/onboarding/spec/control/rum.spec.d.ts +1 -0
  260. package/dist/services/onboarding/spec/control/rum.spec.js +222 -0
  261. package/dist/services/onboarding/spec/control/service-worker-tracker.spec.d.ts +1 -0
  262. package/dist/services/onboarding/spec/control/service-worker-tracker.spec.js +193 -0
  263. package/dist/services/onboarding/spec/control/viewport.spec.d.ts +1 -0
  264. package/dist/services/onboarding/spec/control/viewport.spec.js +200 -0
  265. package/dist/services/onboarding/spec/control/watch.spec.d.ts +1 -0
  266. package/dist/services/onboarding/spec/control/watch.spec.js +187 -0
  267. package/dist/services/onboarding/spec/fetch-event-handler.spec.d.ts +1 -0
  268. package/dist/services/onboarding/spec/fetch-event-handler.spec.js +219 -0
  269. package/dist/services/onboarding/spec/fetch-events/speed-kit-service-worker-js.spec.d.ts +1 -0
  270. package/dist/services/onboarding/spec/fetch-events/speed-kit-service-worker-js.spec.js +41 -0
  271. package/dist/services/onboarding/spec/onboarding-model.spec.js +39 -3
  272. package/dist/services/onboarding/spec/onboarding-service-factory.spec.js +25 -1
  273. package/dist/services/onboarding/spec/request-cache/cache.spec.d.ts +1 -0
  274. package/dist/services/onboarding/spec/request-cache/cache.spec.js +107 -0
  275. package/dist/services/onboarding/spec/todo-collector.spec.d.ts +1 -0
  276. package/dist/services/onboarding/spec/todo-collector.spec.js +136 -0
  277. package/dist/services/onboarding/spec/virtual-orestes-app/virtual-orestes-app.spec.d.ts +1 -0
  278. package/dist/services/onboarding/spec/virtual-orestes-app/virtual-orestes-app.spec.js +65 -0
  279. package/dist/services/onboarding/templates/install-speed-kit-html-template.js +11 -0
  280. package/dist/services/onboarding/templates/spec/install-speed-kit-html-template.spec.d.ts +1 -0
  281. package/dist/services/onboarding/templates/spec/install-speed-kit-html-template.spec.js +119 -0
  282. package/dist/services/onboarding/todo-collector.d.ts +7 -2
  283. package/dist/services/onboarding/todo-collector.js +49 -12
  284. package/dist/services/onboarding/virtual-orestes-app/index.d.ts +38 -0
  285. package/dist/services/onboarding/virtual-orestes-app/index.js +113 -27
  286. package/dist/services/origin-request/asset-variations.d.ts +14 -0
  287. package/dist/services/origin-request/asset-variations.js +11 -4
  288. package/dist/services/origin-request/origin-fetcher.d.ts +7 -0
  289. package/dist/services/origin-request/origin-fetcher.js +43 -5
  290. package/dist/services/origin-request/origin-request-service-build-context.d.ts +17 -0
  291. package/dist/services/origin-request/origin-request-service-build-context.js +8 -0
  292. package/dist/services/origin-request/origin-request-service-factory.d.ts +0 -5
  293. package/dist/services/origin-request/origin-request-service-factory.js +2 -30
  294. package/dist/services/origin-request/origin-request-service.d.ts +121 -6
  295. package/dist/services/origin-request/origin-request-service.js +273 -49
  296. package/dist/services/origin-request/runtime-config-source.d.ts +6 -0
  297. package/dist/services/origin-request/runtime-config-source.js +15 -4
  298. package/dist/services/origin-request/spec/asset-variations.spec.js +20 -0
  299. package/dist/services/origin-request/spec/origin-request-service.spec.js +329 -6
  300. package/dist/services/query-builder/rules/rule-match.d.ts +35 -0
  301. package/dist/services/query-builder/rules/rule-match.js +70 -0
  302. package/dist/services/query-builder/spec/rules/rule-match.spec.d.ts +1 -0
  303. package/dist/services/query-builder/spec/rules/rule-match.spec.js +121 -0
  304. package/dist/services/run-control/browser/run-browser-contexts.d.ts +557 -0
  305. package/dist/services/run-control/browser/run-browser-contexts.js +91 -0
  306. package/dist/services/run-control/browser/run-browser-service-factory.d.ts +5 -0
  307. package/dist/services/run-control/browser/run-browser-service-factory.js +7 -0
  308. package/dist/services/run-control/browser/run-browser-service.d.ts +68 -0
  309. package/dist/services/run-control/browser/run-browser-service.js +206 -0
  310. package/dist/services/run-control/cache/run-cache-contexts.d.ts +349 -0
  311. package/dist/services/run-control/cache/run-cache-contexts.js +51 -0
  312. package/dist/services/run-control/cache/run-cache-service-factory.d.ts +6 -0
  313. package/dist/services/run-control/cache/run-cache-service-factory.js +12 -0
  314. package/dist/services/run-control/cache/run-cache-service.d.ts +35 -0
  315. package/dist/services/run-control/cache/run-cache-service.js +151 -0
  316. package/dist/services/run-control/control-client.d.ts +36 -0
  317. package/dist/services/run-control/control-client.js +147 -0
  318. package/dist/services/run-control/debug/run-debug-contexts.d.ts +416 -0
  319. package/dist/services/run-control/debug/run-debug-contexts.js +47 -0
  320. package/dist/services/run-control/debug/run-debug-service-factory.d.ts +5 -0
  321. package/dist/services/run-control/debug/run-debug-service-factory.js +7 -0
  322. package/dist/services/run-control/debug/run-debug-service.d.ts +39 -0
  323. package/dist/services/run-control/debug/run-debug-service.js +164 -0
  324. package/dist/services/run-control/files/run-files-contexts.d.ts +238 -0
  325. package/dist/services/run-control/files/run-files-contexts.js +26 -0
  326. package/dist/services/run-control/files/run-files-service-factory.d.ts +5 -0
  327. package/dist/services/run-control/files/run-files-service-factory.js +7 -0
  328. package/dist/services/run-control/files/run-files-service.d.ts +29 -0
  329. package/dist/services/run-control/files/run-files-service.js +120 -0
  330. package/dist/services/run-control/index.d.ts +32 -0
  331. package/dist/services/run-control/index.js +31 -0
  332. package/dist/services/run-control/inject/run-inject-contexts.d.ts +319 -0
  333. package/dist/services/run-control/inject/run-inject-contexts.js +38 -0
  334. package/dist/services/run-control/inject/run-inject-service-factory.d.ts +5 -0
  335. package/dist/services/run-control/inject/run-inject-service-factory.js +7 -0
  336. package/dist/services/run-control/inject/run-inject-service.d.ts +31 -0
  337. package/dist/services/run-control/inject/run-inject-service.js +227 -0
  338. package/dist/services/run-control/live-run.d.ts +37 -0
  339. package/dist/services/run-control/live-run.js +56 -0
  340. package/dist/services/run-control/probe/run-probe-contexts.d.ts +333 -0
  341. package/dist/services/run-control/probe/run-probe-contexts.js +73 -0
  342. package/dist/services/run-control/probe/run-probe-service-factory.d.ts +5 -0
  343. package/dist/services/run-control/probe/run-probe-service-factory.js +7 -0
  344. package/dist/services/run-control/probe/run-probe-service.d.ts +54 -0
  345. package/dist/services/run-control/probe/run-probe-service.js +194 -0
  346. package/dist/services/run-control/rum/run-rum-contexts.d.ts +216 -0
  347. package/dist/services/run-control/rum/run-rum-contexts.js +34 -0
  348. package/dist/services/run-control/rum/run-rum-service-factory.d.ts +5 -0
  349. package/dist/services/run-control/rum/run-rum-service-factory.js +7 -0
  350. package/dist/services/run-control/rum/run-rum-service.d.ts +36 -0
  351. package/dist/services/run-control/rum/run-rum-service.js +122 -0
  352. package/dist/services/run-control/run-answer.d.ts +28 -0
  353. package/dist/services/run-control/run-answer.js +58 -0
  354. package/dist/services/run-control/run-control-context.d.ts +102 -0
  355. package/dist/services/run-control/run-control-context.js +36 -0
  356. package/dist/services/run-control/run-control-flags.d.ts +12 -0
  357. package/dist/services/run-control/run-control-flags.js +22 -0
  358. package/dist/services/run-control/run-control-model.d.ts +9 -0
  359. package/dist/services/run-control/run-control-model.js +1 -0
  360. package/dist/services/run-control/run-control-service-factory.d.ts +14 -0
  361. package/dist/services/run-control/run-control-service-factory.js +26 -0
  362. package/dist/services/run-control/session/run-session-contexts.d.ts +25 -0
  363. package/dist/services/run-control/session/run-session-contexts.js +20 -0
  364. package/dist/services/run-control/session/run-session-service-factory.d.ts +8 -0
  365. package/dist/services/run-control/session/run-session-service-factory.js +18 -0
  366. package/dist/services/run-control/session/run-session-service.d.ts +32 -0
  367. package/dist/services/run-control/session/run-session-service.js +151 -0
  368. package/dist/services/run-control/spec/browser/run-browser-service.spec.d.ts +1 -0
  369. package/dist/services/run-control/spec/browser/run-browser-service.spec.js +328 -0
  370. package/dist/services/run-control/spec/cache/run-cache-service.spec.d.ts +1 -0
  371. package/dist/services/run-control/spec/cache/run-cache-service.spec.js +454 -0
  372. package/dist/services/run-control/spec/debug/run-debug-service.spec.d.ts +1 -0
  373. package/dist/services/run-control/spec/debug/run-debug-service.spec.js +113 -0
  374. package/dist/services/run-control/spec/files/run-files-service.spec.d.ts +1 -0
  375. package/dist/services/run-control/spec/files/run-files-service.spec.js +234 -0
  376. package/dist/services/run-control/spec/inject/run-inject-service.spec.d.ts +1 -0
  377. package/dist/services/run-control/spec/inject/run-inject-service.spec.js +251 -0
  378. package/dist/services/run-control/spec/live-run-fixture.d.ts +32 -0
  379. package/dist/services/run-control/spec/live-run-fixture.js +109 -0
  380. package/dist/services/run-control/spec/probe/run-probe-service.spec.d.ts +1 -0
  381. package/dist/services/run-control/spec/probe/run-probe-service.spec.js +108 -0
  382. package/dist/services/run-control/spec/rum/run-rum-service.spec.d.ts +1 -0
  383. package/dist/services/run-control/spec/rum/run-rum-service.spec.js +47 -0
  384. package/dist/services/run-control/spec/run-answer.spec.d.ts +1 -0
  385. package/dist/services/run-control/spec/run-answer.spec.js +57 -0
  386. package/dist/services/run-control/spec/session/run-session-service.spec.d.ts +1 -0
  387. package/dist/services/run-control/spec/session/run-session-service.spec.js +150 -0
  388. package/dist/services/run-log/crash-mirror.d.ts +31 -0
  389. package/dist/services/run-log/crash-mirror.js +69 -0
  390. package/dist/services/run-log/index.d.ts +11 -0
  391. package/dist/services/run-log/index.js +11 -0
  392. package/dist/services/run-log/jsonl-appender.d.ts +46 -0
  393. package/dist/services/run-log/jsonl-appender.js +91 -0
  394. package/dist/services/run-log/log-event-model.d.ts +104 -0
  395. package/dist/services/run-log/log-event-model.js +56 -0
  396. package/dist/services/run-log/log-query-service-factory.d.ts +11 -0
  397. package/dist/services/run-log/log-query-service-factory.js +14 -0
  398. package/dist/services/run-log/log-query-service.d.ts +59 -0
  399. package/dist/services/run-log/log-query-service.js +111 -0
  400. package/dist/services/run-log/log-reader.d.ts +84 -0
  401. package/dist/services/run-log/log-reader.js +180 -0
  402. package/dist/services/run-log/log-summary.d.ts +72 -0
  403. package/dist/services/run-log/log-summary.js +208 -0
  404. package/dist/services/run-log/redaction.d.ts +34 -0
  405. package/dist/services/run-log/redaction.js +124 -0
  406. package/dist/services/run-log/request-log.d.ts +82 -0
  407. package/dist/services/run-log/request-log.js +69 -0
  408. package/dist/services/run-log/request-summary.d.ts +76 -0
  409. package/dist/services/run-log/request-summary.js +0 -0
  410. package/dist/services/run-log/run-log.d.ts +61 -0
  411. package/dist/services/run-log/run-log.js +102 -0
  412. package/dist/services/run-log/spec/log-query-service.spec.d.ts +1 -0
  413. package/dist/services/run-log/spec/log-query-service.spec.js +197 -0
  414. package/dist/services/run-log/spec/log-reader.spec.d.ts +1 -0
  415. package/dist/services/run-log/spec/log-reader.spec.js +109 -0
  416. package/dist/services/run-log/spec/log-summary.spec.d.ts +1 -0
  417. package/dist/services/run-log/spec/log-summary.spec.js +153 -0
  418. package/dist/services/run-log/spec/redaction.spec.d.ts +1 -0
  419. package/dist/services/run-log/spec/redaction.spec.js +61 -0
  420. package/dist/services/run-log/spec/request-log.spec.d.ts +1 -0
  421. package/dist/services/run-log/spec/request-log.spec.js +101 -0
  422. package/dist/services/run-log/spec/request-summary.spec.d.ts +1 -0
  423. package/dist/services/run-log/spec/request-summary.spec.js +171 -0
  424. package/dist/services/run-log/spec/run-log.spec.d.ts +1 -0
  425. package/dist/services/run-log/spec/run-log.spec.js +122 -0
  426. package/dist/services/run-registry/exit-classification.d.ts +39 -0
  427. package/dist/services/run-registry/exit-classification.js +42 -0
  428. package/dist/services/run-registry/index.d.ts +3 -0
  429. package/dist/services/run-registry/index.js +3 -0
  430. package/dist/services/run-registry/process-identity.d.ts +28 -0
  431. package/dist/services/run-registry/process-identity.js +80 -0
  432. package/dist/services/run-registry/run-registry-model.d.ts +128 -0
  433. package/dist/services/run-registry/run-registry-model.js +16 -0
  434. package/dist/services/run-registry/run-registry.d.ts +155 -0
  435. package/dist/services/run-registry/run-registry.js +430 -0
  436. package/dist/services/run-registry/spec/exit-classification.spec.d.ts +1 -0
  437. package/dist/services/run-registry/spec/exit-classification.spec.js +82 -0
  438. package/dist/services/run-registry/spec/run-registry.spec.d.ts +1 -0
  439. package/dist/services/run-registry/spec/run-registry.spec.js +526 -0
  440. package/dist/services/setup/os/tool-registry.js +2 -2
  441. package/oclif.manifest.json +3414 -293
  442. package/package.json +20 -2
@@ -0,0 +1,65 @@
1
+ import { expect } from "chai";
2
+ import { describe, it } from "mocha";
3
+ import { mkdtempSync, rmSync } from "node:fs";
4
+ import { tmpdir } from "node:os";
5
+ import { join } from "node:path";
6
+ import { memoryCli } from "../../../cli/spec/memory-cli.js";
7
+ import { MemorySink } from "../../../cli/sink.js";
8
+ import { Cache } from "../../request-cache/cache.js";
9
+ import { assetRequestUrl } from "../../request-cache/asset-key.js";
10
+ import { VirtualOrestesApp } from "../../virtual-orestes-app/index.js";
11
+ const APP_DOMAIN = "shop.app.baqend.com";
12
+ const PAGE = "https://shop.example.com/cart";
13
+ /** A local app whose origin fetcher names `variations` and must not be asked to fetch. */
14
+ function app(sink, variations = []) {
15
+ const directory = mkdtempSync(join(tmpdir(), "sk-orestes-"));
16
+ let fetched = false;
17
+ const originFetcher = {
18
+ namedVariations: () => variations,
19
+ fetch: async () => {
20
+ fetched = true;
21
+ return undefined;
22
+ },
23
+ };
24
+ const orestes = new VirtualOrestesApp({ appDomain: APP_DOMAIN }, originFetcher, {}, new Cache(memoryCli(), join(directory, "dh-cache")), memoryCli(sink), {});
25
+ return {
26
+ orestes,
27
+ fetched: () => fetched,
28
+ remove: () => rmSync(directory, { recursive: true, force: true }),
29
+ };
30
+ }
31
+ const request = (variation) => ({
32
+ request: { url: assetRequestUrl(APP_DOMAIN, PAGE, variation) },
33
+ });
34
+ describe("VirtualOrestesApp — the break variation", () => {
35
+ it("should answer a break page as Orestes does, so the worker serves it from origin", async () => {
36
+ const sink = new MemorySink();
37
+ const { orestes, fetched, remove } = app(sink);
38
+ try {
39
+ const response = (await orestes.fetchAssetResponse(request("break")));
40
+ await orestes.fetchAssetResponse(request("break"));
41
+ expect(response.responseCode).to.equal(400);
42
+ expect(response.responseHeaders).to.deep.include({
43
+ name: "server-timing",
44
+ value: "errorcode;desc=322",
45
+ });
46
+ expect(fetched()).to.equal(false);
47
+ const reported = sink.lines.filter((line) => line.includes("break"));
48
+ expect(reported).to.have.length(1);
49
+ expect(reported[0]).to.contain("served from origin");
50
+ }
51
+ finally {
52
+ remove();
53
+ }
54
+ });
55
+ it("should build a break page like any other when the runtime config defines break", async () => {
56
+ const { orestes, fetched, remove } = app(new MemorySink(), ["break"]);
57
+ try {
58
+ await orestes.fetchAssetResponse(request("break"));
59
+ expect(fetched()).to.equal(true);
60
+ }
61
+ finally {
62
+ remove();
63
+ }
64
+ });
65
+ });
@@ -175,6 +175,14 @@ aside.loader:not(.stop)::after {
175
175
  }
176
176
  </script>
177
177
  <script type="application/javascript">
178
+ // The registrations the install script starts, so the page can wait for the worker they install.
179
+ const registrations = [];
180
+ const register = navigator.serviceWorker.register;
181
+ navigator.serviceWorker.register = function () {
182
+ const registration = register.apply(this, arguments);
183
+ registrations.push(registration.catch(() => undefined));
184
+ return registration;
185
+ };
178
186
  const installScript = document.createElement('script');
179
187
  installScript.addEventListener('load',()=>{
180
188
  const step1 = document.querySelector('[data-step="1"]')
@@ -209,6 +217,9 @@ aside.loader:not(.stop)::after {
209
217
 
210
218
 
211
219
  await retry(async () => registration.active);
220
+ // Leave through the newest worker. Chrome retires the one it replaces mid-response, and that navigation never commits.
221
+ await Promise.all(registrations);
222
+ await retry(async () => !registration.installing && !registration.waiting).catch(() => undefined);
212
223
 
213
224
  // Ping Service Worker to check whether the application is 'running'
214
225
  await pingServiceWorker(registration, {
@@ -0,0 +1,119 @@
1
+ import { expect } from "chai";
2
+ import { describe, it } from "mocha";
3
+ import { runInNewContext } from "node:vm";
4
+ import { InstallSpeedKitHtmlTemplate } from "../install-speed-kit-html-template.js";
5
+ /** The install page's scripts, run against a fake page whose install script registers `register`. */
6
+ function installPage(register) {
7
+ const html = new InstallSpeedKitHtmlTemplate().render({
8
+ installPath: "https://fixture.app.baqend.com/v1/speedkit/install.js",
9
+ domain: "https://www.fixture.com",
10
+ swPath: "/sw.js",
11
+ });
12
+ const scripts = [...html.matchAll(/<script[^>]*>([\s\S]*?)<\/script>/g)]
13
+ .map(([, code]) => code)
14
+ .join("\n");
15
+ const registration = {
16
+ active: { postMessage: (_, [port]) => port.reply() },
17
+ };
18
+ const element = () => ({
19
+ classList: { add: () => undefined, remove: () => undefined },
20
+ innerText: "0",
21
+ textContent: "",
22
+ });
23
+ let onLoad = () => undefined;
24
+ const timers = [];
25
+ const page = {
26
+ href: "https://www.fixture.com/speed-kit-install.html?url=%2Fshop",
27
+ left: undefined,
28
+ registration,
29
+ load: () => onLoad(),
30
+ /** Lets `seconds` of the page's one-second retries pass. */
31
+ wait: async (seconds) => {
32
+ for (let second = 0; second <= seconds; second++) {
33
+ await new Promise((resolve) => setImmediate(resolve));
34
+ for (const timer of timers.splice(0))
35
+ timer();
36
+ }
37
+ await new Promise((resolve) => setImmediate(resolve));
38
+ },
39
+ };
40
+ const context = {
41
+ location: {
42
+ get href() {
43
+ return page.href;
44
+ },
45
+ set href(value) {
46
+ page.left = value;
47
+ },
48
+ },
49
+ URL,
50
+ setTimeout: (callback) => timers.push(callback),
51
+ addEventListener: () => undefined,
52
+ MessageChannel,
53
+ SpeedKit: { preload: () => undefined },
54
+ navigator: {
55
+ serviceWorker: {
56
+ register,
57
+ getRegistration: async () => registration,
58
+ },
59
+ },
60
+ document: {
61
+ readyState: "complete",
62
+ addEventListener: () => undefined,
63
+ querySelector: (selector) => selector === "head"
64
+ ? { appendChild: () => undefined }
65
+ : (page[selector] ??
66
+ (page[selector] =
67
+ element())),
68
+ createElement: () => ({
69
+ addEventListener: (type, listener) => {
70
+ if (type === "load")
71
+ onLoad = listener;
72
+ },
73
+ setAttribute: () => undefined,
74
+ }),
75
+ },
76
+ };
77
+ runInNewContext(scripts, context);
78
+ return { page, serviceWorker: context.navigator.serviceWorker };
79
+ }
80
+ /** A MessageChannel whose second port answers like a running Speed Kit worker. */
81
+ class MessageChannel {
82
+ port1 = {};
83
+ port2 = {
84
+ reply: () => this.port1.onmessage?.({ data: { applicationState: "ok" } }),
85
+ };
86
+ }
87
+ describe("InstallSpeedKitHtmlTemplate", () => {
88
+ it("leaves only once the worker the install script registered is active", async () => {
89
+ const { page, serviceWorker } = installPage(async () => {
90
+ page.registration.waiting = { state: "installed" };
91
+ return page.registration;
92
+ });
93
+ // The install script registers while it runs, before its load event.
94
+ void serviceWorker.register();
95
+ page.load();
96
+ await page.wait(3);
97
+ expect(page.left).to.equal(undefined);
98
+ page.registration.waiting = undefined;
99
+ await page.wait(1);
100
+ expect(page.left).to.equal("/shop");
101
+ });
102
+ it("leaves after its retries when the new worker never activates", async () => {
103
+ const { page, serviceWorker } = installPage(async () => {
104
+ page.registration.installing = { state: "installing" };
105
+ return page.registration;
106
+ });
107
+ void serviceWorker.register();
108
+ page.load();
109
+ await page.wait(12);
110
+ expect(page.left).to.equal("/shop");
111
+ });
112
+ it("leaves at once when the registration installs no new worker", async () => {
113
+ const { page, serviceWorker } = installPage(async () => page.registration);
114
+ void serviceWorker.register();
115
+ page.load();
116
+ await page.wait(0);
117
+ expect(page.left).to.equal("/shop");
118
+ });
119
+ });
@@ -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
  }
@@ -5,6 +5,7 @@ import { Cache } from "../request-cache/cache.js";
5
5
  import { CliServiceInterface } from "../../cli/index.js";
6
6
  import { OriginFetcher } from "../../origin-request/index.js";
7
7
  import { CustomerConfig } from "../../integration-api/index.js";
8
+ import { LocalCacheErrorEntry } from "../control/control-protocol.js";
8
9
  import { DevtoolsExtensionApi } from "../browser/extension/devtools-extension-api.js";
9
10
  export declare class VirtualOrestesApp {
10
11
  private customerConfig;
@@ -16,8 +17,30 @@ export declare class VirtualOrestesApp {
16
17
  private removeContentSecurityPolicy;
17
18
  private localCacheErrors;
18
19
  private prerendererHintShown;
20
+ /** The pages already reported as `break` pages, so each is reported once. */
21
+ private readonly breakPages;
19
22
  constructor(customerConfig: CustomerConfig, originFetcher: OriginFetcher, documentHandler: DocumentHandlerServer, cache: Cache, cli: CliServiceInterface, developmentToolsMessages: DevtoolsExtensionApi, removeContentSecurityPolicy?: boolean);
20
23
  fetchAssetResponse(event: Protocol.Fetch.RequestPausedEvent): Promise<Partial<Protocol.Fetch.FulfillRequestRequest> | AbortResponse>;
24
+ /** The variations the runtime config names: see {@link OriginFetcher.namedVariations}. */
25
+ namedVariations(): string[];
26
+ /**
27
+ * Build and cache one variation of a url without the browser asking for it.
28
+ *
29
+ * The same path a real asset request takes — {@link buildResponse} fetches
30
+ * the origin with the variation's headers, runs the documentHandler over it
31
+ * and caches the result — with the request synthesised rather than
32
+ * intercepted. That is what makes a variation reachable at all: a browser is
33
+ * one device at a time, so mobile and desktop can never both be in the cache
34
+ * from browsing, and the comparison everyone wants to make is between exactly
35
+ * those two.
36
+ *
37
+ * Throws what the build threw. The caller is asking for one specific entry,
38
+ * so a failure is the answer to its question, not a background detail —
39
+ * unlike {@link refreshEntry}, which is fire-and-forget and logs instead.
40
+ *
41
+ * @returns the cache key the entry was stored under.
42
+ */
43
+ prewarm(originUrl: string, variation: string): Promise<string>;
21
44
  /**
22
45
  * Re-warm all cached entries for the given origin url in the background.
23
46
  *
@@ -49,6 +72,19 @@ export declare class VirtualOrestesApp {
49
72
  private refreshEntry;
50
73
  private buildResponse;
51
74
  private getResponseText;
75
+ /**
76
+ * The urls the local documentHandler could not build, as they stand now.
77
+ *
78
+ * Already collected for the devtools panel; this is the same list for a
79
+ * reader without one. State rather than history: an entry disappears once the
80
+ * same url and variation builds successfully, so an empty list means nothing
81
+ * is currently failing, not that nothing ever did.
82
+ *
83
+ * `occurredAt` is converted to ISO on the way out — the panel wants epoch
84
+ * milliseconds to sort by, a reader wants a timestamp it can compare against
85
+ * a log line.
86
+ */
87
+ getLocalCacheErrors(): LocalCacheErrorEntry[];
52
88
  private localCacheErrorKey;
53
89
  private recordLocalCacheError;
54
90
  private clearLocalCacheError;
@@ -60,6 +96,8 @@ export declare class VirtualOrestesApp {
60
96
  * `ServerDocumentHandlerAbort`. Answering 500 instead makes the service worker treat
61
97
  * the page as an infrastructure failure and disconnect Speed Kit.
62
98
  */
99
+ /** What Orestes answers for an undefined variation: the service worker serves from origin. */
100
+ private returnBreakResponse;
63
101
  private returnAbortResponse;
64
102
  private reportAbort;
65
103
  private warnPrerendererUnreachable;
@@ -1,3 +1,4 @@
1
+ import { assetOriginUrl, assetRequestUrl } from "../request-cache/asset-key.js";
1
2
  import { BaqendResponse } from "../browser/baqend-response.js";
2
3
  import { ABORT_SERVER_TIMING, ABORT_STATUS_CODE, isDocumentHandlerAbort, isLocalPrerendererUnreachable, LOCAL_PRERENDERER_PORT, prerenderFailure, } from "../../document-handler-runtime/document-handler-abort.js";
3
4
  import { isBlockedOriginStatus, ORIGIN_ERROR_STATUS_CODE, originErrorCauseName, originErrorCode, originErrorServerTiming, } from "../../origin-request/index.js";
@@ -20,6 +21,13 @@ const SECURITY_HEADERS = [
20
21
  "strict-transport-security",
21
22
  "x-frame-options",
22
23
  ];
24
+ /**
25
+ * The reserved variation a `customVariation` returns to serve a page from origin. Orestes
26
+ * defines no such variation, so it answers a Bad Request and the service worker falls back.
27
+ */
28
+ const BREAK_VARIATION = "break";
29
+ /** Orestes' `ServerVariationNotDefined`, the error code a `break` request gets. */
30
+ const VARIATION_NOT_DEFINED_CODE = "322";
23
31
  export class VirtualOrestesApp {
24
32
  customerConfig;
25
33
  originFetcher;
@@ -35,6 +43,8 @@ export class VirtualOrestesApp {
35
43
  localCacheErrors = new Map();
36
44
  // The hint to start the pre-renderer is shown once; every later page gets one line.
37
45
  prerendererHintShown = false;
46
+ /** The pages already reported as `break` pages, so each is reported once. */
47
+ breakPages = new Set();
38
48
  constructor(customerConfig, originFetcher, documentHandler, cache, cli, developmentToolsMessages, removeContentSecurityPolicy = false) {
39
49
  this.customerConfig = customerConfig;
40
50
  this.originFetcher = originFetcher;
@@ -51,6 +61,32 @@ export class VirtualOrestesApp {
51
61
  }
52
62
  return this.buildResponse(event.request.url);
53
63
  }
64
+ /** The variations the runtime config names: see {@link OriginFetcher.namedVariations}. */
65
+ namedVariations() {
66
+ return this.originFetcher.namedVariations();
67
+ }
68
+ /**
69
+ * Build and cache one variation of a url without the browser asking for it.
70
+ *
71
+ * The same path a real asset request takes — {@link buildResponse} fetches
72
+ * the origin with the variation's headers, runs the documentHandler over it
73
+ * and caches the result — with the request synthesised rather than
74
+ * intercepted. That is what makes a variation reachable at all: a browser is
75
+ * one device at a time, so mobile and desktop can never both be in the cache
76
+ * from browsing, and the comparison everyone wants to make is between exactly
77
+ * those two.
78
+ *
79
+ * Throws what the build threw. The caller is asking for one specific entry,
80
+ * so a failure is the answer to its question, not a background detail —
81
+ * unlike {@link refreshEntry}, which is fire-and-forget and logs instead.
82
+ *
83
+ * @returns the cache key the entry was stored under.
84
+ */
85
+ async prewarm(originUrl, variation) {
86
+ const requestUrl = assetRequestUrl(this.customerConfig.appDomain, originUrl, variation);
87
+ await this.buildResponse(requestUrl);
88
+ return requestUrl;
89
+ }
54
90
  /**
55
91
  * Re-warm all cached entries for the given origin url in the background.
56
92
  *
@@ -66,10 +102,13 @@ export class VirtualOrestesApp {
66
102
  .map(([key]) => key)
67
103
  .filter((key) => key.includes(originUrl));
68
104
  if (matchingKeys.length === 0) {
69
- this.cli.write(`changeDetection for url: ${originUrl} - nothing cached to refresh`);
105
+ this.cli.write(`changeDetection for url: ${originUrl} - nothing cached to refresh`, false, { scope: "cache", data: { url: originUrl, refreshed: 0 } });
70
106
  return;
71
107
  }
72
- this.cli.write(`changeDetection triggered for url: ${originUrl} - refreshing dh-cache in background`);
108
+ this.cli.write(`changeDetection triggered for url: ${originUrl} - refreshing dh-cache in background`, false, {
109
+ scope: "cache",
110
+ data: { url: originUrl, refreshed: matchingKeys.length },
111
+ });
73
112
  for (const key of matchingKeys) {
74
113
  await this.refreshEntry(key);
75
114
  }
@@ -91,7 +130,10 @@ export class VirtualOrestesApp {
91
130
  if (matchingKeys.length === 0) {
92
131
  return;
93
132
  }
94
- this.cli.write(`refreshing ${matchingKeys.length} dh-cache entries for current url ${currentUrl} in background`);
133
+ this.cli.write(`refreshing ${matchingKeys.length} dh-cache entries for current url ${currentUrl} in background`, false, {
134
+ scope: "cache",
135
+ data: { url: currentUrl, refreshed: matchingKeys.length },
136
+ });
95
137
  for (const key of matchingKeys) {
96
138
  await this.refreshEntry(key);
97
139
  }
@@ -107,7 +149,7 @@ export class VirtualOrestesApp {
107
149
  const result = await safe(this.buildResponse(requestUrl));
108
150
  if (result.success === false) {
109
151
  this.cache.removeEntry(requestUrl);
110
- this.cli.writeError(`failed to refresh dh-cache entry ${requestUrl}: ${result.error}`);
152
+ this.cli.writeError(`failed to refresh dh-cache entry ${requestUrl}: ${result.error}`, false, { scope: "cache", data: { url: requestUrl, error: result.error } });
111
153
  }
112
154
  }
113
155
  async buildResponse(requestUrl) {
@@ -116,6 +158,10 @@ export class VirtualOrestesApp {
116
158
  const variation = UrlObject.searchParams.has("bqvariation")
117
159
  ? UrlObject.searchParams.get("bqvariation").trim()
118
160
  : "default";
161
+ if (variation === BREAK_VARIATION &&
162
+ !this.originFetcher.namedVariations().includes(BREAK_VARIATION)) {
163
+ return this.returnBreakResponse(originUrl);
164
+ }
119
165
  const fetchResult = await this.originFetcher.fetch(originUrl, variation);
120
166
  const response = fetchResult?.response;
121
167
  // URL we actually fetched (origin + variation query params); used for the redirect check below
@@ -145,7 +191,7 @@ export class VirtualOrestesApp {
145
191
  if (!this.isHtmlContentHeader(response?.headers) ||
146
192
  !this.isValidHtmlContent(responseContent)) {
147
193
  const customResponse = new BaqendResponse(responseContent, `text/html; charset=${textEncoding}`, customHeaders);
148
- this.cache.addEntry(requestUrl, customResponse);
194
+ this.cache.addEntry(requestUrl, customResponse, responseContent);
149
195
  return customResponse;
150
196
  }
151
197
  const customResponse = await safe(this.documentHandler.transform(`text/html;charset=${textEncoding}`, responseContent, variation, originUrl, this.convertResponseHeadersToOrestesFormat(response)));
@@ -183,16 +229,36 @@ export class VirtualOrestesApp {
183
229
  name: "x-sk-detected-encoding",
184
230
  value: textEncoding,
185
231
  });
186
- const baqendResponse = new BaqendResponse(Buffer.isBuffer(skResponse.body)
232
+ // Decoded, and cached decoded: only Chrome needs the base64.
233
+ const decodedBody = Buffer.isBuffer(skResponse.body)
187
234
  ? skResponse.body
188
- : iconv.encode(skResponse.body, textEncoding), skResponse.headers["content-type"] ?? `text/html;charset=${textEncoding}`, [...customHeaders, ...originHeaders]);
189
- this.cache.addEntry(requestUrl, baqendResponse);
235
+ : iconv.encode(skResponse.body, textEncoding);
236
+ const baqendResponse = new BaqendResponse(decodedBody, skResponse.headers["content-type"] ?? `text/html;charset=${textEncoding}`, [...customHeaders, ...originHeaders]);
237
+ this.cache.addEntry(requestUrl, baqendResponse, decodedBody);
190
238
  return baqendResponse;
191
239
  }
192
240
  async getResponseText(response) {
193
241
  const { text, charset } = decodeHtml(response?.headers.get("content-type") || "", Buffer.from(await response.arrayBuffer()));
194
242
  return { responseContent: text, textEncoding: charset };
195
243
  }
244
+ /**
245
+ * The urls the local documentHandler could not build, as they stand now.
246
+ *
247
+ * Already collected for the devtools panel; this is the same list for a
248
+ * reader without one. State rather than history: an entry disappears once the
249
+ * same url and variation builds successfully, so an empty list means nothing
250
+ * is currently failing, not that nothing ever did.
251
+ *
252
+ * `occurredAt` is converted to ISO on the way out — the panel wants epoch
253
+ * milliseconds to sort by, a reader wants a timestamp it can compare against
254
+ * a log line.
255
+ */
256
+ getLocalCacheErrors() {
257
+ return [...this.localCacheErrors.values()].map((error) => ({
258
+ ...error,
259
+ occurredAt: new Date(error.occurredAt).toISOString(),
260
+ }));
261
+ }
196
262
  localCacheErrorKey(url, variation) {
197
263
  return `${url}|${variation}`;
198
264
  }
@@ -227,6 +293,24 @@ export class VirtualOrestesApp {
227
293
  * `ServerDocumentHandlerAbort`. Answering 500 instead makes the service worker treat
228
294
  * the page as an infrastructure failure and disconnect Speed Kit.
229
295
  */
296
+ /** What Orestes answers for an undefined variation: the service worker serves from origin. */
297
+ returnBreakResponse(originUrl) {
298
+ if (!this.breakPages.has(originUrl)) {
299
+ this.breakPages.add(originUrl);
300
+ this.cli.comment(`${originUrl} has the variation break: served from origin, not accelerated`, false, {
301
+ scope: "cache",
302
+ data: { url: originUrl, variation: BREAK_VARIATION },
303
+ });
304
+ }
305
+ const message = `Variation ${BREAK_VARIATION} not found.`;
306
+ return new BaqendResponse(message, null, [
307
+ { name: "x-error", value: message },
308
+ {
309
+ name: "server-timing",
310
+ value: originErrorServerTiming(VARIATION_NOT_DEFINED_CODE),
311
+ },
312
+ ], ORIGIN_ERROR_STATUS_CODE);
313
+ }
230
314
  returnAbortResponse(customResponse, customHeaders) {
231
315
  const message = customResponse.error;
232
316
  this.reportAbort(message, customResponse.errorObj);
@@ -238,13 +322,17 @@ export class VirtualOrestesApp {
238
322
  this.warnPrerendererUnreachable();
239
323
  return;
240
324
  }
325
+ const meta = {
326
+ scope: "documentHandler",
327
+ data: { aborted: true, status: ABORT_STATUS_CODE, error: message },
328
+ };
241
329
  const failure = prerenderFailure(error);
242
330
  if (failure) {
243
331
  this.cli.writeError(`[DocumentHandler:local]: SSR failed for ${failure.url} (${failure.variation}): ` +
244
- `${failure.detailMessage ?? "no error message"}`);
332
+ `${failure.detailMessage ?? "no error message"}`, false, meta);
245
333
  return;
246
334
  }
247
- this.cli.writeWarning(`[DocumentHandler:local]: ${message}`);
335
+ this.cli.writeWarning(`[DocumentHandler:local]: ${message}`, false, meta);
248
336
  }
249
337
  warnPrerendererUnreachable() {
250
338
  const unreachable = `no pre-renderer is listening on localhost:${LOCAL_PRERENDERER_PORT}`;
@@ -291,9 +379,18 @@ export class VirtualOrestesApp {
291
379
  return this.returnAbortResponse(customResponse, customHeaders);
292
380
  }
293
381
  const message = `Could not transform html: - ${customResponse.error}`;
294
- this.cli.writeError(`[VirtualOrestes]: ${message}`);
295
- this.cli.comment(customResponse.errorObj.stack);
296
- this.cli.writeWarning("Suggestion: check files: config_documentHandler.es6 | custom_documentHandler.js");
382
+ this.cli.writeError(`[VirtualOrestes]: ${message}`, false, {
383
+ scope: "documentHandler",
384
+ data: {
385
+ error: customResponse.error,
386
+ stack: customResponse.errorObj.stack,
387
+ },
388
+ });
389
+ this.cli.comment(customResponse.errorObj.stack, false, {
390
+ scope: "documentHandler",
391
+ level: "debug",
392
+ });
393
+ this.cli.writeWarning("Suggestion: check files: config_documentHandler.es6 | custom_documentHandler.js", false, { scope: "documentHandler" });
297
394
  customHeaders.push({ name: "x-error", value: message });
298
395
  return new BaqendResponse(message, null, customHeaders, 500);
299
396
  }
@@ -310,7 +407,7 @@ export class VirtualOrestesApp {
310
407
  value: response?.headers.get("location") || "",
311
408
  });
312
409
  const redirectResponse = new BaqendResponse("", null, customHeaders, response.status);
313
- this.cache.addEntry(requestUrl, redirectResponse);
410
+ this.cache.addEntry(requestUrl, redirectResponse, "");
314
411
  return redirectResponse;
315
412
  }
316
413
  handleCdnRedirect(customHeaders, response, requestUrl) {
@@ -328,22 +425,11 @@ export class VirtualOrestesApp {
328
425
  // the CDN redirect surfaced as a bare ClientError (`AssetAPIHandler.ts:200-205`).
329
426
  serverTimingHeader.value += ",errorcode;desc=202";
330
427
  const redirectResponse = new BaqendResponse("", null, customHeaders, 400);
331
- this.cache.addEntry(requestUrl, redirectResponse);
428
+ this.cache.addEntry(requestUrl, redirectResponse, "");
332
429
  return redirectResponse;
333
430
  }
334
431
  getAssetUrl(requestUrl) {
335
- const url = new URL(requestUrl);
336
- const parametersToDelete = [];
337
- for (const [name] of url.searchParams.entries()) {
338
- if (name.startsWith("bq")) {
339
- parametersToDelete.push(name);
340
- }
341
- }
342
- for (const parameter of parametersToDelete) {
343
- url.searchParams.delete(parameter);
344
- }
345
- const cleanedUrl = url.toString();
346
- return cleanedUrl.split("app.baqend.com/v1/asset/")[1];
432
+ return assetOriginUrl(requestUrl);
347
433
  }
348
434
  getCachedResponse(requestUrl) {
349
435
  const response = this.cache.getEntry(requestUrl);
@@ -19,6 +19,13 @@ export interface AssetVariation {
19
19
  regex?: string | null;
20
20
  /** Which config key produced this entry. Set during resolution, for reporting. */
21
21
  matchedKey?: string;
22
+ /**
23
+ * Set during resolution, for reporting: the entry came from a regex key that
24
+ * matched the requested variation, not from a key of that name. Carried on
25
+ * the entry because only the resolution knows it — reading it back off the
26
+ * finished chain cannot tell a named key from a matched template.
27
+ */
28
+ viaTemplate?: boolean;
22
29
  }
23
30
  export type AssetVariationMap = Record<string, AssetVariation>;
24
31
  /** An entry of the runtime config's `speedKit.originMap`, keyed by origin or by host. */
@@ -48,6 +55,13 @@ export declare const DEFAULT_TYPE = "default";
48
55
  export declare const DEFAULT_USER_AGENT = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/18.6 Safari/605.1.15 (compatible; SpeedKit/1.0)";
49
56
  export declare const MOBILE_USER_AGENT = "Mozilla/5.0 (iPhone; CPU iPhone OS 18_6_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/18.6 Mobile/15E148 Safari/604.1 (compatible; SpeedKit/1.0)";
50
57
  export declare const TABLET_USER_AGENT = "Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/139.0.0.0 Safari/537.36 (compatible; SpeedKit/1.0)";
58
+ /**
59
+ * The variation types the server resolves whether a config defines them or not.
60
+ *
61
+ * Exported because "which variations exist" is otherwise answered with the config's own keys alone,
62
+ * and a config that defines none reads as "nothing can be passed" while these three still work.
63
+ */
64
+ export declare const DEVICE_DEFAULT_TYPES: string[];
51
65
  /** Thrown where the server would throw UndefinedVariationException. */
52
66
  export declare class UndefinedVariationError extends Error {
53
67
  constructor(variationType: string);