@appium/base-plugin 2.2.1 → 2.2.3

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/LICENSE CHANGED
@@ -186,7 +186,7 @@
186
186
  same "printed page" as the copyright notice for easier
187
187
  identification within third-party archives.
188
188
 
189
- Copyright JS Foundation and other contributors, https://js.foundation
189
+ Copyright OpenJS Foundation and other contributors, https://openjsf.org/
190
190
 
191
191
  Licensed under the Apache License, Version 2.0 (the "License");
192
192
  you may not use this file except in compliance with the License.
@@ -1,8 +1,8 @@
1
1
  export default BasePlugin;
2
2
  export type Plugin = import('@appium/types').Plugin;
3
3
  export type NextPluginCallback = import('@appium/types').NextPluginCallback;
4
- export type Driver = import('@appium/types').Driver;
5
- export type PluginClass = import('@appium/types').PluginClass;
4
+ export type Constraints = import('@appium/types').Constraints;
5
+ export type Driver<C extends Readonly<Record<string, import("@appium/types").Constraint>>> = import('@appium/types').Driver<C>;
6
6
  /**
7
7
  * @implements {Plugin}
8
8
  */
@@ -54,13 +54,12 @@ export class BasePlugin implements Plugin {
54
54
  * `next` and `driver` objects since naturally we'd want to make sure to trigger the driver's own
55
55
  * `executeMethod` call if an execute method is not found on the plugin itself.
56
56
  *
57
- * @template {Driver} D
57
+ * @template {Constraints} C
58
58
  * @param {NextPluginCallback} next
59
- * @param {D} driver
59
+ * @param {Driver<C>} driver
60
60
  * @param {string} script
61
61
  * @param {[Record<string, any>]|[]} protoArgs
62
- * @this {Plugin}
63
62
  */
64
- executeMethod<D extends import("@appium/types").Driver<typeof import("@appium/types").BASE_DESIRED_CAP_CONSTRAINTS, import("@appium/types").StringRecord, any>>(this: import("@appium/types").Plugin, next: NextPluginCallback, driver: D, script: string, protoArgs: [Record<string, any>] | []): Promise<any>;
63
+ executeMethod<C extends Readonly<Record<string, import("@appium/types").Constraint>>>(next: NextPluginCallback, driver: import("@appium/types").Driver<C, import("@appium/types").StringRecord>, script: string, protoArgs: [Record<string, any>] | []): Promise<any>;
65
64
  }
66
65
  //# sourceMappingURL=plugin.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../lib/plugin.js"],"names":[],"mappings":";qBAuFa,OAAO,eAAe,EAAE,MAAM;iCAC9B,OAAO,eAAe,EAAE,kBAAkB;qBAC1C,OAAO,eAAe,EAAE,MAAM;0BAC9B,OAAO,eAAe,EAAE,WAAW;AAvFhD;;GAEG;AACH;IACE;;;;;;;;;;;;;;OAcG;IACH,wBAAyB;IAEzB;;;;;;;;;;;;;;;OAeG;IACH,4BAA6B;IAE7B;;;OAGG;IACH,kBAHW,MAAM,iDAOhB;IAHC,aAAgB;IAChB,iCAAsB;IACtB,6CAAkD;IAGpD;;;;;;;;;;;;OAYG;IACH,4MANW,kBAAkB,qBAElB,MAAM,aACN,CAAC,OAAO,MAAM,EAAE,GAAG,CAAC,CAAC,GAAC,EAAE,gBAkBlC;CACF"}
1
+ {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../lib/plugin.js"],"names":[],"mappings":";qBAuFa,OAAO,eAAe,EAAE,MAAM;iCAC9B,OAAO,eAAe,EAAE,kBAAkB;0BAC1C,OAAO,eAAe,EAAE,WAAW;6FAKnC,OAAO,eAAe,EAAE,MAAM,CAAC,CAAC,CAAC;AA3F9C;;GAEG;AACH;IACE;;;;;;;;;;;;;;OAcG;IACH,wBAAyB;IAEzB;;;;;;;;;;;;;;;OAeG;IACH,4BAA6B;IAE7B;;;OAGG;IACH,kBAHW,MAAM,iDAOhB;IAHC,aAAgB;IAChB,iCAAsB;IACtB,6CAAkD;IAGpD;;;;;;;;;;;OAWG;IACH,4FALW,kBAAkB,2FAElB,MAAM,aACN,CAAC,OAAO,MAAM,EAAE,GAAG,CAAC,CAAC,GAAC,EAAE,gBAkBlC;CACF"}
@@ -22,22 +22,20 @@ class BasePlugin {
22
22
  * `next` and `driver` objects since naturally we'd want to make sure to trigger the driver's own
23
23
  * `executeMethod` call if an execute method is not found on the plugin itself.
24
24
  *
25
- * @template {Driver} D
25
+ * @template {Constraints} C
26
26
  * @param {NextPluginCallback} next
27
- * @param {D} driver
27
+ * @param {Driver<C>} driver
28
28
  * @param {string} script
29
29
  * @param {[Record<string, any>]|[]} protoArgs
30
- * @this {Plugin}
31
30
  */
32
31
  async executeMethod(next, driver, script, protoArgs) {
33
- const Plugin = /** @type {PluginClass} */ (this.constructor);
32
+ const Plugin = /** @type {import('@appium/types').PluginClass<Plugin>} */ (this.constructor);
34
33
  const commandMetadata = { ...Plugin.executeMethodMap?.[script] };
35
- /** @type {import('@appium/types').PluginCommand<D>|undefined} */
36
- let command;
37
- if (!commandMetadata.command || !(command = this[commandMetadata.command])) {
34
+ if (!commandMetadata.command || !(commandMetadata.command in this)) {
38
35
  this.logger.info(`Plugin did not know how to handle method '${script}'. Passing control to next`);
39
36
  return await next();
40
37
  }
38
+ const command = /** @type {import('@appium/types').PluginCommand<Driver<C>>} */ (this[commandMetadata.command]);
41
39
  const args = (0, base_driver_1.validateExecuteMethodParams)(protoArgs, commandMetadata.params);
42
40
  return await command.call(this, next, driver, ...args);
43
41
  }
@@ -80,7 +78,10 @@ exports.default = BasePlugin;
80
78
  /**
81
79
  * @typedef {import('@appium/types').Plugin} Plugin
82
80
  * @typedef {import('@appium/types').NextPluginCallback} NextPluginCallback
83
- * @typedef {import('@appium/types').Driver} Driver
84
- * @typedef {import('@appium/types').PluginClass} PluginClass
81
+ * @typedef {import('@appium/types').Constraints} Constraints
82
+ */
83
+ /**
84
+ * @template {Constraints} C
85
+ * @typedef {import('@appium/types').Driver<C>} Driver
85
86
  */
86
87
  //# sourceMappingURL=plugin.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.js","sourceRoot":"","sources":["../../lib/plugin.js"],"names":[],"mappings":";;;AAAA,6CAAuC;AACvC,qDAAgE;AAEhE;;GAEG;AACH,MAAM,UAAU;IAoCd;;;OAGG;IACH,YAAY,IAAI,EAAE,OAAO,GAAG,EAAE;QAC5B,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+56,26 @@ class BasePlugin {
56
56
  * `next` and `driver` objects since naturally we'd want to make sure to trigger the driver's own
57
57
  * `executeMethod` call if an execute method is not found on the plugin itself.
58
58
  *
59
- * @template {Driver} D
59
+ * @template {Constraints} C
60
60
  * @param {NextPluginCallback} next
61
- * @param {D} driver
61
+ * @param {Driver<C>} driver
62
62
  * @param {string} script
63
63
  * @param {[Record<string, any>]|[]} protoArgs
64
- * @this {Plugin}
65
64
  */
66
65
  async executeMethod(next, driver, script, protoArgs) {
67
- const Plugin = /** @type {PluginClass} */ (this.constructor);
66
+ const Plugin = /** @type {import('@appium/types').PluginClass<Plugin>} */ (this.constructor);
68
67
  const commandMetadata = {...Plugin.executeMethodMap?.[script]};
69
68
 
70
- /** @type {import('@appium/types').PluginCommand<D>|undefined} */
71
- let command;
72
-
73
- if (!commandMetadata.command || !(command = this[commandMetadata.command])) {
69
+ if (!commandMetadata.command || !(commandMetadata.command in this)) {
74
70
  this.logger.info(
75
71
  `Plugin did not know how to handle method '${script}'. Passing control to next`
76
72
  );
77
73
  return await next();
78
74
  }
75
+
76
+ const command = /** @type {import('@appium/types').PluginCommand<Driver<C>>} */ (
77
+ this[commandMetadata.command]
78
+ );
79
79
  const args = validateExecuteMethodParams(protoArgs, commandMetadata.params);
80
80
  return await command.call(this, next, driver, ...args);
81
81
  }
@@ -87,6 +87,10 @@ export {BasePlugin};
87
87
  /**
88
88
  * @typedef {import('@appium/types').Plugin} Plugin
89
89
  * @typedef {import('@appium/types').NextPluginCallback} NextPluginCallback
90
- * @typedef {import('@appium/types').Driver} Driver
91
- * @typedef {import('@appium/types').PluginClass} PluginClass
90
+ * @typedef {import('@appium/types').Constraints} Constraints
91
+ */
92
+
93
+ /**
94
+ * @template {Constraints} C
95
+ * @typedef {import('@appium/types').Driver<C>} Driver
92
96
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@appium/base-plugin",
3
- "version": "2.2.1",
3
+ "version": "2.2.3",
4
4
  "description": "The base plugin used to create Appium 2.0 plugins",
5
5
  "keywords": [
6
6
  "automation",
@@ -40,8 +40,8 @@
40
40
  "test:unit": "mocha \"./test/unit/**/*.spec.js\""
41
41
  },
42
42
  "dependencies": {
43
- "@appium/base-driver": "^9.3.1",
44
- "@appium/support": "^3.1.5"
43
+ "@appium/base-driver": "^9.3.3",
44
+ "@appium/support": "^3.1.7"
45
45
  },
46
46
  "engines": {
47
47
  "node": "^14.17.0 || ^16.13.0 || >=18.0.0",
@@ -50,7 +50,7 @@
50
50
  "publishConfig": {
51
51
  "access": "public"
52
52
  },
53
- "gitHead": "322363b8876a7ea7b630d538e22965f7bab0ea06",
53
+ "gitHead": "872b924a97c13142bdb8bf4218a4db324f309ce4",
54
54
  "tags": [
55
55
  "appium"
56
56
  ],