@axe-core/watcher 0.0.0 → 0.0.1-next.1142820e
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/dist/cli.d.ts +2 -0
- package/dist/cli.js +134 -0
- package/dist/cli.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +18 -0
- package/dist/index.js.map +1 -0
- package/dist/playwright.d.ts +13 -0
- package/dist/playwright.js +116 -0
- package/dist/playwright.js.map +1 -0
- package/dist/puppeteer.d.ts +15 -0
- package/dist/puppeteer.js +116 -0
- package/dist/puppeteer.js.map +1 -0
- package/dist/util.d.ts +37 -0
- package/dist/util.js +182 -0
- package/dist/util.js.map +1 -0
- package/dist/wdio.d.ts +21 -0
- package/dist/wdio.js +136 -0
- package/dist/wdio.js.map +1 -0
- package/dist/webdriver.d.ts +18 -0
- package/dist/webdriver.js +103 -0
- package/dist/webdriver.js.map +1 -0
- package/extension/content.js +1 -0
- package/extension/content.js.LICENSE.txt +13 -0
- package/extension/manifest.json +24 -0
- package/extension/worker.js +1 -0
- package/extension/worker.js.LICENSE.txt +1 -0
- package/package.json +69 -8
- package/index.js +0 -1
package/dist/cli.d.ts
ADDED
package/dist/cli.js
ADDED
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
var __assign = (this && this.__assign) || function () {
|
|
4
|
+
__assign = Object.assign || function(t) {
|
|
5
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
6
|
+
s = arguments[i];
|
|
7
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
8
|
+
t[p] = s[p];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
12
|
+
return __assign.apply(this, arguments);
|
|
13
|
+
};
|
|
14
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
15
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
16
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
17
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
18
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
19
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
20
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
24
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
25
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
26
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
27
|
+
function step(op) {
|
|
28
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
29
|
+
while (_) try {
|
|
30
|
+
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;
|
|
31
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
32
|
+
switch (op[0]) {
|
|
33
|
+
case 0: case 1: t = op; break;
|
|
34
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
35
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
36
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
37
|
+
default:
|
|
38
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
39
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
40
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
41
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
42
|
+
if (t[2]) _.ops.pop();
|
|
43
|
+
_.trys.pop(); continue;
|
|
44
|
+
}
|
|
45
|
+
op = body.call(thisArg, _);
|
|
46
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
47
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
51
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
52
|
+
};
|
|
53
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
54
|
+
var uuid_1 = require("uuid");
|
|
55
|
+
var pkg_up_1 = __importDefault(require("pkg-up"));
|
|
56
|
+
var fs_1 = __importDefault(require("fs"));
|
|
57
|
+
var assert_1 = __importDefault(require("assert"));
|
|
58
|
+
var util_1 = require("./util");
|
|
59
|
+
var start = function () {
|
|
60
|
+
var sessionId = (0, uuid_1.v4)();
|
|
61
|
+
fs_1.default.writeFileSync(util_1.PATH_TO_SESSION_FILE, JSON.stringify({ id: sessionId }));
|
|
62
|
+
};
|
|
63
|
+
var stop = function () {
|
|
64
|
+
try {
|
|
65
|
+
fs_1.default.unlinkSync(util_1.PATH_TO_SESSION_FILE);
|
|
66
|
+
}
|
|
67
|
+
catch (_a) {
|
|
68
|
+
// Oh well.
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
var init = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
72
|
+
var packageJSON, pkg, _a, _b, pretest, _c, test, _d, posttest;
|
|
73
|
+
return __generator(this, function (_e) {
|
|
74
|
+
switch (_e.label) {
|
|
75
|
+
case 0: return [4 /*yield*/, (0, pkg_up_1.default)()];
|
|
76
|
+
case 1:
|
|
77
|
+
packageJSON = _e.sent();
|
|
78
|
+
(0, assert_1.default)(packageJSON, 'Unable to find package.json');
|
|
79
|
+
pkg = JSON.parse(fs_1.default.readFileSync(packageJSON, 'utf8'));
|
|
80
|
+
_a = pkg.scripts || {}, _b = _a.pretest, pretest = _b === void 0 ? '' : _b, _c = _a.test, test = _c === void 0 ? '' : _c, _d = _a.posttest, posttest = _d === void 0 ? '' : _d;
|
|
81
|
+
if (!pretest.includes('axe-watcher start')) {
|
|
82
|
+
if (pretest) {
|
|
83
|
+
pretest += ' && ';
|
|
84
|
+
}
|
|
85
|
+
pretest += 'axe-watcher start';
|
|
86
|
+
}
|
|
87
|
+
if (!(test === null || test === void 0 ? void 0 : test.trim())) {
|
|
88
|
+
test = 'echo "Error: no test specified" && exit 1';
|
|
89
|
+
}
|
|
90
|
+
if (!posttest.includes('axe-watcher stop')) {
|
|
91
|
+
if (posttest) {
|
|
92
|
+
posttest += ' && ';
|
|
93
|
+
}
|
|
94
|
+
posttest += 'axe-watcher stop';
|
|
95
|
+
}
|
|
96
|
+
fs_1.default.writeFileSync(packageJSON, JSON.stringify(__assign(__assign({}, pkg), { scripts: __assign(__assign({}, pkg.scripts), { pretest: pretest, test: test, posttest: posttest }) }), null, 2));
|
|
97
|
+
return [2 /*return*/];
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
}); };
|
|
101
|
+
var main = function (command) { return __awaiter(void 0, void 0, void 0, function () {
|
|
102
|
+
var _a;
|
|
103
|
+
return __generator(this, function (_b) {
|
|
104
|
+
switch (_b.label) {
|
|
105
|
+
case 0:
|
|
106
|
+
_a = command;
|
|
107
|
+
switch (_a) {
|
|
108
|
+
case 'start': return [3 /*break*/, 1];
|
|
109
|
+
case 'stop': return [3 /*break*/, 2];
|
|
110
|
+
case 'init': return [3 /*break*/, 3];
|
|
111
|
+
}
|
|
112
|
+
return [3 /*break*/, 5];
|
|
113
|
+
case 1:
|
|
114
|
+
start();
|
|
115
|
+
return [3 /*break*/, 6];
|
|
116
|
+
case 2:
|
|
117
|
+
stop();
|
|
118
|
+
return [3 /*break*/, 6];
|
|
119
|
+
case 3: return [4 /*yield*/, init()];
|
|
120
|
+
case 4:
|
|
121
|
+
_b.sent();
|
|
122
|
+
return [3 /*break*/, 6];
|
|
123
|
+
case 5: throw new Error('Unsupported or missing subcommand');
|
|
124
|
+
case 6: return [2 /*return*/];
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
}); };
|
|
128
|
+
var command = process.argv.slice(2)[0];
|
|
129
|
+
main(command).catch(function (error) {
|
|
130
|
+
// eslint-disable-next-line no-console
|
|
131
|
+
console.error(error);
|
|
132
|
+
process.exit(1);
|
|
133
|
+
});
|
|
134
|
+
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,6BAAiC;AACjC,kDAA0B;AAC1B,0CAAmB;AACnB,kDAA2B;AAC3B,+BAA6C;AAE7C,IAAM,KAAK,GAAG;IACZ,IAAM,SAAS,GAAG,IAAA,SAAI,GAAE,CAAA;IACxB,YAAE,CAAC,aAAa,CAAC,2BAAoB,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,EAAE,EAAE,SAAS,EAAE,CAAC,CAAC,CAAA;AAC3E,CAAC,CAAA;AAED,IAAM,IAAI,GAAG;IACX,IAAI;QACF,YAAE,CAAC,UAAU,CAAC,2BAAoB,CAAC,CAAA;KACpC;IAAC,WAAM;QACN,WAAW;KACZ;AACH,CAAC,CAAA;AAED,IAAM,IAAI,GAAG;;;;oBACS,qBAAM,IAAA,gBAAK,GAAE,EAAA;;gBAA3B,WAAW,GAAG,SAAa;gBACjC,IAAA,gBAAM,EAAC,WAAW,EAAE,6BAA6B,CAAC,CAAA;gBAE5C,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,YAAE,CAAC,YAAY,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC,CAAA;gBACxD,KAA6C,GAAG,CAAC,OAAO,IAAI,EAAE,EAA5D,eAAY,EAAZ,OAAO,mBAAG,EAAE,KAAA,EAAE,YAAS,EAAT,IAAI,mBAAG,EAAE,KAAA,EAAE,gBAAa,EAAb,QAAQ,mBAAG,EAAE,KAAA,CAAsB;gBAElE,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,mBAAmB,CAAC,EAAE;oBAC1C,IAAI,OAAO,EAAE;wBACX,OAAO,IAAI,MAAM,CAAA;qBAClB;oBACD,OAAO,IAAI,mBAAmB,CAAA;iBAC/B;gBAED,IAAI,CAAC,CAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,IAAI,EAAE,CAAA,EAAE;oBACjB,IAAI,GAAG,2CAA2C,CAAA;iBACnD;gBAED,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,kBAAkB,CAAC,EAAE;oBAC1C,IAAI,QAAQ,EAAE;wBACZ,QAAQ,IAAI,MAAM,CAAA;qBACnB;oBACD,QAAQ,IAAI,kBAAkB,CAAA;iBAC/B;gBAED,YAAE,CAAC,aAAa,CACd,WAAW,EACX,IAAI,CAAC,SAAS,uBACP,GAAG,KAAE,OAAO,wBAAO,GAAG,CAAC,OAAO,KAAE,OAAO,SAAA,EAAE,IAAI,MAAA,EAAE,QAAQ,UAAA,QAC5D,IAAI,EACJ,CAAC,CACF,CACF,CAAA;;;;KACF,CAAA;AAED,IAAM,IAAI,GAAG,UAAO,OAAe;;;;;gBACzB,KAAA,OAAO,CAAA;;yBACR,OAAO,CAAC,CAAR,wBAAO;yBAGP,MAAM,CAAC,CAAP,wBAAM;yBAGN,MAAM,CAAC,CAAP,wBAAM;;;;gBALT,KAAK,EAAE,CAAA;gBACP,wBAAK;;gBAEL,IAAI,EAAE,CAAA;gBACN,wBAAK;oBAEL,qBAAM,IAAI,EAAE,EAAA;;gBAAZ,SAAY,CAAA;gBACZ,wBAAK;oBAEL,MAAM,IAAI,KAAK,CAAC,mCAAmC,CAAC,CAAA;;;;KAEzD,CAAA;AAED,IAAM,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;AACxC,IAAI,CAAC,OAAO,CAAC,CAAC,KAAK,CAAC,UAAA,KAAK;IACvB,sCAAsC;IACtC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;IACpB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;AACjB,CAAC,CAAC,CAAA"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/*! Copyright Deque 2001-2022 All Rights Reserved */
|
|
2
|
+
export { puppeteerConfig, PuppeteerController } from './puppeteer';
|
|
3
|
+
export { wdioConfig, wdioTestRunner, WdioController } from './wdio';
|
|
4
|
+
export { webdriverConfig, WebdriverController } from './webdriver';
|
|
5
|
+
export { playwrightConfig, PlaywrightController } from './playwright';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*! Copyright Deque 2001-2022 All Rights Reserved */
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.PlaywrightController = exports.playwrightConfig = exports.WebdriverController = exports.webdriverConfig = exports.WdioController = exports.wdioTestRunner = exports.wdioConfig = exports.PuppeteerController = exports.puppeteerConfig = void 0;
|
|
5
|
+
var puppeteer_1 = require("./puppeteer");
|
|
6
|
+
Object.defineProperty(exports, "puppeteerConfig", { enumerable: true, get: function () { return puppeteer_1.puppeteerConfig; } });
|
|
7
|
+
Object.defineProperty(exports, "PuppeteerController", { enumerable: true, get: function () { return puppeteer_1.PuppeteerController; } });
|
|
8
|
+
var wdio_1 = require("./wdio");
|
|
9
|
+
Object.defineProperty(exports, "wdioConfig", { enumerable: true, get: function () { return wdio_1.wdioConfig; } });
|
|
10
|
+
Object.defineProperty(exports, "wdioTestRunner", { enumerable: true, get: function () { return wdio_1.wdioTestRunner; } });
|
|
11
|
+
Object.defineProperty(exports, "WdioController", { enumerable: true, get: function () { return wdio_1.WdioController; } });
|
|
12
|
+
var webdriver_1 = require("./webdriver");
|
|
13
|
+
Object.defineProperty(exports, "webdriverConfig", { enumerable: true, get: function () { return webdriver_1.webdriverConfig; } });
|
|
14
|
+
Object.defineProperty(exports, "WebdriverController", { enumerable: true, get: function () { return webdriver_1.WebdriverController; } });
|
|
15
|
+
var playwright_1 = require("./playwright");
|
|
16
|
+
Object.defineProperty(exports, "playwrightConfig", { enumerable: true, get: function () { return playwright_1.playwrightConfig; } });
|
|
17
|
+
Object.defineProperty(exports, "PlaywrightController", { enumerable: true, get: function () { return playwright_1.PlaywrightController; } });
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA,oDAAoD;;;AAEpD,yCAAkE;AAAzD,4GAAA,eAAe,OAAA;AAAE,gHAAA,mBAAmB,OAAA;AAC7C,+BAAmE;AAA1D,kGAAA,UAAU,OAAA;AAAE,sGAAA,cAAc,OAAA;AAAE,sGAAA,cAAc,OAAA;AACnD,yCAAkE;AAAzD,4GAAA,eAAe,OAAA;AAAE,gHAAA,mBAAmB,OAAA;AAC7C,2CAAqE;AAA5D,8GAAA,gBAAgB,OAAA;AAAE,kHAAA,oBAAoB,OAAA"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Configuration, Controller } 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 PlaywrightController extends Controller {
|
|
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.PlaywrightController = 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 PlaywrightController = /** @class */ (function (_super) {
|
|
95
|
+
__extends(PlaywrightController, _super);
|
|
96
|
+
function PlaywrightController(driver) {
|
|
97
|
+
var _this = _super.call(this) || this;
|
|
98
|
+
_this.driver = driver;
|
|
99
|
+
return _this;
|
|
100
|
+
}
|
|
101
|
+
PlaywrightController.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 PlaywrightController;
|
|
114
|
+
}(util_1.Controller));
|
|
115
|
+
exports.PlaywrightController = PlaywrightController;
|
|
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;IAA0C,wCAAU;IAGlD,8BAAY,MAAY;QAAxB,YACE,iBAAO,SAER;QADC,KAAI,CAAC,MAAM,GAAG,MAAM,CAAA;;IACtB,CAAC;IAEe,4CAAa,GAA7B,UACE,EAAkC;;;;4BAElC,qBAAM,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC,EAAA;;wBAA9B,SAA8B,CAAA;;;;;KAC/B;IACH,2BAAC;AAAD,CAAC,AAbD,CAA0C,iBAAU,GAanD;AAbY,oDAAoB"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Configuration, Controller } 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 PuppeteerController extends Controller {
|
|
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.PuppeteerController = 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 PuppeteerController = /** @class */ (function (_super) {
|
|
95
|
+
__extends(PuppeteerController, _super);
|
|
96
|
+
function PuppeteerController(driver) {
|
|
97
|
+
var _this = _super.call(this) || this;
|
|
98
|
+
_this.driver = driver;
|
|
99
|
+
return _this;
|
|
100
|
+
}
|
|
101
|
+
PuppeteerController.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 PuppeteerController;
|
|
114
|
+
}(util_1.Controller));
|
|
115
|
+
exports.PuppeteerController = PuppeteerController;
|
|
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;IAAyC,uCAAU;IAGjD,6BAAY,MAAY;QAAxB,YACE,iBAAO,SAER;QADC,KAAI,CAAC,MAAM,GAAG,MAAM,CAAA;;IACtB,CAAC;IAEe,2CAAa,GAA7B,UACE,EAAkC;;;;4BAElC,qBAAM,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC,EAAA;;wBAA9B,SAA8B,CAAA;;;;;KAC/B;IACH,0BAAC;AAAD,CAAC,AAbD,CAAyC,iBAAU,GAalD;AAbY,kDAAmB"}
|
package/dist/util.d.ts
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export declare const PATH_TO_EXTENSION: string;
|
|
2
|
+
export declare const DEFAULT_SERVER_URL = "https://axe.deque.com/";
|
|
3
|
+
export declare const PATH_TO_SESSION_FILE: string;
|
|
4
|
+
export declare const PATH_TO_EXTENSION_VARIABLES: string;
|
|
5
|
+
export declare const extensionArgs: readonly [`--disable-extensions-except=${string}`, `--load-extension=${string}`];
|
|
6
|
+
export interface Configuration {
|
|
7
|
+
axe: {
|
|
8
|
+
/** Your axe API key. */
|
|
9
|
+
apiKey: string;
|
|
10
|
+
/** Custom axe server URL. */
|
|
11
|
+
serverURL?: string;
|
|
12
|
+
/** Your session ID. */
|
|
13
|
+
sessionId?: string;
|
|
14
|
+
/**
|
|
15
|
+
* Whether or not to automatically run axe on the page when loaded and
|
|
16
|
+
* when changes are made.
|
|
17
|
+
*/
|
|
18
|
+
autoAnalyze?: boolean;
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
interface WriteVariablesParams {
|
|
22
|
+
apiKey: string;
|
|
23
|
+
serverURL?: string;
|
|
24
|
+
sessionId?: string;
|
|
25
|
+
autoAnalyze?: boolean;
|
|
26
|
+
}
|
|
27
|
+
/** Write the user's settings to the disk, so the extension can load them. */
|
|
28
|
+
export declare function writeVariables({ apiKey, serverURL, sessionId, autoAnalyze }: WriteVariablesParams): void;
|
|
29
|
+
export declare abstract class Controller {
|
|
30
|
+
protected abstract executeScript(fn: string | (() => Promise<void>)): Promise<void>;
|
|
31
|
+
start(): Promise<void>;
|
|
32
|
+
stop(): Promise<void>;
|
|
33
|
+
analyze(): Promise<void>;
|
|
34
|
+
/** Flush all axe-core results by sending them to the server. */
|
|
35
|
+
flush(): Promise<void>;
|
|
36
|
+
}
|
|
37
|
+
export {};
|