reffy 19.1.4 → 19.1.6

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": "19.1.4",
3
+ "version": "19.1.6",
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",
@@ -39,13 +39,13 @@
39
39
  "fetch-filecache-for-crawling": "5.1.1",
40
40
  "puppeteer": "24.15.0",
41
41
  "semver": "^7.3.5",
42
- "web-specs": "3.58.0",
42
+ "web-specs": "3.59.0",
43
43
  "webidl2": "24.5.0"
44
44
  },
45
45
  "devDependencies": {
46
46
  "respec": "35.4.3",
47
47
  "respec-hljs": "2.1.1",
48
- "rollup": "4.45.1",
48
+ "rollup": "4.46.1",
49
49
  "undici": "^7.0.0"
50
50
  },
51
51
  "overrides": {
@@ -9,6 +9,13 @@
9
9
  "type": "string"
10
10
  },
11
11
  "minItems": 1
12
+ },
13
+
14
+ "extended": {
15
+ "type": "array",
16
+ "items": {
17
+ "$ref": "../common.json#/$defs/url"
18
+ }
12
19
  }
13
20
  },
14
21
 
@@ -25,6 +32,7 @@
25
32
  "properties": {
26
33
  "name": { "type": "string", "pattern": "^@" },
27
34
  "href": { "$ref": "../common.json#/$defs/url" },
35
+ "extended": { "$ref": "#/$defs/extended" },
28
36
  "syntax": { "$ref": "../common.json#/$defs/cssValue" },
29
37
  "prose": { "type": "string" },
30
38
  "descriptors": {
@@ -48,13 +56,13 @@
48
56
  "type": "array",
49
57
  "items": {
50
58
  "type": "object",
51
- "required": ["name", "type"],
59
+ "required": ["name"],
52
60
  "additionalProperties": false,
53
61
  "properties": {
54
62
  "name": { "type": "string", "pattern": "^.*()$" },
55
63
  "for": { "$ref": "#/$defs/scopes" },
56
64
  "href": { "$ref": "../common.json#/$defs/url" },
57
- "type": { "type": "string", "enum": ["function"] },
65
+ "extended": { "$ref": "#/$defs/extended" },
58
66
  "prose": { "type": "string" },
59
67
  "syntax": { "$ref": "../common.json#/$defs/cssValue" }
60
68
  }
@@ -69,6 +77,7 @@
69
77
  "properties": {
70
78
  "name": { "$ref": "../common.json#/$defs/cssPropertyName" },
71
79
  "href": { "$ref": "../common.json#/$defs/url" },
80
+ "extended": { "$ref": "#/$defs/extended" },
72
81
  "syntax": { "$ref": "../common.json#/$defs/cssValue" },
73
82
  "legacyAliasOf": { "$ref": "../common.json#/$defs/cssPropertyName" },
74
83
  "styleDeclaration": {
@@ -88,6 +97,7 @@
88
97
  "properties": {
89
98
  "name": { "$ref": "../common.json#/$defs/cssPropertyName" },
90
99
  "href": { "$ref": "../common.json#/$defs/url" },
100
+ "extended": { "$ref": "#/$defs/extended" },
91
101
  "prose": { "type": "string" },
92
102
  "syntax": { "$ref": "../common.json#/$defs/cssValue" }
93
103
  }
@@ -97,13 +107,13 @@
97
107
  "type": "array",
98
108
  "items": {
99
109
  "type": "object",
100
- "required": ["name", "type"],
110
+ "required": ["name"],
101
111
  "additionalProperties": false,
102
112
  "properties": {
103
113
  "name": { "type": "string", "pattern": "^[a-zA-Z0-9-\\+\\(\\)\\[\\]\\{\\}]+$" },
104
114
  "for": { "$ref": "#/$defs/scopes" },
105
115
  "href": { "$ref": "../common.json#/$defs/url" },
106
- "type": { "type": "string", "enum": ["type"] },
116
+ "extended": { "$ref": "#/$defs/extended" },
107
117
  "prose": { "type": "string" },
108
118
  "syntax": { "$ref": "../common.json#/$defs/cssValue" }
109
119
  }
@@ -111,8 +111,9 @@ export default {
111
111
 
112
112
  // The job is "almost" done but we now need to de-duplicate entries.
113
113
  // Duplicated entries exist when:
114
- // - A property is defined in one spec and extended in other specs. We'll
115
- // consolidate the entries (and syntaxes) to get back to a single entry.
114
+ // - A property, function or type is defined in one spec and extended in
115
+ // other specs. We'll consolidate the entries (and syntaxes) to get back to
116
+ // a single entry.
116
117
  // - An at-rule is defined in one spec. Additional descriptors are defined
117
118
  // in other specs. We'll consolidate the entries similarly.
118
119
  // - A descriptor is defined in one level of a spec series, and re-defined
@@ -179,13 +180,22 @@ export default {
179
180
  // Identify the base definition for each feature, using the definition
180
181
  // (that has some known syntax) in the most recent level. Move that base
181
182
  // definition to the beginning of the array and get rid of other base
182
- // definitions.
183
- // (Note: the code chooses one definition if duplicates of base
184
- // definitions in unrelated specs still exist)
183
+ // definitions. Notes:
184
+ // - For properties, an extension is an entry with a `newValues` key.
185
+ // - For functions and types, an extension is an entry without an `href`
186
+ // key (the spec that extends the base type does not contain any `<dfn>`)
187
+ // - The code chooses one definition if duplicates of base definitions in
188
+ // unrelated specs still exist.
185
189
  for (const [name, dfns] of Object.entries(featureDfns)) {
186
- let actualDfns = dfns.filter(dfn => dfn.syntax);
190
+ let actualDfns = dfns.filter(dfn => dfn.href && dfn.syntax);
187
191
  if (actualDfns.length === 0) {
188
- actualDfns = dfns.filter(dfn => !dfn.newValues);
192
+ actualDfns = dfns.filter(dfn => dfn.href && !dfn.newValues);
193
+ }
194
+ if (actualDfns.length === 0) {
195
+ // No base definition, not a real type, let's discard it
196
+ // (problem should be captured through tests on individual extracts)
197
+ delete featureDfns[name];
198
+ continue;
189
199
  }
190
200
  const best = actualDfns.reduce((dfn1, dfn2) => {
191
201
  if (dfn1.spec.series.shortname !== dfn2.spec.series.shortname) {
@@ -199,6 +209,7 @@ export default {
199
209
  return dfn1;
200
210
  }
201
211
  });
212
+ best.extended = [];
202
213
  featureDfns[name] = [best].concat(
203
214
  dfns.filter(dfn => !actualDfns.includes(dfn))
204
215
  );
@@ -239,6 +250,18 @@ export default {
239
250
  continue;
240
251
  }
241
252
  baseDfn.syntax += ' | ' + dfn.newValues;
253
+ baseDfn.extended.push(dfn.href);
254
+ }
255
+ else if (dfn.syntax) {
256
+ // Extensions of functions and types are *re-definitions* in
257
+ // practice, new syntax overrides the base one. There should be
258
+ // only one such extension in unrelated specs, the code assumes
259
+ // that some sort of curation already took place, and picks up
260
+ // a winner randomly.
261
+ // Note: we don't have any `href` info for functions/types
262
+ // extensions, so we'll just use the URL of the crawled spec.
263
+ baseDfn.syntax = dfn.syntax;
264
+ baseDfn.extended = [dfn.spec.crawled ?? dfn.spec.url];
242
265
  }
243
266
  if (baseDfn.descriptors && dfn.descriptors?.length > 0) {
244
267
  baseDfn.descriptors.push(...dfn.descriptors.filter(desc =>