@axe-core/puppeteer 4.6.2-alpha.379 → 4.7.0
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/index.d.ts +48 -5
- package/dist/index.js +472 -8
- package/dist/index.mjs +443 -0
- package/package.json +14 -4
- package/dist/axePartialRunner.d.ts +0 -11
- package/dist/axePartialRunner.js +0 -45
- package/dist/axePartialRunner.js.map +0 -1
- package/dist/axePuppeteer.d.ts +0 -31
- package/dist/axePuppeteer.js +0 -214
- package/dist/axePuppeteer.js.map +0 -1
- package/dist/browser.d.ts +0 -16
- package/dist/browser.js +0 -47
- package/dist/browser.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/legacy.d.ts +0 -10
- package/dist/legacy.js +0 -89
- package/dist/legacy.js.map +0 -1
- package/dist/load-page.d.ts +0 -12
- package/dist/load-page.js +0 -42
- package/dist/load-page.js.map +0 -1
- package/dist/types.d.ts +0 -8
- package/dist/types.js +0 -3
- package/dist/types.js.map +0 -1
- package/dist/utils.d.ts +0 -7
- package/dist/utils.js +0 -97
- package/dist/utils.js.map +0 -1
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,443 @@
|
|
|
1
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
2
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
3
|
+
}) : x)(function(x) {
|
|
4
|
+
if (typeof require !== "undefined")
|
|
5
|
+
return require.apply(this, arguments);
|
|
6
|
+
throw new Error('Dynamic require of "' + x + '" is not supported');
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
// src/axePuppeteer.ts
|
|
10
|
+
import assert from "assert";
|
|
11
|
+
|
|
12
|
+
// src/browser.ts
|
|
13
|
+
function pageIsLoaded() {
|
|
14
|
+
return document.readyState === "complete";
|
|
15
|
+
}
|
|
16
|
+
function axeRunPartialSupport() {
|
|
17
|
+
return typeof window.axe.runPartial === "function";
|
|
18
|
+
}
|
|
19
|
+
function axeConfigure(config) {
|
|
20
|
+
if (config) {
|
|
21
|
+
window.axe.configure(config);
|
|
22
|
+
}
|
|
23
|
+
window.axe.configure({
|
|
24
|
+
branding: { application: "axe-puppeteer" }
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
function axeGetFrameContext(context) {
|
|
28
|
+
return window.axe.utils.getFrameContexts(context);
|
|
29
|
+
}
|
|
30
|
+
function axeShadowSelect(axeSelector) {
|
|
31
|
+
return window.axe.utils.shadowSelect(axeSelector);
|
|
32
|
+
}
|
|
33
|
+
function axeRunPartial(context, options) {
|
|
34
|
+
return window.axe.runPartial(context, options);
|
|
35
|
+
}
|
|
36
|
+
function axeFinishRun(options) {
|
|
37
|
+
return window.axe.finishRun(JSON.parse(window.partialResults), options);
|
|
38
|
+
}
|
|
39
|
+
function axeRunLegacy(context, options) {
|
|
40
|
+
return window.axe.run(context || document, options || {});
|
|
41
|
+
}
|
|
42
|
+
function chunkResultString(chunk) {
|
|
43
|
+
window.partialResults ??= "";
|
|
44
|
+
window.partialResults += chunk;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// src/legacy.ts
|
|
48
|
+
import * as fs from "fs";
|
|
49
|
+
async function injectJS(frame, { source, selector, logOnError, args }) {
|
|
50
|
+
if (!frame) {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
const frames = await frame.$$(selector);
|
|
54
|
+
const injections = [];
|
|
55
|
+
for (const frameElement of frames) {
|
|
56
|
+
const subFrame = await frameElement.contentFrame();
|
|
57
|
+
const p = injectJS(subFrame, {
|
|
58
|
+
source,
|
|
59
|
+
selector,
|
|
60
|
+
args,
|
|
61
|
+
logOnError: true
|
|
62
|
+
});
|
|
63
|
+
injections.push(p);
|
|
64
|
+
}
|
|
65
|
+
const reportError = () => {
|
|
66
|
+
console.error(`Failed to inject axe-core into frame (${frame.url()})`);
|
|
67
|
+
};
|
|
68
|
+
let injectP;
|
|
69
|
+
if (!source) {
|
|
70
|
+
injectP = injectJSModule(frame);
|
|
71
|
+
} else {
|
|
72
|
+
injectP = injectJSSource(frame, source, args);
|
|
73
|
+
}
|
|
74
|
+
if (logOnError) {
|
|
75
|
+
injectP = injectP.catch(reportError);
|
|
76
|
+
}
|
|
77
|
+
injections.push(injectP);
|
|
78
|
+
return Promise.all(injections).then(() => void 0);
|
|
79
|
+
}
|
|
80
|
+
async function injectJSModule(frame) {
|
|
81
|
+
const source = fs.readFileSync(__require.resolve("axe-core"), "utf8");
|
|
82
|
+
await injectJSSource(frame, source);
|
|
83
|
+
}
|
|
84
|
+
function injectJSSource(frame, source, args = []) {
|
|
85
|
+
return frame.evaluate(source, ...args);
|
|
86
|
+
}
|
|
87
|
+
function iframeSelector(disabledFrameSelectors) {
|
|
88
|
+
let selector = "iframe";
|
|
89
|
+
for (const disabledFrameSelector of disabledFrameSelectors) {
|
|
90
|
+
selector += `:not(${disabledFrameSelector})`;
|
|
91
|
+
}
|
|
92
|
+
return selector;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// src/axePartialRunner.ts
|
|
96
|
+
var AxePartialRunner = class {
|
|
97
|
+
constructor(partialPromise, initiator = false) {
|
|
98
|
+
this.initiator = initiator;
|
|
99
|
+
this.partialPromise = caught(partialPromise);
|
|
100
|
+
}
|
|
101
|
+
partialPromise;
|
|
102
|
+
childRunners = [];
|
|
103
|
+
addChildResults(childResultRunner) {
|
|
104
|
+
this.childRunners.push(childResultRunner);
|
|
105
|
+
}
|
|
106
|
+
async getPartials() {
|
|
107
|
+
try {
|
|
108
|
+
const parentPartial = await this.partialPromise;
|
|
109
|
+
const childPromises = this.childRunners.map((childRunner) => {
|
|
110
|
+
return childRunner ? caught(childRunner.getPartials()) : [null];
|
|
111
|
+
});
|
|
112
|
+
const childPartials = (await Promise.all(childPromises)).flat(1);
|
|
113
|
+
return [parentPartial, ...childPartials];
|
|
114
|
+
} catch (e) {
|
|
115
|
+
if (this.initiator) {
|
|
116
|
+
throw e;
|
|
117
|
+
}
|
|
118
|
+
return [null];
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
var caught = ((f) => {
|
|
123
|
+
return (p) => (p.catch(f), p);
|
|
124
|
+
})(() => {
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
// src/utils.ts
|
|
128
|
+
import * as fs2 from "fs";
|
|
129
|
+
async function frameSourceInject(frame, source, config) {
|
|
130
|
+
await assertFrameReady(frame);
|
|
131
|
+
if (!source) {
|
|
132
|
+
const pathFile = __require.resolve("axe-core");
|
|
133
|
+
source = fs2.readFileSync(pathFile, "utf8");
|
|
134
|
+
}
|
|
135
|
+
await frame.evaluate(source);
|
|
136
|
+
await frame.evaluate(axeConfigure, config);
|
|
137
|
+
}
|
|
138
|
+
function arrayify(src) {
|
|
139
|
+
if (!Array.isArray(src)) {
|
|
140
|
+
return [src];
|
|
141
|
+
}
|
|
142
|
+
return src;
|
|
143
|
+
}
|
|
144
|
+
function normalizeContext(includes, excludes, disabledFrameSelectors) {
|
|
145
|
+
const base = {
|
|
146
|
+
exclude: []
|
|
147
|
+
};
|
|
148
|
+
if (excludes.length && Array.isArray(base.exclude)) {
|
|
149
|
+
base.exclude.push(...excludes);
|
|
150
|
+
}
|
|
151
|
+
if (disabledFrameSelectors.length && Array.isArray(base.exclude)) {
|
|
152
|
+
const frameExcludes = disabledFrameSelectors.map((frame) => [frame, "*"]);
|
|
153
|
+
base.exclude.push(...frameExcludes);
|
|
154
|
+
}
|
|
155
|
+
if (includes.length) {
|
|
156
|
+
base.include = includes;
|
|
157
|
+
}
|
|
158
|
+
return base;
|
|
159
|
+
}
|
|
160
|
+
async function getChildFrame(frame, childSelector) {
|
|
161
|
+
const frameElm = await frame.evaluateHandle(axeShadowSelect, childSelector);
|
|
162
|
+
return await frameElm.asElement()?.contentFrame() || null;
|
|
163
|
+
}
|
|
164
|
+
async function assertFrameReady(frame) {
|
|
165
|
+
let pageReady = false;
|
|
166
|
+
try {
|
|
167
|
+
pageReady = await frame.evaluate(pageIsLoaded);
|
|
168
|
+
} catch {
|
|
169
|
+
}
|
|
170
|
+
if (!pageReady) {
|
|
171
|
+
throw new Error("Page/Frame is not ready");
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
// src/axePuppeteer.ts
|
|
176
|
+
var AxePuppeteer = class {
|
|
177
|
+
frame;
|
|
178
|
+
axeSource;
|
|
179
|
+
includes;
|
|
180
|
+
excludes;
|
|
181
|
+
axeOptions;
|
|
182
|
+
config;
|
|
183
|
+
disabledFrameSelectors;
|
|
184
|
+
page;
|
|
185
|
+
legacyMode = false;
|
|
186
|
+
errorUrl;
|
|
187
|
+
constructor(pageFrame, source) {
|
|
188
|
+
if ("mainFrame" in pageFrame) {
|
|
189
|
+
if ("browser" in pageFrame) {
|
|
190
|
+
this.page = pageFrame;
|
|
191
|
+
} else {
|
|
192
|
+
console.warn(
|
|
193
|
+
"AxePuppeteer support for Puppeteer <= 3.0.3 is deprecated"
|
|
194
|
+
);
|
|
195
|
+
}
|
|
196
|
+
this.frame = pageFrame.mainFrame();
|
|
197
|
+
} else {
|
|
198
|
+
console.warn(
|
|
199
|
+
"AxePuppeteer construction with Frame objects is deprecated."
|
|
200
|
+
);
|
|
201
|
+
this.frame = pageFrame;
|
|
202
|
+
}
|
|
203
|
+
this.axeSource = source;
|
|
204
|
+
this.includes = [];
|
|
205
|
+
this.excludes = [];
|
|
206
|
+
this.axeOptions = {};
|
|
207
|
+
this.config = null;
|
|
208
|
+
this.disabledFrameSelectors = [];
|
|
209
|
+
this.errorUrl = "https://github.com/dequelabs/axe-core-npm/blob/develop/packages/puppeteer/error-handling.md";
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* Selector to include in analysis.
|
|
213
|
+
* This may be called any number of times.
|
|
214
|
+
*/
|
|
215
|
+
include(selector) {
|
|
216
|
+
this.includes.push(selector);
|
|
217
|
+
return this;
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* Selector to exclude in analysis.
|
|
221
|
+
* This may be called any number of times.
|
|
222
|
+
*/
|
|
223
|
+
exclude(selector) {
|
|
224
|
+
this.excludes.push(selector);
|
|
225
|
+
return this;
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* Set options to be passed into axe-core
|
|
229
|
+
*/
|
|
230
|
+
options(options) {
|
|
231
|
+
this.axeOptions = options;
|
|
232
|
+
return this;
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* Limit analysis to only the specified rules.
|
|
236
|
+
* Cannot be used with `AxeBuilder#withTags`
|
|
237
|
+
*/
|
|
238
|
+
withRules(rules) {
|
|
239
|
+
rules = arrayify(rules);
|
|
240
|
+
if (!this.axeOptions) {
|
|
241
|
+
this.axeOptions = {};
|
|
242
|
+
}
|
|
243
|
+
this.axeOptions.runOnly = {
|
|
244
|
+
type: "rule",
|
|
245
|
+
values: rules
|
|
246
|
+
};
|
|
247
|
+
return this;
|
|
248
|
+
}
|
|
249
|
+
/**
|
|
250
|
+
* Limit analysis to only specified tags.
|
|
251
|
+
* Cannot be used with `AxeBuilder#withRules`
|
|
252
|
+
*/
|
|
253
|
+
withTags(tags) {
|
|
254
|
+
tags = arrayify(tags);
|
|
255
|
+
if (!this.axeOptions) {
|
|
256
|
+
this.axeOptions = {};
|
|
257
|
+
}
|
|
258
|
+
this.axeOptions.runOnly = {
|
|
259
|
+
type: "tag",
|
|
260
|
+
values: tags
|
|
261
|
+
};
|
|
262
|
+
return this;
|
|
263
|
+
}
|
|
264
|
+
/**
|
|
265
|
+
* Set the list of rules to skip when running an analysis.
|
|
266
|
+
*/
|
|
267
|
+
disableRules(rules) {
|
|
268
|
+
rules = arrayify(rules);
|
|
269
|
+
const newRules = {};
|
|
270
|
+
for (const rule of rules) {
|
|
271
|
+
newRules[rule] = {
|
|
272
|
+
enabled: false
|
|
273
|
+
};
|
|
274
|
+
}
|
|
275
|
+
this.axeOptions.rules = newRules;
|
|
276
|
+
return this;
|
|
277
|
+
}
|
|
278
|
+
/**
|
|
279
|
+
* Set configuration for `axe-core`.
|
|
280
|
+
* This value is passed directly to `axe.configure()`
|
|
281
|
+
*/
|
|
282
|
+
configure(config) {
|
|
283
|
+
assert(
|
|
284
|
+
typeof config === "object",
|
|
285
|
+
"AxePuppeteer needs an object to configure. See axe-core configure API."
|
|
286
|
+
);
|
|
287
|
+
this.config = config;
|
|
288
|
+
return this;
|
|
289
|
+
}
|
|
290
|
+
/**
|
|
291
|
+
* Exclude specific frames from a test
|
|
292
|
+
*/
|
|
293
|
+
disableFrame(selector) {
|
|
294
|
+
this.disabledFrameSelectors.push(selector);
|
|
295
|
+
return this;
|
|
296
|
+
}
|
|
297
|
+
/**
|
|
298
|
+
* Use frameMessenger with <same_origin_only>
|
|
299
|
+
*
|
|
300
|
+
* This disables use of axe.runPartial() which is called in each frame, and
|
|
301
|
+
* axe.finishRun() which is called in a blank page. This uses axe.run() instead,
|
|
302
|
+
* but with the restriction that cross-origin frames will not be tested.
|
|
303
|
+
*/
|
|
304
|
+
setLegacyMode(legacyMode = true) {
|
|
305
|
+
this.legacyMode = legacyMode;
|
|
306
|
+
return this;
|
|
307
|
+
}
|
|
308
|
+
async analyze(callback) {
|
|
309
|
+
try {
|
|
310
|
+
const axeResults = await this.analyzePromise();
|
|
311
|
+
if (callback) {
|
|
312
|
+
callback(null, axeResults);
|
|
313
|
+
}
|
|
314
|
+
return axeResults;
|
|
315
|
+
} catch (err) {
|
|
316
|
+
if (callback) {
|
|
317
|
+
callback(err);
|
|
318
|
+
return null;
|
|
319
|
+
}
|
|
320
|
+
throw err;
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
async analyzePromise() {
|
|
324
|
+
const { frame, axeSource, config } = this;
|
|
325
|
+
const context = normalizeContext(
|
|
326
|
+
this.includes,
|
|
327
|
+
this.excludes,
|
|
328
|
+
this.disabledFrameSelectors
|
|
329
|
+
);
|
|
330
|
+
await frameSourceInject(frame, axeSource, config);
|
|
331
|
+
const runPartialSupported = await frame.evaluate(axeRunPartialSupport);
|
|
332
|
+
if (runPartialSupported !== true || this.page === void 0 || this.legacyMode) {
|
|
333
|
+
return this.runLegacy(context);
|
|
334
|
+
}
|
|
335
|
+
const partialRunner = await this.runPartialRecursive(frame, context);
|
|
336
|
+
const partials = await partialRunner.getPartials();
|
|
337
|
+
try {
|
|
338
|
+
return await this.finishRun(partials);
|
|
339
|
+
} catch (error) {
|
|
340
|
+
throw new Error(
|
|
341
|
+
`${error.message}
|
|
342
|
+
Please check out ${this.errorUrl}`
|
|
343
|
+
);
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
async runPartialRecursive(frame, context) {
|
|
347
|
+
const frameContexts = await frame.evaluate(axeGetFrameContext, context);
|
|
348
|
+
const options = this.axeOptions;
|
|
349
|
+
const partialPromise = frame.evaluate(axeRunPartial, context, options);
|
|
350
|
+
const initiator = frame === this.frame;
|
|
351
|
+
const axePartialRunner = new AxePartialRunner(partialPromise, initiator);
|
|
352
|
+
for (const { frameSelector, frameContext } of frameContexts) {
|
|
353
|
+
try {
|
|
354
|
+
let childResults = null;
|
|
355
|
+
const childFrame = await getChildFrame(frame, frameSelector);
|
|
356
|
+
if (childFrame) {
|
|
357
|
+
await frameSourceInject(childFrame, this.axeSource, this.config);
|
|
358
|
+
childResults = await this.runPartialRecursive(
|
|
359
|
+
childFrame,
|
|
360
|
+
frameContext
|
|
361
|
+
);
|
|
362
|
+
}
|
|
363
|
+
axePartialRunner.addChildResults(childResults);
|
|
364
|
+
} catch {
|
|
365
|
+
axePartialRunner.addChildResults(null);
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
return axePartialRunner;
|
|
369
|
+
}
|
|
370
|
+
async finishRun(partialResults) {
|
|
371
|
+
const { axeOptions, axeSource, config, page } = this;
|
|
372
|
+
assert(page, "Running AxePuppeteer with a frame object is deprecated");
|
|
373
|
+
const browser = page.browser();
|
|
374
|
+
const blankPage = await browser.newPage();
|
|
375
|
+
assert(
|
|
376
|
+
blankPage,
|
|
377
|
+
"Please make sure that you have popup blockers disabled."
|
|
378
|
+
);
|
|
379
|
+
await frameSourceInject(blankPage.mainFrame(), axeSource, config);
|
|
380
|
+
const sizeLimit = 6e7;
|
|
381
|
+
const partialString = JSON.stringify(partialResults);
|
|
382
|
+
async function chunkResults(result) {
|
|
383
|
+
const chunk = result.substring(0, sizeLimit);
|
|
384
|
+
await blankPage.evaluate(chunkResultString, chunk);
|
|
385
|
+
if (result.length > sizeLimit) {
|
|
386
|
+
return await chunkResults(result.substr(sizeLimit));
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
await chunkResults(partialString);
|
|
390
|
+
return await blankPage.evaluate(axeFinishRun, axeOptions).finally(async () => {
|
|
391
|
+
await blankPage.close();
|
|
392
|
+
});
|
|
393
|
+
}
|
|
394
|
+
async runLegacy(context) {
|
|
395
|
+
const options = this.axeOptions;
|
|
396
|
+
const selector = iframeSelector(this.disabledFrameSelectors);
|
|
397
|
+
const source = this.axeSource;
|
|
398
|
+
let config = this.config;
|
|
399
|
+
if (!this.legacyMode) {
|
|
400
|
+
config = {
|
|
401
|
+
...config || {},
|
|
402
|
+
allowedOrigins: ["<unsafe_all_origins>"]
|
|
403
|
+
};
|
|
404
|
+
}
|
|
405
|
+
await injectJS(this.frame, { source, selector });
|
|
406
|
+
await injectJS(this.frame, {
|
|
407
|
+
source: axeConfigure,
|
|
408
|
+
selector,
|
|
409
|
+
args: [config]
|
|
410
|
+
});
|
|
411
|
+
return this.frame.evaluate(axeRunLegacy, context, options);
|
|
412
|
+
}
|
|
413
|
+
};
|
|
414
|
+
|
|
415
|
+
// src/load-page.ts
|
|
416
|
+
async function loadPage(browser, url, pageOpts = {}) {
|
|
417
|
+
const page = await browser.newPage();
|
|
418
|
+
await page.setBypassCSP(true);
|
|
419
|
+
await page.goto(url, pageOpts.opts);
|
|
420
|
+
return new OwningAxePuppeteer(page, pageOpts.source);
|
|
421
|
+
}
|
|
422
|
+
var OwningAxePuppeteer = class extends AxePuppeteer {
|
|
423
|
+
newPage;
|
|
424
|
+
constructor(page, source) {
|
|
425
|
+
super(page, source);
|
|
426
|
+
this.newPage = page;
|
|
427
|
+
}
|
|
428
|
+
async analyze(callback) {
|
|
429
|
+
try {
|
|
430
|
+
return await super.analyze(callback);
|
|
431
|
+
} finally {
|
|
432
|
+
await this.newPage.close();
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
};
|
|
436
|
+
|
|
437
|
+
// src/index.ts
|
|
438
|
+
var src_default = AxePuppeteer;
|
|
439
|
+
export {
|
|
440
|
+
AxePuppeteer,
|
|
441
|
+
src_default as default,
|
|
442
|
+
loadPage
|
|
443
|
+
};
|
package/package.json
CHANGED
|
@@ -1,13 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@axe-core/puppeteer",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.7.0",
|
|
4
4
|
"description": "Provides a chainable axe API for Puppeteer and automatically injects into all frames",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "https://github.com/dequelabs/axe-core-npm.git"
|
|
8
8
|
},
|
|
9
9
|
"main": "dist/index.js",
|
|
10
|
-
"
|
|
10
|
+
"module": "./dist/index.mjs",
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"exports": {
|
|
13
|
+
".": {
|
|
14
|
+
"import": "./dist/index.mjs",
|
|
15
|
+
"require": "./dist/index.js",
|
|
16
|
+
"types": "./dist/index.d.ts"
|
|
17
|
+
}
|
|
18
|
+
},
|
|
11
19
|
"files": [
|
|
12
20
|
"/dist"
|
|
13
21
|
],
|
|
@@ -15,8 +23,9 @@
|
|
|
15
23
|
"access": "public"
|
|
16
24
|
},
|
|
17
25
|
"scripts": {
|
|
18
|
-
"build": "
|
|
26
|
+
"build": "tsup src/index.ts --dts --format esm,cjs",
|
|
19
27
|
"test": "mocha 'test/**/*.test.ts'",
|
|
28
|
+
"test:esm": "node esmTest.mjs",
|
|
20
29
|
"coverage": "nyc npm run test",
|
|
21
30
|
"prepublishOnly": "npm run build"
|
|
22
31
|
},
|
|
@@ -39,6 +48,7 @@
|
|
|
39
48
|
"source-map-support": "^0.5.21",
|
|
40
49
|
"test-listen": "^1.1.0",
|
|
41
50
|
"ts-node": "^10.9.1",
|
|
51
|
+
"tsup": "^6.7.0",
|
|
42
52
|
"typescript": "^4.8.4"
|
|
43
53
|
},
|
|
44
54
|
"dependencies": {
|
|
@@ -77,5 +87,5 @@
|
|
|
77
87
|
"functions": 85,
|
|
78
88
|
"lines": 85
|
|
79
89
|
},
|
|
80
|
-
"gitHead": "
|
|
90
|
+
"gitHead": "623da3a516cbf1c7a0a0461b23a8c98f094cc18d"
|
|
81
91
|
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import * as axe from 'axe-core';
|
|
2
|
-
export declare type PartialResults = Parameters<typeof axe.finishRun>[0];
|
|
3
|
-
export declare class AxePartialRunner {
|
|
4
|
-
private initiator;
|
|
5
|
-
private partialPromise;
|
|
6
|
-
private childRunners;
|
|
7
|
-
constructor(partialPromise: Promise<axe.PartialResult>, initiator?: boolean);
|
|
8
|
-
addChildResults(childResultRunner: AxePartialRunner | null): void;
|
|
9
|
-
getPartials(): Promise<PartialResults>;
|
|
10
|
-
}
|
|
11
|
-
export declare const caught: <T>(p: Promise<T>) => Promise<T>;
|
package/dist/axePartialRunner.js
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.caught = exports.AxePartialRunner = void 0;
|
|
13
|
-
class AxePartialRunner {
|
|
14
|
-
constructor(partialPromise, initiator = false) {
|
|
15
|
-
this.initiator = initiator;
|
|
16
|
-
this.childRunners = [];
|
|
17
|
-
this.partialPromise = (0, exports.caught)(partialPromise);
|
|
18
|
-
}
|
|
19
|
-
addChildResults(childResultRunner) {
|
|
20
|
-
this.childRunners.push(childResultRunner);
|
|
21
|
-
}
|
|
22
|
-
getPartials() {
|
|
23
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
24
|
-
try {
|
|
25
|
-
const parentPartial = yield this.partialPromise;
|
|
26
|
-
const childPromises = this.childRunners.map(childRunner => {
|
|
27
|
-
return childRunner ? (0, exports.caught)(childRunner.getPartials()) : [null];
|
|
28
|
-
});
|
|
29
|
-
const childPartials = (yield Promise.all(childPromises)).flat(1);
|
|
30
|
-
return [parentPartial, ...childPartials];
|
|
31
|
-
}
|
|
32
|
-
catch (e) {
|
|
33
|
-
if (this.initiator) {
|
|
34
|
-
throw e;
|
|
35
|
-
}
|
|
36
|
-
return [null];
|
|
37
|
-
}
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
exports.AxePartialRunner = AxePartialRunner;
|
|
42
|
-
exports.caught = ((f) => {
|
|
43
|
-
return (p) => (p.catch(f), p);
|
|
44
|
-
})(() => { });
|
|
45
|
-
//# sourceMappingURL=axePartialRunner.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"axePartialRunner.js","sourceRoot":"","sources":["../src/axePartialRunner.ts"],"names":[],"mappings":";;;;;;;;;;;;AAcA,MAAa,gBAAgB;IAI3B,YACE,cAA0C,EAClC,YAAqB,KAAK;QAA1B,cAAS,GAAT,SAAS,CAAiB;QAJ5B,iBAAY,GAAmC,EAAE,CAAC;QAMxD,IAAI,CAAC,cAAc,GAAG,IAAA,cAAM,EAAC,cAAc,CAAC,CAAC;IAC/C,CAAC;IAEM,eAAe,CAAC,iBAA0C;QAC/D,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;IAC5C,CAAC;IAEY,WAAW;;YACtB,IAAI;gBACF,MAAM,aAAa,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC;gBAChD,MAAM,aAAa,GAAG,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE;oBACxD,OAAO,WAAW,CAAC,CAAC,CAAC,IAAA,cAAM,EAAC,WAAW,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;gBAClE,CAAC,CAAC,CAAC;gBACH,MAAM,aAAa,GAAG,CAAC,MAAM,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;gBACjE,OAAO,CAAC,aAAa,EAAE,GAAG,aAAa,CAAC,CAAC;aAC1C;YAAC,OAAO,CAAC,EAAE;gBACV,IAAI,IAAI,CAAC,SAAS,EAAE;oBAClB,MAAM,CAAC,CAAC;iBACT;gBACD,OAAO,CAAC,IAAI,CAAC,CAAC;aACf;QACH,CAAC;KAAA;CACF;AA9BD,4CA8BC;AAIY,QAAA,MAAM,GAAG,CAAC,CAAC,CAAa,EAAE,EAAE;IACvC,OAAO,CAAI,CAAa,EAAc,EAAE,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AAE3D,CAAC,CAAC,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC"}
|
package/dist/axePuppeteer.d.ts
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { RunOptions, Spec, AxeResults, SerialFrameSelector } from 'axe-core';
|
|
2
|
-
import { Frame, Page } from 'puppeteer';
|
|
3
|
-
import { AnalyzeCB } from './types';
|
|
4
|
-
export declare class AxePuppeteer {
|
|
5
|
-
private frame;
|
|
6
|
-
private axeSource?;
|
|
7
|
-
private includes;
|
|
8
|
-
private excludes;
|
|
9
|
-
private axeOptions;
|
|
10
|
-
private config;
|
|
11
|
-
private disabledFrameSelectors;
|
|
12
|
-
private page;
|
|
13
|
-
private legacyMode;
|
|
14
|
-
private errorUrl;
|
|
15
|
-
constructor(pageFrame: Page | Frame, source?: string);
|
|
16
|
-
include(selector: SerialFrameSelector): this;
|
|
17
|
-
exclude(selector: SerialFrameSelector): this;
|
|
18
|
-
options(options: RunOptions): this;
|
|
19
|
-
withRules(rules: string | string[]): this;
|
|
20
|
-
withTags(tags: string | string[]): this;
|
|
21
|
-
disableRules(rules: string | string[]): this;
|
|
22
|
-
configure(config: Spec): this;
|
|
23
|
-
disableFrame(selector: string): this;
|
|
24
|
-
setLegacyMode(legacyMode?: boolean): this;
|
|
25
|
-
analyze(): Promise<AxeResults>;
|
|
26
|
-
analyze<T extends AnalyzeCB>(callback?: T): Promise<AxeResults | null>;
|
|
27
|
-
private analyzePromise;
|
|
28
|
-
private runPartialRecursive;
|
|
29
|
-
private finishRun;
|
|
30
|
-
private runLegacy;
|
|
31
|
-
}
|