@applitools/core 4.44.5 → 4.46.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/CHANGELOG.md +80 -0
- package/dist/autonomous/core.js +2 -0
- package/dist/ufg/utils/register-default-scripts.js +28 -5
- package/package.json +18 -18
- package/types/automation/types.d.ts +1 -0
- package/types/autonomous/types.d.ts +5 -0
- package/types/ufg/utils/register-default-scripts.d.ts +13 -3
- package/dist/utils/capture-canvas-image-always.js +0 -82
- package/types/utils/capture-canvas-image-always.d.ts +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,85 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [4.46.0](https://github.com/Applitools-Dev/sdk/compare/js/core@4.45.0...js/core@4.46.0) (2025-09-09)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* enable canvas with webgl for autonomous | FLD 3515 ([#3197](https://github.com/Applitools-Dev/sdk/issues/3197)) ([23f22e5](https://github.com/Applitools-Dev/sdk/commit/23f22e517d52dc70f24093dfb21e072b9aa9fb60))
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* update offline test fixtures to use Google Fonts v12 ([#3215](https://github.com/Applitools-Dev/sdk/issues/3215)) ([ba8ef0c](https://github.com/Applitools-Dev/sdk/commit/ba8ef0c3b11a7f5e9e59a58f29fd5d60760a68ee))
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
### Dependencies
|
|
17
|
+
|
|
18
|
+
* @applitools/utils bumped to 1.12.0
|
|
19
|
+
#### Features
|
|
20
|
+
|
|
21
|
+
* enable canvas with webgl for autonomous | FLD 3515 ([#3197](https://github.com/Applitools-Dev/sdk/issues/3197)) ([23f22e5](https://github.com/Applitools-Dev/sdk/commit/23f22e517d52dc70f24093dfb21e072b9aa9fb60))
|
|
22
|
+
* @applitools/logger bumped to 2.2.3
|
|
23
|
+
|
|
24
|
+
* @applitools/dom-snapshot bumped to 4.13.6
|
|
25
|
+
|
|
26
|
+
* @applitools/socket bumped to 1.3.4
|
|
27
|
+
|
|
28
|
+
* @applitools/req bumped to 1.8.3
|
|
29
|
+
|
|
30
|
+
* @applitools/image bumped to 1.2.3
|
|
31
|
+
|
|
32
|
+
* @applitools/dom-capture bumped to 11.6.4
|
|
33
|
+
|
|
34
|
+
* @applitools/driver bumped to 1.23.4
|
|
35
|
+
|
|
36
|
+
* @applitools/spec-driver-webdriver bumped to 1.4.4
|
|
37
|
+
|
|
38
|
+
* @applitools/spec-driver-selenium bumped to 1.7.4
|
|
39
|
+
|
|
40
|
+
* @applitools/spec-driver-puppeteer bumped to 1.6.4
|
|
41
|
+
|
|
42
|
+
* @applitools/screenshoter bumped to 3.12.4
|
|
43
|
+
|
|
44
|
+
* @applitools/nml-client bumped to 1.11.4
|
|
45
|
+
|
|
46
|
+
* @applitools/tunnel-client bumped to 1.11.1
|
|
47
|
+
|
|
48
|
+
* @applitools/ufg-client bumped to 1.17.3
|
|
49
|
+
|
|
50
|
+
* @applitools/core-base bumped to 1.27.3
|
|
51
|
+
|
|
52
|
+
* @applitools/ec-client bumped to 1.12.6
|
|
53
|
+
|
|
54
|
+
* @applitools/test-server bumped to 1.3.2
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
## [4.45.0](https://github.com/Applitools-Dev/sdk/compare/js/core@4.44.5...js/core@4.45.0) (2025-09-04)
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
### Features
|
|
61
|
+
|
|
62
|
+
* respect NO_PROXY for WebDriver | AD-10927 | FLD-2702 ([#3186](https://github.com/Applitools-Dev/sdk/issues/3186)) ([8e53d9a](https://github.com/Applitools-Dev/sdk/commit/8e53d9a7c1b6fe38c11d63fad915fc89b199a749))
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
### Dependencies
|
|
66
|
+
|
|
67
|
+
* @applitools/dom-shared bumped to 1.1.1
|
|
68
|
+
#### Code Refactoring
|
|
69
|
+
|
|
70
|
+
* dom shared js -> ts ([#3202](https://github.com/Applitools-Dev/sdk/issues/3202)) ([c6d6b77](https://github.com/Applitools-Dev/sdk/commit/c6d6b77179d48539cc40f609f150f380aa48d6bb))
|
|
71
|
+
* @applitools/tunnel-client bumped to 1.11.0
|
|
72
|
+
#### Features
|
|
73
|
+
|
|
74
|
+
* mask apiKey and eyesServerUrl from the logs | AD-10661 ([#3200](https://github.com/Applitools-Dev/sdk/issues/3200)) ([eaba565](https://github.com/Applitools-Dev/sdk/commit/eaba565898d8e72745a1e95c9b17ae77c396ca14))
|
|
75
|
+
* report to coralogix | AD-10945 ([#3191](https://github.com/Applitools-Dev/sdk/issues/3191)) ([2f57db1](https://github.com/Applitools-Dev/sdk/commit/2f57db162db4d3dbe4cdab06096f0d183af94946))
|
|
76
|
+
* @applitools/dom-snapshot bumped to 4.13.5
|
|
77
|
+
|
|
78
|
+
* @applitools/dom-capture bumped to 11.6.3
|
|
79
|
+
|
|
80
|
+
* @applitools/ec-client bumped to 1.12.5
|
|
81
|
+
|
|
82
|
+
|
|
3
83
|
## [4.44.5](https://github.com/Applitools-Dev/sdk/compare/js/core@4.44.4...js/core@4.44.5) (2025-08-27)
|
|
4
84
|
|
|
5
85
|
|
package/dist/autonomous/core.js
CHANGED
|
@@ -10,12 +10,14 @@ const get_render_results_1 = require("./get-render-results");
|
|
|
10
10
|
const create_render_results_1 = require("./create-render-results");
|
|
11
11
|
const open_eyes_1 = require("./open-eyes");
|
|
12
12
|
const open_check_and_close_1 = require("./open-check-and-close");
|
|
13
|
+
const register_default_scripts_1 = require("../ufg/utils/register-default-scripts");
|
|
13
14
|
function makeAutonomousCore({ spec, clients, base: defaultBase, asyncCache, agentId = 'core-autonomous', logger: defaultLogger, } = {}) {
|
|
14
15
|
const logger = (0, logger_1.makeLogger)({ logger: defaultLogger, format: { label: 'core-autonomous' } });
|
|
15
16
|
const core = (0, core_1.makeCore)({ spec, clients, base: defaultBase, asyncCache, agentId, logger });
|
|
16
17
|
return {
|
|
17
18
|
type: 'autonomous',
|
|
18
19
|
takeSnapshots: spec && (0, take_snapshots_1.makeTakeSnapshots)({ core, spec, logger }),
|
|
20
|
+
startSDKHook: spec && (0, register_default_scripts_1.makeRegisterOnNewDocumentScripts)({ spec, logger }),
|
|
19
21
|
createRenderTarget: (0, create_render_target_1.makeCreateRenderTarget)({ core, logger }),
|
|
20
22
|
startRenders: (0, start_renders_1.makeStartRenders)({ core, logger }),
|
|
21
23
|
getRenderResults: (0, get_render_results_1.makeGetRenderResults)({ core, logger }),
|
|
@@ -1,23 +1,46 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.registerDefaultScripts = void 0;
|
|
4
|
-
const
|
|
3
|
+
exports.registerDefaultScripts = exports.makeRegisterOnNewDocumentScripts = void 0;
|
|
4
|
+
const driver_1 = require("@applitools/driver");
|
|
5
5
|
const utils_1 = require("@applitools/utils");
|
|
6
6
|
function wrapFunctionAsIIFE(fn) {
|
|
7
7
|
return `(()=>{ ${fn.toString()} return ${fn.name}.call()})()`;
|
|
8
8
|
}
|
|
9
|
-
|
|
9
|
+
function makeRegisterOnNewDocumentScripts({ spec, logger }) {
|
|
10
|
+
return async function registerOnNewDocumentScripts({ target, enableScripts, }) {
|
|
11
|
+
const driver = await (0, driver_1.makeDriver)({ spec, driver: target, logger });
|
|
12
|
+
return registerDefaultScripts({ driver, logger, enableScripts });
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
exports.makeRegisterOnNewDocumentScripts = makeRegisterOnNewDocumentScripts;
|
|
16
|
+
async function registerDefaultScripts({ driver, enableScripts, logger, }) {
|
|
10
17
|
if (!driver)
|
|
11
18
|
return [];
|
|
12
19
|
try {
|
|
13
|
-
const captureImagesScript = wrapFunctionAsIIFE(
|
|
20
|
+
const captureImagesScript = wrapFunctionAsIIFE(utils_1.snippets.captureImagesFunc);
|
|
14
21
|
const scripts = [];
|
|
15
|
-
if (utils_1.general.getEnvValue('CAPTURE_CANVAS_WITH_WEBGL', 'boolean') === true
|
|
22
|
+
if (utils_1.general.getEnvValue('CAPTURE_CANVAS_WITH_WEBGL', 'boolean') === true ||
|
|
23
|
+
(enableScripts === null || enableScripts === void 0 ? void 0 : enableScripts.captureImagesScript) === true) {
|
|
16
24
|
scripts.push({ name: 'captureImagesScript', code: captureImagesScript });
|
|
17
25
|
}
|
|
26
|
+
if (utils_1.general.getEnvValue('CAPTURE_CANVAS_WITH_PRESERVE_DRAWING_BUFFER', 'boolean') === true ||
|
|
27
|
+
(enableScripts === null || enableScripts === void 0 ? void 0 : enableScripts.enableCanvasPreserveDrawingBufferScript) === true) {
|
|
28
|
+
scripts.push({
|
|
29
|
+
name: 'enableCanvasPreserveDrawingBufferScript',
|
|
30
|
+
code: wrapFunctionAsIIFE(utils_1.snippets.enableCanvasPreserveDrawingBuffer),
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
if (utils_1.general.getEnvValue('CAPTURE_CANVAS_WITH_PRESERVE_DRAWING_BUFFER', 'boolean') === false ||
|
|
34
|
+
(enableScripts === null || enableScripts === void 0 ? void 0 : enableScripts.disableCanvasPreserveDrawingBufferScript) === true) {
|
|
35
|
+
scripts.push({
|
|
36
|
+
name: 'disableCanvasPreserveDrawingBufferScript',
|
|
37
|
+
code: wrapFunctionAsIIFE(utils_1.snippets.disableCanvasPreserveDrawingBuffer),
|
|
38
|
+
});
|
|
39
|
+
}
|
|
18
40
|
await Promise.all(scripts.map(async (script) => {
|
|
19
41
|
logger.info('running user script', script.name);
|
|
20
42
|
await driver.addScriptToEvaluateOnNewDocument(script.code);
|
|
43
|
+
logger.info('user script registered successfully', script.name);
|
|
21
44
|
}));
|
|
22
45
|
return scripts;
|
|
23
46
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@applitools/core",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.46.0",
|
|
4
4
|
"homepage": "https://applitools.com",
|
|
5
5
|
"bugs": {
|
|
6
6
|
"url": "https://github.com/applitools/eyes.sdk.javascript1/issues"
|
|
@@ -79,20 +79,20 @@
|
|
|
79
79
|
}
|
|
80
80
|
},
|
|
81
81
|
"dependencies": {
|
|
82
|
-
"@applitools/core-base": "1.27.
|
|
83
|
-
"@applitools/dom-capture": "11.6.
|
|
84
|
-
"@applitools/dom-snapshot": "4.13.
|
|
85
|
-
"@applitools/driver": "1.23.
|
|
86
|
-
"@applitools/ec-client": "1.12.
|
|
87
|
-
"@applitools/logger": "2.2.
|
|
88
|
-
"@applitools/nml-client": "1.11.
|
|
89
|
-
"@applitools/req": "1.8.
|
|
90
|
-
"@applitools/screenshoter": "3.12.
|
|
82
|
+
"@applitools/core-base": "1.27.3",
|
|
83
|
+
"@applitools/dom-capture": "11.6.4",
|
|
84
|
+
"@applitools/dom-snapshot": "4.13.6",
|
|
85
|
+
"@applitools/driver": "1.23.4",
|
|
86
|
+
"@applitools/ec-client": "1.12.6",
|
|
87
|
+
"@applitools/logger": "2.2.3",
|
|
88
|
+
"@applitools/nml-client": "1.11.4",
|
|
89
|
+
"@applitools/req": "1.8.3",
|
|
90
|
+
"@applitools/screenshoter": "3.12.4",
|
|
91
91
|
"@applitools/snippets": "2.7.0",
|
|
92
|
-
"@applitools/socket": "1.3.
|
|
93
|
-
"@applitools/spec-driver-webdriver": "1.4.
|
|
94
|
-
"@applitools/ufg-client": "1.17.
|
|
95
|
-
"@applitools/utils": "1.
|
|
92
|
+
"@applitools/socket": "1.3.4",
|
|
93
|
+
"@applitools/spec-driver-webdriver": "1.4.4",
|
|
94
|
+
"@applitools/ufg-client": "1.17.3",
|
|
95
|
+
"@applitools/utils": "1.12.0",
|
|
96
96
|
"@types/ws": "8.5.5",
|
|
97
97
|
"abort-controller": "3.0.0",
|
|
98
98
|
"chalk": "4.1.2",
|
|
@@ -106,11 +106,11 @@
|
|
|
106
106
|
"devDependencies": {
|
|
107
107
|
"@applitools/bongo": "^5.10.0",
|
|
108
108
|
"@applitools/sea": "^1.0.0",
|
|
109
|
-
"@applitools/spec-driver-puppeteer": "^1.6.
|
|
110
|
-
"@applitools/spec-driver-selenium": "^1.7.
|
|
111
|
-
"@applitools/test-server": "^1.3.
|
|
109
|
+
"@applitools/spec-driver-puppeteer": "^1.6.4",
|
|
110
|
+
"@applitools/spec-driver-selenium": "^1.7.4",
|
|
111
|
+
"@applitools/test-server": "^1.3.2",
|
|
112
112
|
"@applitools/test-utils": "^1.5.17",
|
|
113
|
-
"@applitools/tunnel-client": "^1.
|
|
113
|
+
"@applitools/tunnel-client": "^1.11.1",
|
|
114
114
|
"@types/mocha": "^10.0.7",
|
|
115
115
|
"@types/node": "^12.20.55",
|
|
116
116
|
"@types/selenium-webdriver": "^4.1.2",
|
|
@@ -50,6 +50,7 @@ export type Script = {
|
|
|
50
50
|
name: string;
|
|
51
51
|
code: string;
|
|
52
52
|
};
|
|
53
|
+
export type BrowserScriptNames = 'captureImagesScript' | 'enableCanvasPreserveDrawingBufferScript' | 'disableCanvasPreserveDrawingBufferScript';
|
|
53
54
|
export interface Core<TSpec extends SpecType> extends Omit<BaseCore.Core, 'openEyes'> {
|
|
54
55
|
readonly base: BaseCore.Core;
|
|
55
56
|
getViewportSize?(options: {
|
|
@@ -3,6 +3,7 @@ import type * as UFGCore from '../ufg/types';
|
|
|
3
3
|
import { type Logger } from '@applitools/logger';
|
|
4
4
|
import { type SpecType } from '@applitools/driver';
|
|
5
5
|
import { type RenderTarget, type StartedRender as UFGStartedRender } from '@applitools/ufg-client';
|
|
6
|
+
import type { Script, BrowserScriptNames } from '../ufg/types';
|
|
6
7
|
export * from '../ufg/types';
|
|
7
8
|
export interface AutonomousCore<TSpec extends SpecType> {
|
|
8
9
|
readonly type: 'autonomous';
|
|
@@ -11,6 +12,10 @@ export interface AutonomousCore<TSpec extends SpecType> {
|
|
|
11
12
|
settings?: Partial<SnapshotSettings<TSpec>>;
|
|
12
13
|
logger?: Logger;
|
|
13
14
|
}): Promise<UFGCore.Snapshot[]>;
|
|
15
|
+
startSDKHook?(options: {
|
|
16
|
+
target: UFGCore.DriverTarget<TSpec>;
|
|
17
|
+
enableScripts?: Partial<Record<BrowserScriptNames, boolean>>;
|
|
18
|
+
}): Promise<Script[]>;
|
|
14
19
|
createRenderTarget(options: {
|
|
15
20
|
snapshot: UFGCore.Snapshot;
|
|
16
21
|
logger?: Logger;
|
|
@@ -1,7 +1,17 @@
|
|
|
1
|
-
import type { Script } from '../types';
|
|
2
|
-
import { type SpecType, type Driver } from '@applitools/driver';
|
|
1
|
+
import type { Script, BrowserScriptNames, DriverTarget } from '../types';
|
|
2
|
+
import { type SpecType, type Driver, type SpecDriver } from '@applitools/driver';
|
|
3
3
|
import { type Logger } from '@applitools/logger';
|
|
4
|
-
|
|
4
|
+
type Options<TSpec extends SpecType> = {
|
|
5
|
+
spec: SpecDriver<TSpec>;
|
|
6
|
+
logger: Logger;
|
|
7
|
+
};
|
|
8
|
+
export declare function makeRegisterOnNewDocumentScripts<TSpec extends SpecType>({ spec, logger }: Options<TSpec>): ({ target, enableScripts, }: {
|
|
9
|
+
target: DriverTarget<TSpec>;
|
|
10
|
+
enableScripts?: Record<BrowserScriptNames, boolean> | undefined;
|
|
11
|
+
}) => Promise<Script[]>;
|
|
12
|
+
export declare function registerDefaultScripts<TSpec extends SpecType>({ driver, enableScripts, logger, }: {
|
|
5
13
|
driver?: Driver<TSpec>;
|
|
14
|
+
enableScripts?: Record<BrowserScriptNames, boolean>;
|
|
6
15
|
logger: Logger;
|
|
7
16
|
}): Promise<Script[]>;
|
|
17
|
+
export {};
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.captureImagesFunc = void 0;
|
|
4
|
-
function captureImagesFunc() {
|
|
5
|
-
async function isNonBlackImage(dataUrl) {
|
|
6
|
-
const img = new Image();
|
|
7
|
-
img.src = dataUrl;
|
|
8
|
-
await new Promise((resolve, reject) => {
|
|
9
|
-
img.onload = () => resolve();
|
|
10
|
-
img.onerror = () => reject();
|
|
11
|
-
});
|
|
12
|
-
const canvas = document.createElement('canvas');
|
|
13
|
-
canvas.width = img.width;
|
|
14
|
-
canvas.height = img.height;
|
|
15
|
-
const ctx = canvas.getContext('2d');
|
|
16
|
-
if (!ctx)
|
|
17
|
-
return false;
|
|
18
|
-
ctx.drawImage(img, 0, 0);
|
|
19
|
-
const imageData = ctx.getImageData(0, 0, canvas.width, canvas.height).data;
|
|
20
|
-
for (let i = 0; i < imageData.length; i += 4) {
|
|
21
|
-
if (imageData[i] !== 0 || imageData[i + 1] !== 0 || imageData[i + 2] !== 0) {
|
|
22
|
-
return true;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
return false;
|
|
26
|
-
}
|
|
27
|
-
function processWebGLCanvases(win) {
|
|
28
|
-
Array.from(win.document.getElementsByTagName('canvas')).forEach((canvas) => {
|
|
29
|
-
const gl = canvas.getContext('webgl') || canvas.getContext('webgl2');
|
|
30
|
-
if (!gl)
|
|
31
|
-
return;
|
|
32
|
-
const attrs = gl.getContextAttributes();
|
|
33
|
-
if (!attrs)
|
|
34
|
-
return;
|
|
35
|
-
const { preserveDrawingBuffer } = attrs;
|
|
36
|
-
if (!preserveDrawingBuffer && canvas.width > 0 && canvas.height > 0) {
|
|
37
|
-
const dataUrl = canvas.toDataURL('image/png');
|
|
38
|
-
if ((canvas.dataset.dataUrl || '') === dataUrl)
|
|
39
|
-
return;
|
|
40
|
-
isNonBlackImage(dataUrl).then(result => {
|
|
41
|
-
if (result) {
|
|
42
|
-
canvas.dataset.dataUrl = dataUrl;
|
|
43
|
-
}
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
function patchRequestAnimationFrame(win) {
|
|
49
|
-
var _a;
|
|
50
|
-
if (win.__rafPatched) {
|
|
51
|
-
return;
|
|
52
|
-
}
|
|
53
|
-
const HTMLCanvasElementCtor = win.HTMLCanvasElement ||
|
|
54
|
-
(win.constructor && win.constructor.HTMLCanvasElement) ||
|
|
55
|
-
(win.document && ((_a = win.document.defaultView) === null || _a === void 0 ? void 0 : _a.HTMLCanvasElement));
|
|
56
|
-
const origGetContext = (HTMLCanvasElementCtor && HTMLCanvasElementCtor.prototype.getContext);
|
|
57
|
-
if (!origGetContext) {
|
|
58
|
-
return;
|
|
59
|
-
}
|
|
60
|
-
const originalRAF = win.requestAnimationFrame;
|
|
61
|
-
win.requestAnimationFrame = function (callback) {
|
|
62
|
-
const rafId = originalRAF.call(this, (time) => {
|
|
63
|
-
callback.call(win, time);
|
|
64
|
-
processWebGLCanvases(win);
|
|
65
|
-
});
|
|
66
|
-
return rafId;
|
|
67
|
-
};
|
|
68
|
-
win.__rafPatched = true;
|
|
69
|
-
}
|
|
70
|
-
function takeCanvasScreenshots(win = window) {
|
|
71
|
-
if (win.__rafPatched) {
|
|
72
|
-
return;
|
|
73
|
-
}
|
|
74
|
-
try {
|
|
75
|
-
patchRequestAnimationFrame(win);
|
|
76
|
-
}
|
|
77
|
-
catch (e) { }
|
|
78
|
-
}
|
|
79
|
-
Object.assign(window, { takeCanvasScreenshots });
|
|
80
|
-
takeCanvasScreenshots();
|
|
81
|
-
}
|
|
82
|
-
exports.captureImagesFunc = captureImagesFunc;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function captureImagesFunc(): void;
|