@appium/support 7.0.4 → 7.0.6

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.
Files changed (113) hide show
  1. package/build/lib/console.d.ts +42 -88
  2. package/build/lib/console.d.ts.map +1 -1
  3. package/build/lib/console.js +25 -85
  4. package/build/lib/console.js.map +1 -1
  5. package/build/lib/doctor.d.ts +6 -18
  6. package/build/lib/doctor.d.ts.map +1 -1
  7. package/build/lib/doctor.js +0 -15
  8. package/build/lib/doctor.js.map +1 -1
  9. package/build/lib/env.d.ts +14 -20
  10. package/build/lib/env.d.ts.map +1 -1
  11. package/build/lib/env.js +24 -61
  12. package/build/lib/env.js.map +1 -1
  13. package/build/lib/fs.d.ts +109 -148
  14. package/build/lib/fs.d.ts.map +1 -1
  15. package/build/lib/fs.js +130 -230
  16. package/build/lib/fs.js.map +1 -1
  17. package/build/lib/image-util.d.ts +7 -6
  18. package/build/lib/image-util.d.ts.map +1 -1
  19. package/build/lib/image-util.js +9 -6
  20. package/build/lib/image-util.js.map +1 -1
  21. package/build/lib/index.d.ts +19 -17
  22. package/build/lib/index.d.ts.map +1 -1
  23. package/build/lib/logger.d.ts +1 -1
  24. package/build/lib/logger.d.ts.map +1 -1
  25. package/build/lib/logger.js +1 -1
  26. package/build/lib/logger.js.map +1 -1
  27. package/build/lib/logging.d.ts +7 -15
  28. package/build/lib/logging.d.ts.map +1 -1
  29. package/build/lib/logging.js +36 -62
  30. package/build/lib/logging.js.map +1 -1
  31. package/build/lib/mjpeg.d.ts +19 -56
  32. package/build/lib/mjpeg.d.ts.map +1 -1
  33. package/build/lib/mjpeg.js +55 -78
  34. package/build/lib/mjpeg.js.map +1 -1
  35. package/build/lib/mkdirp.d.ts +4 -1
  36. package/build/lib/mkdirp.d.ts.map +1 -1
  37. package/build/lib/mkdirp.js +1 -2
  38. package/build/lib/mkdirp.js.map +1 -1
  39. package/build/lib/net.d.ts +52 -90
  40. package/build/lib/net.d.ts.map +1 -1
  41. package/build/lib/net.js +104 -193
  42. package/build/lib/net.js.map +1 -1
  43. package/build/lib/node.d.ts +16 -17
  44. package/build/lib/node.d.ts.map +1 -1
  45. package/build/lib/node.js +115 -120
  46. package/build/lib/node.js.map +1 -1
  47. package/build/lib/npm.d.ts +65 -86
  48. package/build/lib/npm.d.ts.map +1 -1
  49. package/build/lib/npm.js +64 -122
  50. package/build/lib/npm.js.map +1 -1
  51. package/build/lib/plist.d.ts +36 -29
  52. package/build/lib/plist.d.ts.map +1 -1
  53. package/build/lib/plist.js +62 -59
  54. package/build/lib/plist.js.map +1 -1
  55. package/build/lib/process.d.ts +19 -2
  56. package/build/lib/process.d.ts.map +1 -1
  57. package/build/lib/process.js +24 -7
  58. package/build/lib/process.js.map +1 -1
  59. package/build/lib/system.d.ts +41 -6
  60. package/build/lib/system.d.ts.map +1 -1
  61. package/build/lib/system.js +49 -14
  62. package/build/lib/system.js.map +1 -1
  63. package/build/lib/tempdir.d.ts +26 -49
  64. package/build/lib/tempdir.d.ts.map +1 -1
  65. package/build/lib/tempdir.js +46 -78
  66. package/build/lib/tempdir.js.map +1 -1
  67. package/build/lib/timing.d.ts +28 -22
  68. package/build/lib/timing.d.ts.map +1 -1
  69. package/build/lib/timing.js +16 -17
  70. package/build/lib/timing.js.map +1 -1
  71. package/build/lib/util.d.ts +164 -181
  72. package/build/lib/util.d.ts.map +1 -1
  73. package/build/lib/util.js +198 -253
  74. package/build/lib/util.js.map +1 -1
  75. package/build/lib/zip.d.ts +81 -139
  76. package/build/lib/zip.d.ts.map +1 -1
  77. package/build/lib/zip.js +235 -283
  78. package/build/lib/zip.js.map +1 -1
  79. package/lib/console.ts +139 -0
  80. package/lib/{doctor.js → doctor.ts} +6 -20
  81. package/lib/{env.js → env.ts} +34 -62
  82. package/lib/fs.ts +453 -0
  83. package/lib/image-util.ts +40 -0
  84. package/lib/index.ts +1 -0
  85. package/lib/{logger.js → logger.ts} +1 -1
  86. package/lib/logging.ts +157 -0
  87. package/lib/mjpeg.ts +186 -0
  88. package/lib/{mkdirp.js → mkdirp.ts} +2 -2
  89. package/lib/net.ts +305 -0
  90. package/lib/{node.js → node.ts} +136 -135
  91. package/lib/npm.ts +291 -0
  92. package/lib/plist.ts +187 -0
  93. package/lib/process.ts +62 -0
  94. package/lib/system.ts +95 -0
  95. package/lib/tempdir.ts +115 -0
  96. package/lib/{timing.js → timing.ts} +28 -33
  97. package/lib/util.ts +561 -0
  98. package/lib/{zip.js → zip.ts} +344 -299
  99. package/package.json +24 -26
  100. package/tsconfig.json +3 -5
  101. package/index.js +0 -1
  102. package/lib/console.js +0 -173
  103. package/lib/fs.js +0 -496
  104. package/lib/image-util.js +0 -32
  105. package/lib/logging.js +0 -145
  106. package/lib/mjpeg.js +0 -207
  107. package/lib/net.js +0 -336
  108. package/lib/npm.js +0 -310
  109. package/lib/plist.js +0 -182
  110. package/lib/process.js +0 -46
  111. package/lib/system.js +0 -48
  112. package/lib/tempdir.js +0 -131
  113. package/lib/util.js +0 -585
@@ -4,7 +4,7 @@ exports.requireSharp = requireSharp;
4
4
  exports.cropBase64Image = cropBase64Image;
5
5
  let _sharp;
6
6
  /**
7
- * @returns {import('sharp')}
7
+ * @returns The sharp module for image processing
8
8
  */
9
9
  function requireSharp() {
10
10
  if (!_sharp) {
@@ -12,9 +12,10 @@ function requireSharp() {
12
12
  _sharp = require('sharp');
13
13
  }
14
14
  catch (err) {
15
+ const message = err instanceof Error ? err.message : String(err);
15
16
  throw new Error(`Cannot load the 'sharp' module needed for images processing. ` +
16
17
  `Consider visiting https://sharp.pixelplumbing.com/install ` +
17
- `for troubleshooting. Original error: ${err.message}`);
18
+ `for troubleshooting. Original error: ${message}`);
18
19
  }
19
20
  }
20
21
  return _sharp;
@@ -22,13 +23,15 @@ function requireSharp() {
22
23
  /**
23
24
  * Crop the image by given rectangle (use base64 string as input and output)
24
25
  *
25
- * @param {string} base64Image The string with base64 encoded image.
26
+ * @param base64Image The string with base64 encoded image.
26
27
  * Supports all image formats natively supported by Sharp library.
27
- * @param {import('sharp').Region} rect The selected region of image
28
- * @return {Promise<string>} base64 encoded string of cropped image
28
+ * @param rect The selected region of image
29
+ * @returns base64 encoded string of cropped image
29
30
  */
30
31
  async function cropBase64Image(base64Image, rect) {
31
- const buf = await requireSharp()(Buffer.from(base64Image, 'base64')).extract(rect).toBuffer();
32
+ const buf = await requireSharp()(Buffer.from(base64Image, 'base64'))
33
+ .extract(rect)
34
+ .toBuffer();
32
35
  return buf.toString('base64');
33
36
  }
34
37
  //# sourceMappingURL=image-util.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"image-util.js","sourceRoot":"","sources":["../../lib/image-util.js"],"names":[],"mappings":";;AAKA,oCAaC;AAUD,0CAGC;AA/BD,IAAI,MAAM,CAAC;AAEX;;GAEG;AACH,SAAgB,YAAY;IAC1B,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,IAAI,CAAC;YACH,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;QAC5B,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,MAAM,IAAI,KAAK,CACb,+DAA+D;gBAC/D,4DAA4D;gBAC5D,wCAAwC,GAAG,CAAC,OAAO,EAAE,CACtD,CAAC;QACJ,CAAC;IACH,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;;;;;;GAOG;AACI,KAAK,UAAU,eAAe,CAAC,WAAW,EAAE,IAAI;IACrD,MAAM,GAAG,GAAG,MAAM,YAAY,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,CAAC;IAC9F,OAAO,GAAG,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;AAChC,CAAC"}
1
+ {"version":3,"file":"image-util.js","sourceRoot":"","sources":["../../lib/image-util.ts"],"names":[],"mappings":";;AAOA,oCAcC;AAUD,0CAQC;AArCD,IAAI,MAAgC,CAAC;AAErC;;GAEG;AACH,SAAgB,YAAY;IAC1B,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,IAAI,CAAC;YACH,MAAM,GAAG,OAAO,CAAC,OAAO,CAAiB,CAAC;QAC5C,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,MAAM,OAAO,GAAG,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;YACjE,MAAM,IAAI,KAAK,CACb,+DAA+D;gBAC7D,4DAA4D;gBAC5D,wCAAwC,OAAO,EAAE,CACpD,CAAC;QACJ,CAAC;IACH,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;;;;;;GAOG;AACI,KAAK,UAAU,eAAe,CACnC,WAAmB,EACnB,IAAkB;IAElB,MAAM,GAAG,GAAG,MAAM,YAAY,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC;SACjE,OAAO,CAAC,IAAI,CAAC;SACb,QAAQ,EAAE,CAAC;IACd,OAAO,GAAG,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;AAChC,CAAC"}
@@ -23,36 +23,38 @@ declare const _default: {
23
23
  system: typeof system;
24
24
  util: typeof util;
25
25
  fs: {
26
- hasAccess(path: PathLike): Promise<boolean>;
27
- isExecutable(path: PathLike): Promise<boolean>;
28
- exists(path: PathLike): Promise<boolean>;
29
- rimraf(filepath: PathLike): Promise<void>;
30
- rimrafSync(filepath: PathLike): void;
26
+ hasAccess(filePath: import("fs").PathLike): Promise<boolean>;
27
+ isExecutable(filePath: import("fs").PathLike): Promise<boolean>;
28
+ exists(filePath: import("fs").PathLike): Promise<boolean>;
29
+ rimraf(filepath: import("fs").PathLike): Promise<void>;
30
+ rimrafSync(filepath: import("fs").PathLike): void;
31
31
  mkdir(filepath: string | Buffer | URL, opts?: import("fs").MakeDirectoryOptions): Promise<string | undefined>;
32
32
  copyFile(source: string, destination: string, opts?: import("ncp").Options): Promise<void>;
33
- md5(filePath: PathLike): Promise<string>;
34
- mv(from: string, to: string, opts?: mv): Promise<void>;
33
+ md5(filePath: import("fs").PathLike): Promise<string>;
34
+ mv(from: string, to: string, opts?: import("./fs").MvOptions): Promise<void>;
35
35
  which: typeof import("which");
36
- glob: (pattern: string, opts?: import("glob").GlobOptions) => import("bluebird")<string[]>;
36
+ glob(pattern: string, options?: import("glob/raw").GlobOptions): Promise<string[]>;
37
37
  sanitizeName: typeof import("sanitize-filename");
38
- hash(filePath: PathLike, algorithm?: string): Promise<string>;
38
+ hash(filePath: import("fs").PathLike, algorithm?: string): Promise<string>;
39
39
  walk(dir: string, opts?: import("klaw").Options): import("klaw").Walker;
40
- mkdirp(dir: PathLike): Promise<string | undefined>;
41
- walkDir(dir: string, recursive: boolean, callback: WalkDirCallback): Promise<string | null>;
42
- readPackageJsonFrom(dir: string, opts?: import("read-pkg").Options): import("read-pkg").NormalizedPackageJson;
40
+ mkdirp(dir: import("fs").PathLike): Promise<string | undefined>;
41
+ walkDir(dir: string, recursive: boolean, callback: import("./fs").WalkDirCallback): Promise<string | null>;
42
+ readPackageJsonFrom(dir: string, opts?: import("read-pkg", { with: { "resolution-mode": "import" } }).NormalizeOptions & {
43
+ cwd?: string;
44
+ }): import("read-pkg", { with: { "resolution-mode": "import" } }).NormalizedPackageJson;
43
45
  findRoot(dir: string): string;
44
46
  access: typeof import("fs/promises").access;
45
47
  appendFile: typeof import("fs/promises").appendFile;
46
48
  chmod: typeof import("fs/promises").chmod;
47
- close: (arg1: number) => import("bluebird")<any>;
49
+ close: typeof import("fs").close.__promisify__;
48
50
  constants: typeof import("fs").constants;
49
51
  createWriteStream: typeof import("fs").createWriteStream;
50
52
  createReadStream: typeof import("fs").createReadStream;
51
53
  lstat: typeof import("fs/promises").lstat;
52
- open: (path: import("./fs").PathLike, flags: import("fs").OpenMode, mode?: import("fs").Mode) => Promise<number>;
54
+ open: typeof import("fs").open.__promisify__;
53
55
  openFile: typeof import("fs/promises").open;
54
56
  readdir: typeof import("fs/promises").readdir;
55
- read: import("./fs").ReadFn<NodeJS.ArrayBufferView>;
57
+ read: typeof import("fs").read.__promisify__;
56
58
  readFile: typeof import("fs/promises").readFile;
57
59
  readlink: typeof import("fs/promises").readlink;
58
60
  realpath: typeof import("fs/promises").realpath;
@@ -69,7 +71,7 @@ declare const _default: {
69
71
  };
70
72
  cancellableDelay: typeof util.cancellableDelay;
71
73
  plist: typeof plist;
72
- mkdirp: (dir: PathLike) => Promise<string | undefined>;
74
+ mkdirp: (dir: import("fs").PathLike) => Promise<string | undefined>;
73
75
  logger: typeof logger;
74
76
  process: typeof process;
75
77
  zip: typeof zip;
@@ -85,7 +87,7 @@ declare const _default: {
85
87
  export default _default;
86
88
  export type { ConsoleOpts } from './console';
87
89
  export type { ReadFn, WalkDirCallback } from './fs';
88
- export type { NetOptions, DownloadOptions, AuthCredentials, NotHttpUploadOptions, HttpUploadOptions, } from './net';
90
+ export type { NetOptions, DownloadOptions, AuthCredentials, FtpUploadOptions, NotHttpUploadOptions, HttpUploadOptions, } from './net';
89
91
  export type { InstallPackageOpts, ExecOpts, NpmInstallReceipt } from './npm';
90
92
  export type { Affixes, OpenedAffixes } from './tempdir';
91
93
  export type { PluralizeOptions, EncodingOptions, LockFileOptions, NonEmptyString } from './util';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../lib/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,WAAW,CAAC;AACrC,OAAO,KAAK,MAAM,MAAM,UAAU,CAAC;AACnC,OAAO,KAAK,IAAI,MAAM,QAAQ,CAAC;AAC/B,OAAO,EAAC,EAAE,EAAC,MAAM,MAAM,CAAC;AACxB,OAAO,KAAK,GAAG,MAAM,OAAO,CAAC;AAC7B,OAAO,KAAK,KAAK,MAAM,SAAS,CAAC;AACjC,OAAO,EAAC,MAAM,EAAC,MAAM,UAAU,CAAC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L,IAAI,EACJ,MAAM,EACN,GAAG,EACH,OAAO,EACP,MAAM,GACP,CAAC;;;;;;;;;;;;;;;;;;;;;;;eA0C8zT,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAzCj0T,wBAmBE;AAEF,YAAY,EAAC,WAAW,EAAC,MAAM,WAAW,CAAC;AAC3C,YAAY,EAAC,MAAM,EAAE,eAAe,EAAC,MAAM,MAAM,CAAC;AAClD,YAAY,EACV,UAAU,EACV,eAAe,EACf,eAAe,EACf,gBAAgB,EAChB,oBAAoB,EACpB,iBAAiB,GAClB,MAAM,OAAO,CAAC;AACf,YAAY,EAAC,kBAAkB,EAAE,QAAQ,EAAE,iBAAiB,EAAC,MAAM,OAAO,CAAC;AAC3E,YAAY,EAAC,OAAO,EAAE,aAAa,EAAC,MAAM,WAAW,CAAC;AACtD,YAAY,EAAC,gBAAgB,EAAE,eAAe,EAAE,eAAe,EAAE,cAAc,EAAC,MAAM,QAAQ,CAAC;AAC/F,YAAY,EACV,iBAAiB,EACjB,QAAQ,EACR,UAAU,EACV,qBAAqB,EACrB,gBAAgB,GACjB,MAAM,OAAO,CAAC"}
@@ -1,3 +1,3 @@
1
+ declare const log: import("../../types/build/lib").AppiumLogger;
1
2
  export default log;
2
- declare let log: import("../../types/build/lib").AppiumLogger;
3
3
  //# sourceMappingURL=logger.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../lib/logger.js"],"names":[],"mappings":";AAEA,8DAA+B"}
1
+ {"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../lib/logger.ts"],"names":[],"mappings":"AAEA,QAAA,MAAM,GAAG,8CAAuB,CAAC;AAEjC,eAAe,GAAG,CAAC"}
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const logging_1 = require("./logging");
4
- let log = (0, logging_1.getLogger)('Support');
4
+ const log = (0, logging_1.getLogger)('Support');
5
5
  exports.default = log;
6
6
  //# sourceMappingURL=logger.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"logger.js","sourceRoot":"","sources":["../../lib/logger.js"],"names":[],"mappings":";;AAAA,uCAAoC;AAEpC,IAAI,GAAG,GAAG,IAAA,mBAAS,EAAC,SAAS,CAAC,CAAC;AAE/B,kBAAe,GAAG,CAAC"}
1
+ {"version":3,"file":"logger.js","sourceRoot":"","sources":["../../lib/logger.ts"],"names":[],"mappings":";;AAAA,uCAAoC;AAEpC,MAAM,GAAG,GAAG,IAAA,mBAAS,EAAC,SAAS,CAAC,CAAC;AAEjC,kBAAe,GAAG,CAAC"}
@@ -1,9 +1,11 @@
1
+ import type { AppiumLogger, AppiumLoggerLevel, AppiumLoggerPrefix } from '@appium/types';
2
+ export declare const LEVELS: readonly AppiumLoggerLevel[];
3
+ export declare const log: AppiumLogger;
1
4
  /**
2
- *
3
- * @param {AppiumLoggerPrefix?} [prefix=null]
4
- * @returns {AppiumLogger}
5
+ * @param prefix - Optional log prefix
6
+ * @returns A wrapped Appium logger instance
5
7
  */
6
- export function getLogger(prefix?: AppiumLoggerPrefix | null): AppiumLogger;
8
+ export declare function getLogger(prefix?: AppiumLoggerPrefix | null): AppiumLogger;
7
9
  /**
8
10
  * Marks arbitrary log message as sensitive.
9
11
  * This message will then be replaced with the default replacer
@@ -12,19 +14,9 @@ export function getLogger(prefix?: AppiumLoggerPrefix | null): AppiumLogger;
12
14
  * The latter is enabled by the corresponding HTTP middleware
13
15
  * in response to the `X-Appium-Is-Sensitive` request header
14
16
  * being set to 'true'.
15
- *
16
- * @template {any} T
17
- * @param {T} logMessage
18
- * @returns {{[k: string]: T}}
19
17
  */
20
- export function markSensitive<T extends unknown>(logMessage: T): {
18
+ export declare function markSensitive<T>(logMessage: T): {
21
19
  [k: string]: T;
22
20
  };
23
- /** @type {import('@appium/types').AppiumLoggerLevel[]} */
24
- export const LEVELS: import("@appium/types").AppiumLoggerLevel[];
25
- export const log: import("@appium/types").AppiumLogger;
26
21
  export default log;
27
- export type AppiumLoggerPrefix = import("@appium/types").AppiumLoggerPrefix;
28
- export type AppiumLogger = import("@appium/types").AppiumLogger;
29
- export type AppiumLoggerLevel = import("@appium/types").AppiumLoggerLevel;
30
22
  //# sourceMappingURL=logging.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"logging.d.ts","sourceRoot":"","sources":["../../lib/logging.js"],"names":[],"mappings":"AAwBA;;;;GAIG;AACH,mCAHW,kBAAkB,OAAC,GACjB,YAAY,CAyDxB;AAED;;;;;;;;;;;;GAYG;AACH,8BAJmB,CAAC,8BACT,CAAC,GACC;IAAC,CAAC,CAAC,EAAE,MAAM,GAAG,CAAC,CAAA;CAAC,CAI5B;AAjGD,0DAA0D;AAC1D,qBADW,OAAO,eAAe,EAAE,iBAAiB,EAAE,CAC+B;AAiBrF,uDAA+B;;iCAuHlB,OAAO,eAAe,EAAE,kBAAkB;2BAC1C,OAAO,eAAe,EAAE,YAAY;gCACpC,OAAO,eAAe,EAAE,iBAAiB"}
1
+ {"version":3,"file":"logging.d.ts","sourceRoot":"","sources":["../../lib/logging.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,YAAY,EAEZ,iBAAiB,EACjB,kBAAkB,EACnB,MAAM,eAAe,CAAC;AAGvB,eAAO,MAAM,MAAM,EAAE,SAAS,iBAAiB,EAQ9C,CAAC;AAyBF,eAAO,MAAM,GAAG,cAAc,CAAC;AAE/B;;;GAGG;AACH,wBAAgB,SAAS,CAAC,MAAM,GAAE,kBAAkB,GAAG,IAAW,GAAG,YAAY,CA8DhF;AAED;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAAE,UAAU,EAAE,CAAC,GAAG;IAAC,CAAC,CAAC,EAAE,MAAM,GAAG,CAAC,CAAA;CAAC,CAEhE;AA8BD,eAAe,GAAG,CAAC"}
@@ -41,53 +41,49 @@ exports.getLogger = getLogger;
41
41
  exports.markSensitive = markSensitive;
42
42
  const logger_1 = __importStar(require("@appium/logger"));
43
43
  const lodash_1 = __importDefault(require("lodash"));
44
- const moment_1 = __importDefault(require("moment"));
45
- /** @type {import('@appium/types').AppiumLoggerLevel[]} */
46
- exports.LEVELS = ['silly', 'verbose', 'debug', 'info', 'http', 'warn', 'error'];
44
+ exports.LEVELS = [
45
+ 'silly',
46
+ 'verbose',
47
+ 'debug',
48
+ 'info',
49
+ 'http',
50
+ 'warn',
51
+ 'error',
52
+ ];
47
53
  const MAX_LOG_RECORDS_COUNT = 3000;
48
- const PREFIX_TIMESTAMP_FORMAT = 'HH-mm-ss:SSS';
54
+ const globalWithNpmlog = globalThis;
49
55
  // mock log object is used in testing mode to silence the output
50
56
  const MOCK_LOG = {
51
57
  unwrap: () => ({
52
- loadSecureValuesPreprocessingRules: () => ({
53
- issues: [],
54
- rules: [],
55
- }),
58
+ loadSecureValuesPreprocessingRules: () => Promise.resolve({ issues: [], rules: [] }),
56
59
  level: 'verbose',
57
60
  prefix: '',
58
61
  log: lodash_1.default.noop,
59
62
  }),
60
- ...(lodash_1.default.fromPairs(exports.LEVELS.map((l) => [l, lodash_1.default.noop]))),
63
+ ...lodash_1.default.fromPairs(exports.LEVELS.map((l) => [l, lodash_1.default.noop])),
61
64
  };
62
- // export a default logger with no prefix
63
65
  exports.log = getLogger();
64
66
  /**
65
- *
66
- * @param {AppiumLoggerPrefix?} [prefix=null]
67
- * @returns {AppiumLogger}
67
+ * @param prefix - Optional log prefix
68
+ * @returns A wrapped Appium logger instance
68
69
  */
69
70
  function getLogger(prefix = null) {
70
- const [logger, usingGlobalLog] = _getLogger();
71
- // wrap the logger so that we can catch and modify any logging
71
+ const { logger, defaultToVerbose } = _getLogger();
72
72
  const wrappedLogger = {
73
73
  unwrap: () => logger,
74
- levels: exports.LEVELS,
75
- prefix,
76
- errorWithException(/** @type {any[]} */ ...args) {
74
+ levels: [...exports.LEVELS],
75
+ prefix: prefix ?? undefined,
76
+ errorWithException(...args) {
77
77
  this.error(...args);
78
- // make sure we have an `Error` object. Wrap if necessary
79
78
  return lodash_1.default.isError(args[0]) ? args[0] : new Error(args.join('\n'));
80
79
  },
81
- errorAndThrow(/** @type {any[]} */ ...args) {
82
- throw this.errorWithException(args);
80
+ errorAndThrow(...args) {
81
+ throw this.errorWithException(...args);
83
82
  },
84
- updateAsyncContext(
85
- /** @type {import('@appium/types').AppiumLoggerContext} */ contextInfo, replace = false) {
86
- // Older Appium dependencies may not have 'updateAsyncStorage'
83
+ updateAsyncContext(contextInfo, replace = false) {
87
84
  this.unwrap().updateAsyncStorage?.(contextInfo, replace);
88
85
  },
89
86
  };
90
- // allow access to the level of the underlying logger
91
87
  Object.defineProperty(wrappedLogger, 'level', {
92
88
  get() {
93
89
  return logger.level;
@@ -99,12 +95,10 @@ function getLogger(prefix = null) {
99
95
  configurable: true,
100
96
  });
101
97
  const isDebugTimestampLoggingEnabled = process.env._LOG_TIMESTAMP === '1';
102
- // add all the levels from `npmlog`, and map to the underlying logger
103
98
  for (const level of exports.LEVELS) {
104
- wrappedLogger[level] = /** @param {any[]} args */ function (...args) {
99
+ wrappedLogger[level] = function (...args) {
105
100
  const finalPrefix = getFinalPrefix(this.prefix, isDebugTimestampLoggingEnabled);
106
101
  if (args.length) {
107
- // @ts-ignore This is OK
108
102
  logger[level](finalPrefix, ...args);
109
103
  }
110
104
  else {
@@ -112,13 +106,12 @@ function getLogger(prefix = null) {
112
106
  }
113
107
  };
114
108
  }
115
- if (!usingGlobalLog) {
116
- // if we're not using a global log specified from some top-level package,
117
- // set the log level to a default of verbose. Otherwise, let the top-level
118
- // package set the log level
109
+ // Default to verbose when the global was not already set (first use, or standalone);
110
+ // main server will override later.
111
+ if (defaultToVerbose) {
119
112
  wrappedLogger.level = 'verbose';
120
113
  }
121
- return /** @type {AppiumLogger} */ (wrappedLogger);
114
+ return wrappedLogger;
122
115
  }
123
116
  /**
124
117
  * Marks arbitrary log message as sensitive.
@@ -128,51 +121,32 @@ function getLogger(prefix = null) {
128
121
  * The latter is enabled by the corresponding HTTP middleware
129
122
  * in response to the `X-Appium-Is-Sensitive` request header
130
123
  * being set to 'true'.
131
- *
132
- * @template {any} T
133
- * @param {T} logMessage
134
- * @returns {{[k: string]: T}}
135
124
  */
136
125
  function markSensitive(logMessage) {
137
126
  return (0, logger_1.markSensitive)(logMessage);
138
127
  }
139
- /**
140
- *
141
- * @returns {[import('@appium/logger').Logger, boolean]}
142
- */
143
128
  function _getLogger() {
144
- // check if the user set the `_TESTING` or `_FORCE_LOGS` flag
145
129
  const testingMode = process.env._TESTING === '1';
146
130
  const forceLogMode = process.env._FORCE_LOGS === '1';
147
- // if is possible that there is a logger instance that is already around,
148
- // in which case we want t o use that
149
- const useGlobalLog = !!global._global_npmlog;
131
+ const defaultToVerbose = !globalWithNpmlog._global_npmlog;
150
132
  const logger = testingMode && !forceLogMode
151
- // in testing mode, use a mock logger object that we can query
152
133
  ? MOCK_LOG
153
- // otherwise, either use the global, or a new `npmlog` object
154
- : (global._global_npmlog || logger_1.default);
155
- // The default value is 10000, which causes excessive memory usage
156
- logger.maxRecordSize = MAX_LOG_RECORDS_COUNT;
157
- return [logger, useGlobalLog];
134
+ : (globalWithNpmlog._global_npmlog ?? logger_1.default);
135
+ if (!testingMode && !globalWithNpmlog._global_npmlog && logger === logger_1.default) {
136
+ globalWithNpmlog._global_npmlog = logger_1.default;
137
+ logger.maxRecordSize = MAX_LOG_RECORDS_COUNT;
138
+ }
139
+ return { logger, defaultToVerbose };
158
140
  }
159
- /**
160
- * @param {AppiumLoggerPrefix?} prefix
161
- * @param {boolean} [shouldLogTimestamp=false] whether to include timestamps into log prefixes
162
- * @returns {string}
163
- */
164
141
  function getFinalPrefix(prefix, shouldLogTimestamp = false) {
165
142
  const result = (lodash_1.default.isFunction(prefix) ? prefix() : prefix) ?? '';
166
143
  if (!shouldLogTimestamp) {
167
144
  return result;
168
145
  }
169
- const formattedTimestamp = `[${(0, moment_1.default)().format(PREFIX_TIMESTAMP_FORMAT)}]`;
146
+ const now = new Date();
147
+ const pad = (n, z = 2) => String(n).padStart(z, '0');
148
+ const formattedTimestamp = `[${pad(now.getHours())}-${pad(now.getMinutes())}-${pad(now.getSeconds())}:${pad(now.getMilliseconds(), 3)}]`;
170
149
  return result ? `${formattedTimestamp} ${result}` : formattedTimestamp;
171
150
  }
172
151
  exports.default = exports.log;
173
- /**
174
- * @typedef {import('@appium/types').AppiumLoggerPrefix} AppiumLoggerPrefix
175
- * @typedef {import('@appium/types').AppiumLogger} AppiumLogger
176
- * @typedef {import('@appium/types').AppiumLoggerLevel} AppiumLoggerLevel
177
- */
178
152
  //# sourceMappingURL=logging.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"logging.js","sourceRoot":"","sources":["../../lib/logging.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6BA,8BAuDC;AAeD,sCAEC;AArGD,yDAA4E;AAC5E,oDAAuB;AACvB,oDAA4B;AAE5B,0DAA0D;AAC7C,QAAA,MAAM,GAAG,CAAC,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;AACrF,MAAM,qBAAqB,GAAG,IAAI,CAAC;AACnC,MAAM,uBAAuB,GAAG,cAAc,CAAC;AAC/C,gEAAgE;AAChE,MAAM,QAAQ,GAAG;IACf,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC;QACb,kCAAkC,EAAE,GAAG,EAAE,CAAC,CAAC;YACzC,MAAM,EAAE,EAAE;YACV,KAAK,EAAE,EAAE;SACV,CAAC;QACF,KAAK,EAAE,SAAS;QAChB,MAAM,EAAE,EAAE;QACV,GAAG,EAAE,gBAAC,CAAC,IAAI;KACZ,CAAC;IACF,GAAG,CAAC,gBAAC,CAAC,SAAS,CAAC,cAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,gBAAC,CAAC,IAAI,CAAC,CAAC,CAAC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AC"}
@@ -1,65 +1,28 @@
1
+ import { Writable, type WritableOptions } from 'node:stream';
1
2
  /** Class which stores the last bit of data streamed into it */
2
- export class MJpegStream extends Writable {
3
- /**
4
- * Create an MJpegStream
5
- * @param {string} mJpegUrl - URL of MJPEG-over-HTTP stream
6
- * @param {function} [errorHandler=noop] - additional function that will be
7
- * called in the case of any errors.
8
- * @param {object} [options={}] - Options to pass to the Writable constructor
9
- */
10
- constructor(mJpegUrl: string, errorHandler?: Function, options?: object);
11
- /**
12
- * @type {number}
13
- */
14
- updateCount: number;
15
- errorHandler: Function;
16
- url: string;
17
- /**
18
- * Get the base64-encoded version of the JPEG
19
- *
20
- * @returns {?string} base64-encoded JPEG image data
21
- * or `null` if no image can be parsed
22
- */
3
+ export declare class MJpegStream extends Writable {
4
+ readonly errorHandler: (err: Error) => void;
5
+ readonly url: string;
6
+ /** Number of JPEG frames received so far (reset on {@linkcode clear}). Use stream['updateCount'] in tests if needed. */
7
+ private updateCount;
8
+ /** Last received JPEG chunk (base64 via {@linkcode lastChunkBase64}); `null` when no data yet or after {@linkcode clear}/stop. Use stream['lastChunk'] in tests if needed. */
9
+ private lastChunk;
10
+ private registerStartSuccess;
11
+ private registerStartFailure;
12
+ private responseStream;
13
+ private consumer;
14
+ /**
15
+ * @param mJpegUrl - URL of MJPEG-over-HTTP stream
16
+ * @param errorHandler - additional function that will be called in the case of any errors
17
+ * @param options - Options to pass to the Writable constructor
18
+ */
19
+ constructor(mJpegUrl: string, errorHandler?: (err: Error) => void, options?: WritableOptions);
23
20
  get lastChunkBase64(): string | null;
24
- /**
25
- * Get the PNG version of the JPEG buffer
26
- *
27
- * @returns {Promise<Buffer?>} PNG image data or `null` if no PNG
28
- * image can be parsed
29
- */
30
21
  lastChunkPNG(): Promise<Buffer | null>;
31
- /**
32
- * Get the base64-encoded version of the PNG
33
- *
34
- * @returns {Promise<string?>} base64-encoded PNG image data
35
- * or `null` if no image can be parsed
36
- */
37
22
  lastChunkPNGBase64(): Promise<string | null>;
38
- /**
39
- * Reset internal state
40
- */
41
23
  clear(): void;
42
- registerStartSuccess: ((thenableOrResult?: any) => void) | null | undefined;
43
- registerStartFailure: ((error?: any) => void) | null | undefined;
44
- responseStream: any;
45
- consumer: any;
46
- lastChunk: Buffer<ArrayBufferLike> | null | undefined;
47
- /**
48
- * Start reading the MJpeg stream and storing the last image
49
- */
50
24
  start(serverTimeout?: number): Promise<void>;
51
- /**
52
- * Stop reading the MJpeg stream. Ensure we disconnect all the pipes and stop
53
- * the HTTP request itself. Then reset the state.
54
- */
55
25
  stop(): void;
56
- /**
57
- * Override the Writable write() method in order to save the last image and
58
- * log the number of images we have received
59
- * @override
60
- * @param {Buffer} data - binary data streamed from the MJpeg consumer
61
- */
62
- override write(data: Buffer): boolean;
26
+ write(data: Buffer | string | Uint8Array, encoding?: BufferEncoding | ((error: Error | null) => void), callback?: (error: Error | null) => void): boolean;
63
27
  }
64
- import { Writable } from 'stream';
65
28
  //# sourceMappingURL=mjpeg.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"mjpeg.d.ts","sourceRoot":"","sources":["../../lib/mjpeg.js"],"names":[],"mappings":"AA+BA,+DAA+D;AAC/D;IAME;;;;;;OAMG;IACH,sBALW,MAAM,qCAGN,MAAM,EAQhB;IAlBD;;OAEG;IACH,aAFU,MAAM,CAEA;IAYd,uBAAgC;IAChC,YAAmB;IAIrB;;;;;OAKG;IACH,uBAHc,MAAM,OAAA,CAQnB;IAED;;;;;OAKG;IACH,gBAHa,OAAO,CAAC,MAAM,OAAC,CAAC,CAc5B;IAED;;;;;OAKG;IACH,sBAHa,OAAO,CAAC,MAAM,OAAC,CAAC,CAM5B;IAED;;OAEG;IACH,cAOC;IANC,4EAAgC;IAChC,iEAAgC;IAChC,oBAA0B;IAC1B,cAAoB;IACpB,sDAAqB;IAIvB;;OAEG;IACH,6CAyDC;IAED;;;OAGG;IACH,aAWC;IAED;;;;;OAKG;IACH,qBAFW,MAAM,WAYhB;CACF;yBAxMsB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