@webref/xref 1.1.1 → 1.2.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.
Files changed (82) hide show
  1. package/README.md +77 -0
  2. package/ed/dfns/attribution.json +17 -17
  3. package/ed/dfns/connection-allowlists.json +780 -0
  4. package/ed/dfns/did-resolution.json +17 -17
  5. package/ed/dfns/ecmascript.json +2 -2
  6. package/ed/dfns/encoding.json +20 -0
  7. package/ed/dfns/picture-in-picture.json +58 -18
  8. package/ed/dfns/pointerevents4.json +27 -0
  9. package/ed/dfns/rfc8610.json +6 -5
  10. package/ed/dfns/sanitizer-api.json +20 -0
  11. package/ed/dfns/shacl12-rules.json +181 -86
  12. package/ed/dfns/speech-api.json +22 -0
  13. package/ed/dfns/vc-recognized-entities.json +6 -6
  14. package/ed/dfns/web-smart-card.json +1065 -1151
  15. package/ed/dfns/webdriver-bidi.json +1748 -679
  16. package/ed/dfns/webmcp.json +164 -3
  17. package/ed/dfns/webnn.json +20 -0
  18. package/ed/dfns/webrtc-encoded-transform.json +28 -28
  19. package/ed/dfns/webrtc-ice.json +2 -2
  20. package/ed/headings/attribution.json +21 -0
  21. package/ed/headings/connection-allowlists.json +228 -0
  22. package/ed/headings/did-resolution.json +161 -92
  23. package/ed/headings/dom.json +1 -1
  24. package/ed/headings/ecmascript.json +1 -1
  25. package/ed/headings/encoding.json +1 -1
  26. package/ed/headings/picture-in-picture.json +5 -5
  27. package/ed/headings/rfc2397.json +33 -9
  28. package/ed/headings/rfc4120.json +164 -134
  29. package/ed/headings/rfc6386.json +128 -104
  30. package/ed/headings/rfc6454.json +62 -38
  31. package/ed/headings/rfc6455.json +120 -90
  32. package/ed/headings/rfc6797.json +104 -80
  33. package/ed/headings/rfc7034.json +52 -28
  34. package/ed/headings/rfc7239.json +55 -31
  35. package/ed/headings/rfc7469.json +63 -39
  36. package/ed/headings/rfc7578.json +54 -30
  37. package/ed/headings/rfc7932.json +70 -40
  38. package/ed/headings/rfc8610.json +93 -63
  39. package/ed/headings/rfc8878.json +97 -88
  40. package/ed/headings/rfc9163.json +62 -59
  41. package/ed/headings/rfc9649.json +82 -79
  42. package/ed/headings/rfc9659.json +33 -30
  43. package/ed/headings/secure-payment-confirmation.json +1 -1
  44. package/ed/headings/selectors-5.json +8 -1
  45. package/ed/headings/service-workers.json +1 -1
  46. package/ed/headings/shacl12-rules.json +125 -85
  47. package/ed/headings/soft-navigations.json +1 -1
  48. package/ed/headings/storage-access.json +2 -2
  49. package/ed/headings/vc-data-model-2.1.json +72 -72
  50. package/ed/headings/vc-jose-cose.json +70 -70
  51. package/ed/headings/vc-recognized-entities.json +62 -32
  52. package/ed/headings/web-smart-card.json +106 -217
  53. package/ed/headings/webdriver-bidi.json +25 -4
  54. package/ed/headings/webidl.json +1 -1
  55. package/ed/headings/webmcp.json +14 -0
  56. package/ed/headings/webnn.json +1 -1
  57. package/ed/headings/webrtc-encoded-transform.json +1 -1
  58. package/ed/headings/webusb.json +1 -1
  59. package/ed/headings/webvtt1.json +2 -2
  60. package/index.js +56 -8
  61. package/package.json +1 -1
  62. package/specs.json +28925 -0
  63. package/tr/dfns/attribution.json +17 -17
  64. package/tr/dfns/did-resolution.json +17 -17
  65. package/tr/dfns/picture-in-picture.json +58 -18
  66. package/tr/dfns/pointerevents4.json +27 -0
  67. package/tr/dfns/shacl12-rules.json +181 -86
  68. package/tr/dfns/webdriver-bidi.json +1748 -679
  69. package/tr/dfns/webnn.json +20 -0
  70. package/tr/dfns/webrtc-encoded-transform.json +28 -28
  71. package/tr/dfns/webvtt1.json +82 -95
  72. package/tr/headings/attribution.json +21 -0
  73. package/tr/headings/did-resolution.json +161 -92
  74. package/tr/headings/picture-in-picture.json +5 -5
  75. package/tr/headings/secure-payment-confirmation.json +1 -1
  76. package/tr/headings/service-workers.json +1 -1
  77. package/tr/headings/shacl12-rules.json +125 -85
  78. package/tr/headings/webauthn-3.json +9 -2
  79. package/tr/headings/webdriver-bidi.json +25 -4
  80. package/tr/headings/webnn.json +1 -1
  81. package/tr/headings/webrtc-encoded-transform.json +1 -1
  82. package/tr/headings/webvtt1.json +3 -9
@@ -1713,7 +1713,7 @@
1713
1713
  "id": "informative",
1714
1714
  "href": "https://webidl.spec.whatwg.org/#informative",
1715
1715
  "level": 3,
1716
- "title": "Informative References"
1716
+ "title": "Non-Normative References"
1717
1717
  },
1718
1718
  {
1719
1719
  "id": "idl-index",
@@ -101,6 +101,20 @@
101
101
  "title": "Declarative WebMCP",
102
102
  "number": "4.3"
103
103
  },
104
+ {
105
+ "id": "events",
106
+ "href": "https://webmachinelearning.github.io/webmcp/#events",
107
+ "level": 3,
108
+ "title": "Events",
109
+ "number": "4.4"
110
+ },
111
+ {
112
+ "id": "permissions-policy",
113
+ "href": "https://webmachinelearning.github.io/webmcp/#permissions-policy",
114
+ "level": 3,
115
+ "title": "Permissions policy integration",
116
+ "number": "4.5"
117
+ },
104
118
  {
105
119
  "id": "interaction-with-agents",
106
120
  "href": "https://webmachinelearning.github.io/webmcp/#interaction-with-agents",
@@ -1107,7 +1107,7 @@
1107
1107
  "id": "informative",
1108
1108
  "href": "https://webmachinelearning.github.io/webnn/#informative",
1109
1109
  "level": 3,
1110
- "title": "Informative References"
1110
+ "title": "Non-Normative References"
1111
1111
  },
1112
1112
  {
1113
1113
  "id": "idl-index",
@@ -349,7 +349,7 @@
349
349
  "id": "informative",
350
350
  "href": "https://w3c.github.io/webrtc-encoded-transform/#informative",
351
351
  "level": 3,
352
- "title": "Informative References"
352
+ "title": "Non-Normative References"
353
353
  },
354
354
  {
355
355
  "id": "idl-index",
@@ -377,7 +377,7 @@
377
377
  "id": "informative",
378
378
  "href": "https://wicg.github.io/webusb/#informative",
379
379
  "level": 3,
380
- "title": "Informative References"
380
+ "title": "Non-Normative References"
381
381
  },
382
382
  {
383
383
  "id": "idl-index",
@@ -17,8 +17,8 @@
17
17
  "title": "Abstract"
18
18
  },
19
19
  {
20
- "id": "status",
21
- "href": "https://w3c.github.io/webvtt/#status",
20
+ "id": "sotd",
21
+ "href": "https://w3c.github.io/webvtt/#sotd",
22
22
  "level": 2,
23
23
  "title": "Status of this document"
24
24
  },
package/index.js CHANGED
@@ -9,7 +9,8 @@ const scriptPath = path.dirname(fileURLToPath(import.meta.url));
9
9
  */
10
10
  const xref = {
11
11
  dfns: [],
12
- headings: []
12
+ headings: [],
13
+ specs: []
13
14
  };
14
15
 
15
16
  /**
@@ -83,6 +84,18 @@ export function setup(rootFolder = scriptPath) {
83
84
  if (initialized) {
84
85
  return;
85
86
  }
87
+ if (rootFolder === scriptPath) {
88
+ // We're in "package" mode, the root folder contains a `specs.json` file.
89
+ xref.specs = JSON.parse(fs.readFileSync(path.join(rootFolder, 'specs.json'), 'utf8'));
90
+ }
91
+ else {
92
+ // We're in "use crawl results" mode, the root folder won't contain a
93
+ // `specs.json` file, but the `ed` folder should have a crawl index with a
94
+ // list of specs.
95
+ const crawl = JSON.parse(fs.readFileSync(path.join(rootFolder, 'ed', 'index.json'), 'utf8'));
96
+ xref.specs = crawl.results;
97
+ }
98
+
86
99
  for (const type of ['dfns', 'headings']) {
87
100
  setupExtracts(type, rootFolder);
88
101
  }
@@ -94,11 +107,14 @@ export function setup(rootFolder = scriptPath) {
94
107
  * Lookup a URL in the loaded database
95
108
  *
96
109
  * The function returns an array of entries. Each entry is an object with a
97
- * `source` key set to "dfns", "headings", "links", or "alternateIds"; and a
98
- * `entry` key set to either a dfn object when `source` is "dfns" or "links",
99
- * or a heading object when `source` is "headings" or "alternateIds".
110
+ * `source` key set to "dfns" or "headings"; and a `entry` key set to either a
111
+ * dfn object when `source` is "dfns" or a heading object when `source` is
112
+ * "headings".
113
+ *
114
+ * The function accepts a lookup options object as second parameter that sets
115
+ * lookup capabilities and filters. Check the README for details.
100
116
  */
101
- export function lookup(url) {
117
+ export function lookup(url, { standing, version, series } = {}) {
102
118
  if (!initialized) {
103
119
  throw new Error('The `lookup()` function was called before `setup()`.');
104
120
  }
@@ -125,8 +141,40 @@ export function lookup(url) {
125
141
  decodedHash = parsedUrl.hash;
126
142
  }
127
143
  parsedUrl.hash = encodeURIComponent(decodedHash.replace(/^#/, ''));
128
- const lookupUrl = parsedUrl.toString();
144
+ let lookupUrl = parsedUrl.toString();
129
145
 
130
- const res = urlIndex[lookupUrl.toString()];
131
- return structuredClone(res) ?? [];
146
+ // If the series flag is set, the provided URL may also be a spec series URL,
147
+ // which we need to convert to the URL of the current spec in the series.
148
+ if (series && !urlIndex[lookupUrl.toString()]) {
149
+ // Drop the hash to match spec URLs
150
+ const hash = parsedUrl.hash;
151
+ parsedUrl.hash = '';
152
+ const specUrl = parsedUrl.toString();
153
+ const spec = xref.specs.find(spec =>
154
+ spec.shortname === spec.series.currentSpecification &&
155
+ (spec.series.nightlyUrl === specUrl || spec.series.releaseUrl === specUrl)
156
+ );
157
+ if (spec) {
158
+ // The lookup URL matches a series URL indeed, let's change it to the URL
159
+ // of the current spec in the series
160
+ const currentUrl = new URL(
161
+ (spec.series.nightlyUrl === specUrl) ? spec.nightly.url : spec.release.url
162
+ );
163
+ currentUrl.hash = hash;
164
+ lookupUrl = currentUrl.toString();
165
+ }
166
+ }
167
+
168
+ // Look for the resulting URL and filter results as needed
169
+ let res = urlIndex[lookupUrl.toString()] ?? [];
170
+ const hasSpecFilter = standing || version;
171
+ if (hasSpecFilter) {
172
+ res = res.filter(match => {
173
+ const entry = match.entry;
174
+ const spec = xref.specs.find(spec => spec.shortname === entry.spec);
175
+ return (!standing || spec.standing === standing) &&
176
+ (!version || entry.version === version);
177
+ });
178
+ }
179
+ return structuredClone(res);
132
180
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@webref/xref",
3
3
  "description": "Definitions of the web platform for cross-references purpose",
4
- "version": "1.1.1",
4
+ "version": "1.2.1",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "https://github.com/w3c/webref.git",