respec 37.3.1 → 37.3.3

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": "respec",
3
- "version": "37.3.1",
3
+ "version": "37.3.3",
4
4
  "license": "W3C",
5
5
  "description": "A technical specification pre-processor.",
6
6
  "engines": {
@@ -38,17 +38,16 @@
38
38
  "eslint-plugin-import-x": "^4.17.1",
39
39
  "eslint-plugin-jasmine": "^4.2.2",
40
40
  "eslint-plugin-prettier": "^5.5.6",
41
- "globals": "^17.9.0",
42
- "highlight.js": "^11.11.2",
41
+ "globals": "^17.11.0",
42
+ "highlight.js": "^11.12.0",
43
43
  "hyperhtml": "^2.34.2",
44
44
  "idb": "^8.0.3",
45
- "jasmine": "^6.3.0",
46
- "jasmine-core": "^6.3.0",
45
+ "jasmine": "^7.0.0",
46
+ "jasmine-core": "^7.0.1",
47
47
  "karma": "^6.4.4",
48
48
  "karma-chrome-launcher": "^3.2.0",
49
49
  "karma-firefox-launcher": "^2.1.3",
50
50
  "karma-jasmine": "^5.1.0",
51
- "karma-jasmine-html-reporter": "^2.2.0",
52
51
  "karma-mocha-reporter": "^2.2.5",
53
52
  "karma-safari-launcher": "^1.0.0",
54
53
  "lint-staged": "^17.3.0",
@@ -63,7 +62,7 @@
63
62
  "simple-git-hooks": "^2.13.1",
64
63
  "sniffy-mimetype": "^1.1.1",
65
64
  "typescript": "^7.0.2",
66
- "vnu-jar": "^26.8.6",
65
+ "vnu-jar": "^26.8.15",
67
66
  "webidl2": "^24.5.0"
68
67
  },
69
68
  "scripts": {
@@ -89,10 +88,9 @@
89
88
  "test:integration": "karma start ./tests/spec/karma.conf.cjs --single-run"
90
89
  },
91
90
  "dependencies": {
92
- "colors": "1.4.0",
93
91
  "finalhandler": "^2.1.1",
94
92
  "marked": "^18.0.9",
95
- "puppeteer": "^25.5.0",
93
+ "puppeteer": "^25.8.0",
96
94
  "sade": "^1.8.1",
97
95
  "serve-static": "^2.2.1"
98
96
  },
@@ -121,13 +119,13 @@
121
119
  "vnu-jar"
122
120
  ],
123
121
  "overrides": {
124
- "fast-uri": "^3.1.4",
122
+ "fast-uri": "^3.1.5",
125
123
  "flatted": ">=3.4.2",
126
124
  "follow-redirects": ">=1.16.0",
127
125
  "jasmine>glob": ">=10.5.0",
128
126
  "lodash": ">=4.18.0",
129
127
  "qs": ">=6.14.2",
130
- "socket.io-parser": ">=4.2.6",
128
+ "socket.io-parser": ">=4.2.7",
131
129
  "tmp": ">=0.2.4",
132
130
  "ws": ">=8.17.1",
133
131
  "@rollup/pluginutils>picomatch": "^2.3.2",
@@ -1,32 +1,32 @@
1
1
  #!/usr/bin/env node
2
2
  import { readFile, writeFile } from "fs/promises";
3
- import colors from "colors";
4
3
  import finalhandler from "finalhandler";
5
4
  import http from "http";
6
5
  import { marked } from "marked";
7
6
  import path from "path";
8
7
  import sade from "sade";
9
8
  import serveStatic from "serve-static";
9
+ import { styleText } from "node:util";
10
10
  import { toHTML } from "./respecDocWriter.js";
11
11
 
12
12
  const __dirname = import.meta.dirname;
13
13
 
14
14
  class Renderer extends marked.Renderer {
15
15
  strong(token) {
16
- return colors.bold(this.parser.parseInline(token.tokens));
16
+ return styleText("bold", this.parser.parseInline(token.tokens));
17
17
  }
18
18
  em(token) {
19
- return colors.italic(this.parser.parseInline(token.tokens));
19
+ return styleText("italic", this.parser.parseInline(token.tokens));
20
20
  }
21
21
  codespan(token) {
22
- return colors.underline(unescape(token.text));
22
+ return styleText("underline", unescape(token.text));
23
23
  }
24
24
  paragraph(token) {
25
25
  return unescape(this.parser.parseInline(token.tokens));
26
26
  }
27
27
  link(token) {
28
28
  const text = this.parser.parseInline(token.tokens);
29
- return `[${text}](${colors.blue.dim.underline(token.href)})`;
29
+ return `[${text}](${styleText(["blue", "dim", "underline"], token.href)})`;
30
30
  }
31
31
  list(token) {
32
32
  const body = token.items.map(item => this.listitem(item)).join("");
@@ -50,8 +50,8 @@ class Logger {
50
50
  */
51
51
  info(message, timeRemaining) {
52
52
  if (!this.verbose) return;
53
- const header = colors.dim.bgWhite.black.bold("[INFO]");
54
- const time = colors.dim(`[Timeout: ${timeRemaining}ms]`);
53
+ const header = styleText(["dim", "bgWhite", "black", "bold"], "[INFO]");
54
+ const time = styleText("dim", `[Timeout: ${timeRemaining}ms]`);
55
55
  console.error(header, time, message);
56
56
  }
57
57
 
@@ -60,8 +60,8 @@ class Logger {
60
60
  * @param {RsError} rsError
61
61
  */
62
62
  error(rsError) {
63
- const header = colors.bgRed.white.bold("[ERROR]");
64
- const message = colors.red(this._formatMarkdown(rsError.message));
63
+ const header = styleText(["bgRed", "white", "bold"], "[ERROR]");
64
+ const message = styleText("red", this._formatMarkdown(rsError.message));
65
65
  console.error(header, message);
66
66
  if (rsError.plugin) {
67
67
  this._printDetails(rsError);
@@ -70,8 +70,8 @@ class Logger {
70
70
 
71
71
  /** @param {RsError} rsError */
72
72
  warn(rsError) {
73
- const header = colors.bgYellow.black.bold("[WARNING]");
74
- const message = colors.yellow(this._formatMarkdown(rsError.message));
73
+ const header = styleText(["bgYellow", "black", "bold"], "[WARNING]");
74
+ const message = styleText("yellow", this._formatMarkdown(rsError.message));
75
75
  console.error(header, message);
76
76
  if (rsError.plugin) {
77
77
  this._printDetails(rsError);
@@ -80,14 +80,14 @@ class Logger {
80
80
 
81
81
  /** @param {Error | string} error */
82
82
  fatal(error) {
83
- const header = colors.bgRed.white.bold("[FATAL]");
84
- const message = colors.red(error.stack || error);
83
+ const header = styleText(["bgRed", "white", "bold"], "[FATAL]");
84
+ const message = styleText("red", error.stack || error);
85
85
  console.error(header, message);
86
86
  // Errors thrown by respecDocWriter keep the original in `cause`, so the
87
87
  // underlying stack is only reachable by walking the chain.
88
88
  let cause = error instanceof Error ? error.cause : undefined;
89
89
  for (let depth = 0; cause instanceof Error && depth < 5; depth++) {
90
- console.error(colors.red(`Caused by: ${cause.stack}`));
90
+ console.error(styleText("red", `Caused by: ${cause.stack}`));
91
91
  cause = cause.cause;
92
92
  }
93
93
  }
@@ -105,7 +105,11 @@ class Logger {
105
105
  const longestTitle = shouldPrintStacktrace ? "Stacktrace" : "Plugin";
106
106
  const padWidth = longestTitle.length + 1;
107
107
  const paddedTitle = `${title}:`.padStart(padWidth);
108
- console.error(" ", colors.bold(paddedTitle), this._formatMarkdown(value));
108
+ console.error(
109
+ " ",
110
+ styleText("bold", paddedTitle),
111
+ this._formatMarkdown(value)
112
+ );
109
113
  };
110
114
  print("Count", rsError.elements && String(rsError.elements.length));
111
115
  print("Plugin", rsError.plugin);
@@ -113,7 +117,7 @@ class Logger {
113
117
  if (shouldPrintStacktrace) {
114
118
  let stacktrace = `${rsError.stack}`;
115
119
  if (rsError.cause) {
116
- stacktrace += `\n ${colors.bold("Caused by:")} ${rsError.cause.stack.split("\n").join("\n ")}`;
120
+ stacktrace += `\n ${styleText("bold", "Caused by:")} ${rsError.cause.stack.split("\n").join("\n ")}`;
117
121
  }
118
122
  print("Stacktrace", stacktrace);
119
123
  }
@@ -173,18 +177,20 @@ class StaticServer {
173
177
 
174
178
  const cli = sade("respec [source] [destination]", true)
175
179
  .describe("Converts a ReSpec source file to HTML and writes to destination.")
176
- .example(`input.html output.html ${colors.dim("# Output to a file.")}`)
180
+ .example(`input.html output.html ${styleText("dim", "# Output to a file.")}`)
177
181
  .example(
178
- `http://example.com/spec.html stdout ${colors.dim("# Output to stdout.")}`
182
+ `http://example.com/spec.html stdout ${styleText("dim", "# Output to stdout.")}`
179
183
  )
180
184
  .example(
181
- `http://example.com/spec.html output.html -e -w ${colors.dim(
185
+ `http://example.com/spec.html output.html -e -w ${styleText(
186
+ "dim",
182
187
  "# Halt on errors or warning."
183
188
  )}`
184
189
  )
185
190
  .example("--src http://example.com/spec.html --out spec.html")
186
191
  .example(
187
- `--localhost index.html out.html ${colors.dim(
192
+ `--localhost index.html out.html ${styleText(
193
+ "dim",
188
194
  "# Generate file using a local web server."
189
195
  )}`
190
196
  );
@@ -7,6 +7,13 @@ import { readFile } from "fs/promises";
7
7
 
8
8
  const noop = () => {};
9
9
 
10
+ /**
11
+ * Time allowed for the browser process to start, separate from processing.
12
+ * Cold CI runners regularly need longer than puppeteer's 30s default,
13
+ * which surfaced as "Timed out ... waiting for the WS endpoint URL".
14
+ */
15
+ const LAUNCH_TIMEOUT = 120000;
16
+
10
17
  /**
11
18
  * Fetches a ReSpec "src" URL, and writes the processed static HTML to an "out" path.
12
19
  * @param {string} src A URL or filepath that is the ReSpec source.
@@ -41,7 +48,11 @@ export async function toHTML(src, options = {}) {
41
48
  }
42
49
 
43
50
  const log = msg => options.onProgress(msg, timer.remaining);
44
- const timer = createTimer(timeout);
51
+ /**
52
+ * Starts once the browser is up, so a slow launch does not eat the caller's
53
+ * processing budget. `timeout` documents time before *processing* times out.
54
+ */
55
+ let timer = createTimer(timeout);
45
56
 
46
57
  /** @type {RsError[]} */
47
58
  const errors = [];
@@ -65,7 +76,10 @@ export async function toHTML(src, options = {}) {
65
76
  args,
66
77
  devtools,
67
78
  headless: true,
79
+ timeout: LAUNCH_TIMEOUT,
68
80
  });
81
+ // Charge only document processing against the caller's timeout.
82
+ timer = createTimer(timeout);
69
83
 
70
84
  try {
71
85
  const page = await browser.newPage();