reffy 6.4.2 → 6.6.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.
Files changed (43) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +158 -158
  3. package/index.js +11 -11
  4. package/package.json +53 -53
  5. package/reffy.js +248 -248
  6. package/src/browserlib/canonicalize-url.mjs +50 -50
  7. package/src/browserlib/create-outline.mjs +352 -352
  8. package/src/browserlib/extract-cssdfn.mjs +319 -319
  9. package/src/browserlib/extract-dfns.mjs +687 -686
  10. package/src/browserlib/extract-editors.mjs~ +14 -0
  11. package/src/browserlib/extract-elements.mjs +205 -205
  12. package/src/browserlib/extract-headings.mjs +48 -48
  13. package/src/browserlib/extract-ids.mjs +28 -28
  14. package/src/browserlib/extract-links.mjs +28 -28
  15. package/src/browserlib/extract-references.mjs +203 -203
  16. package/src/browserlib/extract-webidl.mjs +134 -134
  17. package/src/browserlib/generate-es-dfn-report.sh~ +4 -0
  18. package/src/browserlib/get-absolute-url.mjs +21 -21
  19. package/src/browserlib/get-generator.mjs +26 -26
  20. package/src/browserlib/get-lastmodified-date.mjs +13 -13
  21. package/src/browserlib/get-title.mjs +11 -11
  22. package/src/browserlib/informative-selector.mjs +16 -16
  23. package/src/browserlib/map-ids-to-headings.mjs +136 -136
  24. package/src/browserlib/reffy.json +53 -53
  25. package/src/cli/check-missing-dfns.js +609 -609
  26. package/src/cli/csstree-grammar-check.js +28 -0
  27. package/src/cli/csstree-grammar-check.js~ +10 -0
  28. package/src/cli/csstree-grammar-parser.js +11 -0
  29. package/src/cli/csstree-grammar-parser.js~ +1 -0
  30. package/src/cli/extract-editors.js~ +38 -0
  31. package/src/cli/generate-idlnames.js +430 -430
  32. package/src/cli/generate-idlparsed.js +139 -139
  33. package/src/cli/merge-crawl-results.js +128 -128
  34. package/src/cli/parse-webidl.js +430 -430
  35. package/src/cli/process-specs.js~ +28 -0
  36. package/src/lib/css-grammar-parse-tree.schema.json +109 -109
  37. package/src/lib/css-grammar-parser.js +440 -440
  38. package/src/lib/fetch.js +56 -56
  39. package/src/lib/nock-server.js +127 -127
  40. package/src/lib/specs-crawler.js +631 -622
  41. package/src/lib/util.js +943 -943
  42. package/src/specs/missing-css-rules.json +197 -197
  43. package/src/specs/spec-equivalents.json +149 -149
package/src/lib/fetch.js CHANGED
@@ -1,56 +1,56 @@
1
- /**
2
- * Wrapper around the fetch module to setup a few config parameters from
3
- * config.json
4
- *
5
- * @module finder
6
- */
7
-
8
- const os = require('os');
9
- const path = require('path');
10
- const baseFetch = require('fetch-filecache-for-crawling');
11
-
12
- // Read configuration parameters from `config.json` file
13
- let config = null;
14
- try {
15
- config = require(path.resolve('config.json'));
16
- }
17
- catch (err) {
18
- config = {};
19
- }
20
-
21
-
22
- /**
23
- * Fetch function that applies fetch parameters defined in `config.json`
24
- * unless parameters are already set.
25
- *
26
- * By default, force the HTTP refresh strategy to "once", so that only one
27
- * HTTP request gets sent on a given URL per crawl.
28
- *
29
- * @function
30
- * @param {String} url URL to fetch
31
- * @param {Object} options Fetch options (and options for node-fetch, and
32
- * options for fetch-filecache-for-crawling)
33
- * @return {Promise(Response)} Promise to get an HTTP response
34
- */
35
- async function fetch(url, options) {
36
- options = Object.assign({headers: {}}, options);
37
- ['cacheFolder', 'resetCache', 'cacheRefresh', 'logToConsole'].forEach(param => {
38
- let fetchParam = (param === 'cacheRefresh') ? 'refresh' : param;
39
- if (config[param] && !options.hasOwnProperty(fetchParam)) {
40
- options[fetchParam] = config[param];
41
- }
42
- });
43
- if (!options.refresh) {
44
- options.refresh = 'once';
45
- }
46
-
47
- // Use cache folder in tmp folder by default
48
- if (!options.cacheFolder) {
49
- options.cacheFolder = path.resolve(os.tmpdir(), 'reffy-cache');
50
- }
51
-
52
- return baseFetch(url, options);
53
- }
54
-
55
-
56
- module.exports = fetch;
1
+ /**
2
+ * Wrapper around the fetch module to setup a few config parameters from
3
+ * config.json
4
+ *
5
+ * @module finder
6
+ */
7
+
8
+ const os = require('os');
9
+ const path = require('path');
10
+ const baseFetch = require('fetch-filecache-for-crawling');
11
+
12
+ // Read configuration parameters from `config.json` file
13
+ let config = null;
14
+ try {
15
+ config = require(path.resolve('config.json'));
16
+ }
17
+ catch (err) {
18
+ config = {};
19
+ }
20
+
21
+
22
+ /**
23
+ * Fetch function that applies fetch parameters defined in `config.json`
24
+ * unless parameters are already set.
25
+ *
26
+ * By default, force the HTTP refresh strategy to "once", so that only one
27
+ * HTTP request gets sent on a given URL per crawl.
28
+ *
29
+ * @function
30
+ * @param {String} url URL to fetch
31
+ * @param {Object} options Fetch options (and options for node-fetch, and
32
+ * options for fetch-filecache-for-crawling)
33
+ * @return {Promise(Response)} Promise to get an HTTP response
34
+ */
35
+ async function fetch(url, options) {
36
+ options = Object.assign({headers: {}}, options);
37
+ ['cacheFolder', 'resetCache', 'cacheRefresh', 'logToConsole'].forEach(param => {
38
+ let fetchParam = (param === 'cacheRefresh') ? 'refresh' : param;
39
+ if (config[param] && !options.hasOwnProperty(fetchParam)) {
40
+ options[fetchParam] = config[param];
41
+ }
42
+ });
43
+ if (!options.refresh) {
44
+ options.refresh = 'once';
45
+ }
46
+
47
+ // Use cache folder in tmp folder by default
48
+ if (!options.cacheFolder) {
49
+ options.cacheFolder = path.resolve(os.tmpdir(), 'reffy-cache');
50
+ }
51
+
52
+ return baseFetch(url, options);
53
+ }
54
+
55
+
56
+ module.exports = fetch;
@@ -1,127 +1,127 @@
1
- /**
2
- * Setup a proxy server that intercepts some network requests. To be used in
3
- * tests not to hit the network.
4
- *
5
- * @module nock-server
6
- */
7
-
8
- const nock = require("nock");
9
- const path = require("path");
10
- const { existsSync } = require('fs');
11
-
12
- /**
13
- * Determine the path to the "node_modules" folder. The path depends on whether
14
- * Reffy is run directly, or installed as a library.
15
- *
16
- * @function
17
- * @return {String} Path to the node_modules folder.
18
- */
19
- function getModulesFolder() {
20
- const rootFolder = path.resolve(__dirname, '../..');
21
- let folder = path.resolve(rootFolder, 'node_modules');
22
- if (existsSync(folder)) {
23
- return folder;
24
- }
25
- folder = path.resolve(rootFolder, '..');
26
- return folder;
27
- }
28
- const modulesFolder = getModulesFolder();
29
-
30
- const mockSpecs = {
31
- "/woff/woff2/": {
32
- html: `
33
- <title>WOFF2</title>
34
- <body>
35
- <dfn id='foo'>Foo</dfn>
36
- <a href="https://www.w3.org/TR/bar/#baz">bar</a>
37
- <ul class='toc'><li><a href='page.html'>page</a></ul>`,
38
- pages: {
39
- "page.html": `<h2 id='bar'>Heading in subpage</h2>`
40
- }
41
- },
42
- "/mediacapture-output/": `
43
- <script>respecConfig = { shortName: 'test' };</script>
44
- <script src='https://www.w3.org/Tools/respec/respec-w3c'></script>
45
- <div id=abstract></div>
46
- <pre class='idl'>[Exposed=Window] interface Foo { attribute DOMString bar; };</pre>`,
47
- "/accelerometer/": `<html>
48
- <h2>Normative references</h2>
49
- <dl>
50
- <dt>FOO</dt>
51
- <dd><a href='https://www.w3.org/TR/Foo'>Foo</a></dd>
52
- </dl>`,
53
- "/pointerlock/": `<html>
54
- <h1>Pointer Lock 2.0`
55
- };
56
-
57
- nock.disableNetConnect();
58
- // for chrome devtool protocol
59
- nock.enableNetConnect('127.0.0.1');
60
-
61
- Object.keys(mockSpecs).forEach(path => {
62
- nock("https://w3c.github.io")
63
- .persist()
64
- .get(path)
65
- .reply(200,
66
- typeof mockSpecs[path] === "string" ? mockSpecs[path] : mockSpecs[path].html,
67
- { 'Content-Type': 'text/html' }
68
- );
69
-
70
- Object.keys(mockSpecs[path].pages || {}).forEach(page => {
71
- nock("https://w3c.github.io")
72
- .persist()
73
- .get(path + page)
74
- .reply(200,
75
- mockSpecs[path].pages[page],
76
- { 'Content-Type': 'text/html' });
77
-
78
- });
79
- });
80
-
81
-
82
- // Handling requests generated by ReSpec documents
83
- nock("https://api.specref.org")
84
- .persist()
85
- .get("/bibrefs?refs=webidl").reply(200,
86
- { webidl: { href: "https://webidl.spec.whatwg.org/" } },
87
- { "Access-Control-Allow-Origin": "*" }
88
- );
89
-
90
- nock("https://www.w3.org")
91
- .persist()
92
- .get("/scripts/TR/2021/fixup.js").reply(200, '')
93
- .get("/StyleSheets/TR/2021/logos/W3C").reply(200, '')
94
- .get("/StyleSheets/TR/2021/base.css").reply(200, '')
95
- .get("/Tools/respec/respec-highlight").replyWithFile(200,
96
- path.join(modulesFolder, "respec-hljs", "dist", "respec-highlight.js"),
97
- { "Content-Type": "application/js" })
98
- .get("/Tools/respec/respec-w3c").replyWithFile(200,
99
- path.join(modulesFolder, "respec", "builds", "respec-w3c.js"),
100
- { "Content-Type": "application/js" })
101
- .get("/TR/idontexist/").reply(404, '')
102
- .get("/TR/ididnotchange/").reply(function() {
103
- if (this.req.headers['if-modified-since'][0] === "Fri, 11 Feb 2022 00:00:42 GMT") {
104
- return [304, ''];
105
- } else {
106
- return [200, 'Unexpected path'];
107
- }
108
- });
109
-
110
- nock("https://drafts.csswg.org")
111
- .persist()
112
- .get("/server-hiccup/").reply(200,
113
- `<html><title>Server hiccup</title>
114
- <h1> Index of Server Hiccup Module Level 42 </h1>`,
115
- { 'Content-Type': 'text/html' });
116
-
117
- nock.emitter.on('error', function (err) {
118
- console.error(err);
119
- });
120
- nock.emitter.on('no match', function(req, options, requestBody) {
121
- // 127.0.0.1 is used by the devtool protocol, we ignore it
122
- if (req && req.hostname !== '127.0.0.1') {
123
- console.error("No match for nock request on " + (options ? options.href : req.href));
124
- }
125
- });
126
-
127
- module.exports = nock;
1
+ /**
2
+ * Setup a proxy server that intercepts some network requests. To be used in
3
+ * tests not to hit the network.
4
+ *
5
+ * @module nock-server
6
+ */
7
+
8
+ const nock = require("nock");
9
+ const path = require("path");
10
+ const { existsSync } = require('fs');
11
+
12
+ /**
13
+ * Determine the path to the "node_modules" folder. The path depends on whether
14
+ * Reffy is run directly, or installed as a library.
15
+ *
16
+ * @function
17
+ * @return {String} Path to the node_modules folder.
18
+ */
19
+ function getModulesFolder() {
20
+ const rootFolder = path.resolve(__dirname, '../..');
21
+ let folder = path.resolve(rootFolder, 'node_modules');
22
+ if (existsSync(folder)) {
23
+ return folder;
24
+ }
25
+ folder = path.resolve(rootFolder, '..');
26
+ return folder;
27
+ }
28
+ const modulesFolder = getModulesFolder();
29
+
30
+ const mockSpecs = {
31
+ "/woff/woff2/": {
32
+ html: `
33
+ <title>WOFF2</title>
34
+ <body>
35
+ <dfn id='foo'>Foo</dfn>
36
+ <a href="https://www.w3.org/TR/bar/#baz">bar</a>
37
+ <ul class='toc'><li><a href='page.html'>page</a></ul>`,
38
+ pages: {
39
+ "page.html": `<h2 id='bar'>Heading in subpage</h2>`
40
+ }
41
+ },
42
+ "/mediacapture-output/": `
43
+ <script>respecConfig = { shortName: 'test' };</script>
44
+ <script src='https://www.w3.org/Tools/respec/respec-w3c'></script>
45
+ <div id=abstract></div>
46
+ <pre class='idl'>[Exposed=Window] interface Foo { attribute DOMString bar; };</pre>`,
47
+ "/accelerometer/": `<html>
48
+ <h2>Normative references</h2>
49
+ <dl>
50
+ <dt>FOO</dt>
51
+ <dd><a href='https://www.w3.org/TR/Foo'>Foo</a></dd>
52
+ </dl>`,
53
+ "/pointerlock/": `<html>
54
+ <h1>Pointer Lock 2.0`
55
+ };
56
+
57
+ nock.disableNetConnect();
58
+ // for chrome devtool protocol
59
+ nock.enableNetConnect('127.0.0.1');
60
+
61
+ Object.keys(mockSpecs).forEach(path => {
62
+ nock("https://w3c.github.io")
63
+ .persist()
64
+ .get(path)
65
+ .reply(200,
66
+ typeof mockSpecs[path] === "string" ? mockSpecs[path] : mockSpecs[path].html,
67
+ { 'Content-Type': 'text/html' }
68
+ );
69
+
70
+ Object.keys(mockSpecs[path].pages || {}).forEach(page => {
71
+ nock("https://w3c.github.io")
72
+ .persist()
73
+ .get(path + page)
74
+ .reply(200,
75
+ mockSpecs[path].pages[page],
76
+ { 'Content-Type': 'text/html' });
77
+
78
+ });
79
+ });
80
+
81
+
82
+ // Handling requests generated by ReSpec documents
83
+ nock("https://api.specref.org")
84
+ .persist()
85
+ .get("/bibrefs?refs=webidl").reply(200,
86
+ { webidl: { href: "https://webidl.spec.whatwg.org/" } },
87
+ { "Access-Control-Allow-Origin": "*" }
88
+ );
89
+
90
+ nock("https://www.w3.org")
91
+ .persist()
92
+ .get("/scripts/TR/2021/fixup.js").reply(200, '')
93
+ .get("/StyleSheets/TR/2021/logos/W3C").reply(200, '')
94
+ .get("/StyleSheets/TR/2021/base.css").reply(200, '')
95
+ .get("/Tools/respec/respec-highlight").replyWithFile(200,
96
+ path.join(modulesFolder, "respec-hljs", "dist", "respec-highlight.js"),
97
+ { "Content-Type": "application/js" })
98
+ .get("/Tools/respec/respec-w3c").replyWithFile(200,
99
+ path.join(modulesFolder, "respec", "builds", "respec-w3c.js"),
100
+ { "Content-Type": "application/js" })
101
+ .get("/TR/idontexist/").reply(404, '')
102
+ .get("/TR/ididnotchange/").reply(function() {
103
+ if (this.req.headers['if-modified-since'][0] === "Fri, 11 Feb 2022 00:00:42 GMT") {
104
+ return [304, ''];
105
+ } else {
106
+ return [200, 'Unexpected path'];
107
+ }
108
+ });
109
+
110
+ nock("https://drafts.csswg.org")
111
+ .persist()
112
+ .get("/server-hiccup/").reply(200,
113
+ `<html><title>Server hiccup</title>
114
+ <h1> Index of Server Hiccup Module Level 42 </h1>`,
115
+ { 'Content-Type': 'text/html' });
116
+
117
+ nock.emitter.on('error', function (err) {
118
+ console.error(err);
119
+ });
120
+ nock.emitter.on('no match', function(req, options, requestBody) {
121
+ // 127.0.0.1 is used by the devtool protocol, we ignore it
122
+ if (req && req.hostname !== '127.0.0.1') {
123
+ console.error("No match for nock request on " + (options ? options.href : req.href));
124
+ }
125
+ });
126
+
127
+ module.exports = nock;