polytypo 1.6.3 → 1.8.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.
Files changed (78) hide show
  1. package/README.md +27 -0
  2. package/dist/{chunk-UOPLHOTJ.js → chunk-4RAZ2EDS.js} +4 -4
  3. package/dist/chunk-6UQAKZ7L.js +35 -0
  4. package/dist/chunk-6UQAKZ7L.js.map +1 -0
  5. package/dist/{chunk-UIUJSDBS.js → chunk-EH542ZE4.js} +2 -2
  6. package/dist/{chunk-VVBJZBXR.js → chunk-EQ2JTKYF.js} +1 -1
  7. package/dist/{chunk-VVBJZBXR.js.map → chunk-EQ2JTKYF.js.map} +1 -1
  8. package/dist/{chunk-OHMN6WPZ.js → chunk-F6HVIPLF.js} +21 -8
  9. package/dist/{chunk-OHMN6WPZ.js.map → chunk-F6HVIPLF.js.map} +1 -1
  10. package/dist/{chunk-JT3VGUUU.cjs → chunk-GK5P55K5.cjs} +3 -3
  11. package/dist/{chunk-JT3VGUUU.cjs.map → chunk-GK5P55K5.cjs.map} +1 -1
  12. package/dist/{chunk-UB7HJ4MX.cjs → chunk-GUROIWJY.cjs} +1 -1
  13. package/dist/{chunk-UB7HJ4MX.cjs.map → chunk-GUROIWJY.cjs.map} +1 -1
  14. package/dist/{chunk-2XWZW3RU.cjs → chunk-KAJ3GVK2.cjs} +23 -27
  15. package/dist/chunk-KAJ3GVK2.cjs.map +1 -0
  16. package/dist/{chunk-4ELGGQ7B.js → chunk-KCKZHLI5.js} +23 -27
  17. package/dist/chunk-KCKZHLI5.js.map +1 -0
  18. package/dist/chunk-KFDDI4LH.cjs +35 -0
  19. package/dist/chunk-KFDDI4LH.cjs.map +1 -0
  20. package/dist/{chunk-BCU7YHWD.cjs → chunk-M3TVDUGX.cjs} +4 -4
  21. package/dist/{chunk-BCU7YHWD.cjs.map → chunk-M3TVDUGX.cjs.map} +1 -1
  22. package/dist/{chunk-RZYVLO3Z.js → chunk-PEBD5XTD.js} +2 -2
  23. package/dist/chunk-UJ3D4DYP.cjs +33 -0
  24. package/dist/{chunk-TV4AZVHZ.cjs.map → chunk-UJ3D4DYP.cjs.map} +1 -1
  25. package/dist/{chunk-7DKZNZUD.cjs → chunk-UWFI3XV7.cjs} +35 -22
  26. package/dist/chunk-UWFI3XV7.cjs.map +1 -0
  27. package/dist/chunk-VBHUVDW4.cjs +296 -0
  28. package/dist/chunk-VBHUVDW4.cjs.map +1 -0
  29. package/dist/{chunk-ODTH774G.js → chunk-XLTVLET5.js} +2 -2
  30. package/dist/chunk-YA64BEKC.cjs +31 -0
  31. package/dist/{chunk-GZSUAD6M.cjs.map → chunk-YA64BEKC.cjs.map} +1 -1
  32. package/dist/{chunk-27B32RJQ.js → chunk-YH77XVJB.js} +126 -17
  33. package/dist/chunk-YH77XVJB.js.map +1 -0
  34. package/dist/{errors-C1_sHGgx.d.ts → errors-DeHxbXRn.d.cts} +8 -0
  35. package/dist/{errors-C1_sHGgx.d.cts → errors-DeHxbXRn.d.ts} +8 -0
  36. package/dist/html.cjs +10 -10
  37. package/dist/html.cjs.map +1 -1
  38. package/dist/html.d.cts +3 -3
  39. package/dist/html.d.ts +3 -3
  40. package/dist/html.js +5 -5
  41. package/dist/html.js.map +1 -1
  42. package/dist/index.cjs +18 -17
  43. package/dist/index.cjs.map +1 -1
  44. package/dist/index.d.cts +2 -2
  45. package/dist/index.d.ts +2 -2
  46. package/dist/index.js +8 -7
  47. package/dist/index.js.map +1 -1
  48. package/dist/markdown.cjs +11 -10
  49. package/dist/markdown.cjs.map +1 -1
  50. package/dist/markdown.d.cts +2 -2
  51. package/dist/markdown.d.ts +2 -2
  52. package/dist/markdown.js +6 -5
  53. package/dist/markdown.js.map +1 -1
  54. package/dist/text.cjs +8 -8
  55. package/dist/text.cjs.map +1 -1
  56. package/dist/text.d.cts +3 -3
  57. package/dist/text.d.ts +3 -3
  58. package/dist/text.js +3 -3
  59. package/dist/text.js.map +1 -1
  60. package/dist/yaml.cjs +10 -9
  61. package/dist/yaml.cjs.map +1 -1
  62. package/dist/yaml.d.cts +3 -3
  63. package/dist/yaml.d.ts +3 -3
  64. package/dist/yaml.js +5 -4
  65. package/dist/yaml.js.map +1 -1
  66. package/package.json +1 -1
  67. package/dist/chunk-27B32RJQ.js.map +0 -1
  68. package/dist/chunk-2XWZW3RU.cjs.map +0 -1
  69. package/dist/chunk-4ELGGQ7B.js.map +0 -1
  70. package/dist/chunk-7DKZNZUD.cjs.map +0 -1
  71. package/dist/chunk-GZSUAD6M.cjs +0 -31
  72. package/dist/chunk-RNH6KTYZ.cjs +0 -187
  73. package/dist/chunk-RNH6KTYZ.cjs.map +0 -1
  74. package/dist/chunk-TV4AZVHZ.cjs +0 -33
  75. /package/dist/{chunk-UOPLHOTJ.js.map → chunk-4RAZ2EDS.js.map} +0 -0
  76. /package/dist/{chunk-UIUJSDBS.js.map → chunk-EH542ZE4.js.map} +0 -0
  77. /package/dist/{chunk-RZYVLO3Z.js.map → chunk-PEBD5XTD.js.map} +0 -0
  78. /package/dist/{chunk-ODTH774G.js.map → chunk-XLTVLET5.js.map} +0 -0
@@ -9,7 +9,7 @@ import {
9
9
  isMarker,
10
10
  runRulesRecording,
11
11
  toCodePoints
12
- } from "./chunk-VVBJZBXR.js";
12
+ } from "./chunk-EQ2JTKYF.js";
13
13
 
14
14
  // src/modes/spans.ts
15
15
  var SPACE = 32;
@@ -160,9 +160,9 @@ function runRulesOverSpans(cp, planned, locale, mode, narrowTarget) {
160
160
  }
161
161
  return current;
162
162
  }
163
- function runOverSpans(source, spans, planned, locale, mode, narrowTarget) {
163
+ function replacementsOfUnit(source, spans, planned, locale, mode, narrowTarget) {
164
164
  const normalized = normalizeSpans(spans);
165
- if (normalized.length === 0) return source;
165
+ if (normalized.length === 0) return [];
166
166
  const transformed = runRulesOverSpans(
167
167
  concatenateSpans(source, normalized),
168
168
  planned,
@@ -171,18 +171,29 @@ function runOverSpans(source, spans, planned, locale, mode, narrowTarget) {
171
171
  narrowTarget
172
172
  );
173
173
  const pieces = splitOnMarker(transformed, normalized.length);
174
+ return normalized.map((span, i) => ({ span, text: fromCodePoints(pieces[i]) }));
175
+ }
176
+ function emit(source, replacements) {
174
177
  let out = "";
175
178
  let cursor = 0;
176
- for (let i = 0; i < normalized.length; i += 1) {
177
- const span = normalized[i];
178
- const replacement = fromCodePoints(pieces[i]);
179
+ for (const { span, text } of replacements) {
179
180
  const original = source.slice(span.start, span.end);
180
181
  out += source.slice(cursor, span.start);
181
- out += replacement === original ? original : replacement;
182
+ out += text === original ? original : text;
182
183
  cursor = span.end;
183
184
  }
184
185
  return out + source.slice(cursor);
185
186
  }
187
+ function runOverSpans(source, spans, planned, locale, mode, narrowTarget) {
188
+ return emit(source, replacementsOfUnit(source, spans, planned, locale, mode, narrowTarget));
189
+ }
190
+ function runOverUnits(source, units, planned, locale, mode, narrowTarget) {
191
+ const replacements = units.flatMap((spans) => replacementsOfUnit(source, spans, planned, locale, mode, narrowTarget)).sort((a, b) => a.span.start - b.span.start);
192
+ return emit(source, replacements);
193
+ }
194
+ function analyzeOverUnits(source, units, planned, locale, mode, narrowTarget) {
195
+ return units.flatMap((spans) => analyzeOverSpans(source, spans, planned, locale, mode, narrowTarget)).sort((a, b) => a.start - b.start);
196
+ }
186
197
  function analyzeOverSpans(source, spans, planned, locale, mode, narrowTarget) {
187
198
  const normalized = normalizeSpans(spans);
188
199
  if (normalized.length === 0) return [];
@@ -200,6 +211,8 @@ function analyzeOverSpans(source, spans, planned, locale, mode, narrowTarget) {
200
211
 
201
212
  export {
202
213
  runOverSpans,
214
+ runOverUnits,
215
+ analyzeOverUnits,
203
216
  analyzeOverSpans
204
217
  };
205
- //# sourceMappingURL=chunk-OHMN6WPZ.js.map
218
+ //# sourceMappingURL=chunk-F6HVIPLF.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/modes/spans.ts","../src/engine/span-runner.ts"],"sourcesContent":["import { toCodePoints } from \"../engine/codepoints.js\";\nimport { isMarker, LINE_MARKER, MARKER } from \"../engine/sentinels.js\";\nimport { PolytypoError } from \"../errors.js\";\nimport type { Edit } from \"../types.js\";\nimport { NO_ORIGIN } from \"../engine/origin.js\";\n\n/**\n * The boundary markers are defined in the engine (src/engine/sentinels.ts), which is where all\n * three non-code-point sentinels live and where their disjointness is maintained. They are\n * re-exported here because the mode layer is what writes them into the array.\n *\n * Which marker separates two spans is decided by the **raw source bytes of the gap between\n * them**, so it is decidable without asking the parser anything and is identical in five\n * runtimes: a gap containing a line terminator gives `LINE_MARKER`, anything else `MARKER`.\n */\nexport { LINE_MARKER, MARKER, isMarker } from \"../engine/sentinels.js\";\n\n/** `BREAK` as the rules define it (`spaces.md` 3.1), tested against the gap's raw source. */\n/** U+0020, the one emitted code point whose meaning is positional (modes.md 3.4, 5 item 2). */\nconst SPACE = 0x20;\n\nconst LINE_TERMINATORS: ReadonlySet<number> = new Set([\n 0x0a, 0x0d, 0x0b, 0x0c, 0x85, 0x2028, 0x2029,\n]);\n\nfunction gapIsLineBoundary(source: string, from: number, to: number): boolean {\n for (let i = from; i < to; i += 1) {\n if (LINE_TERMINATORS.has(source.charCodeAt(i))) return true;\n }\n return false;\n}\n\n/**\n * A processable span, identified by its offsets in the **original source**. Offsets are UTF-16\n * indices into the JS source string, which is what every JS parser reports; they are an\n * implementation detail of this runtime and never reach the rules, which index code points.\n */\nexport interface Span {\n readonly start: number;\n readonly end: number;\n}\n\n/** A span's extent in the concatenated code-point array: `s₀` and `s₁` of modes.md 3.4. */\nexport interface SpanRange {\n readonly first: number;\n readonly last: number;\n}\n\n/**\n * Sort, drop empties, and coalesce spans separated by nothing in the source (modes.md 7.5:\n * a parser that reports one text run as two adjacent nodes must not manufacture a boundary).\n * Overlapping spans are an extractor bug and are rejected rather than silently merged.\n */\nexport function normalizeSpans(spans: readonly Span[]): Span[] {\n const sorted = spans.filter((s) => s.end > s.start).sort((a, b) => a.start - b.start);\n const out: Span[] = [];\n for (const span of sorted) {\n const last = out[out.length - 1];\n if (last === undefined) {\n out.push(span);\n continue;\n }\n if (span.start < last.end) {\n throw new PolytypoError(\n \"POLYTYPO_RULE_CONTRACT\",\n `mode extractor produced overlapping spans (${last.start}, ${last.end}) and (${span.start}, ${span.end})`,\n );\n }\n if (span.start === last.end) {\n out[out.length - 1] = { start: last.start, end: span.end };\n continue;\n }\n out.push(span);\n }\n return out;\n}\n\n/** `S₁ ⌢ [marker] ⌢ S₂ ⌢ … ⌢ Sₘ` (modes.md 3.5 step 2). */\nexport function concatenateSpans(source: string, spans: readonly Span[]): number[] {\n const cp: number[] = [];\n let previous: Span | undefined;\n for (const span of spans) {\n if (previous !== undefined) {\n cp.push(gapIsLineBoundary(source, previous.end, span.start) ? LINE_MARKER : MARKER);\n }\n for (const value of toCodePoints(source.slice(span.start, span.end))) cp.push(value);\n previous = span;\n }\n return cp;\n}\n\n/**\n * The span extents of the array as it stands. Recomputed after every rule, because applying\n * edits shifts every index after the first one — the markers themselves are guaranteed to\n * survive, since no edit may contain one.\n */\nexport function spanRangesOf(cp: readonly number[]): SpanRange[] {\n const ranges: SpanRange[] = [];\n let first = 0;\n for (let i = 0; i < cp.length; i += 1) {\n if (isMarker(cp[i] as number)) {\n ranges.push({ first, last: i - 1 });\n first = i + 1;\n }\n }\n ranges.push({ first, last: cp.length - 1 });\n return ranges;\n}\n\nfunction spanContaining(ranges: readonly SpanRange[], p: number): SpanRange | undefined {\n for (const range of ranges) {\n if (p >= range.first && p <= range.last + 1) return range;\n }\n return undefined;\n}\n\n/**\n * modes.md 3.4, two safety nets, both pure functions of `(p, q, r, s₀, s₁)` — so the verdict is\n * identical on every run, which is what makes redistribution deterministic (modes.md 5, point 3).\n *\n * 1. **No edit may contain a marker.** No rule can produce one; one that does is a bug, and the\n * edit is discarded rather than treated as a redistribution question.\n * 2. **The edge-growth rule.** An edit is discarded if it would place code points at an\n * extremity of its span that were not there before: with `d = q - p + 1` the replaced length\n * and `r` the replacement length, discard when `p = s₀ and r > d`, or `q = s₁ and r > d`.\n *\n * The length test is the whole rule and needs no knowledge of Markdown or HTML syntax. It\n * separates exactly the cases that matter: `\"` → `“` at an edge is 1 → 1 and applies; `--` →\n * `␣–␣` at an edge is 2 → 3 and is discarded, while the same edit interior to a span applies;\n * `(c)` → `©` is 3 → 1 and applies, because shrinking is always safe. An insertion has `d = 0`,\n * so it is discarded exactly when its position coincides with a span edge — the rule this one\n * generalises.\n *\n * **Deletion at an edge is not restricted here**, and must not be: `r > d` is false for a\n * deletion, so this filter never sees one. Deletion at an edge is governed by modes.md 3.3's\n * *Edge tests* clause instead — where a rule asks \"am I at the edge of the text I am allowed to\n * modify\" rather than \"what character is here\", the marker behaves as `NONE`. That clause is the\n * one place a rule may treat a span edge as the end of the text, it exists because `spaces` is\n * the only rule that deletes, and 3.3 states the division: **a rule that deletes must treat a\n * span edge as the end of the text; a rule that replaces or inserts must not, and is governed by\n * this filter.** The single test that claims the clause is `spaces.md` 3.2 step 4.\n */\nexport function filterBoundaryEdits(\n cp: readonly number[],\n edits: readonly Edit[],\n ranges: readonly SpanRange[],\n): Edit[] {\n const out: Edit[] = [];\n for (const edit of edits) {\n let containsMarker = false;\n for (let i = edit.start; i < edit.end; i += 1) {\n if (isMarker(cp[i] as number)) {\n containsMarker = true;\n break;\n }\n }\n if (containsMarker) continue;\n\n // `[start, end)` in the engine's half-open form is `cp[p … q]` with p = start, q = end - 1;\n // an insertion is `q = p - 1`, which falls out of the same expression.\n const p = edit.start;\n const q = edit.end - 1;\n const d = edit.end - edit.start;\n const r = edit.replacement.length;\n const span = spanContaining(ranges, p);\n if (span !== undefined && (p === span.first || q === span.last)) {\n if (r > d) continue;\n // The character clause. `r > d` is not the rule, only a formalisation of it that misses\n // `r === d`: `dashes` P3 admits a run of THREE dashes, so `---` -> `␣–␣` is 3 -> 3 and the\n // length test sees nothing while U+0020 lands on both extremities anyway. Testing the\n // character catches it, and only U+0020 needs testing — it is the one code point any rule\n // emits whose meaning comes from its position rather than from itself (modes.md 5 item 2).\n const first = edit.replacement[0];\n const last = edit.replacement[r - 1];\n if (r > 0 && p === span.first && first === SPACE && cp[p] !== SPACE) continue;\n if (r > 0 && q === span.last && last === SPACE && cp[q] !== SPACE) continue;\n }\n\n out.push(edit);\n }\n return out;\n}\n\n/** Redistribute the transformed array back to one piece per span (modes.md 3.5 step 4). */\nexport function splitOnMarker(cp: readonly number[], expected: number): number[][] {\n const pieces: number[][] = [[]];\n for (const value of cp) {\n if (isMarker(value)) {\n pieces.push([]);\n continue;\n }\n (pieces[pieces.length - 1] as number[]).push(value);\n }\n if (pieces.length !== expected) {\n throw new PolytypoError(\n \"POLYTYPO_RULE_CONTRACT\",\n `boundary markers did not survive the pipeline: expected ${expected} spans, found ${pieces.length}`,\n );\n }\n return pieces;\n}\n\n/**\n * The origin map for `concatenateSpans` (analyze.md §2): for every code point of the joined\n * array, the code-point offset of the character it came from IN THE DOCUMENT, and NO_ORIGIN for\n * the markers, which came from nowhere. `Span` bounds are native string indices, so the\n * conversion to code-point offsets happens here and not in the caller — this is the one place\n * that knows both coordinate systems.\n */\nexport function originOfSpans(source: string, spans: readonly Span[]): number[] {\n const codePointIndexOf = new Array<number>(source.length + 1);\n let cpIndex = 0;\n for (let i = 0; i < source.length;) {\n codePointIndexOf[i] = cpIndex;\n const code = source.codePointAt(i) as number;\n const width = code > 0xffff ? 2 : 1;\n if (width === 2) codePointIndexOf[i + 1] = cpIndex;\n i += width;\n cpIndex += 1;\n }\n codePointIndexOf[source.length] = cpIndex;\n\n const origin: number[] = [];\n let previous: Span | undefined;\n for (const span of spans) {\n if (previous !== undefined) origin.push(NO_ORIGIN);\n const base = codePointIndexOf[span.start] as number;\n const length = toCodePoints(source.slice(span.start, span.end)).length;\n for (let k = 0; k < length; k += 1) origin.push(base + k);\n previous = span;\n }\n return origin;\n}\n","import {\n concatenateSpans,\n filterBoundaryEdits,\n normalizeSpans,\n originOfSpans,\n spanRangesOf,\n splitOnMarker,\n type Span,\n} from \"../modes/spans.js\";\nimport { RULES } from \"../rules/registry.js\";\nimport type { LocaleData, Mode, RuleId } from \"../types.js\";\nimport { applyEdits } from \"./edits.js\";\nimport { fromCodePoints, toCodePoints } from \"./codepoints.js\";\nimport type { Change } from \"./origin.js\";\nimport { runRulesRecording } from \"./rule-runner.js\";\n\n/**\n * The same sequence as `runRules` (`./rule-runner.js`), with the two boundary filters of\n * modes.md 3.4 interposed. The span extents are recomputed after every rule, because applying\n * an edit shifts every index after it; the markers themselves always survive, since no edit may\n * contain one.\n */\nfunction runRulesOverSpans(\n cp: readonly number[],\n planned: readonly RuleId[],\n locale: LocaleData,\n mode: Mode,\n narrowTarget: number,\n): readonly number[] {\n let current = cp;\n for (const id of planned) {\n const rule = RULES[id];\n if (rule === undefined) continue;\n const edits = rule.apply({ cp: current, locale, mode, narrowTarget });\n current = applyEdits(current, filterBoundaryEdits(current, edits, spanRangesOf(current)), id);\n }\n return current;\n}\n\n/**\n * modes.md 3.5. The pipeline runs **once**, over the marker-separated concatenation of every\n * processable span — not per span, which would pair quotation marks in isolation, and not over a\n * naive concatenation, which would manufacture adjacencies the document does not have.\n *\n * The output is the input with a set of disjoint substring replacements applied and nothing else\n * (modes.md 4). A span whose content the rules did not change contributes no replacement, so a\n * document needing no changes comes back byte-identical; the parser located the spans and was\n * then discarded, and the document is never serialised.\n */\nexport function runOverSpans(\n source: string,\n spans: readonly Span[],\n planned: readonly RuleId[],\n locale: LocaleData,\n mode: Mode,\n narrowTarget: number,\n): string {\n const normalized = normalizeSpans(spans);\n if (normalized.length === 0) return source;\n\n const transformed = runRulesOverSpans(\n concatenateSpans(source, normalized),\n planned,\n locale,\n mode,\n narrowTarget,\n );\n const pieces = splitOnMarker(transformed, normalized.length);\n\n let out = \"\";\n let cursor = 0;\n for (let i = 0; i < normalized.length; i += 1) {\n const span = normalized[i] as Span;\n const replacement = fromCodePoints(pieces[i] as number[]);\n const original = source.slice(span.start, span.end);\n out += source.slice(cursor, span.start);\n out += replacement === original ? original : replacement;\n cursor = span.end;\n }\n return out + source.slice(cursor);\n}\n\n/**\n * `runOverSpans`, reporting instead of applying (analyze.md §1). The span table supplies the\n * origin map, so every change comes back in DOCUMENT coordinates — analyze.md §6 names a\n * runtime that reports span-local offsets here as the mistake that passes every text-mode test.\n */\nexport function analyzeOverSpans(\n source: string,\n spans: readonly Span[],\n planned: readonly RuleId[],\n locale: LocaleData,\n mode: Mode,\n narrowTarget: number,\n): Change[] {\n const normalized = normalizeSpans(spans);\n if (normalized.length === 0) return [];\n return runRulesRecording(\n concatenateSpans(source, normalized),\n planned,\n locale,\n mode,\n narrowTarget,\n originOfSpans(source, normalized),\n toCodePoints(source).length,\n (current, edits) => filterBoundaryEdits(current, edits, spanRangesOf(current)),\n );\n}\n"],"mappings":";;;;;;;;;;;;;;AAmBA,IAAM,QAAQ;AAEd,IAAM,mBAAwC,oBAAI,IAAI;AAAA,EACpD;AAAA,EAAM;AAAA,EAAM;AAAA,EAAM;AAAA,EAAM;AAAA,EAAM;AAAA,EAAQ;AACxC,CAAC;AAED,SAAS,kBAAkB,QAAgB,MAAc,IAAqB;AAC5E,WAAS,IAAI,MAAM,IAAI,IAAI,KAAK,GAAG;AACjC,QAAI,iBAAiB,IAAI,OAAO,WAAW,CAAC,CAAC,EAAG,QAAO;AAAA,EACzD;AACA,SAAO;AACT;AAuBO,SAAS,eAAe,OAAgC;AAC7D,QAAM,SAAS,MAAM,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,CAAC,GAAG,MAAM,EAAE,QAAQ,EAAE,KAAK;AACpF,QAAM,MAAc,CAAC;AACrB,aAAW,QAAQ,QAAQ;AACzB,UAAM,OAAO,IAAI,IAAI,SAAS,CAAC;AAC/B,QAAI,SAAS,QAAW;AACtB,UAAI,KAAK,IAAI;AACb;AAAA,IACF;AACA,QAAI,KAAK,QAAQ,KAAK,KAAK;AACzB,YAAM,IAAI;AAAA,QACR;AAAA,QACA,8CAA8C,KAAK,KAAK,KAAK,KAAK,GAAG,UAAU,KAAK,KAAK,KAAK,KAAK,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,OAAO,KAAK,GAAG;AAClD,WAAO,OAAO,MAAM,QAAQ,KAAK,KAAK;AACtC,WAAO,gBAAgB,WAAW,WAAW;AAC7C,aAAS,KAAK;AAAA,EAChB;AACA,SAAO,MAAM,OAAO,MAAM,MAAM;AAClC;AAOO,SAAS,iBACd,QACA,OACA,SACA,QACA,MACA,cACU;AACV,QAAM,aAAa,eAAe,KAAK;AACvC,MAAI,WAAW,WAAW,EAAG,QAAO,CAAC;AACrC,SAAO;AAAA,IACL,iBAAiB,QAAQ,UAAU;AAAA,IACnC;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,cAAc,QAAQ,UAAU;AAAA,IAChC,aAAa,MAAM,EAAE;AAAA,IACrB,CAAC,SAAS,UAAU,oBAAoB,SAAS,OAAO,aAAa,OAAO,CAAC;AAAA,EAC/E;AACF;","names":[]}
1
+ {"version":3,"sources":["../src/modes/spans.ts","../src/engine/span-runner.ts"],"sourcesContent":["import { toCodePoints } from \"../engine/codepoints.js\";\nimport { isMarker, LINE_MARKER, MARKER } from \"../engine/sentinels.js\";\nimport { PolytypoError } from \"../errors.js\";\nimport type { Edit } from \"../types.js\";\nimport { NO_ORIGIN } from \"../engine/origin.js\";\n\n/**\n * The boundary markers are defined in the engine (src/engine/sentinels.ts), which is where all\n * three non-code-point sentinels live and where their disjointness is maintained. They are\n * re-exported here because the mode layer is what writes them into the array.\n *\n * Which marker separates two spans is decided by the **raw source bytes of the gap between\n * them**, so it is decidable without asking the parser anything and is identical in five\n * runtimes: a gap containing a line terminator gives `LINE_MARKER`, anything else `MARKER`.\n */\nexport { LINE_MARKER, MARKER, isMarker } from \"../engine/sentinels.js\";\n\n/** `BREAK` as the rules define it (`spaces.md` 3.1), tested against the gap's raw source. */\n/** U+0020, the one emitted code point whose meaning is positional (modes.md 3.4, 5 item 2). */\nconst SPACE = 0x20;\n\nconst LINE_TERMINATORS: ReadonlySet<number> = new Set([\n 0x0a, 0x0d, 0x0b, 0x0c, 0x85, 0x2028, 0x2029,\n]);\n\nfunction gapIsLineBoundary(source: string, from: number, to: number): boolean {\n for (let i = from; i < to; i += 1) {\n if (LINE_TERMINATORS.has(source.charCodeAt(i))) return true;\n }\n return false;\n}\n\n/**\n * A processable span, identified by its offsets in the **original source**. Offsets are UTF-16\n * indices into the JS source string, which is what every JS parser reports; they are an\n * implementation detail of this runtime and never reach the rules, which index code points.\n */\nexport interface Span {\n readonly start: number;\n readonly end: number;\n}\n\n/** A span's extent in the concatenated code-point array: `s₀` and `s₁` of modes.md 3.4. */\nexport interface SpanRange {\n readonly first: number;\n readonly last: number;\n}\n\n/**\n * Sort, drop empties, and coalesce spans separated by nothing in the source (modes.md 7.5:\n * a parser that reports one text run as two adjacent nodes must not manufacture a boundary).\n * Overlapping spans are an extractor bug and are rejected rather than silently merged.\n */\nexport function normalizeSpans(spans: readonly Span[]): Span[] {\n const sorted = spans.filter((s) => s.end > s.start).sort((a, b) => a.start - b.start);\n const out: Span[] = [];\n for (const span of sorted) {\n const last = out[out.length - 1];\n if (last === undefined) {\n out.push(span);\n continue;\n }\n if (span.start < last.end) {\n throw new PolytypoError(\n \"POLYTYPO_RULE_CONTRACT\",\n `mode extractor produced overlapping spans (${last.start}, ${last.end}) and (${span.start}, ${span.end})`,\n );\n }\n if (span.start === last.end) {\n out[out.length - 1] = { start: last.start, end: span.end };\n continue;\n }\n out.push(span);\n }\n return out;\n}\n\n/** `S₁ ⌢ [marker] ⌢ S₂ ⌢ … ⌢ Sₘ` (modes.md 3.5 step 2). */\nexport function concatenateSpans(source: string, spans: readonly Span[]): number[] {\n const cp: number[] = [];\n let previous: Span | undefined;\n for (const span of spans) {\n if (previous !== undefined) {\n cp.push(gapIsLineBoundary(source, previous.end, span.start) ? LINE_MARKER : MARKER);\n }\n for (const value of toCodePoints(source.slice(span.start, span.end))) cp.push(value);\n previous = span;\n }\n return cp;\n}\n\n/**\n * The span extents of the array as it stands. Recomputed after every rule, because applying\n * edits shifts every index after the first one — the markers themselves are guaranteed to\n * survive, since no edit may contain one.\n */\nexport function spanRangesOf(cp: readonly number[]): SpanRange[] {\n const ranges: SpanRange[] = [];\n let first = 0;\n for (let i = 0; i < cp.length; i += 1) {\n if (isMarker(cp[i] as number)) {\n ranges.push({ first, last: i - 1 });\n first = i + 1;\n }\n }\n ranges.push({ first, last: cp.length - 1 });\n return ranges;\n}\n\nfunction spanContaining(ranges: readonly SpanRange[], p: number): SpanRange | undefined {\n for (const range of ranges) {\n if (p >= range.first && p <= range.last + 1) return range;\n }\n return undefined;\n}\n\n/**\n * modes.md 3.4, two safety nets, both pure functions of `(p, q, r, s₀, s₁)` — so the verdict is\n * identical on every run, which is what makes redistribution deterministic (modes.md 5, point 3).\n *\n * 1. **No edit may contain a marker.** No rule can produce one; one that does is a bug, and the\n * edit is discarded rather than treated as a redistribution question.\n * 2. **The edge-growth rule.** An edit is discarded if it would place code points at an\n * extremity of its span that were not there before: with `d = q - p + 1` the replaced length\n * and `r` the replacement length, discard when `p = s₀ and r > d`, or `q = s₁ and r > d`.\n *\n * The length test is the whole rule and needs no knowledge of Markdown or HTML syntax. It\n * separates exactly the cases that matter: `\"` → `“` at an edge is 1 → 1 and applies; `--` →\n * `␣–␣` at an edge is 2 → 3 and is discarded, while the same edit interior to a span applies;\n * `(c)` → `©` is 3 → 1 and applies, because shrinking is always safe. An insertion has `d = 0`,\n * so it is discarded exactly when its position coincides with a span edge — the rule this one\n * generalises.\n *\n * **Deletion at an edge is not restricted here**, and must not be: `r > d` is false for a\n * deletion, so this filter never sees one. Deletion at an edge is governed by modes.md 3.3's\n * *Edge tests* clause instead — where a rule asks \"am I at the edge of the text I am allowed to\n * modify\" rather than \"what character is here\", the marker behaves as `NONE`. That clause is the\n * one place a rule may treat a span edge as the end of the text, it exists because `spaces` is\n * the only rule that deletes, and 3.3 states the division: **a rule that deletes must treat a\n * span edge as the end of the text; a rule that replaces or inserts must not, and is governed by\n * this filter.** The single test that claims the clause is `spaces.md` 3.2 step 4.\n */\nexport function filterBoundaryEdits(\n cp: readonly number[],\n edits: readonly Edit[],\n ranges: readonly SpanRange[],\n): Edit[] {\n const out: Edit[] = [];\n for (const edit of edits) {\n let containsMarker = false;\n for (let i = edit.start; i < edit.end; i += 1) {\n if (isMarker(cp[i] as number)) {\n containsMarker = true;\n break;\n }\n }\n if (containsMarker) continue;\n\n // `[start, end)` in the engine's half-open form is `cp[p … q]` with p = start, q = end - 1;\n // an insertion is `q = p - 1`, which falls out of the same expression.\n const p = edit.start;\n const q = edit.end - 1;\n const d = edit.end - edit.start;\n const r = edit.replacement.length;\n const span = spanContaining(ranges, p);\n if (span !== undefined && (p === span.first || q === span.last)) {\n if (r > d) continue;\n // The character clause. `r > d` is not the rule, only a formalisation of it that misses\n // `r === d`: `dashes` P3 admits a run of THREE dashes, so `---` -> `␣–␣` is 3 -> 3 and the\n // length test sees nothing while U+0020 lands on both extremities anyway. Testing the\n // character catches it, and only U+0020 needs testing — it is the one code point any rule\n // emits whose meaning comes from its position rather than from itself (modes.md 5 item 2).\n const first = edit.replacement[0];\n const last = edit.replacement[r - 1];\n if (r > 0 && p === span.first && first === SPACE && cp[p] !== SPACE) continue;\n if (r > 0 && q === span.last && last === SPACE && cp[q] !== SPACE) continue;\n }\n\n out.push(edit);\n }\n return out;\n}\n\n/** Redistribute the transformed array back to one piece per span (modes.md 3.5 step 4). */\nexport function splitOnMarker(cp: readonly number[], expected: number): number[][] {\n const pieces: number[][] = [[]];\n for (const value of cp) {\n if (isMarker(value)) {\n pieces.push([]);\n continue;\n }\n (pieces[pieces.length - 1] as number[]).push(value);\n }\n if (pieces.length !== expected) {\n throw new PolytypoError(\n \"POLYTYPO_RULE_CONTRACT\",\n `boundary markers did not survive the pipeline: expected ${expected} spans, found ${pieces.length}`,\n );\n }\n return pieces;\n}\n\n/**\n * The origin map for `concatenateSpans` (analyze.md §2): for every code point of the joined\n * array, the code-point offset of the character it came from IN THE DOCUMENT, and NO_ORIGIN for\n * the markers, which came from nowhere. `Span` bounds are native string indices, so the\n * conversion to code-point offsets happens here and not in the caller — this is the one place\n * that knows both coordinate systems.\n */\nexport function originOfSpans(source: string, spans: readonly Span[]): number[] {\n const codePointIndexOf = new Array<number>(source.length + 1);\n let cpIndex = 0;\n for (let i = 0; i < source.length;) {\n codePointIndexOf[i] = cpIndex;\n const code = source.codePointAt(i) as number;\n const width = code > 0xffff ? 2 : 1;\n if (width === 2) codePointIndexOf[i + 1] = cpIndex;\n i += width;\n cpIndex += 1;\n }\n codePointIndexOf[source.length] = cpIndex;\n\n const origin: number[] = [];\n let previous: Span | undefined;\n for (const span of spans) {\n if (previous !== undefined) origin.push(NO_ORIGIN);\n const base = codePointIndexOf[span.start] as number;\n const length = toCodePoints(source.slice(span.start, span.end)).length;\n for (let k = 0; k < length; k += 1) origin.push(base + k);\n previous = span;\n }\n return origin;\n}\n","import {\n concatenateSpans,\n filterBoundaryEdits,\n normalizeSpans,\n originOfSpans,\n spanRangesOf,\n splitOnMarker,\n type Span,\n} from \"../modes/spans.js\";\nimport { RULES } from \"../rules/registry.js\";\nimport type { LocaleData, Mode, RuleId } from \"../types.js\";\nimport { applyEdits } from \"./edits.js\";\nimport { fromCodePoints, toCodePoints } from \"./codepoints.js\";\nimport type { Change } from \"./origin.js\";\nimport { runRulesRecording } from \"./rule-runner.js\";\n\n/**\n * The same sequence as `runRules` (`./rule-runner.js`), with the two boundary filters of\n * modes.md 3.4 interposed. The span extents are recomputed after every rule, because applying\n * an edit shifts every index after it; the markers themselves always survive, since no edit may\n * contain one.\n */\nfunction runRulesOverSpans(\n cp: readonly number[],\n planned: readonly RuleId[],\n locale: LocaleData,\n mode: Mode,\n narrowTarget: number,\n): readonly number[] {\n let current = cp;\n for (const id of planned) {\n const rule = RULES[id];\n if (rule === undefined) continue;\n const edits = rule.apply({ cp: current, locale, mode, narrowTarget });\n current = applyEdits(current, filterBoundaryEdits(current, edits, spanRangesOf(current)), id);\n }\n return current;\n}\n\n/**\n * modes.md 3.5. The pipeline runs **once**, over the marker-separated concatenation of every\n * processable span — not per span, which would pair quotation marks in isolation, and not over a\n * naive concatenation, which would manufacture adjacencies the document does not have.\n *\n * The output is the input with a set of disjoint substring replacements applied and nothing else\n * (modes.md 4). A span whose content the rules did not change contributes no replacement, so a\n * document needing no changes comes back byte-identical; the parser located the spans and was\n * then discarded, and the document is never serialised.\n */\ninterface Replacement {\n readonly span: Span;\n readonly text: string;\n}\n\n/** One text unit: the marker-separated concatenation, the pipeline, and the pieces it produced. */\nfunction replacementsOfUnit(\n source: string,\n spans: readonly Span[],\n planned: readonly RuleId[],\n locale: LocaleData,\n mode: Mode,\n narrowTarget: number,\n): Replacement[] {\n const normalized = normalizeSpans(spans);\n if (normalized.length === 0) return [];\n const transformed = runRulesOverSpans(\n concatenateSpans(source, normalized),\n planned,\n locale,\n mode,\n narrowTarget,\n );\n const pieces = splitOnMarker(transformed, normalized.length);\n return normalized.map((span, i) => ({ span, text: fromCodePoints(pieces[i] as number[]) }));\n}\n\n/** modes.md 4: the source with disjoint replacements applied at recorded offsets, nothing else. */\nfunction emit(source: string, replacements: readonly Replacement[]): string {\n let out = \"\";\n let cursor = 0;\n for (const { span, text } of replacements) {\n const original = source.slice(span.start, span.end);\n out += source.slice(cursor, span.start);\n out += text === original ? original : text;\n cursor = span.end;\n }\n return out + source.slice(cursor);\n}\n\nexport function runOverSpans(\n source: string,\n spans: readonly Span[],\n planned: readonly RuleId[],\n locale: LocaleData,\n mode: Mode,\n narrowTarget: number,\n): string {\n return emit(source, replacementsOfUnit(source, spans, planned, locale, mode, narrowTarget));\n}\n\n/**\n * modes.md 3.1 and 3.5 step 3 (spec 1.7.0). A document has one text unit, except in `markdown`\n * with `frontmatterKeys`, where the frontmatter block's spans form a unit of their own. The\n * pipeline runs once per unit, and the two edit sets are disjoint because no span of one unit lies\n * inside the other — which is exactly what `markdownSpans` skipping the block guarantees.\n *\n * Only step 5 is shared: the source is emitted once, with every unit's replacements in document\n * order.\n */\nexport function runOverUnits(\n source: string,\n units: readonly (readonly Span[])[],\n planned: readonly RuleId[],\n locale: LocaleData,\n mode: Mode,\n narrowTarget: number,\n): string {\n const replacements = units\n .flatMap((spans) => replacementsOfUnit(source, spans, planned, locale, mode, narrowTarget))\n .sort((a, b) => a.span.start - b.span.start);\n return emit(source, replacements);\n}\n\n/**\n * `runOverSpans`, reporting instead of applying (analyze.md §1). The span table supplies the\n * origin map, so every change comes back in DOCUMENT coordinates — analyze.md §6 names a\n * runtime that reports span-local offsets here as the mistake that passes every text-mode test.\n */\n/** `analyzeOverSpans` per text unit (modes.md 3.1), reported in document order. */\nexport function analyzeOverUnits(\n source: string,\n units: readonly (readonly Span[])[],\n planned: readonly RuleId[],\n locale: LocaleData,\n mode: Mode,\n narrowTarget: number,\n): Change[] {\n return units\n .flatMap((spans) => analyzeOverSpans(source, spans, planned, locale, mode, narrowTarget))\n .sort((a, b) => a.start - b.start);\n}\n\nexport function analyzeOverSpans(\n source: string,\n spans: readonly Span[],\n planned: readonly RuleId[],\n locale: LocaleData,\n mode: Mode,\n narrowTarget: number,\n): Change[] {\n const normalized = normalizeSpans(spans);\n if (normalized.length === 0) return [];\n return runRulesRecording(\n concatenateSpans(source, normalized),\n planned,\n locale,\n mode,\n narrowTarget,\n originOfSpans(source, normalized),\n toCodePoints(source).length,\n (current, edits) => filterBoundaryEdits(current, edits, spanRangesOf(current)),\n );\n}\n"],"mappings":";;;;;;;;;;;;;;AAmBA,IAAM,QAAQ;AAEd,IAAM,mBAAwC,oBAAI,IAAI;AAAA,EACpD;AAAA,EAAM;AAAA,EAAM;AAAA,EAAM;AAAA,EAAM;AAAA,EAAM;AAAA,EAAQ;AACxC,CAAC;AAED,SAAS,kBAAkB,QAAgB,MAAc,IAAqB;AAC5E,WAAS,IAAI,MAAM,IAAI,IAAI,KAAK,GAAG;AACjC,QAAI,iBAAiB,IAAI,OAAO,WAAW,CAAC,CAAC,EAAG,QAAO;AAAA,EACzD;AACA,SAAO;AACT;AAuBO,SAAS,eAAe,OAAgC;AAC7D,QAAM,SAA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SACA,QACA,MACA,cACU;AACV,QAAM,aAAa,eAAe,KAAK;AACvC,MAAI,WAAW,WAAW,EAAG,QAAO,CAAC;AACrC,SAAO;AAAA,IACL,iBAAiB,QAAQ,UAAU;AAAA,IACnC;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,cAAc,QAAQ,UAAU;AAAA,IAChC,aAAa,MAAM,EAAE;AAAA,IACrB,CAAC,SAAS,UAAU,oBAAoB,SAAS,OAAO,aAAa,OAAO,CAAC;AAAA,EAC/E;AACF;","names":[]}
@@ -1,11 +1,11 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunkUB7HJ4MXcjs = require('./chunk-UB7HJ4MX.cjs');
3
+ var _chunkGUROIWJYcjs = require('./chunk-GUROIWJY.cjs');
4
4
 
5
5
  // src/engine/assert-fixed-mode.ts
6
6
  function assertFixedMode(mode, fixed, entryPoint) {
7
7
  if (mode === void 0 || mode === fixed) return;
8
- throw new (0, _chunkUB7HJ4MXcjs.PolytypoError)(
8
+ throw new (0, _chunkGUROIWJYcjs.PolytypoError)(
9
9
  "POLYTYPO_INVALID_MODE",
10
10
  `"${entryPoint}" only supports mode "${fixed}". Received "${String(mode)}" \u2014 import from "polytypo" for the other modes, or omit \`mode\` here.`
11
11
  );
@@ -14,4 +14,4 @@ function assertFixedMode(mode, fixed, entryPoint) {
14
14
 
15
15
 
16
16
  exports.assertFixedMode = assertFixedMode;
17
- //# sourceMappingURL=chunk-JT3VGUUU.cjs.map
17
+ //# sourceMappingURL=chunk-GK5P55K5.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["/home/runner/work/polytypo-js/polytypo-js/dist/chunk-JT3VGUUU.cjs","../src/engine/assert-fixed-mode.ts"],"names":[],"mappings":"AAAA;AACE;AACF,wDAA6B;AAC7B;AACA;ACMO,SAAS,eAAA,CAAgB,IAAA,EAAe,KAAA,EAAa,UAAA,EAA0B;AACpF,EAAA,GAAA,CAAI,KAAA,IAAS,KAAA,EAAA,GAAa,KAAA,IAAS,KAAA,EAAO,MAAA;AAC1C,EAAA,MAAM,IAAI,oCAAA;AAAA,IACR,uBAAA;AAAA,IACA,CAAA,CAAA,EAAI,UAAU,CAAA,sBAAA,EAAyB,KAAK,CAAA,aAAA,EAAgB,MAAA,CAAO,IAAI,CAAC,CAAA,2EAAA;AAAA,EAE1E,CAAA;AACF;ADLA;AACA;AACE;AACF,0CAAC","file":"/home/runner/work/polytypo-js/polytypo-js/dist/chunk-JT3VGUUU.cjs","sourcesContent":[null,"import { PolytypoError } from \"../errors.js\";\nimport type { Mode } from \"../types.js\";\n\n/**\n * `polytypo/text`, `polytypo/html` and `polytypo/markdown` each fix `mode` at the type level by\n * omitting it from their Options type (AUDIT_REMEDIATION_AND_RELEASE_PLAN.md 5.1, criterion 6).\n * A plain-JS caller — or a TypeScript caller passing a wider-typed variable, which excess-property\n * checking does not catch — can still supply a conflicting `mode` at runtime. That is rejected\n * explicitly here, never silently ignored or overridden.\n */\nexport function assertFixedMode(mode: unknown, fixed: Mode, entryPoint: string): void {\n if (mode === undefined || mode === fixed) return;\n throw new PolytypoError(\n \"POLYTYPO_INVALID_MODE\",\n `\"${entryPoint}\" only supports mode \"${fixed}\". Received \"${String(mode)}\" — ` +\n `import from \"polytypo\" for the other modes, or omit \\`mode\\` here.`,\n );\n}\n"]}
1
+ {"version":3,"sources":["/home/runner/work/polytypo-js/polytypo-js/dist/chunk-GK5P55K5.cjs","../src/engine/assert-fixed-mode.ts"],"names":[],"mappings":"AAAA;AACE;AACF,wDAA6B;AAC7B;AACA;ACMO,SAAS,eAAA,CAAgB,IAAA,EAAe,KAAA,EAAa,UAAA,EAA0B;AACpF,EAAA,GAAA,CAAI,KAAA,IAAS,KAAA,EAAA,GAAa,KAAA,IAAS,KAAA,EAAO,MAAA;AAC1C,EAAA,MAAM,IAAI,oCAAA;AAAA,IACR,uBAAA;AAAA,IACA,CAAA,CAAA,EAAI,UAAU,CAAA,sBAAA,EAAyB,KAAK,CAAA,aAAA,EAAgB,MAAA,CAAO,IAAI,CAAC,CAAA,2EAAA;AAAA,EAE1E,CAAA;AACF;ADLA;AACA;AACE;AACF,0CAAC","file":"/home/runner/work/polytypo-js/polytypo-js/dist/chunk-GK5P55K5.cjs","sourcesContent":[null,"import { PolytypoError } from \"../errors.js\";\nimport type { Mode } from \"../types.js\";\n\n/**\n * `polytypo/text`, `polytypo/html` and `polytypo/markdown` each fix `mode` at the type level by\n * omitting it from their Options type (AUDIT_REMEDIATION_AND_RELEASE_PLAN.md 5.1, criterion 6).\n * A plain-JS caller — or a TypeScript caller passing a wider-typed variable, which excess-property\n * checking does not catch — can still supply a conflicting `mode` at runtime. That is rejected\n * explicitly here, never silently ignored or overridden.\n */\nexport function assertFixedMode(mode: unknown, fixed: Mode, entryPoint: string): void {\n if (mode === undefined || mode === fixed) return;\n throw new PolytypoError(\n \"POLYTYPO_INVALID_MODE\",\n `\"${entryPoint}\" only supports mode \"${fixed}\". Received \"${String(mode)}\" — ` +\n `import from \"polytypo\" for the other modes, or omit \\`mode\\` here.`,\n );\n}\n"]}
@@ -5837,4 +5837,4 @@ function runRulesRecording(cp, planned, locale, mode, narrowTarget, origin, inpu
5837
5837
 
5838
5838
 
5839
5839
  exports.PolytypoError = PolytypoError; exports.toCodePoints = toCodePoints; exports.fromCodePoints = fromCodePoints; exports.getLocaleData = getLocaleData; exports.resolveNarrowTarget = resolveNarrowTarget; exports.MARKER = MARKER; exports.LINE_MARKER = LINE_MARKER; exports.isMarker = isMarker; exports.RULES = RULES; exports.applyEdits = applyEdits; exports.NO_ORIGIN = NO_ORIGIN; exports.planRules = planRules; exports.runRules = runRules; exports.runRulesRecording = runRulesRecording;
5840
- //# sourceMappingURL=chunk-UB7HJ4MX.cjs.map
5840
+ //# sourceMappingURL=chunk-GUROIWJY.cjs.map