@pedropaulovc/playwright-core 1.59.0-next
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 +3 -0
- package/ThirdPartyNotices.txt +4076 -0
- package/bin/install_media_pack.ps1 +5 -0
- package/bin/install_webkit_wsl.ps1 +33 -0
- package/bin/reinstall_chrome_beta_linux.sh +42 -0
- package/bin/reinstall_chrome_beta_mac.sh +13 -0
- package/bin/reinstall_chrome_beta_win.ps1 +24 -0
- package/bin/reinstall_chrome_stable_linux.sh +42 -0
- package/bin/reinstall_chrome_stable_mac.sh +12 -0
- package/bin/reinstall_chrome_stable_win.ps1 +24 -0
- package/bin/reinstall_msedge_beta_linux.sh +48 -0
- package/bin/reinstall_msedge_beta_mac.sh +11 -0
- package/bin/reinstall_msedge_beta_win.ps1 +23 -0
- package/bin/reinstall_msedge_dev_linux.sh +48 -0
- package/bin/reinstall_msedge_dev_mac.sh +11 -0
- package/bin/reinstall_msedge_dev_win.ps1 +23 -0
- package/bin/reinstall_msedge_stable_linux.sh +48 -0
- package/bin/reinstall_msedge_stable_mac.sh +11 -0
- package/bin/reinstall_msedge_stable_win.ps1 +24 -0
- package/browsers.json +79 -0
- package/cli.js +18 -0
- package/index.d.ts +17 -0
- package/index.js +32 -0
- package/index.mjs +28 -0
- package/lib/androidServerImpl.js +65 -0
- package/lib/browserServerImpl.js +120 -0
- package/lib/cli/driver.js +97 -0
- package/lib/cli/program.js +603 -0
- package/lib/cli/programWithTestStub.js +74 -0
- package/lib/client/android.js +361 -0
- package/lib/client/api.js +137 -0
- package/lib/client/artifact.js +79 -0
- package/lib/client/browser.js +161 -0
- package/lib/client/browserContext.js +582 -0
- package/lib/client/browserType.js +185 -0
- package/lib/client/cdpSession.js +51 -0
- package/lib/client/channelOwner.js +194 -0
- package/lib/client/clientHelper.js +64 -0
- package/lib/client/clientInstrumentation.js +55 -0
- package/lib/client/clientStackTrace.js +69 -0
- package/lib/client/clock.js +68 -0
- package/lib/client/connection.js +318 -0
- package/lib/client/consoleMessage.js +58 -0
- package/lib/client/coverage.js +44 -0
- package/lib/client/dialog.js +56 -0
- package/lib/client/download.js +62 -0
- package/lib/client/electron.js +138 -0
- package/lib/client/elementHandle.js +284 -0
- package/lib/client/errors.js +77 -0
- package/lib/client/eventEmitter.js +314 -0
- package/lib/client/events.js +103 -0
- package/lib/client/fetch.js +368 -0
- package/lib/client/fileChooser.js +46 -0
- package/lib/client/fileUtils.js +34 -0
- package/lib/client/frame.js +409 -0
- package/lib/client/harRouter.js +87 -0
- package/lib/client/input.js +84 -0
- package/lib/client/jsHandle.js +109 -0
- package/lib/client/jsonPipe.js +39 -0
- package/lib/client/localUtils.js +60 -0
- package/lib/client/locator.js +369 -0
- package/lib/client/network.js +747 -0
- package/lib/client/page.js +745 -0
- package/lib/client/pageAgent.js +64 -0
- package/lib/client/platform.js +77 -0
- package/lib/client/playwright.js +71 -0
- package/lib/client/selectors.js +55 -0
- package/lib/client/stream.js +39 -0
- package/lib/client/timeoutSettings.js +79 -0
- package/lib/client/tracing.js +119 -0
- package/lib/client/types.js +28 -0
- package/lib/client/video.js +59 -0
- package/lib/client/waiter.js +142 -0
- package/lib/client/webError.js +39 -0
- package/lib/client/webSocket.js +93 -0
- package/lib/client/worker.js +85 -0
- package/lib/client/writableStream.js +39 -0
- package/lib/generated/bindingsControllerSource.js +28 -0
- package/lib/generated/clockSource.js +28 -0
- package/lib/generated/injectedScriptSource.js +28 -0
- package/lib/generated/pollingRecorderSource.js +28 -0
- package/lib/generated/storageScriptSource.js +28 -0
- package/lib/generated/utilityScriptSource.js +28 -0
- package/lib/generated/webSocketMockSource.js +336 -0
- package/lib/inProcessFactory.js +60 -0
- package/lib/inprocess.js +3 -0
- package/lib/mcpBundle.js +84 -0
- package/lib/mcpBundleImpl/index.js +147 -0
- package/lib/outofprocess.js +76 -0
- package/lib/protocol/serializers.js +197 -0
- package/lib/protocol/validator.js +2969 -0
- package/lib/protocol/validatorPrimitives.js +193 -0
- package/lib/remote/playwrightConnection.js +129 -0
- package/lib/remote/playwrightServer.js +334 -0
- package/lib/server/agent/actionRunner.js +335 -0
- package/lib/server/agent/actions.js +128 -0
- package/lib/server/agent/codegen.js +111 -0
- package/lib/server/agent/context.js +150 -0
- package/lib/server/agent/expectTools.js +156 -0
- package/lib/server/agent/pageAgent.js +204 -0
- package/lib/server/agent/performTools.js +262 -0
- package/lib/server/agent/tool.js +109 -0
- package/lib/server/android/android.js +465 -0
- package/lib/server/android/backendAdb.js +177 -0
- package/lib/server/artifact.js +127 -0
- package/lib/server/bidi/bidiBrowser.js +549 -0
- package/lib/server/bidi/bidiChromium.js +148 -0
- package/lib/server/bidi/bidiConnection.js +213 -0
- package/lib/server/bidi/bidiDeserializer.js +116 -0
- package/lib/server/bidi/bidiExecutionContext.js +267 -0
- package/lib/server/bidi/bidiFirefox.js +128 -0
- package/lib/server/bidi/bidiInput.js +146 -0
- package/lib/server/bidi/bidiNetworkManager.js +383 -0
- package/lib/server/bidi/bidiOverCdp.js +102 -0
- package/lib/server/bidi/bidiPage.js +583 -0
- package/lib/server/bidi/bidiPdf.js +106 -0
- package/lib/server/bidi/third_party/bidiCommands.d.js +22 -0
- package/lib/server/bidi/third_party/bidiKeyboard.js +256 -0
- package/lib/server/bidi/third_party/bidiProtocol.js +24 -0
- package/lib/server/bidi/third_party/bidiProtocolCore.js +180 -0
- package/lib/server/bidi/third_party/bidiProtocolPermissions.js +42 -0
- package/lib/server/bidi/third_party/bidiSerializer.js +148 -0
- package/lib/server/bidi/third_party/firefoxPrefs.js +259 -0
- package/lib/server/browser.js +149 -0
- package/lib/server/browserContext.js +702 -0
- package/lib/server/browserType.js +336 -0
- package/lib/server/callLog.js +82 -0
- package/lib/server/chromium/appIcon.png +0 -0
- package/lib/server/chromium/chromium.js +395 -0
- package/lib/server/chromium/chromiumSwitches.js +104 -0
- package/lib/server/chromium/crBrowser.js +511 -0
- package/lib/server/chromium/crConnection.js +197 -0
- package/lib/server/chromium/crCoverage.js +235 -0
- package/lib/server/chromium/crDevTools.js +111 -0
- package/lib/server/chromium/crDragDrop.js +131 -0
- package/lib/server/chromium/crExecutionContext.js +146 -0
- package/lib/server/chromium/crInput.js +187 -0
- package/lib/server/chromium/crNetworkManager.js +707 -0
- package/lib/server/chromium/crPage.js +1001 -0
- package/lib/server/chromium/crPdf.js +121 -0
- package/lib/server/chromium/crProtocolHelper.js +145 -0
- package/lib/server/chromium/crServiceWorker.js +136 -0
- package/lib/server/chromium/defaultFontFamilies.js +162 -0
- package/lib/server/chromium/protocol.d.js +16 -0
- package/lib/server/clock.js +149 -0
- package/lib/server/codegen/csharp.js +327 -0
- package/lib/server/codegen/java.js +274 -0
- package/lib/server/codegen/javascript.js +247 -0
- package/lib/server/codegen/jsonl.js +52 -0
- package/lib/server/codegen/language.js +132 -0
- package/lib/server/codegen/languages.js +68 -0
- package/lib/server/codegen/python.js +279 -0
- package/lib/server/codegen/types.js +16 -0
- package/lib/server/console.js +57 -0
- package/lib/server/cookieStore.js +206 -0
- package/lib/server/debugController.js +191 -0
- package/lib/server/debugger.js +119 -0
- package/lib/server/deviceDescriptors.js +39 -0
- package/lib/server/deviceDescriptorsSource.json +1779 -0
- package/lib/server/dialog.js +116 -0
- package/lib/server/dispatchers/androidDispatcher.js +325 -0
- package/lib/server/dispatchers/artifactDispatcher.js +118 -0
- package/lib/server/dispatchers/browserContextDispatcher.js +384 -0
- package/lib/server/dispatchers/browserDispatcher.js +118 -0
- package/lib/server/dispatchers/browserTypeDispatcher.js +64 -0
- package/lib/server/dispatchers/cdpSessionDispatcher.js +44 -0
- package/lib/server/dispatchers/debugControllerDispatcher.js +78 -0
- package/lib/server/dispatchers/dialogDispatcher.js +47 -0
- package/lib/server/dispatchers/dispatcher.js +364 -0
- package/lib/server/dispatchers/electronDispatcher.js +89 -0
- package/lib/server/dispatchers/elementHandlerDispatcher.js +181 -0
- package/lib/server/dispatchers/frameDispatcher.js +227 -0
- package/lib/server/dispatchers/jsHandleDispatcher.js +85 -0
- package/lib/server/dispatchers/jsonPipeDispatcher.js +58 -0
- package/lib/server/dispatchers/localUtilsDispatcher.js +149 -0
- package/lib/server/dispatchers/networkDispatchers.js +213 -0
- package/lib/server/dispatchers/pageAgentDispatcher.js +96 -0
- package/lib/server/dispatchers/pageDispatcher.js +393 -0
- package/lib/server/dispatchers/playwrightDispatcher.js +108 -0
- package/lib/server/dispatchers/streamDispatcher.js +67 -0
- package/lib/server/dispatchers/tracingDispatcher.js +68 -0
- package/lib/server/dispatchers/webSocketRouteDispatcher.js +165 -0
- package/lib/server/dispatchers/writableStreamDispatcher.js +79 -0
- package/lib/server/dom.js +815 -0
- package/lib/server/download.js +70 -0
- package/lib/server/electron/electron.js +273 -0
- package/lib/server/electron/loader.js +29 -0
- package/lib/server/errors.js +69 -0
- package/lib/server/fetch.js +621 -0
- package/lib/server/fileChooser.js +43 -0
- package/lib/server/fileUploadUtils.js +84 -0
- package/lib/server/firefox/ffBrowser.js +418 -0
- package/lib/server/firefox/ffConnection.js +142 -0
- package/lib/server/firefox/ffExecutionContext.js +150 -0
- package/lib/server/firefox/ffInput.js +159 -0
- package/lib/server/firefox/ffNetworkManager.js +256 -0
- package/lib/server/firefox/ffPage.js +497 -0
- package/lib/server/firefox/firefox.js +114 -0
- package/lib/server/firefox/protocol.d.js +16 -0
- package/lib/server/formData.js +147 -0
- package/lib/server/frameSelectors.js +160 -0
- package/lib/server/frames.js +1471 -0
- package/lib/server/har/harRecorder.js +147 -0
- package/lib/server/har/harTracer.js +607 -0
- package/lib/server/harBackend.js +157 -0
- package/lib/server/helper.js +96 -0
- package/lib/server/index.js +58 -0
- package/lib/server/input.js +277 -0
- package/lib/server/instrumentation.js +72 -0
- package/lib/server/javascript.js +291 -0
- package/lib/server/launchApp.js +128 -0
- package/lib/server/localUtils.js +214 -0
- package/lib/server/macEditingCommands.js +143 -0
- package/lib/server/network.js +667 -0
- package/lib/server/page.js +830 -0
- package/lib/server/pipeTransport.js +89 -0
- package/lib/server/playwright.js +69 -0
- package/lib/server/progress.js +132 -0
- package/lib/server/protocolError.js +52 -0
- package/lib/server/recorder/chat.js +161 -0
- package/lib/server/recorder/recorderApp.js +366 -0
- package/lib/server/recorder/recorderRunner.js +138 -0
- package/lib/server/recorder/recorderSignalProcessor.js +83 -0
- package/lib/server/recorder/recorderUtils.js +157 -0
- package/lib/server/recorder/throttledFile.js +57 -0
- package/lib/server/recorder.js +499 -0
- package/lib/server/registry/browserFetcher.js +177 -0
- package/lib/server/registry/dependencies.js +371 -0
- package/lib/server/registry/index.js +1422 -0
- package/lib/server/registry/nativeDeps.js +1280 -0
- package/lib/server/registry/oopDownloadBrowserMain.js +127 -0
- package/lib/server/screencast.js +190 -0
- package/lib/server/screenshotter.js +333 -0
- package/lib/server/selectors.js +112 -0
- package/lib/server/socksClientCertificatesInterceptor.js +383 -0
- package/lib/server/socksInterceptor.js +95 -0
- package/lib/server/trace/recorder/snapshotter.js +147 -0
- package/lib/server/trace/recorder/snapshotterInjected.js +561 -0
- package/lib/server/trace/recorder/tracing.js +604 -0
- package/lib/server/trace/viewer/traceExporter.js +679 -0
- package/lib/server/trace/viewer/traceParser.js +72 -0
- package/lib/server/trace/viewer/traceViewer.js +245 -0
- package/lib/server/transport.js +181 -0
- package/lib/server/types.js +28 -0
- package/lib/server/usKeyboardLayout.js +145 -0
- package/lib/server/utils/ascii.js +44 -0
- package/lib/server/utils/comparators.js +139 -0
- package/lib/server/utils/crypto.js +216 -0
- package/lib/server/utils/debug.js +42 -0
- package/lib/server/utils/debugLogger.js +122 -0
- package/lib/server/utils/env.js +73 -0
- package/lib/server/utils/eventsHelper.js +39 -0
- package/lib/server/utils/expectUtils.js +123 -0
- package/lib/server/utils/fileUtils.js +191 -0
- package/lib/server/utils/happyEyeballs.js +207 -0
- package/lib/server/utils/hostPlatform.js +123 -0
- package/lib/server/utils/httpServer.js +203 -0
- package/lib/server/utils/imageUtils.js +141 -0
- package/lib/server/utils/image_tools/colorUtils.js +89 -0
- package/lib/server/utils/image_tools/compare.js +109 -0
- package/lib/server/utils/image_tools/imageChannel.js +78 -0
- package/lib/server/utils/image_tools/stats.js +102 -0
- package/lib/server/utils/linuxUtils.js +71 -0
- package/lib/server/utils/network.js +242 -0
- package/lib/server/utils/nodePlatform.js +154 -0
- package/lib/server/utils/pipeTransport.js +84 -0
- package/lib/server/utils/processLauncher.js +241 -0
- package/lib/server/utils/profiler.js +65 -0
- package/lib/server/utils/socksProxy.js +511 -0
- package/lib/server/utils/spawnAsync.js +41 -0
- package/lib/server/utils/task.js +51 -0
- package/lib/server/utils/userAgent.js +98 -0
- package/lib/server/utils/wsServer.js +121 -0
- package/lib/server/utils/zipFile.js +74 -0
- package/lib/server/utils/zones.js +57 -0
- package/lib/server/videoRecorder.js +124 -0
- package/lib/server/webkit/protocol.d.js +16 -0
- package/lib/server/webkit/webkit.js +108 -0
- package/lib/server/webkit/wkBrowser.js +335 -0
- package/lib/server/webkit/wkConnection.js +144 -0
- package/lib/server/webkit/wkExecutionContext.js +154 -0
- package/lib/server/webkit/wkInput.js +181 -0
- package/lib/server/webkit/wkInterceptableRequest.js +197 -0
- package/lib/server/webkit/wkPage.js +1158 -0
- package/lib/server/webkit/wkProvisionalPage.js +83 -0
- package/lib/server/webkit/wkWorkers.js +105 -0
- package/lib/third_party/pixelmatch.js +255 -0
- package/lib/utils/isomorphic/ariaSnapshot.js +455 -0
- package/lib/utils/isomorphic/assert.js +31 -0
- package/lib/utils/isomorphic/colors.js +72 -0
- package/lib/utils/isomorphic/cssParser.js +245 -0
- package/lib/utils/isomorphic/cssTokenizer.js +1051 -0
- package/lib/utils/isomorphic/headers.js +53 -0
- package/lib/utils/isomorphic/locatorGenerators.js +689 -0
- package/lib/utils/isomorphic/locatorParser.js +176 -0
- package/lib/utils/isomorphic/locatorUtils.js +81 -0
- package/lib/utils/isomorphic/lruCache.js +51 -0
- package/lib/utils/isomorphic/manualPromise.js +114 -0
- package/lib/utils/isomorphic/mimeType.js +459 -0
- package/lib/utils/isomorphic/multimap.js +80 -0
- package/lib/utils/isomorphic/protocolFormatter.js +81 -0
- package/lib/utils/isomorphic/protocolMetainfo.js +330 -0
- package/lib/utils/isomorphic/rtti.js +43 -0
- package/lib/utils/isomorphic/selectorParser.js +386 -0
- package/lib/utils/isomorphic/semaphore.js +54 -0
- package/lib/utils/isomorphic/stackTrace.js +158 -0
- package/lib/utils/isomorphic/stringUtils.js +204 -0
- package/lib/utils/isomorphic/time.js +49 -0
- package/lib/utils/isomorphic/timeoutRunner.js +66 -0
- package/lib/utils/isomorphic/trace/entries.js +16 -0
- package/lib/utils/isomorphic/trace/snapshotRenderer.js +499 -0
- package/lib/utils/isomorphic/trace/snapshotServer.js +120 -0
- package/lib/utils/isomorphic/trace/snapshotStorage.js +89 -0
- package/lib/utils/isomorphic/trace/traceLoader.js +131 -0
- package/lib/utils/isomorphic/trace/traceModel.js +365 -0
- package/lib/utils/isomorphic/trace/traceModernizer.js +400 -0
- package/lib/utils/isomorphic/trace/versions/traceV3.js +16 -0
- package/lib/utils/isomorphic/trace/versions/traceV4.js +16 -0
- package/lib/utils/isomorphic/trace/versions/traceV5.js +16 -0
- package/lib/utils/isomorphic/trace/versions/traceV6.js +16 -0
- package/lib/utils/isomorphic/trace/versions/traceV7.js +16 -0
- package/lib/utils/isomorphic/trace/versions/traceV8.js +16 -0
- package/lib/utils/isomorphic/traceUtils.js +58 -0
- package/lib/utils/isomorphic/types.js +16 -0
- package/lib/utils/isomorphic/urlMatch.js +190 -0
- package/lib/utils/isomorphic/utilityScriptSerializers.js +251 -0
- package/lib/utils/isomorphic/yaml.js +84 -0
- package/lib/utils.js +111 -0
- package/lib/utilsBundle.js +109 -0
- package/lib/utilsBundleImpl/index.js +218 -0
- package/lib/utilsBundleImpl/xdg-open +1066 -0
- package/lib/vite/htmlReport/index.html +84 -0
- package/lib/vite/recorder/assets/codeMirrorModule-DYBRYzYX.css +1 -0
- package/lib/vite/recorder/assets/codeMirrorModule-DadYNm1I.js +32 -0
- package/lib/vite/recorder/assets/codicon-DCmgc-ay.ttf +0 -0
- package/lib/vite/recorder/assets/index-BSjZa4pk.css +1 -0
- package/lib/vite/recorder/assets/index-BhTWtUlo.js +193 -0
- package/lib/vite/recorder/index.html +29 -0
- package/lib/vite/recorder/playwright-logo.svg +9 -0
- package/lib/vite/traceViewer/assets/codeMirrorModule-DwzBH9eL.js +32 -0
- package/lib/vite/traceViewer/assets/codeMirrorModule-a5XoALAZ.js +32 -0
- package/lib/vite/traceViewer/assets/defaultSettingsView-CJSZINFr.js +266 -0
- package/lib/vite/traceViewer/assets/defaultSettingsView-CdCX8877.js +266 -0
- package/lib/vite/traceViewer/assets/xtermModule-CsJ4vdCR.js +9 -0
- package/lib/vite/traceViewer/codeMirrorModule.DYBRYzYX.css +1 -0
- package/lib/vite/traceViewer/codicon.DCmgc-ay.ttf +0 -0
- package/lib/vite/traceViewer/defaultSettingsView.7ch9cixO.css +1 -0
- package/lib/vite/traceViewer/index.BVu7tZDe.css +1 -0
- package/lib/vite/traceViewer/index.Dd9jebqr.js +2 -0
- package/lib/vite/traceViewer/index.f4OcrOqs.js +2 -0
- package/lib/vite/traceViewer/index.html +43 -0
- package/lib/vite/traceViewer/manifest.webmanifest +16 -0
- package/lib/vite/traceViewer/playwright-logo.svg +9 -0
- package/lib/vite/traceViewer/snapshot.html +21 -0
- package/lib/vite/traceViewer/sw.bundle.js +5 -0
- package/lib/vite/traceViewer/uiMode.Btcz36p_.css +1 -0
- package/lib/vite/traceViewer/uiMode.CQJ9SCIQ.js +5 -0
- package/lib/vite/traceViewer/uiMode.html +17 -0
- package/lib/vite/traceViewer/uiMode.qcahlSup.js +5 -0
- package/lib/vite/traceViewer/xtermModule.DYP7pi_n.css +32 -0
- package/lib/zipBundle.js +34 -0
- package/lib/zipBundleImpl.js +5 -0
- package/package.json +43 -0
- package/types/protocol.d.ts +23824 -0
- package/types/structs.d.ts +45 -0
- package/types/types.d.ts +22843 -0
|
@@ -0,0 +1,679 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var traceExporter_exports = {};
|
|
30
|
+
__export(traceExporter_exports, {
|
|
31
|
+
exportTraceToMarkdown: () => exportTraceToMarkdown
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(traceExporter_exports);
|
|
34
|
+
var import_fs = __toESM(require("fs"));
|
|
35
|
+
var import_path = __toESM(require("path"));
|
|
36
|
+
var import_zipFile = require("../../utils/zipFile");
|
|
37
|
+
async function exportTraceToMarkdown(traceFile, options) {
|
|
38
|
+
const context = await parseTrace(traceFile);
|
|
39
|
+
const outputDir = options.outputDir;
|
|
40
|
+
const assetsDir = import_path.default.join(outputDir, "assets");
|
|
41
|
+
const screenshotsDir = import_path.default.join(assetsDir, "screenshots");
|
|
42
|
+
const snapshotsDir = import_path.default.join(assetsDir, "snapshots");
|
|
43
|
+
await import_fs.default.promises.mkdir(outputDir, { recursive: true });
|
|
44
|
+
let assetMap = /* @__PURE__ */ new Map();
|
|
45
|
+
if (options.includeAssets) {
|
|
46
|
+
await import_fs.default.promises.mkdir(screenshotsDir, { recursive: true });
|
|
47
|
+
await import_fs.default.promises.mkdir(snapshotsDir, { recursive: true });
|
|
48
|
+
assetMap = await extractAssets(traceFile, context, outputDir);
|
|
49
|
+
}
|
|
50
|
+
const files = [
|
|
51
|
+
{ name: "index.md", content: generateIndexMarkdown(context, traceFile) },
|
|
52
|
+
{ name: "metadata.md", content: generateMetadataMarkdown(context) },
|
|
53
|
+
{ name: "timeline.md", content: generateTimelineMarkdown(context.actions, assetMap) },
|
|
54
|
+
{ name: "errors.md", content: generateErrorsMarkdown(context.errors, context.actions) },
|
|
55
|
+
{ name: "console.md", content: generateConsoleMarkdown(context.events) },
|
|
56
|
+
{ name: "network.md", content: generateNetworkMarkdown(context.resources) }
|
|
57
|
+
];
|
|
58
|
+
for (const file of files)
|
|
59
|
+
await import_fs.default.promises.writeFile(import_path.default.join(outputDir, file.name), file.content);
|
|
60
|
+
}
|
|
61
|
+
async function parseTrace(traceFile) {
|
|
62
|
+
const zipFile = new import_zipFile.ZipFile(traceFile);
|
|
63
|
+
const entries = await zipFile.entries();
|
|
64
|
+
const context = {
|
|
65
|
+
browserName: "Unknown",
|
|
66
|
+
wallTime: 0,
|
|
67
|
+
startTime: Number.MAX_SAFE_INTEGER,
|
|
68
|
+
endTime: 0,
|
|
69
|
+
options: {},
|
|
70
|
+
actions: [],
|
|
71
|
+
events: [],
|
|
72
|
+
errors: [],
|
|
73
|
+
resources: [],
|
|
74
|
+
pages: [],
|
|
75
|
+
snapshots: []
|
|
76
|
+
};
|
|
77
|
+
const actionMap = /* @__PURE__ */ new Map();
|
|
78
|
+
const pageMap = /* @__PURE__ */ new Map();
|
|
79
|
+
const traceEntries = entries.filter((name) => name.endsWith(".trace"));
|
|
80
|
+
const networkEntries = entries.filter((name) => name.endsWith(".network"));
|
|
81
|
+
for (const entryName of [...traceEntries, ...networkEntries]) {
|
|
82
|
+
const content = await zipFile.read(entryName);
|
|
83
|
+
const lines = content.toString("utf-8").split("\n");
|
|
84
|
+
for (const line of lines) {
|
|
85
|
+
if (!line.trim())
|
|
86
|
+
continue;
|
|
87
|
+
try {
|
|
88
|
+
const event = JSON.parse(line);
|
|
89
|
+
processTraceEvent(event, context, actionMap, pageMap);
|
|
90
|
+
} catch {
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
context.actions = [...actionMap.values()].sort((a, b) => a.startTime - b.startTime);
|
|
95
|
+
context.pages = [...pageMap.values()];
|
|
96
|
+
for (const action of context.actions) {
|
|
97
|
+
if (action.endTime > context.endTime)
|
|
98
|
+
context.endTime = action.endTime;
|
|
99
|
+
}
|
|
100
|
+
zipFile.close();
|
|
101
|
+
return context;
|
|
102
|
+
}
|
|
103
|
+
function processTraceEvent(event, context, actionMap, pageMap) {
|
|
104
|
+
switch (event.type) {
|
|
105
|
+
case "context-options":
|
|
106
|
+
context.browserName = event.browserName || "Unknown";
|
|
107
|
+
context.channel = event.channel;
|
|
108
|
+
context.title = event.title;
|
|
109
|
+
context.platform = event.platform;
|
|
110
|
+
context.playwrightVersion = event.playwrightVersion;
|
|
111
|
+
context.wallTime = event.wallTime || 0;
|
|
112
|
+
context.startTime = event.monotonicTime || 0;
|
|
113
|
+
context.sdkLanguage = event.sdkLanguage;
|
|
114
|
+
context.options = event.options || {};
|
|
115
|
+
break;
|
|
116
|
+
case "before":
|
|
117
|
+
actionMap.set(event.callId, {
|
|
118
|
+
callId: event.callId,
|
|
119
|
+
class: event.class,
|
|
120
|
+
method: event.method,
|
|
121
|
+
params: event.params || {},
|
|
122
|
+
startTime: event.startTime || 0,
|
|
123
|
+
endTime: 0,
|
|
124
|
+
log: [],
|
|
125
|
+
stack: event.stack,
|
|
126
|
+
beforeSnapshot: event.beforeSnapshot,
|
|
127
|
+
pageId: event.pageId
|
|
128
|
+
});
|
|
129
|
+
break;
|
|
130
|
+
case "after":
|
|
131
|
+
const action = actionMap.get(event.callId);
|
|
132
|
+
if (action) {
|
|
133
|
+
action.endTime = event.endTime || action.startTime;
|
|
134
|
+
action.error = event.error;
|
|
135
|
+
action.result = event.result;
|
|
136
|
+
action.afterSnapshot = event.afterSnapshot;
|
|
137
|
+
}
|
|
138
|
+
break;
|
|
139
|
+
case "log":
|
|
140
|
+
const logAction = actionMap.get(event.callId);
|
|
141
|
+
if (logAction) {
|
|
142
|
+
logAction.log.push({
|
|
143
|
+
time: event.time || 0,
|
|
144
|
+
message: event.message || ""
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
break;
|
|
148
|
+
case "console":
|
|
149
|
+
context.events.push({
|
|
150
|
+
type: "console",
|
|
151
|
+
time: event.time || 0,
|
|
152
|
+
messageType: event.messageType,
|
|
153
|
+
text: event.text,
|
|
154
|
+
location: event.location
|
|
155
|
+
});
|
|
156
|
+
break;
|
|
157
|
+
case "error":
|
|
158
|
+
context.errors.push({
|
|
159
|
+
message: event.message || "Unknown error",
|
|
160
|
+
stack: event.stack
|
|
161
|
+
});
|
|
162
|
+
break;
|
|
163
|
+
case "resource-snapshot":
|
|
164
|
+
if (event.snapshot) {
|
|
165
|
+
context.resources.push({
|
|
166
|
+
request: {
|
|
167
|
+
method: event.snapshot.request?.method || "GET",
|
|
168
|
+
url: event.snapshot.request?.url || ""
|
|
169
|
+
},
|
|
170
|
+
response: {
|
|
171
|
+
status: event.snapshot.response?.status || 0,
|
|
172
|
+
content: event.snapshot.response?.content,
|
|
173
|
+
_failureText: event.snapshot.response?._failureText
|
|
174
|
+
}
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
break;
|
|
178
|
+
case "screencast-frame":
|
|
179
|
+
let page = pageMap.get(event.pageId);
|
|
180
|
+
if (!page) {
|
|
181
|
+
page = { pageId: event.pageId, screencastFrames: [] };
|
|
182
|
+
pageMap.set(event.pageId, page);
|
|
183
|
+
}
|
|
184
|
+
page.screencastFrames.push({
|
|
185
|
+
sha1: event.sha1,
|
|
186
|
+
timestamp: event.timestamp || 0
|
|
187
|
+
});
|
|
188
|
+
break;
|
|
189
|
+
case "frame-snapshot":
|
|
190
|
+
if (event.snapshot) {
|
|
191
|
+
context.snapshots.push({
|
|
192
|
+
snapshotName: event.snapshot.snapshotName || "",
|
|
193
|
+
callId: event.snapshot.callId || "",
|
|
194
|
+
pageId: event.snapshot.pageId || "",
|
|
195
|
+
frameId: event.snapshot.frameId || "",
|
|
196
|
+
frameUrl: event.snapshot.frameUrl || "",
|
|
197
|
+
html: event.snapshot.html,
|
|
198
|
+
timestamp: event.snapshot.timestamp || 0
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
break;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
async function extractAssets(traceFile, context, outputDir) {
|
|
205
|
+
const assetMap = /* @__PURE__ */ new Map();
|
|
206
|
+
const zipFile = new import_zipFile.ZipFile(traceFile);
|
|
207
|
+
const entries = await zipFile.entries();
|
|
208
|
+
const screenshotSha1s = /* @__PURE__ */ new Set();
|
|
209
|
+
for (const page of context.pages) {
|
|
210
|
+
for (const frame of page.screencastFrames)
|
|
211
|
+
screenshotSha1s.add(frame.sha1);
|
|
212
|
+
}
|
|
213
|
+
for (const sha1 of screenshotSha1s) {
|
|
214
|
+
const resourcePath = `resources/${sha1}`;
|
|
215
|
+
if (entries.includes(resourcePath)) {
|
|
216
|
+
try {
|
|
217
|
+
const buffer = await zipFile.read(resourcePath);
|
|
218
|
+
const ext = sha1.includes(".") ? "" : ".png";
|
|
219
|
+
const relativePath = `assets/screenshots/${sha1}${ext}`;
|
|
220
|
+
const fullPath = import_path.default.join(outputDir, relativePath);
|
|
221
|
+
await import_fs.default.promises.writeFile(fullPath, buffer);
|
|
222
|
+
assetMap.set(sha1, `./${relativePath}`);
|
|
223
|
+
} catch {
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
const resourceEntries = entries.filter((name) => name.startsWith("resources/") && !screenshotSha1s.has(name.replace("resources/", "")));
|
|
228
|
+
for (const entryName of resourceEntries) {
|
|
229
|
+
const sha1 = entryName.replace("resources/", "");
|
|
230
|
+
try {
|
|
231
|
+
const buffer = await zipFile.read(entryName);
|
|
232
|
+
const text = buffer.toString("utf-8");
|
|
233
|
+
if (text.startsWith("<!") || text.startsWith("<html") || text.includes("<head") || text.includes("<body")) {
|
|
234
|
+
const ext = sha1.endsWith(".html") ? "" : ".html";
|
|
235
|
+
const relativePath = `assets/snapshots/${sha1}${ext}`;
|
|
236
|
+
const fullPath = import_path.default.join(outputDir, relativePath);
|
|
237
|
+
await import_fs.default.promises.writeFile(fullPath, text);
|
|
238
|
+
assetMap.set(sha1, `./${relativePath}`);
|
|
239
|
+
}
|
|
240
|
+
} catch {
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
for (const snapshot of context.snapshots) {
|
|
244
|
+
if (snapshot.html && snapshot.snapshotName) {
|
|
245
|
+
try {
|
|
246
|
+
const html = renderSnapshotToHtml(snapshot);
|
|
247
|
+
const safeName = snapshot.snapshotName.replace(/[^a-zA-Z0-9@_-]/g, "_");
|
|
248
|
+
const relativePath = `assets/snapshots/${safeName}.html`;
|
|
249
|
+
const fullPath = import_path.default.join(outputDir, relativePath);
|
|
250
|
+
await import_fs.default.promises.writeFile(fullPath, html);
|
|
251
|
+
assetMap.set(snapshot.snapshotName, `./${relativePath}`);
|
|
252
|
+
} catch {
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
zipFile.close();
|
|
257
|
+
return assetMap;
|
|
258
|
+
}
|
|
259
|
+
function generateIndexMarkdown(context, traceFile) {
|
|
260
|
+
const title = context.title || "Trace Export";
|
|
261
|
+
const duration = context.endTime - context.startTime;
|
|
262
|
+
const actionCount = context.actions.length;
|
|
263
|
+
const errorCount = context.errors.length + context.actions.filter((a) => a.error).length;
|
|
264
|
+
const hasErrors = errorCount > 0;
|
|
265
|
+
const errorSummary = collectErrorSummary(context);
|
|
266
|
+
let md = `# Trace Export: ${title}
|
|
267
|
+
|
|
268
|
+
`;
|
|
269
|
+
md += `**Test:** \`${title}\`
|
|
270
|
+
`;
|
|
271
|
+
md += `**Source:** \`${traceFile}\`
|
|
272
|
+
|
|
273
|
+
`;
|
|
274
|
+
md += `**Status:** ${hasErrors ? "FAILED" : "PASSED"} | **Duration:** ${duration}ms | **Actions:** ${actionCount} | **Errors:** ${errorCount}
|
|
275
|
+
|
|
276
|
+
`;
|
|
277
|
+
if (errorSummary.length > 0) {
|
|
278
|
+
md += `## Error Summary
|
|
279
|
+
`;
|
|
280
|
+
for (const error of errorSummary)
|
|
281
|
+
md += `- ${error}
|
|
282
|
+
`;
|
|
283
|
+
md += "\n";
|
|
284
|
+
}
|
|
285
|
+
md += `## Sections
|
|
286
|
+
`;
|
|
287
|
+
md += `- [Timeline](./timeline.md) - Step-by-step action timeline
|
|
288
|
+
`;
|
|
289
|
+
md += `- [Metadata](./metadata.md) - Browser/environment info
|
|
290
|
+
`;
|
|
291
|
+
md += `- [Errors](./errors.md) - Full error details with stack traces
|
|
292
|
+
`;
|
|
293
|
+
md += `- [Console](./console.md) - Browser console output
|
|
294
|
+
`;
|
|
295
|
+
md += `- [Network](./network.md) - HTTP request log
|
|
296
|
+
`;
|
|
297
|
+
return md;
|
|
298
|
+
}
|
|
299
|
+
function collectErrorSummary(context) {
|
|
300
|
+
const errors = [];
|
|
301
|
+
for (const error of context.errors)
|
|
302
|
+
errors.push(truncateString(error.message, 100));
|
|
303
|
+
for (const action of context.actions) {
|
|
304
|
+
if (action.error)
|
|
305
|
+
errors.push(truncateString(action.error.message, 100));
|
|
306
|
+
}
|
|
307
|
+
return errors.slice(0, 10);
|
|
308
|
+
}
|
|
309
|
+
function generateMetadataMarkdown(context) {
|
|
310
|
+
let md = `# Trace Metadata
|
|
311
|
+
|
|
312
|
+
`;
|
|
313
|
+
md += `## Environment
|
|
314
|
+
|
|
315
|
+
`;
|
|
316
|
+
md += `| Property | Value |
|
|
317
|
+
`;
|
|
318
|
+
md += `|----------|-------|
|
|
319
|
+
`;
|
|
320
|
+
md += `| Browser | ${context.browserName || "Unknown"} |
|
|
321
|
+
`;
|
|
322
|
+
if (context.channel)
|
|
323
|
+
md += `| Channel | ${context.channel} |
|
|
324
|
+
`;
|
|
325
|
+
if (context.platform)
|
|
326
|
+
md += `| Platform | ${context.platform} |
|
|
327
|
+
`;
|
|
328
|
+
if (context.playwrightVersion)
|
|
329
|
+
md += `| Playwright Version | ${context.playwrightVersion} |
|
|
330
|
+
`;
|
|
331
|
+
if (context.sdkLanguage)
|
|
332
|
+
md += `| SDK Language | ${context.sdkLanguage} |
|
|
333
|
+
`;
|
|
334
|
+
md += `
|
|
335
|
+
## Context Options
|
|
336
|
+
|
|
337
|
+
`;
|
|
338
|
+
md += `| Property | Value |
|
|
339
|
+
`;
|
|
340
|
+
md += `|----------|-------|
|
|
341
|
+
`;
|
|
342
|
+
if (context.options.viewport)
|
|
343
|
+
md += `| Viewport | ${context.options.viewport.width}x${context.options.viewport.height} |
|
|
344
|
+
`;
|
|
345
|
+
if (context.options.deviceScaleFactor)
|
|
346
|
+
md += `| Device Scale Factor | ${context.options.deviceScaleFactor} |
|
|
347
|
+
`;
|
|
348
|
+
if (context.options.isMobile !== void 0)
|
|
349
|
+
md += `| Mobile | ${context.options.isMobile} |
|
|
350
|
+
`;
|
|
351
|
+
if (context.options.userAgent)
|
|
352
|
+
md += `| User Agent | ${truncateString(context.options.userAgent, 80)} |
|
|
353
|
+
`;
|
|
354
|
+
if (context.options.baseURL)
|
|
355
|
+
md += `| Base URL | ${context.options.baseURL} |
|
|
356
|
+
`;
|
|
357
|
+
md += `
|
|
358
|
+
## Timing
|
|
359
|
+
|
|
360
|
+
`;
|
|
361
|
+
md += `| Property | Value |
|
|
362
|
+
`;
|
|
363
|
+
md += `|----------|-------|
|
|
364
|
+
`;
|
|
365
|
+
md += `| Wall Time | ${new Date(context.wallTime).toISOString()} |
|
|
366
|
+
`;
|
|
367
|
+
md += `| Duration | ${context.endTime - context.startTime}ms |
|
|
368
|
+
`;
|
|
369
|
+
return md;
|
|
370
|
+
}
|
|
371
|
+
function generateTimelineMarkdown(actions, assetMap) {
|
|
372
|
+
if (actions.length === 0)
|
|
373
|
+
return `# Actions Timeline
|
|
374
|
+
|
|
375
|
+
No actions recorded.
|
|
376
|
+
`;
|
|
377
|
+
const startTime = actions[0]?.startTime || 0;
|
|
378
|
+
const totalDuration = actions.length > 0 ? (actions[actions.length - 1].endTime || actions[actions.length - 1].startTime) - startTime : 0;
|
|
379
|
+
let md = `# Actions Timeline
|
|
380
|
+
|
|
381
|
+
`;
|
|
382
|
+
md += `Total actions: ${actions.length} | Duration: ${totalDuration}ms
|
|
383
|
+
|
|
384
|
+
`;
|
|
385
|
+
md += `---
|
|
386
|
+
|
|
387
|
+
`;
|
|
388
|
+
for (let i = 0; i < actions.length; i++) {
|
|
389
|
+
const action = actions[i];
|
|
390
|
+
const relativeTime = action.startTime - startTime;
|
|
391
|
+
const duration = (action.endTime || action.startTime) - action.startTime;
|
|
392
|
+
const hasError = !!action.error;
|
|
393
|
+
md += `## ${i + 1}. [${relativeTime}ms] ${action.class}.${action.method}${hasError ? " - ERROR" : ""}
|
|
394
|
+
|
|
395
|
+
`;
|
|
396
|
+
if (action.params && Object.keys(action.params).length > 0) {
|
|
397
|
+
const paramsStr = formatParams(action.params);
|
|
398
|
+
md += `- **Params:** \`${paramsStr}\`
|
|
399
|
+
`;
|
|
400
|
+
}
|
|
401
|
+
if (hasError)
|
|
402
|
+
md += `- **Error:** ${action.error.message}
|
|
403
|
+
`;
|
|
404
|
+
else if (action.result !== void 0)
|
|
405
|
+
md += `- **Result:** ${formatResult(action.result)}
|
|
406
|
+
`;
|
|
407
|
+
else
|
|
408
|
+
md += `- **Result:** Success
|
|
409
|
+
`;
|
|
410
|
+
md += `- **Duration:** ${duration}ms
|
|
411
|
+
`;
|
|
412
|
+
if (action.stack && action.stack.length > 0) {
|
|
413
|
+
const frame = action.stack[0];
|
|
414
|
+
md += `- **Source:** \`${frame.file}:${frame.line}\`
|
|
415
|
+
`;
|
|
416
|
+
}
|
|
417
|
+
const beforeSnapshot = action.beforeSnapshot ? resolveSnapshotLink(action.beforeSnapshot, assetMap) : null;
|
|
418
|
+
const afterSnapshot = action.afterSnapshot ? resolveSnapshotLink(action.afterSnapshot, assetMap) : null;
|
|
419
|
+
if (beforeSnapshot || afterSnapshot) {
|
|
420
|
+
const links = [];
|
|
421
|
+
if (beforeSnapshot)
|
|
422
|
+
links.push(`[before](${beforeSnapshot})`);
|
|
423
|
+
if (afterSnapshot)
|
|
424
|
+
links.push(`[after](${afterSnapshot})`);
|
|
425
|
+
md += `- **Snapshots:** ${links.join(" | ")}
|
|
426
|
+
`;
|
|
427
|
+
}
|
|
428
|
+
if (action.log && action.log.length > 0) {
|
|
429
|
+
md += `
|
|
430
|
+
<details><summary>Action Log</summary>
|
|
431
|
+
|
|
432
|
+
`;
|
|
433
|
+
for (const entry of action.log)
|
|
434
|
+
md += `- ${entry.message}
|
|
435
|
+
`;
|
|
436
|
+
md += `
|
|
437
|
+
</details>
|
|
438
|
+
`;
|
|
439
|
+
}
|
|
440
|
+
if (hasError && action.stack && action.stack.length > 0) {
|
|
441
|
+
md += `
|
|
442
|
+
<details><summary>Stack Trace</summary>
|
|
443
|
+
|
|
444
|
+
`;
|
|
445
|
+
md += "```\n";
|
|
446
|
+
md += `Error: ${action.error.message}
|
|
447
|
+
`;
|
|
448
|
+
for (const frame of action.stack)
|
|
449
|
+
md += ` at ${frame.function || "(anonymous)"} (${frame.file}:${frame.line}:${frame.column})
|
|
450
|
+
`;
|
|
451
|
+
md += "```\n\n";
|
|
452
|
+
md += `</details>
|
|
453
|
+
`;
|
|
454
|
+
}
|
|
455
|
+
md += `
|
|
456
|
+
---
|
|
457
|
+
|
|
458
|
+
`;
|
|
459
|
+
}
|
|
460
|
+
return md;
|
|
461
|
+
}
|
|
462
|
+
function resolveSnapshotLink(snapshotName, assetMap) {
|
|
463
|
+
if (assetMap.has(snapshotName))
|
|
464
|
+
return assetMap.get(snapshotName);
|
|
465
|
+
for (const [key, assetPath] of assetMap) {
|
|
466
|
+
if (snapshotName.includes(key) || key.includes(snapshotName))
|
|
467
|
+
return assetPath;
|
|
468
|
+
}
|
|
469
|
+
return null;
|
|
470
|
+
}
|
|
471
|
+
function generateErrorsMarkdown(errors, actions) {
|
|
472
|
+
const allErrors = [];
|
|
473
|
+
for (const error of errors) {
|
|
474
|
+
allErrors.push({
|
|
475
|
+
message: error.message,
|
|
476
|
+
stack: error.stack
|
|
477
|
+
});
|
|
478
|
+
}
|
|
479
|
+
for (const action of actions) {
|
|
480
|
+
if (action.error) {
|
|
481
|
+
allErrors.push({
|
|
482
|
+
message: action.error.message,
|
|
483
|
+
stack: action.stack,
|
|
484
|
+
source: action.stack?.[0] ? `${action.stack[0].file}:${action.stack[0].line}` : void 0
|
|
485
|
+
});
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
if (allErrors.length === 0)
|
|
489
|
+
return `# Errors
|
|
490
|
+
|
|
491
|
+
No errors recorded.
|
|
492
|
+
`;
|
|
493
|
+
let md = `# Errors
|
|
494
|
+
|
|
495
|
+
`;
|
|
496
|
+
md += `Total errors: ${allErrors.length}
|
|
497
|
+
|
|
498
|
+
`;
|
|
499
|
+
for (let i = 0; i < allErrors.length; i++) {
|
|
500
|
+
const error = allErrors[i];
|
|
501
|
+
md += `## Error ${i + 1}
|
|
502
|
+
|
|
503
|
+
`;
|
|
504
|
+
md += `**Message:** ${error.message}
|
|
505
|
+
|
|
506
|
+
`;
|
|
507
|
+
if (error.source)
|
|
508
|
+
md += `**Source:** \`${error.source}\`
|
|
509
|
+
|
|
510
|
+
`;
|
|
511
|
+
if (error.stack && error.stack.length > 0) {
|
|
512
|
+
md += `**Stack Trace:**
|
|
513
|
+
|
|
514
|
+
`;
|
|
515
|
+
md += "```\n";
|
|
516
|
+
for (const frame of error.stack)
|
|
517
|
+
md += ` at ${frame.function || "(anonymous)"} (${frame.file}:${frame.line}:${frame.column})
|
|
518
|
+
`;
|
|
519
|
+
md += "```\n\n";
|
|
520
|
+
}
|
|
521
|
+
md += `---
|
|
522
|
+
|
|
523
|
+
`;
|
|
524
|
+
}
|
|
525
|
+
return md;
|
|
526
|
+
}
|
|
527
|
+
function generateConsoleMarkdown(events) {
|
|
528
|
+
const consoleEvents = events.filter((e) => e.type === "console");
|
|
529
|
+
if (consoleEvents.length === 0)
|
|
530
|
+
return `# Console Log
|
|
531
|
+
|
|
532
|
+
No console messages recorded.
|
|
533
|
+
`;
|
|
534
|
+
let md = `# Console Log
|
|
535
|
+
|
|
536
|
+
`;
|
|
537
|
+
md += `Total messages: ${consoleEvents.length}
|
|
538
|
+
|
|
539
|
+
`;
|
|
540
|
+
md += `| Time | Type | Message | Location |
|
|
541
|
+
`;
|
|
542
|
+
md += `|------|------|---------|----------|
|
|
543
|
+
`;
|
|
544
|
+
for (const event of consoleEvents) {
|
|
545
|
+
const message = truncateString(event.text || "", 100).replace(/\|/g, "\\|").replace(/\n/g, " ");
|
|
546
|
+
const location = event.location ? `${event.location.url}:${event.location.lineNumber}` : "";
|
|
547
|
+
md += `| ${event.time}ms | ${event.messageType || "log"} | ${message} | ${truncateString(location, 50)} |
|
|
548
|
+
`;
|
|
549
|
+
}
|
|
550
|
+
return md;
|
|
551
|
+
}
|
|
552
|
+
function generateNetworkMarkdown(resources) {
|
|
553
|
+
if (resources.length === 0)
|
|
554
|
+
return `# Network Log
|
|
555
|
+
|
|
556
|
+
No network requests recorded.
|
|
557
|
+
`;
|
|
558
|
+
let md = `# Network Log
|
|
559
|
+
|
|
560
|
+
`;
|
|
561
|
+
md += `Total requests: ${resources.length}
|
|
562
|
+
|
|
563
|
+
`;
|
|
564
|
+
md += `| # | Method | URL | Status | Size |
|
|
565
|
+
`;
|
|
566
|
+
md += `|---|--------|-----|--------|------|
|
|
567
|
+
`;
|
|
568
|
+
const failedRequests = [];
|
|
569
|
+
for (let i = 0; i < resources.length; i++) {
|
|
570
|
+
const resource = resources[i];
|
|
571
|
+
const url = truncateString(resource.request.url, 60);
|
|
572
|
+
const status = resource.response.status;
|
|
573
|
+
const size = formatSize(resource.response.content?.size || 0);
|
|
574
|
+
md += `| ${i + 1} | ${resource.request.method} | ${url} | ${status} | ${size} |
|
|
575
|
+
`;
|
|
576
|
+
if (status >= 400)
|
|
577
|
+
failedRequests.push(resource);
|
|
578
|
+
}
|
|
579
|
+
if (failedRequests.length > 0) {
|
|
580
|
+
md += `
|
|
581
|
+
## Failed Requests
|
|
582
|
+
|
|
583
|
+
`;
|
|
584
|
+
for (const resource of failedRequests) {
|
|
585
|
+
md += `### ${resource.request.method} ${truncateString(resource.request.url, 80)} - ${resource.response.status}
|
|
586
|
+
|
|
587
|
+
`;
|
|
588
|
+
if (resource.response._failureText)
|
|
589
|
+
md += `**Failure:** ${resource.response._failureText}
|
|
590
|
+
|
|
591
|
+
`;
|
|
592
|
+
if (resource.response.content?.text) {
|
|
593
|
+
md += `<details><summary>Response</summary>
|
|
594
|
+
|
|
595
|
+
`;
|
|
596
|
+
md += "```\n";
|
|
597
|
+
md += truncateString(resource.response.content.text, 1e3);
|
|
598
|
+
md += "\n```\n\n";
|
|
599
|
+
md += `</details>
|
|
600
|
+
|
|
601
|
+
`;
|
|
602
|
+
}
|
|
603
|
+
}
|
|
604
|
+
}
|
|
605
|
+
return md;
|
|
606
|
+
}
|
|
607
|
+
function renderSnapshotToHtml(snapshot) {
|
|
608
|
+
const parts = [];
|
|
609
|
+
parts.push("<!DOCTYPE html>");
|
|
610
|
+
parts.push(`<!-- Playwright Snapshot: ${snapshot.snapshotName} -->`);
|
|
611
|
+
parts.push(`<!-- URL: ${snapshot.frameUrl} -->`);
|
|
612
|
+
parts.push(`<!-- Timestamp: ${snapshot.timestamp} -->`);
|
|
613
|
+
renderNode(snapshot.html, parts);
|
|
614
|
+
return parts.join("");
|
|
615
|
+
}
|
|
616
|
+
function renderNode(node, parts) {
|
|
617
|
+
if (typeof node === "string") {
|
|
618
|
+
parts.push(escapeHtml(node));
|
|
619
|
+
return;
|
|
620
|
+
}
|
|
621
|
+
if (!Array.isArray(node))
|
|
622
|
+
return;
|
|
623
|
+
if (Array.isArray(node[0]))
|
|
624
|
+
return;
|
|
625
|
+
const [tagName, ...rest] = node;
|
|
626
|
+
if (typeof tagName !== "string")
|
|
627
|
+
return;
|
|
628
|
+
let attrs = {};
|
|
629
|
+
let children = [];
|
|
630
|
+
if (rest.length > 0 && typeof rest[0] === "object" && !Array.isArray(rest[0])) {
|
|
631
|
+
attrs = rest[0] || {};
|
|
632
|
+
children = rest.slice(1);
|
|
633
|
+
} else {
|
|
634
|
+
children = rest;
|
|
635
|
+
}
|
|
636
|
+
parts.push(`<${tagName.toLowerCase()}`);
|
|
637
|
+
for (const [key, value] of Object.entries(attrs)) {
|
|
638
|
+
if (key.startsWith("__playwright"))
|
|
639
|
+
continue;
|
|
640
|
+
parts.push(` ${key}="${escapeHtml(String(value))}"`);
|
|
641
|
+
}
|
|
642
|
+
parts.push(">");
|
|
643
|
+
for (const child of children)
|
|
644
|
+
renderNode(child, parts);
|
|
645
|
+
const selfClosing = ["area", "base", "br", "col", "embed", "hr", "img", "input", "link", "meta", "param", "source", "track", "wbr"];
|
|
646
|
+
if (!selfClosing.includes(tagName.toLowerCase()))
|
|
647
|
+
parts.push(`</${tagName.toLowerCase()}>`);
|
|
648
|
+
}
|
|
649
|
+
function escapeHtml(text) {
|
|
650
|
+
return text.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
651
|
+
}
|
|
652
|
+
function truncateString(str, maxLength) {
|
|
653
|
+
if (str.length <= maxLength)
|
|
654
|
+
return str;
|
|
655
|
+
return str.substring(0, maxLength - 3) + "...";
|
|
656
|
+
}
|
|
657
|
+
function formatParams(params) {
|
|
658
|
+
const str = JSON.stringify(params);
|
|
659
|
+
return truncateString(str, 200);
|
|
660
|
+
}
|
|
661
|
+
function formatResult(result) {
|
|
662
|
+
if (result === null || result === void 0)
|
|
663
|
+
return "null";
|
|
664
|
+
if (typeof result === "string")
|
|
665
|
+
return truncateString(result, 100);
|
|
666
|
+
const str = JSON.stringify(result);
|
|
667
|
+
return truncateString(str, 100);
|
|
668
|
+
}
|
|
669
|
+
function formatSize(bytes) {
|
|
670
|
+
if (bytes < 1024)
|
|
671
|
+
return `${bytes}B`;
|
|
672
|
+
if (bytes < 1024 * 1024)
|
|
673
|
+
return `${(bytes / 1024).toFixed(1)}KB`;
|
|
674
|
+
return `${(bytes / (1024 * 1024)).toFixed(1)}MB`;
|
|
675
|
+
}
|
|
676
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
677
|
+
0 && (module.exports = {
|
|
678
|
+
exportTraceToMarkdown
|
|
679
|
+
});
|