@bendyline/squisq 2.11.4 → 2.11.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.
@@ -3,7 +3,7 @@ import {
3
3
  expectedSyllablesAt,
4
4
  flattenRenderableBlocks,
5
5
  wordPosAtExpectedSyllables
6
- } from "./chunk-LI547QHN.js";
6
+ } from "./chunk-AIB5WEK2.js";
7
7
 
8
8
  // src/narration/types.ts
9
9
  var DEFAULT_FEATURE_CONFIG = Object.freeze({
@@ -21,7 +21,7 @@ import {
21
21
  parseAsciiTimeline,
22
22
  pickAutoTemplate,
23
23
  profileBlockContents
24
- } from "./chunk-PJRVODWW.js";
24
+ } from "./chunk-C3NAY5YP.js";
25
25
  import {
26
26
  DEFAULT_THEME,
27
27
  FRONTMATTER_CUSTOM_TEMPLATES_KEY,
@@ -1930,7 +1930,7 @@ function autoTemplatePreservesContent(templateName, contents) {
1930
1930
  case "leftFeature":
1931
1931
  case "rightFeature":
1932
1932
  case "statHighlight":
1933
- return true;
1933
+ return nodes.length > 0 && nodes.every((node) => node.type === "paragraph");
1934
1934
  default:
1935
1935
  return false;
1936
1936
  }
@@ -2470,7 +2470,8 @@ var EMPTY_PROFILE = Object.freeze({
2470
2470
  hasTable: false,
2471
2471
  hasDate: false,
2472
2472
  hasNumberHighlight: false,
2473
- wordCount: 0
2473
+ wordCount: 0,
2474
+ hasCompoundBody: false
2474
2475
  });
2475
2476
  var DATE_PATTERNS = [
2476
2477
  /\b(January|February|March|April|May|June|July|August|September|October|November|December)\s+(\d{1,2},?\s+)?\d{4}\b/i,
@@ -2596,13 +2597,15 @@ function profileBlockContents(nodes) {
2596
2597
  hasDate,
2597
2598
  hasNumberHighlight,
2598
2599
  wordCount,
2600
+ hasCompoundBody: nodes.length > 1 && nodes.some((node) => node.type !== "paragraph"),
2599
2601
  hasAsciiDiagram,
2600
2602
  hasTimeline,
2601
2603
  hasTree
2602
2604
  };
2603
2605
  }
2604
- var UNIVERSAL_DEFAULTS = ["title", "sectionHeader", "factCard", "twoColumn"];
2606
+ var UNIVERSAL_DEFAULTS = ["title", "sectionHeader", "content", "factCard", "twoColumn"];
2605
2607
  function recommendedNamesForProfile(profile) {
2608
+ if (profile.hasCompoundBody) return ["content"];
2606
2609
  const names = /* @__PURE__ */ new Set();
2607
2610
  let anyContentSignal = false;
2608
2611
  if (profile.hasAsciiDiagram) {
@@ -2659,12 +2662,14 @@ function recommendedNamesForProfile(profile) {
2659
2662
  if (anyContentSignal) {
2660
2663
  names.add("title");
2661
2664
  names.add("sectionHeader");
2665
+ names.add("content");
2662
2666
  } else {
2663
2667
  for (const n of UNIVERSAL_DEFAULTS) names.add(n);
2664
2668
  }
2665
2669
  return Array.from(names);
2666
2670
  }
2667
2671
  function pickAutoTemplate(profile, blockIndex = 0) {
2672
+ if (profile.hasCompoundBody) return void 0;
2668
2673
  if (profile.hasAsciiDiagram) return "diagram";
2669
2674
  if (profile.hasTimeline) return "timeline";
2670
2675
  if (profile.hasTree) return "tree";
@@ -30,7 +30,7 @@ import {
30
30
  templateRegistry,
31
31
  writeCustomTemplatesToFrontmatter,
32
32
  writeCustomThemesToFrontmatter
33
- } from "./chunk-LI547QHN.js";
33
+ } from "./chunk-AIB5WEK2.js";
34
34
  import {
35
35
  iconMarker
36
36
  } from "./chunk-7ZAAICW4.js";
@@ -50,7 +50,7 @@ import {
50
50
  toCells,
51
51
  toGrid,
52
52
  traceBoxes
53
- } from "./chunk-PJRVODWW.js";
53
+ } from "./chunk-C3NAY5YP.js";
54
54
  import {
55
55
  defaultPageStyle,
56
56
  resolveMediaSchedule
@@ -769,19 +769,6 @@ function collectAllDocImages(blocks) {
769
769
  walkBlocks(blocks);
770
770
  return images;
771
771
  }
772
- function extractListItems(contents) {
773
- if (!contents) return [];
774
- const items = [];
775
- for (const node of contents) {
776
- if (node.type === "list") {
777
- for (const item of node.children) {
778
- const text = extractPlainText(item).trim();
779
- if (text) items.push(text);
780
- }
781
- }
782
- }
783
- return items;
784
- }
785
772
  function getTemplateDefaults(templateName, headingText, block) {
786
773
  const body = extractBodyText(block.contents);
787
774
  switch (templateName) {
@@ -801,10 +788,10 @@ function getTemplateDefaults(templateName, headingText, block) {
801
788
  return { fact: headingText, explanation: body || headingText };
802
789
  case "comparisonBar":
803
790
  return { leftLabel: "A", leftValue: 60, rightLabel: "B", rightValue: 40 };
804
- case "list": {
805
- const items = extractListItems(block.contents);
806
- return { items: items.length > 0 ? items : ["Item 1", "Item 2", "Item 3"] };
807
- }
791
+ case "list":
792
+ return deriveTemplateInputs(templateName, headingText, block.contents) ?? {
793
+ items: ["Item 1", "Item 2", "Item 3"]
794
+ };
808
795
  case "definitionCard":
809
796
  return { term: headingText, definition: body || headingText };
810
797
  case "dateEvent":
package/dist/doc/index.js CHANGED
@@ -70,7 +70,7 @@ import {
70
70
  validateMarkdownDoc,
71
71
  validateMarkdownSource,
72
72
  writeDashboardLayoutsToFrontmatter
73
- } from "../chunk-NV7LNKS2.js";
73
+ } from "../chunk-NUS5YAI5.js";
74
74
  import {
75
75
  ASCII_CHAR_H,
76
76
  ASCII_CHAR_W,
@@ -192,7 +192,7 @@ import {
192
192
  wrapWithPersistentLayers,
193
193
  writeCustomTemplatesToFrontmatter,
194
194
  writeCustomThemesToFrontmatter
195
- } from "../chunk-LI547QHN.js";
195
+ } from "../chunk-AIB5WEK2.js";
196
196
  import {
197
197
  PATH_SHAPE_KINDS,
198
198
  anchorPoint,
@@ -229,7 +229,7 @@ import {
229
229
  parseAsciiTimelineWithStats,
230
230
  parseTree,
231
231
  parseWrappedFlowTimeline
232
- } from "../chunk-PJRVODWW.js";
232
+ } from "../chunk-C3NAY5YP.js";
233
233
  import "../chunk-GAZKTT4R.js";
234
234
  import {
235
235
  DEFAULT_THEME,
package/dist/index.d.ts CHANGED
@@ -26,5 +26,6 @@ export { IconSuggestion, canonicalIconToken, iconGlyph, looksLikeIconToken, reso
26
26
  export { BlockContentProfile, RecommendationResult, profileBlockContents, recommendTemplatesForBlock } from './recommend/index.js';
27
27
  export { AdvanceCoverage, AlignConfig, AlignInput, BandpassState, BuildAdvanceTimingOptions, BuildNarrationTimingOptions, BuildScriptOptions, DEFAULT_ALIGN_CONFIG, DEFAULT_FEATURE_CONFIG, DEFAULT_NUCLEI_CONFIG, DEFAULT_PACING_CONFIG, DEFAULT_VAD_CONFIG, EMPTY_ADVANCE_LOG, FeatureConfig, FeatureState, FrameFeatures, NarrationAlignment, NarrationBlockRange, NarrationScript, NarrationSessionConfig, NarrationSessionState, NarrationTimingBlock, NarrationTimingJsonV3, NarrationTimingMethod, NarrationTrace, NucleiConfig, NucleiState, PacingConfig, PacingState, PacingTick, ScriptBlockRange, ScriptToken, SlideAdvance, SlideAdvanceLog, TraceSample, VadConfig, VadState, WordTiming, advanceCoverage, alignNarration, bandpassRun, buildAdvanceTimingJson, buildNarrationScript, buildNarrationTimingJson, createBandpass, createFeatureState, createNarrationSession, createNucleiState, createPacingState, createVadState, detectSyllableOnsets, downsampleTrace, estimateSyllables, expectedSyllablesAt, extractFrameFeatures, featureStep, narrationSessionStep, nucleiStep, pacingStep, parseNarrationTimingJson, reanchorPacing, reanchorSession, recordSlideShown, traceWordPosAt, vadStep, wordIndexAtChar, wordIndexAtTime, wordPosAtExpectedSyllables } from './narration/index.js';
28
28
  export { FenceRenderContext, FenceRenderer, FenceRendererMap, fenceRendererLangs } from './fence/index.js';
29
- export { BlankProtectedSpansOptions, BlankedText, DEFAULT_PROOF_SETTINGS, JoinedSegments, LINT_KIND_CATEGORIES, PROOF_DIALECTS, PROOF_FRONTMATTER_KEYS, PROOF_JOIN_SEPARATOR, ProofCategory, ProofDialect, ProofFinding, ProofRange, ProofSuggestion, ProofSuggestionKind, ProofingSettings, SegmentSpan, blankProtectedSpans, buildJoinedText, categorizeLintKind, dropMaskedFindings, formatProofDictionary, mapJoinedSpanToSegment, parseProofDictionary, readProofingSettings, resolveProofDialect } from './proof/index.js';
29
+ export { P as PROOF_DIALECTS, a as ProofCategory, b as ProofDialect, c as ProofFinding, d as ProofRange, e as ProofSuggestion, f as ProofSuggestionKind } from './types-BQWu0gzi.js';
30
+ export { BlankProtectedSpansOptions, BlankedText, DEFAULT_PROOF_SETTINGS, JoinedSegments, LINT_KIND_CATEGORIES, PROOF_FRONTMATTER_KEYS, PROOF_JOIN_SEPARATOR, ProofingSettings, SegmentSpan, blankProtectedSpans, buildJoinedText, categorizeLintKind, dropMaskedFindings, formatProofDictionary, mapJoinedSpanToSegment, parseProofDictionary, readProofingSettings, resolveProofDialect } from './proof/index.js';
30
31
  import './viewState-lTZS-hP_.js';
package/dist/index.js CHANGED
@@ -27,7 +27,7 @@ import {
27
27
  recordSlideShown,
28
28
  traceWordPosAt,
29
29
  vadStep
30
- } from "./chunk-4UNTPQ4J.js";
30
+ } from "./chunk-2P44EZLI.js";
31
31
  import {
32
32
  fenceRendererLangs
33
33
  } from "./chunk-PGI7HSWE.js";
@@ -227,7 +227,7 @@ import {
227
227
  validateMarkdownDoc,
228
228
  validateMarkdownSource,
229
229
  writeDashboardLayoutsToFrontmatter
230
- } from "./chunk-NV7LNKS2.js";
230
+ } from "./chunk-NUS5YAI5.js";
231
231
  import {
232
232
  ASCII_CHAR_H,
233
233
  ASCII_CHAR_W,
@@ -357,7 +357,7 @@ import {
357
357
  wrapWithPersistentLayers,
358
358
  writeCustomTemplatesToFrontmatter,
359
359
  writeCustomThemesToFrontmatter
360
- } from "./chunk-LI547QHN.js";
360
+ } from "./chunk-AIB5WEK2.js";
361
361
  import {
362
362
  PATH_SHAPE_KINDS,
363
363
  anchorPoint,
@@ -402,7 +402,7 @@ import {
402
402
  parseWrappedFlowTimeline,
403
403
  profileBlockContents,
404
404
  recommendTemplatesForBlock
405
- } from "./chunk-PJRVODWW.js";
405
+ } from "./chunk-C3NAY5YP.js";
406
406
  import {
407
407
  defaultPageStyle,
408
408
  getDocPlaybackDuration,
@@ -27,7 +27,7 @@ import {
27
27
  recordSlideShown,
28
28
  traceWordPosAt,
29
29
  vadStep
30
- } from "../chunk-4UNTPQ4J.js";
30
+ } from "../chunk-2P44EZLI.js";
31
31
  import {
32
32
  buildNarrationScript,
33
33
  buildNarrationTimingJson,
@@ -37,9 +37,9 @@ import {
37
37
  wordIndexAtChar,
38
38
  wordIndexAtTime,
39
39
  wordPosAtExpectedSyllables
40
- } from "../chunk-LI547QHN.js";
40
+ } from "../chunk-AIB5WEK2.js";
41
41
  import "../chunk-PUS54YU6.js";
42
- import "../chunk-PJRVODWW.js";
42
+ import "../chunk-C3NAY5YP.js";
43
43
  import "../chunk-RXYKU6EX.js";
44
44
  import "../chunk-BAOV476U.js";
45
45
  import "../chunk-TMOHAFYE.js";
@@ -1,47 +1,5 @@
1
- /**
2
- * Plain-data types for the proofing (grammar + spellcheck) pipeline.
3
- *
4
- * These types are engine-agnostic: an editor host adapts a concrete
5
- * engine (harper.js, a service, a test fake) to produce `ProofFinding`s,
6
- * while this module stays pure and dependency-free so the mapping and
7
- * masking helpers can run in Node tests and any consumer bundle.
8
- */
9
- /** Severity/color tier of a finding: red, green, or blue squiggle. */
10
- type ProofCategory = 'spelling' | 'grammar' | 'style';
11
- /** How a suggestion is applied relative to the finding's span. */
12
- type ProofSuggestionKind = 'replace' | 'remove' | 'insertAfter';
13
- /** One candidate fix for a finding. */
14
- interface ProofSuggestion {
15
- /** Replacement/insertion text (empty for `remove`). */
16
- text: string;
17
- kind: ProofSuggestionKind;
18
- }
19
- /** A half-open `[start, end)` range in UTF-16 code units. */
20
- interface ProofRange {
21
- start: number;
22
- end: number;
23
- }
24
- /**
25
- * One issue found in a linted text. Offsets index into the exact string
26
- * that was linted (UTF-16 code units — the same coordinate space as
27
- * ProseMirror, Monaco, and DOM Range).
28
- */
29
- interface ProofFinding extends ProofRange {
30
- /** Stable within one lint pass; the provider maps id → engine handle. */
31
- id: string;
32
- category: ProofCategory;
33
- /** Raw engine kind (e.g. `Typo`), for diagnostics and future filtering. */
34
- kind: string;
35
- /** Human-readable description of the issue. */
36
- message: string;
37
- /** Text at `[start, end)` when linted — staleness check before applying. */
38
- originalText: string;
39
- suggestions: ProofSuggestion[];
40
- }
41
- /** English dialects supported by the proofing engine. */
42
- type ProofDialect = 'American' | 'British' | 'Australian' | 'Canadian' | 'Indian';
43
- /** All supported dialects, in display order. */
44
- declare const PROOF_DIALECTS: readonly ProofDialect[];
1
+ import { a as ProofCategory, d as ProofRange, b as ProofDialect } from '../types-BQWu0gzi.js';
2
+ export { P as PROOF_DIALECTS, c as ProofFinding, e as ProofSuggestion, f as ProofSuggestionKind } from '../types-BQWu0gzi.js';
45
3
 
46
4
  /**
47
5
  * Mapping from harper's `LintKind` vocabulary to squisq's three proofing
@@ -195,4 +153,4 @@ declare function formatProofDictionary(words: readonly string[]): string | null;
195
153
  /** Read all proofing settings from a parsed frontmatter record. */
196
154
  declare function readProofingSettings(frontmatter: Record<string, unknown> | undefined): ProofingSettings;
197
155
 
198
- export { type BlankProtectedSpansOptions, type BlankedText, DEFAULT_PROOF_SETTINGS, type JoinedSegments, LINT_KIND_CATEGORIES, PROOF_DIALECTS, PROOF_FRONTMATTER_KEYS, PROOF_JOIN_SEPARATOR, type ProofCategory, type ProofDialect, type ProofFinding, type ProofRange, type ProofSuggestion, type ProofSuggestionKind, type ProofingSettings, type SegmentSpan, blankProtectedSpans, buildJoinedText, categorizeLintKind, dropMaskedFindings, formatProofDictionary, mapJoinedSpanToSegment, parseProofDictionary, readProofingSettings, resolveProofDialect };
156
+ export { type BlankProtectedSpansOptions, type BlankedText, DEFAULT_PROOF_SETTINGS, type JoinedSegments, LINT_KIND_CATEGORIES, PROOF_FRONTMATTER_KEYS, PROOF_JOIN_SEPARATOR, ProofCategory, ProofDialect, ProofRange, type ProofingSettings, type SegmentSpan, blankProtectedSpans, buildJoinedText, categorizeLintKind, dropMaskedFindings, formatProofDictionary, mapJoinedSpanToSegment, parseProofDictionary, readProofingSettings, resolveProofDialect };
@@ -20,6 +20,12 @@ interface BlockContentProfile {
20
20
  hasDate: boolean;
21
21
  hasNumberHighlight: boolean;
22
22
  wordCount: number;
23
+ /**
24
+ * True when a structural body node (list, table, quote, fence, etc.) has
25
+ * top-level siblings. Specialized templates generally consume only one
26
+ * structure; the complete-body template is the safe recommendation.
27
+ */
28
+ hasCompoundBody?: boolean;
23
29
  /**
24
30
  * True when the body is dominated by exactly one code fence whose content
25
31
  * is an ASCII box-and-line diagram (see `doc/asciiDiagram/detect.ts`).
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  profileBlockContents,
3
3
  recommendTemplatesForBlock
4
- } from "../chunk-PJRVODWW.js";
4
+ } from "../chunk-C3NAY5YP.js";
5
5
  import "../chunk-X7BNDUNI.js";
6
6
  export {
7
7
  profileBlockContents,
@@ -0,0 +1,141 @@
1
+ import { c as ProofFinding } from '../types-BQWu0gzi.js';
2
+
3
+ /**
4
+ * Plain-data types for the review pipeline.
5
+ *
6
+ * Review generalizes proofing. Spellcheck asks "is this word wrong?"; a
7
+ * reviewer may also ask "is this paragraph clear?", and the two differ in three
8
+ * ways the {@link ProofFinding} shape cannot express: a reviewer is slow enough
9
+ * that results must stream and be cancellable, it needs document structure
10
+ * rather than one flat string, and its suggestion is often a rewritten
11
+ * paragraph rather than a replaced word.
12
+ *
13
+ * `@bendyline/squisq/proof` is untouched and keeps working. A
14
+ * {@link ProofingProvider} is adapted into this pipeline by the editor, so
15
+ * there is one renderer rather than two.
16
+ */
17
+
18
+ /**
19
+ * How much a finding matters.
20
+ *
21
+ * Separate from the hue a provider draws in: severity orders findings within a
22
+ * provider, while the hue says which provider they came from. Conflating them
23
+ * is what makes a style hint and a spelling mistake indistinguishable.
24
+ */
25
+ type ReviewSeverity = 'info' | 'suggestion' | 'warning' | 'error';
26
+ /** How a suggestion is applied relative to the finding. */
27
+ type ReviewSuggestionKind = 'replace' | 'remove' | 'insertAfter' | 'replaceBlock';
28
+ interface ReviewSuggestion {
29
+ /** Replacement text. Empty for `remove`. */
30
+ text: string;
31
+ /**
32
+ * `replaceBlock` swaps the whole owning block rather than the finding's span.
33
+ * A model asked to improve a sentence rewrites the sentence; forcing that
34
+ * into a span replacement is what produces the mangled half-edits.
35
+ */
36
+ kind: ReviewSuggestionKind;
37
+ /** Button label, e.g. "Tighten". Falls back to a kind-derived default. */
38
+ label?: string;
39
+ }
40
+ /**
41
+ * One issue in a reviewed document.
42
+ *
43
+ * Offsets are UTF-16 code units into {@link ReviewRequest.source} — the same
44
+ * coordinate space as ProseMirror, Monaco and DOM Range.
45
+ */
46
+ interface ReviewFinding {
47
+ /** Unique within one pass of one provider. */
48
+ id: string;
49
+ /**
50
+ * Which provider produced this. Namespaces decorations and groups the panel,
51
+ * so two providers can report the same span without colliding.
52
+ */
53
+ source: string;
54
+ start: number;
55
+ end: number;
56
+ /**
57
+ * The block this finding is about.
58
+ *
59
+ * Present even when the span is exact, because a span goes stale as soon as
60
+ * the user types while the block does not — a finding that can still be
61
+ * navigated to is worth more than one that can only be discarded.
62
+ */
63
+ blockKey?: number;
64
+ severity: ReviewSeverity;
65
+ /** Provider-defined grouping, e.g. `spelling` or `clarity`. */
66
+ category: string;
67
+ /** One sentence. Shown inline. */
68
+ message: string;
69
+ /** The longer "why", shown on expand. A linter rarely has one; a model does. */
70
+ rationale?: string;
71
+ /** Text at `[start, end)` when reviewed — the staleness check before applying. */
72
+ originalText: string;
73
+ suggestions: ReviewSuggestion[];
74
+ }
75
+ /** One block handed to a provider. */
76
+ interface ReviewBlockInput {
77
+ /** Matches the editor's block key, so a finding can navigate back. */
78
+ key: number;
79
+ /** 1-based line where the block starts in `source`. */
80
+ startLine: number;
81
+ /** Nearest enclosing heading, for context. Null at the top of a document. */
82
+ heading: string | null;
83
+ /** Block text, with machine vocabulary already masked. */
84
+ text: string;
85
+ /** UTF-16 offset of `text` within {@link ReviewRequest.source}. */
86
+ offset: number;
87
+ }
88
+ /** Identifies the document under review. */
89
+ interface ReviewDocumentRef {
90
+ articleId: string;
91
+ fileName?: string;
92
+ }
93
+ interface ReviewRequest {
94
+ /** The whole document, for a provider that wants surrounding context. */
95
+ source: string;
96
+ blocks: readonly ReviewBlockInput[];
97
+ /**
98
+ * Blocks changed since this provider's last pass, when the editor knows.
99
+ *
100
+ * A hint, not a restriction: a cheap provider may ignore it and re-scan
101
+ * everything, while an expensive one can review only what moved. Absent on
102
+ * a first pass.
103
+ */
104
+ changedBlockKeys?: readonly number[];
105
+ language?: 'plaintext' | 'markdown';
106
+ documentRef: ReviewDocumentRef;
107
+ }
108
+ /**
109
+ * Progress from one provider pass.
110
+ *
111
+ * `findings` is additive and may arrive many times: a reviewer that takes
112
+ * seconds per block should show its first result immediately rather than
113
+ * holding everything until the last block returns.
114
+ */
115
+ type ReviewEvent = {
116
+ type: 'findings';
117
+ findings: readonly ReviewFinding[];
118
+ } | {
119
+ type: 'progress';
120
+ blockKey: number;
121
+ } | {
122
+ type: 'done';
123
+ } | {
124
+ type: 'error';
125
+ message: string;
126
+ };
127
+ /** The provider id the editor adapts harper under. */
128
+ declare const PROOFING_REVIEW_SOURCE = "harper";
129
+ /**
130
+ * Adapt one proofing finding into a review finding.
131
+ *
132
+ * `offset` shifts engine-relative offsets into document coordinates, for a
133
+ * provider that linted a block or a joined run rather than the whole source.
134
+ */
135
+ declare function proofFindingToReviewFinding(finding: ProofFinding, options?: {
136
+ source?: string;
137
+ offset?: number;
138
+ blockKey?: number;
139
+ }): ReviewFinding;
140
+
141
+ export { PROOFING_REVIEW_SOURCE, type ReviewBlockInput, type ReviewDocumentRef, type ReviewEvent, type ReviewFinding, type ReviewRequest, type ReviewSeverity, type ReviewSuggestion, type ReviewSuggestionKind, proofFindingToReviewFinding };
@@ -0,0 +1,29 @@
1
+ // src/review/types.ts
2
+ var PROOF_SEVERITY = Object.freeze({
3
+ spelling: "error",
4
+ grammar: "warning",
5
+ style: "suggestion"
6
+ });
7
+ var PROOFING_REVIEW_SOURCE = "harper";
8
+ function proofFindingToReviewFinding(finding, options = {}) {
9
+ const offset = options.offset ?? 0;
10
+ return {
11
+ id: finding.id,
12
+ source: options.source ?? PROOFING_REVIEW_SOURCE,
13
+ start: finding.start + offset,
14
+ end: finding.end + offset,
15
+ ...options.blockKey === void 0 ? {} : { blockKey: options.blockKey },
16
+ severity: PROOF_SEVERITY[finding.category],
17
+ category: finding.category,
18
+ message: finding.message,
19
+ originalText: finding.originalText,
20
+ suggestions: finding.suggestions.map((suggestion) => ({
21
+ text: suggestion.text,
22
+ kind: suggestion.kind
23
+ }))
24
+ };
25
+ }
26
+ export {
27
+ PROOFING_REVIEW_SOURCE,
28
+ proofFindingToReviewFinding
29
+ };
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Plain-data types for the proofing (grammar + spellcheck) pipeline.
3
+ *
4
+ * These types are engine-agnostic: an editor host adapts a concrete
5
+ * engine (harper.js, a service, a test fake) to produce `ProofFinding`s,
6
+ * while this module stays pure and dependency-free so the mapping and
7
+ * masking helpers can run in Node tests and any consumer bundle.
8
+ */
9
+ /** Severity/color tier of a finding: red, green, or blue squiggle. */
10
+ type ProofCategory = 'spelling' | 'grammar' | 'style';
11
+ /** How a suggestion is applied relative to the finding's span. */
12
+ type ProofSuggestionKind = 'replace' | 'remove' | 'insertAfter';
13
+ /** One candidate fix for a finding. */
14
+ interface ProofSuggestion {
15
+ /** Replacement/insertion text (empty for `remove`). */
16
+ text: string;
17
+ kind: ProofSuggestionKind;
18
+ }
19
+ /** A half-open `[start, end)` range in UTF-16 code units. */
20
+ interface ProofRange {
21
+ start: number;
22
+ end: number;
23
+ }
24
+ /**
25
+ * One issue found in a linted text. Offsets index into the exact string
26
+ * that was linted (UTF-16 code units — the same coordinate space as
27
+ * ProseMirror, Monaco, and DOM Range).
28
+ */
29
+ interface ProofFinding extends ProofRange {
30
+ /** Stable within one lint pass; the provider maps id → engine handle. */
31
+ id: string;
32
+ category: ProofCategory;
33
+ /** Raw engine kind (e.g. `Typo`), for diagnostics and future filtering. */
34
+ kind: string;
35
+ /** Human-readable description of the issue. */
36
+ message: string;
37
+ /** Text at `[start, end)` when linted — staleness check before applying. */
38
+ originalText: string;
39
+ suggestions: ProofSuggestion[];
40
+ }
41
+ /** English dialects supported by the proofing engine. */
42
+ type ProofDialect = 'American' | 'British' | 'Australian' | 'Canadian' | 'Indian';
43
+ /** All supported dialects, in display order. */
44
+ declare const PROOF_DIALECTS: readonly ProofDialect[];
45
+
46
+ export { PROOF_DIALECTS as P, type ProofCategory as a, type ProofDialect as b, type ProofFinding as c, type ProofRange as d, type ProofSuggestion as e, type ProofSuggestionKind as f };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bendyline/squisq",
3
- "version": "2.11.4",
3
+ "version": "2.11.5",
4
4
  "description": "Headless utilities for doc/block rendering, spatial math, Markdown, and storage",
5
5
  "license": "MIT",
6
6
  "author": "Bendyline",
@@ -132,6 +132,11 @@
132
132
  "import": "./dist/proof/index.js",
133
133
  "default": "./dist/proof/index.js"
134
134
  },
135
+ "./review": {
136
+ "types": "./dist/review/index.d.ts",
137
+ "import": "./dist/review/index.js",
138
+ "default": "./dist/review/index.js"
139
+ },
135
140
  "./table": {
136
141
  "types": "./dist/table/index.d.ts",
137
142
  "import": "./dist/table/index.js",