@temelj/mdx 0.11.1 → 0.11.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.
@@ -37,6 +37,8 @@ interface MdxMessage {
37
37
  place?: MdxMessagePlace | undefined;
38
38
  sourceLine?: string | undefined;
39
39
  snippet?: string | undefined;
40
+ sourcePointer?: string | undefined;
41
+ hint?: string | undefined;
40
42
  cause?: {
41
43
  name?: string | undefined;
42
44
  message: string;
@@ -60,6 +62,8 @@ declare class MdxCompileError extends Error {
60
62
  readonly place?: MdxMessagePlace | undefined;
61
63
  readonly sourceLine?: string | undefined;
62
64
  readonly snippet?: string | undefined;
65
+ readonly sourcePointer?: string | undefined;
66
+ readonly hint?: string | undefined;
63
67
  readonly diagnostics: MdxMessage[];
64
68
  constructor(reason: string, options?: {
65
69
  source?: string | undefined;
@@ -69,6 +73,9 @@ declare class MdxCompileError extends Error {
69
73
  place?: MdxMessagePlace | undefined;
70
74
  sourceLine?: string | undefined;
71
75
  snippet?: string | undefined;
76
+ sourcePointer?: string | undefined;
77
+ hint?: string | undefined;
78
+ causeMessage?: string | undefined;
72
79
  diagnostics?: MdxMessage[] | undefined;
73
80
  cause?: unknown;
74
81
  });
@@ -1 +1 @@
1
- {"version":3,"file":"compiler.d.mts","names":[],"sources":["../src/compiler.ts"],"mappings":";;;;;;;;;AAkBA;;KAAY,SAAA,YAAqB,UAAA;;;AAKjC;UAAiB,iBAAA;EACf,eAAA;EACA,UAAA,GAAa,cAAA;AAAA;AAAA,UAGE,eAAA;EACf,IAAA;EACA,MAAA;EACA,MAAA;AAAA;AAAA,UAGe,eAAA;EACf,KAAA,GAAQ,eAAA;EACR,GAAA,GAAM,eAAA;AAAA;AAAA,UAGS,UAAA;EACf,OAAA;EACA,MAAA;EACA,MAAA;EACA,MAAA;EACA,KAAA;EACA,IAAA;EACA,MAAA;EACA,KAAA,GAAQ,eAAA;EACR,UAAA;EACA,OAAA;EACA,KAAA;IACE,IAAA;I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IAAc,iBAAA,EACzC,iBAAA,GAAoB,kBAAA,GACnB,OAAA,CAAQ,WAAA,CAAY,CAAA,CAAE,MAAA,CAAO,kBAAA;AAAA"}
package/dist/compiler.mjs CHANGED
@@ -13,6 +13,8 @@ var MdxCompileError = class extends Error {
13
13
  place;
14
14
  sourceLine;
15
15
  snippet;
16
+ sourcePointer;
17
+ hint;
16
18
  diagnostics;
17
19
  constructor(reason, options = {}) {
18
20
  super(formatDiagnosticMessage(reason, {
@@ -21,7 +23,10 @@ var MdxCompileError = class extends Error {
21
23
  line: options.line,
22
24
  column: options.column,
23
25
  sourceLine: options.sourceLine,
24
- snippet: options.snippet
26
+ snippet: options.snippet,
27
+ sourcePointer: options.sourcePointer,
28
+ hint: options.hint,
29
+ causeMessage: options.causeMessage
25
30
  }), options.cause === void 0 ? void 0 : { cause: options.cause });
26
31
  this.name = "MdxCompileError";
27
32
  this.reason = reason;
@@ -32,6 +37,8 @@ var MdxCompileError = class extends Error {
32
37
  this.place = options.place;
33
38
  this.sourceLine = options.sourceLine;
34
39
  this.snippet = options.snippet;
40
+ this.sourcePointer = options.sourcePointer;
41
+ this.hint = options.hint;
35
42
  this.diagnostics = options.diagnostics ?? [];
36
43
  }
37
44
  };
@@ -65,6 +72,7 @@ var MdxCompiler = class {
65
72
  path: "/source.mdx"
66
73
  });
67
74
  matter(vfile, { strip: true });
75
+ const sourceContext = createDiagnosticSourceContext(sourceText, toSourceText(vfile.value));
68
76
  const remarkPlugins = [
69
77
  ...this.remarkPlugins,
70
78
  ...this.mdxOptions?.remarkPlugins ?? [],
@@ -85,18 +93,19 @@ var MdxCompiler = class {
85
93
  rehypePlugins
86
94
  })).value.toString();
87
95
  } catch (error) {
88
- throw toMdxCompileError(error, sourceText, vfile.messages);
96
+ throw toMdxCompileError(error, sourceContext, vfile.messages);
89
97
  }
90
98
  const frontmatter = frontmatterSchema === void 0 ? vfile.data.matter ?? {} : frontmatterSchema.parse(vfile.data.matter ?? {});
91
99
  return {
92
100
  compiled,
93
101
  frontmatter,
94
- messages: normalizeMessages(vfile.messages, sourceText)
102
+ messages: normalizeMessages(vfile.messages, sourceContext)
95
103
  };
96
104
  }
97
105
  };
98
- function toMdxCompileError(error, sourceText, diagnostics) {
99
- const details = getDiagnosticDetails(sourceText, getErrorPlace(error), error);
106
+ function toMdxCompileError(error, sourceContext, diagnostics) {
107
+ const details = getDiagnosticDetails(sourceContext, getErrorPlace(error), error);
108
+ const cause = getErrorCause(error);
100
109
  return new MdxCompileError(getErrorReason(error), {
101
110
  source: getErrorField(error, "source"),
102
111
  ruleId: getErrorField(error, "ruleId"),
@@ -105,13 +114,16 @@ function toMdxCompileError(error, sourceText, diagnostics) {
105
114
  place: details.place,
106
115
  sourceLine: details.sourceLine,
107
116
  snippet: details.snippet,
108
- diagnostics: normalizeMessages(diagnostics, sourceText),
117
+ sourcePointer: details.sourcePointer,
118
+ hint: details.hint,
119
+ causeMessage: cause?.message,
120
+ diagnostics: normalizeMessages(diagnostics, sourceContext),
109
121
  cause: error
110
122
  });
111
123
  }
112
- function normalizeMessages(messages, sourceText) {
124
+ function normalizeMessages(messages, sourceContext) {
113
125
  return messages.map((message) => {
114
- const details = getDiagnosticDetails(sourceText, toMessagePlace(message), message);
126
+ const details = getDiagnosticDetails(sourceContext, toMessagePlace(message), message);
115
127
  const reason = getErrorReason(message);
116
128
  const source = getErrorField(message, "source");
117
129
  const ruleId = getErrorField(message, "ruleId");
@@ -124,6 +136,8 @@ function normalizeMessages(messages, sourceText) {
124
136
  column: details.column,
125
137
  sourceLine: details.sourceLine,
126
138
  snippet: details.snippet,
139
+ sourcePointer: details.sourcePointer,
140
+ hint: details.hint,
127
141
  causeMessage: cause?.message
128
142
  }),
129
143
  reason,
@@ -135,6 +149,8 @@ function normalizeMessages(messages, sourceText) {
135
149
  place: details.place,
136
150
  sourceLine: details.sourceLine,
137
151
  snippet: details.snippet,
152
+ sourcePointer: details.sourcePointer,
153
+ hint: details.hint,
138
154
  cause
139
155
  };
140
156
  });
@@ -146,16 +162,21 @@ function formatDiagnosticMessage(reason, options) {
146
162
  options.line === void 0 ? void 0 : options.column === void 0 ? `at ${options.line}` : `at ${options.line}:${options.column}`
147
163
  ].filter(Boolean).join(" ")];
148
164
  if (options.snippet !== void 0) lines.push(`Source: ${options.snippet}`);
149
- if (options.sourceLine !== void 0 && options.sourceLine !== options.snippet) lines.push(`Line: ${options.sourceLine}`);
165
+ if (options.sourceLine !== void 0 && options.sourceLine !== options.snippet) {
166
+ lines.push(`Line: ${options.sourceLine}`);
167
+ if (options.sourcePointer !== void 0) lines.push(` ${options.sourcePointer}`);
168
+ }
150
169
  if (options.causeMessage !== void 0 && options.causeMessage !== "" && options.causeMessage !== reason) lines.push(`Cause: ${options.causeMessage}`);
170
+ if (options.hint !== void 0) lines.push(`Hint: ${options.hint}`);
151
171
  return lines.join("\n");
152
172
  }
153
- function getDiagnosticDetails(sourceText, place, error) {
154
- const line = place?.start?.line ?? getErrorNumberField(error, "line");
155
- const column = place?.start?.column ?? getErrorNumberField(error, "column");
156
- const normalizedPlace = line === void 0 && column === void 0 && place === void 0 ? void 0 : {
173
+ function getDiagnosticDetails(sourceContext, place, error) {
174
+ const compileLine = place?.start?.line ?? getErrorNumberField(error, "line");
175
+ let line = compileLine === void 0 ? void 0 : compileLine + sourceContext.lineOffset;
176
+ let column = place?.start?.column ?? getErrorNumberField(error, "column");
177
+ let normalizedPlace = mapPlaceToOriginalSource(place === void 0 && compileLine === void 0 && column === void 0 ? void 0 : {
157
178
  start: {
158
- line,
179
+ line: compileLine,
159
180
  column,
160
181
  offset: place?.start?.offset
161
182
  },
@@ -164,15 +185,61 @@ function getDiagnosticDetails(sourceText, place, error) {
164
185
  column: place.end.column,
165
186
  offset: place.end.offset
166
187
  }
167
- };
188
+ }, sourceContext.lineOffset);
189
+ let sourceLine = getSourceLine(sourceContext.originalSourceText, line);
190
+ let snippet = getSourceSnippet(sourceContext.originalSourceText, normalizedPlace);
191
+ let sourcePointer = getSourcePointer(column);
192
+ let hint;
193
+ const refinedExpressionContext = getMdxExpressionContext(sourceContext.originalSourceText, {
194
+ line,
195
+ column,
196
+ sourceLine,
197
+ snippet,
198
+ error
199
+ });
200
+ if (refinedExpressionContext !== void 0) {
201
+ line = refinedExpressionContext.line;
202
+ column = refinedExpressionContext.column;
203
+ sourceLine = refinedExpressionContext.sourceLine;
204
+ snippet = refinedExpressionContext.snippet;
205
+ sourcePointer = refinedExpressionContext.sourcePointer;
206
+ hint = refinedExpressionContext.hint;
207
+ normalizedPlace = {
208
+ start: {
209
+ line,
210
+ column,
211
+ offset: void 0
212
+ },
213
+ end: void 0
214
+ };
215
+ }
168
216
  return {
169
217
  line,
170
218
  column,
171
219
  place: normalizedPlace,
172
- sourceLine: getSourceLine(sourceText, line),
173
- snippet: getSourceSnippet(sourceText, normalizedPlace)
220
+ sourceLine,
221
+ snippet,
222
+ sourcePointer,
223
+ hint
224
+ };
225
+ }
226
+ function getMdxExpressionContext(sourceText, options) {
227
+ if (!shouldRefineMdxExpressionContext(options)) return;
228
+ const candidate = findSuspiciousBraceExpression(sourceText, options.line, options.column);
229
+ if (candidate === void 0) return;
230
+ return {
231
+ line: candidate.line,
232
+ column: candidate.column,
233
+ sourceLine: candidate.sourceLine,
234
+ snippet: candidate.snippet,
235
+ sourcePointer: getSourcePointer(candidate.column) ?? "^",
236
+ hint: getErrorCause(options.error)?.message === "Unexpected content after expression" ? "MDX treats `{...}` as JavaScript. If you meant literal braces in text, escape them or wrap the text in code." : void 0
174
237
  };
175
238
  }
239
+ function shouldRefineMdxExpressionContext(options) {
240
+ const trimmedSourceLine = options.sourceLine?.trim();
241
+ return isMdxExpressionError(options.error) && getErrorCause(options.error)?.message === "Unexpected content after expression" && (options.sourceLine === void 0 || options.sourceLine.trim() === "" || options.snippet === void 0) && !(trimmedSourceLine?.startsWith("{") && trimmedSourceLine.endsWith("}"));
242
+ }
176
243
  function getSourceLine(sourceText, line) {
177
244
  if (line === void 0 || line < 1) return;
178
245
  return sourceText.split(/\r?\n/u)[line - 1];
@@ -180,6 +247,12 @@ function getSourceLine(sourceText, line) {
180
247
  function getSourceSnippet(sourceText, place) {
181
248
  if (place?.start?.offset !== void 0 && place.end?.offset !== void 0) return sourceText.slice(place.start.offset, place.end.offset) || void 0;
182
249
  if (place?.start?.line === void 0 || place.start.column === void 0) return;
250
+ if (place.end === void 0) {
251
+ const line = sourceText.split(/\r?\n/u)[place.start.line - 1];
252
+ if (line === void 0) return;
253
+ const character = line.at(place.start.column - 1);
254
+ return character === void 0 || character.trim() === "" ? void 0 : character;
255
+ }
183
256
  const lines = sourceText.split(/\r?\n/u);
184
257
  const startLineIndex = place.start.line - 1;
185
258
  const endLineIndex = (place.end?.line ?? place.start.line) - 1;
@@ -194,6 +267,110 @@ function getSourceSnippet(sourceText, place) {
194
267
  }
195
268
  return selectedLines.join("\n") || void 0;
196
269
  }
270
+ function getSourcePointer(column) {
271
+ if (column === void 0 || column < 1) return;
272
+ return `${" ".repeat(column - 1)}^`;
273
+ }
274
+ function mapPlaceToOriginalSource(place, lineOffset) {
275
+ if (place === void 0) return;
276
+ return {
277
+ start: mapPointToOriginalSource(place.start, lineOffset),
278
+ end: mapPointToOriginalSource(place.end, lineOffset)
279
+ };
280
+ }
281
+ function mapPointToOriginalSource(point, lineOffset) {
282
+ if (point === void 0) return;
283
+ return {
284
+ line: point.line === void 0 ? void 0 : point.line + lineOffset,
285
+ column: point.column,
286
+ offset: lineOffset === 0 ? point.offset : void 0
287
+ };
288
+ }
289
+ function findSuspiciousBraceExpression(sourceText, line, column) {
290
+ const lines = sourceText.split(/\r?\n/u);
291
+ const searchLines = getNearbyLineNumbers(line, lines.length, 2);
292
+ let bestMatch;
293
+ for (const lineNumber of searchLines) {
294
+ const sourceLine = lines[lineNumber - 1];
295
+ if (sourceLine === void 0 || sourceLine.trim() === "") continue;
296
+ const expression = findLineBraceExpression(sourceLine, lineNumber, column);
297
+ if (expression === void 0) continue;
298
+ const score = (line === void 0 ? 0 : Math.abs(lineNumber - line)) * 10 + expression.distance;
299
+ if (bestMatch === void 0 || score < bestMatch.score) bestMatch = {
300
+ ...expression,
301
+ score
302
+ };
303
+ }
304
+ return bestMatch;
305
+ }
306
+ function getNearbyLineNumbers(line, totalLines, radius) {
307
+ if (line === void 0) return Array.from({ length: totalLines }, (_, index) => index + 1);
308
+ const lineNumbers = [];
309
+ for (let distance = 0; distance <= radius; distance++) {
310
+ const before = line - distance;
311
+ if (before >= 1) lineNumbers.push(before);
312
+ if (distance === 0) continue;
313
+ const after = line + distance;
314
+ if (after <= totalLines) lineNumbers.push(after);
315
+ }
316
+ return lineNumbers;
317
+ }
318
+ function findLineBraceExpression(sourceLine, line, column) {
319
+ let bestMatch;
320
+ for (const match of sourceLine.matchAll(/\{[^{}\n]+\}/gu)) {
321
+ const braceStart = match.index;
322
+ if (braceStart === void 0) continue;
323
+ const expanded = expandBraceExpression(sourceLine, braceStart);
324
+ if (expanded === void 0) continue;
325
+ const distance = column === void 0 ? 0 : Math.abs(braceStart + 1 - column);
326
+ if (bestMatch === void 0 || distance < bestMatch.distance) bestMatch = {
327
+ line,
328
+ column: braceStart + 1,
329
+ sourceLine,
330
+ snippet: expanded,
331
+ distance
332
+ };
333
+ }
334
+ return bestMatch;
335
+ }
336
+ function expandBraceExpression(sourceLine, braceStart) {
337
+ const braceEnd = sourceLine.indexOf("}", braceStart);
338
+ if (braceEnd === -1) return;
339
+ let start = braceStart;
340
+ while (start > 0 && /[A-Za-z0-9_]/u.test(sourceLine[start - 1])) start--;
341
+ let end = braceEnd + 1;
342
+ while (end < sourceLine.length) {
343
+ while (end < sourceLine.length && /[A-Za-z0-9_]/u.test(sourceLine[end])) end++;
344
+ if (sourceLine[end] !== "{") break;
345
+ const chainedEnd = sourceLine.indexOf("}", end);
346
+ if (chainedEnd === -1) break;
347
+ end = chainedEnd + 1;
348
+ }
349
+ return sourceLine.slice(start, end) || void 0;
350
+ }
351
+ function isMdxExpressionError(error) {
352
+ return getErrorField(error, "source") === "micromark-extension-mdx-expression" && getErrorField(error, "ruleId") === "acorn";
353
+ }
354
+ function createDiagnosticSourceContext(originalSourceText, compileSourceText) {
355
+ return {
356
+ originalSourceText,
357
+ lineOffset: getSourceLineOffset(originalSourceText, compileSourceText)
358
+ };
359
+ }
360
+ function getSourceLineOffset(originalSourceText, compileSourceText) {
361
+ const originalLines = originalSourceText.split(/\r?\n/u);
362
+ const compileLines = compileSourceText.split(/\r?\n/u);
363
+ const maxOffset = originalLines.length - compileLines.length;
364
+ for (let offset = 0; offset <= maxOffset; offset++) {
365
+ let isMatch = true;
366
+ for (let index = 0; index < compileLines.length; index++) if (originalLines[offset + index] !== compileLines[index]) {
367
+ isMatch = false;
368
+ break;
369
+ }
370
+ if (isMatch) return offset;
371
+ }
372
+ return maxOffset > 0 ? maxOffset : 0;
373
+ }
197
374
  function getErrorPlace(error) {
198
375
  if (typeof error !== "object" || error === null) return;
199
376
  const candidate = error;
@@ -1 +1 @@
1
- {"version":3,"file":"compiler.mjs","names":["compileMdxJs"],"sources":["../src/compiler.ts"],"sourcesContent":["import {\n compile as compileMdxJs,\n type CompileOptions as MdxJsCompileOptions,\n} from \"@mdx-js/mdx\";\nimport remarkFrontmatterPlugin from \"remark-frontmatter\";\nimport remarkGfmPlugin from \"remark-gfm\";\nimport type { Pluggable, PluggableList, Plugin } from \"unified\";\nimport { VFile } from \"vfile\";\nimport { matter } from \"vfile-matter\";\nimport type { z } from \"zod\";\n\nimport type { HastNode } from \"./types\";\n\nexport { remarkFrontmatterPlugin, remarkGfmPlugin };\n\n/**\n * Represents the source content for an MDX document.\n */\nexport type MdxSource = string | Uint8Array;\n\n/**\n * Options for compiling an MDX document.\n */\nexport interface MdxCompileOptions {\n frontmatterOnly?: boolean | undefined;\n mdxOptions?: MdxJsCompileOptions;\n}\n\nexport interface MdxMessagePoint {\n line?: number | undefined;\n column?: number | undefined;\n offset?: number | undefined;\n}\n\nexport interface MdxMessagePlace {\n start?: MdxMessagePoint | undefined;\n end?: MdxMessagePoint | undefined;\n}\n\nexport interface MdxMessage {\n message: string;\n reason: string;\n source?: string | undefined;\n ruleId?: string | undefined;\n fatal?: boolean | undefined;\n line?: number | undefined;\n column?: number | undefined;\n place?: MdxMessagePlace | undefined;\n sourceLine?: string | undefined;\n snippet?: string | undefined;\n cause?: {\n name?: string | undefined;\n message: string;\n };\n}\n\ntype VFileLikeMessage = VFile[\"messages\"][number];\n\n/**\n * The result of compiling an MDX document.\n * Compiled content is optional, because sometimes we only need the frontmatter.\n */\nexport interface MdxArtifact<TFrontmatter = Record<string, unknown>> {\n compiled?: string | undefined;\n frontmatter: TFrontmatter;\n messages: MdxMessage[];\n}\n\nexport class MdxCompileError extends Error {\n public readonly reason: string;\n public readonly source?: string | undefined;\n public readonly ruleId?: string | undefined;\n public readonly line?: number | undefined;\n public readonly column?: number | undefined;\n public readonly place?: MdxMessagePlace | undefined;\n public readonly sourceLine?: string | undefined;\n public readonly snippet?: string | undefined;\n public readonly diagnostics: MdxMessage[];\n\n public constructor(\n reason: string,\n options: {\n source?: string | undefined;\n ruleId?: string | undefined;\n line?: number | undefined;\n column?: number | undefined;\n place?: MdxMessagePlace | undefined;\n sourceLine?: string | undefined;\n snippet?: string | undefined;\n diagnostics?: MdxMessage[] | undefined;\n cause?: unknown;\n } = {},\n ) {\n super(\n formatDiagnosticMessage(reason, {\n source: options.source,\n ruleId: options.ruleId,\n line: options.line,\n column: options.column,\n sourceLine: options.sourceLine,\n snippet: options.snippet,\n }),\n options.cause === undefined ? undefined : { cause: options.cause },\n );\n\n this.name = \"MdxCompileError\";\n this.reason = reason;\n this.source = options.source;\n this.ruleId = options.ruleId;\n this.line = options.line;\n this.column = options.column;\n this.place = options.place;\n this.sourceLine = options.sourceLine;\n this.snippet = options.snippet;\n this.diagnostics = options.diagnostics ?? [];\n }\n}\n\n/**\n * A reusable compiler for compiling MDX.\n */\nexport class MdxCompiler {\n private readonly mdxOptions: MdxJsCompileOptions;\n private readonly remarkPlugins: PluggableList;\n private readonly rehypePlugins: PluggableList;\n\n public constructor(mdxOptions: MdxJsCompileOptions = {}) {\n this.mdxOptions = mdxOptions;\n this.remarkPlugins = [remarkFrontmatterPlugin, remarkGfmPlugin];\n this.rehypePlugins = [];\n }\n\n public withRemarkPlugin<TOptions>(\n plugin: Plugin<[TOptions?], HastNode, HastNode>,\n options?: TOptions,\n ): MdxCompiler {\n if (options === undefined) {\n this.remarkPlugins.push(plugin as Pluggable);\n } else {\n this.remarkPlugins.push([plugin, options] as Pluggable);\n }\n return this;\n }\n\n public withRehypePlugin<TOptions>(\n plugin: Plugin<[TOptions?], HastNode, HastNode>,\n options?: TOptions,\n ): MdxCompiler {\n if (options === undefined) {\n this.rehypePlugins.push(plugin as Pluggable);\n } else {\n this.rehypePlugins.push([plugin, options] as Pluggable);\n }\n return this;\n }\n\n public async compile<TFrontmatterSchema extends z.ZodSchema>(\n source: MdxSource,\n { frontmatterOnly = false, mdxOptions }: MdxCompileOptions = {},\n frontmatterSchema?: TFrontmatterSchema,\n ): Promise<MdxArtifact<z.output<TFrontmatterSchema>>> {\n const sourceText = toSourceText(source);\n const vfile = new VFile({\n value: source,\n // Needed so vfile doesn't need to access fs.\n cwd: \"/\",\n path: \"/source.mdx\",\n });\n matter(vfile, { strip: true });\n\n const remarkPlugins = [\n ...this.remarkPlugins,\n ...(this.mdxOptions?.remarkPlugins ?? []),\n ...(mdxOptions?.remarkPlugins ?? []),\n ];\n const rehypePlugins = [\n ...this.rehypePlugins,\n ...(this.mdxOptions?.rehypePlugins ?? []),\n ...(mdxOptions?.rehypePlugins ?? []),\n ];\n\n let compiled: string | undefined;\n if (!frontmatterOnly) {\n try {\n const compiledFile = await compileMdxJs(vfile, {\n outputFormat: \"function-body\",\n ...(this.mdxOptions ?? {}),\n ...(mdxOptions ?? {}),\n remarkPlugins,\n rehypePlugins,\n });\n compiled = compiledFile.value.toString();\n } catch (error) {\n throw toMdxCompileError(error, sourceText, vfile.messages);\n }\n }\n\n const frontmatter =\n frontmatterSchema === undefined\n ? (vfile.data.matter ?? {})\n : (frontmatterSchema as z.ZodSchema).parse(vfile.data.matter ?? {});\n\n return {\n compiled,\n frontmatter: frontmatter as z.output<TFrontmatterSchema>,\n messages: normalizeMessages(vfile.messages, sourceText),\n };\n }\n}\n\nfunction toMdxCompileError(\n error: unknown,\n sourceText: string,\n diagnostics: readonly VFileLikeMessage[],\n): MdxCompileError {\n const details = getDiagnosticDetails(sourceText, getErrorPlace(error), error);\n\n return new MdxCompileError(getErrorReason(error), {\n source: getErrorField(error, \"source\"),\n ruleId: getErrorField(error, \"ruleId\"),\n line: details.line,\n column: details.column,\n place: details.place,\n sourceLine: details.sourceLine,\n snippet: details.snippet,\n diagnostics: normalizeMessages(diagnostics, sourceText),\n cause: error,\n });\n}\n\nfunction normalizeMessages(\n messages: readonly VFileLikeMessage[],\n sourceText: string,\n): MdxMessage[] {\n return messages.map((message) => {\n const details = getDiagnosticDetails(\n sourceText,\n toMessagePlace(message),\n message,\n );\n const reason = getErrorReason(message);\n const source = getErrorField(message, \"source\");\n const ruleId = getErrorField(message, \"ruleId\");\n const cause = getErrorCause(message);\n\n return {\n message: formatDiagnosticMessage(reason, {\n source,\n ruleId,\n line: details.line,\n column: details.column,\n sourceLine: details.sourceLine,\n snippet: details.snippet,\n causeMessage: cause?.message,\n }),\n reason,\n source,\n ruleId,\n fatal: typeof message.fatal === \"boolean\" ? message.fatal : undefined,\n line: details.line,\n column: details.column,\n place: details.place,\n sourceLine: details.sourceLine,\n snippet: details.snippet,\n cause,\n };\n });\n}\n\nfunction formatDiagnosticMessage(\n reason: string,\n options: {\n source?: string | undefined;\n ruleId?: string | undefined;\n line?: number | undefined;\n column?: number | undefined;\n sourceLine?: string | undefined;\n snippet?: string | undefined;\n causeMessage?: string | undefined;\n },\n): string {\n const origin =\n options.source === undefined\n ? undefined\n : options.ruleId === undefined\n ? options.source\n : `${options.source}:${options.ruleId}`;\n const location =\n options.line === undefined\n ? undefined\n : options.column === undefined\n ? `at ${options.line}`\n : `at ${options.line}:${options.column}`;\n\n const lines = [[reason, origin, location].filter(Boolean).join(\" \")];\n\n if (options.snippet !== undefined) {\n lines.push(`Source: ${options.snippet}`);\n }\n if (\n options.sourceLine !== undefined &&\n options.sourceLine !== options.snippet\n ) {\n lines.push(`Line: ${options.sourceLine}`);\n }\n if (\n options.causeMessage !== undefined &&\n options.causeMessage !== \"\" &&\n options.causeMessage !== reason\n ) {\n lines.push(`Cause: ${options.causeMessage}`);\n }\n\n return lines.join(\"\\n\");\n}\n\nfunction getDiagnosticDetails(\n sourceText: string,\n place: MdxMessagePlace | undefined,\n error: unknown,\n): {\n line?: number | undefined;\n column?: number | undefined;\n place?: MdxMessagePlace | undefined;\n sourceLine?: string | undefined;\n snippet?: string | undefined;\n} {\n const line = place?.start?.line ?? getErrorNumberField(error, \"line\");\n const column = place?.start?.column ?? getErrorNumberField(error, \"column\");\n const normalizedPlace =\n line === undefined && column === undefined && place === undefined\n ? undefined\n : {\n start: {\n line,\n column,\n offset: place?.start?.offset,\n },\n end:\n place?.end === undefined\n ? undefined\n : {\n line: place.end.line,\n column: place.end.column,\n offset: place.end.offset,\n },\n };\n\n return {\n line,\n column,\n place: normalizedPlace,\n sourceLine: getSourceLine(sourceText, line),\n snippet: getSourceSnippet(sourceText, normalizedPlace),\n };\n}\n\nfunction getSourceLine(\n sourceText: string,\n line: number | undefined,\n): string | undefined {\n if (line === undefined || line < 1) {\n return undefined;\n }\n return sourceText.split(/\\r?\\n/u)[line - 1];\n}\n\nfunction getSourceSnippet(\n sourceText: string,\n place: MdxMessagePlace | undefined,\n): string | undefined {\n if (place?.start?.offset !== undefined && place.end?.offset !== undefined) {\n return sourceText.slice(place.start.offset, place.end.offset) || undefined;\n }\n\n if (place?.start?.line === undefined || place.start.column === undefined) {\n return undefined;\n }\n\n const lines = sourceText.split(/\\r?\\n/u);\n const startLineIndex = place.start.line - 1;\n const endLineIndex = (place.end?.line ?? place.start.line) - 1;\n\n if (startLineIndex < 0 || startLineIndex >= lines.length) {\n return undefined;\n }\n\n const selectedLines = lines.slice(startLineIndex, endLineIndex + 1);\n if (selectedLines.length === 0) {\n return undefined;\n }\n\n selectedLines[0] = selectedLines[0].slice(place.start.column - 1);\n\n const endColumn = place.end?.column;\n if (endColumn !== undefined) {\n const lastIndex = selectedLines.length - 1;\n selectedLines[lastIndex] = selectedLines[lastIndex].slice(0, endColumn - 1);\n }\n\n return selectedLines.join(\"\\n\") || undefined;\n}\n\nfunction getErrorPlace(error: unknown): MdxMessagePlace | undefined {\n if (typeof error !== \"object\" || error === null) {\n return undefined;\n }\n\n const candidate = error as {\n place?: unknown;\n position?: unknown;\n };\n\n return toPlace(candidate.place) ?? toPlace(candidate.position);\n}\n\nfunction toMessagePlace(\n message: VFileLikeMessage,\n): MdxMessagePlace | undefined {\n return toPlace(message.place);\n}\n\nfunction toPlace(value: unknown): MdxMessagePlace | undefined {\n if (typeof value !== \"object\" || value === null) {\n return undefined;\n }\n\n const candidate = value as {\n start?: unknown;\n end?: unknown;\n line?: unknown;\n column?: unknown;\n offset?: unknown;\n };\n\n if (candidate.start !== undefined || candidate.end !== undefined) {\n return {\n start: toPoint(candidate.start),\n end: toPoint(candidate.end),\n };\n }\n\n const point = toPoint(candidate);\n return point === undefined ? undefined : { start: point };\n}\n\nfunction toPoint(value: unknown): MdxMessagePoint | undefined {\n if (typeof value !== \"object\" || value === null) {\n return undefined;\n }\n\n const candidate = value as {\n line?: unknown;\n column?: unknown;\n offset?: unknown;\n };\n const line = typeof candidate.line === \"number\" ? candidate.line : undefined;\n const column =\n typeof candidate.column === \"number\" ? candidate.column : undefined;\n const offset =\n typeof candidate.offset === \"number\" ? candidate.offset : undefined;\n\n if (line === undefined && column === undefined && offset === undefined) {\n return undefined;\n }\n\n return { line, column, offset };\n}\n\nfunction getErrorReason(error: unknown): string {\n if (error instanceof Error && error.message !== \"\") {\n return error.message;\n }\n\n const reason = getErrorField(error, \"reason\");\n if (reason !== undefined && reason !== \"\") {\n return reason;\n }\n\n return String(error);\n}\n\nfunction getErrorCause(\n error: unknown,\n): { name?: string | undefined; message: string } | undefined {\n if (typeof error !== \"object\" || error === null || !(\"cause\" in error)) {\n return undefined;\n }\n\n const cause = (error as { cause?: unknown }).cause;\n if (cause instanceof Error) {\n return {\n name: cause.name,\n message: cause.message,\n };\n }\n if (typeof cause === \"string\" && cause !== \"\") {\n return {\n message: cause,\n };\n }\n\n return undefined;\n}\n\nfunction getErrorField(\n error: unknown,\n field: \"source\" | \"ruleId\" | \"reason\",\n): string | undefined {\n if (typeof error !== \"object\" || error === null || !(field in error)) {\n return undefined;\n }\n\n const value = (error as Record<string, unknown>)[field];\n return typeof value === \"string\" && value !== \"\" ? value : undefined;\n}\n\nfunction getErrorNumberField(\n error: unknown,\n field: \"line\" | \"column\",\n): number | undefined {\n if (typeof error !== \"object\" || error === null || !(field in error)) {\n return undefined;\n }\n\n const value = (error as Record<string, unknown>)[field];\n return typeof value === \"number\" ? value : undefined;\n}\n\nfunction toSourceText(source: MdxSource): string {\n return typeof source === \"string\" ? source : new TextDecoder().decode(source);\n}\n"],"mappings":";;;;;;AAoEA,IAAa,kBAAb,cAAqC,MAAM;CACzC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CAEA,YACE,QACA,UAUI,EAAE,EACN;AACA,QACE,wBAAwB,QAAQ;GAC9B,QAAQ,QAAQ;GAChB,QAAQ,QAAQ;GAChB,MAAM,QAAQ;GACd,QAAQ,QAAQ;GAChB,YAAY,QAAQ;GACpB,SAAS,QAAQ;GAClB,CAAC,EACF,QAAQ,UAAU,KAAA,IAAY,KAAA,IAAY,EAAE,OAAO,QAAQ,OAAO,CACnE;AAED,OAAK,OAAO;AACZ,OAAK,SAAS;AACd,OAAK,SAAS,QAAQ;AACtB,OAAK,SAAS,QAAQ;AACtB,OAAK,OAAO,QAAQ;AACpB,OAAK,SAAS,QAAQ;AACtB,OAAK,QAAQ,QAAQ;AACrB,OAAK,aAAa,QAAQ;AAC1B,OAAK,UAAU,QAAQ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mjs","names":["compileMdxJs"],"sources":["../src/compiler.ts"],"sourcesContent":["import {\n compile as compileMdxJs,\n type CompileOptions as MdxJsCompileOptions,\n} from \"@mdx-js/mdx\";\nimport remarkFrontmatterPlugin from \"remark-frontmatter\";\nimport remarkGfmPlugin from \"remark-gfm\";\nimport type { Pluggable, PluggableList, Plugin } from \"unified\";\nimport { VFile } from \"vfile\";\nimport { matter } from \"vfile-matter\";\nimport type { z } from \"zod\";\n\nimport type { HastNode } from \"./types\";\n\nexport { remarkFrontmatterPlugin, remarkGfmPlugin };\n\n/**\n * Represents the source content for an MDX document.\n */\nexport type MdxSource = string | Uint8Array;\n\n/**\n * Options for compiling an MDX document.\n */\nexport interface MdxCompileOptions {\n frontmatterOnly?: boolean | undefined;\n mdxOptions?: MdxJsCompileOptions;\n}\n\nexport interface MdxMessagePoint {\n line?: number | undefined;\n column?: number | undefined;\n offset?: number | undefined;\n}\n\nexport interface MdxMessagePlace {\n start?: MdxMessagePoint | undefined;\n end?: MdxMessagePoint | undefined;\n}\n\nexport interface MdxMessage {\n message: string;\n reason: string;\n source?: string | undefined;\n ruleId?: string | undefined;\n fatal?: boolean | undefined;\n line?: number | undefined;\n column?: number | undefined;\n place?: MdxMessagePlace | undefined;\n sourceLine?: string | undefined;\n snippet?: string | undefined;\n sourcePointer?: string | undefined;\n hint?: string | undefined;\n cause?: {\n name?: string | undefined;\n message: string;\n };\n}\n\ntype VFileLikeMessage = VFile[\"messages\"][number];\n\ninterface MdxDiagnosticSourceContext {\n originalSourceText: string;\n lineOffset: number;\n}\n\n/**\n * The result of compiling an MDX document.\n * Compiled content is optional, because sometimes we only need the frontmatter.\n */\nexport interface MdxArtifact<TFrontmatter = Record<string, unknown>> {\n compiled?: string | undefined;\n frontmatter: TFrontmatter;\n messages: MdxMessage[];\n}\n\nexport class MdxCompileError extends Error {\n public readonly reason: string;\n public readonly source?: string | undefined;\n public readonly ruleId?: string | undefined;\n public readonly line?: number | undefined;\n public readonly column?: number | undefined;\n public readonly place?: MdxMessagePlace | undefined;\n public readonly sourceLine?: string | undefined;\n public readonly snippet?: string | undefined;\n public readonly sourcePointer?: string | undefined;\n public readonly hint?: string | undefined;\n public readonly diagnostics: MdxMessage[];\n\n public constructor(\n reason: string,\n options: {\n source?: string | undefined;\n ruleId?: string | undefined;\n line?: number | undefined;\n column?: number | undefined;\n place?: MdxMessagePlace | undefined;\n sourceLine?: string | undefined;\n snippet?: string | undefined;\n sourcePointer?: string | undefined;\n hint?: string | undefined;\n causeMessage?: string | undefined;\n diagnostics?: MdxMessage[] | undefined;\n cause?: unknown;\n } = {},\n ) {\n super(\n formatDiagnosticMessage(reason, {\n source: options.source,\n ruleId: options.ruleId,\n line: options.line,\n column: options.column,\n sourceLine: options.sourceLine,\n snippet: options.snippet,\n sourcePointer: options.sourcePointer,\n hint: options.hint,\n causeMessage: options.causeMessage,\n }),\n options.cause === undefined ? undefined : { cause: options.cause },\n );\n\n this.name = \"MdxCompileError\";\n this.reason = reason;\n this.source = options.source;\n this.ruleId = options.ruleId;\n this.line = options.line;\n this.column = options.column;\n this.place = options.place;\n this.sourceLine = options.sourceLine;\n this.snippet = options.snippet;\n this.sourcePointer = options.sourcePointer;\n this.hint = options.hint;\n this.diagnostics = options.diagnostics ?? [];\n }\n}\n\n/**\n * A reusable compiler for compiling MDX.\n */\nexport class MdxCompiler {\n private readonly mdxOptions: MdxJsCompileOptions;\n private readonly remarkPlugins: PluggableList;\n private readonly rehypePlugins: PluggableList;\n\n public constructor(mdxOptions: MdxJsCompileOptions = {}) {\n this.mdxOptions = mdxOptions;\n this.remarkPlugins = [remarkFrontmatterPlugin, remarkGfmPlugin];\n this.rehypePlugins = [];\n }\n\n public withRemarkPlugin<TOptions>(\n plugin: Plugin<[TOptions?], HastNode, HastNode>,\n options?: TOptions,\n ): MdxCompiler {\n if (options === undefined) {\n this.remarkPlugins.push(plugin as Pluggable);\n } else {\n this.remarkPlugins.push([plugin, options] as Pluggable);\n }\n return this;\n }\n\n public withRehypePlugin<TOptions>(\n plugin: Plugin<[TOptions?], HastNode, HastNode>,\n options?: TOptions,\n ): MdxCompiler {\n if (options === undefined) {\n this.rehypePlugins.push(plugin as Pluggable);\n } else {\n this.rehypePlugins.push([plugin, options] as Pluggable);\n }\n return this;\n }\n\n public async compile<TFrontmatterSchema extends z.ZodSchema>(\n source: MdxSource,\n { frontmatterOnly = false, mdxOptions }: MdxCompileOptions = {},\n frontmatterSchema?: TFrontmatterSchema,\n ): Promise<MdxArtifact<z.output<TFrontmatterSchema>>> {\n const sourceText = toSourceText(source);\n const vfile = new VFile({\n value: source,\n // Needed so vfile doesn't need to access fs.\n cwd: \"/\",\n path: \"/source.mdx\",\n });\n matter(vfile, { strip: true });\n const compileSourceText = toSourceText(vfile.value as MdxSource);\n const sourceContext = createDiagnosticSourceContext(\n sourceText,\n compileSourceText,\n );\n\n const remarkPlugins = [\n ...this.remarkPlugins,\n ...(this.mdxOptions?.remarkPlugins ?? []),\n ...(mdxOptions?.remarkPlugins ?? []),\n ];\n const rehypePlugins = [\n ...this.rehypePlugins,\n ...(this.mdxOptions?.rehypePlugins ?? []),\n ...(mdxOptions?.rehypePlugins ?? []),\n ];\n\n let compiled: string | undefined;\n if (!frontmatterOnly) {\n try {\n const compiledFile = await compileMdxJs(vfile, {\n outputFormat: \"function-body\",\n ...(this.mdxOptions ?? {}),\n ...(mdxOptions ?? {}),\n remarkPlugins,\n rehypePlugins,\n });\n compiled = compiledFile.value.toString();\n } catch (error) {\n throw toMdxCompileError(error, sourceContext, vfile.messages);\n }\n }\n\n const frontmatter =\n frontmatterSchema === undefined\n ? (vfile.data.matter ?? {})\n : (frontmatterSchema as z.ZodSchema).parse(vfile.data.matter ?? {});\n\n return {\n compiled,\n frontmatter: frontmatter as z.output<TFrontmatterSchema>,\n messages: normalizeMessages(vfile.messages, sourceContext),\n };\n }\n}\n\nfunction toMdxCompileError(\n error: unknown,\n sourceContext: MdxDiagnosticSourceContext,\n diagnostics: readonly VFileLikeMessage[],\n): MdxCompileError {\n const details = getDiagnosticDetails(\n sourceContext,\n getErrorPlace(error),\n error,\n );\n const cause = getErrorCause(error);\n\n return new MdxCompileError(getErrorReason(error), {\n source: getErrorField(error, \"source\"),\n ruleId: getErrorField(error, \"ruleId\"),\n line: details.line,\n column: details.column,\n place: details.place,\n sourceLine: details.sourceLine,\n snippet: details.snippet,\n sourcePointer: details.sourcePointer,\n hint: details.hint,\n causeMessage: cause?.message,\n diagnostics: normalizeMessages(diagnostics, sourceContext),\n cause: error,\n });\n}\n\nfunction normalizeMessages(\n messages: readonly VFileLikeMessage[],\n sourceContext: MdxDiagnosticSourceContext,\n): MdxMessage[] {\n return messages.map((message) => {\n const details = getDiagnosticDetails(\n sourceContext,\n toMessagePlace(message),\n message,\n );\n const reason = getErrorReason(message);\n const source = getErrorField(message, \"source\");\n const ruleId = getErrorField(message, \"ruleId\");\n const cause = getErrorCause(message);\n\n return {\n message: formatDiagnosticMessage(reason, {\n source,\n ruleId,\n line: details.line,\n column: details.column,\n sourceLine: details.sourceLine,\n snippet: details.snippet,\n sourcePointer: details.sourcePointer,\n hint: details.hint,\n causeMessage: cause?.message,\n }),\n reason,\n source,\n ruleId,\n fatal: typeof message.fatal === \"boolean\" ? message.fatal : undefined,\n line: details.line,\n column: details.column,\n place: details.place,\n sourceLine: details.sourceLine,\n snippet: details.snippet,\n sourcePointer: details.sourcePointer,\n hint: details.hint,\n cause,\n };\n });\n}\n\nfunction formatDiagnosticMessage(\n reason: string,\n options: {\n source?: string | undefined;\n ruleId?: string | undefined;\n line?: number | undefined;\n column?: number | undefined;\n sourceLine?: string | undefined;\n snippet?: string | undefined;\n sourcePointer?: string | undefined;\n hint?: string | undefined;\n causeMessage?: string | undefined;\n },\n): string {\n const origin =\n options.source === undefined\n ? undefined\n : options.ruleId === undefined\n ? options.source\n : `${options.source}:${options.ruleId}`;\n const location =\n options.line === undefined\n ? undefined\n : options.column === undefined\n ? `at ${options.line}`\n : `at ${options.line}:${options.column}`;\n\n const lines = [[reason, origin, location].filter(Boolean).join(\" \")];\n\n if (options.snippet !== undefined) {\n lines.push(`Source: ${options.snippet}`);\n }\n if (\n options.sourceLine !== undefined &&\n options.sourceLine !== options.snippet\n ) {\n lines.push(`Line: ${options.sourceLine}`);\n if (options.sourcePointer !== undefined) {\n lines.push(` ${options.sourcePointer}`);\n }\n }\n if (\n options.causeMessage !== undefined &&\n options.causeMessage !== \"\" &&\n options.causeMessage !== reason\n ) {\n lines.push(`Cause: ${options.causeMessage}`);\n }\n if (options.hint !== undefined) {\n lines.push(`Hint: ${options.hint}`);\n }\n\n return lines.join(\"\\n\");\n}\n\nfunction getDiagnosticDetails(\n sourceContext: MdxDiagnosticSourceContext,\n place: MdxMessagePlace | undefined,\n error: unknown,\n): {\n line?: number | undefined;\n column?: number | undefined;\n place?: MdxMessagePlace | undefined;\n sourceLine?: string | undefined;\n snippet?: string | undefined;\n sourcePointer?: string | undefined;\n hint?: string | undefined;\n} {\n const compileLine = place?.start?.line ?? getErrorNumberField(error, \"line\");\n let line =\n compileLine === undefined\n ? undefined\n : compileLine + sourceContext.lineOffset;\n let column = place?.start?.column ?? getErrorNumberField(error, \"column\");\n let normalizedPlace = mapPlaceToOriginalSource(\n place === undefined && compileLine === undefined && column === undefined\n ? undefined\n : {\n start: {\n line: compileLine,\n column,\n offset: place?.start?.offset,\n },\n end:\n place?.end === undefined\n ? undefined\n : {\n line: place.end.line,\n column: place.end.column,\n offset: place.end.offset,\n },\n },\n sourceContext.lineOffset,\n );\n let sourceLine = getSourceLine(sourceContext.originalSourceText, line);\n let snippet = getSourceSnippet(\n sourceContext.originalSourceText,\n normalizedPlace,\n );\n let sourcePointer = getSourcePointer(column);\n let hint: string | undefined;\n\n const refinedExpressionContext = getMdxExpressionContext(\n sourceContext.originalSourceText,\n {\n line,\n column,\n sourceLine,\n snippet,\n error,\n },\n );\n\n if (refinedExpressionContext !== undefined) {\n line = refinedExpressionContext.line;\n column = refinedExpressionContext.column;\n sourceLine = refinedExpressionContext.sourceLine;\n snippet = refinedExpressionContext.snippet;\n sourcePointer = refinedExpressionContext.sourcePointer;\n hint = refinedExpressionContext.hint;\n normalizedPlace = {\n start: {\n line,\n column,\n offset: undefined,\n },\n end: undefined,\n };\n }\n\n return {\n line,\n column,\n place: normalizedPlace,\n sourceLine,\n snippet,\n sourcePointer,\n hint,\n };\n}\n\nfunction getMdxExpressionContext(\n sourceText: string,\n options: {\n line?: number | undefined;\n column?: number | undefined;\n sourceLine?: string | undefined;\n snippet?: string | undefined;\n error: unknown;\n },\n):\n | {\n line: number;\n column: number;\n sourceLine: string;\n snippet: string;\n sourcePointer: string;\n hint?: string | undefined;\n }\n | undefined {\n if (!shouldRefineMdxExpressionContext(options)) {\n return undefined;\n }\n\n const candidate = findSuspiciousBraceExpression(\n sourceText,\n options.line,\n options.column,\n );\n if (candidate === undefined) {\n return undefined;\n }\n\n return {\n line: candidate.line,\n column: candidate.column,\n sourceLine: candidate.sourceLine,\n snippet: candidate.snippet,\n sourcePointer: getSourcePointer(candidate.column) ?? \"^\",\n hint:\n getErrorCause(options.error)?.message ===\n \"Unexpected content after expression\"\n ? \"MDX treats `{...}` as JavaScript. If you meant literal braces in text, escape them or wrap the text in code.\"\n : undefined,\n };\n}\n\nfunction shouldRefineMdxExpressionContext(options: {\n sourceLine?: string | undefined;\n snippet?: string | undefined;\n error: unknown;\n}): boolean {\n const trimmedSourceLine = options.sourceLine?.trim();\n\n return (\n isMdxExpressionError(options.error) &&\n getErrorCause(options.error)?.message ===\n \"Unexpected content after expression\" &&\n (options.sourceLine === undefined ||\n options.sourceLine.trim() === \"\" ||\n options.snippet === undefined) &&\n !(trimmedSourceLine?.startsWith(\"{\") && trimmedSourceLine.endsWith(\"}\"))\n );\n}\n\nfunction getSourceLine(\n sourceText: string,\n line: number | undefined,\n): string | undefined {\n if (line === undefined || line < 1) {\n return undefined;\n }\n return sourceText.split(/\\r?\\n/u)[line - 1];\n}\n\nfunction getSourceSnippet(\n sourceText: string,\n place: MdxMessagePlace | undefined,\n): string | undefined {\n if (place?.start?.offset !== undefined && place.end?.offset !== undefined) {\n return sourceText.slice(place.start.offset, place.end.offset) || undefined;\n }\n\n if (place?.start?.line === undefined || place.start.column === undefined) {\n return undefined;\n }\n\n if (place.end === undefined) {\n const lines = sourceText.split(/\\r?\\n/u);\n const line = lines[place.start.line - 1];\n if (line === undefined) {\n return undefined;\n }\n\n const character = line.at(place.start.column - 1);\n return character === undefined || character.trim() === \"\"\n ? undefined\n : character;\n }\n\n const lines = sourceText.split(/\\r?\\n/u);\n const startLineIndex = place.start.line - 1;\n const endLineIndex = (place.end?.line ?? place.start.line) - 1;\n\n if (startLineIndex < 0 || startLineIndex >= lines.length) {\n return undefined;\n }\n\n const selectedLines = lines.slice(startLineIndex, endLineIndex + 1);\n if (selectedLines.length === 0) {\n return undefined;\n }\n\n selectedLines[0] = selectedLines[0].slice(place.start.column - 1);\n\n const endColumn = place.end?.column;\n if (endColumn !== undefined) {\n const lastIndex = selectedLines.length - 1;\n selectedLines[lastIndex] = selectedLines[lastIndex].slice(0, endColumn - 1);\n }\n\n return selectedLines.join(\"\\n\") || undefined;\n}\n\nfunction getSourcePointer(column: number | undefined): string | undefined {\n if (column === undefined || column < 1) {\n return undefined;\n }\n\n return `${\" \".repeat(column - 1)}^`;\n}\n\nfunction mapPlaceToOriginalSource(\n place: MdxMessagePlace | undefined,\n lineOffset: number,\n): MdxMessagePlace | undefined {\n if (place === undefined) {\n return undefined;\n }\n\n return {\n start: mapPointToOriginalSource(place.start, lineOffset),\n end: mapPointToOriginalSource(place.end, lineOffset),\n };\n}\n\nfunction mapPointToOriginalSource(\n point: MdxMessagePoint | undefined,\n lineOffset: number,\n): MdxMessagePoint | undefined {\n if (point === undefined) {\n return undefined;\n }\n\n return {\n line: point.line === undefined ? undefined : point.line + lineOffset,\n column: point.column,\n offset: lineOffset === 0 ? point.offset : undefined,\n };\n}\n\nfunction findSuspiciousBraceExpression(\n sourceText: string,\n line: number | undefined,\n column: number | undefined,\n):\n | {\n line: number;\n column: number;\n sourceLine: string;\n snippet: string;\n }\n | undefined {\n const lines = sourceText.split(/\\r?\\n/u);\n const searchLines = getNearbyLineNumbers(line, lines.length, 2);\n let bestMatch:\n | {\n line: number;\n column: number;\n sourceLine: string;\n snippet: string;\n score: number;\n }\n | undefined;\n\n for (const lineNumber of searchLines) {\n const sourceLine = lines[lineNumber - 1];\n if (sourceLine === undefined || sourceLine.trim() === \"\") {\n continue;\n }\n\n const expression = findLineBraceExpression(sourceLine, lineNumber, column);\n if (expression === undefined) {\n continue;\n }\n\n const lineDistance = line === undefined ? 0 : Math.abs(lineNumber - line);\n const score = lineDistance * 10 + expression.distance;\n\n if (bestMatch === undefined || score < bestMatch.score) {\n bestMatch = {\n ...expression,\n score,\n };\n }\n }\n\n return bestMatch;\n}\n\nfunction getNearbyLineNumbers(\n line: number | undefined,\n totalLines: number,\n radius: number,\n): number[] {\n if (line === undefined) {\n return Array.from({ length: totalLines }, (_, index) => index + 1);\n }\n\n const lineNumbers: number[] = [];\n for (let distance = 0; distance <= radius; distance++) {\n const before = line - distance;\n if (before >= 1) {\n lineNumbers.push(before);\n }\n\n if (distance === 0) {\n continue;\n }\n\n const after = line + distance;\n if (after <= totalLines) {\n lineNumbers.push(after);\n }\n }\n\n return lineNumbers;\n}\n\nfunction findLineBraceExpression(\n sourceLine: string,\n line: number,\n column: number | undefined,\n):\n | {\n line: number;\n column: number;\n sourceLine: string;\n snippet: string;\n distance: number;\n }\n | undefined {\n let bestMatch:\n | {\n line: number;\n column: number;\n sourceLine: string;\n snippet: string;\n distance: number;\n }\n | undefined;\n\n for (const match of sourceLine.matchAll(/\\{[^{}\\n]+\\}/gu)) {\n const braceStart = match.index;\n if (braceStart === undefined) {\n continue;\n }\n\n const expanded = expandBraceExpression(sourceLine, braceStart);\n if (expanded === undefined) {\n continue;\n }\n\n const distance =\n column === undefined ? 0 : Math.abs(braceStart + 1 - column);\n if (bestMatch === undefined || distance < bestMatch.distance) {\n bestMatch = {\n line,\n column: braceStart + 1,\n sourceLine,\n snippet: expanded,\n distance,\n };\n }\n }\n\n return bestMatch;\n}\n\nfunction expandBraceExpression(\n sourceLine: string,\n braceStart: number,\n): string | undefined {\n const braceEnd = sourceLine.indexOf(\"}\", braceStart);\n if (braceEnd === -1) {\n return undefined;\n }\n\n let start = braceStart;\n while (start > 0 && /[A-Za-z0-9_]/u.test(sourceLine[start - 1])) {\n start--;\n }\n\n let end = braceEnd + 1;\n while (end < sourceLine.length) {\n while (end < sourceLine.length && /[A-Za-z0-9_]/u.test(sourceLine[end])) {\n end++;\n }\n\n if (sourceLine[end] !== \"{\") {\n break;\n }\n\n const chainedEnd = sourceLine.indexOf(\"}\", end);\n if (chainedEnd === -1) {\n break;\n }\n end = chainedEnd + 1;\n }\n\n return sourceLine.slice(start, end) || undefined;\n}\n\nfunction isMdxExpressionError(error: unknown): boolean {\n return (\n getErrorField(error, \"source\") === \"micromark-extension-mdx-expression\" &&\n getErrorField(error, \"ruleId\") === \"acorn\"\n );\n}\n\nfunction createDiagnosticSourceContext(\n originalSourceText: string,\n compileSourceText: string,\n): MdxDiagnosticSourceContext {\n return {\n originalSourceText,\n lineOffset: getSourceLineOffset(originalSourceText, compileSourceText),\n };\n}\n\nfunction getSourceLineOffset(\n originalSourceText: string,\n compileSourceText: string,\n): number {\n const originalLines = originalSourceText.split(/\\r?\\n/u);\n const compileLines = compileSourceText.split(/\\r?\\n/u);\n const maxOffset = originalLines.length - compileLines.length;\n\n for (let offset = 0; offset <= maxOffset; offset++) {\n let isMatch = true;\n for (let index = 0; index < compileLines.length; index++) {\n if (originalLines[offset + index] !== compileLines[index]) {\n isMatch = false;\n break;\n }\n }\n\n if (isMatch) {\n return offset;\n }\n }\n\n return maxOffset > 0 ? maxOffset : 0;\n}\n\nfunction getErrorPlace(error: unknown): MdxMessagePlace | undefined {\n if (typeof error !== \"object\" || error === null) {\n return undefined;\n }\n\n const candidate = error as {\n place?: unknown;\n position?: unknown;\n };\n\n return toPlace(candidate.place) ?? toPlace(candidate.position);\n}\n\nfunction toMessagePlace(\n message: VFileLikeMessage,\n): MdxMessagePlace | undefined {\n return toPlace(message.place);\n}\n\nfunction toPlace(value: unknown): MdxMessagePlace | undefined {\n if (typeof value !== \"object\" || value === null) {\n return undefined;\n }\n\n const candidate = value as {\n start?: unknown;\n end?: unknown;\n line?: unknown;\n column?: unknown;\n offset?: unknown;\n };\n\n if (candidate.start !== undefined || candidate.end !== undefined) {\n return {\n start: toPoint(candidate.start),\n end: toPoint(candidate.end),\n };\n }\n\n const point = toPoint(candidate);\n return point === undefined ? undefined : { start: point };\n}\n\nfunction toPoint(value: unknown): MdxMessagePoint | undefined {\n if (typeof value !== \"object\" || value === null) {\n return undefined;\n }\n\n const candidate = value as {\n line?: unknown;\n column?: unknown;\n offset?: unknown;\n };\n const line = typeof candidate.line === \"number\" ? candidate.line : undefined;\n const column =\n typeof candidate.column === \"number\" ? candidate.column : undefined;\n const offset =\n typeof candidate.offset === \"number\" ? candidate.offset : undefined;\n\n if (line === undefined && column === undefined && offset === undefined) {\n return undefined;\n }\n\n return { line, column, offset };\n}\n\nfunction getErrorReason(error: unknown): string {\n if (error instanceof Error && error.message !== \"\") {\n return error.message;\n }\n\n const reason = getErrorField(error, \"reason\");\n if (reason !== undefined && reason !== \"\") {\n return reason;\n }\n\n return String(error);\n}\n\nfunction getErrorCause(\n error: unknown,\n): { name?: string | undefined; message: string } | undefined {\n if (typeof error !== \"object\" || error === null || !(\"cause\" in error)) {\n return undefined;\n }\n\n const cause = (error as { cause?: unknown }).cause;\n if (cause instanceof Error) {\n return {\n name: cause.name,\n message: cause.message,\n };\n }\n if (typeof cause === \"string\" && cause !== \"\") {\n return {\n message: cause,\n };\n }\n\n return undefined;\n}\n\nfunction getErrorField(\n error: unknown,\n field: \"source\" | \"ruleId\" | \"reason\",\n): string | undefined {\n if (typeof error !== \"object\" || error === null || !(field in error)) {\n return undefined;\n }\n\n const value = (error as Record<string, unknown>)[field];\n return typeof value === \"string\" && value !== \"\" ? value : undefined;\n}\n\nfunction getErrorNumberField(\n error: unknown,\n field: \"line\" | \"column\",\n): number | undefined {\n if (typeof error !== \"object\" || error === null || !(field in error)) {\n return undefined;\n }\n\n const value = (error as Record<string, unknown>)[field];\n return typeof value === \"number\" ? value : undefined;\n}\n\nfunction toSourceText(source: MdxSource): string {\n return typeof source === \"string\" ? source : new TextDecoder().decode(source);\n}\n"],"mappings":";;;;;;AA2EA,IAAa,kBAAb,cAAqC,MAAM;CACzC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CAEA,YACE,QACA,UAaI,EAAE,EACN;AACA,QACE,wBAAwB,QAAQ;GAC9B,QAAQ,QAAQ;GAChB,QAAQ,QAAQ;GAChB,MAAM,QAAQ;GACd,QAAQ,QAAQ;GAChB,YAAY,QAAQ;GACpB,SAAS,QAAQ;GACjB,eAAe,QAAQ;GACvB,MAAM,QAAQ;GACd,cAAc,QAAQ;GACvB,CAAC,EACF,QAAQ,UAAU,KAAA,IAAY,KAAA,IAAY,EAAE,OAAO,QAAQ,OAAO,CACnE;AAED,OAAK,OAAO;AACZ,OAAK,SAAS;AACd,OAAK,SAAS,QAAQ;AACtB,OAAK,SAAS,QAAQ;AACtB,OAAK,OAAO,QAAQ;AACpB,OAAK,SAAS,QAAQ;AACtB,OAAK,QAAQ,QAAQ;AACrB,OAAK,aAAa,QAAQ;AAC1B,OAAK,UAAU,QAAQ;AACvB,OAAK,gBAAgB,QAAQ;AAC7B,OAAK,OAAO,QAAQ;AACpB,OAAK,cAAc,QAAQ,eAAe,EAAE;;;;;;AAOhD,IAAa,cAAb,MAAyB;CACvB;CACA;CACA;CAEA,YAAmB,aAAkC,EAAE,EAAE;AACvD,OAAK,aAAa;AAClB,OAAK,gBAAgB,CAAC,yBAAyB,gBAAgB;AAC/D,OAAK,gBAAgB,EAAE;;CAGzB,iBACE,QACA,SACa;AACb,MAAI,YAAY,KAAA,EACd,MAAK,cAAc,KAAK,OAAoB;M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ACnB,QAAO;EACL,MAAM,MAAM;EACZ,SAAS,MAAM;EAChB;AAEH,KAAI,OAAO,UAAU,YAAY,UAAU,GACzC,QAAO,EACL,SAAS,OACV;;AAML,SAAS,cACP,OACA,OACoB;AACpB,KAAI,OAAO,UAAU,YAAY,UAAU,QAAQ,EAAE,SAAS,OAC5D;CAGF,MAAM,QAAS,MAAkC;AACjD,QAAO,OAAO,UAAU,YAAY,UAAU,KAAK,QAAQ,KAAA;;AAG7D,SAAS,oBACP,OACA,OACoB;AACpB,KAAI,OAAO,UAAU,YAAY,UAAU,QAAQ,EAAE,SAAS,OAC5D;CAGF,MAAM,QAAS,MAAkC;AACjD,QAAO,OAAO,UAAU,WAAW,QAAQ,KAAA;;AAG7C,SAAS,aAAa,QAA2B;AAC/C,QAAO,OAAO,WAAW,WAAW,SAAS,IAAI,aAAa,CAAC,OAAO,OAAO"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@temelj/mdx",
3
- "version": "0.11.1",
3
+ "version": "0.11.2",
4
4
  "description": "MDX processing utilities.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -25,11 +25,11 @@
25
25
  "github-slugger": "^2.0.0",
26
26
  "hast": "^1.0.0",
27
27
  "hast-util-to-string": "^3.0.1",
28
+ "rehype-katex": "^7.0.1",
28
29
  "remark-frontmatter": "^5.0.0",
29
30
  "remark-gfm": "^4.0.1",
30
31
  "remark-math": "^6.0.0",
31
32
  "remark-parse": "^11.0.0",
32
- "rehype-katex": "^7.0.1",
33
33
  "shiki": "^4.0.2",
34
34
  "unified": "^11.0.5",
35
35
  "unist-util-remove": "^4.0.0",