@ai-matrx/content-ir 0.23.0 → 0.24.1

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/dist/surfaces.cjs CHANGED
@@ -1784,7 +1784,8 @@ var KIND_KEY_TEXT_G = /(?<!\\)"__kind"\s*:/g;
1784
1784
  function findBrokenKindJsonRegions(source, options = {}) {
1785
1785
  const broken = [];
1786
1786
  if (!KIND_KEY_TEXT.test(source)) return broken;
1787
- const endOf = lazyJsonEnds(source);
1787
+ const mayHaveBalancedValue = source.includes("}") || source.includes("]");
1788
+ const endOf = mayHaveBalancedValue ? lazyJsonEnds(source) : null;
1788
1789
  const keys = [];
1789
1790
  KIND_KEY_TEXT_G.lastIndex = 0;
1790
1791
  for (let m = KIND_KEY_TEXT_G.exec(source); m; m = KIND_KEY_TEXT_G.exec(source)) keys.push(m.index);
@@ -1818,7 +1819,7 @@ function findBrokenKindJsonRegions(source, options = {}) {
1818
1819
  break;
1819
1820
  }
1820
1821
  if (verdict.at <= key) continue;
1821
- const end = endOf(start);
1822
+ const end = endOf?.(start) ?? null;
1822
1823
  if (end !== null && lenientJson(source.slice(start, end))) {
1823
1824
  broken.push({ start, end, content: source.slice(start, end) });
1824
1825
  start = end - 1;
@@ -2165,6 +2166,7 @@ function quotedCodeRanges(text) {
2165
2166
  }
2166
2167
  function noteUnreadableKinds(text) {
2167
2168
  if (!hasKindKey(text)) return text;
2169
+ if (!text.includes("}") && !text.includes("]")) return text;
2168
2170
  const quoted = quotedCodeRanges(text);
2169
2171
  const fences = findCodeRanges(text).filter((range) => range.kind === "fence");
2170
2172
  const spans = [];
@@ -2306,7 +2308,8 @@ ${out}`;
2306
2308
  ${out}`;
2307
2309
  }
2308
2310
  function convertRegions(text, excludeLiteralContexts, options, leftover = (piece) => piece) {
2309
- const spans = findKindCarryingJsonValues(text, { excludeLiteralContexts }).map(
2311
+ const completeRegions = text.includes("}") || text.includes("]") ? findKindCarryingJsonValues(text, { excludeLiteralContexts }) : [];
2312
+ const spans = completeRegions.map(
2310
2313
  (region) => ({ start: region.start, end: region.end, md: valueMarkdown(region.value) })
2311
2314
  );
2312
2315
  if (options.broken === "note") {
@@ -2361,6 +2364,7 @@ function convertRegions(text, excludeLiteralContexts, options, leftover = (piece
2361
2364
  var JSON_FENCE_LANGS2 = /* @__PURE__ */ new Set(["", "json", "jsonc", "json5"]);
2362
2365
  var QUOTE_PREFIX = /^(?: {0,3}> ?)*/;
2363
2366
  function convertKindFences(text, options) {
2367
+ if (!text.includes("`") && !text.includes("~")) return text;
2364
2368
  const fences = findCodeRanges(text).filter((range) => range.kind === "fence");
2365
2369
  let out = text;
2366
2370
  for (let i = fences.length - 1; i >= 0; i--) {
@@ -2415,6 +2419,7 @@ function convertFrontMatterKind(text, options) {
2415
2419
  return md + openAfter(text.slice(end));
2416
2420
  }
2417
2421
  function convertCommentKinds(text, options) {
2422
+ if (!text.includes("<!--")) return text;
2418
2423
  const quoted = quotedCodeRanges(text);
2419
2424
  const comments = [...text.matchAll(/<!--[\s\S]*?(?:-->|$)/g)].filter(
2420
2425
  (m) => hasKindKey(m[0]) && !quoted.some(([a, b]) => m.index >= a && m.index < b)