reffy 18.1.2 → 18.2.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": "18.1.2",
3
+ "version": "18.2.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",
@@ -35,18 +35,18 @@
35
35
  "dependencies": {
36
36
  "ajv": "8.17.1",
37
37
  "ajv-formats": "3.0.1",
38
- "commander": "12.1.0",
38
+ "commander": "13.0.0",
39
39
  "fetch-filecache-for-crawling": "5.1.1",
40
- "puppeteer": "23.11.1",
40
+ "puppeteer": "24.1.0",
41
41
  "semver": "^7.3.5",
42
- "web-specs": "3.31.0",
42
+ "web-specs": "3.34.0",
43
43
  "webidl2": "24.4.1"
44
44
  },
45
45
  "devDependencies": {
46
46
  "mocha": "11.0.1",
47
- "respec": "35.2.1",
47
+ "respec": "35.2.2",
48
48
  "respec-hljs": "2.1.1",
49
- "rollup": "4.28.1",
49
+ "rollup": "4.30.1",
50
50
  "undici": "^7.0.0"
51
51
  },
52
52
  "overrides": {
@@ -85,6 +85,12 @@ function hasValidType(el) {
85
85
  'element-attr',
86
86
  'attr-value',
87
87
 
88
+ // CDDL types
89
+ 'cddl-module',
90
+ 'cddl-type',
91
+ 'cddl-parameter',
92
+ 'cddl-key',
93
+ 'cddl-value',
88
94
 
89
95
  // URL scheme
90
96
  'scheme',
@@ -231,13 +237,15 @@ function definitionMapper(el, idToHeading, usesDfnDataModel) {
231
237
  [],
232
238
 
233
239
  // Definition is public if explicitly marked as exportable or if export has
234
- // not been explicitly disallowed and its type is not "dfn", or if the spec
235
- // is an old spec that does not use the "data-dfn-type" convention.
240
+ // not been explicitly disallowed and its type is not "dfn" or a CDDL type,
241
+ // or if the spec is an old spec that does not use the "data-dfn-type"
242
+ // convention.
236
243
  access: (!usesDfnDataModel ||
237
244
  el.hasAttribute('data-export') ||
238
245
  (!el.hasAttribute('data-noexport') &&
239
246
  el.hasAttribute('data-dfn-type') &&
240
- el.getAttribute('data-dfn-type') !== 'dfn')) ?
247
+ el.getAttribute('data-dfn-type') !== 'dfn' &&
248
+ !el.getAttribute('data-dfn-type').startsWith('cddl-'))) ?
241
249
  'public' : 'private',
242
250
 
243
251
  // Whether the term is defined in a normative/informative section
@@ -293,6 +301,10 @@ export default function (spec, idToHeading = {}) {
293
301
  case "SVG2":
294
302
  preProcessSVG2();
295
303
  break;
304
+ case "rfc8610":
305
+ // RFC8610 defines CDDL
306
+ preProcessRFC8610();
307
+ break;
296
308
  }
297
309
 
298
310
  const definitions = [...document.querySelectorAll(definitionsSelector)];
@@ -861,3 +873,53 @@ function preProcessSVG2() {
861
873
  });
862
874
 
863
875
  }
876
+
877
+ /**
878
+ * The CDDL RFC defines a standard prelude with a number of CDDL types that
879
+ * other specs that define CDDL make extensive use of. To be able to link back
880
+ * to these type definitions from other specs, we need these types to appear
881
+ * in the dfns extract of the RFC somehow.
882
+ *
883
+ * Now, the RFC only defines one ID for the appendix that contains the
884
+ * standard prelude. We need to "share" that ID across all types. To avoid
885
+ * introducing definitions that have the same ID and href, which could perhaps
886
+ * confuse tools that ingest the definitions, the approach taken here is to
887
+ * create a single definition that contains all the types as linking text.
888
+ */
889
+ function preProcessRFC8610() {
890
+ // The RFC is defined as a set of pages (yuck!)
891
+ // The standard prelude is an appendix, let's look for it
892
+ const prePages = [...document.querySelectorAll('pre.newpage')];
893
+ const preludeStart = /<a [^>]*id=[^>]*>Appendix .<\/a>\.\s+Standard Prelude/;
894
+ const preludeEnd = /Figure \d+: CDDL Prelude/;
895
+ const preStart = prePages
896
+ .findIndex(pre => pre.innerHTML.match(preludeStart));
897
+ if (preStart === -1) {
898
+ // Can't find the expected prelude start text, not a good start!
899
+ return;
900
+ }
901
+ const preEnd = prePages
902
+ .findIndex((pre, idx) => idx >= preStart && pre.innerHTML.match(preludeEnd));
903
+ if (preEnd === -1) {
904
+ // Can't find the expected prelude ending text, not a good start!
905
+ return;
906
+ }
907
+
908
+ // Extract the list of types defined in the appendix
909
+ const preludeTypes = prePages.slice(preStart, preEnd + 1)
910
+ .map(pre => [...pre.innerHTML.matchAll(/^\s+([a-z0-9\-]+) = .*$/mg)]
911
+ .map(m => m[1])
912
+ )
913
+ .flat();
914
+
915
+ // Convert the appendix heading into a cddl-type definition that lists
916
+ // all CDDL types.
917
+ const el = prePages[preStart].querySelector(`a[id]`);
918
+ const dfn = document.createElement("dfn");
919
+ dfn.id = el.id;
920
+ dfn.dataset.dfnType = 'cddl-type';
921
+ dfn.dataset.lt = preludeTypes.join('|');
922
+ dfn.dataset.export = '';
923
+ dfn.textContent = el.textContent;
924
+ el.replaceWith(dfn);
925
+ }