@speedkit/cli 4.50.5 → 4.51.0-run-control.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1369 -10
- package/dist/base/run-control-command.d.ts +15 -0
- package/dist/base/run-control-command.js +20 -0
- package/dist/build-info.json +6 -0
- package/dist/commands/diff.d.ts +6 -1
- package/dist/commands/diff.js +9 -3
- package/dist/commands/onboarding/browser/click.d.ts +75 -0
- package/dist/commands/onboarding/browser/click.js +19 -0
- package/dist/commands/onboarding/browser/emulate.d.ts +93 -0
- package/dist/commands/onboarding/browser/emulate.js +23 -0
- package/dist/commands/onboarding/browser/navigate.d.ts +67 -0
- package/dist/commands/onboarding/browser/navigate.js +18 -0
- package/dist/commands/onboarding/browser/panel.d.ts +63 -0
- package/dist/commands/onboarding/browser/panel.js +12 -0
- package/dist/commands/onboarding/browser/reinstall-sw.d.ts +63 -0
- package/dist/commands/onboarding/browser/reinstall-sw.js +14 -0
- package/dist/commands/onboarding/browser/reset.d.ts +71 -0
- package/dist/commands/onboarding/browser/reset.js +18 -0
- package/dist/commands/onboarding/browser/screenshot.d.ts +77 -0
- package/dist/commands/onboarding/browser/screenshot.js +19 -0
- package/dist/commands/onboarding/browser/state.d.ts +63 -0
- package/dist/commands/onboarding/browser/state.js +12 -0
- package/dist/commands/onboarding/browser/tabs.d.ts +58 -0
- package/dist/commands/onboarding/browser/tabs.js +16 -0
- package/dist/commands/onboarding/cache/clear.d.ts +58 -0
- package/dist/commands/onboarding/cache/clear.js +12 -0
- package/dist/commands/onboarding/cache/errors.d.ts +58 -0
- package/dist/commands/onboarding/cache/errors.js +12 -0
- package/dist/commands/onboarding/cache/evict.d.ts +62 -0
- package/dist/commands/onboarding/cache/evict.js +15 -0
- package/dist/commands/onboarding/cache/get.d.ts +85 -0
- package/dist/commands/onboarding/cache/get.js +17 -0
- package/dist/commands/onboarding/cache/list.d.ts +58 -0
- package/dist/commands/onboarding/cache/list.js +15 -0
- package/dist/commands/onboarding/cache/prewarm.d.ts +73 -0
- package/dist/commands/onboarding/cache/prewarm.js +20 -0
- package/dist/commands/onboarding/cache/refresh.d.ts +62 -0
- package/dist/commands/onboarding/cache/refresh.js +18 -0
- package/dist/commands/onboarding/cdp.d.ts +81 -0
- package/dist/commands/onboarding/cdp.js +18 -0
- package/dist/commands/onboarding/debug/arm.d.ts +77 -0
- package/dist/commands/onboarding/debug/arm.js +18 -0
- package/dist/commands/onboarding/debug/await.d.ts +71 -0
- package/dist/commands/onboarding/debug/await.js +18 -0
- package/dist/commands/onboarding/debug/disarm.d.ts +63 -0
- package/dist/commands/onboarding/debug/disarm.js +12 -0
- package/dist/commands/onboarding/debug/eval.d.ts +75 -0
- package/dist/commands/onboarding/debug/eval.js +16 -0
- package/dist/commands/onboarding/debug/release.d.ts +63 -0
- package/dist/commands/onboarding/debug/release.js +12 -0
- package/dist/commands/onboarding/debug/resume.d.ts +63 -0
- package/dist/commands/onboarding/debug/resume.js +12 -0
- package/dist/commands/onboarding/debug/status.d.ts +63 -0
- package/dist/commands/onboarding/debug/status.js +12 -0
- package/dist/commands/onboarding/debug/step.d.ts +67 -0
- package/dist/commands/onboarding/debug/step.js +15 -0
- package/dist/commands/onboarding/files/list.d.ts +58 -0
- package/dist/commands/onboarding/files/list.js +12 -0
- package/dist/commands/onboarding/files/read.d.ts +73 -0
- package/dist/commands/onboarding/files/read.js +16 -0
- package/dist/commands/onboarding/files/rebuild.d.ts +63 -0
- package/dist/commands/onboarding/files/rebuild.js +18 -0
- package/dist/commands/onboarding/files/validate.d.ts +58 -0
- package/dist/commands/onboarding/files/validate.js +12 -0
- package/dist/commands/onboarding/fouc.d.ts +77 -0
- package/dist/commands/onboarding/fouc.js +16 -0
- package/dist/commands/onboarding/inject/add.d.ts +89 -0
- package/dist/commands/onboarding/inject/add.js +17 -0
- package/dist/commands/onboarding/inject/clear.d.ts +63 -0
- package/dist/commands/onboarding/inject/clear.js +12 -0
- package/dist/commands/onboarding/inject/list.d.ts +63 -0
- package/dist/commands/onboarding/inject/list.js +12 -0
- package/dist/commands/onboarding/inject/read.d.ts +75 -0
- package/dist/commands/onboarding/inject/read.js +18 -0
- package/dist/commands/onboarding/inject/recipes.d.ts +63 -0
- package/dist/commands/onboarding/inject/recipes.js +12 -0
- package/dist/commands/onboarding/inject/remove.d.ts +67 -0
- package/dist/commands/onboarding/inject/remove.js +15 -0
- package/dist/commands/onboarding/list.d.ts +13 -0
- package/dist/commands/onboarding/list.js +12 -0
- package/dist/commands/onboarding/logs.d.ts +41 -0
- package/dist/commands/onboarding/logs.js +256 -0
- package/dist/commands/onboarding/navwalk.d.ts +95 -0
- package/dist/commands/onboarding/navwalk.js +19 -0
- package/dist/commands/onboarding/response.d.ts +67 -0
- package/dist/commands/onboarding/response.js +18 -0
- package/dist/commands/onboarding/rum/beacons.d.ts +75 -0
- package/dist/commands/onboarding/rum/beacons.js +16 -0
- package/dist/commands/onboarding/rum/get.d.ts +77 -0
- package/dist/commands/onboarding/rum/get.js +18 -0
- package/dist/commands/onboarding/rum/key.d.ts +67 -0
- package/dist/commands/onboarding/rum/key.js +13 -0
- package/dist/commands/onboarding/rum/previous.d.ts +63 -0
- package/dist/commands/onboarding/rum/previous.js +12 -0
- package/dist/commands/onboarding/status.d.ts +13 -0
- package/dist/commands/onboarding/status.js +17 -0
- package/dist/commands/onboarding/todo.d.ts +58 -0
- package/dist/commands/onboarding/todo.js +12 -0
- package/dist/commands/onboarding/viewport.d.ts +101 -0
- package/dist/commands/onboarding/viewport.js +18 -0
- package/dist/commands/onboarding/watch.d.ts +93 -0
- package/dist/commands/onboarding/watch.js +16 -0
- package/dist/commands/onboarding.d.ts +26 -0
- package/dist/commands/onboarding.js +220 -3
- package/dist/commands/origin-request.d.ts +4 -0
- package/dist/commands/origin-request.js +4 -0
- package/dist/commands/spec/onboarding.spec.d.ts +1 -0
- package/dist/commands/spec/onboarding.spec.js +127 -0
- package/dist/services/cli/build-info.d.ts +33 -0
- package/dist/services/cli/build-info.js +63 -0
- package/dist/services/cli/cli-environment-factory.d.ts +3 -0
- package/dist/services/cli/cli-environment-factory.js +1 -0
- package/dist/services/cli/cli-service-build-context.d.ts +3 -0
- package/dist/services/cli/cli-service-factory.js +1 -1
- package/dist/services/cli/cli-service-model.d.ts +29 -10
- package/dist/services/cli/cli-service.d.ts +60 -11
- package/dist/services/cli/cli-service.js +196 -32
- package/dist/services/cli/index.d.ts +2 -0
- package/dist/services/cli/index.js +2 -0
- package/dist/services/cli/sink.d.ts +47 -0
- package/dist/services/cli/sink.js +31 -0
- package/dist/services/cli/spec/build-identity.spec.d.ts +1 -0
- package/dist/services/cli/spec/build-identity.spec.js +85 -0
- package/dist/services/cli/spec/build-info.spec.d.ts +1 -0
- package/dist/services/cli/spec/build-info.spec.js +10 -0
- package/dist/services/cli/spec/cli-service-log.spec.d.ts +1 -0
- package/dist/services/cli/spec/cli-service-log.spec.js +133 -0
- package/dist/services/cli/spec/cli-service.spec.js +113 -50
- package/dist/services/cli/spec/memory-cli.d.ts +9 -0
- package/dist/services/cli/spec/memory-cli.js +9 -0
- package/dist/services/diff/config-at-ref.d.ts +20 -0
- package/dist/services/diff/config-at-ref.js +33 -0
- package/dist/services/diff/diff-service-build-context.d.ts +8 -0
- package/dist/services/diff/diff-service-build-context.js +40 -1
- package/dist/services/diff/diff-service-factory.d.ts +2 -0
- package/dist/services/diff/diff-service-factory.js +48 -20
- package/dist/services/diff/diff-service.d.ts +11 -0
- package/dist/services/diff/diff-service.js +37 -11
- package/dist/services/diff/page-source.d.ts +12 -0
- package/dist/services/diff/page-source.js +16 -11
- package/dist/services/diff/sinks/tool-diff-sink.d.ts +3 -2
- package/dist/services/diff/sinks/tool-diff-sink.js +3 -2
- package/dist/services/diff/spec/config-at-ref.spec.d.ts +1 -0
- package/dist/services/diff/spec/config-at-ref.spec.js +46 -0
- package/dist/services/diff/spec/diff-service-build-context.spec.js +19 -0
- package/dist/services/diff/spec/diff-service.spec.js +95 -0
- package/dist/services/git/git-repository.d.ts +2 -0
- package/dist/services/git/git-repository.js +6 -0
- package/dist/services/integration-api/customer-config-flags.js +1 -0
- package/dist/services/onboarding/browser/baqend-response.d.ts +17 -1
- package/dist/services/onboarding/browser/baqend-response.js +23 -0
- package/dist/services/onboarding/browser/console-log.d.ts +9 -0
- package/dist/services/onboarding/browser/console-log.js +27 -0
- package/dist/services/onboarding/browser/executable/executable-validator.js +4 -2
- package/dist/services/onboarding/browser/extension/extension-bridge.js +5 -3
- package/dist/services/onboarding/browser/extension/extension-downloader.js +17 -8
- package/dist/services/onboarding/browser/extension/extension-validator.js +9 -4
- package/dist/services/onboarding/control/body-inspect.d.ts +24 -0
- package/dist/services/onboarding/control/body-inspect.js +106 -0
- package/dist/services/onboarding/control/browser-session.d.ts +521 -0
- package/dist/services/onboarding/control/browser-session.js +1273 -0
- package/dist/services/onboarding/control/config-validation.d.ts +17 -0
- package/dist/services/onboarding/control/config-validation.js +46 -0
- package/dist/services/onboarding/control/control-protocol.d.ts +1390 -0
- package/dist/services/onboarding/control/control-protocol.js +69 -0
- package/dist/services/onboarding/control/control-server.d.ts +284 -0
- package/dist/services/onboarding/control/control-server.js +1609 -0
- package/dist/services/onboarding/control/debug-session.d.ts +190 -0
- package/dist/services/onboarding/control/debug-session.js +801 -0
- package/dist/services/onboarding/control/fouc.d.ts +23 -0
- package/dist/services/onboarding/control/fouc.js +151 -0
- package/dist/services/onboarding/control/index.d.ts +4 -0
- package/dist/services/onboarding/control/index.js +4 -0
- package/dist/services/onboarding/control/navwalk.d.ts +65 -0
- package/dist/services/onboarding/control/navwalk.js +248 -0
- package/dist/services/onboarding/control/preload-registry.d.ts +150 -0
- package/dist/services/onboarding/control/preload-registry.js +829 -0
- package/dist/services/onboarding/control/response-explainer.d.ts +24 -0
- package/dist/services/onboarding/control/response-explainer.js +257 -0
- package/dist/services/onboarding/control/rum.d.ts +8 -0
- package/dist/services/onboarding/control/rum.js +220 -0
- package/dist/services/onboarding/control/service-worker-tracker.d.ts +68 -0
- package/dist/services/onboarding/control/service-worker-tracker.js +119 -0
- package/dist/services/onboarding/control/viewport.d.ts +45 -0
- package/dist/services/onboarding/control/viewport.js +344 -0
- package/dist/services/onboarding/control/watch.d.ts +26 -0
- package/dist/services/onboarding/control/watch.js +149 -0
- package/dist/services/onboarding/dashboard/diff-against-current-page.js +3 -1
- package/dist/services/onboarding/dashboard/index.js +7 -2
- package/dist/services/onboarding/fetch-event-handler.d.ts +24 -5
- package/dist/services/onboarding/fetch-event-handler.js +94 -32
- package/dist/services/onboarding/fetch-events/speed-kit-install-js.js +11 -2
- package/dist/services/onboarding/fetch-events/speed-kit-rum-pi-request.d.ts +14 -0
- package/dist/services/onboarding/fetch-events/speed-kit-rum-pi-request.js +30 -0
- package/dist/services/onboarding/fetch-events/speed-kit-service-worker-js.d.ts +13 -0
- package/dist/services/onboarding/fetch-events/speed-kit-service-worker-js.js +28 -1
- package/dist/services/onboarding/file-events/file-watcher.d.ts +42 -1
- package/dist/services/onboarding/file-events/file-watcher.js +117 -12
- package/dist/services/onboarding/onboarding-model.d.ts +30 -0
- package/dist/services/onboarding/onboarding-model.js +10 -0
- package/dist/services/onboarding/onboarding-service-build-context.d.ts +4 -0
- package/dist/services/onboarding/onboarding-service-build-context.js +6 -0
- package/dist/services/onboarding/onboarding-service-factory.d.ts +17 -1
- package/dist/services/onboarding/onboarding-service-factory.js +131 -17
- package/dist/services/onboarding/onboarding-service.d.ts +40 -1
- package/dist/services/onboarding/onboarding-service.js +135 -22
- package/dist/services/onboarding/request-cache/asset-key.d.ts +61 -0
- package/dist/services/onboarding/request-cache/asset-key.js +115 -0
- package/dist/services/onboarding/request-cache/cache.d.ts +62 -5
- package/dist/services/onboarding/request-cache/cache.js +128 -17
- package/dist/services/onboarding/spec/browser/console-log.spec.d.ts +1 -0
- package/dist/services/onboarding/spec/browser/console-log.spec.js +42 -0
- package/dist/services/onboarding/spec/control/browser-session.spec.d.ts +1 -0
- package/dist/services/onboarding/spec/control/browser-session.spec.js +526 -0
- package/dist/services/onboarding/spec/control/control-server.spec.d.ts +1 -0
- package/dist/services/onboarding/spec/control/control-server.spec.js +338 -0
- package/dist/services/onboarding/spec/control/debug-session.spec.d.ts +1 -0
- package/dist/services/onboarding/spec/control/debug-session.spec.js +693 -0
- package/dist/services/onboarding/spec/control/fakes.d.ts +31 -0
- package/dist/services/onboarding/spec/control/fakes.js +66 -0
- package/dist/services/onboarding/spec/control/fouc.spec.d.ts +1 -0
- package/dist/services/onboarding/spec/control/fouc.spec.js +167 -0
- package/dist/services/onboarding/spec/control/navwalk.spec.d.ts +1 -0
- package/dist/services/onboarding/spec/control/navwalk.spec.js +222 -0
- package/dist/services/onboarding/spec/control/preload-registry.spec.d.ts +1 -0
- package/dist/services/onboarding/spec/control/preload-registry.spec.js +432 -0
- package/dist/services/onboarding/spec/control/response-explainer.spec.d.ts +1 -0
- package/dist/services/onboarding/spec/control/response-explainer.spec.js +324 -0
- package/dist/services/onboarding/spec/control/rum.spec.d.ts +1 -0
- package/dist/services/onboarding/spec/control/rum.spec.js +222 -0
- package/dist/services/onboarding/spec/control/service-worker-tracker.spec.d.ts +1 -0
- package/dist/services/onboarding/spec/control/service-worker-tracker.spec.js +193 -0
- package/dist/services/onboarding/spec/control/viewport.spec.d.ts +1 -0
- package/dist/services/onboarding/spec/control/viewport.spec.js +200 -0
- package/dist/services/onboarding/spec/control/watch.spec.d.ts +1 -0
- package/dist/services/onboarding/spec/control/watch.spec.js +172 -0
- package/dist/services/onboarding/spec/fetch-event-handler.spec.d.ts +1 -0
- package/dist/services/onboarding/spec/fetch-event-handler.spec.js +202 -0
- package/dist/services/onboarding/spec/fetch-events/speed-kit-service-worker-js.spec.d.ts +1 -0
- package/dist/services/onboarding/spec/fetch-events/speed-kit-service-worker-js.spec.js +41 -0
- package/dist/services/onboarding/spec/onboarding-model.spec.js +37 -0
- package/dist/services/onboarding/spec/onboarding-service-factory.spec.js +1 -0
- package/dist/services/onboarding/spec/request-cache/cache.spec.d.ts +1 -0
- package/dist/services/onboarding/spec/request-cache/cache.spec.js +107 -0
- package/dist/services/onboarding/spec/todo-collector.spec.d.ts +1 -0
- package/dist/services/onboarding/spec/todo-collector.spec.js +136 -0
- package/dist/services/onboarding/todo-collector.d.ts +7 -2
- package/dist/services/onboarding/todo-collector.js +49 -12
- package/dist/services/onboarding/virtual-orestes-app/index.d.ts +34 -0
- package/dist/services/onboarding/virtual-orestes-app/index.js +82 -27
- package/dist/services/origin-request/asset-variations.d.ts +14 -0
- package/dist/services/origin-request/asset-variations.js +11 -4
- package/dist/services/origin-request/origin-fetcher.d.ts +7 -0
- package/dist/services/origin-request/origin-fetcher.js +43 -5
- package/dist/services/origin-request/origin-request-service-build-context.d.ts +17 -0
- package/dist/services/origin-request/origin-request-service-build-context.js +8 -0
- package/dist/services/origin-request/origin-request-service-factory.d.ts +0 -5
- package/dist/services/origin-request/origin-request-service-factory.js +2 -30
- package/dist/services/origin-request/origin-request-service.d.ts +121 -6
- package/dist/services/origin-request/origin-request-service.js +273 -49
- package/dist/services/origin-request/runtime-config-source.js +9 -4
- package/dist/services/origin-request/spec/asset-variations.spec.js +20 -0
- package/dist/services/origin-request/spec/origin-request-service.spec.js +329 -6
- package/dist/services/query-builder/rules/rule-match.d.ts +35 -0
- package/dist/services/query-builder/rules/rule-match.js +70 -0
- package/dist/services/query-builder/spec/rules/rule-match.spec.d.ts +1 -0
- package/dist/services/query-builder/spec/rules/rule-match.spec.js +121 -0
- package/dist/services/run-control/browser/run-browser-contexts.d.ts +541 -0
- package/dist/services/run-control/browser/run-browser-contexts.js +78 -0
- package/dist/services/run-control/browser/run-browser-service-factory.d.ts +5 -0
- package/dist/services/run-control/browser/run-browser-service-factory.js +7 -0
- package/dist/services/run-control/browser/run-browser-service.d.ts +64 -0
- package/dist/services/run-control/browser/run-browser-service.js +199 -0
- package/dist/services/run-control/cache/run-cache-contexts.d.ts +349 -0
- package/dist/services/run-control/cache/run-cache-contexts.js +51 -0
- package/dist/services/run-control/cache/run-cache-service-factory.d.ts +6 -0
- package/dist/services/run-control/cache/run-cache-service-factory.js +12 -0
- package/dist/services/run-control/cache/run-cache-service.d.ts +35 -0
- package/dist/services/run-control/cache/run-cache-service.js +151 -0
- package/dist/services/run-control/control-client.d.ts +36 -0
- package/dist/services/run-control/control-client.js +147 -0
- package/dist/services/run-control/debug/run-debug-contexts.d.ts +411 -0
- package/dist/services/run-control/debug/run-debug-contexts.js +44 -0
- package/dist/services/run-control/debug/run-debug-service-factory.d.ts +5 -0
- package/dist/services/run-control/debug/run-debug-service-factory.js +7 -0
- package/dist/services/run-control/debug/run-debug-service.d.ts +38 -0
- package/dist/services/run-control/debug/run-debug-service.js +161 -0
- package/dist/services/run-control/files/run-files-contexts.d.ts +238 -0
- package/dist/services/run-control/files/run-files-contexts.js +26 -0
- package/dist/services/run-control/files/run-files-service-factory.d.ts +5 -0
- package/dist/services/run-control/files/run-files-service-factory.js +7 -0
- package/dist/services/run-control/files/run-files-service.d.ts +29 -0
- package/dist/services/run-control/files/run-files-service.js +120 -0
- package/dist/services/run-control/index.d.ts +32 -0
- package/dist/services/run-control/index.js +31 -0
- package/dist/services/run-control/inject/run-inject-contexts.d.ts +319 -0
- package/dist/services/run-control/inject/run-inject-contexts.js +32 -0
- package/dist/services/run-control/inject/run-inject-service-factory.d.ts +5 -0
- package/dist/services/run-control/inject/run-inject-service-factory.js +7 -0
- package/dist/services/run-control/inject/run-inject-service.d.ts +31 -0
- package/dist/services/run-control/inject/run-inject-service.js +203 -0
- package/dist/services/run-control/live-run.d.ts +37 -0
- package/dist/services/run-control/live-run.js +56 -0
- package/dist/services/run-control/probe/run-probe-contexts.d.ts +333 -0
- package/dist/services/run-control/probe/run-probe-contexts.js +73 -0
- package/dist/services/run-control/probe/run-probe-service-factory.d.ts +5 -0
- package/dist/services/run-control/probe/run-probe-service-factory.js +7 -0
- package/dist/services/run-control/probe/run-probe-service.d.ts +54 -0
- package/dist/services/run-control/probe/run-probe-service.js +193 -0
- package/dist/services/run-control/rum/run-rum-contexts.d.ts +216 -0
- package/dist/services/run-control/rum/run-rum-contexts.js +34 -0
- package/dist/services/run-control/rum/run-rum-service-factory.d.ts +5 -0
- package/dist/services/run-control/rum/run-rum-service-factory.js +7 -0
- package/dist/services/run-control/rum/run-rum-service.d.ts +36 -0
- package/dist/services/run-control/rum/run-rum-service.js +122 -0
- package/dist/services/run-control/run-answer.d.ts +28 -0
- package/dist/services/run-control/run-answer.js +58 -0
- package/dist/services/run-control/run-control-context.d.ts +102 -0
- package/dist/services/run-control/run-control-context.js +36 -0
- package/dist/services/run-control/run-control-flags.d.ts +12 -0
- package/dist/services/run-control/run-control-flags.js +22 -0
- package/dist/services/run-control/run-control-model.d.ts +9 -0
- package/dist/services/run-control/run-control-model.js +1 -0
- package/dist/services/run-control/run-control-service-factory.d.ts +14 -0
- package/dist/services/run-control/run-control-service-factory.js +26 -0
- package/dist/services/run-control/session/run-session-contexts.d.ts +25 -0
- package/dist/services/run-control/session/run-session-contexts.js +20 -0
- package/dist/services/run-control/session/run-session-service-factory.d.ts +8 -0
- package/dist/services/run-control/session/run-session-service-factory.js +18 -0
- package/dist/services/run-control/session/run-session-service.d.ts +25 -0
- package/dist/services/run-control/session/run-session-service.js +95 -0
- package/dist/services/run-control/spec/browser/run-browser-service.spec.d.ts +1 -0
- package/dist/services/run-control/spec/browser/run-browser-service.spec.js +327 -0
- package/dist/services/run-control/spec/cache/run-cache-service.spec.d.ts +1 -0
- package/dist/services/run-control/spec/cache/run-cache-service.spec.js +454 -0
- package/dist/services/run-control/spec/debug/run-debug-service.spec.d.ts +1 -0
- package/dist/services/run-control/spec/debug/run-debug-service.spec.js +113 -0
- package/dist/services/run-control/spec/files/run-files-service.spec.d.ts +1 -0
- package/dist/services/run-control/spec/files/run-files-service.spec.js +234 -0
- package/dist/services/run-control/spec/inject/run-inject-service.spec.d.ts +1 -0
- package/dist/services/run-control/spec/inject/run-inject-service.spec.js +224 -0
- package/dist/services/run-control/spec/live-run-fixture.d.ts +32 -0
- package/dist/services/run-control/spec/live-run-fixture.js +109 -0
- package/dist/services/run-control/spec/probe/run-probe-service.spec.d.ts +1 -0
- package/dist/services/run-control/spec/probe/run-probe-service.spec.js +108 -0
- package/dist/services/run-control/spec/rum/run-rum-service.spec.d.ts +1 -0
- package/dist/services/run-control/spec/rum/run-rum-service.spec.js +47 -0
- package/dist/services/run-control/spec/run-answer.spec.d.ts +1 -0
- package/dist/services/run-control/spec/run-answer.spec.js +57 -0
- package/dist/services/run-control/spec/session/run-session-service.spec.d.ts +1 -0
- package/dist/services/run-control/spec/session/run-session-service.spec.js +101 -0
- package/dist/services/run-log/crash-mirror.d.ts +31 -0
- package/dist/services/run-log/crash-mirror.js +69 -0
- package/dist/services/run-log/index.d.ts +11 -0
- package/dist/services/run-log/index.js +11 -0
- package/dist/services/run-log/jsonl-appender.d.ts +46 -0
- package/dist/services/run-log/jsonl-appender.js +91 -0
- package/dist/services/run-log/log-event-model.d.ts +104 -0
- package/dist/services/run-log/log-event-model.js +56 -0
- package/dist/services/run-log/log-query-service-factory.d.ts +11 -0
- package/dist/services/run-log/log-query-service-factory.js +14 -0
- package/dist/services/run-log/log-query-service.d.ts +59 -0
- package/dist/services/run-log/log-query-service.js +111 -0
- package/dist/services/run-log/log-reader.d.ts +84 -0
- package/dist/services/run-log/log-reader.js +180 -0
- package/dist/services/run-log/log-summary.d.ts +72 -0
- package/dist/services/run-log/log-summary.js +208 -0
- package/dist/services/run-log/redaction.d.ts +34 -0
- package/dist/services/run-log/redaction.js +124 -0
- package/dist/services/run-log/request-log.d.ts +80 -0
- package/dist/services/run-log/request-log.js +69 -0
- package/dist/services/run-log/request-summary.d.ts +76 -0
- package/dist/services/run-log/request-summary.js +0 -0
- package/dist/services/run-log/run-log.d.ts +61 -0
- package/dist/services/run-log/run-log.js +102 -0
- package/dist/services/run-log/spec/log-query-service.spec.d.ts +1 -0
- package/dist/services/run-log/spec/log-query-service.spec.js +197 -0
- package/dist/services/run-log/spec/log-reader.spec.d.ts +1 -0
- package/dist/services/run-log/spec/log-reader.spec.js +109 -0
- package/dist/services/run-log/spec/log-summary.spec.d.ts +1 -0
- package/dist/services/run-log/spec/log-summary.spec.js +153 -0
- package/dist/services/run-log/spec/redaction.spec.d.ts +1 -0
- package/dist/services/run-log/spec/redaction.spec.js +61 -0
- package/dist/services/run-log/spec/request-log.spec.d.ts +1 -0
- package/dist/services/run-log/spec/request-log.spec.js +101 -0
- package/dist/services/run-log/spec/request-summary.spec.d.ts +1 -0
- package/dist/services/run-log/spec/request-summary.spec.js +171 -0
- package/dist/services/run-log/spec/run-log.spec.d.ts +1 -0
- package/dist/services/run-log/spec/run-log.spec.js +122 -0
- package/dist/services/run-registry/exit-classification.d.ts +39 -0
- package/dist/services/run-registry/exit-classification.js +42 -0
- package/dist/services/run-registry/index.d.ts +3 -0
- package/dist/services/run-registry/index.js +3 -0
- package/dist/services/run-registry/process-identity.d.ts +28 -0
- package/dist/services/run-registry/process-identity.js +80 -0
- package/dist/services/run-registry/run-registry-model.d.ts +128 -0
- package/dist/services/run-registry/run-registry-model.js +16 -0
- package/dist/services/run-registry/run-registry.d.ts +150 -0
- package/dist/services/run-registry/run-registry.js +409 -0
- package/dist/services/run-registry/spec/exit-classification.spec.d.ts +1 -0
- package/dist/services/run-registry/spec/exit-classification.spec.js +82 -0
- package/dist/services/run-registry/spec/run-registry.spec.d.ts +1 -0
- package/dist/services/run-registry/spec/run-registry.spec.js +509 -0
- package/dist/services/setup/os/tool-registry.js +2 -2
- package/oclif.manifest.json +3293 -272
- package/package.json +20 -2
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { FoucData } from "./control-protocol.js";
|
|
2
|
+
import { PreloadRegistry } from "./preload-registry.js";
|
|
3
|
+
export interface FoucOptions {
|
|
4
|
+
selector?: string;
|
|
5
|
+
durationMs?: number;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Catch a paint that happened before the page was styled.
|
|
9
|
+
*
|
|
10
|
+
* The symptom is a flash of unstyled content, and it is the one Speed Kit
|
|
11
|
+
* failure that is invisible by the time anyone can look: by the end of the load
|
|
12
|
+
* the page is styled, so every after-the-fact inspection says it is fine. The
|
|
13
|
+
* only way to see it is to sample across the load itself.
|
|
14
|
+
*
|
|
15
|
+
* The test is a comparison rather than a screenshot: did a contentful paint
|
|
16
|
+
* happen while the document had fewer stylesheets applied than it ended up
|
|
17
|
+
* with. That is a heuristic and it is worth knowing which way it errs — a page
|
|
18
|
+
* that loads a late, purely decorative sheet reads as a flash it never had, and
|
|
19
|
+
* a page whose first sheet arrives with the document but applies to nothing
|
|
20
|
+
* reads as clean. The samples are returned so the verdict can be checked rather
|
|
21
|
+
* than taken.
|
|
22
|
+
*/
|
|
23
|
+
export declare function runFouc(preloads: PreloadRegistry, reload: () => Promise<void>, options: FoucOptions): Promise<FoucData>;
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
/** Fast enough to land between a paint and the stylesheet that follows it. */
|
|
2
|
+
const SAMPLE_MS = 16;
|
|
3
|
+
const DEFAULT_DURATION_MS = 8_000;
|
|
4
|
+
const MAX_DURATION_MS = 60_000;
|
|
5
|
+
/**
|
|
6
|
+
* Catch a paint that happened before the page was styled.
|
|
7
|
+
*
|
|
8
|
+
* The symptom is a flash of unstyled content, and it is the one Speed Kit
|
|
9
|
+
* failure that is invisible by the time anyone can look: by the end of the load
|
|
10
|
+
* the page is styled, so every after-the-fact inspection says it is fine. The
|
|
11
|
+
* only way to see it is to sample across the load itself.
|
|
12
|
+
*
|
|
13
|
+
* The test is a comparison rather than a screenshot: did a contentful paint
|
|
14
|
+
* happen while the document had fewer stylesheets applied than it ended up
|
|
15
|
+
* with. That is a heuristic and it is worth knowing which way it errs — a page
|
|
16
|
+
* that loads a late, purely decorative sheet reads as a flash it never had, and
|
|
17
|
+
* a page whose first sheet arrives with the document but applies to nothing
|
|
18
|
+
* reads as clean. The samples are returned so the verdict can be checked rather
|
|
19
|
+
* than taken.
|
|
20
|
+
*/
|
|
21
|
+
export async function runFouc(preloads, reload, options) {
|
|
22
|
+
const durationMs = Math.min(MAX_DURATION_MS, Math.max(1_000, options.durationMs ?? DEFAULT_DURATION_MS));
|
|
23
|
+
const selector = options.selector ?? null;
|
|
24
|
+
await preloads.reserve("fouc", foucScript(selector));
|
|
25
|
+
try {
|
|
26
|
+
// Always: a sampler installed mid-life has already missed the only moment
|
|
27
|
+
// that matters.
|
|
28
|
+
await reload();
|
|
29
|
+
await delay(durationMs);
|
|
30
|
+
const read = await preloads.read("fouc", Number.MAX_SAFE_INTEGER);
|
|
31
|
+
const samples = (read.records ?? [])
|
|
32
|
+
.map(({ t, v }) => ({ t, ...v }))
|
|
33
|
+
.filter((sample) => typeof sample.sheets === "number");
|
|
34
|
+
return analyse(samples, selector, durationMs);
|
|
35
|
+
}
|
|
36
|
+
finally {
|
|
37
|
+
await preloads.release("fouc").catch(() => undefined);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
function analyse(samples, selector, durationMs) {
|
|
41
|
+
const sheetsFinal = samples.length > 0 ? samples[samples.length - 1].sheets : null;
|
|
42
|
+
const firstPainted = samples.find((sample) => sample.painted) ?? null;
|
|
43
|
+
const fcp = firstPainted?.fcp ?? null;
|
|
44
|
+
// The document as the paint found it: the last sample taken before it, on
|
|
45
|
+
// the same clock. The first sample *after* it can already have the sheet the
|
|
46
|
+
// paint went without.
|
|
47
|
+
const atPaint = fcp === null
|
|
48
|
+
? firstPainted
|
|
49
|
+
: ([...samples].reverse().find((sample) => sample.t <= fcp) ??
|
|
50
|
+
firstPainted);
|
|
51
|
+
const settled = sheetsFinal === null
|
|
52
|
+
? null
|
|
53
|
+
: (samples.find((sample) => sample.sheets === sheetsFinal) ?? null);
|
|
54
|
+
const sheetsAtPaint = atPaint?.sheets ?? null;
|
|
55
|
+
const pendingAtPaint = atPaint?.pending ?? [];
|
|
56
|
+
const unstyledPaint = (atPaint?.pendingCount ?? 0) > 0;
|
|
57
|
+
const lateSheets = sheetsAtPaint === null || sheetsFinal === null
|
|
58
|
+
? null
|
|
59
|
+
: Math.max(0, sheetsFinal - sheetsAtPaint);
|
|
60
|
+
const backgrounds = [];
|
|
61
|
+
let previous;
|
|
62
|
+
for (const sample of samples) {
|
|
63
|
+
if (sample.background !== previous) {
|
|
64
|
+
backgrounds.push({ t: sample.t, value: sample.background });
|
|
65
|
+
previous = sample.background;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
const paintedAt = fcp === null ? (firstPainted?.t ?? null) : Math.round(fcp);
|
|
69
|
+
return {
|
|
70
|
+
selector,
|
|
71
|
+
durationMs,
|
|
72
|
+
unstyledPaint,
|
|
73
|
+
paintedAt,
|
|
74
|
+
settledAt: settled?.t ?? null,
|
|
75
|
+
sheetsAtPaint,
|
|
76
|
+
sheetsFinal,
|
|
77
|
+
pendingAtPaint,
|
|
78
|
+
lateSheets,
|
|
79
|
+
backgrounds,
|
|
80
|
+
samples,
|
|
81
|
+
verdict: verdictFor(samples, {
|
|
82
|
+
paintedAt,
|
|
83
|
+
pendingCount: atPaint?.pendingCount ?? 0,
|
|
84
|
+
pendingAtPaint,
|
|
85
|
+
lateSheets,
|
|
86
|
+
}),
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Unstyled means a stylesheet that was already in the document had not loaded
|
|
91
|
+
* when the page painted. It used to mean "fewer sheets than at the end", and a
|
|
92
|
+
* widget inserting its own sheets after the paint made every load read as a
|
|
93
|
+
* flash, with numbers that changed from run to run.
|
|
94
|
+
*/
|
|
95
|
+
function verdictFor(samples, { paintedAt, pendingCount, pendingAtPaint, lateSheets }) {
|
|
96
|
+
if (samples.length === 0) {
|
|
97
|
+
return "nothing was sampled — the page did not load within the window, or the preload never ran.";
|
|
98
|
+
}
|
|
99
|
+
if (paintedAt === null) {
|
|
100
|
+
return "no contentful paint in the window. Nothing rendered, so there was nothing to flash — look at why the page did not paint.";
|
|
101
|
+
}
|
|
102
|
+
const late = lateSheets && lateSheets > 0
|
|
103
|
+
? ` ${lateSheets} more stylesheet${lateSheets === 1 ? " was" : "s were"} added after the paint, by script; a paint cannot wait for those, so they are not counted — if one of them styles what is on screen, look at the backgrounds.`
|
|
104
|
+
: "";
|
|
105
|
+
if (pendingCount > 0) {
|
|
106
|
+
return `painted at ${paintedAt}ms while ${pendingCount} stylesheet${pendingCount === 1 ? "" : "s"} already in the document had not loaded (${pendingAtPaint.join(", ")}${pendingCount > pendingAtPaint.length ? ", …" : ""}) — content was on screen before the page was styled.${late}`;
|
|
107
|
+
}
|
|
108
|
+
return `painted at ${paintedAt}ms with every stylesheet in the document loaded — no unstyled paint in this load.${late}`;
|
|
109
|
+
}
|
|
110
|
+
function delay(ms) {
|
|
111
|
+
return new Promise((resolve) => {
|
|
112
|
+
const timer = setTimeout(resolve, ms);
|
|
113
|
+
timer.unref();
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* The sampler, reading the three things a flash shows up in.
|
|
118
|
+
*
|
|
119
|
+
* The sheet count is the signal; the paint entry is the clock; the background
|
|
120
|
+
* is the corroboration a human can recognise, because a flash is nearly always
|
|
121
|
+
* a background going from white to the brand colour or the other way about.
|
|
122
|
+
*/
|
|
123
|
+
function foucScript(selector) {
|
|
124
|
+
return `
|
|
125
|
+
var target = ${JSON.stringify(selector)};
|
|
126
|
+
|
|
127
|
+
var take = guard(function () {
|
|
128
|
+
var element = target ? document.querySelector(target) : document.body;
|
|
129
|
+
var painted = false;
|
|
130
|
+
try {
|
|
131
|
+
painted = (performance.getEntriesByType("paint") || []).some(function (entry) {
|
|
132
|
+
return entry.name === "first-contentful-paint";
|
|
133
|
+
});
|
|
134
|
+
} catch (ignored) {
|
|
135
|
+
// Not every engine exposes paint timing; the sheet count still works.
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
record({
|
|
139
|
+
sheets: (document.styleSheets || []).length,
|
|
140
|
+
painted: painted,
|
|
141
|
+
present: Boolean(element),
|
|
142
|
+
background: element ? getComputedStyle(element).backgroundColor : null
|
|
143
|
+
});
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
take();
|
|
147
|
+
var timer = setInterval(function () {
|
|
148
|
+
if (slot.disabled) { clearInterval(timer); return; }
|
|
149
|
+
take();
|
|
150
|
+
}, ${SAMPLE_MS});`;
|
|
151
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { NavwalkData, NavwalkFlow } from "./control-protocol.js";
|
|
2
|
+
export declare class NoTriggerError extends Error {
|
|
3
|
+
readonly code = "NO_TRIGGER";
|
|
4
|
+
}
|
|
5
|
+
/** One Document request, before it is deduped and classified. */
|
|
6
|
+
export interface RawDocumentHit {
|
|
7
|
+
url: string;
|
|
8
|
+
status: number | null;
|
|
9
|
+
/** False for a request seen in a popup the flow opened. */
|
|
10
|
+
main: boolean;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* What walking a flow needs from the browser.
|
|
14
|
+
*
|
|
15
|
+
* `collectDocumentRequests` is the whole reason this is not a page-level
|
|
16
|
+
* capability: the hops that matter happen in targets the main page does not
|
|
17
|
+
* own, and a capture scoped to one target misses precisely the ones worth
|
|
18
|
+
* having.
|
|
19
|
+
*/
|
|
20
|
+
export interface NavwalkBrowser {
|
|
21
|
+
url(): string | null;
|
|
22
|
+
evaluate<T>(expression: string): Promise<T>;
|
|
23
|
+
/** The return is ignored; `BrowserController` answers with more. */
|
|
24
|
+
navigate(url: string): Promise<unknown>;
|
|
25
|
+
/** Watch every target now open and every one that appears. Returns a stop. */
|
|
26
|
+
collectDocumentRequests(onHit: (hit: RawDocumentHit) => void): Promise<() => Promise<void>>;
|
|
27
|
+
}
|
|
28
|
+
export interface NavwalkOptions {
|
|
29
|
+
flow?: NavwalkFlow;
|
|
30
|
+
click?: string;
|
|
31
|
+
url?: string;
|
|
32
|
+
waitMs?: number;
|
|
33
|
+
/**
|
|
34
|
+
* Pages this run knows to be accelerated — what the documentHandler has
|
|
35
|
+
* cached. A prefix that would also disable one of them is too broad, and is
|
|
36
|
+
* dropped from the candidates with the page it would have caught.
|
|
37
|
+
*/
|
|
38
|
+
knownPages?: string[];
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Walk a login or checkout flow and report every same-origin document hop.
|
|
42
|
+
*
|
|
43
|
+
* `tools/sk-auth-walk.mjs` promoted. It exists because the obvious tools answer
|
|
44
|
+
* the wrong question: a network list scoped to the main target since the last
|
|
45
|
+
* navigation misses the interim 302s once the flow bounces off-domain, and
|
|
46
|
+
* misses document requests in the popup a "sign in with…" control opens. Those
|
|
47
|
+
* are exactly the hops that have to be named in `disabledScopes`, and they are
|
|
48
|
+
* invisible in a single-target snapshot.
|
|
49
|
+
*
|
|
50
|
+
* The output is candidates, not an answer. Which prefix to write is a judgement
|
|
51
|
+
* about what else it would catch, and that lives in the config rather than in
|
|
52
|
+
* this capture.
|
|
53
|
+
*/
|
|
54
|
+
export declare function runNavwalk(browser: NavwalkBrowser, options: NavwalkOptions): Promise<NavwalkData>;
|
|
55
|
+
/**
|
|
56
|
+
* Drop every candidate that would also disable a page known to be accelerated.
|
|
57
|
+
*
|
|
58
|
+
* `/it-it` is a prefix of the login hop on a site whose every page sits under
|
|
59
|
+
* `/it-it`, and offering it as a scope offers to switch Speed Kit off for the
|
|
60
|
+
* whole market. The evidence is concrete pages — the one the walk started on,
|
|
61
|
+
* and what the documentHandler cached — rather than a reading of the
|
|
62
|
+
* `enabledSites` patterns, which can be regexes. A page the flow itself hit is
|
|
63
|
+
* not evidence against its own scope.
|
|
64
|
+
*/
|
|
65
|
+
export declare function pruneScopes(data: NavwalkData, knownPages: string[]): NavwalkData;
|
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
/** Long enough for a redirect chain and an auth bounce to finish. */
|
|
2
|
+
const DEFAULT_WAIT_MS = 9_000;
|
|
3
|
+
/**
|
|
4
|
+
* The header account control, in the languages the customers are in.
|
|
5
|
+
*
|
|
6
|
+
* Matched against text, `aria-label` and `href`, because a shop that shows an
|
|
7
|
+
* icon has the word only in one of the three.
|
|
8
|
+
*/
|
|
9
|
+
const LOGIN_MATCH = "log\\s?in|sign\\s?in|anmelden|mein konto|my account|/account|/login|/customer";
|
|
10
|
+
/** The cart's checkout CTA, reached after landing on `/cart`. */
|
|
11
|
+
const CHECKOUT_MATCH = "check\\s?out|zur kasse|kasse|proceed|/checkout|bezahlen";
|
|
12
|
+
export class NoTriggerError extends Error {
|
|
13
|
+
code = "NO_TRIGGER";
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Walk a login or checkout flow and report every same-origin document hop.
|
|
17
|
+
*
|
|
18
|
+
* `tools/sk-auth-walk.mjs` promoted. It exists because the obvious tools answer
|
|
19
|
+
* the wrong question: a network list scoped to the main target since the last
|
|
20
|
+
* navigation misses the interim 302s once the flow bounces off-domain, and
|
|
21
|
+
* misses document requests in the popup a "sign in with…" control opens. Those
|
|
22
|
+
* are exactly the hops that have to be named in `disabledScopes`, and they are
|
|
23
|
+
* invisible in a single-target snapshot.
|
|
24
|
+
*
|
|
25
|
+
* The output is candidates, not an answer. Which prefix to write is a judgement
|
|
26
|
+
* about what else it would catch, and that lives in the config rather than in
|
|
27
|
+
* this capture.
|
|
28
|
+
*/
|
|
29
|
+
export async function runNavwalk(browser, options) {
|
|
30
|
+
const waitMs = Math.min(60_000, Math.max(500, options.waitMs ?? DEFAULT_WAIT_MS));
|
|
31
|
+
const flow = options.flow ?? (options.click ? null : "login");
|
|
32
|
+
// Where to put the tab back, and the first page a candidate must not cover:
|
|
33
|
+
// the walk starts on an ordinary accelerated page, almost by definition.
|
|
34
|
+
const startedOn = browser.url();
|
|
35
|
+
if (options.url) {
|
|
36
|
+
await browser.navigate(options.url);
|
|
37
|
+
await settle();
|
|
38
|
+
}
|
|
39
|
+
// The checkout CTA is on the cart, so a walk that starts anywhere else clicks
|
|
40
|
+
// whatever happens to match and reports a flow it never entered.
|
|
41
|
+
if (flow === "checkout") {
|
|
42
|
+
const origin = await browser.evaluate("location.origin");
|
|
43
|
+
await browser.navigate(`${origin}/cart`);
|
|
44
|
+
await settle();
|
|
45
|
+
}
|
|
46
|
+
const hits = [];
|
|
47
|
+
const stop = await browser.collectDocumentRequests((hit) => hits.push(hit));
|
|
48
|
+
try {
|
|
49
|
+
const host = await browser.evaluate("location.host");
|
|
50
|
+
// Everything captured so far belongs to the page that is already loaded —
|
|
51
|
+
// ambient iframes, pixel sandboxes, a Shopify web-pixel worker. Only hops
|
|
52
|
+
// the trigger produces are scope candidates.
|
|
53
|
+
hits.length = 0;
|
|
54
|
+
const clicked = await browser.evaluate(clickExpression(triggerFor(flow, options.click), selectorFor(options.click)));
|
|
55
|
+
if (clicked === "NONE") {
|
|
56
|
+
throw new NoTriggerError(`nothing on the page matched the trigger — pass \`click\` with the control's text or a CSS selector for the ${flow ?? "flow"} entry point`);
|
|
57
|
+
}
|
|
58
|
+
await delay(waitMs);
|
|
59
|
+
const walked = shape(hits, { host, clicked, flow, waitedMs: waitMs });
|
|
60
|
+
const pruned = pruneScopes(walked, [
|
|
61
|
+
...[startedOn, options.url].filter(Boolean),
|
|
62
|
+
...(options.knownPages ?? []),
|
|
63
|
+
]);
|
|
64
|
+
return { ...pruned, startedOn, ...(await goBack(browser, startedOn)) };
|
|
65
|
+
}
|
|
66
|
+
finally {
|
|
67
|
+
await stop();
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Put the tab back where the walk found it.
|
|
72
|
+
*
|
|
73
|
+
* A login flow ends on an identity provider as often as not, and a run left
|
|
74
|
+
* there makes every later op answer about the wrong site. When going back
|
|
75
|
+
* fails, the answer says where the tab was left instead.
|
|
76
|
+
*/
|
|
77
|
+
async function goBack(browser, startedOn) {
|
|
78
|
+
const endedOn = browser.url();
|
|
79
|
+
if (!startedOn || endedOn === startedOn) {
|
|
80
|
+
return { endedOn, returned: false };
|
|
81
|
+
}
|
|
82
|
+
try {
|
|
83
|
+
await browser.navigate(startedOn);
|
|
84
|
+
return { endedOn, returned: true };
|
|
85
|
+
}
|
|
86
|
+
catch {
|
|
87
|
+
return { endedOn, returned: false };
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Drop every candidate that would also disable a page known to be accelerated.
|
|
92
|
+
*
|
|
93
|
+
* `/it-it` is a prefix of the login hop on a site whose every page sits under
|
|
94
|
+
* `/it-it`, and offering it as a scope offers to switch Speed Kit off for the
|
|
95
|
+
* whole market. The evidence is concrete pages — the one the walk started on,
|
|
96
|
+
* and what the documentHandler cached — rather than a reading of the
|
|
97
|
+
* `enabledSites` patterns, which can be regexes. A page the flow itself hit is
|
|
98
|
+
* not evidence against its own scope.
|
|
99
|
+
*/
|
|
100
|
+
export function pruneScopes(data, knownPages) {
|
|
101
|
+
const flowPaths = new Set(data.sameOrigin.map((hit) => hit.path));
|
|
102
|
+
const guarded = knownPages
|
|
103
|
+
.map((page) => {
|
|
104
|
+
try {
|
|
105
|
+
return new URL(page);
|
|
106
|
+
}
|
|
107
|
+
catch {
|
|
108
|
+
return null;
|
|
109
|
+
}
|
|
110
|
+
})
|
|
111
|
+
.filter((url) => url !== null && url.host === data.host)
|
|
112
|
+
.filter((url) => !flowPaths.has(url.pathname));
|
|
113
|
+
const droppedScopes = [];
|
|
114
|
+
const keep = (scope) => {
|
|
115
|
+
const covered = guarded.find((url) => url.pathname === scope || url.pathname.startsWith(`${scope}/`));
|
|
116
|
+
if (covered) {
|
|
117
|
+
droppedScopes.push({ scope, covers: covered.href });
|
|
118
|
+
return false;
|
|
119
|
+
}
|
|
120
|
+
return true;
|
|
121
|
+
};
|
|
122
|
+
return {
|
|
123
|
+
...data,
|
|
124
|
+
candidateScopes: {
|
|
125
|
+
depth1: data.candidateScopes.depth1.filter(keep),
|
|
126
|
+
depth2: data.candidateScopes.depth2.filter(keep),
|
|
127
|
+
},
|
|
128
|
+
droppedScopes,
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
function triggerFor(flow, click) {
|
|
132
|
+
if (click && !/[.#[]/.test(click)) {
|
|
133
|
+
return click;
|
|
134
|
+
}
|
|
135
|
+
if (flow === "checkout") {
|
|
136
|
+
return CHECKOUT_MATCH;
|
|
137
|
+
}
|
|
138
|
+
return flow === "login" ? LOGIN_MATCH : null;
|
|
139
|
+
}
|
|
140
|
+
/** A CSS selector is anything with a selector character in it. */
|
|
141
|
+
function selectorFor(click) {
|
|
142
|
+
return click && /[.#[]/.test(click) ? click : null;
|
|
143
|
+
}
|
|
144
|
+
function shape(hits, { host, clicked, flow, waitedMs }) {
|
|
145
|
+
// One entry per url, preferring the one that carries a status: the request
|
|
146
|
+
// and its response arrive as two events and only the second knows the code.
|
|
147
|
+
const byUrl = new Map();
|
|
148
|
+
for (const hit of hits) {
|
|
149
|
+
const previous = byUrl.get(hit.url);
|
|
150
|
+
if (!previous || (previous.status === null && hit.status !== null)) {
|
|
151
|
+
byUrl.set(hit.url, hit);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
const all = [];
|
|
155
|
+
for (const hit of byUrl.values()) {
|
|
156
|
+
let parsed;
|
|
157
|
+
try {
|
|
158
|
+
parsed = new URL(hit.url);
|
|
159
|
+
}
|
|
160
|
+
catch {
|
|
161
|
+
continue;
|
|
162
|
+
}
|
|
163
|
+
all.push({
|
|
164
|
+
url: hit.url,
|
|
165
|
+
path: parsed.pathname,
|
|
166
|
+
status: hit.status,
|
|
167
|
+
target: hit.main ? "main" : "popup",
|
|
168
|
+
sameOrigin: parsed.host === host,
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
const sameOrigin = all.filter((hit) => hit.sameOrigin);
|
|
172
|
+
const offOrigin = all.filter((hit) => !hit.sameOrigin);
|
|
173
|
+
const depth1 = new Set();
|
|
174
|
+
const depth2 = new Set();
|
|
175
|
+
for (const hit of sameOrigin) {
|
|
176
|
+
const segments = hit.path.split("/").filter(Boolean);
|
|
177
|
+
if (segments.length >= 1) {
|
|
178
|
+
depth1.add(`/${segments[0]}`);
|
|
179
|
+
}
|
|
180
|
+
if (segments.length >= 2) {
|
|
181
|
+
depth2.add(`/${segments.slice(0, 2).join("/")}`);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
return {
|
|
185
|
+
host,
|
|
186
|
+
clicked,
|
|
187
|
+
flow,
|
|
188
|
+
waitedMs,
|
|
189
|
+
sameOrigin,
|
|
190
|
+
offOrigin,
|
|
191
|
+
candidateScopes: {
|
|
192
|
+
depth1: [...depth1].sort(),
|
|
193
|
+
depth2: [...depth2].sort(),
|
|
194
|
+
},
|
|
195
|
+
droppedScopes: [],
|
|
196
|
+
startedOn: null,
|
|
197
|
+
endedOn: null,
|
|
198
|
+
returned: false,
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Find the control and click it, returning what it clicked.
|
|
203
|
+
*
|
|
204
|
+
* Evaluated in the page rather than driven through a selector API, so it works
|
|
205
|
+
* whatever the site is built with — and it clicks the real control instead of
|
|
206
|
+
* navigating to a guessed url, which is the point: the hops are produced by
|
|
207
|
+
* what the control actually does.
|
|
208
|
+
*/
|
|
209
|
+
function clickExpression(matchText, selector) {
|
|
210
|
+
return `(function (matchText, selector) {
|
|
211
|
+
function visible(element) {
|
|
212
|
+
var box = element.getBoundingClientRect();
|
|
213
|
+
return box.width > 0 && box.height > 0;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
var found = null;
|
|
217
|
+
if (selector) found = document.querySelector(selector);
|
|
218
|
+
if (!found && matchText) {
|
|
219
|
+
var pattern = new RegExp(matchText, "i");
|
|
220
|
+
found = Array.prototype.slice
|
|
221
|
+
.call(document.querySelectorAll("a,button,[role=button]"))
|
|
222
|
+
.filter(visible)
|
|
223
|
+
.find(function (element) {
|
|
224
|
+
return (
|
|
225
|
+
pattern.test((element.textContent || "").trim()) ||
|
|
226
|
+
pattern.test(element.getAttribute("aria-label") || "") ||
|
|
227
|
+
pattern.test(element.getAttribute("href") || "")
|
|
228
|
+
);
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
if (!found) return "NONE";
|
|
232
|
+
|
|
233
|
+
var label = (found.textContent || found.getAttribute("aria-label") || "").trim();
|
|
234
|
+
found.click();
|
|
235
|
+
return found.tagName.toLowerCase() + ' "' + label.slice(0, 40) + '" href=' +
|
|
236
|
+
(found.getAttribute("href") || "-");
|
|
237
|
+
})(${JSON.stringify(matchText)}, ${JSON.stringify(selector)})`;
|
|
238
|
+
}
|
|
239
|
+
/** Long enough for a navigation this function asked for to have started. */
|
|
240
|
+
function settle() {
|
|
241
|
+
return delay(2_500);
|
|
242
|
+
}
|
|
243
|
+
function delay(ms) {
|
|
244
|
+
return new Promise((resolve) => {
|
|
245
|
+
const timer = setTimeout(resolve, ms);
|
|
246
|
+
timer.unref();
|
|
247
|
+
});
|
|
248
|
+
}
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import { InjectAddData, InjectListData, InjectReadData, InjectRecipeParam, InjectRecipesData, InjectRemoveData } from "./control-protocol.js";
|
|
2
|
+
/** How many may be registered at once. */
|
|
3
|
+
export declare const PRELOAD_LIMIT = 8;
|
|
4
|
+
/** Minutes a preload lives for when the caller names no TTL. */
|
|
5
|
+
export declare const DEFAULT_TTL_MINUTES = 30;
|
|
6
|
+
/**
|
|
7
|
+
* What the registry needs from the browser, and nothing else.
|
|
8
|
+
*
|
|
9
|
+
* The same argument {@link PageEvaluator} makes: handed a `Page` or a
|
|
10
|
+
* `CDPSession`, this would grow reasons to reach for the rest of CDP. Three
|
|
11
|
+
* methods are the whole of what managing preloads takes, and they are trivially
|
|
12
|
+
* faked, so the recipes can be tested for what they *emit* without a browser.
|
|
13
|
+
*/
|
|
14
|
+
export interface PreloadTransport {
|
|
15
|
+
/** Whether there is a document to register against at all. */
|
|
16
|
+
readonly pageAvailable: boolean;
|
|
17
|
+
/** `Page.addScriptToEvaluateOnNewDocument`; returns its identifier. */
|
|
18
|
+
addScript(source: string): Promise<string>;
|
|
19
|
+
removeScript(identifier: string): Promise<void>;
|
|
20
|
+
/** `Runtime.evaluate`, never `page.evaluate` — the page may be paused. */
|
|
21
|
+
evaluate<T>(expression: string): Promise<T>;
|
|
22
|
+
}
|
|
23
|
+
export declare class NoSuchPreloadError extends Error {
|
|
24
|
+
readonly code = "NO_SUCH_PRELOAD";
|
|
25
|
+
}
|
|
26
|
+
export declare class UnknownRecipeError extends Error {
|
|
27
|
+
readonly recipes: string[];
|
|
28
|
+
readonly code = "UNKNOWN_RECIPE";
|
|
29
|
+
constructor(message: string, recipes: string[]);
|
|
30
|
+
}
|
|
31
|
+
export declare class BadRecipeParamsError extends Error {
|
|
32
|
+
readonly params: InjectRecipeParam[];
|
|
33
|
+
readonly code = "BAD_RECIPE_PARAMS";
|
|
34
|
+
constructor(message: string, params: InjectRecipeParam[]);
|
|
35
|
+
}
|
|
36
|
+
export declare class InjectSourceRequiredError extends Error {
|
|
37
|
+
readonly code = "INJECT_SOURCE_REQUIRED";
|
|
38
|
+
}
|
|
39
|
+
export declare class TooManyPreloadsError extends Error {
|
|
40
|
+
readonly registered: string[];
|
|
41
|
+
readonly code = "TOO_MANY_PRELOADS";
|
|
42
|
+
constructor(message: string, registered: string[]);
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* The key a reserved preload is filed under.
|
|
46
|
+
*
|
|
47
|
+
* A reserved entry belongs to another tool rather than to a caller of
|
|
48
|
+
* `sk onboarding inject`, so it is addressed by a stable name instead of an allocated id.
|
|
49
|
+
*/
|
|
50
|
+
export type ReservedPreload = "debug" | "watch" | "fouc";
|
|
51
|
+
/**
|
|
52
|
+
* The preloads a run has registered, and the only thing allowed to add one.
|
|
53
|
+
*
|
|
54
|
+
* Three consumers wanted `Page.addScriptToEvaluateOnNewDocument` — the sampler,
|
|
55
|
+
* the breakpoint bridge's flag delivery, and injected hooks — and three ad-hoc
|
|
56
|
+
* call sites would have meant three ways to leave a script behind. A preload
|
|
57
|
+
* outlives the turn that added it, survives every navigation, and is invisible
|
|
58
|
+
* to the human watching the run's output. So it is registered in one place that
|
|
59
|
+
* can list them, expire them, and switch off the copy already running.
|
|
60
|
+
*/
|
|
61
|
+
export declare class PreloadRegistry {
|
|
62
|
+
private readonly transport;
|
|
63
|
+
/**
|
|
64
|
+
* Told whenever what is installed changes.
|
|
65
|
+
*
|
|
66
|
+
* The hook the tab marker hangs off: "an agent has left something in this
|
|
67
|
+
* page" is exactly the set of moments this fires on, and it is the
|
|
68
|
+
* condition worth showing rather than the fact that a tool ran.
|
|
69
|
+
*/
|
|
70
|
+
private readonly onChange?;
|
|
71
|
+
private readonly registered;
|
|
72
|
+
/** Set while a retire is in flight, so one notification covers the batch. */
|
|
73
|
+
private changed;
|
|
74
|
+
private counter;
|
|
75
|
+
/** Expired since the last time anyone was told, so an absence is explained. */
|
|
76
|
+
private expired;
|
|
77
|
+
constructor(transport: PreloadTransport,
|
|
78
|
+
/**
|
|
79
|
+
* Told whenever what is installed changes.
|
|
80
|
+
*
|
|
81
|
+
* The hook the tab marker hangs off: "an agent has left something in this
|
|
82
|
+
* page" is exactly the set of moments this fires on, and it is the
|
|
83
|
+
* condition worth showing rather than the fact that a tool ran.
|
|
84
|
+
*/
|
|
85
|
+
onChange?: () => void);
|
|
86
|
+
/**
|
|
87
|
+
* What is installed, without asking the page.
|
|
88
|
+
*
|
|
89
|
+
* `list` needs an evaluation to say whether a script is running; this only
|
|
90
|
+
* answers what is registered, which is all a status label needs and cheap
|
|
91
|
+
* enough to compute on every change.
|
|
92
|
+
*/
|
|
93
|
+
summary(): {
|
|
94
|
+
count: number;
|
|
95
|
+
origins: string[];
|
|
96
|
+
};
|
|
97
|
+
get size(): number;
|
|
98
|
+
recipes(): InjectRecipesData;
|
|
99
|
+
add(request: {
|
|
100
|
+
recipe?: string;
|
|
101
|
+
params?: Record<string, unknown>;
|
|
102
|
+
source?: string;
|
|
103
|
+
ttlMinutes?: number;
|
|
104
|
+
}): Promise<InjectAddData>;
|
|
105
|
+
list(): Promise<InjectListData>;
|
|
106
|
+
read(preload: string, limit?: number): Promise<InjectReadData>;
|
|
107
|
+
remove(preload: string): Promise<InjectRemoveData>;
|
|
108
|
+
clear(): Promise<InjectRemoveData>;
|
|
109
|
+
/**
|
|
110
|
+
* Install a script another tool owns, under a name instead of an id.
|
|
111
|
+
*
|
|
112
|
+
* Registered here rather than straight onto the transport so that one place
|
|
113
|
+
* still knows about every script running in the page: an agent that reads
|
|
114
|
+
* `sk onboarding inject list`, sees nothing, and concludes the page is unmodified while
|
|
115
|
+
* `sk onboarding debug` has hooks in it has been misled by the tool built to prevent
|
|
116
|
+
* exactly that. Replacing an existing reservation is the normal case — arming
|
|
117
|
+
* a different set of breakpoints is a new script under the same name.
|
|
118
|
+
*/
|
|
119
|
+
reserve(name: ReservedPreload, body: string): Promise<void>;
|
|
120
|
+
release(name: ReservedPreload): Promise<boolean>;
|
|
121
|
+
/**
|
|
122
|
+
* Register everything again against a session that has just been made.
|
|
123
|
+
*
|
|
124
|
+
* A CDP session does not survive being detached, and the identifiers it
|
|
125
|
+
* handed out do not either. Without this a preload would keep appearing in
|
|
126
|
+
* `list` while no longer running in the browser, which is the one failure
|
|
127
|
+
* this tool cannot afford: every conclusion drawn from an empty buffer would
|
|
128
|
+
* be wrong in the same direction.
|
|
129
|
+
*/
|
|
130
|
+
reapply(): Promise<void>;
|
|
131
|
+
/** Whatever is left at the end of the run, dropped without ceremony. */
|
|
132
|
+
dispose(): void;
|
|
133
|
+
private require;
|
|
134
|
+
private expire;
|
|
135
|
+
/**
|
|
136
|
+
* Unregister and switch off, in that order.
|
|
137
|
+
*
|
|
138
|
+
* Unregistering stops the *next* document. The copy already running in this
|
|
139
|
+
* one has already installed its hooks and cannot be taken back out, so it is
|
|
140
|
+
* switched off through the flag every recipe checks before it records. A
|
|
141
|
+
* removal that did only the first half would leave a spy recording into a
|
|
142
|
+
* buffer nothing lists.
|
|
143
|
+
*/
|
|
144
|
+
private retire;
|
|
145
|
+
/** Every entry's page-side state in one evaluation, or null when there is no page. */
|
|
146
|
+
private pageState;
|
|
147
|
+
private describe;
|
|
148
|
+
private evaluateQuietly;
|
|
149
|
+
private drainExpired;
|
|
150
|
+
}
|