@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,83 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var wkProvisionalPage_exports = {};
|
|
20
|
+
__export(wkProvisionalPage_exports, {
|
|
21
|
+
WKProvisionalPage: () => WKProvisionalPage
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(wkProvisionalPage_exports);
|
|
24
|
+
var import_utils = require("../../utils");
|
|
25
|
+
var import_eventsHelper = require("../utils/eventsHelper");
|
|
26
|
+
class WKProvisionalPage {
|
|
27
|
+
constructor(session, page) {
|
|
28
|
+
this._sessionListeners = [];
|
|
29
|
+
this._mainFrameId = null;
|
|
30
|
+
this._session = session;
|
|
31
|
+
this._wkPage = page;
|
|
32
|
+
this._coopNavigationRequest = page._page.mainFrame().pendingDocument()?.request;
|
|
33
|
+
const overrideFrameId = (handler) => {
|
|
34
|
+
return (payload) => {
|
|
35
|
+
if (payload.frameId)
|
|
36
|
+
payload.frameId = this._wkPage._page.frameManager.mainFrame()._id;
|
|
37
|
+
handler(payload);
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
const wkPage = this._wkPage;
|
|
41
|
+
this._sessionListeners = [
|
|
42
|
+
import_eventsHelper.eventsHelper.addEventListener(session, "Network.requestWillBeSent", overrideFrameId((e) => this._onRequestWillBeSent(e))),
|
|
43
|
+
import_eventsHelper.eventsHelper.addEventListener(session, "Network.requestIntercepted", overrideFrameId((e) => wkPage._onRequestIntercepted(session, e))),
|
|
44
|
+
import_eventsHelper.eventsHelper.addEventListener(session, "Network.responseReceived", overrideFrameId((e) => wkPage._onResponseReceived(session, e))),
|
|
45
|
+
import_eventsHelper.eventsHelper.addEventListener(session, "Network.loadingFinished", overrideFrameId((e) => this._onLoadingFinished(e))),
|
|
46
|
+
import_eventsHelper.eventsHelper.addEventListener(session, "Network.loadingFailed", overrideFrameId((e) => this._onLoadingFailed(e)))
|
|
47
|
+
];
|
|
48
|
+
this.initializationPromise = this._wkPage._initializeSession(session, true, ({ frameTree }) => this._handleFrameTree(frameTree));
|
|
49
|
+
}
|
|
50
|
+
coopNavigationRequest() {
|
|
51
|
+
return this._coopNavigationRequest;
|
|
52
|
+
}
|
|
53
|
+
dispose() {
|
|
54
|
+
import_eventsHelper.eventsHelper.removeEventListeners(this._sessionListeners);
|
|
55
|
+
}
|
|
56
|
+
commit() {
|
|
57
|
+
(0, import_utils.assert)(this._mainFrameId);
|
|
58
|
+
this._wkPage._onFrameAttached(this._mainFrameId, null);
|
|
59
|
+
}
|
|
60
|
+
_onRequestWillBeSent(event) {
|
|
61
|
+
if (this._coopNavigationRequest && this._coopNavigationRequest.url() === event.request.url) {
|
|
62
|
+
this._wkPage._adoptRequestFromNewProcess(this._coopNavigationRequest, this._session, event.requestId);
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
this._wkPage._onRequestWillBeSent(this._session, event);
|
|
66
|
+
}
|
|
67
|
+
_onLoadingFinished(event) {
|
|
68
|
+
this._coopNavigationRequest = void 0;
|
|
69
|
+
this._wkPage._onLoadingFinished(event);
|
|
70
|
+
}
|
|
71
|
+
_onLoadingFailed(event) {
|
|
72
|
+
this._coopNavigationRequest = void 0;
|
|
73
|
+
this._wkPage._onLoadingFailed(this._session, event);
|
|
74
|
+
}
|
|
75
|
+
_handleFrameTree(frameTree) {
|
|
76
|
+
(0, import_utils.assert)(!frameTree.frame.parentId);
|
|
77
|
+
this._mainFrameId = frameTree.frame.id;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
81
|
+
0 && (module.exports = {
|
|
82
|
+
WKProvisionalPage
|
|
83
|
+
});
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var wkWorkers_exports = {};
|
|
20
|
+
__export(wkWorkers_exports, {
|
|
21
|
+
WKWorkers: () => WKWorkers
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(wkWorkers_exports);
|
|
24
|
+
var import_eventsHelper = require("../utils/eventsHelper");
|
|
25
|
+
var import_page = require("../page");
|
|
26
|
+
var import_wkConnection = require("./wkConnection");
|
|
27
|
+
var import_wkExecutionContext = require("./wkExecutionContext");
|
|
28
|
+
class WKWorkers {
|
|
29
|
+
constructor(page) {
|
|
30
|
+
this._sessionListeners = [];
|
|
31
|
+
this._workerSessions = /* @__PURE__ */ new Map();
|
|
32
|
+
this._page = page;
|
|
33
|
+
}
|
|
34
|
+
setSession(session) {
|
|
35
|
+
import_eventsHelper.eventsHelper.removeEventListeners(this._sessionListeners);
|
|
36
|
+
this.clear();
|
|
37
|
+
this._sessionListeners = [
|
|
38
|
+
import_eventsHelper.eventsHelper.addEventListener(session, "Worker.workerCreated", (event) => {
|
|
39
|
+
const worker = new import_page.Worker(this._page, event.url);
|
|
40
|
+
const workerSession = new import_wkConnection.WKSession(session.connection, event.workerId, (message) => {
|
|
41
|
+
session.send("Worker.sendMessageToWorker", {
|
|
42
|
+
workerId: event.workerId,
|
|
43
|
+
message: JSON.stringify(message)
|
|
44
|
+
}).catch((e) => {
|
|
45
|
+
workerSession.dispatchMessage({ id: message.id, error: { message: e.message } });
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
this._workerSessions.set(event.workerId, workerSession);
|
|
49
|
+
worker.createExecutionContext(new import_wkExecutionContext.WKExecutionContext(workerSession, void 0));
|
|
50
|
+
worker.workerScriptLoaded();
|
|
51
|
+
this._page.addWorker(event.workerId, worker);
|
|
52
|
+
workerSession.on("Console.messageAdded", (event2) => this._onConsoleMessage(worker, event2));
|
|
53
|
+
Promise.all([
|
|
54
|
+
workerSession.send("Runtime.enable"),
|
|
55
|
+
workerSession.send("Console.enable"),
|
|
56
|
+
session.send("Worker.initialized", { workerId: event.workerId })
|
|
57
|
+
]).catch((e) => {
|
|
58
|
+
this._page.removeWorker(event.workerId);
|
|
59
|
+
});
|
|
60
|
+
}),
|
|
61
|
+
import_eventsHelper.eventsHelper.addEventListener(session, "Worker.dispatchMessageFromWorker", (event) => {
|
|
62
|
+
const workerSession = this._workerSessions.get(event.workerId);
|
|
63
|
+
if (!workerSession)
|
|
64
|
+
return;
|
|
65
|
+
workerSession.dispatchMessage(JSON.parse(event.message));
|
|
66
|
+
}),
|
|
67
|
+
import_eventsHelper.eventsHelper.addEventListener(session, "Worker.workerTerminated", (event) => {
|
|
68
|
+
const workerSession = this._workerSessions.get(event.workerId);
|
|
69
|
+
if (!workerSession)
|
|
70
|
+
return;
|
|
71
|
+
workerSession.dispose();
|
|
72
|
+
this._workerSessions.delete(event.workerId);
|
|
73
|
+
this._page.removeWorker(event.workerId);
|
|
74
|
+
})
|
|
75
|
+
];
|
|
76
|
+
}
|
|
77
|
+
clear() {
|
|
78
|
+
this._page.clearWorkers();
|
|
79
|
+
this._workerSessions.clear();
|
|
80
|
+
}
|
|
81
|
+
async initializeSession(session) {
|
|
82
|
+
await session.send("Worker.enable");
|
|
83
|
+
}
|
|
84
|
+
async _onConsoleMessage(worker, event) {
|
|
85
|
+
const { type, level, text, parameters, url, line: lineNumber, column: columnNumber } = event.message;
|
|
86
|
+
let derivedType = type || "";
|
|
87
|
+
if (type === "log")
|
|
88
|
+
derivedType = level;
|
|
89
|
+
else if (type === "timing")
|
|
90
|
+
derivedType = "timeEnd";
|
|
91
|
+
const handles = (parameters || []).map((p) => {
|
|
92
|
+
return (0, import_wkExecutionContext.createHandle)(worker.existingExecutionContext, p);
|
|
93
|
+
});
|
|
94
|
+
const location = {
|
|
95
|
+
url: url || "",
|
|
96
|
+
lineNumber: (lineNumber || 1) - 1,
|
|
97
|
+
columnNumber: (columnNumber || 1) - 1
|
|
98
|
+
};
|
|
99
|
+
this._page.addConsoleMessage(worker, derivedType, handles, location, handles.length ? void 0 : text);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
103
|
+
0 && (module.exports = {
|
|
104
|
+
WKWorkers
|
|
105
|
+
});
|
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* ISC License
|
|
4
|
+
*
|
|
5
|
+
* Copyright (c) 2019, Mapbox
|
|
6
|
+
|
|
7
|
+
* Permission to use, copy, modify, and/or distribute this software for any purpose
|
|
8
|
+
* with or without fee is hereby granted, provided that the above copyright notice
|
|
9
|
+
* and this permission notice appear in all copies.
|
|
10
|
+
*
|
|
11
|
+
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
12
|
+
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
|
13
|
+
* FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
14
|
+
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
|
|
15
|
+
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
|
|
16
|
+
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
|
|
17
|
+
* THIS SOFTWARE.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
'use strict';
|
|
21
|
+
|
|
22
|
+
module.exports = pixelmatch;
|
|
23
|
+
|
|
24
|
+
const defaultOptions = {
|
|
25
|
+
threshold: 0.1, // matching threshold (0 to 1); smaller is more sensitive
|
|
26
|
+
includeAA: false, // whether to skip anti-aliasing detection
|
|
27
|
+
alpha: 0.1, // opacity of original image in diff output
|
|
28
|
+
aaColor: [255, 255, 0], // color of anti-aliased pixels in diff output
|
|
29
|
+
diffColor: [255, 0, 0], // color of different pixels in diff output
|
|
30
|
+
diffColorAlt: null, // whether to detect dark on light differences between img1 and img2 and set an alternative color to differentiate between the two
|
|
31
|
+
diffMask: false // draw the diff over a transparent background (a mask)
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
function pixelmatch(img1, img2, output, width, height, options) {
|
|
35
|
+
|
|
36
|
+
if (!isPixelData(img1) || !isPixelData(img2) || (output && !isPixelData(output)))
|
|
37
|
+
throw new Error('Image data: Uint8Array, Uint8ClampedArray or Buffer expected.');
|
|
38
|
+
|
|
39
|
+
if (img1.length !== img2.length || (output && output.length !== img1.length))
|
|
40
|
+
throw new Error('Image sizes do not match.');
|
|
41
|
+
|
|
42
|
+
if (img1.length !== width * height * 4) throw new Error('Image data size does not match width/height.');
|
|
43
|
+
|
|
44
|
+
options = Object.assign({}, defaultOptions, options);
|
|
45
|
+
|
|
46
|
+
// check if images are identical
|
|
47
|
+
const len = width * height;
|
|
48
|
+
const a32 = new Uint32Array(img1.buffer, img1.byteOffset, len);
|
|
49
|
+
const b32 = new Uint32Array(img2.buffer, img2.byteOffset, len);
|
|
50
|
+
let identical = true;
|
|
51
|
+
|
|
52
|
+
for (let i = 0; i < len; i++) {
|
|
53
|
+
if (a32[i] !== b32[i]) { identical = false; break; }
|
|
54
|
+
}
|
|
55
|
+
if (identical) { // fast path if identical
|
|
56
|
+
if (output && !options.diffMask) {
|
|
57
|
+
for (let i = 0; i < len; i++) drawGrayPixel(img1, 4 * i, options.alpha, output);
|
|
58
|
+
}
|
|
59
|
+
return 0;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// maximum acceptable square distance between two colors;
|
|
63
|
+
// 35215 is the maximum possible value for the YIQ difference metric
|
|
64
|
+
const maxDelta = 35215 * options.threshold * options.threshold;
|
|
65
|
+
let diff = 0;
|
|
66
|
+
|
|
67
|
+
// compare each pixel of one image against the other one
|
|
68
|
+
for (let y = 0; y < height; y++) {
|
|
69
|
+
for (let x = 0; x < width; x++) {
|
|
70
|
+
|
|
71
|
+
const pos = (y * width + x) * 4;
|
|
72
|
+
|
|
73
|
+
// squared YUV distance between colors at this pixel position, negative if the img2 pixel is darker
|
|
74
|
+
const delta = colorDelta(img1, img2, pos, pos);
|
|
75
|
+
|
|
76
|
+
// the color difference is above the threshold
|
|
77
|
+
if (Math.abs(delta) > maxDelta) {
|
|
78
|
+
// check it's a real rendering difference or just anti-aliasing
|
|
79
|
+
if (!options.includeAA && (antialiased(img1, x, y, width, height, img2) ||
|
|
80
|
+
antialiased(img2, x, y, width, height, img1))) {
|
|
81
|
+
// one of the pixels is anti-aliasing; draw as yellow and do not count as difference
|
|
82
|
+
// note that we do not include such pixels in a mask
|
|
83
|
+
if (output && !options.diffMask) drawPixel(output, pos, ...options.aaColor);
|
|
84
|
+
|
|
85
|
+
} else {
|
|
86
|
+
// found substantial difference not caused by anti-aliasing; draw it as such
|
|
87
|
+
if (output) {
|
|
88
|
+
drawPixel(output, pos, ...(delta < 0 && options.diffColorAlt || options.diffColor));
|
|
89
|
+
}
|
|
90
|
+
diff++;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
} else if (output) {
|
|
94
|
+
// pixels are similar; draw background as grayscale image blended with white
|
|
95
|
+
if (!options.diffMask) drawGrayPixel(img1, pos, options.alpha, output);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// return the number of different pixels
|
|
101
|
+
return diff;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
function isPixelData(arr) {
|
|
105
|
+
// work around instanceof Uint8Array not working properly in some Jest environments
|
|
106
|
+
return ArrayBuffer.isView(arr) && arr.constructor.BYTES_PER_ELEMENT === 1;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// check if a pixel is likely a part of anti-aliasing;
|
|
110
|
+
// based on "Anti-aliased Pixel and Intensity Slope Detector" paper by V. Vysniauskas, 2009
|
|
111
|
+
|
|
112
|
+
function antialiased(img, x1, y1, width, height, img2) {
|
|
113
|
+
const x0 = Math.max(x1 - 1, 0);
|
|
114
|
+
const y0 = Math.max(y1 - 1, 0);
|
|
115
|
+
const x2 = Math.min(x1 + 1, width - 1);
|
|
116
|
+
const y2 = Math.min(y1 + 1, height - 1);
|
|
117
|
+
const pos = (y1 * width + x1) * 4;
|
|
118
|
+
let zeroes = x1 === x0 || x1 === x2 || y1 === y0 || y1 === y2 ? 1 : 0;
|
|
119
|
+
let min = 0;
|
|
120
|
+
let max = 0;
|
|
121
|
+
let minX, minY, maxX, maxY;
|
|
122
|
+
|
|
123
|
+
// go through 8 adjacent pixels
|
|
124
|
+
for (let x = x0; x <= x2; x++) {
|
|
125
|
+
for (let y = y0; y <= y2; y++) {
|
|
126
|
+
if (x === x1 && y === y1) continue;
|
|
127
|
+
|
|
128
|
+
// brightness delta between the center pixel and adjacent one
|
|
129
|
+
const delta = colorDelta(img, img, pos, (y * width + x) * 4, true);
|
|
130
|
+
|
|
131
|
+
// count the number of equal, darker and brighter adjacent pixels
|
|
132
|
+
if (delta === 0) {
|
|
133
|
+
zeroes++;
|
|
134
|
+
// if found more than 2 equal siblings, it's definitely not anti-aliasing
|
|
135
|
+
if (zeroes > 2) return false;
|
|
136
|
+
|
|
137
|
+
// remember the darkest pixel
|
|
138
|
+
} else if (delta < min) {
|
|
139
|
+
min = delta;
|
|
140
|
+
minX = x;
|
|
141
|
+
minY = y;
|
|
142
|
+
|
|
143
|
+
// remember the brightest pixel
|
|
144
|
+
} else if (delta > max) {
|
|
145
|
+
max = delta;
|
|
146
|
+
maxX = x;
|
|
147
|
+
maxY = y;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
// if there are no both darker and brighter pixels among siblings, it's not anti-aliasing
|
|
153
|
+
if (min === 0 || max === 0) return false;
|
|
154
|
+
|
|
155
|
+
// if either the darkest or the brightest pixel has 3+ equal siblings in both images
|
|
156
|
+
// (definitely not anti-aliased), this pixel is anti-aliased
|
|
157
|
+
return (hasManySiblings(img, minX, minY, width, height) && hasManySiblings(img2, minX, minY, width, height)) ||
|
|
158
|
+
(hasManySiblings(img, maxX, maxY, width, height) && hasManySiblings(img2, maxX, maxY, width, height));
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
// check if a pixel has 3+ adjacent pixels of the same color.
|
|
162
|
+
function hasManySiblings(img, x1, y1, width, height) {
|
|
163
|
+
const x0 = Math.max(x1 - 1, 0);
|
|
164
|
+
const y0 = Math.max(y1 - 1, 0);
|
|
165
|
+
const x2 = Math.min(x1 + 1, width - 1);
|
|
166
|
+
const y2 = Math.min(y1 + 1, height - 1);
|
|
167
|
+
const pos = (y1 * width + x1) * 4;
|
|
168
|
+
let zeroes = x1 === x0 || x1 === x2 || y1 === y0 || y1 === y2 ? 1 : 0;
|
|
169
|
+
|
|
170
|
+
// go through 8 adjacent pixels
|
|
171
|
+
for (let x = x0; x <= x2; x++) {
|
|
172
|
+
for (let y = y0; y <= y2; y++) {
|
|
173
|
+
if (x === x1 && y === y1) continue;
|
|
174
|
+
|
|
175
|
+
const pos2 = (y * width + x) * 4;
|
|
176
|
+
if (img[pos] === img[pos2] &&
|
|
177
|
+
img[pos + 1] === img[pos2 + 1] &&
|
|
178
|
+
img[pos + 2] === img[pos2 + 2] &&
|
|
179
|
+
img[pos + 3] === img[pos2 + 3]) zeroes++;
|
|
180
|
+
|
|
181
|
+
if (zeroes > 2) return true;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
return false;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
// calculate color difference according to the paper "Measuring perceived color difference
|
|
189
|
+
// using YIQ NTSC transmission color space in mobile applications" by Y. Kotsarenko and F. Ramos
|
|
190
|
+
|
|
191
|
+
function colorDelta(img1, img2, k, m, yOnly) {
|
|
192
|
+
let r1 = img1[k + 0];
|
|
193
|
+
let g1 = img1[k + 1];
|
|
194
|
+
let b1 = img1[k + 2];
|
|
195
|
+
let a1 = img1[k + 3];
|
|
196
|
+
|
|
197
|
+
let r2 = img2[m + 0];
|
|
198
|
+
let g2 = img2[m + 1];
|
|
199
|
+
let b2 = img2[m + 2];
|
|
200
|
+
let a2 = img2[m + 3];
|
|
201
|
+
|
|
202
|
+
if (a1 === a2 && r1 === r2 && g1 === g2 && b1 === b2) return 0;
|
|
203
|
+
|
|
204
|
+
if (a1 < 255) {
|
|
205
|
+
a1 /= 255;
|
|
206
|
+
r1 = blend(r1, a1);
|
|
207
|
+
g1 = blend(g1, a1);
|
|
208
|
+
b1 = blend(b1, a1);
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
if (a2 < 255) {
|
|
212
|
+
a2 /= 255;
|
|
213
|
+
r2 = blend(r2, a2);
|
|
214
|
+
g2 = blend(g2, a2);
|
|
215
|
+
b2 = blend(b2, a2);
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
const y1 = rgb2y(r1, g1, b1);
|
|
219
|
+
const y2 = rgb2y(r2, g2, b2);
|
|
220
|
+
const y = y1 - y2;
|
|
221
|
+
|
|
222
|
+
if (yOnly) return y; // brightness difference only
|
|
223
|
+
|
|
224
|
+
const i = rgb2i(r1, g1, b1) - rgb2i(r2, g2, b2);
|
|
225
|
+
const q = rgb2q(r1, g1, b1) - rgb2q(r2, g2, b2);
|
|
226
|
+
|
|
227
|
+
const delta = 0.5053 * y * y + 0.299 * i * i + 0.1957 * q * q;
|
|
228
|
+
|
|
229
|
+
// encode whether the pixel lightens or darkens in the sign
|
|
230
|
+
return y1 > y2 ? -delta : delta;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
function rgb2y(r, g, b) { return r * 0.29889531 + g * 0.58662247 + b * 0.11448223; }
|
|
234
|
+
function rgb2i(r, g, b) { return r * 0.59597799 - g * 0.27417610 - b * 0.32180189; }
|
|
235
|
+
function rgb2q(r, g, b) { return r * 0.21147017 - g * 0.52261711 + b * 0.31114694; }
|
|
236
|
+
|
|
237
|
+
// blend semi-transparent color with white
|
|
238
|
+
function blend(c, a) {
|
|
239
|
+
return 255 + (c - 255) * a;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
function drawPixel(output, pos, r, g, b) {
|
|
243
|
+
output[pos + 0] = r;
|
|
244
|
+
output[pos + 1] = g;
|
|
245
|
+
output[pos + 2] = b;
|
|
246
|
+
output[pos + 3] = 255;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
function drawGrayPixel(img, i, alpha, output) {
|
|
250
|
+
const r = img[i + 0];
|
|
251
|
+
const g = img[i + 1];
|
|
252
|
+
const b = img[i + 2];
|
|
253
|
+
const val = blend(rgb2y(r, g, b), alpha * img[i + 3] / 255);
|
|
254
|
+
drawPixel(output, i, val, val, val);
|
|
255
|
+
}
|