respec 35.8.0 → 36.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.
@@ -1,32 +1,24 @@
1
- // ReSpec Worker v1.0.0
2
- try {
3
- importScripts("https://www.w3.org/Tools/respec/respec-highlight");
4
- } catch (err) {
5
- console.error("Network error loading highlighter", err);
1
+ // ReSpec Worker
2
+ // hljs is either inlined by core/worker.js (preferred) or loaded below via
3
+ // importScripts as a fallback when the inline fetch was not possible.
4
+ if (typeof self.hljs === "undefined" && self.RESPEC_HIGHLIGHT_URL) {
5
+ try {
6
+ importScripts(self.RESPEC_HIGHLIGHT_URL);
7
+ } catch (err) {
8
+ console.error("Network error loading highlighter", err);
9
+ }
6
10
  }
7
11
 
8
- self.addEventListener("message", ({ data: originalData }) => {
9
- const data = Object.assign({}, originalData);
10
- switch (data.action) {
11
- case "highlight-load-lang": {
12
- const { langURL, propName, lang } = data;
13
- importScripts(langURL);
14
- self.hljs.registerLanguage(lang, self[propName]);
15
- break;
16
- }
17
- case "highlight": {
18
- const { code } = data;
19
- const langs = data.languages.length ? data.languages : undefined;
20
- try {
21
- const { value, language } = self.hljs.highlightAuto(code, langs);
22
- Object.assign(data, { value, language });
23
- } catch (err) {
24
- console.error("Could not transform some code?", err);
25
- // Post back the original code
26
- Object.assign(data, { value: code, language: "" });
27
- }
28
- break;
29
- }
12
+ self.addEventListener("message", ({ data }) => {
13
+ if (data.action !== "highlight") return;
14
+ const { code } = data;
15
+ const langs = data.languages?.length ? data.languages : undefined;
16
+ try {
17
+ const { value, language } = self.hljs.highlightAuto(code, langs);
18
+ Object.assign(data, { value, language });
19
+ } catch (err) {
20
+ console.error("Could not transform some code?", err);
21
+ Object.assign(data, { value: code, language: "" });
30
22
  }
31
23
  self.postMessage(data);
32
24
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "respec",
3
- "version": "35.8.0",
3
+ "version": "36.0.0",
4
4
  "license": "W3C",
5
5
  "description": "A technical specification pre-processor.",
6
6
  "engines": {
@@ -24,25 +24,27 @@
24
24
  "Robin Berjon"
25
25
  ],
26
26
  "devDependencies": {
27
- "@rollup/plugin-alias": "^5.1.1",
28
- "@rollup/plugin-commonjs": "^29.0.0",
27
+ "@eslint/js": "^9.8.0",
28
+ "@rollup/plugin-commonjs": "^29.0.2",
29
29
  "@rollup/plugin-node-resolve": "^16.0.3",
30
- "@rollup/plugin-terser": "^0.4.4",
30
+ "@rollup/plugin-terser": "^1.0.0",
31
31
  "@types/pluralize": "0.0.33",
32
32
  "boxen": "^8.0.1",
33
+ "cddlparser": "^0.6.0",
33
34
  "chokidar": "^5.0.0",
34
35
  "clean-css": "^5.3.3",
35
36
  "epipebomb": "^1.0.0",
36
- "eslint": "^8.57.1",
37
+ "eslint": "^9.8.0",
37
38
  "eslint-config-prettier": "^10.1.8",
38
39
  "eslint-plugin-import": "^2.32.0",
39
40
  "eslint-plugin-jasmine": "^4.2.2",
40
41
  "eslint-plugin-prettier": "^5.5.5",
42
+ "globals": "^17.5.0",
41
43
  "highlight.js": "^11.11.1",
42
44
  "hyperhtml": "^2.34.2",
43
45
  "idb": "^8.0.3",
44
- "jasmine": "^6.0.0",
45
- "jasmine-core": "^6.0.1",
46
+ "jasmine": "^6.2.0",
47
+ "jasmine-core": "^6.2.0",
46
48
  "karma": "^6.4.4",
47
49
  "karma-chrome-launcher": "^3.2.0",
48
50
  "karma-firefox-launcher": "^2.1.3",
@@ -50,17 +52,19 @@
50
52
  "karma-jasmine-html-reporter": "^2.2.0",
51
53
  "karma-mocha-reporter": "^2.2.5",
52
54
  "karma-safari-launcher": "^1.0.0",
55
+ "lint-staged": "^16.4.0",
53
56
  "loading-indicator": "^2.0.0",
54
57
  "pluralize": "^8.0.0",
55
- "prettier": "^3.8.1",
58
+ "prettier": "^3.8.2",
56
59
  "prompt": "^1.3.0",
57
- "rollup": "^4.57.1",
60
+ "rollup": "^4.60.1",
58
61
  "rollup-plugin-minify-html-literals": "^1.2.6",
59
- "serve": "^14.2.5",
60
- "serve-handler": "^6.1.6",
62
+ "serve": "^14.2.6",
63
+ "serve-handler": "^6.1.7",
64
+ "simple-git-hooks": "^2.13.1",
61
65
  "sniffy-mimetype": "^1.1.1",
62
- "typescript": "^5.9.3",
63
- "vnu-jar": "^26.2.19",
66
+ "typescript": "^6.0.3",
67
+ "vnu-jar": "^26.4.11",
64
68
  "webidl2": "^24.5.0"
65
69
  },
66
70
  "scripts": {
@@ -74,7 +78,7 @@
74
78
  "build:dini": "pnpm builder dini",
75
79
  "builddeps": "rollup -c js/deps/rollup.config.js --bundleConfigAsCjs && rollup -c worker/rollup.config.js --bundleConfigAsCjs",
76
80
  "lint": "tsc -p src/jsconfig.json && eslint .",
77
- "prepare": "pnpm builddeps",
81
+ "prepare": "pnpm builddeps && simple-git-hooks",
78
82
  "builder": "node ./tools/builder.cjs",
79
83
  "release": "node ./tools/release.cjs",
80
84
  "server": "serve",
@@ -88,8 +92,8 @@
88
92
  "dependencies": {
89
93
  "colors": "1.4.0",
90
94
  "finalhandler": "^2.1.1",
91
- "marked": "^12.0.2",
92
- "puppeteer": "^24.37.5",
95
+ "marked": "^18.0.0",
96
+ "puppeteer": "^24.40.0",
93
97
  "sade": "^1.8.1",
94
98
  "serve-static": "^2.2.1"
95
99
  },
@@ -98,14 +102,43 @@
98
102
  "tools/respec2html.js",
99
103
  "tools/respecDocWriter.js"
100
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
+ },
101
112
  "prettier": {
102
113
  "trailingComma": "es5",
103
114
  "arrowParens": "avoid"
104
115
  },
105
116
  "pnpm": {
106
117
  "onlyBuiltDependencies": [
107
- "puppeteer"
108
- ]
118
+ "puppeteer",
119
+ "simple-git-hooks"
120
+ ],
121
+ "ignoredBuiltDependencies": [
122
+ "vnu-jar"
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
+ }
109
142
  },
110
143
  "funding": {
111
144
  "type": "opencollective",
@@ -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,28 +9,31 @@ import sade from "sade";
10
9
  import serveStatic from "serve-static";
11
10
  import { toHTML } from "./respecDocWriter.js";
12
11
 
13
- const __dirname = path.dirname(fileURLToPath(import.meta.url));
12
+ const __dirname = import.meta.dirname;
14
13
 
15
14
  class Renderer extends marked.Renderer {
16
- strong(text) {
17
- return colors.bold(text);
15
+ strong(token) {
16
+ return colors.bold(this.parser.parseInline(token.tokens));
18
17
  }
19
- em(text) {
20
- return colors.italic(text);
18
+ em(token) {
19
+ return colors.italic(this.parser.parseInline(token.tokens));
21
20
  }
22
- codespan(text) {
23
- return colors.underline(unescape(text));
21
+ codespan(token) {
22
+ return colors.underline(unescape(token.text));
24
23
  }
25
- paragraph(text) {
26
- return unescape(text);
24
+ paragraph(token) {
25
+ return unescape(this.parser.parseInline(token.tokens));
27
26
  }
28
- link(href, _title, text) {
29
- return `[${text}](${colors.blue.dim.underline(href)})`;
27
+ link(token) {
28
+ const text = this.parser.parseInline(token.tokens);
29
+ return `[${text}](${colors.blue.dim.underline(token.href)})`;
30
30
  }
31
- list(body, _orderered) {
31
+ list(token) {
32
+ const body = token.items.map(item => this.listitem(item)).join("");
32
33
  return `\n${body}`;
33
34
  }
34
- listitem(text) {
35
+ listitem(token) {
36
+ const text = this.parser.parseInline(token.tokens);
35
37
  return `* ${text}\n`;
36
38
  }
37
39
  }
@@ -85,7 +87,7 @@ class Logger {
85
87
 
86
88
  _formatMarkdown(str) {
87
89
  if (typeof str !== "string") return str;
88
- return marked(str, { smartypants: true, renderer: new Renderer() });
90
+ return marked(str, { renderer: new Renderer() });
89
91
  }
90
92
 
91
93
  /** @param {import("./respecDocWriter").ReSpecError} rsError */
@@ -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(__dirname, "..", "builds", `${profile}.js`);
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({
@@ -276,7 +278,7 @@ async function evaluateHTML(version, timer) {
276
278
  return new Promise((resolve, reject) => {
277
279
  promise.then(resolve, reject);
278
280
  const msg = `Timeout: document.respec.ready didn't resolve in ${ms}ms.`;
279
- setTimeout(() => reject(msg), ms);
281
+ setTimeout(() => reject(new Error(msg)), ms);
280
282
  });
281
283
  }
282
284
  }