@hawkeyexl/manni 2.8.3 → 2.8.5

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.
@@ -75,7 +75,7 @@ import {
75
75
  withValueAt,
76
76
  writeEncryptionKey,
77
77
  writeFileAtomic
78
- } from "./chunk-KGI7B6DD.js";
78
+ } from "./chunk-4UI4MDAG.js";
79
79
 
80
80
  // src/meta/core/reencrypt.ts
81
81
  import { extname } from "node:path";
@@ -1036,10 +1036,14 @@ function fenceSpanAt(text, line, format) {
1036
1036
  if (!block || block.line !== line) return void 0;
1037
1037
  return { start: line, end: lineAt(text, block.end) };
1038
1038
  }
1039
- function insideFence(text, bodyOffset, line, format) {
1040
- return fencedBlocks(text, bodyOffset, format).some(
1041
- (block) => line > block.line && line <= lineAt(text, block.end)
1039
+ function fenceAround(text, bodyOffset, line, format) {
1040
+ const block = fencedBlocks(text, bodyOffset, format).find(
1041
+ (b) => line > b.line && line <= lineAt(text, b.end)
1042
1042
  );
1043
+ return block === void 0 ? void 0 : { start: block.line, end: lineAt(text, block.end) };
1044
+ }
1045
+ function insideFence(text, bodyOffset, line, format) {
1046
+ return fenceAround(text, bodyOffset, line, format) !== void 0;
1043
1047
  }
1044
1048
  function unitHolding(text, line, format, body) {
1045
1049
  const textOf = (n) => lineText(text, offsetOfLine(text, n), lineEnd(text, offsetOfLine(text, n)));
@@ -1722,9 +1726,12 @@ function spellElsewhere(spans) {
1722
1726
  const last = named4.pop() ?? "";
1723
1727
  return named4.length === 0 ? `${noun} ${last}` : `${noun} ${named4.join(", ")} and ${last}`;
1724
1728
  }
1725
- function rowsAt(line, lines, recorded, named4) {
1729
+ function spanOf(line, recorded) {
1726
1730
  const width = recorded === void 0 ? 1 : Math.max(1, recorded.end - recorded.start + 1);
1727
- const end = line + width - 1;
1731
+ return { start: line, end: line + width - 1 };
1732
+ }
1733
+ function rowsAt(line, lines, recorded, named4) {
1734
+ const end = spanOf(line, recorded).end;
1728
1735
  if (end > lines.length) return "table-short";
1729
1736
  for (let n = line; n <= end; n++) {
1730
1737
  if (!isTableRow(lines[n - 1] ?? "")) return "table-short";
@@ -1743,7 +1750,11 @@ function unitOrWhy(page, line, lines, recorded, named4 = false) {
1743
1750
  if (block !== void 0) {
1744
1751
  return { lines: block, kind: "block", text: lines.slice(block.start - 1, block.end) };
1745
1752
  }
1746
- if (insideFence(page.content, page.bodyOffset, line, page.format)) return "fenced";
1753
+ const around = fenceAround(page.content, page.bodyOffset, line, page.format);
1754
+ if (around !== void 0) {
1755
+ const span2 = spanOf(line, recorded);
1756
+ return span2.end < around.end ? { lines: span2, kind: "fenced-lines", text: lines.slice(span2.start - 1, span2.end) } : "fence-crossed";
1757
+ }
1747
1758
  if (isTableRow(own)) return rowsAt(line, lines, recorded, named4);
1748
1759
  const paragraph = paragraphAfter(
1749
1760
  page.content,
@@ -4213,8 +4224,8 @@ function sayNoUnit(reason) {
4213
4224
  return "the line is outside the page body";
4214
4225
  case "blank":
4215
4226
  return "the line is blank";
4216
- case "fenced":
4217
- return "the line sits inside a fenced block";
4227
+ case "fence-crossed":
4228
+ return "the claim's lines are not all inside one fenced block";
4218
4229
  case "marker":
4219
4230
  return "that line now holds a cite marker, not claim text";
4220
4231
  case "not-a-paragraph":
@@ -4225,6 +4236,9 @@ function sayNoUnit(reason) {
4225
4236
  return "that line is a table rule, not claim text";
4226
4237
  }
4227
4238
  }
4239
+ function unitNoun(kind) {
4240
+ return kind === "fenced-lines" ? "fenced text" : kind;
4241
+ }
4228
4242
  function settles(plan) {
4229
4243
  switch (plan.kind) {
4230
4244
  case "claim-moved":
@@ -4270,8 +4284,21 @@ function apply2(content, format, plan) {
4270
4284
  // The move is a page rewrite, applied to the whole page before any splice.
4271
4285
  case "marker-moved":
4272
4286
  return content;
4273
- case "source-moved":
4274
- return spliceEntryField(content, format, index, ["source", "lines"], plan.lines);
4287
+ case "source-moved": {
4288
+ let out = spliceEntryField(content, format, index, ["source", "lines"], plan.lines);
4289
+ out = spliceEntryField(
4290
+ out,
4291
+ format,
4292
+ index,
4293
+ ["source", "integrity"],
4294
+ plan.minted.source.integrity
4295
+ );
4296
+ const commit = plan.minted.source["commit-sha"];
4297
+ if (commit !== void 0) {
4298
+ out = spliceEntryField(out, format, index, ["source", "commit-sha"], commit);
4299
+ }
4300
+ return out;
4301
+ }
4275
4302
  case "claim-accepted": {
4276
4303
  let out = spliceEntryField(content, format, index, ["claim", "integrity"], plan.pin);
4277
4304
  if (plan.lines !== void 0) {
@@ -4331,6 +4358,9 @@ function applyToEntry(entry, plan) {
4331
4358
  const source = end("source");
4332
4359
  if (source === void 0) return false;
4333
4360
  source.lines = plan.lines;
4361
+ source.integrity = plan.minted.source.integrity;
4362
+ const commit = plan.minted.source["commit-sha"];
4363
+ if (commit !== void 0) source["commit-sha"] = commit;
4334
4364
  return true;
4335
4365
  }
4336
4366
  case "claim-accepted": {
@@ -4684,8 +4714,33 @@ async function runUpdate(opts) {
4684
4714
  }
4685
4715
  if (result.source.status === "moved" && result.source.newLines !== void 0) {
4686
4716
  const at2 = parseLines(result.source.newLines);
4687
- if (at2 !== void 0 && result.source.newSrc !== void 0) {
4688
- out.push({ kind: "source-moved", result, lines: lineSpec(at2), to: result.source.newSrc });
4717
+ const to = result.source.newSrc;
4718
+ const recorded = result.citation.source["commit-sha"];
4719
+ if (at2 !== void 0 && to !== void 0) {
4720
+ try {
4721
+ const minted = await mintCitation({
4722
+ root: run3.root,
4723
+ src: to,
4724
+ ...run3.key === void 0 ? {} : { key: run3.key },
4725
+ ...recorded === void 0 ? { commitSha: false } : {},
4726
+ gitClient: git,
4727
+ ...pageOptions.sourceIndex === void 0 ? {} : { sourceIndex: pageOptions.sourceIndex }
4728
+ });
4729
+ if (recorded !== void 0 && minted.source["commit-sha"] === void 0) {
4730
+ declined.set(result.origin.index, {
4731
+ rule: "source-moved",
4732
+ why: "Not rewritten: git is not available here, so the entry's commit-sha cannot advance with its lines."
4733
+ });
4734
+ } else {
4735
+ out.push({ kind: "source-moved", result, lines: lineSpec(at2), to, minted });
4736
+ }
4737
+ } catch (error) {
4738
+ if (!(error instanceof CiteError)) throw error;
4739
+ declined.set(result.origin.index, {
4740
+ rule: "source-moved",
4741
+ why: `Not rewritten: ${error.message}`
4742
+ });
4743
+ }
4689
4744
  }
4690
4745
  }
4691
4746
  if (!accept) return out;
@@ -4700,7 +4755,7 @@ async function runUpdate(opts) {
4700
4755
  if (unit !== void 0 && wide !== void 0) {
4701
4756
  declined.set(result.origin.index, {
4702
4757
  rule: "claim-changed",
4703
- why: `Not re-pinned: the ${unit.kind} ${wide}.`
4758
+ why: `Not re-pinned: the ${unitNoun(unit.kind)} ${wide}.`
4704
4759
  });
4705
4760
  } else if (unit === void 0) {
4706
4761
  const why = at2 === void 0 ? void 0 : noUnitAt(page, at2, lines, held, named4);
@@ -4710,7 +4765,12 @@ async function runUpdate(opts) {
4710
4765
  why: `Not re-pinned: ${sayNoUnit(why)}.`
4711
4766
  });
4712
4767
  }
4713
- } else if (pin !== void 0 && (!wantsBlock || unit.kind === "block")) {
4768
+ } else if (wantsBlock && unit.kind !== "block") {
4769
+ declined.set(result.origin.index, {
4770
+ rule: "claim-changed",
4771
+ why: "Not re-pinned: quote: true, and the line no longer opens a fenced block."
4772
+ });
4773
+ } else if (pin !== void 0) {
4714
4774
  const elsewhere = named4 ? [] : otherClaimSpans(lines, unit.lines, pin, page.bodyLine);
4715
4775
  const replaced = replacementAt(claim, unit.text, page.format);
4716
4776
  if (replaced !== void 0 && only === void 0) {
@@ -5356,10 +5416,10 @@ function renderCheckPretty(run3, opts) {
5356
5416
  return lines.join("\n");
5357
5417
  }
5358
5418
  function spellAtSpec(spec) {
5359
- const span = spanOf(spec);
5419
+ const span = spanOf2(spec);
5360
5420
  return span === void 0 ? `lines ${spec}` : spellAt(span);
5361
5421
  }
5362
- function spanOf(spec) {
5422
+ function spanOf2(spec) {
5363
5423
  const [first, second] = spec.split("-");
5364
5424
  const start = Number(first);
5365
5425
  const end = second === void 0 ? start : Number(second);
@@ -5367,8 +5427,8 @@ function spanOf(spec) {
5367
5427
  return { start, end };
5368
5428
  }
5369
5429
  function widening(held, now) {
5370
- const was = spanOf(held);
5371
- const is = spanOf(now);
5430
+ const was = spanOf2(held);
5431
+ const is = spanOf2(now);
5372
5432
  if (was === void 0 || is === void 0) return "";
5373
5433
  const parts = [];
5374
5434
  if (is.start < was.start) {
@@ -6057,4 +6117,4 @@ export {
6057
6117
  runKeyRotate,
6058
6118
  runKeySet
6059
6119
  };
6060
- //# sourceMappingURL=chunk-DGC4CCK3.js.map
6120
+ //# sourceMappingURL=chunk-GRPDC5BY.js.map