@knapsack/source-conflicts-adapter 4.89.10--canary.7202.53e0d58.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/.eslintrc.cjs +9 -0
- package/README.md +269 -0
- package/dist/analyzer.d.ts +29 -0
- package/dist/analyzer.d.ts.map +1 -0
- package/dist/analyzer.js +61 -0
- package/dist/analyzer.js.map +1 -0
- package/dist/analyzer.vitest.d.ts +2 -0
- package/dist/analyzer.vitest.d.ts.map +1 -0
- package/dist/analyzer.vitest.js +60 -0
- package/dist/analyzer.vitest.js.map +1 -0
- package/dist/compare/preview.d.ts +28 -0
- package/dist/compare/preview.d.ts.map +1 -0
- package/dist/compare/preview.js +27 -0
- package/dist/compare/preview.js.map +1 -0
- package/dist/compare/preview.vitest.d.ts +2 -0
- package/dist/compare/preview.vitest.d.ts.map +1 -0
- package/dist/compare/preview.vitest.js +67 -0
- package/dist/compare/preview.vitest.js.map +1 -0
- package/dist/detect.d.ts +13 -0
- package/dist/detect.d.ts.map +1 -0
- package/dist/detect.js +104 -0
- package/dist/detect.js.map +1 -0
- package/dist/detect.vitest.d.ts +2 -0
- package/dist/detect.vitest.d.ts.map +1 -0
- package/dist/detect.vitest.js +116 -0
- package/dist/detect.vitest.js.map +1 -0
- package/dist/index.d.ts +26 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +26 -0
- package/dist/index.js.map +1 -0
- package/dist/mdx/mdxConflicts.d.ts +160 -0
- package/dist/mdx/mdxConflicts.d.ts.map +1 -0
- package/dist/mdx/mdxConflicts.js +393 -0
- package/dist/mdx/mdxConflicts.js.map +1 -0
- package/dist/mdx/mdxConflicts.vitest.d.ts +2 -0
- package/dist/mdx/mdxConflicts.vitest.d.ts.map +1 -0
- package/dist/mdx/mdxConflicts.vitest.js +101 -0
- package/dist/mdx/mdxConflicts.vitest.js.map +1 -0
- package/dist/mdx/mdxRules.d.ts +56 -0
- package/dist/mdx/mdxRules.d.ts.map +1 -0
- package/dist/mdx/mdxRules.js +386 -0
- package/dist/mdx/mdxRules.js.map +1 -0
- package/dist/mdx/mdxRules.vitest.d.ts +2 -0
- package/dist/mdx/mdxRules.vitest.d.ts.map +1 -0
- package/dist/mdx/mdxRules.vitest.js +36 -0
- package/dist/mdx/mdxRules.vitest.js.map +1 -0
- package/dist/mdx/sharedProcessor.d.ts +13 -0
- package/dist/mdx/sharedProcessor.d.ts.map +1 -0
- package/dist/mdx/sharedProcessor.js +48 -0
- package/dist/mdx/sharedProcessor.js.map +1 -0
- package/dist/mdx/tableMdx.d.ts +45 -0
- package/dist/mdx/tableMdx.d.ts.map +1 -0
- package/dist/mdx/tableMdx.js +114 -0
- package/dist/mdx/tableMdx.js.map +1 -0
- package/dist/mdx/tableMdx.vitest.d.ts +2 -0
- package/dist/mdx/tableMdx.vitest.d.ts.map +1 -0
- package/dist/mdx/tableMdx.vitest.js +99 -0
- package/dist/mdx/tableMdx.vitest.js.map +1 -0
- package/dist/multiSourceCompare.d.ts +40 -0
- package/dist/multiSourceCompare.d.ts.map +1 -0
- package/dist/multiSourceCompare.js +286 -0
- package/dist/multiSourceCompare.js.map +1 -0
- package/dist/multiSourceCompare.vitest.d.ts +2 -0
- package/dist/multiSourceCompare.vitest.d.ts.map +1 -0
- package/dist/multiSourceCompare.vitest.js +46 -0
- package/dist/multiSourceCompare.vitest.js.map +1 -0
- package/dist/parse.d.ts +6 -0
- package/dist/parse.d.ts.map +1 -0
- package/dist/parse.js +21 -0
- package/dist/parse.js.map +1 -0
- package/dist/parse.vitest.d.ts +2 -0
- package/dist/parse.vitest.d.ts.map +1 -0
- package/dist/parse.vitest.js +34 -0
- package/dist/parse.vitest.js.map +1 -0
- package/dist/parser.d.ts +4 -0
- package/dist/parser.d.ts.map +1 -0
- package/dist/parser.js +61 -0
- package/dist/parser.js.map +1 -0
- package/dist/transformer.d.ts +4 -0
- package/dist/transformer.d.ts.map +1 -0
- package/dist/transformer.js +112 -0
- package/dist/transformer.js.map +1 -0
- package/dist/types.d.ts +57 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +13 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/canonicalCache.d.ts +7 -0
- package/dist/utils/canonicalCache.d.ts.map +1 -0
- package/dist/utils/canonicalCache.js +18 -0
- package/dist/utils/canonicalCache.js.map +1 -0
- package/dist/utils/canonicalCache.vitest.d.ts +2 -0
- package/dist/utils/canonicalCache.vitest.d.ts.map +1 -0
- package/dist/utils/canonicalCache.vitest.js +40 -0
- package/dist/utils/canonicalCache.vitest.js.map +1 -0
- package/dist/utils/frontmatter.d.ts +13 -0
- package/dist/utils/frontmatter.d.ts.map +1 -0
- package/dist/utils/frontmatter.js +14 -0
- package/dist/utils/frontmatter.js.map +1 -0
- package/dist/utils/frontmatter.vitest.d.ts +2 -0
- package/dist/utils/frontmatter.vitest.d.ts.map +1 -0
- package/dist/utils/frontmatter.vitest.js +34 -0
- package/dist/utils/frontmatter.vitest.js.map +1 -0
- package/dist/validator.d.ts +7 -0
- package/dist/validator.d.ts.map +1 -0
- package/dist/validator.js +30 -0
- package/dist/validator.js.map +1 -0
- package/package.json +60 -0
- package/tsconfig.json +9 -0
- package/vitest.config.mjs +9 -0
|
@@ -0,0 +1,386 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MDX/section canonicalization rules.
|
|
3
|
+
*
|
|
4
|
+
* Error policy (do not change without review): On parse error, every rule returns
|
|
5
|
+
* a normalized fallback so one bad section does not break the run. ws_v1, table_v1,
|
|
6
|
+
* json_fences_v1, ast_v1 return normalizeProseWhitespace(raw/fragment); prettier_fences_v1
|
|
7
|
+
* returns normalizeOutputLight(raw). Callers: comparing outputs across rules can show diffs
|
|
8
|
+
* when one rule hit parse error (prose fallback vs light fallback).
|
|
9
|
+
*/
|
|
10
|
+
import stringify from 'fast-json-stable-stringify';
|
|
11
|
+
import { toString } from 'mdast-util-to-string';
|
|
12
|
+
import prettier from 'prettier';
|
|
13
|
+
import { removePosition } from 'unist-util-remove-position';
|
|
14
|
+
import { visit } from 'unist-util-visit';
|
|
15
|
+
import { getSharedProcessor } from './sharedProcessor.js';
|
|
16
|
+
/** Shared processor for batch runs; pass as context.processor so rules reuse one instance. */
|
|
17
|
+
export { getSharedProcessor } from './sharedProcessor.js';
|
|
18
|
+
/** Deterministic comparison for sorting (avoid localeCompare for hashing). */
|
|
19
|
+
function compareAsc(a, b) {
|
|
20
|
+
if (a < b)
|
|
21
|
+
return -1;
|
|
22
|
+
if (a > b)
|
|
23
|
+
return 1;
|
|
24
|
+
return 0;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Light normalization for individual text/inlineCode nodes only (spaces + trailing).
|
|
28
|
+
* Does not change newlines; full-output normalizers (normalizeProseWhitespace / normalizeOutputLight) own CRLF → LF.
|
|
29
|
+
*/
|
|
30
|
+
function normalizeInlineText(val) {
|
|
31
|
+
return val.replace(/[ \t]+/g, ' ').replace(/[ \t]+$/g, '');
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Aggressive prose normalization: use only on full string output.
|
|
35
|
+
* .trim() is intentional for canonical hashing; it can remove leading/trailing
|
|
36
|
+
* whitespace that matters for rendering — acceptable when the goal is comparison/hashing.
|
|
37
|
+
*/
|
|
38
|
+
function normalizeProseWhitespace(s) {
|
|
39
|
+
return s
|
|
40
|
+
.replace(/\r\n/g, '\n')
|
|
41
|
+
.replace(/[ \t]+$/gm, '')
|
|
42
|
+
.replace(/[ \t]+/g, ' ')
|
|
43
|
+
.replace(/\n{3,}/g, '\n\n')
|
|
44
|
+
.trim();
|
|
45
|
+
}
|
|
46
|
+
/** Light output normalization: CRLF, trailing space, blank lines only (no prose collapse). */
|
|
47
|
+
function normalizeOutputLight(s) {
|
|
48
|
+
return s
|
|
49
|
+
.replace(/\r\n/g, '\n')
|
|
50
|
+
.replace(/[ \t]+$/gm, '')
|
|
51
|
+
.replace(/\n{3,}/g, '\n\n')
|
|
52
|
+
.trim();
|
|
53
|
+
}
|
|
54
|
+
/** Normalize code block content (indentation, line trim, collapse). CRLF → LF for consistency. */
|
|
55
|
+
function normalizeCodeBlock(code) {
|
|
56
|
+
return code
|
|
57
|
+
.replace(/\r\n/g, '\n')
|
|
58
|
+
.split('\n')
|
|
59
|
+
.map((l) => l.trim())
|
|
60
|
+
.join('\n')
|
|
61
|
+
.replace(/[ \t]+/g, ' ')
|
|
62
|
+
.replace(/\n{3,}/g, '\n\n')
|
|
63
|
+
.trim();
|
|
64
|
+
}
|
|
65
|
+
export const ruleExact = {
|
|
66
|
+
id: 'exact',
|
|
67
|
+
applies: () => true,
|
|
68
|
+
async canonicalize(_anchor, raw, _context) {
|
|
69
|
+
return raw;
|
|
70
|
+
},
|
|
71
|
+
};
|
|
72
|
+
/** Parse raw to mdast; returns null on parse error. Uses context.getParsed(raw) when provided (parse-once). */
|
|
73
|
+
export function parseMdast(raw, processor, context) {
|
|
74
|
+
const pre = context?.getParsed?.(raw);
|
|
75
|
+
if (pre != null)
|
|
76
|
+
return pre;
|
|
77
|
+
try {
|
|
78
|
+
const proc = (processor ?? getSharedProcessor());
|
|
79
|
+
const tree = proc.parse(raw);
|
|
80
|
+
removePosition(tree, { force: true });
|
|
81
|
+
return { tree, processor: proc };
|
|
82
|
+
}
|
|
83
|
+
catch {
|
|
84
|
+
return null;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
function canonicalizeSection(raw, processor, context) {
|
|
88
|
+
const parsed = parseMdast(raw, processor, context);
|
|
89
|
+
if (!parsed)
|
|
90
|
+
return normalizeProseWhitespace(raw);
|
|
91
|
+
const { tree, processor: proc } = parsed;
|
|
92
|
+
visit(tree, ['text', 'inlineCode'], (node) => {
|
|
93
|
+
if (typeof node.value === 'string') {
|
|
94
|
+
node.value = normalizeInlineText(node.value);
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
visit(tree, 'code', (node) => {
|
|
98
|
+
if (typeof node.value === 'string') {
|
|
99
|
+
node.value = normalizeCodeBlock(node.value);
|
|
100
|
+
}
|
|
101
|
+
node.lang = (node.lang ?? '').trim().toLowerCase() || undefined;
|
|
102
|
+
});
|
|
103
|
+
const out = proc.stringify(tree);
|
|
104
|
+
return normalizeProseWhitespace(out);
|
|
105
|
+
}
|
|
106
|
+
/** Max raw length for ws/table/json rules (parse + heuristic). */
|
|
107
|
+
const DEFAULT_PARSE_MAX_CHARS = 80_000;
|
|
108
|
+
/**
|
|
109
|
+
* ws_v1: normalizes prose (text/inlineCode) and code blocks. Use when indentation/spacing noise in code is common.
|
|
110
|
+
* Rule ordering: prefer ws_v1 for sections where code blocks should be normalized; use ast_v1 when only prose matters.
|
|
111
|
+
*/
|
|
112
|
+
export const ruleWhitespace = {
|
|
113
|
+
id: 'ws_v1',
|
|
114
|
+
applies(_anchor, raw) {
|
|
115
|
+
return raw.length <= DEFAULT_PARSE_MAX_CHARS;
|
|
116
|
+
},
|
|
117
|
+
async canonicalize(_anchor, raw, context) {
|
|
118
|
+
return canonicalizeSection(raw, context?.processor, context);
|
|
119
|
+
},
|
|
120
|
+
};
|
|
121
|
+
/** Heuristic: separator line (|---| etc) must be preceded by a line with at least two | (avoids "a | b" prose). */
|
|
122
|
+
function looksLikeTableWithSeparator(raw) {
|
|
123
|
+
return /(^|\n)[^\n]*\|[^\n]*\|[^\n]*\n\s*\|?\s*:?-{3,}:?\s*(\|\s*:?-{3,}:?\s*)+\|?\s*(?=\n|$)/m.test(raw);
|
|
124
|
+
}
|
|
125
|
+
function cellText(cell) {
|
|
126
|
+
return normalizeInlineText(toString(cell))
|
|
127
|
+
.replace(/\r\n/g, '\n')
|
|
128
|
+
.replace(/\n+/g, ' ')
|
|
129
|
+
.replace(/[ \t]+/g, ' ')
|
|
130
|
+
.trim();
|
|
131
|
+
}
|
|
132
|
+
function canonicalizeTablesAST(raw, processor, context) {
|
|
133
|
+
const parsed = parseMdast(raw, processor, context);
|
|
134
|
+
if (!parsed)
|
|
135
|
+
return normalizeProseWhitespace(raw);
|
|
136
|
+
const { tree, processor: proc } = parsed;
|
|
137
|
+
let hasTable = false;
|
|
138
|
+
visit(tree, 'table', (table) => {
|
|
139
|
+
hasTable = true;
|
|
140
|
+
const rows = table.children ?? [];
|
|
141
|
+
if (rows.length < 2)
|
|
142
|
+
return; // header + at least one body row
|
|
143
|
+
const [headerRow, ...bodyRows] = rows;
|
|
144
|
+
const cellTextMap = new Map();
|
|
145
|
+
for (const row of rows) {
|
|
146
|
+
for (const cell of row.children ?? []) {
|
|
147
|
+
const c = cell;
|
|
148
|
+
cellTextMap.set(c, cellText(c));
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
function rowKey(row) {
|
|
152
|
+
return (row.children ?? [])
|
|
153
|
+
.map((cell) => cellTextMap.get(cell) ?? '')
|
|
154
|
+
.join('|');
|
|
155
|
+
}
|
|
156
|
+
// Stable sort: use original index as a final tiebreak so output is deterministic.
|
|
157
|
+
const indexed = bodyRows.map((row, i) => {
|
|
158
|
+
const cell0 = (row.children ?? [])[0];
|
|
159
|
+
const firstKey = (cell0 != null ? (cellTextMap.get(cell0) ?? '') : '').toLowerCase();
|
|
160
|
+
return { row, i, firstKey, rowKeyLower: rowKey(row).toLowerCase() };
|
|
161
|
+
});
|
|
162
|
+
indexed.sort((a, b) => {
|
|
163
|
+
const cmp = compareAsc(a.firstKey, b.firstKey);
|
|
164
|
+
if (cmp !== 0)
|
|
165
|
+
return cmp;
|
|
166
|
+
const rowCmp = compareAsc(a.rowKeyLower, b.rowKeyLower);
|
|
167
|
+
if (rowCmp !== 0)
|
|
168
|
+
return rowCmp;
|
|
169
|
+
return a.i - b.i;
|
|
170
|
+
});
|
|
171
|
+
table.children = [headerRow, ...indexed.map((x) => x.row)];
|
|
172
|
+
// This rule turns tables into plain-text cells: **bold** vs bold compare equal.
|
|
173
|
+
// Intentional for stable hashing; see docs.
|
|
174
|
+
for (const row of table.children) {
|
|
175
|
+
for (const cell of row.children ?? []) {
|
|
176
|
+
const cellNode = cell;
|
|
177
|
+
cellNode.children = [
|
|
178
|
+
{ type: 'text', value: cellTextMap.get(cellNode) ?? '' },
|
|
179
|
+
];
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
});
|
|
183
|
+
if (!hasTable)
|
|
184
|
+
return normalizeProseWhitespace(raw);
|
|
185
|
+
const out = proc.stringify(tree);
|
|
186
|
+
return normalizeProseWhitespace(out);
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* AST-based table rule; only runs when raw looks like a table (pipes + separator row).
|
|
190
|
+
* Turns tables into plain-text cells (links/emphasis stripped) so e.g. **bold** and bold compare equal — explicit tradeoff for hashing.
|
|
191
|
+
* applies() is heuristic only; canonicalizeTablesAST no-ops when no table nodes exist.
|
|
192
|
+
* TODO: consider makeRuleTables({ keyColumn: 0 }) so sort key column is configurable.
|
|
193
|
+
*/
|
|
194
|
+
export const ruleTables = {
|
|
195
|
+
id: 'table_v1',
|
|
196
|
+
applies(_anchor, raw) {
|
|
197
|
+
return (raw.length <= DEFAULT_PARSE_MAX_CHARS &&
|
|
198
|
+
raw.includes('\n') &&
|
|
199
|
+
raw.includes('|') &&
|
|
200
|
+
raw.includes('---') &&
|
|
201
|
+
looksLikeTableWithSeparator(raw));
|
|
202
|
+
},
|
|
203
|
+
async canonicalize(_anchor, raw, context) {
|
|
204
|
+
return canonicalizeTablesAST(raw, context?.processor, context);
|
|
205
|
+
},
|
|
206
|
+
};
|
|
207
|
+
const DEFAULT_MAX_CHARS = 50_000;
|
|
208
|
+
function canonicalizeAst(fragment, processor, context) {
|
|
209
|
+
const parsed = parseMdast(fragment, processor, context);
|
|
210
|
+
if (!parsed)
|
|
211
|
+
return normalizeProseWhitespace(fragment);
|
|
212
|
+
const { tree, processor: proc } = parsed;
|
|
213
|
+
visit(tree, ['text', 'inlineCode'], (node) => {
|
|
214
|
+
if (typeof node.value === 'string') {
|
|
215
|
+
node.value = normalizeInlineText(node.value);
|
|
216
|
+
}
|
|
217
|
+
});
|
|
218
|
+
const out = proc.stringify(tree);
|
|
219
|
+
return normalizeProseWhitespace(out);
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* ast_v1: normalizes prose only (text/inlineCode); does not touch code blocks. More conservative than ws_v1.
|
|
223
|
+
* Use when only prose normalization is needed; pick ws_v1 when code block normalization is desired.
|
|
224
|
+
*/
|
|
225
|
+
export function makeRuleAst(opts) {
|
|
226
|
+
const maxChars = opts?.maxChars ?? DEFAULT_MAX_CHARS;
|
|
227
|
+
const enabled = opts?.enabled ?? true;
|
|
228
|
+
return {
|
|
229
|
+
id: 'ast_v1',
|
|
230
|
+
applies(_anchor, raw) {
|
|
231
|
+
return enabled && raw.length <= maxChars;
|
|
232
|
+
},
|
|
233
|
+
async canonicalize(_anchor, raw, context) {
|
|
234
|
+
return canonicalizeAst(raw, context?.processor, context);
|
|
235
|
+
},
|
|
236
|
+
};
|
|
237
|
+
}
|
|
238
|
+
/** Max section length for Prettier rule only. */
|
|
239
|
+
const DEFAULT_PRETTIER_MAX_SECTION_CHARS = 80_000;
|
|
240
|
+
const DEFAULT_MAX_CODE_CHARS = 30_000;
|
|
241
|
+
const DEFAULT_MAX_CODE_LINES = 400;
|
|
242
|
+
function chooseParser(lang) {
|
|
243
|
+
const l = (lang || '').toLowerCase();
|
|
244
|
+
if (l === 'ts' || l === 'tsx' || l === 'typescript')
|
|
245
|
+
return 'babel-ts';
|
|
246
|
+
if (l === 'js' || l === 'jsx' || l === 'javascript')
|
|
247
|
+
return 'babel';
|
|
248
|
+
if (l === 'json')
|
|
249
|
+
return 'json';
|
|
250
|
+
return null;
|
|
251
|
+
}
|
|
252
|
+
/** Pinned options for canonical formatting (no implicit config). */
|
|
253
|
+
const PRETTIER_CANONICAL_OPTIONS = {
|
|
254
|
+
endOfLine: 'lf',
|
|
255
|
+
printWidth: 80,
|
|
256
|
+
tabWidth: 2,
|
|
257
|
+
semi: true,
|
|
258
|
+
singleQuote: true,
|
|
259
|
+
trailingComma: 'es5',
|
|
260
|
+
};
|
|
261
|
+
function prettierFilepathForParser(parser) {
|
|
262
|
+
// Helps Prettier select the right printer behavior without reading config.
|
|
263
|
+
if (parser === 'babel-ts')
|
|
264
|
+
return 'snippet.ts';
|
|
265
|
+
if (parser === 'json')
|
|
266
|
+
return 'snippet.json';
|
|
267
|
+
if (parser === 'babel')
|
|
268
|
+
return 'snippet.js';
|
|
269
|
+
return undefined;
|
|
270
|
+
}
|
|
271
|
+
/** Do not resolve config; use PRETTIER_CANONICAL_OPTIONS only so hashes match across envs/CI. */
|
|
272
|
+
async function formatCode(code, parser) {
|
|
273
|
+
const formatted = await prettier.format(code, {
|
|
274
|
+
parser,
|
|
275
|
+
...PRETTIER_CANONICAL_OPTIONS,
|
|
276
|
+
filepath: prettierFilepathForParser(parser),
|
|
277
|
+
});
|
|
278
|
+
return formatted.replace(/[ \t]+$/gm, '').trim();
|
|
279
|
+
}
|
|
280
|
+
/**
|
|
281
|
+
* Prettier rule: only normalizes code nodes; prose is not collapsed.
|
|
282
|
+
* Single visit: mutate inline when no parser or over limits; collect only { node, parser } for await.
|
|
283
|
+
*/
|
|
284
|
+
async function canonicalizeWithPrettierFences(raw, processor, context) {
|
|
285
|
+
const parsed = parseMdast(raw, processor, context);
|
|
286
|
+
if (!parsed)
|
|
287
|
+
return normalizeOutputLight(raw);
|
|
288
|
+
const { tree, processor: proc } = parsed;
|
|
289
|
+
let hasCode = false;
|
|
290
|
+
const toFormat = [];
|
|
291
|
+
visit(tree, 'code', (node) => {
|
|
292
|
+
hasCode = true;
|
|
293
|
+
const lang = (node.lang ?? '').trim().toLowerCase();
|
|
294
|
+
const value = node.value ?? '';
|
|
295
|
+
const parser = chooseParser(lang);
|
|
296
|
+
const codeLines = value.split('\n').length;
|
|
297
|
+
if (!parser) {
|
|
298
|
+
node.value = normalizeCodeBlock(value);
|
|
299
|
+
node.lang = lang || undefined;
|
|
300
|
+
return;
|
|
301
|
+
}
|
|
302
|
+
if (value.length > DEFAULT_MAX_CODE_CHARS ||
|
|
303
|
+
codeLines > DEFAULT_MAX_CODE_LINES) {
|
|
304
|
+
node.value = normalizeCodeBlock(value);
|
|
305
|
+
node.lang = lang || undefined;
|
|
306
|
+
return;
|
|
307
|
+
}
|
|
308
|
+
node.lang = lang || undefined;
|
|
309
|
+
toFormat.push({ node, parser });
|
|
310
|
+
});
|
|
311
|
+
if (!hasCode)
|
|
312
|
+
return normalizeOutputLight(raw);
|
|
313
|
+
for (const { node, parser } of toFormat) {
|
|
314
|
+
const value = node.value ?? '';
|
|
315
|
+
const lang = (node.lang ?? '').trim().toLowerCase();
|
|
316
|
+
try {
|
|
317
|
+
node.value = await formatCode(value, parser);
|
|
318
|
+
}
|
|
319
|
+
catch {
|
|
320
|
+
node.value = normalizeCodeBlock(value);
|
|
321
|
+
}
|
|
322
|
+
node.lang = lang || undefined;
|
|
323
|
+
}
|
|
324
|
+
const out = proc.stringify(tree);
|
|
325
|
+
return normalizeOutputLight(out);
|
|
326
|
+
}
|
|
327
|
+
export function makeRulePrettierFences(opts) {
|
|
328
|
+
const maxSectionChars = opts?.maxSectionChars ?? DEFAULT_PRETTIER_MAX_SECTION_CHARS;
|
|
329
|
+
const enabled = opts?.enabled ?? true;
|
|
330
|
+
return {
|
|
331
|
+
id: 'prettier_fences_v1',
|
|
332
|
+
applies(_anchor, raw) {
|
|
333
|
+
if (!enabled)
|
|
334
|
+
return false;
|
|
335
|
+
if (raw.length > maxSectionChars)
|
|
336
|
+
return false;
|
|
337
|
+
return /```|~~~/.test(raw);
|
|
338
|
+
},
|
|
339
|
+
async canonicalize(_anchor, raw, context) {
|
|
340
|
+
return canonicalizeWithPrettierFences(raw, context?.processor, context);
|
|
341
|
+
},
|
|
342
|
+
};
|
|
343
|
+
}
|
|
344
|
+
/**
|
|
345
|
+
* JSON code blocks: canonicalize value with fast-json-stable-stringify.
|
|
346
|
+
* Single visit: track hasAnyCode and touchedJson; early-return if no code or no json touched.
|
|
347
|
+
*/
|
|
348
|
+
async function canonicalizeJsonFences(raw, processor, context) {
|
|
349
|
+
const parsed = parseMdast(raw, processor, context);
|
|
350
|
+
if (!parsed)
|
|
351
|
+
return normalizeProseWhitespace(raw);
|
|
352
|
+
const { tree, processor: proc } = parsed;
|
|
353
|
+
let hasAnyCode = false;
|
|
354
|
+
let touchedJson = false;
|
|
355
|
+
visit(tree, 'code', (node) => {
|
|
356
|
+
hasAnyCode = true;
|
|
357
|
+
const lang = (node.lang ?? '').trim().toLowerCase();
|
|
358
|
+
if (lang !== 'json')
|
|
359
|
+
return;
|
|
360
|
+
touchedJson = true;
|
|
361
|
+
const value = node.value ?? '';
|
|
362
|
+
try {
|
|
363
|
+
const parsedJson = JSON.parse(value);
|
|
364
|
+
node.value = stringify(parsedJson);
|
|
365
|
+
}
|
|
366
|
+
catch {
|
|
367
|
+
// leave invalid JSON unchanged; do not throw
|
|
368
|
+
}
|
|
369
|
+
node.lang = 'json';
|
|
370
|
+
});
|
|
371
|
+
if (!hasAnyCode || !touchedJson)
|
|
372
|
+
return normalizeProseWhitespace(raw);
|
|
373
|
+
const out = proc.stringify(tree);
|
|
374
|
+
return normalizeProseWhitespace(out);
|
|
375
|
+
}
|
|
376
|
+
/** Only runs when raw might contain a json code fence (```json or ~~~json). */
|
|
377
|
+
export const ruleJsonFences = {
|
|
378
|
+
id: 'json_fences_v1',
|
|
379
|
+
applies(_anchor, raw) {
|
|
380
|
+
return (raw.length <= DEFAULT_PARSE_MAX_CHARS && /```json|~~~json/i.test(raw));
|
|
381
|
+
},
|
|
382
|
+
async canonicalize(_anchor, raw, context) {
|
|
383
|
+
return canonicalizeJsonFences(raw, context?.processor, context);
|
|
384
|
+
},
|
|
385
|
+
};
|
|
386
|
+
//# sourceMappingURL=mdxRules.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mdxRules.js","sourceRoot":"","sources":["../../src/mdx/mdxRules.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,SAAS,MAAM,4BAA4B,CAAC;AACnD,OAAO,EAAE,QAA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,CAAC,CAAC,CAAC;IAEH,IAAI,CAAC,UAAU,IAAI,CAAC,WAAW;QAAE,OAAO,wBAAwB,CAAC,GAAG,CAAC,CAAC;IAEtE,MAAM,GAAG,GAAG,IAAI,CAAC,SAAS,CAAC,IAAqB,CAAsB,CAAC;IACvE,OAAO,wBAAwB,CAAC,GAAG,CAAC,CAAC;AACvC,CAAC;AAED,+EAA+E;AAC/E,MAAM,CAAC,MAAM,cAAc,GAAS;IAClC,EAAE,EAAE,gBAAgB;IACpB,OAAO,CAAC,OAAO,EAAE,GAAG;QAClB,OAAO,CACL,GAAG,CAAC,MAAM,IAAI,uBAAuB,IAAI,kBAAkB,CAAC,IAAI,CAAC,GAAG,CAAC,CACtE,CAAC;IACJ,CAAC;IACD,KAAK,CAAC,YAAY,CAAC,OAAO,EAAE,GAAG,EAAE,OAAQ;QACvC,OAAO,sBAAsB,CAC3B,GAAG,EACH,OAAO,EAAE,SAAkC,EAC3C,OAAO,CACR,CAAC;IACJ,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mdxRules.vitest.d.ts","sourceRoot":"","sources":["../../src/mdx/mdxRules.vitest.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest';
|
|
2
|
+
import { ruleExact, ruleWhitespace, ruleTables } from './mdxRules.js';
|
|
3
|
+
describe('ruleExact', () => {
|
|
4
|
+
it('applies returns true for any anchor and raw', () => {
|
|
5
|
+
expect(ruleExact.applies('props', '')).toBe(true);
|
|
6
|
+
expect(ruleExact.applies('any', 'content')).toBe(true);
|
|
7
|
+
});
|
|
8
|
+
it('canonicalize returns raw unchanged', async () => {
|
|
9
|
+
const raw = 'hello\nworld';
|
|
10
|
+
const out = await ruleExact.canonicalize('anchor', raw);
|
|
11
|
+
expect(out).toBe(raw);
|
|
12
|
+
});
|
|
13
|
+
});
|
|
14
|
+
describe('ruleWhitespace', () => {
|
|
15
|
+
it('applies returns true when raw length <= 80_000', () => {
|
|
16
|
+
expect(ruleWhitespace.applies('x', '')).toBe(true);
|
|
17
|
+
expect(ruleWhitespace.applies('x', 'a'.repeat(80_000))).toBe(true);
|
|
18
|
+
});
|
|
19
|
+
it('applies returns false when raw length > 80_000', () => {
|
|
20
|
+
expect(ruleWhitespace.applies('x', 'a'.repeat(80_001))).toBe(false);
|
|
21
|
+
});
|
|
22
|
+
});
|
|
23
|
+
describe('ruleTables', () => {
|
|
24
|
+
it('applies returns true for content that looks like a pipe table with separator', () => {
|
|
25
|
+
const tableLike = '| A | B |\n|---|---|\n| 1 | 2 |';
|
|
26
|
+
expect(ruleTables.applies('props', tableLike)).toBe(true);
|
|
27
|
+
});
|
|
28
|
+
it('applies returns false for plain prose with pipe character', () => {
|
|
29
|
+
expect(ruleTables.applies('x', 'a | b')).toBe(false);
|
|
30
|
+
});
|
|
31
|
+
it('applies returns false when over parse max chars', () => {
|
|
32
|
+
const long = `| A | B |\n|---|---|\n| 1 | 2 |${'x'.repeat(80_000)}`;
|
|
33
|
+
expect(ruleTables.applies('props', long)).toBe(false);
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
//# sourceMappingURL=mdxRules.vitest.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mdxRules.vitest.js","sourceRoot":"","sources":["../../src/mdx/mdxRules.vitest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAEtE,QAAQ,CAAC,WAAW,EAAE,GAAG,EAAE;IACzB,EAAE,CAAC,6CAA6C,EAAE,GAAG,EAAE;QACrD,MAAM,CAAC,SAAS,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAClD,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C,CAAC;IAC5D,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,2DAA2D,EAAE,GAAG,EAAE;QACnE,MAAM,CAAC,UAAU,CAAC,OAAO,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACvD,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,iDAAiD,EAAE,GAAG,EAAE;QACzD,MAAM,IAAI,GAAG,kCAAkC,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC;QACpE,MAAM,CAAC,UAAU,CAAC,OAAO,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACxD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Single shared unified processor for all markdown/MDX parsing in source-conflicts.
|
|
3
|
+
* Ensures rules and table parsing use the same AST/parser (remark-parse + remark-gfm + remark-mdx).
|
|
4
|
+
*
|
|
5
|
+
* Plugins are used as-is (no unwrap) so unified receives the real plugin and can attach Parser.
|
|
6
|
+
* Validates by parsing empty string at creation so misconfiguration fails loud at startup.
|
|
7
|
+
*/
|
|
8
|
+
import type { Processor } from 'unified';
|
|
9
|
+
/**
|
|
10
|
+
* Returns the shared markdown/MDX processor. Created lazily on first use.
|
|
11
|
+
*/
|
|
12
|
+
export declare function getSharedProcessor(): Processor;
|
|
13
|
+
//# sourceMappingURL=sharedProcessor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sharedProcessor.d.ts","sourceRoot":"","sources":["../../src/mdx/sharedProcessor.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AA0CzC;;GAEG;AACH,wBAAgB,kBAAkB,IAAI,SAAS,CAK9C"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Single shared unified processor for all markdown/MDX parsing in source-conflicts.
|
|
3
|
+
* Ensures rules and table parsing use the same AST/parser (remark-parse + remark-gfm + remark-mdx).
|
|
4
|
+
*
|
|
5
|
+
* Plugins are used as-is (no unwrap) so unified receives the real plugin and can attach Parser.
|
|
6
|
+
* Validates by parsing empty string at creation so misconfiguration fails loud at startup.
|
|
7
|
+
*/
|
|
8
|
+
import { unified } from 'unified';
|
|
9
|
+
import remarkParse from 'remark-parse';
|
|
10
|
+
import remarkGfm from 'remark-gfm';
|
|
11
|
+
import remarkMdx from 'remark-mdx';
|
|
12
|
+
import remarkStringify from 'remark-stringify';
|
|
13
|
+
let processor = null;
|
|
14
|
+
function createProcessor() {
|
|
15
|
+
const p = unified()
|
|
16
|
+
.use(remarkParse)
|
|
17
|
+
.use(remarkGfm)
|
|
18
|
+
.use(remarkMdx)
|
|
19
|
+
// remark-stringify plugin typings don't match unified Processor; runtime is correct
|
|
20
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- unified vs remark-stringify typings
|
|
21
|
+
.use(remarkStringify, {
|
|
22
|
+
bullet: '-',
|
|
23
|
+
fence: '`',
|
|
24
|
+
fences: true,
|
|
25
|
+
listItemIndent: 'one',
|
|
26
|
+
rule: '-',
|
|
27
|
+
emphasis: '_',
|
|
28
|
+
strong: '*',
|
|
29
|
+
});
|
|
30
|
+
// Validate by parsing so misconfiguration fails at startup.
|
|
31
|
+
try {
|
|
32
|
+
p.parse('');
|
|
33
|
+
}
|
|
34
|
+
catch (err) {
|
|
35
|
+
throw new Error(`Shared markdown processor could not parse after applying remark-parse: ${err instanceof Error ? err.message : String(err)}`);
|
|
36
|
+
}
|
|
37
|
+
return p;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Returns the shared markdown/MDX processor. Created lazily on first use.
|
|
41
|
+
*/
|
|
42
|
+
export function getSharedProcessor() {
|
|
43
|
+
if (!processor) {
|
|
44
|
+
processor = createProcessor();
|
|
45
|
+
}
|
|
46
|
+
return processor;
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=sharedProcessor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sharedProcessor.js","sourceRoot":"","sources":["../../src/mdx/sharedProcessor.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,WAAW,MAAM,cAAc,CAAC;AACvC,OAAO,SAAS,MAAM,YAAY,CAAC;AACnC,OAAO,SAAS,MAAM,YAAY,CAAC;AACnC,OAAO,eAAe,MAAM,kBAAkB,CAAC;AAI/C,IAAI,SAAS,GAAqB,IAAI,CAAC;AAEvC,SAAS,eAAe;IACtB,MAAM,CAAC,GAAG,OAAO,EAAE;SAChB,GAAG,CAAC,WAAqB,CAAC;SAC1B,GAAG,CAAC,SAAmB,CAAC;SACxB,GAAG,CAAC,SAAmB,CAAC;QACzB,oFAAoF;QACpF,qGAAqG;SACpG,GAAG,CAAC,eAAsB,EAAE;QAC3B,MAAM,EAAE,GAAG;QACX,KAAK,EAAE,GAAG;QACV,MAAM,EAAE,IAAI;QACZ,cAAc,EAAE,KAAK;QACrB,IAAI,EAAE,GAAG;QACT,QAAQ,EAAE,GAAG;QACb,MAAM,EAAE,GAAG;KACZ,CAAC,CAAC;IAEL,4DAA4D;IAC5D,IAAI,CAAC;QACH,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IACd,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CACb,0EACE,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CACjD,EAAE,CACH,CAAC;IACJ,CAAC;IAED,OAAO,CAAC,CAAC;AACX,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,kBAAkB;IAChC,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,SAAS,GAAG,eAAe,EAAE,CAAC;IAChC,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parse markdown pipe tables in section body into a stable structural form for comparison.
|
|
3
|
+
* Used for any anchor whose section contains a table (props, slots, events, variants, etc.).
|
|
4
|
+
*
|
|
5
|
+
* Uses the shared unified processor (remark-parse + remark-gfm) so all rules share the same AST/parser.
|
|
6
|
+
*/
|
|
7
|
+
/** Parsed table: sorted column names, key column (first header), and rows as records. */
|
|
8
|
+
export type TableNode = {
|
|
9
|
+
/** Column names in stable order (sorted for canonical form). */
|
|
10
|
+
columns: string[];
|
|
11
|
+
/** Row identity = value of this column (first column in header order). */
|
|
12
|
+
keyColumn: string;
|
|
13
|
+
/** Rows keyed by column name. */
|
|
14
|
+
rows: Array<Record<string, string>>;
|
|
15
|
+
};
|
|
16
|
+
/** Options for parseTable. All optional; no limits by default. */
|
|
17
|
+
export type ParseTableOptions = {
|
|
18
|
+
/** When true, body rows with a different cell count than the header are skipped. Default: false (missing cells become '', extra cells ignored). */
|
|
19
|
+
strictColumnCount?: boolean;
|
|
20
|
+
/** Cap the number of body rows parsed. Omitted = no limit. */
|
|
21
|
+
maxRows?: number;
|
|
22
|
+
/** Truncate cell values to this length. Omitted = no limit. */
|
|
23
|
+
maxCellLength?: number;
|
|
24
|
+
};
|
|
25
|
+
/** Normalize row key for comparison and hashing (trim + lowercase). Use consistently for grouping and canonical form. */
|
|
26
|
+
export declare function rowKeyNorm(v: unknown): string;
|
|
27
|
+
/**
|
|
28
|
+
* Parse the first markdown pipe table in raw into a table node.
|
|
29
|
+
* Row identity = first column value. Returns null if no valid table.
|
|
30
|
+
*
|
|
31
|
+
* Column count: by default, body rows with fewer cells get '' for missing columns; extra cells are ignored.
|
|
32
|
+
* Use options.strictColumnCount to skip rows whose cell count does not match the header.
|
|
33
|
+
*
|
|
34
|
+
* @param raw - Section body (may contain text before/after the table).
|
|
35
|
+
* @param options - Optional: strictColumnCount, maxRows, maxCellLength.
|
|
36
|
+
*/
|
|
37
|
+
export declare function parseTable(raw: string, options?: ParseTableOptions): TableNode | null;
|
|
38
|
+
/**
|
|
39
|
+
* Stable canonical JSON string for hashing.
|
|
40
|
+
* Must be deterministic: sorted keys and stable ordering.
|
|
41
|
+
*
|
|
42
|
+
* @param node - Parsed table (e.g. from parseTable).
|
|
43
|
+
*/
|
|
44
|
+
export declare function canonicalizeTable(node: TableNode): string;
|
|
45
|
+
//# sourceMappingURL=tableMdx.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tableMdx.d.ts","sourceRoot":"","sources":["../../src/mdx/tableMdx.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAmBH,yFAAyF;AACzF,MAAM,MAAM,SAAS,GAAG;IACtB,gEAAgE;IAChE,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,0EAA0E;IAC1E,SAAS,EAAE,MAAM,CAAC;IAClB,iCAAiC;IACjC,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;CACrC,CAAC;AAEF,kEAAkE;AAClE,MAAM,MAAM,iBAAiB,GAAG;IAC9B,mJAAmJ;IACnJ,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,8DAA8D;IAC9D,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,+DAA+D;IAC/D,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB,CAAC;AAMF,yHAAyH;AACzH,wBAAgB,UAAU,CAAC,CAAC,EAAE,OAAO,GAAG,MAAM,CAI7C;AAYD;;;;;;;;;GASG;AACH,wBAAgB,UAAU,CACxB,GAAG,EAAE,MAAM,EACX,OAAO,CAAC,EAAE,iBAAiB,GAC1B,SAAS,GAAG,IAAI,CAgElB;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,SAAS,GAAG,MAAM,CAezD"}
|