@axe-core/watcher 0.0.0 → 0.0.1-next.47b61783

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.
@@ -0,0 +1,4 @@
1
+ export { puppeteerConfig, PuppeteerManualController } from './puppeteer';
2
+ export { wdioConfig, wdioTestRunner, WdioManualController } from './wdio';
3
+ export { webdriverConfig, WebdriverManualController } from './webdriver';
4
+ export { playwrightConfig, PlaywrightManualController } from './playwright';
package/dist/index.js ADDED
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PlaywrightManualController = exports.playwrightConfig = exports.WebdriverManualController = exports.webdriverConfig = exports.WdioManualController = exports.wdioTestRunner = exports.wdioConfig = exports.PuppeteerManualController = exports.puppeteerConfig = void 0;
4
+ var puppeteer_1 = require("./puppeteer");
5
+ Object.defineProperty(exports, "puppeteerConfig", { enumerable: true, get: function () { return puppeteer_1.puppeteerConfig; } });
6
+ Object.defineProperty(exports, "PuppeteerManualController", { enumerable: true, get: function () { return puppeteer_1.PuppeteerManualController; } });
7
+ var wdio_1 = require("./wdio");
8
+ Object.defineProperty(exports, "wdioConfig", { enumerable: true, get: function () { return wdio_1.wdioConfig; } });
9
+ Object.defineProperty(exports, "wdioTestRunner", { enumerable: true, get: function () { return wdio_1.wdioTestRunner; } });
10
+ Object.defineProperty(exports, "WdioManualController", { enumerable: true, get: function () { return wdio_1.WdioManualController; } });
11
+ var webdriver_1 = require("./webdriver");
12
+ Object.defineProperty(exports, "webdriverConfig", { enumerable: true, get: function () { return webdriver_1.webdriverConfig; } });
13
+ Object.defineProperty(exports, "WebdriverManualController", { enumerable: true, get: function () { return webdriver_1.WebdriverManualController; } });
14
+ var playwright_1 = require("./playwright");
15
+ Object.defineProperty(exports, "playwrightConfig", { enumerable: true, get: function () { return playwright_1.playwrightConfig; } });
16
+ Object.defineProperty(exports, "PlaywrightManualController", { enumerable: true, get: function () { return playwright_1.PlaywrightManualController; } });
17
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,yCAAwE;AAA/D,4GAAA,eAAe,OAAA;AAAE,sHAAA,yBAAyB,OAAA;AACnD,+BAAyE;AAAhE,kGAAA,UAAU,OAAA;AAAE,sGAAA,cAAc,OAAA;AAAE,4GAAA,oBAAoB,OAAA;AACzD,yCAAwE;AAA/D,4GAAA,eAAe,OAAA;AAAE,sHAAA,yBAAyB,OAAA;AACnD,2CAA2E;AAAlE,8GAAA,gBAAgB,OAAA;AAAE,wHAAA,0BAA0B,OAAA"}
@@ -0,0 +1,13 @@
1
+ import { Configuration, ManualController } from './util';
2
+ import type { LaunchOptions, Page } from 'playwright';
3
+ /**
4
+ * Creates a Playwright config that uses axe extension
5
+ *
6
+ * @param opts Playwright config to extend
7
+ */
8
+ export declare function playwrightConfig(opts: Configuration & LaunchOptions): LaunchOptions;
9
+ export declare class PlaywrightManualController extends ManualController {
10
+ private driver;
11
+ constructor(driver: Page);
12
+ protected executeScript(fn: string | (() => Promise<void>)): Promise<void>;
13
+ }
@@ -0,0 +1,116 @@
1
+ "use strict";
2
+ var __extends = (this && this.__extends) || (function () {
3
+ var extendStatics = function (d, b) {
4
+ extendStatics = Object.setPrototypeOf ||
5
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
+ return extendStatics(d, b);
8
+ };
9
+ return function (d, b) {
10
+ if (typeof b !== "function" && b !== null)
11
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
+ extendStatics(d, b);
13
+ function __() { this.constructor = d; }
14
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
+ };
16
+ })();
17
+ var __assign = (this && this.__assign) || function () {
18
+ __assign = Object.assign || function(t) {
19
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
20
+ s = arguments[i];
21
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
22
+ t[p] = s[p];
23
+ }
24
+ return t;
25
+ };
26
+ return __assign.apply(this, arguments);
27
+ };
28
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
29
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
30
+ return new (P || (P = Promise))(function (resolve, reject) {
31
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
32
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
33
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
34
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
35
+ });
36
+ };
37
+ var __generator = (this && this.__generator) || function (thisArg, body) {
38
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
39
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
40
+ function verb(n) { return function (v) { return step([n, v]); }; }
41
+ function step(op) {
42
+ if (f) throw new TypeError("Generator is already executing.");
43
+ while (_) try {
44
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
45
+ if (y = 0, t) op = [op[0] & 2, t.value];
46
+ switch (op[0]) {
47
+ case 0: case 1: t = op; break;
48
+ case 4: _.label++; return { value: op[1], done: false };
49
+ case 5: _.label++; y = op[1]; op = [0]; continue;
50
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
51
+ default:
52
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
53
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
54
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
55
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
56
+ if (t[2]) _.ops.pop();
57
+ _.trys.pop(); continue;
58
+ }
59
+ op = body.call(thisArg, _);
60
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
61
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
62
+ }
63
+ };
64
+ var __rest = (this && this.__rest) || function (s, e) {
65
+ var t = {};
66
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
67
+ t[p] = s[p];
68
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
69
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
70
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
71
+ t[p[i]] = s[p[i]];
72
+ }
73
+ return t;
74
+ };
75
+ Object.defineProperty(exports, "__esModule", { value: true });
76
+ exports.PlaywrightManualController = exports.playwrightConfig = void 0;
77
+ var util_1 = require("./util");
78
+ /**
79
+ * Creates a Playwright config that uses axe extension
80
+ *
81
+ * @param opts Playwright config to extend
82
+ */
83
+ function playwrightConfig(opts) {
84
+ var axe = opts.axe, config = __rest(opts, ["axe"]);
85
+ var _a = config.args, args = _a === void 0 ? [] : _a;
86
+ (0, util_1.writeVariables)(axe);
87
+ if (config.headless) {
88
+ throw new Error('Cannot use extension while headless.');
89
+ }
90
+ args = args.concat(util_1.extensionArgs);
91
+ return __assign(__assign({}, config), { headless: false, args: args });
92
+ }
93
+ exports.playwrightConfig = playwrightConfig;
94
+ var PlaywrightManualController = /** @class */ (function (_super) {
95
+ __extends(PlaywrightManualController, _super);
96
+ function PlaywrightManualController(driver) {
97
+ var _this = _super.call(this) || this;
98
+ _this.driver = driver;
99
+ return _this;
100
+ }
101
+ PlaywrightManualController.prototype.executeScript = function (fn) {
102
+ return __awaiter(this, void 0, void 0, function () {
103
+ return __generator(this, function (_a) {
104
+ switch (_a.label) {
105
+ case 0: return [4 /*yield*/, this.driver.evaluate(fn)];
106
+ case 1:
107
+ _a.sent();
108
+ return [2 /*return*/];
109
+ }
110
+ });
111
+ });
112
+ };
113
+ return PlaywrightManualController;
114
+ }(util_1.ManualController));
115
+ exports.PlaywrightManualController = PlaywrightManualController;
116
+ //# sourceMappingURL=playwright.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"playwright.js","sourceRoot":"","sources":["../src/playwright.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+BAKe;AAGf;;;;GAIG;AAEH,SAAgB,gBAAgB,CAC9B,IAAmC;IAE3B,IAAA,GAAG,GAAgB,IAAI,IAApB,EAAK,MAAM,UAAK,IAAI,EAAzB,OAAkB,CAAF,CAAS;IACzB,IAAA,KAAc,MAAM,KAAX,EAAT,IAAI,mBAAG,EAAE,KAAA,CAAW;IAC1B,IAAA,qBAAc,EAAC,GAAG,CAAC,CAAA;IAEnB,IAAI,MAAM,CAAC,QAAQ,EAAE;QACnB,MAAM,IAAI,KAAK,CAAC,sCAAsC,CAAC,CAAA;KACxD;IAED,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC,oBAAa,CAAC,CAAA;IAEjC,6BACK,MAAM,KACT,QAAQ,EAAE,KAAK,EACf,IAAI,MAAA,IACL;AACH,CAAC;AAlBD,4CAkBC;AAED;IAAgD,8CAAgB;IAG9D,oCAAY,MAAY;QAAxB,YACE,iBAAO,SAER;QADC,KAAI,CAAC,MAAM,GAAG,MAAM,CAAA;;IACtB,CAAC;IAEe,kDAAa,GAA7B,UACE,EAAkC;;;;4BAElC,qBAAM,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC,EAAA;;wBAA9B,SAA8B,CAAA;;;;;KAC/B;IACH,iCAAC;AAAD,CAAC,AAbD,CAAgD,uBAAgB,GAa/D;AAbY,gEAA0B"}
@@ -0,0 +1,15 @@
1
+ import { Configuration, ManualController } from './util';
2
+ import type { LaunchOptions, BrowserLaunchArgumentOptions, BrowserConnectOptions, Page } from 'puppeteer';
3
+ declare type Options = LaunchOptions & BrowserLaunchArgumentOptions & BrowserConnectOptions;
4
+ /**
5
+ * Creates a Puppeteer config that uses axe extension.
6
+ *
7
+ * @param opts Config to extend
8
+ */
9
+ export declare function puppeteerConfig(opts: Configuration & Options): Options;
10
+ export declare class PuppeteerManualController extends ManualController {
11
+ private driver;
12
+ constructor(driver: Page);
13
+ protected executeScript(fn: string | (() => Promise<void>)): Promise<void>;
14
+ }
15
+ export {};
@@ -0,0 +1,116 @@
1
+ "use strict";
2
+ var __extends = (this && this.__extends) || (function () {
3
+ var extendStatics = function (d, b) {
4
+ extendStatics = Object.setPrototypeOf ||
5
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
+ return extendStatics(d, b);
8
+ };
9
+ return function (d, b) {
10
+ if (typeof b !== "function" && b !== null)
11
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
+ extendStatics(d, b);
13
+ function __() { this.constructor = d; }
14
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
+ };
16
+ })();
17
+ var __assign = (this && this.__assign) || function () {
18
+ __assign = Object.assign || function(t) {
19
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
20
+ s = arguments[i];
21
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
22
+ t[p] = s[p];
23
+ }
24
+ return t;
25
+ };
26
+ return __assign.apply(this, arguments);
27
+ };
28
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
29
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
30
+ return new (P || (P = Promise))(function (resolve, reject) {
31
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
32
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
33
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
34
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
35
+ });
36
+ };
37
+ var __generator = (this && this.__generator) || function (thisArg, body) {
38
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
39
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
40
+ function verb(n) { return function (v) { return step([n, v]); }; }
41
+ function step(op) {
42
+ if (f) throw new TypeError("Generator is already executing.");
43
+ while (_) try {
44
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
45
+ if (y = 0, t) op = [op[0] & 2, t.value];
46
+ switch (op[0]) {
47
+ case 0: case 1: t = op; break;
48
+ case 4: _.label++; return { value: op[1], done: false };
49
+ case 5: _.label++; y = op[1]; op = [0]; continue;
50
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
51
+ default:
52
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
53
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
54
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
55
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
56
+ if (t[2]) _.ops.pop();
57
+ _.trys.pop(); continue;
58
+ }
59
+ op = body.call(thisArg, _);
60
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
61
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
62
+ }
63
+ };
64
+ var __rest = (this && this.__rest) || function (s, e) {
65
+ var t = {};
66
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
67
+ t[p] = s[p];
68
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
69
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
70
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
71
+ t[p[i]] = s[p[i]];
72
+ }
73
+ return t;
74
+ };
75
+ Object.defineProperty(exports, "__esModule", { value: true });
76
+ exports.PuppeteerManualController = exports.puppeteerConfig = void 0;
77
+ var util_1 = require("./util");
78
+ /**
79
+ * Creates a Puppeteer config that uses axe extension.
80
+ *
81
+ * @param opts Config to extend
82
+ */
83
+ function puppeteerConfig(opts) {
84
+ var axe = opts.axe, config = __rest(opts, ["axe"]);
85
+ var _a = config.args, args = _a === void 0 ? [] : _a;
86
+ (0, util_1.writeVariables)(axe);
87
+ if (config.headless) {
88
+ throw new Error('Cannot use extension while headless.');
89
+ }
90
+ args = args.concat(util_1.extensionArgs);
91
+ return __assign(__assign({}, config), { headless: false, args: args });
92
+ }
93
+ exports.puppeteerConfig = puppeteerConfig;
94
+ var PuppeteerManualController = /** @class */ (function (_super) {
95
+ __extends(PuppeteerManualController, _super);
96
+ function PuppeteerManualController(driver) {
97
+ var _this = _super.call(this) || this;
98
+ _this.driver = driver;
99
+ return _this;
100
+ }
101
+ PuppeteerManualController.prototype.executeScript = function (fn) {
102
+ return __awaiter(this, void 0, void 0, function () {
103
+ return __generator(this, function (_a) {
104
+ switch (_a.label) {
105
+ case 0: return [4 /*yield*/, this.driver.evaluate(fn)];
106
+ case 1:
107
+ _a.sent();
108
+ return [2 /*return*/];
109
+ }
110
+ });
111
+ });
112
+ };
113
+ return PuppeteerManualController;
114
+ }(util_1.ManualController));
115
+ exports.PuppeteerManualController = PuppeteerManualController;
116
+ //# sourceMappingURL=puppeteer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"puppeteer.js","sourceRoot":"","sources":["../src/puppeteer.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+BAKe;AAYf;;;;GAIG;AAEH,SAAgB,eAAe,CAAC,IAA6B;IACnD,IAAA,GAAG,GAAgB,IAAI,IAApB,EAAK,MAAM,UAAK,IAAI,EAAzB,OAAkB,CAAF,CAAS;IACzB,IAAA,KAAc,MAAM,KAAX,EAAT,IAAI,mBAAG,EAAE,KAAA,CAAW;IAC1B,IAAA,qBAAc,EAAC,GAAG,CAAC,CAAA;IAEnB,IAAI,MAAM,CAAC,QAAQ,EAAE;QACnB,MAAM,IAAI,KAAK,CAAC,sCAAsC,CAAC,CAAA;KACxD;IAED,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC,oBAAa,CAAC,CAAA;IAEjC,6BACK,MAAM,KACT,QAAQ,EAAE,KAAK,EACf,IAAI,MAAA,IACL;AACH,CAAC;AAhBD,0CAgBC;AAED;IAA+C,6CAAgB;IAG7D,mCAAY,MAAY;QAAxB,YACE,iBAAO,SAER;QADC,KAAI,CAAC,MAAM,GAAG,MAAM,CAAA;;IACtB,CAAC;IAEe,iDAAa,GAA7B,UACE,EAAkC;;;;4BAElC,qBAAM,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC,EAAA;;wBAA9B,SAA8B,CAAA;;;;;KAC/B;IACH,gCAAC;AAAD,CAAC,AAbD,CAA+C,uBAAgB,GAa9D;AAbY,8DAAyB"}
package/dist/util.d.ts ADDED
@@ -0,0 +1,32 @@
1
+ export declare const PATH_TO_EXTENSION: string;
2
+ export declare const DEFAULT_SERVER_URL = "https://axe.deque.com/";
3
+ export declare const extensionArgs: readonly [`--disable-extensions-except=${string}`, `--load-extension=${string}`];
4
+ export interface Configuration {
5
+ axe: {
6
+ /** Your axe API key. */
7
+ apiKey: string;
8
+ /** Custom axe server URL. */
9
+ serverURL?: string;
10
+ /** Your session ID. */
11
+ sessionId?: string;
12
+ /**
13
+ * Whether or not to automatically run axe on the page when loaded and
14
+ * when changes are made.
15
+ */
16
+ autoAnalyze?: boolean;
17
+ };
18
+ }
19
+ interface WriteVariablesParams {
20
+ apiKey: string;
21
+ serverURL?: string;
22
+ sessionId?: string;
23
+ autoAnalyze?: boolean;
24
+ }
25
+ export declare function writeVariables({ apiKey, serverURL, sessionId, autoAnalyze }: WriteVariablesParams): void;
26
+ export declare abstract class ManualController {
27
+ protected abstract executeScript(fn: string | (() => Promise<void>)): Promise<void>;
28
+ start(): Promise<void>;
29
+ stop(): Promise<void>;
30
+ analyze(): Promise<void>;
31
+ }
32
+ export {};
package/dist/util.js ADDED
@@ -0,0 +1,167 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
26
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
27
+ return new (P || (P = Promise))(function (resolve, reject) {
28
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
29
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
30
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
31
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
32
+ });
33
+ };
34
+ var __generator = (this && this.__generator) || function (thisArg, body) {
35
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
36
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
37
+ function verb(n) { return function (v) { return step([n, v]); }; }
38
+ function step(op) {
39
+ if (f) throw new TypeError("Generator is already executing.");
40
+ while (_) try {
41
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
42
+ if (y = 0, t) op = [op[0] & 2, t.value];
43
+ switch (op[0]) {
44
+ case 0: case 1: t = op; break;
45
+ case 4: _.label++; return { value: op[1], done: false };
46
+ case 5: _.label++; y = op[1]; op = [0]; continue;
47
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
48
+ default:
49
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
50
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
51
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
52
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
53
+ if (t[2]) _.ops.pop();
54
+ _.trys.pop(); continue;
55
+ }
56
+ op = body.call(thisArg, _);
57
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
58
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
59
+ }
60
+ };
61
+ Object.defineProperty(exports, "__esModule", { value: true });
62
+ exports.ManualController = exports.writeVariables = exports.extensionArgs = exports.DEFAULT_SERVER_URL = exports.PATH_TO_EXTENSION = void 0;
63
+ var fs = __importStar(require("fs"));
64
+ var path = __importStar(require("path"));
65
+ exports.PATH_TO_EXTENSION = path.join(__dirname, '..', 'extension');
66
+ exports.DEFAULT_SERVER_URL = 'https://axe.deque.com/';
67
+ exports.extensionArgs = [
68
+ "--disable-extensions-except=".concat(exports.PATH_TO_EXTENSION),
69
+ "--load-extension=".concat(exports.PATH_TO_EXTENSION)
70
+ ];
71
+ // Write the user's settings to the disk, so the extension can load them
72
+ function writeVariables(_a) {
73
+ var apiKey = _a.apiKey, serverURL = _a.serverURL, sessionId = _a.sessionId, autoAnalyze = _a.autoAnalyze;
74
+ if (!serverURL) {
75
+ serverURL = exports.DEFAULT_SERVER_URL;
76
+ }
77
+ var urlString;
78
+ try {
79
+ urlString = new URL(serverURL).toString();
80
+ }
81
+ catch (err) {
82
+ throw new Error("Error when converting serverURL to URL. Ensure it is formatted properly: ".concat(err));
83
+ }
84
+ if (typeof autoAnalyze === 'undefined') {
85
+ autoAnalyze = true;
86
+ }
87
+ var filePath = path.join(exports.PATH_TO_EXTENSION, 'variables.json');
88
+ fs.writeFileSync(filePath, JSON.stringify({
89
+ api_key: apiKey,
90
+ server_url: urlString,
91
+ session_id: sessionId,
92
+ auto_analyze: !!autoAnalyze
93
+ }));
94
+ }
95
+ exports.writeVariables = writeVariables;
96
+ function updateAutoAnalyze(newVal) {
97
+ var filePath = path.join(exports.PATH_TO_EXTENSION, 'variables.json');
98
+ var fileContents = fs.readFileSync(filePath, 'utf-8');
99
+ var jsonValue = JSON.parse(fileContents);
100
+ jsonValue['auto_analyze'] = newVal;
101
+ fs.writeFileSync(filePath, JSON.stringify(jsonValue));
102
+ }
103
+ var ManualController = /** @class */ (function () {
104
+ function ManualController() {
105
+ }
106
+ ManualController.prototype.start = function () {
107
+ return __awaiter(this, void 0, void 0, function () {
108
+ return __generator(this, function (_a) {
109
+ switch (_a.label) {
110
+ case 0:
111
+ updateAutoAnalyze(true);
112
+ return [4 /*yield*/, this.executeScript(function () {
113
+ var event = new CustomEvent('axe:start-auto-mode');
114
+ window.dispatchEvent(event);
115
+ return Promise.resolve();
116
+ })];
117
+ case 1:
118
+ _a.sent();
119
+ return [2 /*return*/];
120
+ }
121
+ });
122
+ });
123
+ };
124
+ ManualController.prototype.stop = function () {
125
+ return __awaiter(this, void 0, void 0, function () {
126
+ return __generator(this, function (_a) {
127
+ switch (_a.label) {
128
+ case 0:
129
+ updateAutoAnalyze(false);
130
+ return [4 /*yield*/, this.executeScript(function () {
131
+ var event = new CustomEvent('axe:stop-auto-mode');
132
+ window.dispatchEvent(event);
133
+ return Promise.resolve();
134
+ })];
135
+ case 1:
136
+ _a.sent();
137
+ return [2 /*return*/];
138
+ }
139
+ });
140
+ });
141
+ };
142
+ ManualController.prototype.analyze = function () {
143
+ return __awaiter(this, void 0, void 0, function () {
144
+ return __generator(this, function (_a) {
145
+ switch (_a.label) {
146
+ case 0: return [4 /*yield*/, this.executeScript(function () {
147
+ return new Promise(function (resolve) {
148
+ var event = new CustomEvent('axe:manual-mode-analyze');
149
+ window.dispatchEvent(event);
150
+ var p = function () {
151
+ window.removeEventListener('axe:manual-mode-analyze-done', p);
152
+ resolve();
153
+ };
154
+ window.addEventListener('axe:manual-mode-analyze-done', p);
155
+ });
156
+ })];
157
+ case 1:
158
+ _a.sent();
159
+ return [2 /*return*/];
160
+ }
161
+ });
162
+ });
163
+ };
164
+ return ManualController;
165
+ }());
166
+ exports.ManualController = ManualController;
167
+ //# sourceMappingURL=util.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"util.js","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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,CAAA;gCACD,MAAM,CAAC,gBAAgB,CAAC,8BAA8B,EAAE,CAAC,CAAC,CAAA;4BAC5D,CAAC,CAAC,CAAA;wBACJ,CAAC,CAAC,EAAA;;wBAVF,SAUE,CAAA;;;;;KACH;IACH,uBAAC;AAAD,CAAC,AApCD,IAoCC;AApCqB,4CAAgB"}
package/dist/wdio.d.ts ADDED
@@ -0,0 +1,21 @@
1
+ import { Configuration, ManualController } from './util';
2
+ import type { Options } from '@wdio/types';
3
+ interface Browser {
4
+ executeAsyncScript(script: string, args: object[]): void;
5
+ }
6
+ interface WdioArg extends Configuration {
7
+ options?: Options.WebDriver;
8
+ }
9
+ /**
10
+ * Creates a WebDriverIO config that uses axe extension
11
+ *
12
+ * @param arg Config to extend
13
+ */
14
+ export declare function wdioConfig(arg: WdioArg): Options.WebDriver;
15
+ export declare function wdioTestRunner(axe: Configuration['axe'], config: Options.Testrunner): Options.Testrunner;
16
+ export declare class WdioManualController extends ManualController {
17
+ private driver;
18
+ constructor(driver: Browser);
19
+ protected executeScript(fn: string | (() => Promise<void>)): Promise<void>;
20
+ }
21
+ export {};