chrome-devtools-mcp 1.6.0 → 1.8.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 +73 -22
- package/build/src/McpContext.js +121 -44
- package/build/src/McpPage.js +230 -14
- package/build/src/McpResponse.js +209 -283
- package/build/src/SlimMcpResponse.js +1 -1
- package/build/src/TextSnapshot.js +80 -19
- package/build/src/ToolHandler.js +80 -15
- package/build/src/bin/chrome-devtools-mcp-main.js +3 -3
- package/build/src/bin/chrome-devtools.js +47 -32
- package/build/src/browser.js +3 -1
- package/build/src/{PageCollector.js → collectors/PageCollector.js} +15 -10
- package/build/src/{ServiceWorkerCollector.js → collectors/ServiceWorkerCollector.js} +1 -1
- package/build/src/{bin/chrome-devtools-cli-options.js → config/cli-options.js} +414 -23
- package/build/src/{bin/chrome-devtools-mcp-cli-options.js → config/mcp-options.js} +74 -9
- package/build/src/daemon/client.js +33 -2
- package/build/src/daemon/daemon.js +17 -13
- package/build/src/daemon/utils.js +18 -3
- package/build/src/devtools/DevtoolsUtils.js +9 -16
- package/build/src/formatters/ConsoleFormatter.js +43 -10
- package/build/src/formatters/HeapSnapshotFormatter.js +58 -13
- package/build/src/formatters/IssueFormatter.js +1 -1
- package/build/src/formatters/NetworkFormatter.js +7 -7
- package/build/src/index.js +34 -5
- package/build/src/{HeapSnapshotManager.js → processors/HeapSnapshotManager.js} +82 -27
- package/build/src/{trace-processing/parse.js → processors/PerformanceTrace.js} +1 -1
- package/build/src/telemetry/ClearcutLogger.js +16 -1
- package/build/src/telemetry/flagUtils.js +4 -3
- package/build/src/telemetry/transformation.js +30 -0
- package/build/src/telemetry/types.js +4 -0
- package/build/src/third_party/THIRD_PARTY_NOTICES +235 -113
- package/build/src/third_party/bundled-packages.json +6 -7
- package/build/src/third_party/devtools-formatter-worker.js +60 -19
- package/build/src/third_party/devtools-heap-snapshot-worker.js +657 -224
- package/build/src/third_party/index.js +62484 -43814
- 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/connectionAllowlistEmbeddingRequirementNotSatisfied.md +26 -0
- package/build/src/third_party/issue-descriptions/connectionAllowlistIFrameAttributeLoosensEmbeddingRequirement.md +19 -0
- package/build/src/third_party/issue-descriptions/connectionAllowlistInvalidAllowConnectionAllowlistFrom.md +21 -0
- 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/federatedAuthRequestAccountsBlockedByConnectionAllowlist.md +1 -0
- 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/federatedAuthRequestConfigBlockedByConnectionAllowlist.md +1 -0
- 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/federatedAuthRequestIdTokenBlockedByConnectionAllowlist.md +1 -0
- 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/federatedAuthRequestWellKnownBlockedByConnectionAllowlist.md +1 -0
- 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 +1125 -1027
- package/build/src/tools/categories.js +3 -0
- package/build/src/tools/console.js +9 -3
- package/build/src/tools/emulation.js +2 -2
- package/build/src/tools/extensions.js +7 -5
- package/build/src/tools/input.js +222 -120
- package/build/src/tools/lighthouse.js +3 -1
- package/build/src/tools/memory.js +144 -17
- package/build/src/tools/network.js +6 -3
- package/build/src/tools/pages.js +13 -16
- package/build/src/tools/performance.js +57 -46
- package/build/src/tools/pwa.js +128 -0
- package/build/src/tools/screencast.js +6 -4
- package/build/src/tools/screenshot.js +192 -84
- package/build/src/tools/script.js +118 -34
- package/build/src/tools/slim/tools.js +3 -3
- package/build/src/tools/snapshot.js +5 -3
- package/build/src/tools/thirdPartyDeveloper.js +2 -2
- package/build/src/tools/tools.js +2 -0
- package/build/src/tools/webmcp.js +2 -2
- package/build/src/utils/WaitForHelper.js +299 -0
- package/build/src/utils/bytes.js +105 -0
- package/build/src/utils/logger.js +25 -11
- package/build/src/utils/polyfill.js +6 -3
- package/build/src/utils/url.js +43 -0
- package/build/src/version.js +1 -1
- package/package.json +37 -25
- package/skills/a11y-debugging/SKILL.md +2 -0
- package/skills/chrome-devtools/SKILL.md +5 -4
- package/skills/chrome-devtools-cli/SKILL.md +109 -64
- package/skills/debug-optimize-lcp/SKILL.md +9 -9
- package/skills/memory-leak-debugging/SKILL.md +14 -18
- package/skills/memory-leak-debugging/references/common-leaks.md +1 -1
- package/skills/troubleshooting/SKILL.md +1 -0
- package/build/src/WaitForHelper.js +0 -200
- package/build/src/devtools/DevToolsConnectionAdapter.js +0 -70
- 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/Mutex.js +0 -38
- package/build/src/utils/string.js +0 -37
- package/skills/memory-leak-debugging/references/compare_snapshots.js +0 -109
- package/skills/memory-leak-debugging/references/memlab.md +0 -29
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { zod } from '../third_party/index.js';
|
|
7
|
+
import { ToolCategory } from './categories.js';
|
|
8
|
+
import { defineTool } from './ToolDefinition.js';
|
|
9
|
+
const manifestIdSchema = zod
|
|
10
|
+
.string()
|
|
11
|
+
.describe('The manifest ID of the web app: the resolved `id` member of its manifest. ' +
|
|
12
|
+
'If `id` is omitted, it defaults to the resolved `start_url` ' +
|
|
13
|
+
'(e.g. "https://example.com/"). See https://w3c.github.io/manifest/#id-member.');
|
|
14
|
+
const displayModeSchema = zod
|
|
15
|
+
.enum(['standalone', 'browser'])
|
|
16
|
+
.optional()
|
|
17
|
+
.describe('Optional user display mode preference applied after install. ' +
|
|
18
|
+
'"standalone" opens the app in its own window; "browser" opens it as a ' +
|
|
19
|
+
'tab. Installs via the PWA CDP domain default to "browser" because they ' +
|
|
20
|
+
'do not simulate the install dialog, so pass "standalone" to get an ' +
|
|
21
|
+
'app-window experience.');
|
|
22
|
+
export const installPwa = defineTool({
|
|
23
|
+
name: 'install_pwa',
|
|
24
|
+
description: 'Installs a Progressive Web App (PWA) identified by its manifest ID. ' +
|
|
25
|
+
'This installs through the PWA CDP domain without a user gesture or install ' +
|
|
26
|
+
'dialog. DevTools installs default to browser display mode.',
|
|
27
|
+
annotations: {
|
|
28
|
+
category: ToolCategory.PWA,
|
|
29
|
+
readOnlyHint: false,
|
|
30
|
+
},
|
|
31
|
+
schema: {
|
|
32
|
+
manifestId: manifestIdSchema,
|
|
33
|
+
installUrlOrBundleUrl: zod
|
|
34
|
+
.string()
|
|
35
|
+
.describe('The location of the app or bundle. For a normal site this is the page ' +
|
|
36
|
+
'URL; for an Isolated Web App it can be a file:// or http(s):// ' +
|
|
37
|
+
'signed web bundle.'),
|
|
38
|
+
displayMode: displayModeSchema,
|
|
39
|
+
},
|
|
40
|
+
blockedByDialog: false,
|
|
41
|
+
// We do not validate file paths for remote browser instances
|
|
42
|
+
// because they are on the remote host and not accessed by the MCP server.
|
|
43
|
+
verifyFilesSchema: {
|
|
44
|
+
installUrlOrBundleUrl: {
|
|
45
|
+
local: true,
|
|
46
|
+
remote: false,
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
handler: async (request, response, context) => {
|
|
50
|
+
const { manifestId, installUrlOrBundleUrl, displayMode } = request.params;
|
|
51
|
+
await context.installPWA({
|
|
52
|
+
manifestId,
|
|
53
|
+
installUrlOrBundleUrl,
|
|
54
|
+
displayMode,
|
|
55
|
+
});
|
|
56
|
+
response.appendResponseLine(`Installed PWA with manifest ID: ${manifestId}`);
|
|
57
|
+
if (displayMode) {
|
|
58
|
+
response.appendResponseLine(`Display mode set to: ${displayMode}`);
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
});
|
|
62
|
+
export const uninstallPwa = defineTool({
|
|
63
|
+
name: 'uninstall_pwa',
|
|
64
|
+
description: 'Uninstalls a Progressive Web App identified by its manifest ID and ' +
|
|
65
|
+
'closes any open app windows.',
|
|
66
|
+
annotations: {
|
|
67
|
+
category: ToolCategory.PWA,
|
|
68
|
+
readOnlyHint: false,
|
|
69
|
+
},
|
|
70
|
+
schema: {
|
|
71
|
+
manifestId: manifestIdSchema,
|
|
72
|
+
},
|
|
73
|
+
blockedByDialog: false,
|
|
74
|
+
verifyFilesSchema: {},
|
|
75
|
+
handler: async (request, response, context) => {
|
|
76
|
+
const { manifestId } = request.params;
|
|
77
|
+
await context.uninstallPWA({ manifestId });
|
|
78
|
+
response.appendResponseLine(`Uninstalled PWA with manifest ID: ${manifestId}`);
|
|
79
|
+
response.setIncludePages(true);
|
|
80
|
+
},
|
|
81
|
+
});
|
|
82
|
+
export const launchPwa = defineTool({
|
|
83
|
+
name: 'launch_pwa',
|
|
84
|
+
description: 'Launches an installed Progressive Web App using its saved display mode. ' +
|
|
85
|
+
'Optionally opens a specific URL within the same app instead of the default ' +
|
|
86
|
+
'start URL.',
|
|
87
|
+
annotations: {
|
|
88
|
+
category: ToolCategory.PWA,
|
|
89
|
+
readOnlyHint: false,
|
|
90
|
+
},
|
|
91
|
+
schema: {
|
|
92
|
+
manifestId: manifestIdSchema,
|
|
93
|
+
url: zod
|
|
94
|
+
.string()
|
|
95
|
+
.optional()
|
|
96
|
+
.describe('Optional URL within the app to open instead of the default start URL.'),
|
|
97
|
+
},
|
|
98
|
+
blockedByDialog: false,
|
|
99
|
+
verifyFilesSchema: {},
|
|
100
|
+
handler: async (request, response, context) => {
|
|
101
|
+
const { manifestId, url } = request.params;
|
|
102
|
+
const page = await context.launchPWA({ manifestId, url });
|
|
103
|
+
response.appendResponseLine(`Launched PWA with manifest ID: ${manifestId} (${page.url()})`);
|
|
104
|
+
response.setIncludePages(true);
|
|
105
|
+
},
|
|
106
|
+
});
|
|
107
|
+
export const getOsAppState = defineTool({
|
|
108
|
+
name: 'get_os_app_state',
|
|
109
|
+
description: 'Returns the OS integration state (badge count and registered file ' +
|
|
110
|
+
'handlers) for an installed web app, identified by its manifest ID.',
|
|
111
|
+
annotations: {
|
|
112
|
+
category: ToolCategory.PWA,
|
|
113
|
+
readOnlyHint: true,
|
|
114
|
+
},
|
|
115
|
+
schema: {
|
|
116
|
+
manifestId: manifestIdSchema,
|
|
117
|
+
},
|
|
118
|
+
blockedByDialog: false,
|
|
119
|
+
verifyFilesSchema: {},
|
|
120
|
+
handler: async (request, response, context) => {
|
|
121
|
+
const { manifestId } = request.params;
|
|
122
|
+
const state = await context.getPWAState({ manifestId });
|
|
123
|
+
response.appendResponseLine(`OS app state for manifest ID: ${manifestId}`);
|
|
124
|
+
response.appendResponseLine(`Badge count: ${state.badgeCount}`);
|
|
125
|
+
response.appendResponseLine(`File handlers: ${JSON.stringify(state.fileHandlers)}`);
|
|
126
|
+
},
|
|
127
|
+
});
|
|
128
|
+
//# sourceMappingURL=pwa.js.map
|
|
@@ -16,7 +16,7 @@ async function generateTempFilePath() {
|
|
|
16
16
|
const supportedExtensions = ['.webm', '.mp4'];
|
|
17
17
|
export const startScreencast = definePageTool(args => ({
|
|
18
18
|
name: 'screencast_start',
|
|
19
|
-
description: `Starts recording a screencast (video) of the
|
|
19
|
+
description: `Starts recording a screencast (video) of the target page in specified format.`,
|
|
20
20
|
annotations: {
|
|
21
21
|
category: ToolCategory.DEBUGGING,
|
|
22
22
|
readOnlyHint: false,
|
|
@@ -29,7 +29,9 @@ export const startScreencast = definePageTool(args => ({
|
|
|
29
29
|
.describe(`Output file path (${supportedExtensions.join(',')} are supported). Uses mkdtemp to generate a unique path if not provided.`),
|
|
30
30
|
},
|
|
31
31
|
blockedByDialog: false,
|
|
32
|
-
verifyFilesSchema:
|
|
32
|
+
verifyFilesSchema: {
|
|
33
|
+
filePath: true,
|
|
34
|
+
},
|
|
33
35
|
handler: async (request, response, context) => {
|
|
34
36
|
if (context.getScreenRecorder() !== null) {
|
|
35
37
|
response.appendResponseLine('Error: a screencast recording is already in progress. Use screencast_stop to stop it before starting a new one.');
|
|
@@ -89,7 +91,7 @@ export const startScreencast = definePageTool(args => ({
|
|
|
89
91
|
}));
|
|
90
92
|
export const stopScreencast = definePageTool({
|
|
91
93
|
name: 'screencast_stop',
|
|
92
|
-
description: 'Stops the active screencast recording on the
|
|
94
|
+
description: 'Stops the active screencast recording on the target page.',
|
|
93
95
|
annotations: {
|
|
94
96
|
category: ToolCategory.DEBUGGING,
|
|
95
97
|
readOnlyHint: false,
|
|
@@ -97,7 +99,7 @@ export const stopScreencast = definePageTool({
|
|
|
97
99
|
},
|
|
98
100
|
schema: {},
|
|
99
101
|
blockedByDialog: false,
|
|
100
|
-
verifyFilesSchema:
|
|
102
|
+
verifyFilesSchema: {},
|
|
101
103
|
handler: async (_request, response, context) => {
|
|
102
104
|
const data = context.getScreenRecorder();
|
|
103
105
|
if (!data) {
|
|
@@ -3,39 +3,132 @@
|
|
|
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';
|
|
9
61
|
async function getSourceBox(page, element, fullPage) {
|
|
10
62
|
if (element) {
|
|
11
|
-
const
|
|
12
|
-
|
|
63
|
+
const viewport = page.viewport();
|
|
64
|
+
const [box, devicePixelRatio] = await Promise.all([
|
|
65
|
+
element.boundingBox(),
|
|
66
|
+
viewport
|
|
67
|
+
? (viewport.deviceScaleFactor ?? 1)
|
|
68
|
+
: page.evaluate(() => window.devicePixelRatio),
|
|
69
|
+
]);
|
|
70
|
+
return box ? { ...box, devicePixelRatio } : undefined;
|
|
13
71
|
}
|
|
14
72
|
if (fullPage) {
|
|
15
73
|
const dims = await page.evaluate(() => ({
|
|
16
74
|
width: Math.max(document.documentElement.scrollWidth, document.body?.scrollWidth ?? 0),
|
|
17
75
|
height: Math.max(document.documentElement.scrollHeight, document.body?.scrollHeight ?? 0),
|
|
76
|
+
devicePixelRatio: window.devicePixelRatio,
|
|
18
77
|
}));
|
|
19
78
|
if (dims.width <= 0 || dims.height <= 0) {
|
|
20
79
|
return undefined;
|
|
21
80
|
}
|
|
22
|
-
return {
|
|
81
|
+
return {
|
|
82
|
+
x: 0,
|
|
83
|
+
y: 0,
|
|
84
|
+
width: dims.width,
|
|
85
|
+
height: dims.height,
|
|
86
|
+
devicePixelRatio: dims.devicePixelRatio,
|
|
87
|
+
};
|
|
23
88
|
}
|
|
24
89
|
const viewport = page.viewport();
|
|
25
|
-
if (
|
|
90
|
+
if (viewport) {
|
|
91
|
+
return {
|
|
92
|
+
x: 0,
|
|
93
|
+
y: 0,
|
|
94
|
+
width: viewport.width,
|
|
95
|
+
height: viewport.height,
|
|
96
|
+
devicePixelRatio: viewport.deviceScaleFactor ?? 1,
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
// The browser is launched and connected with `defaultViewport: null`, so
|
|
100
|
+
// `page.viewport()` stays null until something emulates one. Fall back to the
|
|
101
|
+
// window's own dimensions, which is the area a viewport screenshot captures.
|
|
102
|
+
const dims = await page.evaluate(() => ({
|
|
103
|
+
width: window.innerWidth,
|
|
104
|
+
height: window.innerHeight,
|
|
105
|
+
devicePixelRatio: window.devicePixelRatio,
|
|
106
|
+
}));
|
|
107
|
+
if (dims.width <= 0 || dims.height <= 0) {
|
|
26
108
|
return undefined;
|
|
27
109
|
}
|
|
28
|
-
return {
|
|
110
|
+
return {
|
|
111
|
+
x: 0,
|
|
112
|
+
y: 0,
|
|
113
|
+
width: dims.width,
|
|
114
|
+
height: dims.height,
|
|
115
|
+
devicePixelRatio: dims.devicePixelRatio,
|
|
116
|
+
};
|
|
29
117
|
}
|
|
30
118
|
function computeDownscaleClip(box, maxWidth, maxHeight) {
|
|
31
|
-
const widthScale = maxWidth !== undefined
|
|
32
|
-
|
|
119
|
+
const widthScale = maxWidth !== undefined
|
|
120
|
+
? Math.min(1, maxWidth / (box.width * box.devicePixelRatio))
|
|
121
|
+
: 1;
|
|
122
|
+
const heightScale = maxHeight !== undefined
|
|
123
|
+
? Math.min(1, maxHeight / (box.height * box.devicePixelRatio))
|
|
124
|
+
: 1;
|
|
33
125
|
const scale = Math.min(widthScale, heightScale);
|
|
34
126
|
if (scale >= 1) {
|
|
35
127
|
return undefined;
|
|
36
128
|
}
|
|
37
129
|
// Skip degenerate sub-pixel results.
|
|
38
|
-
if (Math.round(box.width *
|
|
130
|
+
if (Math.round(box.width * box.devicePixelRatio * scale) < 1 ||
|
|
131
|
+
Math.round(box.height * box.devicePixelRatio * scale) < 1) {
|
|
39
132
|
return undefined;
|
|
40
133
|
}
|
|
41
134
|
return {
|
|
@@ -82,86 +175,101 @@ export const screenshot = definePageTool(args => {
|
|
|
82
175
|
.describe('The absolute path, or a path relative to the current working directory, to save the screenshot to instead of attaching it to the response.'),
|
|
83
176
|
},
|
|
84
177
|
blockedByDialog: true,
|
|
85
|
-
verifyFilesSchema:
|
|
178
|
+
verifyFilesSchema: {
|
|
179
|
+
filePath: true,
|
|
180
|
+
},
|
|
86
181
|
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
|
-
|
|
182
|
+
const env_1 = { stack: [], error: void 0, hasError: false };
|
|
183
|
+
try {
|
|
184
|
+
if (request.params.uid && request.params.fullPage) {
|
|
185
|
+
throw new Error('Providing both "uid" and "fullPage" is not allowed.');
|
|
186
|
+
}
|
|
187
|
+
const page = request.page.pptrPage;
|
|
188
|
+
const element = __addDisposableResource(env_1, request.params.uid
|
|
189
|
+
? await request.page.getElementByUid(request.params.uid)
|
|
190
|
+
: undefined, false);
|
|
191
|
+
const format = request.params.format;
|
|
192
|
+
const quality = format === 'png'
|
|
193
|
+
? undefined
|
|
194
|
+
: (request.params.quality ?? screenshotQuality);
|
|
195
|
+
const fullPage = request.params.fullPage ?? false;
|
|
196
|
+
// `getElementByUid` mints a fresh ElementHandle per call, so dispose it
|
|
197
|
+
// once the capture is done to avoid leaking a remote object for the life
|
|
198
|
+
// of the page's execution context.
|
|
199
|
+
let screenshot;
|
|
200
|
+
// Compute a downscale clip when --screenshot-max-width or
|
|
201
|
+
// --screenshot-max-height is set and the source exceeds either bound.
|
|
202
|
+
// The smaller scale factor wins so both bounds are respected while
|
|
203
|
+
// preserving aspect ratio.
|
|
204
|
+
let clip;
|
|
205
|
+
if (screenshotMaxWidth !== undefined ||
|
|
206
|
+
screenshotMaxHeight !== undefined) {
|
|
207
|
+
const box = await getSourceBox(page, element, fullPage);
|
|
208
|
+
if (box) {
|
|
209
|
+
clip = computeDownscaleClip(box, screenshotMaxWidth, screenshotMaxHeight);
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
if (clip) {
|
|
213
|
+
// page.screenshot with clip lets the CDP scale param downscale the
|
|
214
|
+
// capture for viewport, full-page and element shots alike. We rely on
|
|
215
|
+
// Puppeteer's default of captureBeyondViewport=true when a clip is
|
|
216
|
+
// present so element/full-page captures below the fold still work.
|
|
217
|
+
screenshot = await page.screenshot({
|
|
218
|
+
type: format,
|
|
219
|
+
quality,
|
|
220
|
+
optimizeForSpeed: true,
|
|
221
|
+
clip,
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
else if (element) {
|
|
225
|
+
screenshot = await element.screenshot({
|
|
226
|
+
type: format,
|
|
227
|
+
quality,
|
|
228
|
+
optimizeForSpeed: true,
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
else {
|
|
232
|
+
screenshot = await page.screenshot({
|
|
233
|
+
type: format,
|
|
234
|
+
fullPage,
|
|
235
|
+
quality,
|
|
236
|
+
optimizeForSpeed: true,
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
if (request.params.uid) {
|
|
240
|
+
response.appendResponseLine(`Took a screenshot of node with uid "${request.params.uid}".`);
|
|
241
|
+
}
|
|
242
|
+
else if (fullPage) {
|
|
243
|
+
response.appendResponseLine('Took a screenshot of the full current page.');
|
|
244
|
+
}
|
|
245
|
+
else {
|
|
246
|
+
response.appendResponseLine("Took a screenshot of the current page's viewport.");
|
|
247
|
+
}
|
|
248
|
+
// Narrow `format` at the point of use: in the factory form of
|
|
249
|
+
// definePageTool TS widens the Schema generic, which loses the literal
|
|
250
|
+
// union from zod.enum on request.params.format.
|
|
251
|
+
const extension = format === 'jpeg' ? '.jpeg' : format === 'webp' ? '.webp' : '.png';
|
|
252
|
+
if (request.params.filePath) {
|
|
253
|
+
const result = await context.saveFile(screenshot, request.params.filePath, extension);
|
|
254
|
+
response.appendResponseLine(`Saved screenshot to ${result.filename}.`);
|
|
255
|
+
}
|
|
256
|
+
else if (screenshot.length >= 2_000_000) {
|
|
257
|
+
const { filepath } = await context.saveTemporaryFile(screenshot, `screenshot${extension}`);
|
|
258
|
+
response.appendResponseLine(`Saved screenshot to ${filepath}.`);
|
|
259
|
+
}
|
|
260
|
+
else {
|
|
261
|
+
response.attachImage({
|
|
262
|
+
mimeType: `image/${format}`,
|
|
263
|
+
data: Buffer.from(screenshot).toString('base64'),
|
|
264
|
+
});
|
|
109
265
|
}
|
|
110
266
|
}
|
|
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}.`);
|
|
267
|
+
catch (e_1) {
|
|
268
|
+
env_1.error = e_1;
|
|
269
|
+
env_1.hasError = true;
|
|
159
270
|
}
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
mimeType: `image/${format}`,
|
|
163
|
-
data: Buffer.from(screenshot).toString('base64'),
|
|
164
|
-
});
|
|
271
|
+
finally {
|
|
272
|
+
__disposeResources(env_1);
|
|
165
273
|
}
|
|
166
274
|
},
|
|
167
275
|
};
|