@rse/specbook 1.0.2 → 1.0.4

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.
Files changed (44) hide show
  1. package/README.md +106 -19
  2. package/dst/specbook-api.d.ts +32 -12
  3. package/dst/specbook-api.js +114 -33
  4. package/dst/specbook-cli.js +92 -31
  5. package/dst/specbook-cmd-describe.d.ts +7 -1
  6. package/dst/specbook-cmd-describe.js +56 -11
  7. package/dst/specbook-cmd-export.d.ts +3 -1
  8. package/dst/specbook-cmd-export.js +46 -3
  9. package/dst/specbook-cmd-init.d.ts +2 -1
  10. package/dst/specbook-cmd-lint.d.ts +4 -2
  11. package/dst/specbook-cmd-lint.js +12 -8
  12. package/dst/specbook-cmd-preview.d.ts +12 -0
  13. package/dst/specbook-cmd-preview.js +57 -0
  14. package/dst/specbook-config.d.ts +1 -1
  15. package/dst/specbook-config.js +187 -37
  16. package/dst/specbook-diagnostic.d.ts +2 -0
  17. package/dst/specbook-diagnostic.js +4 -2
  18. package/dst/specbook-diagram.d.ts +1 -0
  19. package/dst/specbook-diagram.js +0 -0
  20. package/dst/specbook-export-ast.js +4 -2
  21. package/dst/specbook-export-common.js +5 -3
  22. package/dst/specbook-export-html-search.js +118 -30
  23. package/dst/specbook-export-html.css +1140 -233
  24. package/dst/specbook-export-html.d.ts +1 -1
  25. package/dst/specbook-export-html.js +764 -120
  26. package/dst/specbook-export-md.js +4 -2
  27. package/dst/specbook-export-pdf.d.ts +4 -1
  28. package/dst/specbook-export-pdf.js +46 -16
  29. package/dst/specbook-format-schema.d.ts +33 -1
  30. package/dst/specbook-format-schema.js +34 -2
  31. package/dst/specbook-format.md +193 -25
  32. package/dst/specbook-format.yaml +2291 -299
  33. package/dst/specbook-link.d.ts +2 -1
  34. package/dst/specbook-link.js +43 -3
  35. package/dst/specbook-mcp.js +20 -11
  36. package/dst/specbook-parse-common.d.ts +4 -2
  37. package/dst/specbook-parse-common.js +6 -3
  38. package/dst/specbook-parse-semantic.js +290 -30
  39. package/dst/specbook-parse-syntax.js +3 -1
  40. package/dst/specbook-parse-value.d.ts +1 -0
  41. package/dst/specbook-parse-value.js +17 -3
  42. package/dst/specbook-parse.js +1 -1
  43. package/dst/specbook-verbose.d.ts +2 -0
  44. package/package.json +14 -6
@@ -97,13 +97,19 @@ export const compileValueExpr = (source) => {
97
97
  }
98
98
  return expr;
99
99
  };
100
+ /* whether a value expression admits Wiki-style references at all: a
101
+ reference constraint, or a list with a reference alternative */
102
+ export const admitsReferences = (expr) => expr.kind === "reference"
103
+ || (expr.kind === "list" && expr.alternatives.some((alternative) => alternative.kind === "reference"));
100
104
  /* split a property value at top-level commas, honoring double-quoted
101
- sections and "[[...]]" reference bracketing (empty items are kept,
102
- as only the caller can decide whether to report or skip them) */
105
+ sections, "[[...]]" reference bracketing, and "(...)" parenthesized
106
+ sections like "enum(xxx,yyy)" (empty items are kept, as only the
107
+ caller can decide whether to report or skip them) */
103
108
  export const splitItems = (text) => {
104
109
  const parts = [""];
105
110
  let quoted = false;
106
111
  let bracketed = false;
112
+ let depth = 0;
107
113
  for (let i = 0; i < text.length; i++) {
108
114
  const char = text[i];
109
115
  if (char === "\"" && text[i - 1] !== "\\")
@@ -118,7 +124,15 @@ export const splitItems = (text) => {
118
124
  bracketed = false;
119
125
  i++;
120
126
  }
121
- else if (!quoted && !bracketed && char === ",")
127
+ else if (!quoted && !bracketed && char === "(") {
128
+ depth++;
129
+ parts[parts.length - 1] += char;
130
+ }
131
+ else if (!quoted && !bracketed && char === ")" && depth > 0) {
132
+ depth--;
133
+ parts[parts.length - 1] += char;
134
+ }
135
+ else if (!quoted && !bracketed && depth === 0 && char === ",")
122
136
  parts.push("");
123
137
  else
124
138
  parts[parts.length - 1] += char;
@@ -36,5 +36,5 @@ export const parseSpecification = (sources, config) => {
36
36
  ctx.diagnose(sources[0]?.file ?? "", 1, `internal AST invalid at "${path}": ${issue.message}`);
37
37
  }
38
38
  }
39
- return { specification, diagnostics: ctx.diagnostics };
39
+ return { specification, diagnostics: ctx.diagnostics, assets: Array.from(ctx.assets) };
40
40
  };
@@ -1,2 +1,4 @@
1
+ export type VerboseLevel = "debug" | "notice";
2
+ export type Verbose = (msg: string, level?: VerboseLevel) => void;
1
3
  export declare const literal: (value: string | number) => string;
2
4
  export declare const renderVerbose: (msg: string, style?: (value: string) => string) => string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rse/specbook",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "publishConfig": { "access": "public" },
5
5
  "description": "Markdown-based Specification Format (API, CLI and MCP service)",
6
6
  "license": "Apache-2.0",
@@ -17,12 +17,12 @@
17
17
  },
18
18
  "files": [ "dst" ],
19
19
  "dependencies": {
20
- "marked": "18.0.10",
20
+ "marked": "18.0.11",
21
21
  "marked-smartypants": "1.1.12",
22
22
  "yaml": "2.9.0",
23
23
  "json5": "2.2.3",
24
24
  "pdf-lib": "1.17.1",
25
- "subset-font": "2.5.0",
25
+ "subset-font": "2.6.0",
26
26
  "@rse/mrcs": "0.9.2",
27
27
  "@rse/gradia": "1.1.4",
28
28
  "@toon-format/toon": "4.1.1",
@@ -36,19 +36,26 @@
36
36
  "source-code-error": "1.2.0",
37
37
  "commander": "15.0.0",
38
38
  "chalk": "6.0.0",
39
+ "chokidar": "5.0.0",
40
+ "glob": "13.0.6",
41
+ "es-toolkit": "1.52.0",
42
+ "fastify": "5.12.1",
43
+ "@fastify/websocket": "11.3.0",
39
44
  "@modelcontextprotocol/sdk": "1.30.0",
40
- "zod": "4.4.3"
45
+ "zod": "4.5.1"
41
46
  },
42
47
  "devDependencies": {
48
+ "chokidar-cli": "3.0.0",
43
49
  "eslint": "10.9.0",
44
50
  "@eslint/js": "10.0.1",
45
- "typescript-eslint": "8.67.0",
51
+ "typescript-eslint": "8.68.0",
46
52
  "eslint-plugin-promise": "7.3.0",
47
53
  "neostandard": "0.14.0-next.1",
48
54
  "globals": "17.11.0",
49
- "@types/node": "26.2.0",
55
+ "@types/node": "26.4.0",
50
56
  "@types/subset-font": "2.3.0",
51
57
  "@types/nunjucks": "3.2.6",
58
+ "@types/ws": "8.18.1",
52
59
  "typescript": "6.0.3",
53
60
  "tsx": "4.23.12",
54
61
  "source-sans": "3.52.0",
@@ -57,6 +64,7 @@
57
64
  "postcss": "8.5.26",
58
65
  "postcss-cli": "11.0.1",
59
66
  "postcss-url": "10.1.4",
67
+ "stylus": "0.64.0",
60
68
  "@rse/stx": "1.1.6",
61
69
  "shx": "0.4.0",
62
70
  "nodemon": "3.1.14"