reffy 18.3.2 → 18.4.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "reffy",
3
- "version": "18.3.2",
3
+ "version": "18.4.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",
@@ -37,16 +37,16 @@
37
37
  "ajv-formats": "3.0.1",
38
38
  "commander": "13.1.0",
39
39
  "fetch-filecache-for-crawling": "5.1.1",
40
- "puppeteer": "24.2.0",
40
+ "puppeteer": "24.3.1",
41
41
  "semver": "^7.3.5",
42
- "web-specs": "3.39.0",
42
+ "web-specs": "3.42.0",
43
43
  "webidl2": "24.4.1"
44
44
  },
45
45
  "devDependencies": {
46
46
  "mocha": "11.1.0",
47
47
  "respec": "35.2.2",
48
48
  "respec-hljs": "2.1.1",
49
- "rollup": "4.34.6",
49
+ "rollup": "4.34.9",
50
50
  "undici": "^7.0.0"
51
51
  },
52
52
  "overrides": {
@@ -289,8 +289,8 @@ export default function (spec, idToHeading = {}) {
289
289
 
290
290
  const shortname = (typeof spec === 'string') ? spec : spec.shortname;
291
291
  switch (shortname) {
292
- case "CSS21":
293
- preProcessCSS21();
292
+ case "CSS2":
293
+ preProcessCSS2();
294
294
  break;
295
295
  case "html":
296
296
  preProcessHTML();
@@ -738,7 +738,15 @@ function preProcessHTML() {
738
738
  });
739
739
  }
740
740
 
741
- function preProcessCSS21() {
741
+ /**
742
+ * CSS 2.1 does not use the definitions data model and needs to be processed
743
+ * to create the right definitions.
744
+ *
745
+ * Note: CSS 2.2 does follow the definitions data model, but does not contain
746
+ * any element that matches the `span.index-def` selector, so the function is
747
+ * a no-op for CSS 2.2 and that's a good thing.
748
+ */
749
+ function preProcessCSS2() {
742
750
  document.querySelectorAll('span.index-def')
743
751
  .forEach(span => {
744
752
  // Definition ID is to be found in a nearby anchor
@@ -169,13 +169,40 @@ mockAgent
169
169
  }
170
170
  });
171
171
 
172
+ mockAgent
173
+ .get("https://www.w3.org")
174
+ .intercept({ method: "GET", path: "/TR/iredirect/" })
175
+ .reply(200,
176
+ `<!DOCTYPE html><script>window.location = '/TR/recentlyupdated/';</script>`,
177
+ {
178
+ headers: {
179
+ "Content-Type": "text/html",
180
+ "Last-Modified": "Fri, 11 Feb 2022 00:00:42 GMT"
181
+ }
182
+ }
183
+ );
184
+
185
+ mockAgent
186
+ .get("https://www.w3.org")
187
+ .intercept({ method: "GET", path: "/TR/recentlyupdated/" })
188
+ .reply(200,
189
+ `<html><title>Recently updated</title>
190
+ <h1>Recently updated</h1>`,
191
+ {
192
+ headers: {
193
+ "Content-Type": "text/html",
194
+ "Last-Modified": (new Date()).toString()
195
+ }
196
+ }
197
+ );
198
+
172
199
  mockAgent
173
200
  .get("https://drafts.csswg.org")
174
201
  .intercept({ method: "GET", path: "/server-hiccup/" })
175
202
  .reply(200,
176
203
  `<html><title>Server hiccup</title>
177
204
  <h1> Index of Server Hiccup Module Level 42 </h1>`,
178
- { header: { "Content-Type": "text/html" } })
205
+ { headers: { "Content-Type": "text/html" } })
179
206
  .persist();
180
207
 
181
208
  /*nock.emitter.on('error', function (err) {
@@ -138,8 +138,15 @@ async function crawlSpec(spec, crawlOptions) {
138
138
  if (result.crawled) {
139
139
  spec.crawled = result.crawled;
140
140
  }
141
- if (result.crawlCacheInfo) {
142
- spec.crawlCacheInfo = result.crawlCacheInfo;
141
+ if (result.crawlCacheInfo &&
142
+ (result.crawled === spec.url ||
143
+ result.crawled === spec.nightly?.url)) {
144
+ // Note: Some redirection took place. That happens when, e.g., a
145
+ // WICG spec gets moved to another group, until we update the URL
146
+ // in browser-specs. Redirection is done through scripting. Reffy
147
+ // follows the redirect but the cache info it receives from
148
+ // Puppeteer is for the initial URL. We cannot rely on it!
149
+ spec.crawlCacheInfo = result.crawlCacheInfo;
143
150
  }
144
151
  crawlOptions.modules.forEach(mod => {
145
152
  if (result[mod.property]) {