chrome-devtools-mcp 1.5.0 → 1.7.0
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 +41 -9
- package/build/src/HeapSnapshotManager.js +77 -28
- package/build/src/McpContext.js +233 -383
- package/build/src/McpPage.js +466 -41
- package/build/src/McpResponse.js +285 -331
- package/build/src/PageCollector.js +53 -122
- package/build/src/SlimMcpResponse.js +1 -1
- package/build/src/TextSnapshot.js +100 -21
- package/build/src/ToolHandler.js +31 -10
- package/build/src/WaitForHelper.js +140 -56
- package/build/src/bin/chrome-devtools-cli-options.js +63 -3
- package/build/src/bin/chrome-devtools-mcp-cli-options.js +16 -7
- package/build/src/bin/chrome-devtools-mcp-main.js +3 -3
- package/build/src/bin/chrome-devtools.js +19 -3
- package/build/src/browser.js +1 -1
- package/build/src/daemon/client.js +55 -3
- package/build/src/daemon/daemon.js +17 -12
- package/build/src/daemon/utils.js +19 -4
- package/build/src/devtools/DevtoolsUtils.js +9 -65
- package/build/src/{issue-descriptions.js → devtools/issueDescriptions.js} +2 -2
- package/build/src/formatters/HeapSnapshotFormatter.js +48 -11
- package/build/src/formatters/IssueFormatter.js +2 -2
- package/build/src/index.js +13 -3
- package/build/src/telemetry/ClearcutLogger.js +4 -1
- package/build/src/telemetry/WatchdogClient.js +1 -1
- package/build/src/telemetry/metricsRegistry.js +2 -9
- package/build/src/telemetry/persistence.js +1 -1
- package/build/src/telemetry/transformation.js +50 -0
- package/build/src/telemetry/watchdog/ClearcutSender.js +1 -1
- package/build/src/telemetry/watchdog/main.js +1 -1
- package/build/src/third_party/THIRD_PARTY_NOTICES +230 -287
- package/build/src/third_party/bundled-packages.json +4 -6
- package/build/src/third_party/devtools-formatter-worker.js +60 -19
- package/build/src/third_party/devtools-heap-snapshot-worker.js +383 -182
- package/build/src/third_party/index.js +30171 -11328
- package/build/src/third_party/issue-descriptions/CoepCorpNotSameOrigin.md +2 -2
- package/build/src/third_party/issue-descriptions/CoepCorpNotSameOriginAfterDefaultedToSameOriginByCoep.md +3 -3
- package/build/src/third_party/issue-descriptions/CoepCorpNotSameSite.md +2 -2
- package/build/src/third_party/issue-descriptions/CoepFrameResourceNeedsCoepHeader.md +1 -1
- package/build/src/third_party/issue-descriptions/CompatibilityModeQuirks.md +1 -1
- package/build/src/third_party/issue-descriptions/CookieAttributeValueExceedsMaxSize.md +2 -2
- package/build/src/third_party/issue-descriptions/LowTextContrast.md +1 -1
- package/build/src/third_party/issue-descriptions/SameSiteNoneInsecureErrorRead.md +1 -1
- package/build/src/third_party/issue-descriptions/SameSiteNoneInsecureErrorSet.md +1 -1
- package/build/src/third_party/issue-descriptions/SameSiteNoneInsecureWarnRead.md +1 -1
- package/build/src/third_party/issue-descriptions/SameSiteNoneInsecureWarnSet.md +1 -1
- package/build/src/third_party/issue-descriptions/SameSiteUnspecifiedLaxAllowUnsafeRead.md +3 -3
- package/build/src/third_party/issue-descriptions/SameSiteUnspecifiedLaxAllowUnsafeSet.md +3 -3
- package/build/src/third_party/issue-descriptions/bounceTrackingMitigations.md +1 -1
- package/build/src/third_party/issue-descriptions/connectionAllowlistInvalidAllowlistItemType.md +2 -2
- package/build/src/third_party/issue-descriptions/connectionAllowlistInvalidHeader.md +2 -2
- package/build/src/third_party/issue-descriptions/connectionAllowlistInvalidUrlPattern.md +3 -3
- package/build/src/third_party/issue-descriptions/connectionAllowlistItemNotInnerList.md +2 -2
- package/build/src/third_party/issue-descriptions/connectionAllowlistMoreThanOneList.md +2 -2
- package/build/src/third_party/issue-descriptions/connectionAllowlistReportingEndpointNotToken.md +1 -1
- package/build/src/third_party/issue-descriptions/cookieCrossSiteRedirectDowngrade.md +3 -3
- package/build/src/third_party/issue-descriptions/cookieExcludeBlockedWithinRelatedWebsiteSet.md +1 -1
- package/build/src/third_party/issue-descriptions/cookieExcludePortMismatch.md +1 -1
- package/build/src/third_party/issue-descriptions/cookieExcludeSchemeMismatch.md +1 -1
- package/build/src/third_party/issue-descriptions/cookieExcludeThirdPartyPhaseoutSet.md +1 -1
- package/build/src/third_party/issue-descriptions/cookieWarnThirdPartyPhaseoutRead.md +1 -1
- package/build/src/third_party/issue-descriptions/corsAllowCredentialsRequired.md +1 -1
- package/build/src/third_party/issue-descriptions/corsDisabledScheme.md +2 -2
- package/build/src/third_party/issue-descriptions/corsDisallowedByMode.md +2 -2
- package/build/src/third_party/issue-descriptions/corsHeaderDisallowedByPreflightResponse.md +1 -1
- package/build/src/third_party/issue-descriptions/corsInvalidHeaderValues.md +3 -3
- package/build/src/third_party/issue-descriptions/corsLocalNetworkAccessPermissionDenied.md +1 -1
- package/build/src/third_party/issue-descriptions/corsMethodDisallowedByPreflightResponse.md +1 -1
- package/build/src/third_party/issue-descriptions/corsNoCorsRedirectModeNotFollow.md +1 -1
- package/build/src/third_party/issue-descriptions/corsOriginMismatch.md +3 -3
- package/build/src/third_party/issue-descriptions/corsPreflightResponseInvalid.md +2 -2
- package/build/src/third_party/issue-descriptions/corsRedirectContainsCredentials.md +3 -3
- package/build/src/third_party/issue-descriptions/corsWildcardOriginNotAllowed.md +4 -3
- package/build/src/third_party/issue-descriptions/cspEvalViolation.md +4 -4
- package/build/src/third_party/issue-descriptions/cspInlineViolation.md +2 -2
- package/build/src/third_party/issue-descriptions/cspTrustedTypesPolicyViolation.md +2 -2
- package/build/src/third_party/issue-descriptions/cspTrustedTypesSinkViolation.md +4 -4
- package/build/src/third_party/issue-descriptions/cspURLViolation.md +4 -4
- package/build/src/third_party/issue-descriptions/emailVerificationRequestAccountsEmptyList.md +1 -1
- package/build/src/third_party/issue-descriptions/emailVerificationRequestAccountsHttpNotFound.md +1 -1
- package/build/src/third_party/issue-descriptions/emailVerificationRequestAccountsInvalidContentType.md +1 -1
- package/build/src/third_party/issue-descriptions/emailVerificationRequestAccountsInvalidResponse.md +1 -1
- package/build/src/third_party/issue-descriptions/emailVerificationRequestAccountsNoResponse.md +1 -1
- package/build/src/third_party/issue-descriptions/emailVerificationRequestDnsFetchFailed.md +1 -1
- package/build/src/third_party/issue-descriptions/emailVerificationRequestDnsInvalidRecord.md +1 -1
- package/build/src/third_party/issue-descriptions/emailVerificationRequestEmailVerificationWellKnownHttpNotFound.md +1 -1
- package/build/src/third_party/issue-descriptions/emailVerificationRequestEmailVerificationWellKnownInvalidContentType.md +1 -1
- package/build/src/third_party/issue-descriptions/emailVerificationRequestEmailVerificationWellKnownInvalidResponse.md +1 -1
- package/build/src/third_party/issue-descriptions/emailVerificationRequestEmailVerificationWellKnownNoResponse.md +1 -1
- package/build/src/third_party/issue-descriptions/emailVerificationRequestInvalidEmail.md +1 -1
- package/build/src/third_party/issue-descriptions/emailVerificationRequestJwksHttpNotFound.md +1 -1
- package/build/src/third_party/issue-descriptions/emailVerificationRequestJwksInvalidResponse.md +1 -1
- package/build/src/third_party/issue-descriptions/emailVerificationRequestKeyBindingSigningFailed.md +1 -1
- package/build/src/third_party/issue-descriptions/emailVerificationRequestRpOriginIsOpaque.md +1 -1
- package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenHttpNotFound.md +1 -1
- package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenInvalidContentType.md +1 -1
- package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenInvalidResponse.md +1 -1
- package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenInvalidSdJwt.md +1 -1
- package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenMalformedSdJwt.md +1 -1
- package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenNoResponse.md +1 -1
- package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationKbInvalidAudience.md +1 -1
- package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationKbInvalidIssuedAt.md +1 -1
- package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationKbInvalidNonce.md +1 -1
- package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationKbInvalidSdHash.md +1 -1
- package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationKbInvalidTyp.md +1 -1
- package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationKbMissingAud.md +1 -1
- package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationKbMissingCnf.md +1 -1
- package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationKbMissingIat.md +1 -1
- package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationKbMissingNonce.md +1 -1
- package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationKbMissingSdHash.md +1 -1
- package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationKbSignatureFailed.md +1 -1
- package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationSdJwtInvalidEmail.md +1 -1
- package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationSdJwtInvalidEmailVerified.md +1 -1
- package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationSdJwtInvalidHolderKey.md +1 -1
- package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationSdJwtInvalidIssuedAt.md +1 -1
- package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationSdJwtInvalidIssuer.md +1 -1
- package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationSdJwtJwksMissingKeys.md +1 -1
- package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationSdJwtMissingCnf.md +1 -1
- package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationSdJwtMissingEmail.md +1 -1
- package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationSdJwtMissingIat.md +1 -1
- package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationSdJwtMissingIss.md +1 -1
- package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationSdJwtSignatureFailed.md +1 -1
- package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationSdJwtUnsupportedHeaderAlg.md +1 -1
- package/build/src/third_party/issue-descriptions/emailVerificationRequestUserLoggedOut.md +1 -1
- package/build/src/third_party/issue-descriptions/emailVerificationRequestWellKnownAccountsEndpointCrossOrigin.md +1 -1
- package/build/src/third_party/issue-descriptions/emailVerificationRequestWellKnownHttpNotFound.md +1 -1
- package/build/src/third_party/issue-descriptions/emailVerificationRequestWellKnownInvalidContentType.md +1 -1
- package/build/src/third_party/issue-descriptions/emailVerificationRequestWellKnownInvalidResponse.md +1 -1
- package/build/src/third_party/issue-descriptions/emailVerificationRequestWellKnownIssuanceEndpointCrossOrigin.md +1 -1
- package/build/src/third_party/issue-descriptions/emailVerificationRequestWellKnownListEmpty.md +1 -1
- package/build/src/third_party/issue-descriptions/emailVerificationRequestWellKnownMissingAccountsEndpoint.md +1 -1
- package/build/src/third_party/issue-descriptions/emailVerificationRequestWellKnownMissingIssuanceEndpoint.md +1 -1
- package/build/src/third_party/issue-descriptions/emailVerificationRequestWellKnownNoResponse.md +1 -1
- package/build/src/third_party/issue-descriptions/emailVerificationRequestWellKnownUnsupportedSigningAlgorithm.md +1 -1
- package/build/src/third_party/issue-descriptions/federatedAuthRequestAccountsHttpNotFound.md +1 -1
- package/build/src/third_party/issue-descriptions/federatedAuthRequestAccountsInvalidResponse.md +1 -1
- package/build/src/third_party/issue-descriptions/federatedAuthRequestAccountsNoResponse.md +1 -1
- package/build/src/third_party/issue-descriptions/federatedAuthRequestApprovalDeclined.md +1 -1
- package/build/src/third_party/issue-descriptions/federatedAuthRequestCanceled.md +1 -1
- package/build/src/third_party/issue-descriptions/federatedAuthRequestErrorFetchingSignin.md +1 -1
- package/build/src/third_party/issue-descriptions/federatedAuthRequestErrorIdToken.md +1 -1
- package/build/src/third_party/issue-descriptions/federatedAuthRequestIdTokenHttpNotFound.md +1 -1
- package/build/src/third_party/issue-descriptions/federatedAuthRequestIdTokenInvalidRequest.md +1 -1
- package/build/src/third_party/issue-descriptions/federatedAuthRequestIdTokenInvalidResponse.md +1 -1
- package/build/src/third_party/issue-descriptions/federatedAuthRequestIdTokenNoResponse.md +1 -1
- package/build/src/third_party/issue-descriptions/federatedAuthRequestInvalidSigninResponse.md +1 -1
- package/build/src/third_party/issue-descriptions/federatedAuthRequestManifestHttpNotFound.md +1 -1
- package/build/src/third_party/issue-descriptions/federatedAuthRequestManifestInvalidResponse.md +1 -1
- package/build/src/third_party/issue-descriptions/federatedAuthRequestManifestNoResponse.md +1 -1
- package/build/src/third_party/issue-descriptions/federatedAuthRequestTooManyRequests.md +1 -1
- package/build/src/third_party/issue-descriptions/federatedAuthUserInfoRequestInvalidAccountsResponse.md +1 -1
- package/build/src/third_party/issue-descriptions/federatedAuthUserInfoRequestInvalidConfigOrWellKnown.md +1 -1
- package/build/src/third_party/issue-descriptions/federatedAuthUserInfoRequestNoAccountSharingPermission.md +1 -1
- package/build/src/third_party/issue-descriptions/federatedAuthUserInfoRequestNoApiPermission.md +1 -1
- package/build/src/third_party/issue-descriptions/federatedAuthUserInfoRequestNoReturningUserFromFetchedAccounts.md +1 -1
- package/build/src/third_party/issue-descriptions/federatedAuthUserInfoRequestNotIframe.md +1 -1
- package/build/src/third_party/issue-descriptions/federatedAuthUserInfoRequestNotPotentiallyTrustworthy.md +1 -1
- package/build/src/third_party/issue-descriptions/federatedAuthUserInfoRequestNotSameOrigin.md +1 -1
- package/build/src/third_party/issue-descriptions/federatedAuthUserInfoRequestNotSignedInWithIdp.md +1 -1
- package/build/src/third_party/issue-descriptions/fetchingPartitionedBlobURL.md +2 -2
- package/build/src/third_party/issue-descriptions/genericFormAriaLabelledByToNonExistingIdError.md +2 -2
- package/build/src/third_party/issue-descriptions/genericFormAutocompleteAttributeEmptyError.md +1 -1
- package/build/src/third_party/issue-descriptions/genericFormDuplicateIdForInputError.md +1 -1
- package/build/src/third_party/issue-descriptions/genericFormEmptyIdAndNameAttributesForInputError.md +2 -2
- package/build/src/third_party/issue-descriptions/genericFormInputAssignedAutocompleteValueToIdOrNameAttributeError.md +2 -2
- package/build/src/third_party/issue-descriptions/genericFormInputHasWrongButWellIntendedAutocompleteValueError.md +1 -1
- package/build/src/third_party/issue-descriptions/genericFormInputWithNoLabelError.md +1 -1
- package/build/src/third_party/issue-descriptions/genericFormLabelForMatchesNonExistingIdError.md +2 -2
- package/build/src/third_party/issue-descriptions/genericFormLabelForNameError.md +1 -1
- package/build/src/third_party/issue-descriptions/genericFormLabelHasNeitherForNorNestedInputError.md +1 -1
- package/build/src/third_party/issue-descriptions/genericFormModelContextMissingToolName.md +1 -1
- package/build/src/third_party/issue-descriptions/genericFormModelContextParameterMissingName.md +1 -1
- package/build/src/third_party/issue-descriptions/genericFormModelContextRequiredParameterMissingName.md +1 -1
- package/build/src/third_party/issue-descriptions/genericNavigationEntryMarkedSkippable.md +2 -2
- package/build/src/third_party/issue-descriptions/heavyAd.md +1 -1
- package/build/src/third_party/issue-descriptions/lazyLoadImageZeroSize.md +7 -0
- package/build/src/third_party/issue-descriptions/navigatingPartitionedBlobURL.md +3 -3
- package/build/src/third_party/issue-descriptions/permissionElementActivationDisabled.md +1 -1
- package/build/src/third_party/issue-descriptions/permissionElementActivationDisabledWithOccluder.md +1 -1
- package/build/src/third_party/issue-descriptions/permissionElementActivationDisabledWithOccluderParent.md +1 -1
- package/build/src/third_party/issue-descriptions/permissionElementFencedFrameDisallowed.md +2 -2
- package/build/src/third_party/issue-descriptions/permissionElementFontSizeTooLarge.md +2 -2
- package/build/src/third_party/issue-descriptions/permissionElementFontSizeTooSmall.md +2 -2
- package/build/src/third_party/issue-descriptions/permissionElementInsetBoxShadowUnsupported.md +1 -1
- package/build/src/third_party/issue-descriptions/permissionElementInvalidDisplayStyle.md +2 -2
- package/build/src/third_party/issue-descriptions/permissionElementInvalidSizeValue.md +2 -2
- package/build/src/third_party/issue-descriptions/permissionElementInvalidType.md +2 -2
- package/build/src/third_party/issue-descriptions/permissionElementInvalidTypeActivation.md +2 -2
- package/build/src/third_party/issue-descriptions/permissionElementNonOpaqueColor.md +1 -1
- package/build/src/third_party/issue-descriptions/permissionElementPaddingBottomUnsupported.md +2 -2
- package/build/src/third_party/issue-descriptions/permissionElementPaddingRightUnsupported.md +2 -2
- package/build/src/third_party/issue-descriptions/permissionElementRequestInProgress.md +2 -2
- package/build/src/third_party/issue-descriptions/permissionElementSecurityChecksFailed.md +1 -1
- package/build/src/third_party/issue-descriptions/permissionElementTypeNotSupported.md +2 -2
- package/build/src/third_party/issue-descriptions/permissionElementUntrustedEvent.md +1 -1
- package/build/src/third_party/issue-descriptions/placeholderDescriptionForInvisibleIssues.md +1 -1
- package/build/src/third_party/issue-descriptions/selectElementAccessibilityDisallowedOptGroupChild.md +1 -1
- package/build/src/third_party/issue-descriptions/selectElementAccessibilityDisallowedSelectChild.md +1 -1
- package/build/src/third_party/issue-descriptions/selectElementAccessibilityInteractiveContentAttributesSelectDescendant.md +1 -1
- package/build/src/third_party/issue-descriptions/selectElementAccessibilityInteractiveContentLegendChild.md +1 -1
- package/build/src/third_party/issue-descriptions/selectElementAccessibilityInteractiveContentOptionChild.md +1 -1
- package/build/src/third_party/issue-descriptions/selectElementAccessibilityNonPhrasingContentOptionChild.md +1 -1
- package/build/src/third_party/issue-descriptions/selectivePermissionsIntervention.md +3 -3
- package/build/src/third_party/issue-descriptions/sharedArrayBuffer.md +1 -1
- package/build/src/third_party/issue-descriptions/sharedDictionaryUseErrorCrossOriginNoCorsRequest.md +1 -1
- package/build/src/third_party/issue-descriptions/sharedDictionaryUseErrorMatchingDictionaryNotUsed.md +1 -1
- package/build/src/third_party/issue-descriptions/sharedDictionaryUseErrorUnexpectedContentDictionaryHeader.md +1 -1
- package/build/src/third_party/issue-descriptions/sharedDictionaryWriteErrorCossOriginNoCorsRequest.md +1 -1
- package/build/src/third_party/issue-descriptions/sharedDictionaryWriteErrorDisallowedBySettings.md +1 -1
- package/build/src/third_party/issue-descriptions/sharedDictionaryWriteErrorExpiredResponse.md +1 -1
- package/build/src/third_party/issue-descriptions/sharedDictionaryWriteErrorFeatureDisabled.md +2 -2
- package/build/src/third_party/issue-descriptions/sharedDictionaryWriteErrorInvalidStructuredHeader.md +1 -1
- package/build/src/third_party/issue-descriptions/sharedDictionaryWriteErrorNavigationRequest.md +2 -2
- package/build/src/third_party/issue-descriptions/sriInvalidSignatureHeader.md +4 -4
- package/build/src/third_party/issue-descriptions/sriInvalidSignatureInputHeader.md +4 -4
- package/build/src/third_party/issue-descriptions/sriMissingSignatureHeader.md +1 -1
- package/build/src/third_party/issue-descriptions/sriMissingSignatureInputHeader.md +2 -2
- package/build/src/third_party/issue-descriptions/sriSignatureHeaderValueIsIncorrectLength.md +2 -2
- package/build/src/third_party/issue-descriptions/sriSignatureHeaderValueIsNotByteSequence.md +4 -4
- package/build/src/third_party/issue-descriptions/sriSignatureHeaderValueIsParameterized.md +4 -4
- package/build/src/third_party/issue-descriptions/sriSignatureInputHeaderInvalidComponentName.md +1 -1
- package/build/src/third_party/issue-descriptions/sriSignatureInputHeaderInvalidComponentType.md +2 -2
- package/build/src/third_party/issue-descriptions/sriSignatureInputHeaderInvalidDerivedComponentParameter.md +1 -1
- package/build/src/third_party/issue-descriptions/sriSignatureInputHeaderInvalidHeaderComponentParameter.md +1 -1
- package/build/src/third_party/issue-descriptions/sriSignatureInputHeaderInvalidParameter.md +2 -2
- package/build/src/third_party/issue-descriptions/sriSignatureInputHeaderKeyIdLength.md +5 -5
- package/build/src/third_party/issue-descriptions/sriSignatureInputHeaderMissingLabel.md +3 -3
- package/build/src/third_party/issue-descriptions/sriSignatureInputHeaderMissingRequiredParameters.md +2 -2
- package/build/src/third_party/issue-descriptions/sriSignatureInputHeaderValueMissingComponents.md +2 -2
- package/build/src/third_party/issue-descriptions/sriSignatureInputHeaderValueNotInnerList.md +2 -2
- package/build/src/third_party/issue-descriptions/sriValidationFailedIntegrityMismatch.md +4 -4
- package/build/src/third_party/issue-descriptions/sriValidationFailedInvalidLength.md +3 -3
- package/build/src/third_party/issue-descriptions/sriValidationFailedSignatureExpired.md +2 -2
- package/build/src/third_party/issue-descriptions/sriValidationFailedSignatureMismatch.md +2 -2
- package/build/src/third_party/issue-descriptions/stylesheetLateImport.md +1 -1
- package/build/src/third_party/issue-descriptions/summaryElementAccessibilityInteractiveContentSummaryDescendant.md +1 -1
- package/build/src/third_party/issue-descriptions/unencodedDigestIncorrectDigestLength.md +2 -2
- package/build/src/third_party/issue-descriptions/unencodedDigestIncorrectDigestType.md +3 -3
- package/build/src/third_party/issue-descriptions/unencodedDigestMalformedDictionary.md +2 -2
- package/build/src/third_party/issue-descriptions/unencodedDigestUnknownAlgorithm.md +1 -1
- package/build/src/third_party/lighthouse-devtools-mcp-bundle.js +3177 -6340
- package/build/src/tools/emulation.js +2 -2
- package/build/src/tools/extensions.js +1 -1
- package/build/src/tools/input.js +213 -112
- package/build/src/tools/lighthouse.js +1 -1
- package/build/src/tools/memory.js +49 -4
- package/build/src/tools/network.js +5 -5
- package/build/src/tools/pages.js +22 -89
- package/build/src/tools/performance.js +62 -41
- package/build/src/tools/screenshot.js +152 -77
- package/build/src/tools/script.js +95 -28
- package/build/src/tools/snapshot.js +2 -2
- package/build/src/tools/thirdPartyDeveloper.js +1 -1
- package/build/src/tools/webmcp.js +1 -1
- package/build/src/trace-processing/parse.js +1 -1
- package/build/src/{logger.js → utils/logger.js} +1 -1
- package/build/src/utils/polyfill.js +11 -0
- package/build/src/utils/url.js +43 -0
- package/build/src/version.js +1 -1
- package/package.json +23 -15
- package/skills/memory-leak-debugging/SKILL.md +23 -19
- package/skills/memory-leak-debugging/references/common-leaks.md +1 -1
- package/build/src/Mutex.js +0 -38
- package/build/src/devtools/DevToolsConnectionAdapter.js +0 -70
- package/build/src/polyfill.js +0 -8
- package/build/src/third_party/issue-descriptions/SameSiteExcludeContextDowngradeRead.md +0 -8
- package/build/src/third_party/issue-descriptions/SameSiteExcludeContextDowngradeSet.md +0 -8
- package/build/src/third_party/issue-descriptions/SameSiteExcludeNavigationContextDowngrade.md +0 -8
- package/build/src/third_party/issue-descriptions/SameSiteWarnCrossDowngradeRead.md +0 -8
- package/build/src/third_party/issue-descriptions/SameSiteWarnCrossDowngradeSet.md +0 -8
- package/build/src/third_party/issue-descriptions/SameSiteWarnStrictLaxDowngradeStrict.md +0 -8
- package/build/src/third_party/issue-descriptions/arInsecureContext.md +0 -7
- package/build/src/third_party/issue-descriptions/arInvalidInfoHeader.md +0 -5
- package/build/src/third_party/issue-descriptions/arInvalidRegisterOsSourceHeader.md +0 -5
- package/build/src/third_party/issue-descriptions/arInvalidRegisterOsTriggerHeader.md +0 -5
- package/build/src/third_party/issue-descriptions/arInvalidRegisterSourceHeader.md +0 -5
- package/build/src/third_party/issue-descriptions/arInvalidRegisterTriggerHeader.md +0 -5
- package/build/src/third_party/issue-descriptions/arNavigationRegistrationUniqueScopeAlreadySet.md +0 -5
- package/build/src/third_party/issue-descriptions/arNavigationRegistrationWithoutTransientUserActivation.md +0 -6
- package/build/src/third_party/issue-descriptions/arNoRegisterOsSourceHeader.md +0 -5
- package/build/src/third_party/issue-descriptions/arNoRegisterOsTriggerHeader.md +0 -5
- package/build/src/third_party/issue-descriptions/arNoRegisterSourceHeader.md +0 -5
- package/build/src/third_party/issue-descriptions/arNoRegisterTriggerHeader.md +0 -5
- package/build/src/third_party/issue-descriptions/arNoWebOrOsSupport.md +0 -4
- package/build/src/third_party/issue-descriptions/arOsSourceIgnored.md +0 -18
- package/build/src/third_party/issue-descriptions/arOsTriggerIgnored.md +0 -19
- package/build/src/third_party/issue-descriptions/arPermissionPolicyDisabled.md +0 -8
- package/build/src/third_party/issue-descriptions/arSourceAndTriggerHeaders.md +0 -9
- package/build/src/third_party/issue-descriptions/arSourceIgnored.md +0 -13
- package/build/src/third_party/issue-descriptions/arTriggerIgnored.md +0 -12
- package/build/src/third_party/issue-descriptions/arUntrustworthyReportingOrigin.md +0 -10
- package/build/src/third_party/issue-descriptions/arWebAndOsHeaders.md +0 -11
- package/build/src/utils/types.js +0 -7
- package/skills/memory-leak-debugging/references/compare_snapshots.js +0 -109
- package/skills/memory-leak-debugging/references/memlab.md +0 -29
package/build/src/tools/pages.js
CHANGED
|
@@ -3,55 +3,10 @@
|
|
|
3
3
|
* Copyright 2025 Google LLC
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
|
-
import { logger } from '../logger.js';
|
|
7
6
|
import { zod } from '../third_party/index.js';
|
|
7
|
+
import { logger } from '../utils/logger.js';
|
|
8
8
|
import { ToolCategory } from './categories.js';
|
|
9
9
|
import { CLOSE_PAGE_ERROR, definePageTool, defineTool, timeoutSchema, } from './ToolDefinition.js';
|
|
10
|
-
async function navigateWithInterception(page, action, allowListString, timeout) {
|
|
11
|
-
const allowList = allowListString
|
|
12
|
-
? allowListString.split(',').map((p) => new URLPattern(p.trim()))
|
|
13
|
-
: undefined;
|
|
14
|
-
const requestHandler = (interceptedRequest) => {
|
|
15
|
-
if (!interceptedRequest.isNavigationRequest()) {
|
|
16
|
-
void interceptedRequest.continue();
|
|
17
|
-
return;
|
|
18
|
-
}
|
|
19
|
-
const requestUrl = interceptedRequest.url();
|
|
20
|
-
const isAllowed = allowList.some((pattern) => pattern.test(requestUrl));
|
|
21
|
-
if (isAllowed) {
|
|
22
|
-
void interceptedRequest.continue();
|
|
23
|
-
}
|
|
24
|
-
else {
|
|
25
|
-
logger?.(`Blocking request to: ${requestUrl}`);
|
|
26
|
-
void interceptedRequest.abort('blockedbyclient');
|
|
27
|
-
}
|
|
28
|
-
};
|
|
29
|
-
const cleanupInterception = async () => {
|
|
30
|
-
if (allowList) {
|
|
31
|
-
page.pptrPage.off('request', requestHandler);
|
|
32
|
-
await page.pptrPage.setRequestInterception(false).catch(error => {
|
|
33
|
-
logger?.(`Failed to disable request interception`, error);
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
if (allowList) {
|
|
38
|
-
await page.pptrPage.setRequestInterception(true);
|
|
39
|
-
page.pptrPage.on('request', requestHandler);
|
|
40
|
-
}
|
|
41
|
-
try {
|
|
42
|
-
await page.waitForEventsAfterAction(async () => {
|
|
43
|
-
try {
|
|
44
|
-
await action();
|
|
45
|
-
}
|
|
46
|
-
finally {
|
|
47
|
-
await cleanupInterception();
|
|
48
|
-
}
|
|
49
|
-
}, { timeout });
|
|
50
|
-
}
|
|
51
|
-
finally {
|
|
52
|
-
await cleanupInterception();
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
10
|
export const listPages = defineTool(args => {
|
|
56
11
|
return {
|
|
57
12
|
name: 'list_pages',
|
|
@@ -129,7 +84,7 @@ export const closePage = defineTool({
|
|
|
129
84
|
response.setListThirdPartyDeveloperTools();
|
|
130
85
|
},
|
|
131
86
|
});
|
|
132
|
-
export const newPage = defineTool(
|
|
87
|
+
export const newPage = defineTool(() => {
|
|
133
88
|
return {
|
|
134
89
|
name: 'new_page',
|
|
135
90
|
description: `Open a new tab and load a URL. Use project URL if not specified otherwise.`,
|
|
@@ -149,29 +104,23 @@ export const newPage = defineTool(args => {
|
|
|
149
104
|
.describe('If specified, the page is created in an isolated browser context with the given name. ' +
|
|
150
105
|
'Pages in the same browser context share cookies and storage. ' +
|
|
151
106
|
'Pages in different browser contexts are fully isolated.'),
|
|
152
|
-
...(args?.experimentalNavigationAllowlist
|
|
153
|
-
? {
|
|
154
|
-
allowList: zod
|
|
155
|
-
.string()
|
|
156
|
-
.optional()
|
|
157
|
-
.describe('Optional comma-separated list of URL patterns to allow. If provided, all other navigations will be blocked.'),
|
|
158
|
-
}
|
|
159
|
-
: {}),
|
|
160
107
|
...timeoutSchema,
|
|
161
108
|
},
|
|
162
109
|
blockedByDialog: false,
|
|
163
110
|
verifyFilesSchema: [],
|
|
164
111
|
handler: async (request, response, context) => {
|
|
165
112
|
const page = await context.newPage(request.params.background, request.params.isolatedContext);
|
|
166
|
-
await
|
|
167
|
-
|
|
168
|
-
|
|
113
|
+
await page.waitForEventsAfterAction(async () => {
|
|
114
|
+
await page.pptrPage.goto(request.params.url, {
|
|
115
|
+
timeout: request.params.timeout,
|
|
116
|
+
});
|
|
117
|
+
}, { timeout: request.params.timeout });
|
|
169
118
|
response.setIncludePages(true);
|
|
170
119
|
response.setListThirdPartyDeveloperTools();
|
|
171
120
|
},
|
|
172
121
|
};
|
|
173
122
|
});
|
|
174
|
-
export const navigatePage = definePageTool(
|
|
123
|
+
export const navigatePage = definePageTool(() => {
|
|
175
124
|
return {
|
|
176
125
|
name: 'navigate_page',
|
|
177
126
|
description: `Go to a URL, or back, forward, or reload. Use project URL if not specified otherwise.`,
|
|
@@ -190,21 +139,13 @@ export const navigatePage = definePageTool(args => {
|
|
|
190
139
|
.optional()
|
|
191
140
|
.describe('Whether to ignore cache on reload.'),
|
|
192
141
|
handleBeforeUnload: zod
|
|
193
|
-
.enum(['accept', '
|
|
142
|
+
.enum(['accept', 'dismiss'])
|
|
194
143
|
.optional()
|
|
195
144
|
.describe('Whether to auto accept or beforeunload dialogs triggered by this navigation. Default is accept.'),
|
|
196
145
|
initScript: zod
|
|
197
146
|
.string()
|
|
198
147
|
.optional()
|
|
199
148
|
.describe('A JavaScript script to be executed on each new document before any other scripts for the next navigation.'),
|
|
200
|
-
...(args?.experimentalNavigationAllowlist
|
|
201
|
-
? {
|
|
202
|
-
allowList: zod
|
|
203
|
-
.string()
|
|
204
|
-
.optional()
|
|
205
|
-
.describe('Optional comma-separated list of URL patterns to allow. If provided, all other navigations will be blocked.'),
|
|
206
|
-
}
|
|
207
|
-
: {}),
|
|
208
149
|
...timeoutSchema,
|
|
209
150
|
},
|
|
210
151
|
blockedByDialog: false,
|
|
@@ -220,29 +161,14 @@ export const navigatePage = definePageTool(args => {
|
|
|
220
161
|
if (!request.params.type) {
|
|
221
162
|
request.params.type = 'url';
|
|
222
163
|
}
|
|
223
|
-
const handleBeforeUnload = request.params.handleBeforeUnload ?? 'accept';
|
|
224
|
-
const dialogHandler = (dialog) => {
|
|
225
|
-
if (dialog.type() === 'beforeunload') {
|
|
226
|
-
if (handleBeforeUnload === 'accept') {
|
|
227
|
-
response.appendResponseLine(`Accepted a beforeunload dialog.`);
|
|
228
|
-
void dialog.accept();
|
|
229
|
-
}
|
|
230
|
-
else {
|
|
231
|
-
response.appendResponseLine(`Declined a beforeunload dialog.`);
|
|
232
|
-
void dialog.dismiss();
|
|
233
|
-
}
|
|
234
|
-
// We are not going to report the dialog like regular dialogs.
|
|
235
|
-
page.clearDialog();
|
|
236
|
-
}
|
|
237
|
-
};
|
|
238
164
|
let initScriptId;
|
|
239
165
|
if (request.params.initScript) {
|
|
240
166
|
const { identifier } = await page.pptrPage.evaluateOnNewDocument(request.params.initScript);
|
|
241
167
|
initScriptId = identifier;
|
|
242
168
|
}
|
|
243
|
-
page.pptrPage.on('dialog', dialogHandler);
|
|
244
169
|
try {
|
|
245
|
-
|
|
170
|
+
const action = request.params.handleBeforeUnload ?? 'accept';
|
|
171
|
+
const result = await page.waitForEventsAfterAction(async () => {
|
|
246
172
|
switch (request.params.type) {
|
|
247
173
|
case 'url':
|
|
248
174
|
if (!request.params.url) {
|
|
@@ -287,10 +213,16 @@ export const navigatePage = definePageTool(args => {
|
|
|
287
213
|
}
|
|
288
214
|
break;
|
|
289
215
|
}
|
|
290
|
-
},
|
|
216
|
+
}, {
|
|
217
|
+
timeout: request.params.timeout,
|
|
218
|
+
handleDialog: { beforeunload: action },
|
|
219
|
+
});
|
|
220
|
+
if (result.dialogHandled) {
|
|
221
|
+
response.appendResponseLine(`${action === 'dismiss' ? 'Dismissed' : 'Accepted'} a beforeunload dialog.`);
|
|
222
|
+
page.clearDialog();
|
|
223
|
+
}
|
|
291
224
|
}
|
|
292
225
|
finally {
|
|
293
|
-
page.pptrPage.off('dialog', dialogHandler);
|
|
294
226
|
if (initScriptId) {
|
|
295
227
|
await page.pptrPage
|
|
296
228
|
.removeScriptToEvaluateOnNewDocument(initScriptId)
|
|
@@ -318,7 +250,7 @@ export const resizePage = definePageTool({
|
|
|
318
250
|
},
|
|
319
251
|
blockedByDialog: false,
|
|
320
252
|
verifyFilesSchema: [],
|
|
321
|
-
handler: async (request, response
|
|
253
|
+
handler: async (request, response) => {
|
|
322
254
|
const page = request.page;
|
|
323
255
|
try {
|
|
324
256
|
const browser = page.pptrPage.browser();
|
|
@@ -361,7 +293,7 @@ export const handleDialog = definePageTool({
|
|
|
361
293
|
},
|
|
362
294
|
blockedByDialog: false,
|
|
363
295
|
verifyFilesSchema: [],
|
|
364
|
-
handler: async (request, response
|
|
296
|
+
handler: async (request, response) => {
|
|
365
297
|
const page = request.page;
|
|
366
298
|
const dialog = page.getDialog();
|
|
367
299
|
if (!dialog) {
|
|
@@ -414,6 +346,7 @@ export const getTabId = definePageTool({
|
|
|
414
346
|
const page = context.getPageById(request.params.pageId);
|
|
415
347
|
const tabId = page.pptrPage._tabId;
|
|
416
348
|
response.setTabId(tabId);
|
|
349
|
+
response.appendResponseLine(`Tab ID: ${tabId}`);
|
|
417
350
|
},
|
|
418
351
|
});
|
|
419
352
|
//# sourceMappingURL=pages.js.map
|
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
6
|
import zlib from 'node:zlib';
|
|
7
|
-
import { logger } from '../logger.js';
|
|
8
7
|
import { zod, DevTools } from '../third_party/index.js';
|
|
9
8
|
import { parseRawTraceBuffer, traceResultIsSuccess, } from '../trace-processing/parse.js';
|
|
9
|
+
import { logger } from '../utils/logger.js';
|
|
10
10
|
import { ToolCategory } from './categories.js';
|
|
11
11
|
import { definePageTool } from './ToolDefinition.js';
|
|
12
12
|
const filePathSchema = zod
|
|
@@ -41,47 +41,68 @@ export const startTrace = definePageTool({
|
|
|
41
41
|
context.setIsRunningPerformanceTrace(true);
|
|
42
42
|
const page = request.page;
|
|
43
43
|
const pageUrlForTracing = page.pptrPage.url();
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
await page.pptrPage.goto(pageUrlForTracing, {
|
|
76
|
-
waitUntil: ['load'],
|
|
44
|
+
try {
|
|
45
|
+
if (request.params.reload) {
|
|
46
|
+
// Before starting the recording, navigate to about:blank to clear out any state.
|
|
47
|
+
// We use `load` because `networkidle0` is known to be flaky for about:blank in Puppeteer.
|
|
48
|
+
await page.pptrPage.goto('about:blank', {
|
|
49
|
+
waitUntil: 'load',
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
// Keep in sync with the categories arrays in:
|
|
53
|
+
// https://source.chromium.org/chromium/chromium/src/+/main:third_party/devtools-frontend/src/front_end/panels/timeline/TimelineController.ts
|
|
54
|
+
// https://github.com/GoogleChrome/lighthouse/blob/master/lighthouse-core/gather/gatherers/trace.js
|
|
55
|
+
const categories = [
|
|
56
|
+
'-*',
|
|
57
|
+
'blink.console',
|
|
58
|
+
'blink.user_timing',
|
|
59
|
+
'devtools.timeline',
|
|
60
|
+
'disabled-by-default-devtools.screenshot',
|
|
61
|
+
'disabled-by-default-devtools.timeline',
|
|
62
|
+
'disabled-by-default-devtools.timeline.invalidationTracking',
|
|
63
|
+
'disabled-by-default-devtools.timeline.frame',
|
|
64
|
+
'disabled-by-default-devtools.timeline.stack',
|
|
65
|
+
'disabled-by-default-v8.cpu_profiler',
|
|
66
|
+
'disabled-by-default-v8.cpu_profiler.hires',
|
|
67
|
+
'latencyInfo',
|
|
68
|
+
'loading',
|
|
69
|
+
'disabled-by-default-lighthouse',
|
|
70
|
+
'v8.execute',
|
|
71
|
+
'v8',
|
|
72
|
+
];
|
|
73
|
+
await page.pptrPage.tracing.start({
|
|
74
|
+
categories,
|
|
77
75
|
});
|
|
76
|
+
if (request.params.reload) {
|
|
77
|
+
await page.pptrPage.goto(pageUrlForTracing, {
|
|
78
|
+
waitUntil: ['load'],
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
if (request.params.autoStop) {
|
|
82
|
+
await new Promise(resolve => setTimeout(resolve, 5_000));
|
|
83
|
+
await stopTracingAndAppendOutput(page, response, context, request.params.filePath);
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
response.appendResponseLine(`The performance trace is being recorded. Use performance_stop_trace to stop it.`);
|
|
87
|
+
}
|
|
78
88
|
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
89
|
+
catch (error) {
|
|
90
|
+
// If a setup step (navigation, tracing.start) throws before
|
|
91
|
+
// stopTracingAndAppendOutput runs, the running flag would otherwise stay
|
|
92
|
+
// stuck `true` for the rest of the session, blocking all future traces.
|
|
93
|
+
// Unwind here: stop tracing if it was started and clear the flag. When
|
|
94
|
+
// autoStop already ran stopTracingAndAppendOutput the flag is already
|
|
95
|
+
// false and this is a no-op.
|
|
96
|
+
if (context.isRunningPerformanceTrace()) {
|
|
97
|
+
try {
|
|
98
|
+
await page.pptrPage.tracing.stop();
|
|
99
|
+
}
|
|
100
|
+
catch {
|
|
101
|
+
// Tracing may not have started yet; ignore.
|
|
102
|
+
}
|
|
103
|
+
context.setIsRunningPerformanceTrace(false);
|
|
104
|
+
}
|
|
105
|
+
throw error;
|
|
85
106
|
}
|
|
86
107
|
},
|
|
87
108
|
});
|
|
@@ -148,7 +169,7 @@ async function stopTracingAndAppendOutput(page, response, context, filePath) {
|
|
|
148
169
|
});
|
|
149
170
|
});
|
|
150
171
|
}
|
|
151
|
-
const file = await context.saveFile(dataToWrite, filePath, filePath.endsWith('.gz') ? '.
|
|
172
|
+
const file = await context.saveFile(dataToWrite, filePath, filePath.endsWith('.gz') ? '.gz' : '.json');
|
|
152
173
|
response.appendResponseLine(`The raw trace data was saved to ${file.filename}.`);
|
|
153
174
|
}
|
|
154
175
|
const result = await parseRawTraceBuffer(traceEventsBuffer, {
|
|
@@ -3,6 +3,58 @@
|
|
|
3
3
|
* Copyright 2025 Google LLC
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
|
+
var __addDisposableResource = (this && this.__addDisposableResource) || function (env, value, async) {
|
|
7
|
+
if (value !== null && value !== void 0) {
|
|
8
|
+
if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
|
|
9
|
+
var dispose, inner;
|
|
10
|
+
if (async) {
|
|
11
|
+
if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined.");
|
|
12
|
+
dispose = value[Symbol.asyncDispose];
|
|
13
|
+
}
|
|
14
|
+
if (dispose === void 0) {
|
|
15
|
+
if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined.");
|
|
16
|
+
dispose = value[Symbol.dispose];
|
|
17
|
+
if (async) inner = dispose;
|
|
18
|
+
}
|
|
19
|
+
if (typeof dispose !== "function") throw new TypeError("Object not disposable.");
|
|
20
|
+
if (inner) dispose = function() { try { inner.call(this); } catch (e) { return Promise.reject(e); } };
|
|
21
|
+
env.stack.push({ value: value, dispose: dispose, async: async });
|
|
22
|
+
}
|
|
23
|
+
else if (async) {
|
|
24
|
+
env.stack.push({ async: true });
|
|
25
|
+
}
|
|
26
|
+
return value;
|
|
27
|
+
};
|
|
28
|
+
var __disposeResources = (this && this.__disposeResources) || (function (SuppressedError) {
|
|
29
|
+
return function (env) {
|
|
30
|
+
function fail(e) {
|
|
31
|
+
env.error = env.hasError ? new SuppressedError(e, env.error, "An error was suppressed during disposal.") : e;
|
|
32
|
+
env.hasError = true;
|
|
33
|
+
}
|
|
34
|
+
var r, s = 0;
|
|
35
|
+
function next() {
|
|
36
|
+
while (r = env.stack.pop()) {
|
|
37
|
+
try {
|
|
38
|
+
if (!r.async && s === 1) return s = 0, env.stack.push(r), Promise.resolve().then(next);
|
|
39
|
+
if (r.dispose) {
|
|
40
|
+
var result = r.dispose.call(r.value);
|
|
41
|
+
if (r.async) return s |= 2, Promise.resolve(result).then(next, function(e) { fail(e); return next(); });
|
|
42
|
+
}
|
|
43
|
+
else s |= 1;
|
|
44
|
+
}
|
|
45
|
+
catch (e) {
|
|
46
|
+
fail(e);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
if (s === 1) return env.hasError ? Promise.reject(env.error) : Promise.resolve();
|
|
50
|
+
if (env.hasError) throw env.error;
|
|
51
|
+
}
|
|
52
|
+
return next();
|
|
53
|
+
};
|
|
54
|
+
})(typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
55
|
+
var e = new Error(message);
|
|
56
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
57
|
+
});
|
|
6
58
|
import { zod } from '../third_party/index.js';
|
|
7
59
|
import { ToolCategory } from './categories.js';
|
|
8
60
|
import { definePageTool } from './ToolDefinition.js';
|
|
@@ -22,10 +74,20 @@ async function getSourceBox(page, element, fullPage) {
|
|
|
22
74
|
return { x: 0, y: 0, width: dims.width, height: dims.height };
|
|
23
75
|
}
|
|
24
76
|
const viewport = page.viewport();
|
|
25
|
-
if (
|
|
77
|
+
if (viewport) {
|
|
78
|
+
return { x: 0, y: 0, width: viewport.width, height: viewport.height };
|
|
79
|
+
}
|
|
80
|
+
// The browser is launched and connected with `defaultViewport: null`, so
|
|
81
|
+
// `page.viewport()` stays null until something emulates one. Fall back to the
|
|
82
|
+
// window's own dimensions, which is the area a viewport screenshot captures.
|
|
83
|
+
const dims = await page.evaluate(() => ({
|
|
84
|
+
width: window.innerWidth,
|
|
85
|
+
height: window.innerHeight,
|
|
86
|
+
}));
|
|
87
|
+
if (dims.width <= 0 || dims.height <= 0) {
|
|
26
88
|
return undefined;
|
|
27
89
|
}
|
|
28
|
-
return { x: 0, y: 0, width:
|
|
90
|
+
return { x: 0, y: 0, width: dims.width, height: dims.height };
|
|
29
91
|
}
|
|
30
92
|
function computeDownscaleClip(box, maxWidth, maxHeight) {
|
|
31
93
|
const widthScale = maxWidth !== undefined ? Math.min(1, maxWidth / box.width) : 1;
|
|
@@ -84,84 +146,97 @@ export const screenshot = definePageTool(args => {
|
|
|
84
146
|
blockedByDialog: true,
|
|
85
147
|
verifyFilesSchema: ['filePath'],
|
|
86
148
|
handler: async (request, response, context) => {
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
149
|
+
const env_1 = { stack: [], error: void 0, hasError: false };
|
|
150
|
+
try {
|
|
151
|
+
if (request.params.uid && request.params.fullPage) {
|
|
152
|
+
throw new Error('Providing both "uid" and "fullPage" is not allowed.');
|
|
153
|
+
}
|
|
154
|
+
const page = request.page.pptrPage;
|
|
155
|
+
const element = __addDisposableResource(env_1, request.params.uid
|
|
156
|
+
? await request.page.getElementByUid(request.params.uid)
|
|
157
|
+
: undefined, false);
|
|
158
|
+
const format = request.params.format;
|
|
159
|
+
const quality = format === 'png'
|
|
160
|
+
? undefined
|
|
161
|
+
: (request.params.quality ?? screenshotQuality);
|
|
162
|
+
const fullPage = request.params.fullPage ?? false;
|
|
163
|
+
// `getElementByUid` mints a fresh ElementHandle per call, so dispose it
|
|
164
|
+
// once the capture is done to avoid leaking a remote object for the life
|
|
165
|
+
// of the page's execution context.
|
|
166
|
+
let screenshot;
|
|
167
|
+
// Compute a downscale clip when --screenshot-max-width or
|
|
168
|
+
// --screenshot-max-height is set and the source exceeds either bound.
|
|
169
|
+
// The smaller scale factor wins so both bounds are respected while
|
|
170
|
+
// preserving aspect ratio.
|
|
171
|
+
let clip;
|
|
172
|
+
if (screenshotMaxWidth !== undefined ||
|
|
173
|
+
screenshotMaxHeight !== undefined) {
|
|
174
|
+
const box = await getSourceBox(page, element, fullPage);
|
|
175
|
+
if (box) {
|
|
176
|
+
clip = computeDownscaleClip(box, screenshotMaxWidth, screenshotMaxHeight);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
if (clip) {
|
|
180
|
+
// page.screenshot with clip lets the CDP scale param downscale the
|
|
181
|
+
// capture for viewport, full-page and element shots alike. We rely on
|
|
182
|
+
// Puppeteer's default of captureBeyondViewport=true when a clip is
|
|
183
|
+
// present so element/full-page captures below the fold still work.
|
|
184
|
+
screenshot = await page.screenshot({
|
|
185
|
+
type: format,
|
|
186
|
+
quality,
|
|
187
|
+
optimizeForSpeed: true,
|
|
188
|
+
clip,
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
else if (element) {
|
|
192
|
+
screenshot = await element.screenshot({
|
|
193
|
+
type: format,
|
|
194
|
+
quality,
|
|
195
|
+
optimizeForSpeed: true,
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
else {
|
|
199
|
+
screenshot = await page.screenshot({
|
|
200
|
+
type: format,
|
|
201
|
+
fullPage,
|
|
202
|
+
quality,
|
|
203
|
+
optimizeForSpeed: true,
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
if (request.params.uid) {
|
|
207
|
+
response.appendResponseLine(`Took a screenshot of node with uid "${request.params.uid}".`);
|
|
208
|
+
}
|
|
209
|
+
else if (fullPage) {
|
|
210
|
+
response.appendResponseLine('Took a screenshot of the full current page.');
|
|
211
|
+
}
|
|
212
|
+
else {
|
|
213
|
+
response.appendResponseLine("Took a screenshot of the current page's viewport.");
|
|
214
|
+
}
|
|
215
|
+
// Narrow `format` at the point of use: in the factory form of
|
|
216
|
+
// definePageTool TS widens the Schema generic, which loses the literal
|
|
217
|
+
// union from zod.enum on request.params.format.
|
|
218
|
+
const extension = format === 'jpeg' ? '.jpeg' : format === 'webp' ? '.webp' : '.png';
|
|
219
|
+
if (request.params.filePath) {
|
|
220
|
+
const result = await context.saveFile(screenshot, request.params.filePath, extension);
|
|
221
|
+
response.appendResponseLine(`Saved screenshot to ${result.filename}.`);
|
|
222
|
+
}
|
|
223
|
+
else if (screenshot.length >= 2_000_000) {
|
|
224
|
+
const { filepath } = await context.saveTemporaryFile(screenshot, `screenshot${extension}`);
|
|
225
|
+
response.appendResponseLine(`Saved screenshot to ${filepath}.`);
|
|
226
|
+
}
|
|
227
|
+
else {
|
|
228
|
+
response.attachImage({
|
|
229
|
+
mimeType: `image/${format}`,
|
|
230
|
+
data: Buffer.from(screenshot).toString('base64'),
|
|
231
|
+
});
|
|
109
232
|
}
|
|
110
233
|
}
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
// capture for viewport, full-page and element shots alike. We rely on
|
|
115
|
-
// Puppeteer's default of captureBeyondViewport=true when a clip is
|
|
116
|
-
// present so element/full-page captures below the fold still work.
|
|
117
|
-
screenshot = await page.screenshot({
|
|
118
|
-
type: format,
|
|
119
|
-
quality,
|
|
120
|
-
optimizeForSpeed: true,
|
|
121
|
-
clip,
|
|
122
|
-
});
|
|
123
|
-
}
|
|
124
|
-
else if (element) {
|
|
125
|
-
screenshot = await element.screenshot({
|
|
126
|
-
type: format,
|
|
127
|
-
quality,
|
|
128
|
-
optimizeForSpeed: true,
|
|
129
|
-
});
|
|
130
|
-
}
|
|
131
|
-
else {
|
|
132
|
-
screenshot = await page.screenshot({
|
|
133
|
-
type: format,
|
|
134
|
-
fullPage,
|
|
135
|
-
quality,
|
|
136
|
-
optimizeForSpeed: true,
|
|
137
|
-
});
|
|
138
|
-
}
|
|
139
|
-
if (request.params.uid) {
|
|
140
|
-
response.appendResponseLine(`Took a screenshot of node with uid "${request.params.uid}".`);
|
|
141
|
-
}
|
|
142
|
-
else if (fullPage) {
|
|
143
|
-
response.appendResponseLine('Took a screenshot of the full current page.');
|
|
144
|
-
}
|
|
145
|
-
else {
|
|
146
|
-
response.appendResponseLine("Took a screenshot of the current page's viewport.");
|
|
147
|
-
}
|
|
148
|
-
// Narrow `format` at the point of use: in the factory form of
|
|
149
|
-
// definePageTool TS widens the Schema generic, which loses the literal
|
|
150
|
-
// union from zod.enum on request.params.format.
|
|
151
|
-
const extension = format === 'jpeg' ? '.jpeg' : format === 'webp' ? '.webp' : '.png';
|
|
152
|
-
if (request.params.filePath) {
|
|
153
|
-
const result = await context.saveFile(screenshot, request.params.filePath, extension);
|
|
154
|
-
response.appendResponseLine(`Saved screenshot to ${result.filename}.`);
|
|
155
|
-
}
|
|
156
|
-
else if (screenshot.length >= 2_000_000) {
|
|
157
|
-
const { filepath } = await context.saveTemporaryFile(screenshot, `screenshot${extension}`);
|
|
158
|
-
response.appendResponseLine(`Saved screenshot to ${filepath}.`);
|
|
234
|
+
catch (e_1) {
|
|
235
|
+
env_1.error = e_1;
|
|
236
|
+
env_1.hasError = true;
|
|
159
237
|
}
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
mimeType: `image/${format}`,
|
|
163
|
-
data: Buffer.from(screenshot).toString('base64'),
|
|
164
|
-
});
|
|
238
|
+
finally {
|
|
239
|
+
__disposeResources(env_1);
|
|
165
240
|
}
|
|
166
241
|
},
|
|
167
242
|
};
|