@applitools/eyes-browser 1.4.7 → 1.4.8

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,55 @@
1
1
  # Changelog
2
2
 
3
+ ## [1.4.8](https://github.com/Applitools-Dev/sdk/compare/js/eyes-browser@1.4.7...js/eyes-browser@1.4.8) (2024-07-23)
4
+
5
+
6
+ ### Dependencies
7
+
8
+ * @applitools/driver bumped to 1.18.0
9
+ #### Features
10
+
11
+ * disable broker url cache ([#2428](https://github.com/Applitools-Dev/sdk/issues/2428)) ([cb8d5fe](https://github.com/Applitools-Dev/sdk/commit/cb8d5fefb13d3ab42984d2bd4d4ac3d4e10646b0))
12
+
13
+
14
+ #### Bug Fixes
15
+
16
+ * executing web script on mobile environment ([#2380](https://github.com/Applitools-Dev/sdk/issues/2380)) ([da2e551](https://github.com/Applitools-Dev/sdk/commit/da2e551e01082d3cc21b9da5b43e6680233c080d))
17
+ * @applitools/ufg-client bumped to 1.12.3
18
+ #### Bug Fixes
19
+
20
+ * update makeUploadResource to include apiKey in the cache key ([#2411](https://github.com/Applitools-Dev/sdk/issues/2411)) ([4114c58](https://github.com/Applitools-Dev/sdk/commit/4114c58ec16fa855374b23810cef1e36d4bb53a7))
21
+
22
+
23
+ #### Performance Improvements
24
+
25
+ * trim file content when logging it ([#2437](https://github.com/Applitools-Dev/sdk/issues/2437)) ([02ec1f7](https://github.com/Applitools-Dev/sdk/commit/02ec1f79a323af2e89a7428b75212707c761d1ca))
26
+ * @applitools/core bumped to 4.18.0
27
+ #### Features
28
+
29
+ * disable broker url cache ([#2428](https://github.com/Applitools-Dev/sdk/issues/2428)) ([cb8d5fe](https://github.com/Applitools-Dev/sdk/commit/cb8d5fefb13d3ab42984d2bd4d4ac3d4e10646b0))
30
+
31
+
32
+
33
+ * @applitools/spec-driver-webdriver bumped to 1.1.11
34
+
35
+ * @applitools/spec-driver-selenium bumped to 1.5.82
36
+
37
+ * @applitools/spec-driver-puppeteer bumped to 1.4.11
38
+
39
+ * @applitools/screenshoter bumped to 3.8.35
40
+
41
+ * @applitools/nml-client bumped to 1.8.9
42
+
43
+ * @applitools/ec-client bumped to 1.9.3
44
+
45
+ * @applitools/eyes bumped to 1.22.0
46
+ #### Features
47
+
48
+ * disable broker url cache ([#2428](https://github.com/Applitools-Dev/sdk/issues/2428)) ([cb8d5fe](https://github.com/Applitools-Dev/sdk/commit/cb8d5fefb13d3ab42984d2bd4d4ac3d4e10646b0))
49
+
50
+
51
+
52
+
3
53
  ## [1.4.7](https://github.com/Applitools-Dev/sdk/compare/js/eyes-browser@1.4.6...js/eyes-browser@1.4.7) (2024-06-26)
4
54
 
5
55
 
package/dist/index.js CHANGED
@@ -32450,7 +32450,7 @@ var require_driver = __commonJS({
32450
32450
  await (scrollingElement === null || scrollingElement === void 0 ? void 0 : scrollingElement.refresh());
32451
32451
  return refreshThis;
32452
32452
  }
32453
- async refresh({ reset } = {}) {
32453
+ async refresh({ reset, name } = {}) {
32454
32454
  if (reset) {
32455
32455
  if (utils34.general.getEnvValue("AVOID_DRIVER_STATE_REST", "boolean")) {
32456
32456
  this._logger.log(`Skipping reset of the driver state`);
@@ -32463,6 +32463,9 @@ var require_driver = __commonJS({
32463
32463
  this._state = {};
32464
32464
  }
32465
32465
  }
32466
+ if (name === "NATIVE_APP") {
32467
+ return reset ? resetReference(this) : this;
32468
+ }
32466
32469
  const spec = this._spec;
32467
32470
  let currentContext = this.currentContext.target;
32468
32471
  let contextInfo;
@@ -32867,7 +32870,7 @@ var require_driver = __commonJS({
32867
32870
  }
32868
32871
  try {
32869
32872
  await this._spec.switchWorld(this.target, name);
32870
- await this.refresh({ reset: true });
32873
+ await this.refresh({ reset: true, name });
32871
32874
  } catch (error) {
32872
32875
  this._logger.error("Unable to switch world due to the error", error);
32873
32876
  throw new Error(`Unable to switch world, the original error was: ${error.message}`);
@@ -36096,12 +36099,16 @@ var require_get_nml_client = __commonJS({
36096
36099
  var nml_client_1 = require_dist5();
36097
36100
  var clients = /* @__PURE__ */ new Map();
36098
36101
  function makeGetNMLClient({ client, logger: mainLogger }) {
36099
- return async function getNMLClient({ driver, settings, logger }) {
36102
+ return {
36103
+ getNMLClient,
36104
+ clearNMLClientCache
36105
+ };
36106
+ async function getNMLClient({ driver, settings, logger }) {
36100
36107
  if (client)
36101
36108
  return client;
36102
36109
  logger = logger.extend(mainLogger);
36103
36110
  const { sessionId } = await driver.getDriverInfo();
36104
- const cacheKey = sessionId ? JSON.stringify({ sessionId, settings }) : JSON.stringify({ guid: driver.guid, settings });
36111
+ const cacheKey = sessionId !== null && sessionId !== void 0 ? sessionId : driver.guid;
36105
36112
  const clientFromCache = clients.get(cacheKey);
36106
36113
  if (clientFromCache) {
36107
36114
  return clientFromCache;
@@ -36113,7 +36120,12 @@ var require_get_nml_client = __commonJS({
36113
36120
  clients.set(cacheKey, nmlClient);
36114
36121
  return nmlClient;
36115
36122
  }
36116
- };
36123
+ }
36124
+ async function clearNMLClientCache(driver) {
36125
+ const { sessionId } = await driver.getDriverInfo();
36126
+ const cacheKey = sessionId !== null && sessionId !== void 0 ? sessionId : driver.guid;
36127
+ clients.delete(cacheKey);
36128
+ }
36117
36129
  }
36118
36130
  exports.makeGetNMLClient = makeGetNMLClient;
36119
36131
  }
@@ -37623,7 +37635,7 @@ var require_core2 = __commonJS({
37623
37635
  locate: (0, locate_1.makeLocate)({ spec, core, logger }),
37624
37636
  locateText: (0, locate_text_1.makeLocateText)({ spec, core, logger }),
37625
37637
  extractText: (0, extract_text_1.makeExtractText)({ spec, core, logger }),
37626
- getNMLClient: (0, get_nml_client_1.makeGetNMLClient)({ client: clients === null || clients === void 0 ? void 0 : clients.nml, logger }),
37638
+ ...(0, get_nml_client_1.makeGetNMLClient)({ client: clients === null || clients === void 0 ? void 0 : clients.nml, logger }),
37627
37639
  openEyes: (0, open_eyes_1.makeOpenEyes)({ spec, core, logger })
37628
37640
  };
37629
37641
  });
@@ -44472,6 +44484,7 @@ var require_req_ufg = __commonJS({
44472
44484
  exports.makeReqUFG = void 0;
44473
44485
  var req_1 = (init_dist(), __toCommonJS(dist_exports));
44474
44486
  var utils34 = __importStar(require_browser3());
44487
+ var buffer_1 = require_buffer();
44475
44488
  function makeReqUFG({ settings, logger }) {
44476
44489
  var _a;
44477
44490
  return (0, req_1.makeReq)({
@@ -44511,7 +44524,19 @@ var require_req_ufg = __commonJS({
44511
44524
  requestId = `${counter++}--${guid}`;
44512
44525
  request.headers.set("x-applitools-eyes-client-request-id", requestId);
44513
44526
  }
44514
- logger === null || logger === void 0 ? void 0 : logger.log(`Request "${options === null || options === void 0 ? void 0 : options.name}" [${requestId}] will be sent to the address "[${request.method}]${request.url}" with body`, options === null || options === void 0 ? void 0 : options.body);
44527
+ const { body, originalSize, isTrimmed } = trimBody();
44528
+ logger === null || logger === void 0 ? void 0 : logger.log(`Request "${options === null || options === void 0 ? void 0 : options.name}" [${requestId}] will be sent to the address "[${request.method}]${request.url}" with body${isTrimmed ? ` (trimmed from ${originalSize})` : ""}`, body);
44529
+ function trimBody() {
44530
+ if ((options === null || options === void 0 ? void 0 : options.body) instanceof buffer_1.Buffer || (options === null || options === void 0 ? void 0 : options.body) instanceof Uint8Array) {
44531
+ return {
44532
+ body: options.body.subarray(0, 10),
44533
+ originalSize: options.body.length,
44534
+ isTrimmed: options.body.length > 10
44535
+ };
44536
+ } else {
44537
+ return { body: options === null || options === void 0 ? void 0 : options.body };
44538
+ }
44539
+ }
44515
44540
  },
44516
44541
  beforeRetry({ request, attempt, error, response, options }) {
44517
44542
  var _a;
@@ -44737,7 +44762,7 @@ var require_requests3 = __commonJS({
44737
44762
  }
44738
44763
  async function checkResources({ resources, logger: logger2 = mainLogger }) {
44739
44764
  logger2 = logger2.extend(mainLogger, { tags: [`ufg-request-${utils34.general.shortid()}`] });
44740
- logger2.log('Request "checkResources" called for resources', resources);
44765
+ logger2.log('Request "checkResources" called for resources', resources.map(trimValueForResource));
44741
44766
  const response = await req2("./resources/query/resources-exist", {
44742
44767
  name: "checkResources",
44743
44768
  method: "POST",
@@ -44754,7 +44779,7 @@ var require_requests3 = __commonJS({
44754
44779
  }
44755
44780
  async function uploadResource({ resource, logger: logger2 = mainLogger }) {
44756
44781
  logger2 = logger2.extend(mainLogger, { tags: [`ufg-request-${utils34.general.shortid()}`] });
44757
- logger2.log('Request "uploadResource" called for resource', resource);
44782
+ logger2.log('Request "uploadResource" called for resource', trimValueForResource(resource));
44758
44783
  await req2(`./resources/sha256/${resource.hash.hash}`, {
44759
44784
  name: "uploadResource",
44760
44785
  method: "PUT",
@@ -44905,6 +44930,9 @@ var require_requests3 = __commonJS({
44905
44930
  }
44906
44931
  return pathSelector;
44907
44932
  }
44933
+ function trimValueForResource(resource) {
44934
+ return { ...resource, value: resource.value.subarray(0, 10) };
44935
+ }
44908
44936
  }
44909
44937
  });
44910
44938
 
@@ -84846,14 +84874,14 @@ var require_upload_resource = __commonJS({
84846
84874
  var logger_1 = require_browser6();
84847
84875
  var throat_1 = __importDefault(require_throat());
84848
84876
  var utils34 = __importStar(require_browser3());
84849
- function makeUploadResource({ requests, batchingTimeout = 300, concurrency = 100, logger: mainLogger }) {
84877
+ function makeUploadResource({ requests, batchingTimeout = 300, concurrency = 100, logger: mainLogger, apiKey }) {
84850
84878
  const uploadedResources = /* @__PURE__ */ new Set();
84851
84879
  const requestedResources = /* @__PURE__ */ new Map();
84852
84880
  const uploadResourceWithConcurrency = (0, throat_1.default)(concurrency, requests.uploadResource);
84853
84881
  const uploadResourceWithBatching = utils34.general.batchify(uploadResources, { timeout: batchingTimeout });
84854
84882
  return async function uploadResource({ resource, logger = mainLogger }) {
84855
84883
  logger = logger.extend(mainLogger, { tags: [`upload-resource-${utils34.general.shortid()}`] });
84856
- const hash = resource.hash.hash;
84884
+ const hash = resource.hash.hash + "_" + apiKey;
84857
84885
  if (uploadedResources.has(hash)) {
84858
84886
  return Promise.resolve();
84859
84887
  } else if (requestedResources.has(hash)) {
@@ -84884,6 +84912,9 @@ var require_upload_resource = __commonJS({
84884
84912
  uploadResourceWithConcurrency(options).then(resolve, reject);
84885
84913
  }
84886
84914
  });
84915
+ if (presentedResources.length !== batch.length) {
84916
+ throw new Error(`Unexpected number of presented resources - ${presentedResources.length} instead of ${batch.length}`);
84917
+ }
84887
84918
  } catch (err) {
84888
84919
  batch.forEach(([, { reject }]) => reject(err));
84889
84920
  }
@@ -84925,7 +84956,7 @@ var require_client2 = __commonJS({
84925
84956
  apiKey: settings.apiKey,
84926
84957
  logger
84927
84958
  });
84928
- const uploadResource = (0, upload_resource_1.makeUploadResource)({ requests, logger });
84959
+ const uploadResource = (0, upload_resource_1.makeUploadResource)({ requests, logger, apiKey: settings.apiKey });
84929
84960
  const processResources = (0, process_resources_1.makeProcessResources)({
84930
84961
  fetchResource,
84931
84962
  cache,
@@ -85900,7 +85931,7 @@ var require_core3 = __commonJS({
85900
85931
  locateText: (0, locate_text_1.makeLocateText)({ spec, core, logger }),
85901
85932
  extractText: (0, extract_text_1.makeExtractText)({ spec, core, logger }),
85902
85933
  getUFGClient: (0, get_ufg_client_1.makeGetUFGClient)({ client: clients === null || clients === void 0 ? void 0 : clients.ufg, fetchConcurrency, asyncCache, logger }),
85903
- getNMLClient: (0, get_nml_client_1.makeGetNMLClient)({ client: clients === null || clients === void 0 ? void 0 : clients.nml, logger }),
85934
+ ...(0, get_nml_client_1.makeGetNMLClient)({ client: clients === null || clients === void 0 ? void 0 : clients.nml, logger }),
85904
85935
  openEyes: (0, open_eyes_1.makeOpenEyes)({ spec, core, logger })
85905
85936
  };
85906
85937
  });
@@ -86767,6 +86798,9 @@ var require_open_eyes4 = __commonJS({
86767
86798
  },
86768
86799
  logger
86769
86800
  });
86801
+ if (settings.disableBrokerUrlCache && driver) {
86802
+ await core.clearNMLClientCache(driver);
86803
+ }
86770
86804
  const getTypedEyes = (0, get_typed_eyes_1.makeGetTypedEyes)({
86771
86805
  type,
86772
86806
  settings,
@@ -87283,7 +87317,7 @@ var require_package2 = __commonJS({
87283
87317
  "../core/package.json"(exports, module) {
87284
87318
  module.exports = {
87285
87319
  name: "@applitools/core",
87286
- version: "4.17.0",
87320
+ version: "4.18.0",
87287
87321
  homepage: "https://applitools.com",
87288
87322
  bugs: {
87289
87323
  url: "https://github.com/applitools/eyes.sdk.javascript1/issues"
@@ -87325,12 +87359,12 @@ var require_package2 = __commonJS({
87325
87359
  ],
87326
87360
  scripts: {
87327
87361
  lint: "run --top-level eslint '**/*.ts'",
87328
- build: "yarn build:dist",
87362
+ build: "yarn build:dist && yarn build:bin",
87363
+ "build:short": "yarn build:dist",
87329
87364
  "build:dist": "run --top-level tsc --project ./tsconfig.build.json",
87330
87365
  "build:bin": "sea",
87331
87366
  "build:bin:zip": "zip -j ./bin/core.zip $(find ./bin -type f -not -name '*.zip' -not -name '*.tar.gz' | xargs)",
87332
87367
  "build:bin:tgz": "tar -czf ./bin/core.tar.gz $(find ./bin -type f -not -name '*.zip' -not -name '*.tar.gz' | xargs)",
87333
- "build:full": "yarn build:dist && yarn build:bin",
87334
87368
  test: "run --top-level mocha './test/**/*.spec.ts' --exclude './test/bin/**' --parallel --jobs ${MOCHA_JOBS:-15} --exit",
87335
87369
  "test:local": "MOCHA_OMIT_TAGS=sauce run test",
87336
87370
  "test:sauce": "MOCHA_ONLY_TAGS=sauce run test",
@@ -87377,7 +87411,7 @@ var require_package2 = __commonJS({
87377
87411
  "node-fetch": "2.6.7",
87378
87412
  semver: "7.6.2",
87379
87413
  webdriver: "7.31.1",
87380
- ws: "8.13.0",
87414
+ ws: "8.17.1",
87381
87415
  yargs: "17.7.2"
87382
87416
  },
87383
87417
  devDependencies: {
@@ -87758,7 +87792,7 @@ var require_core4 = __commonJS({
87758
87792
  base,
87759
87793
  getViewportSize: spec && (0, get_viewport_size_1.makeGetViewportSize)({ spec, logger }),
87760
87794
  setViewportSize: spec && (0, set_viewport_size_1.makeSetViewportSize)({ spec, logger }),
87761
- getNMLClient: (0, get_nml_client_1.makeGetNMLClient)({ client: clients === null || clients === void 0 ? void 0 : clients.nml, logger }),
87795
+ ...(0, get_nml_client_1.makeGetNMLClient)({ client: clients === null || clients === void 0 ? void 0 : clients.nml, logger }),
87762
87796
  getECClient: (0, get_ec_client_1.makeGetECClient)({ logger }),
87763
87797
  getAccountInfo: (0, get_account_info_1.makeGetAccountInfo)({ core, logger }),
87764
87798
  // Note: `defaultBase` is passesd for `base`, and `cores` is not passed here on purpose, so that a manager will create its own base, which would apply the correct concurrency value that was passed to the manager.
@@ -91402,7 +91436,7 @@ var require_package3 = __commonJS({
91402
91436
  "../eyes/package.json"(exports, module) {
91403
91437
  module.exports = {
91404
91438
  name: "@applitools/eyes",
91405
- version: "1.21.0",
91439
+ version: "1.22.0",
91406
91440
  keywords: [
91407
91441
  "applitools",
91408
91442
  "eyes",
@@ -95007,6 +95041,19 @@ var ConfigurationData = class {
95007
95041
  this.dontCloseBatches = dontCloseBatches;
95008
95042
  return this;
95009
95043
  }
95044
+ get disableNMLUrlCache() {
95045
+ return this._config.disableNMLUrlCache;
95046
+ }
95047
+ set disableNMLUrlCache(disableNMLUrlCache) {
95048
+ this._config.disableNMLUrlCache = disableNMLUrlCache;
95049
+ }
95050
+ getDisableNMLUrlCache() {
95051
+ return this.disableNMLUrlCache;
95052
+ }
95053
+ setDisableNMLUrlCache(disableNMLUrlCache) {
95054
+ this.disableNMLUrlCache = disableNMLUrlCache;
95055
+ return this;
95056
+ }
95010
95057
  /** @internal */
95011
95058
  toObject() {
95012
95059
  return this._config;
@@ -95046,7 +95093,8 @@ var ConfigurationData = class {
95046
95093
  gitBranchingTimestamp: this.gitMergeBaseTimestamp,
95047
95094
  ignoreGitBranching: this.ignoreGitMergeBase,
95048
95095
  saveDiffs: this.saveDiffs,
95049
- keepBatchOpen: this.dontCloseBatches
95096
+ keepBatchOpen: this.dontCloseBatches,
95097
+ disableBrokerUrlCache: this.disableNMLUrlCache
95050
95098
  }),
95051
95099
  screenshot: utils20.general.removeUndefinedProps({
95052
95100
  fully: this.forceFullPageScreenshot,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@applitools/eyes-browser",
3
- "version": "1.4.7",
3
+ "version": "1.4.8",
4
4
  "keywords": [
5
5
  "applitools",
6
6
  "browser",
@@ -48,7 +48,7 @@
48
48
  "test": "run --top-level mocha './test/**/*.spec.ts'"
49
49
  },
50
50
  "dependencies": {
51
- "@applitools/eyes": "1.21.0"
51
+ "@applitools/eyes": "1.22.0"
52
52
  },
53
53
  "devDependencies": {
54
54
  "@types/node": "^12.20.55",
@@ -84,6 +84,7 @@ export type Configuration<TSpec extends Core.SpecType = Core.SpecType> = {
84
84
  };
85
85
  disableBrowserFetching?: boolean;
86
86
  waitBeforeCapture?: number;
87
+ disableNMLUrlCache?: boolean;
87
88
  };
88
89
  export declare class ConfigurationData<TSpec extends Core.SpecType = Core.SpecType> implements Required<Configuration<TSpec>> {
89
90
  protected static readonly _spec: Core.SpecDriver<Core.SpecType>;
@@ -379,6 +380,10 @@ export declare class ConfigurationData<TSpec extends Core.SpecType = Core.SpecTy
379
380
  getDontCloseBatches(): boolean;
380
381
  /** @undocumented */
381
382
  setDontCloseBatches(dontCloseBatches: boolean): this;
383
+ get disableNMLUrlCache(): boolean;
384
+ set disableNMLUrlCache(disableNMLUrlCache: boolean);
385
+ getDisableNMLUrlCache(): boolean;
386
+ setDisableNMLUrlCache(disableNMLUrlCache: boolean): this;
382
387
  /** @internal */
383
388
  toObject(): Configuration<TSpec>;
384
389
  /** @internal */