reffy 14.8.2 → 15.0.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "reffy",
3
- "version": "14.8.2",
3
+ "version": "15.0.0",
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",
@@ -36,16 +36,16 @@
36
36
  "ajv-formats": "2.1.1",
37
37
  "commander": "12.0.0",
38
38
  "fetch-filecache-for-crawling": "5.1.1",
39
- "puppeteer": "22.3.0",
39
+ "puppeteer": "22.6.0",
40
40
  "semver": "^7.3.5",
41
- "web-specs": "3.4.0",
41
+ "web-specs": "3.5.0",
42
42
  "webidl2": "24.4.1"
43
43
  },
44
44
  "devDependencies": {
45
45
  "mocha": "10.3.0",
46
- "respec": "34.4.0",
46
+ "respec": "34.5.0",
47
47
  "respec-hljs": "2.1.1",
48
- "rollup": "4.12.0",
48
+ "rollup": "4.13.0",
49
49
  "undici": "^6.1.0"
50
50
  },
51
51
  "overrides": {
@@ -3,17 +3,10 @@
3
3
  "$id": "https://github.com/w3c/reffy/blob/main/schemas/browserlib/extract-links.json",
4
4
 
5
5
  "type": "object",
6
- "propertyNames": { "$ref": "../common.json#/$defs/url" },
7
- "additionalProperties": {
8
- "type": "object",
9
- "additionalProperties": false,
10
- "properties": {
11
- "anchors": {
12
- "type": "array",
13
- "items": { "$ref": "../common.json#/$defs/id" },
14
- "minItems": 1
15
- },
16
- "specShortname": { "$ref": "../common.json#/$defs/shortname" }
17
- }
6
+ "additionalProperties": false,
7
+ "required": ["rawlinks", "autolinks"],
8
+ "properties": {
9
+ "rawlinks": { "$ref": "../common.json#/$defs/links" },
10
+ "autolinks": { "$ref": "../common.json#/$defs/links" }
18
11
  }
19
12
  }
@@ -127,6 +127,23 @@
127
127
  "url": { "$ref": "#/$defs/url" }
128
128
  }
129
129
  }
130
+ },
131
+
132
+ "links": {
133
+ "type": "object",
134
+ "propertyNames": { "$ref": "#/$defs/url" },
135
+ "additionalProperties": {
136
+ "type": "object",
137
+ "additionalProperties": false,
138
+ "properties": {
139
+ "anchors": {
140
+ "type": "array",
141
+ "items": { "$ref": "#/$defs/id" },
142
+ "minItems": 1
143
+ },
144
+ "specShortname": { "$ref": "#/$defs/shortname" }
145
+ }
146
+ }
130
147
  }
131
148
  }
132
149
  }
@@ -1,8 +1,24 @@
1
+ function fromLinksToAnchors(links) {
2
+ return Object.keys(links)
3
+ .sort()
4
+ // turning sets into arrays
5
+ .reduce((acc, u) => {
6
+ acc[u] = {};
7
+ if (links[u].anchors.size > 0) {
8
+ acc[u].anchors = [...links[u].anchors];
9
+ }
10
+ return acc;
11
+ }, {});
12
+ }
13
+
1
14
  /**
2
15
  * Extract absolute links of the document and their fragments
16
+ * in two set: autolinks (generated by spec authoring tools from webref)
17
+ * and rawlinks (the rest)
3
18
  */
4
19
  export default function () {
5
- const links = {};
20
+ const rawlinks = {};
21
+ const autolinks = {};
6
22
  document.querySelectorAll('a[href^=http]').forEach(n => {
7
23
  // Ignore links from the "head" section, which either link to
8
24
  // self, the GitHub repo, the implementation report, and other
@@ -11,21 +27,17 @@ export default function () {
11
27
  // carry their diff (e.g. W3C Recs with candidate corrections)
12
28
  if (n.closest('.head, del')) return;
13
29
  const pageUrl = n.href.split('#')[0];
14
- if (!links[pageUrl]) {
15
- links[pageUrl] = {anchors: new Set()};
30
+ // links generated by authoring tools have data-link-type set
31
+ let linkSet = n.dataset.linkType ? autolinks : rawlinks;
32
+ if (!linkSet[pageUrl]) {
33
+ linkSet[pageUrl] = {anchors: new Set()};
16
34
  }
17
35
  if (n.href.includes('#') && n.href.split('#')[1]) {
18
- links[pageUrl].anchors.add(n.href.split('#')[1]);
36
+ linkSet[pageUrl].anchors.add(n.href.split('#')[1]);
19
37
  }
20
38
  });
21
- return Object.keys(links)
22
- .sort()
23
- // turning sets into arrays
24
- .reduce((acc, u) => {
25
- acc[u] = {};
26
- if (links[u].anchors.size > 0) {
27
- acc[u].anchors = [...links[u].anchors];
28
- }
29
- return acc;
30
- }, {});
39
+ return {
40
+ rawlinks: fromLinksToAnchors(rawlinks),
41
+ autolinks: fromLinksToAnchors(autolinks)
42
+ };
31
43
  }