respec 35.9.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/README.md +23 -34
- package/builds/respec-aom.js +137 -111
- package/builds/respec-aom.js.map +1 -1
- package/builds/respec-dini.js +138 -112
- package/builds/respec-dini.js.map +1 -1
- package/builds/respec-geonovum.js +113 -87
- package/builds/respec-geonovum.js.map +1 -1
- package/builds/respec-w3c.js +605 -374
- package/builds/respec-w3c.js.map +1 -1
- package/builds/respec-worker.js +54 -8
- package/package.json +44 -16
- package/tools/respec2html.js +1 -2
- package/tools/respecDocWriter.js +16 -33
package/builds/respec-worker.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// ReSpec Worker
|
|
1
|
+
// ReSpec Worker
|
|
2
2
|
// hljs is either inlined by core/worker.js (preferred) or loaded below via
|
|
3
3
|
// importScripts as a fallback when the inline fetch was not possible.
|
|
4
4
|
if (typeof self.hljs === "undefined" && self.RESPEC_HIGHLIGHT_URL) {
|
|
@@ -9,24 +9,70 @@ if (typeof self.hljs === "undefined" && self.RESPEC_HIGHLIGHT_URL) {
|
|
|
9
9
|
}
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
self.addEventListener("message", ({ data
|
|
13
|
-
const data = Object.assign({}, originalData);
|
|
12
|
+
self.addEventListener("message", ({ data }) => {
|
|
14
13
|
switch (data.action) {
|
|
15
14
|
case "highlight-load-lang": {
|
|
16
|
-
const { langURL, propName, lang } = data;
|
|
17
|
-
|
|
18
|
-
|
|
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;
|
|
19
66
|
break;
|
|
20
67
|
}
|
|
21
68
|
case "highlight": {
|
|
22
69
|
const { code } = data;
|
|
23
|
-
const langs = data.languages
|
|
70
|
+
const langs = data.languages?.length ? data.languages : undefined;
|
|
24
71
|
try {
|
|
25
72
|
const { value, language } = self.hljs.highlightAuto(code, langs);
|
|
26
73
|
Object.assign(data, { value, language });
|
|
27
74
|
} catch (err) {
|
|
28
75
|
console.error("Could not transform some code?", err);
|
|
29
|
-
// Post back the original code
|
|
30
76
|
Object.assign(data, { value: code, language: "" });
|
|
31
77
|
}
|
|
32
78
|
break;
|
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": {
|
|
@@ -24,13 +24,13 @@
|
|
|
24
24
|
"Robin Berjon"
|
|
25
25
|
],
|
|
26
26
|
"devDependencies": {
|
|
27
|
-
"@
|
|
27
|
+
"@eslint/js": "^9.8.0",
|
|
28
28
|
"@rollup/plugin-commonjs": "^29.0.2",
|
|
29
29
|
"@rollup/plugin-node-resolve": "^16.0.3",
|
|
30
30
|
"@rollup/plugin-terser": "^1.0.0",
|
|
31
31
|
"@types/pluralize": "0.0.33",
|
|
32
|
-
"@eslint/js": "^9.8.0",
|
|
33
32
|
"boxen": "^8.0.1",
|
|
33
|
+
"cddlparser": "^0.6.0",
|
|
34
34
|
"chokidar": "^5.0.0",
|
|
35
35
|
"clean-css": "^5.3.3",
|
|
36
36
|
"epipebomb": "^1.0.0",
|
|
@@ -39,12 +39,12 @@
|
|
|
39
39
|
"eslint-plugin-import": "^2.32.0",
|
|
40
40
|
"eslint-plugin-jasmine": "^4.2.2",
|
|
41
41
|
"eslint-plugin-prettier": "^5.5.5",
|
|
42
|
-
"globals": "^
|
|
42
|
+
"globals": "^17.5.0",
|
|
43
43
|
"highlight.js": "^11.11.1",
|
|
44
44
|
"hyperhtml": "^2.34.2",
|
|
45
45
|
"idb": "^8.0.3",
|
|
46
|
-
"jasmine": "^6.
|
|
47
|
-
"jasmine-core": "^6.
|
|
46
|
+
"jasmine": "^6.2.0",
|
|
47
|
+
"jasmine-core": "^6.2.0",
|
|
48
48
|
"karma": "^6.4.4",
|
|
49
49
|
"karma-chrome-launcher": "^3.2.0",
|
|
50
50
|
"karma-firefox-launcher": "^2.1.3",
|
|
@@ -52,17 +52,19 @@
|
|
|
52
52
|
"karma-jasmine-html-reporter": "^2.2.0",
|
|
53
53
|
"karma-mocha-reporter": "^2.2.5",
|
|
54
54
|
"karma-safari-launcher": "^1.0.0",
|
|
55
|
+
"lint-staged": "^16.4.0",
|
|
55
56
|
"loading-indicator": "^2.0.0",
|
|
56
57
|
"pluralize": "^8.0.0",
|
|
57
|
-
"prettier": "^3.8.
|
|
58
|
+
"prettier": "^3.8.3",
|
|
58
59
|
"prompt": "^1.3.0",
|
|
59
|
-
"rollup": "^4.
|
|
60
|
+
"rollup": "^4.60.2",
|
|
60
61
|
"rollup-plugin-minify-html-literals": "^1.2.6",
|
|
61
|
-
"serve": "^14.2.
|
|
62
|
+
"serve": "^14.2.6",
|
|
62
63
|
"serve-handler": "^6.1.7",
|
|
64
|
+
"simple-git-hooks": "^2.13.1",
|
|
63
65
|
"sniffy-mimetype": "^1.1.1",
|
|
64
|
-
"typescript": "^
|
|
65
|
-
"vnu-jar": "^26.
|
|
66
|
+
"typescript": "^6.0.3",
|
|
67
|
+
"vnu-jar": "^26.4.16",
|
|
66
68
|
"webidl2": "^24.5.0"
|
|
67
69
|
},
|
|
68
70
|
"scripts": {
|
|
@@ -76,7 +78,7 @@
|
|
|
76
78
|
"build:dini": "pnpm builder dini",
|
|
77
79
|
"builddeps": "rollup -c js/deps/rollup.config.js --bundleConfigAsCjs && rollup -c worker/rollup.config.js --bundleConfigAsCjs",
|
|
78
80
|
"lint": "tsc -p src/jsconfig.json && eslint .",
|
|
79
|
-
"prepare": "pnpm builddeps",
|
|
81
|
+
"prepare": "pnpm builddeps && simple-git-hooks",
|
|
80
82
|
"builder": "node ./tools/builder.cjs",
|
|
81
83
|
"release": "node ./tools/release.cjs",
|
|
82
84
|
"server": "serve",
|
|
@@ -90,8 +92,8 @@
|
|
|
90
92
|
"dependencies": {
|
|
91
93
|
"colors": "1.4.0",
|
|
92
94
|
"finalhandler": "^2.1.1",
|
|
93
|
-
"marked": "^
|
|
94
|
-
"puppeteer": "^24.
|
|
95
|
+
"marked": "^18.0.2",
|
|
96
|
+
"puppeteer": "^24.42.0",
|
|
95
97
|
"sade": "^1.8.1",
|
|
96
98
|
"serve-static": "^2.2.1"
|
|
97
99
|
},
|
|
@@ -100,17 +102,43 @@
|
|
|
100
102
|
"tools/respec2html.js",
|
|
101
103
|
"tools/respecDocWriter.js"
|
|
102
104
|
],
|
|
105
|
+
"simple-git-hooks": {
|
|
106
|
+
"pre-commit": "npx lint-staged"
|
|
107
|
+
},
|
|
108
|
+
"lint-staged": {
|
|
109
|
+
"*.js": "eslint --fix",
|
|
110
|
+
"*.{js,json,md,html,css}": "prettier --write"
|
|
111
|
+
},
|
|
103
112
|
"prettier": {
|
|
104
113
|
"trailingComma": "es5",
|
|
105
114
|
"arrowParens": "avoid"
|
|
106
115
|
},
|
|
107
116
|
"pnpm": {
|
|
108
117
|
"onlyBuiltDependencies": [
|
|
109
|
-
"puppeteer"
|
|
118
|
+
"puppeteer",
|
|
119
|
+
"simple-git-hooks"
|
|
110
120
|
],
|
|
111
121
|
"ignoredBuiltDependencies": [
|
|
112
122
|
"vnu-jar"
|
|
113
|
-
]
|
|
123
|
+
],
|
|
124
|
+
"overrides": {
|
|
125
|
+
"flatted": ">=3.4.2",
|
|
126
|
+
"jasmine>glob": ">=10.5.0",
|
|
127
|
+
"lodash": ">=4.18.0",
|
|
128
|
+
"qs": ">=6.14.2",
|
|
129
|
+
"socket.io-parser": ">=4.2.6",
|
|
130
|
+
"tmp": ">=0.2.4",
|
|
131
|
+
"ws": ">=8.17.1",
|
|
132
|
+
"eslint-plugin-import>minimatch": "^3.1.4",
|
|
133
|
+
"eslint>minimatch": "^3.1.4",
|
|
134
|
+
"eslint>brace-expansion": "^1.1.13",
|
|
135
|
+
"minimatch>brace-expansion": "^1.1.13",
|
|
136
|
+
"karma>minimatch": "^3.1.4",
|
|
137
|
+
"jasmine>minimatch": "^9.0.7",
|
|
138
|
+
"@rollup/pluginutils>picomatch": "^2.3.2",
|
|
139
|
+
"@rollup/plugin-commonjs>picomatch": "^4.0.4",
|
|
140
|
+
"anymatch>picomatch": "^2.3.2"
|
|
141
|
+
}
|
|
114
142
|
},
|
|
115
143
|
"funding": {
|
|
116
144
|
"type": "opencollective",
|
package/tools/respec2html.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { readFile, writeFile } from "fs/promises";
|
|
3
3
|
import colors from "colors";
|
|
4
|
-
import { fileURLToPath } from "url";
|
|
5
4
|
import finalhandler from "finalhandler";
|
|
6
5
|
import http from "http";
|
|
7
6
|
import { marked } from "marked";
|
|
@@ -10,7 +9,7 @@ import sade from "sade";
|
|
|
10
9
|
import serveStatic from "serve-static";
|
|
11
10
|
import { toHTML } from "./respecDocWriter.js";
|
|
12
11
|
|
|
13
|
-
const __dirname =
|
|
12
|
+
const __dirname = import.meta.dirname;
|
|
14
13
|
|
|
15
14
|
class Renderer extends marked.Renderer {
|
|
16
15
|
strong(token) {
|
package/tools/respecDocWriter.js
CHANGED
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Exports toHTML() method, allowing programmatic control of the spec generator.
|
|
3
3
|
*/
|
|
4
|
-
import { fileURLToPath } from "url";
|
|
5
4
|
import path from "path";
|
|
6
5
|
import puppeteer from "puppeteer";
|
|
7
6
|
import { readFile } from "fs/promises";
|
|
8
7
|
|
|
9
|
-
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
10
|
-
|
|
11
8
|
const noop = () => {};
|
|
12
9
|
|
|
13
10
|
/**
|
|
@@ -142,7 +139,12 @@ async function useLocalReSpec(page, log) {
|
|
|
142
139
|
const url = new URL(request.url());
|
|
143
140
|
const respecProfileRegex = /\/(respec-[\w-]+)(?:\.js)?$/;
|
|
144
141
|
const profile = url.pathname.match(respecProfileRegex)[1];
|
|
145
|
-
const localPath = path.join(
|
|
142
|
+
const localPath = path.join(
|
|
143
|
+
import.meta.dirname,
|
|
144
|
+
"..",
|
|
145
|
+
"builds",
|
|
146
|
+
`${profile}.js`
|
|
147
|
+
);
|
|
146
148
|
const relPath = path.relative(process.cwd(), localPath);
|
|
147
149
|
log(`Intercepted ${url} to respond with ${relPath}`);
|
|
148
150
|
await request.respond({
|
|
@@ -223,7 +225,7 @@ async function checkIfReSpec(page) {
|
|
|
223
225
|
*/
|
|
224
226
|
async function generateHTML(page, timer, version, url) {
|
|
225
227
|
try {
|
|
226
|
-
return await page.evaluate(evaluateHTML,
|
|
228
|
+
return await page.evaluate(evaluateHTML, timer);
|
|
227
229
|
} catch (err) {
|
|
228
230
|
const msg = `\nš Sorry, there was an error generating the HTML. Please report this issue!\n${`${
|
|
229
231
|
`Specification: ${url}\n` +
|
|
@@ -235,48 +237,29 @@ async function generateHTML(page, timer, version, url) {
|
|
|
235
237
|
}
|
|
236
238
|
|
|
237
239
|
/**
|
|
238
|
-
* @param {ReSpecVersion} version
|
|
239
240
|
* @param {ReturnType<typeof createTimer>} timer
|
|
240
241
|
*/
|
|
241
|
-
async function evaluateHTML(
|
|
242
|
+
async function evaluateHTML(timer) {
|
|
242
243
|
await timeout(
|
|
243
244
|
document.respec ? document.respec.ready : document.respecIsReady,
|
|
244
245
|
timer.remaining
|
|
245
246
|
);
|
|
246
247
|
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
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."
|
|
252
253
|
);
|
|
253
|
-
// Document references an older version of ReSpec that does not yet
|
|
254
|
-
// have the "core/exporter" module. Try with the old "ui/save-html"
|
|
255
|
-
// module.
|
|
256
|
-
const { exportDocument } = await new Promise((resolve, reject) => {
|
|
257
|
-
require(["ui/save-html"], resolve, err => {
|
|
258
|
-
reject(new Error(err.message));
|
|
259
|
-
});
|
|
260
|
-
});
|
|
261
|
-
return exportDocument("html", "text/html");
|
|
262
|
-
} else if (!document.respec || !document.respec.toHTML) {
|
|
263
|
-
const { rsDocToDataURL } = await new Promise((resolve, reject) => {
|
|
264
|
-
require(["core/exporter"], resolve, err => {
|
|
265
|
-
reject(new Error(err.message));
|
|
266
|
-
});
|
|
267
|
-
});
|
|
268
|
-
const dataURL = rsDocToDataURL("text/html");
|
|
269
|
-
const encodedString = dataURL.replace(/^data:\w+\/\w+;charset=utf-8,/, "");
|
|
270
|
-
return decodeURIComponent(encodedString);
|
|
271
|
-
} else {
|
|
272
|
-
return await document.respec.toHTML();
|
|
273
254
|
}
|
|
274
255
|
|
|
256
|
+
return await document.respec.toHTML();
|
|
257
|
+
|
|
275
258
|
function timeout(promise, ms) {
|
|
276
259
|
return new Promise((resolve, reject) => {
|
|
277
260
|
promise.then(resolve, reject);
|
|
278
261
|
const msg = `Timeout: document.respec.ready didn't resolve in ${ms}ms.`;
|
|
279
|
-
setTimeout(() => reject(msg), ms);
|
|
262
|
+
setTimeout(() => reject(new Error(msg)), ms);
|
|
280
263
|
});
|
|
281
264
|
}
|
|
282
265
|
}
|