respec 36.0.0 ā 37.0.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/builds/respec-aom.js +136 -9611
- package/builds/respec-aom.js.map +1 -1
- package/builds/respec-dini.js +141 -9755
- package/builds/respec-dini.js.map +1 -1
- package/builds/respec-geonovum.js +99 -9310
- package/builds/respec-geonovum.js.map +1 -1
- package/builds/respec-w3c.js +592 -17711
- package/builds/respec-w3c.js.map +1 -1
- package/builds/respec-worker.js +67 -9
- package/package.json +6 -6
- package/tools/respecDocWriter.js +9 -28
package/builds/respec-worker.js
CHANGED
|
@@ -10,15 +10,73 @@ if (typeof self.hljs === "undefined" && self.RESPEC_HIGHLIGHT_URL) {
|
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
self.addEventListener("message", ({ data }) => {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
13
|
+
switch (data.action) {
|
|
14
|
+
case "highlight-load-lang": {
|
|
15
|
+
const { langURL, langScript, propName, lang } = data;
|
|
16
|
+
console.warn(
|
|
17
|
+
`[ReSpec] The "highlight-load-lang" worker action is deprecated ` +
|
|
18
|
+
`and will be removed in a future version. ` +
|
|
19
|
+
`To migrate, fetch your language script in the main thread and ` +
|
|
20
|
+
`send the text as "langScript" instead of "langURL". ` +
|
|
21
|
+
`The "langURL" path may fail in Firefox. ` +
|
|
22
|
+
`See https://github.com/speced/respec/issues/5228`
|
|
23
|
+
);
|
|
24
|
+
try {
|
|
25
|
+
if (langScript) {
|
|
26
|
+
const blob = new Blob([langScript], {
|
|
27
|
+
type: "application/javascript",
|
|
28
|
+
});
|
|
29
|
+
const objectURL = URL.createObjectURL(blob);
|
|
30
|
+
try {
|
|
31
|
+
importScripts(objectURL);
|
|
32
|
+
} finally {
|
|
33
|
+
URL.revokeObjectURL(objectURL);
|
|
34
|
+
}
|
|
35
|
+
} else if (langURL) {
|
|
36
|
+
const { protocol, hostname } = new URL(langURL);
|
|
37
|
+
const isSecure =
|
|
38
|
+
protocol === "https:" ||
|
|
39
|
+
(protocol === "http:" &&
|
|
40
|
+
(hostname === "localhost" ||
|
|
41
|
+
hostname === "127.0.0.1" ||
|
|
42
|
+
hostname === "[::1]"));
|
|
43
|
+
if (!isSecure) {
|
|
44
|
+
throw new Error(
|
|
45
|
+
`langURL must be https: or http: on localhost, got "${langURL}"`
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
importScripts(langURL);
|
|
49
|
+
} else {
|
|
50
|
+
throw new Error(
|
|
51
|
+
`No langScript or langURL provided for language "${lang}"`
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
if (typeof self[propName] === "function") {
|
|
55
|
+
self.hljs.registerLanguage(lang, self[propName]);
|
|
56
|
+
} else {
|
|
57
|
+
throw new Error(
|
|
58
|
+
`Language definer "${propName}" is not a function on self`
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
} catch (err) {
|
|
62
|
+
console.error("Failed to load or register language", lang, err);
|
|
63
|
+
}
|
|
64
|
+
delete data.langScript;
|
|
65
|
+
delete data.langURL;
|
|
66
|
+
break;
|
|
67
|
+
}
|
|
68
|
+
case "highlight": {
|
|
69
|
+
const { code } = data;
|
|
70
|
+
const langs = data.languages?.length ? data.languages : undefined;
|
|
71
|
+
try {
|
|
72
|
+
const { value, language } = self.hljs.highlightAuto(code, langs);
|
|
73
|
+
Object.assign(data, { value, language });
|
|
74
|
+
} catch (err) {
|
|
75
|
+
console.error("Could not transform some code?", err);
|
|
76
|
+
Object.assign(data, { value: code, language: "" });
|
|
77
|
+
}
|
|
78
|
+
break;
|
|
79
|
+
}
|
|
22
80
|
}
|
|
23
81
|
self.postMessage(data);
|
|
24
82
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "respec",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "37.0.0",
|
|
4
4
|
"license": "W3C",
|
|
5
5
|
"description": "A technical specification pre-processor.",
|
|
6
6
|
"engines": {
|
|
@@ -55,16 +55,16 @@
|
|
|
55
55
|
"lint-staged": "^16.4.0",
|
|
56
56
|
"loading-indicator": "^2.0.0",
|
|
57
57
|
"pluralize": "^8.0.0",
|
|
58
|
-
"prettier": "^3.8.
|
|
58
|
+
"prettier": "^3.8.3",
|
|
59
59
|
"prompt": "^1.3.0",
|
|
60
|
-
"rollup": "^4.60.
|
|
60
|
+
"rollup": "^4.60.2",
|
|
61
61
|
"rollup-plugin-minify-html-literals": "^1.2.6",
|
|
62
62
|
"serve": "^14.2.6",
|
|
63
63
|
"serve-handler": "^6.1.7",
|
|
64
64
|
"simple-git-hooks": "^2.13.1",
|
|
65
65
|
"sniffy-mimetype": "^1.1.1",
|
|
66
66
|
"typescript": "^6.0.3",
|
|
67
|
-
"vnu-jar": "^26.4.
|
|
67
|
+
"vnu-jar": "^26.4.16",
|
|
68
68
|
"webidl2": "^24.5.0"
|
|
69
69
|
},
|
|
70
70
|
"scripts": {
|
|
@@ -92,8 +92,8 @@
|
|
|
92
92
|
"dependencies": {
|
|
93
93
|
"colors": "1.4.0",
|
|
94
94
|
"finalhandler": "^2.1.1",
|
|
95
|
-
"marked": "^18.0.
|
|
96
|
-
"puppeteer": "^24.
|
|
95
|
+
"marked": "^18.0.2",
|
|
96
|
+
"puppeteer": "^24.42.0",
|
|
97
97
|
"sade": "^1.8.1",
|
|
98
98
|
"serve-static": "^2.2.1"
|
|
99
99
|
},
|
package/tools/respecDocWriter.js
CHANGED
|
@@ -225,7 +225,7 @@ async function checkIfReSpec(page) {
|
|
|
225
225
|
*/
|
|
226
226
|
async function generateHTML(page, timer, version, url) {
|
|
227
227
|
try {
|
|
228
|
-
return await page.evaluate(evaluateHTML,
|
|
228
|
+
return await page.evaluate(evaluateHTML, timer);
|
|
229
229
|
} catch (err) {
|
|
230
230
|
const msg = `\nš Sorry, there was an error generating the HTML. Please report this issue!\n${`${
|
|
231
231
|
`Specification: ${url}\n` +
|
|
@@ -237,43 +237,24 @@ async function generateHTML(page, timer, version, url) {
|
|
|
237
237
|
}
|
|
238
238
|
|
|
239
239
|
/**
|
|
240
|
-
* @param {ReSpecVersion} version
|
|
241
240
|
* @param {ReturnType<typeof createTimer>} timer
|
|
242
241
|
*/
|
|
243
|
-
async function evaluateHTML(
|
|
242
|
+
async function evaluateHTML(timer) {
|
|
244
243
|
await timeout(
|
|
245
244
|
document.respec ? document.respec.ready : document.respecIsReady,
|
|
246
245
|
timer.remaining
|
|
247
246
|
);
|
|
248
247
|
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
248
|
+
if (!document.respec?.toHTML) {
|
|
249
|
+
throw new Error(
|
|
250
|
+
"document.respec.toHTML is not available. " +
|
|
251
|
+
"Please upgrade to a newer version of ReSpec, " +
|
|
252
|
+
"or use an older version of the ReSpec CLI."
|
|
254
253
|
);
|
|
255
|
-
// Document references an older version of ReSpec that does not yet
|
|
256
|
-
// have the "core/exporter" module. Try with the old "ui/save-html"
|
|
257
|
-
// module.
|
|
258
|
-
const { exportDocument } = await new Promise((resolve, reject) => {
|
|
259
|
-
require(["ui/save-html"], resolve, err => {
|
|
260
|
-
reject(new Error(err.message));
|
|
261
|
-
});
|
|
262
|
-
});
|
|
263
|
-
return exportDocument("html", "text/html");
|
|
264
|
-
} else if (!document.respec || !document.respec.toHTML) {
|
|
265
|
-
const { rsDocToDataURL } = await new Promise((resolve, reject) => {
|
|
266
|
-
require(["core/exporter"], resolve, err => {
|
|
267
|
-
reject(new Error(err.message));
|
|
268
|
-
});
|
|
269
|
-
});
|
|
270
|
-
const dataURL = rsDocToDataURL("text/html");
|
|
271
|
-
const encodedString = dataURL.replace(/^data:\w+\/\w+;charset=utf-8,/, "");
|
|
272
|
-
return decodeURIComponent(encodedString);
|
|
273
|
-
} else {
|
|
274
|
-
return await document.respec.toHTML();
|
|
275
254
|
}
|
|
276
255
|
|
|
256
|
+
return await document.respec.toHTML();
|
|
257
|
+
|
|
277
258
|
function timeout(promise, ms) {
|
|
278
259
|
return new Promise((resolve, reject) => {
|
|
279
260
|
promise.then(resolve, reject);
|