reffy 12.1.5 → 13.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 +1 -1
- package/package.json +7 -7
- package/src/browserlib/extract-events.mjs +27 -11
package/README.md
CHANGED
|
@@ -10,7 +10,7 @@ The code features a generic crawler that can fetch Web specifications and genera
|
|
|
10
10
|
|
|
11
11
|
### Pre-requisites
|
|
12
12
|
|
|
13
|
-
To install Reffy, you need [Node.js](https://nodejs.org/en/)
|
|
13
|
+
To install Reffy, you need [Node.js](https://nodejs.org/en/) 18 or greater (the crawler itself may still run with earlier versions of Node.js, but version 18 is needed to run tests).
|
|
14
14
|
|
|
15
15
|
### Installation
|
|
16
16
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "reffy",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "13.0.1",
|
|
4
4
|
"description": "W3C/WHATWG spec dependencies exploration companion. Features a short set of tools to study spec references as well as WebIDL term definitions and references found in W3C specifications.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
],
|
|
28
28
|
"license": "MIT",
|
|
29
29
|
"engines": {
|
|
30
|
-
"node": ">=
|
|
30
|
+
"node": ">=18"
|
|
31
31
|
},
|
|
32
32
|
"main": "index.js",
|
|
33
33
|
"bin": "./reffy.js",
|
|
@@ -37,18 +37,18 @@
|
|
|
37
37
|
"ajv-formats": "2.1.1",
|
|
38
38
|
"commander": "10.0.1",
|
|
39
39
|
"fetch-filecache-for-crawling": "4.1.0",
|
|
40
|
-
"puppeteer": "
|
|
40
|
+
"puppeteer": "20.1.2",
|
|
41
41
|
"semver": "^7.3.5",
|
|
42
|
-
"web-specs": "2.
|
|
42
|
+
"web-specs": "2.57.0",
|
|
43
43
|
"webidl2": "24.2.2"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"chai": "4.3.7",
|
|
47
47
|
"mocha": "10.2.0",
|
|
48
|
-
"nock": "13.3.
|
|
49
|
-
"respec": "
|
|
48
|
+
"nock": "13.3.1",
|
|
49
|
+
"respec": "34.1.1",
|
|
50
50
|
"respec-hljs": "2.1.1",
|
|
51
|
-
"rollup": "3.
|
|
51
|
+
"rollup": "3.21.5"
|
|
52
52
|
},
|
|
53
53
|
"scripts": {
|
|
54
54
|
"test": "mocha --recursive tests/"
|
|
@@ -160,24 +160,40 @@ export default function (spec) {
|
|
|
160
160
|
[...document.querySelectorAll("a")]
|
|
161
161
|
.filter(a => !a.closest(informativeSelector) && isFiringLink(a))
|
|
162
162
|
.forEach(a => {
|
|
163
|
-
|
|
164
|
-
//
|
|
165
|
-
//
|
|
166
|
-
|
|
163
|
+
// Clone and drop possible annotations to avoid extracting asides.
|
|
164
|
+
// (note the need to temporarily add the cloned node to the document
|
|
165
|
+
// so that ranges can be used)
|
|
166
|
+
const apos = [...a.parentNode.children].findIndex(c => c === a);
|
|
167
|
+
const container = a.parentNode.cloneNode(true);
|
|
168
|
+
const aclone = container.children[apos];
|
|
169
|
+
|
|
170
|
+
const annotations = container.querySelectorAll("aside, .mdn-anno");
|
|
171
|
+
annotations.forEach(n => n.remove());
|
|
172
|
+
document.body.appendChild(container);
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
// There can be multiple "fire an event" links in a container,
|
|
176
|
+
// limiting our text parsing to content in between two such links,
|
|
177
|
+
// or to the first time aside appears (no whitespaces in Bikeshed
|
|
178
|
+
// so code would extract the beginning of the annotation otherwise),
|
|
179
|
+
// or the end of the container if neither of the above occurs.
|
|
167
180
|
const range = document.createRange();
|
|
168
181
|
range.selectNode(container);
|
|
169
|
-
range.setStart(
|
|
182
|
+
range.setStart(aclone, 0);
|
|
170
183
|
|
|
171
|
-
let
|
|
184
|
+
let nextFiringEl, curEl = aclone;
|
|
172
185
|
while ((curEl = curEl.nextElementSibling)) {
|
|
173
186
|
if (curEl.tagName === "A" && isFiringLink(curEl)) {
|
|
174
|
-
|
|
187
|
+
nextFiringEl = curEl;
|
|
188
|
+
break;
|
|
175
189
|
}
|
|
176
190
|
}
|
|
177
|
-
|
|
178
|
-
|
|
191
|
+
|
|
192
|
+
if (nextFiringEl) {
|
|
193
|
+
range.setEndBefore(nextFiringEl);
|
|
179
194
|
}
|
|
180
195
|
const parsedText = range.toString();
|
|
196
|
+
document.body.removeChild(container);
|
|
181
197
|
let phrasing;
|
|
182
198
|
let m = parsedText.match(/fir(e|ing)\s+a(n|\s+pointer)\s+event\s+named\s+"?(?<eventName>[a-z]+)/i);
|
|
183
199
|
if (m) {
|
|
@@ -225,8 +241,8 @@ export default function (spec) {
|
|
|
225
241
|
}
|
|
226
242
|
}
|
|
227
243
|
if (!event.interface) {
|
|
228
|
-
let curEl =
|
|
229
|
-
while ((curEl = curEl.nextElementSibling)) {
|
|
244
|
+
let curEl = aclone, iface;
|
|
245
|
+
while ((curEl = curEl.nextElementSibling) && curEl !== nextFiringEl) {
|
|
230
246
|
if (curEl.textContent.match(/^([A-Z]+[a-z0-9]*)+Event$/)) {
|
|
231
247
|
iface = curEl.textContent.trim();
|
|
232
248
|
break;
|