@khanglvm/relay 0.20.1 → 0.20.2
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 +1 -1
- package/src/spec/ready.js +31 -9
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@khanglvm/relay",
|
|
3
|
-
"version": "0.20.
|
|
3
|
+
"version": "0.20.2",
|
|
4
4
|
"description": "Question boards with rich blocks (markdown, charts, mermaid, tables, code, diffs, video, sandboxed HTML), clickable local file-links, and element-level annotations for AI coding agents (Claude Code, Codex, \u2026): ask users structured questions, present interactive visuals, collect inline comments, read answers as JSON \u2014 in a local browser board OR rendered INLINE inside the Claude & Codex apps as an MCP App (SEP-1865).",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ai-agents",
|
package/src/spec/ready.js
CHANGED
|
@@ -17,6 +17,36 @@ function compactError(err) {
|
|
|
17
17
|
return msg.length > 500 ? msg.slice(0, 497) + '...' : msg;
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
+
// A sandbox in which the browser build of mermaid can parse, but not render.
|
|
21
|
+
function parserContext() {
|
|
22
|
+
const quietConsole = { log() {}, info() {}, warn() {}, error() {}, debug() {} };
|
|
23
|
+
const context = {
|
|
24
|
+
console: quietConsole,
|
|
25
|
+
setTimeout,
|
|
26
|
+
clearTimeout,
|
|
27
|
+
// Mermaid 11's langium parsers (pie, gitGraph, packet, architecture, radar)
|
|
28
|
+
// and its link handling call these browser globals, which a vm context lacks.
|
|
29
|
+
TextEncoder,
|
|
30
|
+
TextDecoder,
|
|
31
|
+
structuredClone,
|
|
32
|
+
URL,
|
|
33
|
+
};
|
|
34
|
+
context.globalThis = context;
|
|
35
|
+
// DOMPurify 3 (bundled in mermaid) builds a stub without addHook or sanitize
|
|
36
|
+
// when window has no document, and mermaid calls both while it parses labels.
|
|
37
|
+
// This document is just enough for DOMPurify to build its full API: with no
|
|
38
|
+
// document.implementation it reports isSupported = false, and then sanitize
|
|
39
|
+
// returns its input unchanged. That is safe only because this instance parses
|
|
40
|
+
// and never renders. The document stays on window, not as a global, so
|
|
41
|
+
// mermaid's own code never takes a DOM path.
|
|
42
|
+
context.window = {
|
|
43
|
+
addEventListener() {},
|
|
44
|
+
document: { nodeType: 9, createElement: () => ({}) },
|
|
45
|
+
Element: function Element() {},
|
|
46
|
+
};
|
|
47
|
+
return vm.createContext(context);
|
|
48
|
+
}
|
|
49
|
+
|
|
20
50
|
async function mermaidValidator() {
|
|
21
51
|
if (mermaidValidatorPromise) return mermaidValidatorPromise;
|
|
22
52
|
mermaidValidatorPromise = (async () => {
|
|
@@ -27,15 +57,7 @@ async function mermaidValidator() {
|
|
|
27
57
|
} catch {
|
|
28
58
|
throw new CliError('mermaid blocks need the vendored parser (vendor/mermaid.min.js is missing).');
|
|
29
59
|
}
|
|
30
|
-
const
|
|
31
|
-
const context = {
|
|
32
|
-
console: quietConsole,
|
|
33
|
-
setTimeout,
|
|
34
|
-
clearTimeout,
|
|
35
|
-
};
|
|
36
|
-
context.globalThis = context;
|
|
37
|
-
context.window = { addEventListener() {} };
|
|
38
|
-
vm.createContext(context);
|
|
60
|
+
const context = parserContext();
|
|
39
61
|
try {
|
|
40
62
|
vm.runInContext(source, context, { filename: sourcePath });
|
|
41
63
|
} catch (err) {
|