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