appium-uiwatchers-plugin 1.0.0 → 1.0.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.
- package/README.md +7 -2
- package/lib/commands/clear.d.ts +12 -0
- package/lib/commands/clear.d.ts.map +1 -0
- package/lib/commands/clear.js +22 -0
- package/lib/commands/clear.js.map +1 -0
- package/lib/commands/list.d.ts +12 -0
- package/lib/commands/list.d.ts.map +1 -0
- package/lib/commands/list.js +19 -0
- package/lib/commands/list.js.map +1 -0
- package/lib/commands/register.d.ts +13 -0
- package/lib/commands/register.d.ts.map +1 -0
- package/lib/commands/register.js +34 -0
- package/lib/commands/register.js.map +1 -0
- package/lib/commands/toggle.d.ts +18 -0
- package/lib/commands/toggle.d.ts.map +1 -0
- package/lib/commands/toggle.js +34 -0
- package/lib/commands/toggle.js.map +1 -0
- package/lib/commands/unregister.d.ts +13 -0
- package/lib/commands/unregister.d.ts.map +1 -0
- package/lib/commands/unregister.js +32 -0
- package/lib/commands/unregister.js.map +1 -0
- package/lib/config.d.ts +21 -0
- package/lib/config.d.ts.map +1 -0
- package/lib/config.js +13 -0
- package/lib/config.js.map +1 -0
- package/lib/element-cache.d.ts +93 -0
- package/lib/element-cache.d.ts.map +1 -0
- package/lib/element-cache.js +207 -0
- package/lib/element-cache.js.map +1 -0
- package/lib/plugin.d.ts +73 -0
- package/lib/plugin.d.ts.map +1 -0
- package/lib/plugin.js +353 -0
- package/lib/plugin.js.map +1 -0
- package/lib/types.d.ts +163 -0
- package/lib/types.d.ts.map +1 -0
- package/lib/types.js +5 -0
- package/lib/types.js.map +1 -0
- package/lib/utils.d.ts +24 -0
- package/lib/utils.d.ts.map +1 -0
- package/lib/utils.js +33 -0
- package/lib/utils.js.map +1 -0
- package/lib/validators.d.ts +18 -0
- package/lib/validators.d.ts.map +1 -0
- package/lib/validators.js +112 -0
- package/lib/validators.js.map +1 -0
- package/lib/watcher-checker.d.ts +12 -0
- package/lib/watcher-checker.d.ts.map +1 -0
- package/lib/watcher-checker.js +88 -0
- package/lib/watcher-checker.js.map +1 -0
- package/lib/watcher-store.d.ts +91 -0
- package/lib/watcher-store.d.ts.map +1 -0
- package/lib/watcher-store.js +177 -0
- package/lib/watcher-store.js.map +1 -0
- package/package.json +4 -1
- package/.c8rc.json +0 -12
- package/.github/workflows/npm-publish.yml +0 -28
- package/.husky/pre-commit +0 -4
- package/.lintstagedrc.json +0 -4
- package/.mocharc.json +0 -10
- package/.prettierignore +0 -6
- package/.prettierrc +0 -11
- package/eslint.config.js +0 -65
- package/src/commands/clear.ts +0 -28
- package/src/commands/list.ts +0 -23
- package/src/commands/register.ts +0 -47
- package/src/commands/toggle.ts +0 -43
- package/src/commands/unregister.ts +0 -43
- package/src/config.ts +0 -30
- package/src/element-cache.ts +0 -262
- package/src/plugin.ts +0 -437
- package/src/types.ts +0 -207
- package/src/utils.ts +0 -47
- package/src/validators.ts +0 -131
- package/src/watcher-checker.ts +0 -113
- package/src/watcher-store.ts +0 -210
- package/test/e2e/config.e2e.spec.cjs +0 -420
- package/test/e2e/plugin.e2e.spec.cjs +0 -312
- package/test/unit/element-cache.spec.js +0 -269
- package/test/unit/plugin.spec.js +0 -52
- package/test/unit/utils.spec.js +0 -85
- package/test/unit/validators.spec.js +0 -246
- package/test/unit/watcher-checker.spec.js +0 -274
- package/test/unit/watcher-store.spec.js +0 -405
- package/tsconfig.json +0 -31
package/lib/utils.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Utility functions for UI Watchers Plugin
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* W3C WebDriver Element Identifier key
|
|
6
|
+
* This is the standard key used in W3C WebDriver protocol to identify elements
|
|
7
|
+
*/
|
|
8
|
+
export const W3C_ELEMENT_KEY = 'element-6066-11e4-a52e-4f735466cecf';
|
|
9
|
+
/**
|
|
10
|
+
* Extract element ID from element object
|
|
11
|
+
* Handles W3C format, JSONWP format, and direct string IDs
|
|
12
|
+
*
|
|
13
|
+
* @param element - Element object or string ID
|
|
14
|
+
* @returns The element ID string, or undefined if not found
|
|
15
|
+
*/
|
|
16
|
+
export function extractElementId(element) {
|
|
17
|
+
if (!element)
|
|
18
|
+
return undefined;
|
|
19
|
+
// Direct string ID
|
|
20
|
+
if (typeof element === 'string') {
|
|
21
|
+
return element;
|
|
22
|
+
}
|
|
23
|
+
// W3C format
|
|
24
|
+
if (element[W3C_ELEMENT_KEY]) {
|
|
25
|
+
return element[W3C_ELEMENT_KEY];
|
|
26
|
+
}
|
|
27
|
+
// JSONWP format
|
|
28
|
+
if (element.ELEMENT) {
|
|
29
|
+
return element.ELEMENT;
|
|
30
|
+
}
|
|
31
|
+
return undefined;
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=utils.js.map
|
package/lib/utils.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;;GAGG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,qCAAqC,CAAC;AAUrE;;;;;;GAMG;AACH,MAAM,UAAU,gBAAgB,CAC9B,OAAkD;IAElD,IAAI,CAAC,OAAO;QAAE,OAAO,SAAS,CAAC;IAE/B,mBAAmB;IACnB,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE,CAAC;QAChC,OAAO,OAAO,CAAC;IACjB,CAAC;IAED,aAAa;IACb,IAAI,OAAO,CAAC,eAAe,CAAC,EAAE,CAAC;QAC7B,OAAO,OAAO,CAAC,eAAe,CAAC,CAAC;IAClC,CAAC;IAED,gBAAgB;IAChB,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;QACpB,OAAO,OAAO,CAAC,OAAO,CAAC;IACzB,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Validation functions for UI Watcher registration parameters
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Validates a locator object
|
|
6
|
+
* @param locator - The locator to validate
|
|
7
|
+
* @param fieldName - Name of the field for error messages
|
|
8
|
+
* @throws Error if locator is invalid
|
|
9
|
+
*/
|
|
10
|
+
export declare function validateLocator(locator: any, fieldName: string): void;
|
|
11
|
+
/**
|
|
12
|
+
* Validates all watcher registration parameters
|
|
13
|
+
* @param params - Watcher registration parameters
|
|
14
|
+
* @param maxDurationMs - Maximum allowed duration in milliseconds
|
|
15
|
+
* @throws Error if any validation rule fails
|
|
16
|
+
*/
|
|
17
|
+
export declare function validateWatcherParams(params: any, maxDurationMs: number): void;
|
|
18
|
+
//# sourceMappingURL=validators.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validators.d.ts","sourceRoot":"","sources":["../src/validators.ts"],"names":[],"mappings":"AAAA;;GAEG;AAiBH;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,GAAG,IAAI,CA6BrE;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,GAAG,EAAE,aAAa,EAAE,MAAM,GAAG,IAAI,CAoE9E"}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Validation functions for UI Watcher registration parameters
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Valid Appium locator strategies
|
|
6
|
+
*/
|
|
7
|
+
const VALID_LOCATOR_STRATEGIES = [
|
|
8
|
+
'id',
|
|
9
|
+
'accessibility id',
|
|
10
|
+
'class name',
|
|
11
|
+
'xpath',
|
|
12
|
+
'name',
|
|
13
|
+
'-android uiautomator',
|
|
14
|
+
'-ios predicate string',
|
|
15
|
+
'-ios class chain',
|
|
16
|
+
'css selector',
|
|
17
|
+
];
|
|
18
|
+
/**
|
|
19
|
+
* Validates a locator object
|
|
20
|
+
* @param locator - The locator to validate
|
|
21
|
+
* @param fieldName - Name of the field for error messages
|
|
22
|
+
* @throws Error if locator is invalid
|
|
23
|
+
*/
|
|
24
|
+
export function validateLocator(locator, fieldName) {
|
|
25
|
+
// Check if locator exists
|
|
26
|
+
if (!locator || typeof locator !== 'object') {
|
|
27
|
+
throw new Error(`${fieldName} is required`);
|
|
28
|
+
}
|
|
29
|
+
// Check if 'using' field exists and is a string
|
|
30
|
+
if (!locator.using) {
|
|
31
|
+
throw new Error(`'using' is mandatory for ${fieldName}`);
|
|
32
|
+
}
|
|
33
|
+
if (typeof locator.using !== 'string') {
|
|
34
|
+
throw new Error(`'using' must be string for ${fieldName} `);
|
|
35
|
+
}
|
|
36
|
+
// Check if 'value' field exists and is a string
|
|
37
|
+
if (!locator.value) {
|
|
38
|
+
throw new Error(`'value' is mandatory for ${fieldName}`);
|
|
39
|
+
}
|
|
40
|
+
if (typeof locator.value !== 'string') {
|
|
41
|
+
throw new Error(`'value' must be string for ${fieldName} `);
|
|
42
|
+
}
|
|
43
|
+
// Validate locator strategy (case-insensitive)
|
|
44
|
+
const strategy = locator.using.toLowerCase();
|
|
45
|
+
if (!VALID_LOCATOR_STRATEGIES.includes(strategy)) {
|
|
46
|
+
throw new Error(`Invalid locator strategy for ${fieldName}`);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Validates all watcher registration parameters
|
|
51
|
+
* @param params - Watcher registration parameters
|
|
52
|
+
* @param maxDurationMs - Maximum allowed duration in milliseconds
|
|
53
|
+
* @throws Error if any validation rule fails
|
|
54
|
+
*/
|
|
55
|
+
export function validateWatcherParams(params, maxDurationMs) {
|
|
56
|
+
// Check if params exists
|
|
57
|
+
if (!params || typeof params !== 'object') {
|
|
58
|
+
throw new Error('Invalid watcher parameters');
|
|
59
|
+
}
|
|
60
|
+
// Validate required field: name
|
|
61
|
+
if (!params.name) {
|
|
62
|
+
throw new Error('UIWatcher name is required');
|
|
63
|
+
}
|
|
64
|
+
if (typeof params.name !== 'string') {
|
|
65
|
+
throw new Error('UIWatcher name must be string type');
|
|
66
|
+
}
|
|
67
|
+
if (params.name.trim() === '') {
|
|
68
|
+
throw new Error('UIWatcher name is empty');
|
|
69
|
+
}
|
|
70
|
+
// Validate required field: referenceLocator
|
|
71
|
+
if (!params.referenceLocator) {
|
|
72
|
+
throw new Error('UIWatcher referenceLocator is required');
|
|
73
|
+
}
|
|
74
|
+
validateLocator(params.referenceLocator, 'referenceLocator');
|
|
75
|
+
// Validate required field: actionLocator
|
|
76
|
+
if (!params.actionLocator) {
|
|
77
|
+
throw new Error('UIWatcher actionLocator is required');
|
|
78
|
+
}
|
|
79
|
+
validateLocator(params.actionLocator, 'actionLocator');
|
|
80
|
+
// Validate required field: duration
|
|
81
|
+
if (params.duration === undefined || params.duration === null) {
|
|
82
|
+
throw new Error('UIWatcher duration is required');
|
|
83
|
+
}
|
|
84
|
+
if (typeof params.duration !== 'number' || params.duration <= 0) {
|
|
85
|
+
throw new Error('UIWatcher duration must be a positive number');
|
|
86
|
+
}
|
|
87
|
+
if (params.duration > maxDurationMs) {
|
|
88
|
+
throw new Error(`UIWatcher duration must be ≤ ${maxDurationMs / 1000} seconds`);
|
|
89
|
+
}
|
|
90
|
+
// Validate optional field: priority (if provided)
|
|
91
|
+
if (params.priority !== undefined && params.priority !== null) {
|
|
92
|
+
if (typeof params.priority !== 'number') {
|
|
93
|
+
throw new Error('UIWatcher priority must be a number');
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
// Validate optional field: stopOnFound (if provided)
|
|
97
|
+
if (params.stopOnFound !== undefined && params.stopOnFound !== null) {
|
|
98
|
+
if (typeof params.stopOnFound !== 'boolean') {
|
|
99
|
+
throw new Error('UIWatcher stopOnFound must be a boolean');
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
// Validate optional field: cooldownMs (if provided)
|
|
103
|
+
if (params.cooldownMs !== undefined && params.cooldownMs !== null) {
|
|
104
|
+
if (typeof params.cooldownMs !== 'number') {
|
|
105
|
+
throw new Error('UIWatcher cooldownMs must be a number');
|
|
106
|
+
}
|
|
107
|
+
if (params.cooldownMs < 0) {
|
|
108
|
+
throw new Error('UIWatcher cooldownMs must be ≥ 0');
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
//# sourceMappingURL=validators.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validators.js","sourceRoot":"","sources":["../src/validators.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;GAEG;AACH,MAAM,wBAAwB,GAAG;IAC/B,IAAI;IACJ,kBAAkB;IAClB,YAAY;IACZ,OAAO;IACP,MAAM;IACN,sBAAsB;IACtB,uBAAuB;IACvB,kBAAkB;IAClB,cAAc;CACf,CAAC;AAEF;;;;;GAKG;AACH,MAAM,UAAU,eAAe,CAAC,OAAY,EAAE,SAAiB;IAC7D,0BAA0B;IAC1B,IAAI,CAAC,OAAO,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE,CAAC;QAC5C,MAAM,IAAI,KAAK,CAAC,GAAG,SAAS,cAAc,CAAC,CAAC;IAC9C,CAAC;IAED,gDAAgD;IAChD,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;QACnB,MAAM,IAAI,KAAK,CAAC,4BAA4B,SAAS,EAAE,CAAC,CAAC;IAC3D,CAAC;IAED,IAAI,OAAO,OAAO,CAAC,KAAK,KAAK,QAAQ,EAAE,CAAC;QACtC,MAAM,IAAI,KAAK,CAAC,8BAA8B,SAAS,GAAG,CAAC,CAAC;IAC9D,CAAC;IAED,gDAAgD;IAChD,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;QACnB,MAAM,IAAI,KAAK,CAAC,4BAA4B,SAAS,EAAE,CAAC,CAAC;IAC3D,CAAC;IAED,IAAI,OAAO,OAAO,CAAC,KAAK,KAAK,QAAQ,EAAE,CAAC;QACtC,MAAM,IAAI,KAAK,CAAC,8BAA8B,SAAS,GAAG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AAC,EAAE,CAAC;YAC1B,MAAM,IAAI,KAAK,CAAC,kCAAkC,CAAC,CAAC;QACtD,CAAC;IACH,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Core watcher checking algorithm
|
|
3
|
+
*/
|
|
4
|
+
import type { WatcherStore } from './watcher-store.js';
|
|
5
|
+
/**
|
|
6
|
+
* Check all active watchers and execute actions for matching elements
|
|
7
|
+
* @param driver - Appium driver instance
|
|
8
|
+
* @param store - Watcher store instance
|
|
9
|
+
* @returns true if at least one watcher was successfully triggered, false otherwise
|
|
10
|
+
*/
|
|
11
|
+
export declare function checkWatchers(driver: any, store: WatcherStore): Promise<boolean>;
|
|
12
|
+
//# sourceMappingURL=watcher-checker.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"watcher-checker.d.ts","sourceRoot":"","sources":["../src/watcher-checker.ts"],"names":[],"mappings":"AAAA;;GAEG;AAKH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAIvD;;;;;GAKG;AACH,wBAAsB,aAAa,CAAC,MAAM,EAAE,GAAG,EAAE,KAAK,EAAE,YAAY,GAAG,OAAO,CAAC,OAAO,CAAC,CA+FtF"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Core watcher checking algorithm
|
|
3
|
+
*/
|
|
4
|
+
/* global setTimeout */
|
|
5
|
+
import { logger } from '@appium/support';
|
|
6
|
+
const log = logger.getLogger('AppiumUIWatchers');
|
|
7
|
+
/**
|
|
8
|
+
* Check all active watchers and execute actions for matching elements
|
|
9
|
+
* @param driver - Appium driver instance
|
|
10
|
+
* @param store - Watcher store instance
|
|
11
|
+
* @returns true if at least one watcher was successfully triggered, false otherwise
|
|
12
|
+
*/
|
|
13
|
+
export async function checkWatchers(driver, store) {
|
|
14
|
+
// Track if any watcher was triggered
|
|
15
|
+
let watcherTriggered = false;
|
|
16
|
+
// Check if watchers are globally disabled
|
|
17
|
+
if (!store.isEnabled()) {
|
|
18
|
+
log.debug('[UIWatchers] Watcher checking is disabled, skipping');
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
// Get active, sorted watchers (by priority desc, then FIFO)
|
|
22
|
+
const watchers = store.getSortedWatchers();
|
|
23
|
+
// Early return if no active watchers
|
|
24
|
+
if (watchers.length === 0) {
|
|
25
|
+
log.debug('[UIWatchers] No active watchers to check');
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
log.debug(`[UIWatchers] Checking ${watchers.length} active watchers`);
|
|
29
|
+
// Check each watcher in priority order
|
|
30
|
+
for (const watcher of watchers) {
|
|
31
|
+
// Skip inactive watchers (marked inactive by stopOnFound)
|
|
32
|
+
if (watcher.status === 'inactive') {
|
|
33
|
+
log.debug(`[UIWatchers] Skipping inactive watcher '${watcher.name}'`);
|
|
34
|
+
continue;
|
|
35
|
+
}
|
|
36
|
+
log.debug(`[UIWatchers] Checking watcher '${watcher.name}' (priority=${watcher.priority})`);
|
|
37
|
+
try {
|
|
38
|
+
// Try to find the reference element
|
|
39
|
+
try {
|
|
40
|
+
await driver.findElement(watcher.referenceLocator.using, watcher.referenceLocator.value);
|
|
41
|
+
}
|
|
42
|
+
catch {
|
|
43
|
+
// Reference element not found - continue to next watcher
|
|
44
|
+
log.debug(`[UIWatchers] Watcher '${watcher.name}': Reference element not found`);
|
|
45
|
+
continue;
|
|
46
|
+
}
|
|
47
|
+
// Reference element found
|
|
48
|
+
log.debug(`[UIWatchers] Watcher '${watcher.name}': Reference element found`);
|
|
49
|
+
// Try to find and click the action element
|
|
50
|
+
try {
|
|
51
|
+
const actionElement = await driver.findElement(watcher.actionLocator.using, watcher.actionLocator.value);
|
|
52
|
+
// Click the action element
|
|
53
|
+
await driver.click(actionElement.ELEMENT || actionElement);
|
|
54
|
+
// Action click succeeded
|
|
55
|
+
log.info(`[UIWatchers] UIWatcher '${watcher.name}' triggered successfully`);
|
|
56
|
+
watcherTriggered = true;
|
|
57
|
+
// Update trigger statistics
|
|
58
|
+
store.incrementTriggerCount(watcher.name);
|
|
59
|
+
// Mark as inactive if stopOnFound is true
|
|
60
|
+
if (watcher.stopOnFound) {
|
|
61
|
+
store.markInactive(watcher.name);
|
|
62
|
+
log.debug(`[UIWatchers] Watcher '${watcher.name}' marked inactive (stopOnFound=true)`);
|
|
63
|
+
}
|
|
64
|
+
// Execute cooldown wait if configured
|
|
65
|
+
if (watcher.cooldownMs > 0) {
|
|
66
|
+
log.debug(`[UIWatchers] Watcher '${watcher.name}': Executing cooldown wait (${watcher.cooldownMs}ms)`);
|
|
67
|
+
await new Promise((resolve) => setTimeout(resolve, watcher.cooldownMs));
|
|
68
|
+
log.debug(`[UIWatchers] Watcher '${watcher.name}': Cooldown complete`);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
catch (clickError) {
|
|
72
|
+
// Action click failed
|
|
73
|
+
log.warn(`[UIWatchers] UIWatcher '${watcher.name}' action click failed: ${clickError.message}`);
|
|
74
|
+
// Continue to next watcher (don't execute cooldown or mark inactive)
|
|
75
|
+
continue;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
catch (error) {
|
|
79
|
+
// Unexpected error during watcher checking
|
|
80
|
+
log.error(`[UIWatchers] Unexpected error checking watcher '${watcher.name}': ${error.message}`);
|
|
81
|
+
// Continue to next watcher
|
|
82
|
+
continue;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
log.debug(`[UIWatchers] Watcher checking complete (triggered=${watcherTriggered})`);
|
|
86
|
+
return watcherTriggered;
|
|
87
|
+
}
|
|
88
|
+
//# sourceMappingURL=watcher-checker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"watcher-checker.js","sourceRoot":"","sources":["../src/watcher-checker.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,uBAAuB;AAEvB,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC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CAAC;gBACzE,CAAC;YACH,CAAC;YAAC,OAAO,UAAe,EAAE,CAAC;gBACzB,sBAAsB;gBACtB,GAAG,CAAC,IAAI,CACN,2BAA2B,OAAO,CAAC,IAAI,0BAA0B,UAAU,CAAC,OAAO,EAAE,CACtF,CAAC;gBACF,qEAAqE;gBACrE,SAAS;YACX,CAAC;QACH,CAAC;QAAC,OAAO,KAAU,EAAE,CAAC;YACpB,2CAA2C;YAC3C,GAAG,CAAC,KAAK,CACP,mDAAmD,OAAO,CAAC,IAAI,MAAM,KAAK,CAAC,OAAO,EAAE,CACrF,CAAC;YACF,2BAA2B;YAC3B,SAAS;QACX,CAAC;IACH,CAAC;IAED,GAAG,CAAC,KAAK,CAAC,qDAAqD,gBAAgB,GAAG,CAAC,CAAC;IACpF,OAAO,gBAAgB,CAAC;AAC1B,CAAC"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WatcherStore - In-memory storage for registered UI watchers
|
|
3
|
+
*/
|
|
4
|
+
import type { WatcherState, UIWatcher } from './types.js';
|
|
5
|
+
import type { PluginConfig } from './config.js';
|
|
6
|
+
/**
|
|
7
|
+
* WatcherStore manages the lifecycle and state of all registered UI watchers
|
|
8
|
+
*/
|
|
9
|
+
export declare class WatcherStore {
|
|
10
|
+
/** Internal storage for watchers (keyed by watcher name) */
|
|
11
|
+
private watchers;
|
|
12
|
+
/** Global enable/disable flag for watcher checking */
|
|
13
|
+
private enabled;
|
|
14
|
+
/** Plugin configuration */
|
|
15
|
+
private config;
|
|
16
|
+
constructor(config: Required<PluginConfig>);
|
|
17
|
+
/**
|
|
18
|
+
* Get the plugin configuration
|
|
19
|
+
* @returns The plugin configuration
|
|
20
|
+
*/
|
|
21
|
+
getConfig(): Required<PluginConfig>;
|
|
22
|
+
/**
|
|
23
|
+
* Add a new watcher to the store
|
|
24
|
+
* @param watcher - Watcher registration parameters
|
|
25
|
+
* @returns The created watcher state
|
|
26
|
+
* @throws Error if validation fails
|
|
27
|
+
*/
|
|
28
|
+
add(watcher: UIWatcher): WatcherState;
|
|
29
|
+
/**
|
|
30
|
+
* Remove a watcher by name
|
|
31
|
+
* @param name - Name of the watcher to remove
|
|
32
|
+
* @returns True if watcher was removed, false if not found
|
|
33
|
+
*/
|
|
34
|
+
remove(name: string): boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Get a watcher by name
|
|
37
|
+
* @param name - Name of the watcher to retrieve
|
|
38
|
+
* @returns The watcher state, or undefined if not found
|
|
39
|
+
*/
|
|
40
|
+
get(name: string): WatcherState | undefined;
|
|
41
|
+
/**
|
|
42
|
+
* Get all watchers (including expired ones)
|
|
43
|
+
* @returns Array of all watchers
|
|
44
|
+
*/
|
|
45
|
+
list(): WatcherState[];
|
|
46
|
+
/**
|
|
47
|
+
* Get only active (non-expired) watchers
|
|
48
|
+
* Automatically removes expired watchers from storage
|
|
49
|
+
* @returns Array of active watchers
|
|
50
|
+
*/
|
|
51
|
+
getActiveWatchers(): WatcherState[];
|
|
52
|
+
/**
|
|
53
|
+
* Get active watchers sorted by priority (descending) and registration time (FIFO)
|
|
54
|
+
* @returns Array of sorted active watchers
|
|
55
|
+
*/
|
|
56
|
+
getSortedWatchers(): WatcherState[];
|
|
57
|
+
/**
|
|
58
|
+
* Clear all watchers from the store
|
|
59
|
+
* @returns Number of watchers removed
|
|
60
|
+
*/
|
|
61
|
+
clear(): number;
|
|
62
|
+
/**
|
|
63
|
+
* Mark a watcher as inactive (used for stopOnFound)
|
|
64
|
+
* @param name - Name of the watcher to mark inactive
|
|
65
|
+
*/
|
|
66
|
+
markInactive(name: string): void;
|
|
67
|
+
/**
|
|
68
|
+
* Increment the trigger count for a watcher
|
|
69
|
+
* @param name - Name of the watcher
|
|
70
|
+
*/
|
|
71
|
+
incrementTriggerCount(name: string): void;
|
|
72
|
+
/**
|
|
73
|
+
* Update the last triggered timestamp for a watcher
|
|
74
|
+
* @param name - Name of the watcher
|
|
75
|
+
*/
|
|
76
|
+
updateLastTriggered(name: string): void;
|
|
77
|
+
/**
|
|
78
|
+
* Disable watcher checking globally
|
|
79
|
+
*/
|
|
80
|
+
disable(): void;
|
|
81
|
+
/**
|
|
82
|
+
* Enable watcher checking globally
|
|
83
|
+
*/
|
|
84
|
+
enable(): void;
|
|
85
|
+
/**
|
|
86
|
+
* Check if watcher checking is enabled
|
|
87
|
+
* @returns True if enabled, false otherwise
|
|
88
|
+
*/
|
|
89
|
+
isEnabled(): boolean;
|
|
90
|
+
}
|
|
91
|
+
//# sourceMappingURL=watcher-store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"watcher-store.d.ts","sourceRoot":"","sources":["../src/watcher-store.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAC1D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEhD;;GAEG;AACH,qBAAa,YAAY;IACvB,4DAA4D;IAC5D,OAAO,CAAC,QAAQ,CAA4B;IAE5C,sDAAsD;IACtD,OAAO,CAAC,OAAO,CAAU;IAEzB,2BAA2B;IAC3B,OAAO,CAAC,MAAM,CAAyB;gBAE3B,MAAM,EAAE,QAAQ,CAAC,YAAY,CAAC;IAM1C;;;OAGG;IACH,SAAS,IAAI,QAAQ,CAAC,YAAY,CAAC;IAInC;;;;;OAKG;IACH,GAAG,CAAC,OAAO,EAAE,SAAS,GAAG,YAAY;IAiCrC;;;;OAIG;IACH,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAI7B;;;;OAIG;IACH,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,YAAY,GAAG,SAAS;IAI3C;;;OAGG;IACH,IAAI,IAAI,YAAY,EAAE;IAItB;;;;OAIG;IACH,iBAAiB,IAAI,YAAY,EAAE;IAsBnC;;;OAGG;IACH,iBAAiB,IAAI,YAAY,EAAE;IAcnC;;;OAGG;IACH,KAAK,IAAI,MAAM;IAMf;;;OAGG;IACH,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAOhC;;;OAGG;IACH,qBAAqB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAQzC;;;OAGG;IACH,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAOvC;;OAEG;IACH,OAAO,IAAI,IAAI;IAIf;;OAEG;IACH,MAAM,IAAI,IAAI;IAId;;;OAGG;IACH,SAAS,IAAI,OAAO;CAGrB"}
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WatcherStore - In-memory storage for registered UI watchers
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* WatcherStore manages the lifecycle and state of all registered UI watchers
|
|
6
|
+
*/
|
|
7
|
+
export class WatcherStore {
|
|
8
|
+
constructor(config) {
|
|
9
|
+
this.watchers = new Map();
|
|
10
|
+
this.enabled = true;
|
|
11
|
+
this.config = config;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Get the plugin configuration
|
|
15
|
+
* @returns The plugin configuration
|
|
16
|
+
*/
|
|
17
|
+
getConfig() {
|
|
18
|
+
return this.config;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Add a new watcher to the store
|
|
22
|
+
* @param watcher - Watcher registration parameters
|
|
23
|
+
* @returns The created watcher state
|
|
24
|
+
* @throws Error if validation fails
|
|
25
|
+
*/
|
|
26
|
+
add(watcher) {
|
|
27
|
+
// Check for duplicate name
|
|
28
|
+
if (this.watchers.has(watcher.name)) {
|
|
29
|
+
throw new Error(`UIWatcher with name '${watcher.name}' already exists`);
|
|
30
|
+
}
|
|
31
|
+
// Check maximum watcher limit (count only non-expired watchers)
|
|
32
|
+
const activeCount = this.getActiveWatchers().length;
|
|
33
|
+
if (activeCount >= this.config.maxWatchers) {
|
|
34
|
+
throw new Error(`Maximum ${this.config.maxWatchers} UI watchers allowed per session`);
|
|
35
|
+
}
|
|
36
|
+
// Create watcher state with computed fields
|
|
37
|
+
const now = Date.now();
|
|
38
|
+
const watcherState = {
|
|
39
|
+
name: watcher.name,
|
|
40
|
+
priority: watcher.priority ?? 0,
|
|
41
|
+
referenceLocator: watcher.referenceLocator,
|
|
42
|
+
actionLocator: watcher.actionLocator,
|
|
43
|
+
duration: watcher.duration,
|
|
44
|
+
stopOnFound: watcher.stopOnFound ?? false,
|
|
45
|
+
cooldownMs: watcher.cooldownMs ?? 0,
|
|
46
|
+
registeredAt: now,
|
|
47
|
+
expiresAt: now + watcher.duration,
|
|
48
|
+
status: 'active',
|
|
49
|
+
triggerCount: 0,
|
|
50
|
+
lastTriggeredAt: null,
|
|
51
|
+
};
|
|
52
|
+
this.watchers.set(watcher.name, watcherState);
|
|
53
|
+
return watcherState;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Remove a watcher by name
|
|
57
|
+
* @param name - Name of the watcher to remove
|
|
58
|
+
* @returns True if watcher was removed, false if not found
|
|
59
|
+
*/
|
|
60
|
+
remove(name) {
|
|
61
|
+
return this.watchers.delete(name);
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Get a watcher by name
|
|
65
|
+
* @param name - Name of the watcher to retrieve
|
|
66
|
+
* @returns The watcher state, or undefined if not found
|
|
67
|
+
*/
|
|
68
|
+
get(name) {
|
|
69
|
+
return this.watchers.get(name);
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Get all watchers (including expired ones)
|
|
73
|
+
* @returns Array of all watchers
|
|
74
|
+
*/
|
|
75
|
+
list() {
|
|
76
|
+
return Array.from(this.watchers.values());
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Get only active (non-expired) watchers
|
|
80
|
+
* Automatically removes expired watchers from storage
|
|
81
|
+
* @returns Array of active watchers
|
|
82
|
+
*/
|
|
83
|
+
getActiveWatchers() {
|
|
84
|
+
const now = Date.now();
|
|
85
|
+
const activeWatchers = [];
|
|
86
|
+
const expiredNames = [];
|
|
87
|
+
// Identify active and expired watchers
|
|
88
|
+
for (const [name, watcher] of this.watchers.entries()) {
|
|
89
|
+
if (now >= watcher.expiresAt) {
|
|
90
|
+
expiredNames.push(name);
|
|
91
|
+
}
|
|
92
|
+
else {
|
|
93
|
+
activeWatchers.push(watcher);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
// Remove expired watchers
|
|
97
|
+
for (const name of expiredNames) {
|
|
98
|
+
this.watchers.delete(name);
|
|
99
|
+
}
|
|
100
|
+
return activeWatchers;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Get active watchers sorted by priority (descending) and registration time (FIFO)
|
|
104
|
+
* @returns Array of sorted active watchers
|
|
105
|
+
*/
|
|
106
|
+
getSortedWatchers() {
|
|
107
|
+
const activeWatchers = this.getActiveWatchers();
|
|
108
|
+
return activeWatchers.sort((a, b) => {
|
|
109
|
+
// Sort by priority descending (higher priority first)
|
|
110
|
+
if (a.priority !== b.priority) {
|
|
111
|
+
return b.priority - a.priority;
|
|
112
|
+
}
|
|
113
|
+
// If priority is the same, sort by registration time ascending (FIFO)
|
|
114
|
+
return a.registeredAt - b.registeredAt;
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Clear all watchers from the store
|
|
119
|
+
* @returns Number of watchers removed
|
|
120
|
+
*/
|
|
121
|
+
clear() {
|
|
122
|
+
const count = this.watchers.size;
|
|
123
|
+
this.watchers.clear();
|
|
124
|
+
return count;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Mark a watcher as inactive (used for stopOnFound)
|
|
128
|
+
* @param name - Name of the watcher to mark inactive
|
|
129
|
+
*/
|
|
130
|
+
markInactive(name) {
|
|
131
|
+
const watcher = this.watchers.get(name);
|
|
132
|
+
if (watcher) {
|
|
133
|
+
watcher.status = 'inactive';
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Increment the trigger count for a watcher
|
|
138
|
+
* @param name - Name of the watcher
|
|
139
|
+
*/
|
|
140
|
+
incrementTriggerCount(name) {
|
|
141
|
+
const watcher = this.watchers.get(name);
|
|
142
|
+
if (watcher) {
|
|
143
|
+
watcher.triggerCount++;
|
|
144
|
+
watcher.lastTriggeredAt = Date.now();
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Update the last triggered timestamp for a watcher
|
|
149
|
+
* @param name - Name of the watcher
|
|
150
|
+
*/
|
|
151
|
+
updateLastTriggered(name) {
|
|
152
|
+
const watcher = this.watchers.get(name);
|
|
153
|
+
if (watcher) {
|
|
154
|
+
watcher.lastTriggeredAt = Date.now();
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Disable watcher checking globally
|
|
159
|
+
*/
|
|
160
|
+
disable() {
|
|
161
|
+
this.enabled = false;
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Enable watcher checking globally
|
|
165
|
+
*/
|
|
166
|
+
enable() {
|
|
167
|
+
this.enabled = true;
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Check if watcher checking is enabled
|
|
171
|
+
* @returns True if enabled, false otherwise
|
|
172
|
+
*/
|
|
173
|
+
isEnabled() {
|
|
174
|
+
return this.enabled;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
//# sourceMappingURL=watcher-store.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"watcher-store.js","sourceRoot":"","sources":["../src/watcher-store.ts"],"names":[],"mappings":"AAAA;;GAEG;AAKH;;GAEG;AACH,MAAM,OAAO,YAAY;IAUvB,YAAY,MAA8B;QACxC,IAAI,CAAC,QAAQ,GAAG,IAAI,GAAG,EAAE,CAAC;QAC1B,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;QACpB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAED;;;OAGG;IACH,SAAS;QACP,OA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AC,OAAO,CAAC;IACtB,CAAC;CACF"}
|
package/package.json
CHANGED
package/.c8rc.json
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"all": true,
|
|
3
|
-
"include": ["lib/**/*.js"],
|
|
4
|
-
"exclude": ["test/**", "**/*.spec.js", "**/*.test.js", "**/*.e2e.spec.cjs", "lib/types.js"],
|
|
5
|
-
"reporter": ["text", "html", "lcov"],
|
|
6
|
-
"report-dir": "./coverage",
|
|
7
|
-
"check-coverage": true,
|
|
8
|
-
"lines": 80,
|
|
9
|
-
"statements": 80,
|
|
10
|
-
"functions": 80,
|
|
11
|
-
"branches": 80
|
|
12
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
name: Publish to NPM
|
|
2
|
-
|
|
3
|
-
on:
|
|
4
|
-
release:
|
|
5
|
-
types: [published]
|
|
6
|
-
|
|
7
|
-
jobs:
|
|
8
|
-
publish:
|
|
9
|
-
runs-on: ubuntu-latest
|
|
10
|
-
permissions:
|
|
11
|
-
contents: read
|
|
12
|
-
id-token: write
|
|
13
|
-
steps:
|
|
14
|
-
- uses: actions/checkout@v4
|
|
15
|
-
|
|
16
|
-
- uses: actions/setup-node@v4
|
|
17
|
-
with:
|
|
18
|
-
node-version: '20.x'
|
|
19
|
-
registry-url: 'https://registry.npmjs.org'
|
|
20
|
-
|
|
21
|
-
- name: Install latest npm
|
|
22
|
-
run: npm install -g npm@latest
|
|
23
|
-
|
|
24
|
-
- name: Install dependencies
|
|
25
|
-
run: npm ci
|
|
26
|
-
|
|
27
|
-
- name: Publish to npm
|
|
28
|
-
run: npm publish --provenance --access public
|
package/.husky/pre-commit
DELETED
package/.lintstagedrc.json
DELETED
package/.mocharc.json
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"require": ["@appium/support/build/lib/env"],
|
|
3
|
-
"timeout": 20000,
|
|
4
|
-
"slow": 10000,
|
|
5
|
-
"reporter": "spec",
|
|
6
|
-
"color": true,
|
|
7
|
-
"recursive": true,
|
|
8
|
-
"exit": true,
|
|
9
|
-
"spec": ["test/unit/**/*.spec.js", "test/integration/**/*.spec.js", "test/e2e/**/*.e2e.spec.cjs"]
|
|
10
|
-
}
|