@applitools/core 4.40.0 → 4.41.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 CHANGED
@@ -1,5 +1,99 @@
1
1
  # Changelog
2
2
 
3
+ ## [4.41.0](https://github.com/Applitools-Dev/sdk/compare/js/core@4.40.0...js/core@4.41.0) (2025-07-07)
4
+
5
+
6
+ ### Features
7
+
8
+ * canvas webgl without preserveDrawingBuffer=1 | FLD-3144 ([#3040](https://github.com/Applitools-Dev/sdk/issues/3040)) ([f82d8f1](https://github.com/Applitools-Dev/sdk/commit/f82d8f148f913098752ec7bef8635a46b453d6fa))
9
+ * support https_proxy and http_proxy env variables | FLD-2702 ([#3046](https://github.com/Applitools-Dev/sdk/issues/3046)) ([0633809](https://github.com/Applitools-Dev/sdk/commit/06338099f44bfb149a5829f62c2f9b19e2392850))
10
+
11
+
12
+ ### Bug Fixes
13
+
14
+ * add retries for ConnectEnomem errors | FLD-3015 ([#3052](https://github.com/Applitools-Dev/sdk/issues/3052)) ([92caa45](https://github.com/Applitools-Dev/sdk/commit/92caa452b4a6d6f86c903548b40f8207a0ed11d0))
15
+ * determine storybook 9 version | AD-10406 ([#3054](https://github.com/Applitools-Dev/sdk/issues/3054)) ([23486bf](https://github.com/Applitools-Dev/sdk/commit/23486bf1c9dc905d243239214e0e838d54c0b3c2))
16
+ * support for programmatically added nested css rules | FLD-3212 ([#3049](https://github.com/Applitools-Dev/sdk/issues/3049)) ([5abb0f7](https://github.com/Applitools-Dev/sdk/commit/5abb0f7904c4d9e4b716291abecad54554b9ca01))
17
+
18
+
19
+ ### Dependencies
20
+
21
+ * @applitools/utils bumped to 1.9.0
22
+ #### Features
23
+
24
+ * support https_proxy and http_proxy env variables | FLD-2702 ([#3046](https://github.com/Applitools-Dev/sdk/issues/3046)) ([0633809](https://github.com/Applitools-Dev/sdk/commit/06338099f44bfb149a5829f62c2f9b19e2392850))
25
+ * @applitools/dom-snapshot bumped to 4.12.0
26
+ #### Features
27
+
28
+ * canvas webgl without preserveDrawingBuffer=1 | FLD-3144 ([#3040](https://github.com/Applitools-Dev/sdk/issues/3040)) ([f82d8f1](https://github.com/Applitools-Dev/sdk/commit/f82d8f148f913098752ec7bef8635a46b453d6fa))
29
+
30
+
31
+ #### Bug Fixes
32
+
33
+ * support for programmatically added nested css rules | FLD-3212 ([#3049](https://github.com/Applitools-Dev/sdk/issues/3049)) ([5abb0f7](https://github.com/Applitools-Dev/sdk/commit/5abb0f7904c4d9e4b716291abecad54554b9ca01))
34
+
35
+
36
+
37
+ * @applitools/driver bumped to 1.22.0
38
+ #### Features
39
+
40
+ * canvas webgl without preserveDrawingBuffer=1 | FLD-3144 ([#3040](https://github.com/Applitools-Dev/sdk/issues/3040)) ([f82d8f1](https://github.com/Applitools-Dev/sdk/commit/f82d8f148f913098752ec7bef8635a46b453d6fa))
41
+
42
+
43
+
44
+ * @applitools/spec-driver-webdriver bumped to 1.3.0
45
+ #### Features
46
+
47
+ * canvas webgl without preserveDrawingBuffer=1 | FLD-3144 ([#3040](https://github.com/Applitools-Dev/sdk/issues/3040)) ([f82d8f1](https://github.com/Applitools-Dev/sdk/commit/f82d8f148f913098752ec7bef8635a46b453d6fa))
48
+ * support https_proxy and http_proxy env variables | FLD-2702 ([#3046](https://github.com/Applitools-Dev/sdk/issues/3046)) ([0633809](https://github.com/Applitools-Dev/sdk/commit/06338099f44bfb149a5829f62c2f9b19e2392850))
49
+
50
+
51
+
52
+ * @applitools/spec-driver-selenium bumped to 1.6.0
53
+ #### Features
54
+
55
+ * canvas webgl without preserveDrawingBuffer=1 | FLD-3144 ([#3040](https://github.com/Applitools-Dev/sdk/issues/3040)) ([f82d8f1](https://github.com/Applitools-Dev/sdk/commit/f82d8f148f913098752ec7bef8635a46b453d6fa))
56
+
57
+
58
+
59
+ * @applitools/spec-driver-puppeteer bumped to 1.5.0
60
+ #### Features
61
+
62
+ * canvas webgl without preserveDrawingBuffer=1 | FLD-3144 ([#3040](https://github.com/Applitools-Dev/sdk/issues/3040)) ([f82d8f1](https://github.com/Applitools-Dev/sdk/commit/f82d8f148f913098752ec7bef8635a46b453d6fa))
63
+
64
+
65
+
66
+ * @applitools/nml-client bumped to 1.9.6
67
+ #### Bug Fixes
68
+
69
+ * add retries for ConnectEnomem errors | FLD-3015 ([#3052](https://github.com/Applitools-Dev/sdk/issues/3052)) ([92caa45](https://github.com/Applitools-Dev/sdk/commit/92caa452b4a6d6f86c903548b40f8207a0ed11d0))
70
+
71
+
72
+
73
+ * @applitools/logger bumped to 2.1.5
74
+
75
+ * @applitools/socket bumped to 1.2.6
76
+
77
+ * @applitools/req bumped to 1.7.14
78
+
79
+ * @applitools/image bumped to 1.1.21
80
+
81
+ * @applitools/screenshoter bumped to 3.11.6
82
+
83
+ * @applitools/tunnel-client bumped to 1.8.1
84
+
85
+ * @applitools/ufg-client bumped to 1.16.13
86
+
87
+ * @applitools/core-base bumped to 1.25.5
88
+ #### Bug Fixes
89
+
90
+ * add retries for ConnectEnomem errors | FLD-3015 ([#3052](https://github.com/Applitools-Dev/sdk/issues/3052)) ([92caa45](https://github.com/Applitools-Dev/sdk/commit/92caa452b4a6d6f86c903548b40f8207a0ed11d0))
91
+
92
+
93
+
94
+ * @applitools/ec-client bumped to 1.10.16
95
+
96
+
3
97
  ## [4.40.0](https://github.com/Applitools-Dev/sdk/compare/js/core@4.39.3...js/core@4.40.0) (2025-06-15)
4
98
 
5
99
 
@@ -35,6 +35,7 @@ const extract_default_environment_1 = require("./utils/extract-default-environme
35
35
  const verify_environment_info_1 = require("./utils/verify-environment-info");
36
36
  const abort_controller_1 = require("abort-controller");
37
37
  const utils = __importStar(require("@applitools/utils"));
38
+ const register_default_scripts_1 = require("./utils/register-default-scripts");
38
39
  function makeOpenEyes({ core, spec, logger: mainLogger }) {
39
40
  return async function openEyes({ target, settings, storage = new Map(), logger = mainLogger, }) {
40
41
  var _a, _b, _c, _d;
@@ -52,6 +53,9 @@ function makeOpenEyes({ core, spec, logger: mainLogger }) {
52
53
  }
53
54
  }
54
55
  const environments = await (0, extract_default_environment_1.extractDefaultEnvironments)({ driver });
56
+ if (utils.general.getEnvValue('REGISTER_SCRIPTS_ON_NEW_DOCUMENT', 'boolean') === true) {
57
+ await (0, register_default_scripts_1.registerDefaultScripts)({ driver, logger });
58
+ }
55
59
  const controller = new abort_controller_1.AbortController();
56
60
  const { signal } = controller;
57
61
  const account = await core.getAccountInfo({ settings, logger });
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.registerDefaultScripts = void 0;
4
+ const capture_canvas_image_always_1 = require("../../utils/capture-canvas-image-always");
5
+ const utils_1 = require("@applitools/utils");
6
+ function wrapFunctionAsIIFE(fn) {
7
+ return `(()=>{ ${fn.toString()} return ${fn.name}.call()})()`;
8
+ }
9
+ async function registerDefaultScripts({ driver, logger, }) {
10
+ if (!driver)
11
+ return [];
12
+ try {
13
+ const captureImagesScript = wrapFunctionAsIIFE(capture_canvas_image_always_1.captureImagesFunc);
14
+ const scripts = [];
15
+ if (utils_1.general.getEnvValue('CAPTURE_CANVAS_WITH_WEBGL', 'boolean') === true) {
16
+ scripts.push({ name: 'captureImagesScript', code: captureImagesScript });
17
+ }
18
+ await scripts.forEach(async (script) => {
19
+ logger.info('running user script', script.name);
20
+ await driver.addScriptToEvaluateOnNewDocument(script.code);
21
+ });
22
+ return scripts;
23
+ }
24
+ catch (error) {
25
+ logger.error(error);
26
+ return [];
27
+ }
28
+ }
29
+ exports.registerDefaultScripts = registerDefaultScripts;
@@ -157,6 +157,9 @@ function makeSpec({ socket, spec, }) {
157
157
  async executeUserFunction(userFunction) {
158
158
  return socket.request('Driver.executeUserFunction', userFunction);
159
159
  },
160
+ async executeBrowserCommands(driver, commands) {
161
+ return socket.request('Driver.executeBrowserCommands', { driver, commands });
162
+ },
160
163
  };
161
164
  // add default commands to spec (if not already there) such as `isUserFunction`
162
165
  spec = addDefaultCommands(spec);
@@ -0,0 +1,82 @@
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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@applitools/core",
3
- "version": "4.40.0",
3
+ "version": "4.41.0",
4
4
  "homepage": "https://applitools.com",
5
5
  "bugs": {
6
6
  "url": "https://github.com/applitools/eyes.sdk.javascript1/issues"
@@ -47,14 +47,14 @@
47
47
  "build:bin": "yarn build && sea",
48
48
  "build:bin:zip": "zip -j ./bin/core.zip $(find ./bin -type f -not -name '*.zip' -not -name '*.tar.gz' | xargs)",
49
49
  "build:bin:tgz": "tar -czf ./bin/core.tar.gz $(find ./bin -type f -not -name '*.zip' -not -name '*.tar.gz' | xargs)",
50
- "test": "run --top-level mocha './test/**/*.spec.ts' --exclude './test/bin/**' --parallel --jobs ${MOCHA_JOBS:-15} --exit",
50
+ "test": "run --top-level mocha './test/**/*.spec.ts' --exclude './test/bin/**' --parallel --jobs ${MOCHA_JOBS:-15} --exit --require ./test/mocha-global-setup.js",
51
51
  "test:local": "MOCHA_OMIT_TAGS=sauce,browserstack run test",
52
52
  "test:sauce": "MOCHA_ONLY_TAGS=sauce,browserstack run test",
53
- "test:bin": "MOCHA_GROUP=bin run --top-level mocha './test/bin/**/*.spec.ts' --parallel --jobs ${MOCHA_JOBS:-15}",
54
- "test:e2e": "MOCHA_GROUP=e2e run --top-level mocha './test/e2e/**/*.spec.ts' --parallel --jobs ${MOCHA_JOBS:-15} --exit",
55
- "test:it": "MOCHA_GROUP=it run --top-level mocha './test/it/**/*.spec.ts'",
56
- "test:unit": "MOCHA_GROUP=unit run --top-level mocha './test/unit/**/*.spec.ts'",
57
- "setup": "run --top-level browsers:setup",
53
+ "test:bin": "MOCHA_GROUP=bin run --top-level mocha './test/bin/**/*.spec.ts' --parallel --jobs ${MOCHA_JOBS:-15} --require ./test/mocha-global-setup.js",
54
+ "test:e2e": "MOCHA_GROUP=e2e run --top-level mocha './test/e2e/**/*.spec.ts' --parallel --jobs ${MOCHA_JOBS:-15} --exit --require ./test/mocha-global-setup.js",
55
+ "test:it": "MOCHA_GROUP=it run --top-level mocha './test/it/**/*.spec.ts' --require ./test/mocha-global-setup.js",
56
+ "test:unit": "MOCHA_GROUP=unit run --top-level mocha './test/unit/**/*.spec.ts' --require ./test/mocha-global-setup.js",
57
+ "setup": "run --top-level browsers:setup && run --top-level xvfb:setup",
58
58
  "setup:standalone": "sh -c 'yarn chromedriver --port=4444 --verbose &'"
59
59
  },
60
60
  "sea": {
@@ -75,20 +75,20 @@
75
75
  }
76
76
  },
77
77
  "dependencies": {
78
- "@applitools/core-base": "1.25.4",
78
+ "@applitools/core-base": "1.25.5",
79
79
  "@applitools/dom-capture": "11.5.6",
80
- "@applitools/dom-snapshot": "4.11.22",
81
- "@applitools/driver": "1.21.4",
82
- "@applitools/ec-client": "1.10.15",
83
- "@applitools/logger": "2.1.4",
84
- "@applitools/nml-client": "1.9.5",
85
- "@applitools/req": "1.7.13",
86
- "@applitools/screenshoter": "3.11.5",
80
+ "@applitools/dom-snapshot": "4.12.0",
81
+ "@applitools/driver": "1.22.0",
82
+ "@applitools/ec-client": "1.10.16",
83
+ "@applitools/logger": "2.1.5",
84
+ "@applitools/nml-client": "1.9.6",
85
+ "@applitools/req": "1.7.14",
86
+ "@applitools/screenshoter": "3.11.6",
87
87
  "@applitools/snippets": "2.6.5",
88
- "@applitools/socket": "1.2.5",
89
- "@applitools/spec-driver-webdriver": "1.2.6",
90
- "@applitools/ufg-client": "1.16.12",
91
- "@applitools/utils": "1.8.2",
88
+ "@applitools/socket": "1.2.6",
89
+ "@applitools/spec-driver-webdriver": "1.3.0",
90
+ "@applitools/ufg-client": "1.16.13",
91
+ "@applitools/utils": "1.9.0",
92
92
  "@types/ws": "8.5.5",
93
93
  "abort-controller": "3.0.0",
94
94
  "chalk": "4.1.2",
@@ -102,11 +102,11 @@
102
102
  "devDependencies": {
103
103
  "@applitools/bongo": "^5.10.0",
104
104
  "@applitools/sea": "^1.0.0",
105
- "@applitools/spec-driver-puppeteer": "^1.4.30",
106
- "@applitools/spec-driver-selenium": "^1.5.101",
105
+ "@applitools/spec-driver-puppeteer": "^1.5.0",
106
+ "@applitools/spec-driver-selenium": "^1.6.0",
107
107
  "@applitools/test-server": "^1.2.3",
108
108
  "@applitools/test-utils": "^1.5.17",
109
- "@applitools/tunnel-client": "^1.8.0",
109
+ "@applitools/tunnel-client": "^1.8.1",
110
110
  "@types/mocha": "^10.0.7",
111
111
  "@types/node": "^12.20.55",
112
112
  "@types/selenium-webdriver": "^4.1.2",
@@ -116,7 +116,7 @@
116
116
  "crypto": "^1.0.1",
117
117
  "nock": "^13.3.2",
118
118
  "png-async": "^0.9.4",
119
- "puppeteer": "^19.11.1",
119
+ "puppeteer": "^24.11.1",
120
120
  "selenium-webdriver": "^4.15.0"
121
121
  },
122
122
  "engines": {
@@ -46,6 +46,10 @@ export type ExactEnvironment = BaseCore.Environment & {
46
46
  fallbackBaselineId?: string;
47
47
  };
48
48
  export type Environment = RenderEnvironment | ExactEnvironment;
49
+ export type Script = {
50
+ name: string;
51
+ code: string;
52
+ };
49
53
  export interface Core<TSpec extends SpecType> extends Omit<BaseCore.Core, 'openEyes'> {
50
54
  readonly base: BaseCore.Core;
51
55
  getViewportSize?(options: {
@@ -0,0 +1,7 @@
1
+ import type { Script } from '../types';
2
+ import { type SpecType, type Driver } from '@applitools/driver';
3
+ import { type Logger } from '@applitools/logger';
4
+ export declare function registerDefaultScripts<TSpec extends SpecType>({ driver, logger, }: {
5
+ driver?: Driver<TSpec>;
6
+ logger: Logger;
7
+ }): Promise<Script[]>;
@@ -194,5 +194,9 @@ export interface UniversalSpecDriver<T extends SpecType> {
194
194
  }): Promise<void>;
195
195
  isUserFunction(ref: any): Promise<boolean>;
196
196
  executeUserFunction(userFunction: Ref): Promise<any>;
197
+ executeBrowserCommands(options: {
198
+ driver?: T['driver'];
199
+ commands: any[];
200
+ }): Promise<any>;
197
201
  }
198
202
  export {};
@@ -0,0 +1 @@
1
+ export declare function captureImagesFunc(): void;