appium 3.2.2 → 3.3.1

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 (250) hide show
  1. package/build/lib/appium.d.ts +147 -205
  2. package/build/lib/appium.d.ts.map +1 -1
  3. package/build/lib/appium.js +169 -282
  4. package/build/lib/appium.js.map +1 -1
  5. package/build/lib/bidi-commands.d.ts.map +1 -1
  6. package/build/lib/bidi-commands.js +11 -11
  7. package/build/lib/bidi-commands.js.map +1 -1
  8. package/build/lib/bootstrap/appium-initializer.d.ts +21 -0
  9. package/build/lib/bootstrap/appium-initializer.d.ts.map +1 -0
  10. package/build/lib/bootstrap/appium-initializer.js +146 -0
  11. package/build/lib/bootstrap/appium-initializer.js.map +1 -0
  12. package/build/lib/bootstrap/appium-main-runner.d.ts +22 -0
  13. package/build/lib/bootstrap/appium-main-runner.d.ts.map +1 -0
  14. package/build/lib/bootstrap/appium-main-runner.js +109 -0
  15. package/build/lib/bootstrap/appium-main-runner.js.map +1 -0
  16. package/build/lib/bootstrap/config-file.d.ts +37 -0
  17. package/build/lib/bootstrap/config-file.d.ts.map +1 -0
  18. package/build/lib/{config-file.js → bootstrap/config-file.js} +62 -138
  19. package/build/lib/bootstrap/config-file.js.map +1 -0
  20. package/build/lib/bootstrap/grid-v3-register.d.ts +20 -0
  21. package/build/lib/bootstrap/grid-v3-register.d.ts.map +1 -0
  22. package/build/lib/bootstrap/grid-v3-register.js +185 -0
  23. package/build/lib/bootstrap/grid-v3-register.js.map +1 -0
  24. package/build/lib/bootstrap/init-types.d.ts +16 -0
  25. package/build/lib/bootstrap/init-types.d.ts.map +1 -0
  26. package/build/lib/bootstrap/init-types.js +3 -0
  27. package/build/lib/bootstrap/init-types.js.map +1 -0
  28. package/build/lib/bootstrap/main-helpers.d.ts +55 -0
  29. package/build/lib/bootstrap/main-helpers.d.ts.map +1 -0
  30. package/build/lib/bootstrap/main-helpers.js +187 -0
  31. package/build/lib/bootstrap/main-helpers.js.map +1 -0
  32. package/build/lib/bootstrap/node-helpers.d.ts +32 -0
  33. package/build/lib/bootstrap/node-helpers.d.ts.map +1 -0
  34. package/build/lib/bootstrap/node-helpers.js +201 -0
  35. package/build/lib/bootstrap/node-helpers.js.map +1 -0
  36. package/build/lib/bootstrap/startup-config.d.ts +22 -0
  37. package/build/lib/bootstrap/startup-config.d.ts.map +1 -0
  38. package/build/lib/bootstrap/startup-config.js +111 -0
  39. package/build/lib/bootstrap/startup-config.js.map +1 -0
  40. package/build/lib/cli/args.d.ts +16 -12
  41. package/build/lib/cli/args.d.ts.map +1 -1
  42. package/build/lib/cli/args.js +20 -40
  43. package/build/lib/cli/args.js.map +1 -1
  44. package/build/lib/cli/driver-command.d.ts +51 -93
  45. package/build/lib/cli/driver-command.d.ts.map +1 -1
  46. package/build/lib/cli/driver-command.js +11 -66
  47. package/build/lib/cli/driver-command.js.map +1 -1
  48. package/build/lib/cli/extension-command.d.ts +173 -377
  49. package/build/lib/cli/extension-command.d.ts.map +1 -1
  50. package/build/lib/cli/extension-command.js +387 -656
  51. package/build/lib/cli/extension-command.js.map +1 -1
  52. package/build/lib/cli/extension.d.ts +10 -15
  53. package/build/lib/cli/extension.d.ts.map +1 -1
  54. package/build/lib/cli/extension.js +15 -33
  55. package/build/lib/cli/extension.js.map +1 -1
  56. package/build/lib/cli/parser.d.ts +37 -66
  57. package/build/lib/cli/parser.d.ts.map +1 -1
  58. package/build/lib/cli/parser.js +69 -104
  59. package/build/lib/cli/parser.js.map +1 -1
  60. package/build/lib/cli/plugin-command.d.ts +50 -90
  61. package/build/lib/cli/plugin-command.d.ts.map +1 -1
  62. package/build/lib/cli/plugin-command.js +11 -63
  63. package/build/lib/cli/plugin-command.js.map +1 -1
  64. package/build/lib/cli/setup-command.d.ts +21 -26
  65. package/build/lib/cli/setup-command.d.ts.map +1 -1
  66. package/build/lib/cli/setup-command.js +19 -61
  67. package/build/lib/cli/setup-command.js.map +1 -1
  68. package/build/lib/cli/utils.d.ts +33 -35
  69. package/build/lib/cli/utils.d.ts.map +1 -1
  70. package/build/lib/cli/utils.js +48 -50
  71. package/build/lib/cli/utils.js.map +1 -1
  72. package/build/lib/constants.d.ts +23 -23
  73. package/build/lib/constants.d.ts.map +1 -1
  74. package/build/lib/constants.js +10 -15
  75. package/build/lib/constants.js.map +1 -1
  76. package/build/lib/doctor/doctor.d.ts +40 -57
  77. package/build/lib/doctor/doctor.d.ts.map +1 -1
  78. package/build/lib/doctor/doctor.js +31 -62
  79. package/build/lib/doctor/doctor.js.map +1 -1
  80. package/build/lib/extension/driver-config.d.ts +18 -77
  81. package/build/lib/extension/driver-config.d.ts.map +1 -1
  82. package/build/lib/extension/driver-config.js +37 -125
  83. package/build/lib/extension/driver-config.js.map +1 -1
  84. package/build/lib/extension/extension-config.d.ts +103 -210
  85. package/build/lib/extension/extension-config.d.ts.map +1 -1
  86. package/build/lib/extension/extension-config.js +180 -342
  87. package/build/lib/extension/extension-config.js.map +1 -1
  88. package/build/lib/extension/index.d.ts +12 -29
  89. package/build/lib/extension/index.d.ts.map +1 -1
  90. package/build/lib/extension/index.js +33 -75
  91. package/build/lib/extension/index.js.map +1 -1
  92. package/build/lib/extension/manifest-migrations.d.ts +3 -20
  93. package/build/lib/extension/manifest-migrations.d.ts.map +1 -1
  94. package/build/lib/extension/manifest-migrations.js +20 -101
  95. package/build/lib/extension/manifest-migrations.js.map +1 -1
  96. package/build/lib/extension/manifest.d.ts +61 -107
  97. package/build/lib/extension/manifest.d.ts.map +1 -1
  98. package/build/lib/extension/manifest.js +181 -356
  99. package/build/lib/extension/manifest.js.map +1 -1
  100. package/build/lib/extension/package-changed.d.ts +1 -3
  101. package/build/lib/extension/package-changed.d.ts.map +1 -1
  102. package/build/lib/extension/package-changed.js +8 -15
  103. package/build/lib/extension/package-changed.js.map +1 -1
  104. package/build/lib/extension/plugin-config.d.ts +10 -52
  105. package/build/lib/extension/plugin-config.d.ts.map +1 -1
  106. package/build/lib/extension/plugin-config.js +11 -63
  107. package/build/lib/extension/plugin-config.js.map +1 -1
  108. package/build/lib/helpers/build.d.ts +22 -0
  109. package/build/lib/helpers/build.d.ts.map +1 -0
  110. package/build/lib/helpers/build.js +109 -0
  111. package/build/lib/helpers/build.js.map +1 -0
  112. package/build/lib/helpers/capability.d.ts +38 -0
  113. package/build/lib/helpers/capability.d.ts.map +1 -0
  114. package/build/lib/helpers/capability.js +128 -0
  115. package/build/lib/helpers/capability.js.map +1 -0
  116. package/build/lib/helpers/network.d.ts +14 -0
  117. package/build/lib/helpers/network.d.ts.map +1 -0
  118. package/build/lib/helpers/network.js +35 -0
  119. package/build/lib/helpers/network.js.map +1 -0
  120. package/build/lib/insecure-features.js +6 -6
  121. package/build/lib/insecure-features.js.map +1 -1
  122. package/build/lib/inspector-commands.d.ts +6 -0
  123. package/build/lib/inspector-commands.d.ts.map +1 -1
  124. package/build/lib/inspector-commands.js +6 -0
  125. package/build/lib/inspector-commands.js.map +1 -1
  126. package/build/lib/logger.d.ts +2 -3
  127. package/build/lib/logger.d.ts.map +1 -1
  128. package/build/lib/logger.js +2 -3
  129. package/build/lib/logger.js.map +1 -1
  130. package/build/lib/logsink.d.ts +13 -22
  131. package/build/lib/logsink.d.ts.map +1 -1
  132. package/build/lib/logsink.js +48 -103
  133. package/build/lib/logsink.js.map +1 -1
  134. package/build/lib/main.d.ts +15 -58
  135. package/build/lib/main.d.ts.map +1 -1
  136. package/build/lib/main.js +25 -425
  137. package/build/lib/main.js.map +1 -1
  138. package/build/lib/schema/arg-spec.d.ts +32 -107
  139. package/build/lib/schema/arg-spec.d.ts.map +1 -1
  140. package/build/lib/schema/arg-spec.js +11 -107
  141. package/build/lib/schema/arg-spec.js.map +1 -1
  142. package/build/lib/schema/cli-args-guards.d.ts +34 -0
  143. package/build/lib/schema/cli-args-guards.d.ts.map +1 -0
  144. package/build/lib/schema/cli-args-guards.js +49 -0
  145. package/build/lib/schema/cli-args-guards.js.map +1 -0
  146. package/build/lib/schema/cli-args.d.ts +3 -15
  147. package/build/lib/schema/cli-args.d.ts.map +1 -1
  148. package/build/lib/schema/cli-args.js +17 -107
  149. package/build/lib/schema/cli-args.js.map +1 -1
  150. package/build/lib/schema/cli-transformers.d.ts +15 -12
  151. package/build/lib/schema/cli-transformers.d.ts.map +1 -1
  152. package/build/lib/schema/cli-transformers.js +15 -45
  153. package/build/lib/schema/cli-transformers.js.map +1 -1
  154. package/build/lib/schema/format-errors.d.ts +28 -0
  155. package/build/lib/schema/format-errors.d.ts.map +1 -0
  156. package/build/lib/schema/format-errors.js +29 -0
  157. package/build/lib/schema/format-errors.js.map +1 -0
  158. package/build/lib/schema/index.d.ts +4 -2
  159. package/build/lib/schema/index.d.ts.map +1 -1
  160. package/build/lib/schema/index.js +2 -0
  161. package/build/lib/schema/index.js.map +1 -1
  162. package/build/lib/schema/keywords.d.ts +12 -20
  163. package/build/lib/schema/keywords.d.ts.map +1 -1
  164. package/build/lib/schema/keywords.js +6 -51
  165. package/build/lib/schema/keywords.js.map +1 -1
  166. package/build/lib/schema/schema.d.ts +106 -231
  167. package/build/lib/schema/schema.d.ts.map +1 -1
  168. package/build/lib/schema/schema.js +88 -358
  169. package/build/lib/schema/schema.js.map +1 -1
  170. package/build/lib/utils.d.ts +7 -267
  171. package/build/lib/utils.d.ts.map +1 -1
  172. package/build/lib/utils.js +10 -409
  173. package/build/lib/utils.js.map +1 -1
  174. package/lib/{appium.js → appium.ts} +297 -341
  175. package/lib/bidi-commands.ts +10 -14
  176. package/lib/bootstrap/appium-initializer.ts +212 -0
  177. package/lib/bootstrap/appium-main-runner.ts +172 -0
  178. package/lib/bootstrap/config-file.ts +178 -0
  179. package/lib/bootstrap/grid-v3-register.ts +250 -0
  180. package/lib/bootstrap/init-types.ts +31 -0
  181. package/lib/bootstrap/main-helpers.ts +223 -0
  182. package/lib/bootstrap/node-helpers.ts +180 -0
  183. package/lib/bootstrap/startup-config.ts +143 -0
  184. package/lib/cli/{args.js → args.ts} +45 -56
  185. package/lib/cli/driver-command.ts +122 -0
  186. package/lib/cli/{extension-command.js → extension-command.ts} +827 -906
  187. package/lib/cli/extension.ts +65 -0
  188. package/lib/cli/{parser.js → parser.ts} +93 -116
  189. package/lib/cli/plugin-command.ts +117 -0
  190. package/lib/cli/{setup-command.js → setup-command.ts} +59 -74
  191. package/lib/cli/utils.ts +97 -0
  192. package/lib/{constants.js → constants.ts} +30 -41
  193. package/lib/doctor/{doctor.js → doctor.ts} +82 -92
  194. package/lib/extension/driver-config.ts +165 -0
  195. package/lib/extension/{extension-config.js → extension-config.ts} +291 -405
  196. package/lib/extension/index.ts +143 -0
  197. package/lib/extension/manifest-migrations.ts +57 -0
  198. package/lib/extension/manifest.ts +369 -0
  199. package/lib/extension/{package-changed.js → package-changed.ts} +9 -18
  200. package/lib/extension/plugin-config.ts +62 -0
  201. package/lib/helpers/build.ts +111 -0
  202. package/lib/helpers/capability.ts +171 -0
  203. package/lib/helpers/network.ts +30 -0
  204. package/lib/insecure-features.ts +1 -1
  205. package/lib/inspector-commands.ts +6 -1
  206. package/lib/{logger.js → logger.ts} +1 -2
  207. package/lib/{logsink.js → logsink.ts} +91 -137
  208. package/lib/main.ts +60 -0
  209. package/lib/schema/arg-spec.ts +131 -0
  210. package/lib/schema/cli-args-guards.ts +67 -0
  211. package/lib/schema/cli-args.ts +171 -0
  212. package/lib/schema/cli-transformers.ts +83 -0
  213. package/lib/schema/format-errors.ts +43 -0
  214. package/lib/schema/index.ts +4 -0
  215. package/lib/schema/keywords.ts +96 -0
  216. package/lib/schema/schema.ts +448 -0
  217. package/lib/utils.ts +73 -0
  218. package/package.json +17 -18
  219. package/scripts/autoinstall-extensions.js +3 -0
  220. package/build/lib/config-file.d.ts +0 -100
  221. package/build/lib/config-file.d.ts.map +0 -1
  222. package/build/lib/config-file.js.map +0 -1
  223. package/build/lib/config.d.ts +0 -70
  224. package/build/lib/config.d.ts.map +0 -1
  225. package/build/lib/config.js +0 -390
  226. package/build/lib/config.js.map +0 -1
  227. package/build/lib/grid-register.d.ts +0 -10
  228. package/build/lib/grid-register.d.ts.map +0 -1
  229. package/build/lib/grid-register.js +0 -134
  230. package/build/lib/grid-register.js.map +0 -1
  231. package/lib/cli/driver-command.js +0 -174
  232. package/lib/cli/extension.js +0 -74
  233. package/lib/cli/plugin-command.js +0 -164
  234. package/lib/cli/utils.js +0 -91
  235. package/lib/config-file.js +0 -228
  236. package/lib/config.js +0 -389
  237. package/lib/extension/driver-config.js +0 -245
  238. package/lib/extension/index.js +0 -169
  239. package/lib/extension/manifest-migrations.js +0 -136
  240. package/lib/extension/manifest.js +0 -550
  241. package/lib/extension/plugin-config.js +0 -112
  242. package/lib/grid-register.js +0 -146
  243. package/lib/main.js +0 -545
  244. package/lib/schema/arg-spec.js +0 -229
  245. package/lib/schema/cli-args.js +0 -254
  246. package/lib/schema/cli-transformers.js +0 -113
  247. package/lib/schema/index.js +0 -2
  248. package/lib/schema/keywords.js +0 -136
  249. package/lib/schema/schema.js +0 -725
  250. package/lib/utils.js +0 -512
@@ -36,111 +36,27 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
36
36
  return (mod && mod.__esModule) ? mod : { "default": mod };
37
37
  };
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
- exports.formatErrors = formatErrors;
40
39
  exports.readConfigFile = readConfigFile;
41
40
  exports.normalizeConfig = normalizeConfig;
42
- const better_ajv_errors_1 = __importDefault(require("@sidvind/better-ajv-errors"));
43
41
  const lilconfig_1 = require("lilconfig");
44
42
  const lodash_1 = __importDefault(require("lodash"));
45
43
  const yaml = __importStar(require("yaml"));
46
- const schema_1 = require("./schema/schema");
47
- /**
48
- * lilconfig loader to handle `.yaml` files
49
- * @type {import('lilconfig').LoaderSync}
50
- */
51
- function yamlLoader(filepath, content) {
52
- try {
53
- return yaml.parse(content);
54
- }
55
- catch (e) {
56
- throw new Error(`The YAML config at '${filepath}' cannot be loaded. Original error: ${e.message}`);
57
- }
58
- }
44
+ const schema_1 = require("../schema/schema");
45
+ const format_errors_1 = require("../schema/format-errors");
59
46
  /**
60
47
  * A cache of the raw config file (a JSON string) at a filepath.
61
48
  * This is used for better error reporting.
62
49
  * Note that config files needn't be JSON, but it helps if they are.
63
- * @type {Map<string,RawJson>}
64
50
  */
65
51
  const rawConfig = new Map();
66
- /**
67
- * Custom JSON loader that caches the raw config file (for use with `better-ajv-errors`).
68
- * If it weren't for this cache, this would be unnecessary.
69
- * @type {import('lilconfig').LoaderSync}
70
- */
71
- function jsonLoader(filepath, content) {
72
- rawConfig.set(filepath, content);
73
- try {
74
- return JSON.parse(content);
75
- }
76
- catch (e) {
77
- throw new Error(`The JSON config at '${filepath}' cannot be loaded. Original error: ${e.message}`);
78
- }
79
- }
80
- /**
81
- * Loads a config file from an explicit path
82
- * @param {LilconfigAsyncSearcher} lc - lilconfig instance
83
- * @param {string} filepath - Path to config file
84
- * @returns {Promise<import('lilconfig').LilconfigResult>}
85
- */
86
- async function loadConfigFile(lc, filepath) {
87
- try {
88
- // removing "await" will cause any rejection to _not_ be caught in this block!
89
- return await lc.load(filepath);
90
- }
91
- catch ( /** @type {unknown} */err) {
92
- if ( /** @type {NodeJS.ErrnoException} */(err).code === 'ENOENT') {
93
- /** @type {NodeJS.ErrnoException} */ (err).message = `Config file not found at user-provided path: ${filepath}`;
94
- throw err;
95
- }
96
- else if (err instanceof SyntaxError) {
97
- // generally invalid JSON
98
- err.message = `Config file at user-provided path ${filepath} is invalid:\n${err.message}`;
99
- throw err;
100
- }
101
- throw err;
102
- }
103
- }
104
- /**
105
- * Searches for a config file
106
- * @param {LilconfigAsyncSearcher} lc - lilconfig instance
107
- * @returns {Promise<import('lilconfig').LilconfigResult>}
108
- */
109
- async function searchConfigFile(lc) {
110
- return await lc.search();
111
- }
112
- /**
113
- * Given an array of errors and the result of loading a config file, generate a
114
- * helpful string for the user.
115
- *
116
- * - If `opts` contains a `json` property, this should be the original JSON
117
- * _string_ of the config file. This is only applicable if the config file
118
- * was in JSON format. If present, it will associate line numbers with errors.
119
- * - If `errors` happens to be empty, this will throw.
120
- * @param {import('ajv').ErrorObject[]} errors - Non-empty array of errors. Required.
121
- * @param {ReadConfigFileResult['config']|any} [config] -
122
- * Configuration & metadata
123
- * @param {FormatConfigErrorsOptions} [opts]
124
- * @throws {TypeError} If `errors` is empty
125
- * @returns {string}
126
- */
127
- function formatErrors(errors = [], config = {}, opts = {}) {
128
- if (errors && !errors.length) {
129
- throw new TypeError('Array of errors must be non-empty');
130
- }
131
- return (0, better_ajv_errors_1.default)((0, schema_1.getSchema)(opts.schemaId), config, errors, {
132
- json: opts.json,
133
- format: 'cli',
134
- });
135
- }
136
52
  /**
137
53
  * Given an optional path, read a config file. Validates the config file.
138
54
  *
139
55
  * Call {@link validate} if you already have a config object.
140
- * @param {string} [filepath] - Path to config file, if we have one
141
- * @param {ReadConfigFileOptions} [opts] - Options
142
56
  * @public
143
- * @returns {Promise<ReadConfigFileResult>} Contains config and filepath, if found, and any errors
57
+ * @param filepath - Explicit config path; when omitted, searches with lilconfig
58
+ * @param opts - e.g. `pretty` for formatted validation errors
59
+ * @returns Contains config and filepath, if found, and any errors
144
60
  */
145
61
  async function readConfigFile(filepath, opts = {}) {
146
62
  const lc = (0, lilconfig_1.lilconfig)('appium', {
@@ -162,14 +78,14 @@ async function readConfigFile(filepath, opts = {}) {
162
78
  configResult = { ...result, errors };
163
79
  }
164
80
  else {
165
- const reason = formatErrors(errors, result.config, {
81
+ const reason = (0, format_errors_1.formatErrors)(errors, result.config, {
166
82
  json: rawConfig.get(result.filepath),
167
83
  pretty,
168
84
  });
169
85
  configResult = reason ? { ...result, errors, reason } : { ...result, errors };
170
86
  }
171
87
  // normalize (to camel case) all top-level property names of the config file
172
- configResult.config = normalizeConfig(/** @type {AppiumConfig} */ (configResult.config));
88
+ configResult.config = normalizeConfig(configResult.config);
173
89
  return configResult;
174
90
  }
175
91
  finally {
@@ -180,70 +96,78 @@ async function readConfigFile(filepath, opts = {}) {
180
96
  return result ?? {};
181
97
  }
182
98
  /**
183
- * Convert schema property names to either a) the value of the `appiumCliDest` property, if any; or b) camel-case
184
- * @param {AppiumConfig} config - Configuration object
185
- * @returns {NormalizedAppiumConfig} New object with camel-cased keys (or `dest` keys).
99
+ * Converts schema property names to either the `appiumCliDest` value, if any, or camelCase.
100
+ *
101
+ * @param config - Raw config object as parsed from file
102
+ * @returns New object with camel-cased keys (or CLI `dest` keys).
186
103
  */
187
104
  function normalizeConfig(config) {
188
105
  const schema = (0, schema_1.getSchema)();
189
- /**
190
- * @param {AppiumConfig} config
191
- * @param {string} [section] - Keypath (lodash `_.get()` style) to section of config. If omitted, assume root Appium config schema
192
- * @todo Rewrite as a loop
193
- * @returns Normalized section of config
194
- */
195
- const normalize = (config, section) => {
196
- const obj = lodash_1.default.isUndefined(section) ? config : lodash_1.default.get(config, section, config);
197
- const mappedObj = lodash_1.default.mapKeys(obj, (__, prop) => lodash_1.default.get(schema, `properties.server.properties[${prop}].appiumCliDest`, lodash_1.default.camelCase(prop)));
106
+ const isSchemaTypeObject = (schemaObj) => Boolean(schemaObj?.properties || schemaObj?.type === 'object');
107
+ const normalize = (rootConfig, section) => {
108
+ const obj = lodash_1.default.isUndefined(section)
109
+ ? rootConfig
110
+ : lodash_1.default.get(rootConfig, section, rootConfig);
111
+ const mappedObj = lodash_1.default.mapKeys(obj, (_v, prop) => lodash_1.default.get(schema, `properties.server.properties[${prop}].appiumCliDest`, lodash_1.default.camelCase(prop)));
198
112
  return lodash_1.default.mapValues(mappedObj, (value, property) => {
199
113
  const nextSection = section ? `${section}.${property}` : property;
200
114
  return isSchemaTypeObject(schema.properties?.[property])
201
- ? normalize(config, nextSection)
115
+ ? normalize(rootConfig, nextSection)
202
116
  : value;
203
117
  });
204
118
  };
205
- /**
206
- * Returns `true` if the schema prop references an object, or if it's an object itself
207
- * @param {import('ajv').SchemaObject|object} schema - Referencing schema object
208
- */
209
- const isSchemaTypeObject = (schema) => Boolean(schema?.properties || schema?.type === 'object');
210
119
  return normalize(config);
211
120
  }
212
121
  /**
213
- * Result of calling {@link readConfigFile}.
214
- * @typedef ReadConfigFileResult
215
- * @property {import('ajv').ErrorObject[]} [errors] - Validation errors
216
- * @property {string} [filepath] - The path to the config file, if found
217
- * @property {boolean} [isEmpty] - If `true`, the config file exists but is empty
218
- * @property {NormalizedAppiumConfig} [config] - The parsed configuration
219
- * @property {string|import('@sidvind/better-ajv-errors').IOutputError[]} [reason] - Human-readable error messages and suggestions. If the `pretty` option is `true`, this will be a nice string to print.
220
- */
221
- /**
222
- * Options for {@link readConfigFile}.
223
- * @typedef ReadConfigFileOptions
224
- * @property {boolean} [pretty=true] If `false`, do not use color and fancy formatting in the `reason` property of the {@link ReadConfigFileResult}. The value of `reason` is then suitable for machine-reading.
225
- */
226
- /**
227
- * This is an `AsyncSearcher` which is inexplicably _not_ exported by the `lilconfig` type definition.
228
- * @typedef {ReturnType<import('lilconfig')["lilconfig"]>} LilconfigAsyncSearcher
229
- */
230
- /**
231
- * The contents of an Appium config file. Generated from schema
232
- * @typedef {import('@appium/types').AppiumConfig} AppiumConfig
122
+ * lilconfig loader to handle `.yaml` files
233
123
  */
124
+ function yamlLoader(filepath, content) {
125
+ try {
126
+ return yaml.parse(content);
127
+ }
128
+ catch (e) {
129
+ throw new Error(`The YAML config at '${filepath}' cannot be loaded. Original error: ${e.message}`);
130
+ }
131
+ }
234
132
  /**
235
- * The contents of an Appium config file with camelcased property names (and using `appiumCliDest` value if present). Generated from {@link AppiumConfig}
236
- * @typedef {import('@appium/types').NormalizedAppiumConfig} NormalizedAppiumConfig
133
+ * Custom JSON loader that caches the raw config file (for use with `better-ajv-errors`).
134
+ * If it weren't for this cache, this would be unnecessary.
237
135
  */
136
+ function jsonLoader(filepath, content) {
137
+ rawConfig.set(filepath, content);
138
+ try {
139
+ return JSON.parse(content);
140
+ }
141
+ catch (e) {
142
+ rawConfig.delete(filepath);
143
+ throw new Error(`The JSON config at '${filepath}' cannot be loaded. Original error: ${e.message}`);
144
+ }
145
+ }
238
146
  /**
239
- * The string should be a raw JSON string.
240
- * @typedef {string} RawJson
147
+ * Loads a config file from an explicit path
241
148
  */
149
+ async function loadConfigFile(lc, filepath) {
150
+ try {
151
+ // removing "await" will cause any rejection to _not_ be caught in this block!
152
+ return await lc.load(filepath);
153
+ }
154
+ catch (err) {
155
+ if (err.code === 'ENOENT') {
156
+ err.message = `Config file not found at user-provided path: ${filepath}`;
157
+ throw err;
158
+ }
159
+ else if (err instanceof SyntaxError) {
160
+ // generally invalid JSON
161
+ err.message = `Config file at user-provided path ${filepath} is invalid:\n${err.message}`;
162
+ throw err;
163
+ }
164
+ throw err;
165
+ }
166
+ }
242
167
  /**
243
- * Options for {@link formatErrors}.
244
- * @typedef FormatConfigErrorsOptions
245
- * @property {import('./config-file').RawJson} [json] - Raw JSON config (as string)
246
- * @property {boolean} [pretty=true] - Whether to format errors as a CLI-friendly string
247
- * @property {string} [schemaId] - Specific ID of a prop; otherwise entire schema
168
+ * Searches for a config file
248
169
  */
170
+ async function searchConfigFile(lc) {
171
+ return await lc.search();
172
+ }
249
173
  //# sourceMappingURL=config-file.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config-file.js","sourceRoot":"","sources":["../../../lib/bootstrap/config-file.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgDA,wCAyCC;AAQD,0CAwBC;AAvHD,yCAA2E;AAC3E,oDAAuB;AACvB,2CAA6B;AAE7B,6CAAqD;AACrD,2DAAqD;AAErD;;;;GAIG;AACH,MAAM,SAAS,GAAG,IAAI,GAAG,EAAkB,CAAC;AAyB5C;;;;;;;;GAQG;AACI,KAAK,UAAU,cAAc,CAClC,QAAiB,EACjB,OAA8B,EAAE;IAEhC,MAAM,EAAE,GAAG,IAAA,qBAAS,EAAC,QAAQ,EAAE;QAC7B,OAAO,EAAE;YACP,OAAO,EAAE,UAAwB;YACjC,MAAM,EAAE,UAAwB;YAChC,OAAO,EAAE,UAAwB;YACjC,KAAK,EAAE,UAAwB;SA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EAAE,CAAC,MAAM,EAAE,CAAC;AAC3B,CAAC"}
@@ -0,0 +1,20 @@
1
+ import type { StringRecord } from '@appium/types';
2
+ interface Grid3HubConfiguration {
3
+ hubProtocol?: string;
4
+ hubHost?: string;
5
+ hubPort?: number;
6
+ url?: string;
7
+ host?: string;
8
+ port?: number;
9
+ id?: string;
10
+ register?: boolean;
11
+ registerCycle?: number;
12
+ }
13
+ interface Grid3NodeConfig extends StringRecord {
14
+ configuration?: Grid3HubConfiguration;
15
+ capabilities?: unknown;
16
+ }
17
+ export default function registerNode(data: string, addr: string, port: number, basePath: string): Promise<void>;
18
+ export default function registerNode(data: Grid3NodeConfig, addr?: string, port?: number, basePath?: string): Promise<void>;
19
+ export {};
20
+ //# sourceMappingURL=grid-v3-register.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"grid-v3-register.d.ts","sourceRoot":"","sources":["../../../lib/bootstrap/grid-v3-register.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,eAAe,CAAC;AAkBhD,UAAU,qBAAqB;IAC7B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,UAAU,eAAgB,SAAQ,YAAY;IAC5C,aAAa,CAAC,EAAE,qBAAqB,CAAC;IACtC,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB;AAOD,wBAA8B,YAAY,CACxC,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,IAAI,CAAC,CAAC;AACjB,wBAA8B,YAAY,CACxC,IAAI,EAAE,eAAe,EACrB,IAAI,CAAC,EAAE,MAAM,EACb,IAAI,CAAC,EAAE,MAAM,EACb,QAAQ,CAAC,EAAE,MAAM,GAChB,OAAO,CAAC,IAAI,CAAC,CAAC"}
@@ -0,0 +1,185 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.default = registerNode;
7
+ const axios_1 = __importDefault(require("axios"));
8
+ const support_1 = require("@appium/support");
9
+ const lodash_1 = __importDefault(require("lodash"));
10
+ const logger_1 = require("../logger");
11
+ /**
12
+ * Selenium **Grid 3** (legacy hub) node integration.
13
+ *
14
+ * Registers this Appium process as a node with a Selenium Grid 3 hub using the classic
15
+ * `/grid/register` endpoint and `/grid/api/proxy` for re-registration checks.
16
+ * This does **not** apply to Selenium Grid 4 (which uses a different topology and APIs).
17
+ *
18
+ * @see https://www.selenium.dev/documentation/legacy/grid_3/
19
+ */
20
+ /** REST paths exposed by a Selenium Grid 3 hub. */
21
+ const GRID_V3_REGISTER_PATH = '/grid/register';
22
+ const GRID_V3_PROXY_API_PATH = '/grid/api/proxy';
23
+ /**
24
+ * Registers this server as a node with a **Selenium Grid 3** hub.
25
+ *
26
+ * When `data` is a path to a JSON config file, `addr`, `port`, and `basePath` are required (they define
27
+ * how the hub reaches this Appium server). When `data` is an inline config object, those parameters are
28
+ * optional and only used to fill missing node URL fields in the config.
29
+ *
30
+ * @deprecated Selenium Grid 3 registration is legacy and slated for removal.
31
+ * Use Selenium Grid 4 integration (node relay) instead.
32
+ *
33
+ * @param data - Path to a JSON file or an inline parsed config object
34
+ * @param addr - Bind to this address
35
+ * @param port - Bind to this port
36
+ * @param basePath - Base path for the Appium server (used in the node URL sent to the hub; may be `''`)
37
+ */
38
+ async function registerNode(data, addr, port, basePath) {
39
+ if (typeof data === 'string') {
40
+ if (addr === undefined || port === undefined || basePath === undefined) {
41
+ throw logger_1.log.errorWithException('When the first argument is a Selenium Grid 3 node config file path, address, port, and basePath ' +
42
+ 'are required (e.g. match your Appium `--address`, `--port`, and base path).');
43
+ }
44
+ if (typeof port !== 'number' || !Number.isFinite(port)) {
45
+ throw logger_1.log.errorWithException('When registering from a node config file path, port must be a finite number.');
46
+ }
47
+ }
48
+ let configHolder;
49
+ if (lodash_1.default.isString(data)) {
50
+ const configFilePath = data;
51
+ let fileContent;
52
+ try {
53
+ fileContent = await support_1.fs.readFile(data, 'utf-8');
54
+ }
55
+ catch (err) {
56
+ logger_1.log.error(`Unable to load Selenium Grid 3 node configuration file ${configFilePath} to ` +
57
+ `register with the hub: ${err.message}`);
58
+ return;
59
+ }
60
+ try {
61
+ configHolder = JSON.parse(fileContent);
62
+ }
63
+ catch (err) {
64
+ throw logger_1.log.errorWithException(`Syntax error in Selenium Grid 3 node configuration file ${configFilePath}: ` +
65
+ err.message);
66
+ }
67
+ }
68
+ else {
69
+ configHolder = data;
70
+ }
71
+ postRequest(configHolder, addr, port, basePath);
72
+ }
73
+ /** Base URL for the Selenium Grid 3 hub (protocol + host + port). */
74
+ function hubUri(config) {
75
+ const protocol = config.hubProtocol || 'http';
76
+ return `${protocol}://${config.hubHost}:${config.hubPort}`;
77
+ }
78
+ /** POST registration payload to the Selenium Grid 3 hub. */
79
+ async function registerToGrid(postOptions, configHolder) {
80
+ const hubCfg = configHolder.configuration;
81
+ if (!hubCfg) {
82
+ return;
83
+ }
84
+ try {
85
+ const { status } = await (0, axios_1.default)(postOptions);
86
+ if (status !== 200) {
87
+ throw new Error(`Request failed with code ${status}`);
88
+ }
89
+ logger_1.log.debug(`Appium successfully registered with the Selenium Grid 3 hub at ` + hubUri(hubCfg));
90
+ }
91
+ catch (err) {
92
+ logger_1.log.error(`An attempt to register with the Selenium Grid 3 hub was unsuccessful: ` +
93
+ err.message);
94
+ }
95
+ }
96
+ function postRequest(configHolder, addr, port, basePath) {
97
+ // Move Selenium Grid 3 (flat) configuration properties into `configuration`
98
+ if (!lodash_1.default.has(configHolder, 'configuration')) {
99
+ const configuration = {};
100
+ const holder = configHolder;
101
+ for (const property in holder) {
102
+ if (lodash_1.default.has(holder, property) && property !== 'capabilities') {
103
+ configuration[property] = holder[property];
104
+ delete holder[property];
105
+ }
106
+ }
107
+ holder.configuration = configuration;
108
+ }
109
+ const cfg = configHolder.configuration;
110
+ if (!cfg) {
111
+ return;
112
+ }
113
+ // if the node config does not have the appium/webdriver url, host, and port,
114
+ // automatically add it based on how appium was initialized
115
+ // otherwise, we will take whatever the user setup
116
+ // because we will always set localhost/127.0.0.1. this won't work if your
117
+ // node and hub aren't in the same place
118
+ if (!cfg.url || !cfg.host || !cfg.port) {
119
+ cfg.url = `http://${addr}:${port}${basePath}`;
120
+ cfg.host = addr;
121
+ cfg.port = port;
122
+ }
123
+ // if the node config does not have id automatically add it
124
+ if (!cfg.id) {
125
+ cfg.id = `http://${cfg.host}:${cfg.port}`;
126
+ }
127
+ // the post options
128
+ const regRequest = {
129
+ url: `${hubUri(cfg)}${GRID_V3_REGISTER_PATH}`,
130
+ method: 'POST',
131
+ data: configHolder,
132
+ };
133
+ if (cfg.register !== true) {
134
+ logger_1.log.debug(`No Selenium Grid 3 hub registration sent (${cfg.register} = false)`);
135
+ return;
136
+ }
137
+ const registerCycleInterval = cfg.registerCycle;
138
+ if (registerCycleInterval === undefined || isNaN(registerCycleInterval) || registerCycleInterval <= 0) {
139
+ logger_1.log.warn(`'registerCycle' is not a valid positive number. ` +
140
+ `No registration request will be sent to the Selenium Grid 3 hub.`);
141
+ return;
142
+ }
143
+ // initiate a new Thread
144
+ let first = true;
145
+ logger_1.log.debug(`Starting auto-register thread for Selenium Grid 3. ` +
146
+ `Will try to register every ${registerCycleInterval} ms.`);
147
+ setInterval(async function registerRetry() {
148
+ if (first) {
149
+ first = false;
150
+ await registerToGrid(regRequest, configHolder);
151
+ }
152
+ else if (!(await isAlreadyRegistered(configHolder))) {
153
+ // make the http POST to the Selenium Grid 3 hub for registration
154
+ await registerToGrid(regRequest, configHolder);
155
+ }
156
+ }, registerCycleInterval);
157
+ }
158
+ /** Query the Selenium Grid 3 hub to see if this node id is already registered. */
159
+ async function isAlreadyRegistered(configHolder) {
160
+ //check if node is already registered
161
+ const hubCfg = configHolder.configuration;
162
+ if (!hubCfg?.id) {
163
+ return;
164
+ }
165
+ const id = hubCfg.id;
166
+ try {
167
+ const { data, status } = await (0, axios_1.default)({
168
+ url: `${hubUri(hubCfg)}${GRID_V3_PROXY_API_PATH}`,
169
+ params: { id },
170
+ timeout: 10000,
171
+ });
172
+ if (status !== 200) {
173
+ throw new Error(`Request failed with code ${status}`);
174
+ }
175
+ if (!data.success) {
176
+ // if register fail, print the debug msg
177
+ logger_1.log.debug(`Selenium Grid 3 hub registration check: ${data.msg}`);
178
+ }
179
+ return data.success;
180
+ }
181
+ catch (err) {
182
+ logger_1.log.debug(`Selenium Grid 3 hub down or not responding: ${err.message}`);
183
+ }
184
+ }
185
+ //# sourceMappingURL=grid-v3-register.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"grid-v3-register.js","sourceRoot":"","sources":["../../../lib/bootstrap/grid-v3-register.ts"],"names":[],"mappings":";;;;;AAqEA,+BA8CC;AAnHD,kDAA0B;AAC1B,6CAAmC;AAEnC,oDAAuB;AACvB,sCAAwC;AAExC;;;;;;;;GAQG;AAEH,mDAAmD;AACnD,MAAM,qBAAqB,GAAG,gBAAgB,CAAC;AAC/C,MAAM,sBAAsB,GAAG,iBAAiB,CAAC;AAoCjD;;;;;;;;;;;;;;GAcG;AACY,KAAK,UAAU,YAAY,CACxC,IAA8B,EAC9B,IAAa,EACb,IAAa,EACb,QAAiB;IAEjB,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,CAAC;QAC7B,IAAI,IAAI,KAAK,SAAS,IAAI,IAAI,KAAK,SAAS,IAAI,QAAQ,KAAK,SA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AAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,YAAM,CAAC,KAAK,CAAC,+CAAgD,GAAa,CAAC,OAAO,EAAE,CAAC,CAAC;IACxF,CAAC;AACH,CAAC"}
@@ -0,0 +1,16 @@
1
+ import type { AppiumDriver } from '../appium';
2
+ import type { Args, CliCommand, CliCommandServer, CliCommandSetupSubcommand, CliExtensionSubcommand, ParsedArgs } from 'appium/types';
3
+ import type { ExtensionConfigs } from '../extension';
4
+ /** Empty object returned when `init` completes for non-server CLI flows (extension/setup). */
5
+ export type ExtCommandInitResult = Record<string, never>;
6
+ /** Driver/plugin config plus server instance and merged server args after successful server `init`. */
7
+ export type ServerInitData = ExtensionConfigs & {
8
+ appiumDriver: AppiumDriver;
9
+ parsedArgs: ParsedArgs<CliCommandServer>;
10
+ appiumHome: string;
11
+ };
12
+ /** Discriminated by CLI command: server subcommand yields {@link ServerInitData}; otherwise {@link ExtCommandInitResult}. */
13
+ export type InitResult<Cmd extends CliCommand = CliCommandServer> = Cmd extends CliCommandServer ? ServerInitData : ExtCommandInitResult;
14
+ /** CLI + programmatic args before `init` narrows by `subcommand`. */
15
+ export type PreConfigArgs = Args<CliCommand, CliExtensionSubcommand | CliCommandSetupSubcommand | void>;
16
+ //# sourceMappingURL=init-types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"init-types.d.ts","sourceRoot":"","sources":["../../../lib/bootstrap/init-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,WAAW,CAAC;AAC5C,OAAO,KAAK,EACV,IAAI,EACJ,UAAU,EACV,gBAAgB,EAChB,yBAAyB,EACzB,sBAAsB,EACtB,UAAU,EACX,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EAAC,gBAAgB,EAAC,MAAM,cAAc,CAAC;AAEnD,8FAA8F;AAC9F,MAAM,MAAM,oBAAoB,GAAG,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;AAEzD,uGAAuG;AACvG,MAAM,MAAM,cAAc,GAAG,gBAAgB,GAAG;IAC9C,YAAY,EAAE,YAAY,CAAC;IAC3B,UAAU,EAAE,UAAU,CAAC,gBAAgB,CAAC,CAAC;IACzC,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,6HAA6H;AAC7H,MAAM,MAAM,UAAU,CAAC,GAAG,SAAS,UAAU,GAAG,gBAAgB,IAAI,GAAG,SAAS,gBAAgB,GAC5F,cAAc,GACd,oBAAoB,CAAC;AAEzB,qEAAqE;AACrE,MAAM,MAAM,aAAa,GAAG,IAAI,CAC9B,UAAU,EACV,sBAAsB,GAAG,yBAAyB,GAAG,IAAI,CAC1D,CAAC"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=init-types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"init-types.js","sourceRoot":"","sources":["../../../lib/bootstrap/init-types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,55 @@
1
+ import { type ServerOpts } from '@appium/base-driver';
2
+ import type { AppiumServer, Driver, MethodMap, UpdateServerCallback } from '@appium/types';
3
+ import type { AppiumDriver } from '../appium';
4
+ import type { ParsedArgs, CliCommandServer } from 'appium/types';
5
+ import type { DriverNameMap, PluginNameMap } from '../extension';
6
+ /**
7
+ * Logs a value to the console using the info logger (with util.inspect formatting).
8
+ */
9
+ export declare const inspect: (t1: unknown) => void;
10
+ /**
11
+ * Prints the current build info JSON to stdout.
12
+ *
13
+ * This updates build metadata first (using GitHub fallback) and then logs the
14
+ * resulting {@link BuildInfo} object.
15
+ */
16
+ export declare function showBuildInfo(): Promise<void>;
17
+ /**
18
+ * Human-readable label for where Appium resolved `APPIUM_HOME` from (CLI, env, or autodetect).
19
+ */
20
+ export declare function determineAppiumHomeSource(appiumHomeFromArgs?: string | null): string;
21
+ /**
22
+ * Logs the REST listener URL; if the bind address is a broadcast address, lists concrete interface URLs.
23
+ */
24
+ export declare function logServerAddress(url: string): void;
25
+ /**
26
+ * Validates Node version, optional long stack traces, schema, tmp dir, and `--build-info` early exit.
27
+ *
28
+ * @param args - Parsed server CLI args
29
+ * @param throwInsteadOfExit - When true, rethrows failures instead of calling `process.exit(1)`
30
+ */
31
+ export declare function preflightChecks(args: ParsedArgs<CliCommandServer>, throwInsteadOfExit?: boolean): Promise<void>;
32
+ /**
33
+ * Prints welcome line (version + optional git rev), non-default server args, and default capabilities.
34
+ */
35
+ export declare function logStartupInfo(args: ParsedArgs<CliCommandServer>): Promise<void>;
36
+ /**
37
+ * Collects `updateServer` hooks from active driver and plugin classes for HTTP server customization.
38
+ */
39
+ export declare function getServerUpdaters(driverClasses: DriverNameMap, pluginClasses: PluginNameMap): UpdateServerCallback[];
40
+ /**
41
+ * Merges `newMethodMap` contributions from all active drivers and plugins into one method map.
42
+ */
43
+ export declare function getExtraMethodMap(driverClasses: DriverNameMap, pluginClasses: PluginNameMap): MethodMap<Driver>;
44
+ /**
45
+ * Builds {@link ServerOpts} and normalized base path for the Appium HTTP server from CLI args and extensions.
46
+ */
47
+ export declare function buildServerOpts(appiumDriver: AppiumDriver, parsedArgs: ParsedArgs<CliCommandServer>, driverClasses: DriverNameMap, pluginClasses: PluginNameMap): {
48
+ serverOpts: ServerOpts;
49
+ normalizedBasePath: string;
50
+ };
51
+ /**
52
+ * Creates the Appium HTTP server and attaches WebSocket handlers for BiDi under the normalized base path.
53
+ */
54
+ export declare function createAppiumServer(serverOpts: ServerOpts, appiumDriver: AppiumDriver, normalizedBasePath: string): Promise<AppiumServer>;
55
+ //# sourceMappingURL=main-helpers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"main-helpers.d.ts","sourceRoot":"","sources":["../../../lib/bootstrap/main-helpers.ts"],"names":[],"mappings":"AAEA,OAAO,EAIL,KAAK,UAAU,EAChB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,KAAK,EAAC,YAAY,EAAE,MAAM,EAAE,SAAS,EAAE,oBAAoB,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