@stll/folio-core 0.72.0 → 0.74.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 (244) hide show
  1. package/README.md +12 -6
  2. package/dist/ai-edits/applyTypes.d.ts +85 -0
  3. package/dist/ai-edits/applyTypes.js +24 -0
  4. package/dist/ai-edits/clean-text.d.ts +7 -1
  5. package/dist/ai-edits/clean-text.js +23 -2
  6. package/dist/ai-edits/finalSectionReview.d.ts +1 -1
  7. package/dist/ai-edits/headless.d.ts +29 -147
  8. package/dist/ai-edits/headless.js +215 -1639
  9. package/dist/ai-edits/index.d.ts +3 -3
  10. package/dist/ai-edits/index.js +2 -3
  11. package/dist/ai-edits/pending-suggestions.d.ts +14 -4
  12. package/dist/ai-edits/pending-suggestions.js +183 -90
  13. package/dist/ai-edits/pendingJoin.js +6 -1
  14. package/dist/ai-edits/retired-comment-receipts.d.ts +1 -1
  15. package/dist/ai-edits/snapshot.js +9 -4
  16. package/dist/ai-edits/table-cell-mutations.d.ts +1 -1
  17. package/dist/ai-edits/table-cell-mutations.js +2 -2
  18. package/dist/ai-edits/table-geometry.d.ts +1 -1
  19. package/dist/ai-edits/table-geometry.js +1 -1
  20. package/dist/ai-edits/table-row-column-mutations.d.ts +1 -1
  21. package/dist/ai-edits/table-row-column-mutations.js +1 -1
  22. package/dist/ai-edits/tableNodes.d.ts +38 -0
  23. package/dist/ai-edits/tableNodes.js +86 -0
  24. package/dist/ai-edits/tracked-batch-fidelity.d.ts +1 -1
  25. package/dist/ai-edits/tracked-batch-fidelity.js +1 -1
  26. package/dist/ai-edits/undefinedReferences.d.ts +7 -0
  27. package/dist/canonical/batchCommentReferences.js +1 -0
  28. package/dist/canonical/canonicalInlineGaps.d.ts +56 -0
  29. package/dist/canonical/canonicalInlineGaps.js +118 -0
  30. package/dist/canonical/canonicalInlineProjection.d.ts +4 -13
  31. package/dist/canonical/canonicalInlineProjection.js +5 -27
  32. package/dist/canonical/canonicalProjectionBlocks.d.ts +4 -4
  33. package/dist/canonical/canonicalPublicOperations.js +282 -75
  34. package/dist/canonical/canonicalSelection.js +1 -1
  35. package/dist/canonical/canonicalSession.d.ts +9 -1
  36. package/dist/canonical/canonicalSession.js +106 -33
  37. package/dist/compare/compare.d.ts +1 -1
  38. package/dist/compare/inline-atoms-model.d.ts +1 -1
  39. package/dist/compare/inline-atoms.d.ts +2 -2
  40. package/dist/compare/inline-provenance-model.d.ts +1 -1
  41. package/dist/compare/inline-provenance.d.ts +2 -2
  42. package/dist/compat/eigenpal.d.ts +3 -3
  43. package/dist/compat/eigenpal.js +2 -3
  44. package/dist/controller/autocompleteSuggestion.js +1 -1
  45. package/dist/controller/canonicalClipboard.d.ts +13 -3
  46. package/dist/controller/canonicalClipboard.js +186 -50
  47. package/dist/controller/canonicalClipboardResources.d.ts +9 -1
  48. package/dist/controller/canonicalClipboardResources.js +22 -2
  49. package/dist/controller/canonicalComposition.js +1 -1
  50. package/dist/controller/canonicalInput.js +1 -1
  51. package/dist/controller/canonicalPresence.js +1 -1
  52. package/dist/controller/canonicalReview.d.ts +1 -1
  53. package/dist/controller/canonicalReview.js +1 -1
  54. package/dist/controller/canonicalRoomAuthority.js +1 -1
  55. package/dist/controller/canonicalRoomWire.js +1 -1
  56. package/dist/controller/canonicalStructure.js +1 -1
  57. package/dist/controller/canonicalTabRoom.js +1 -1
  58. package/dist/controller/canonicalWatermark.d.ts +10 -0
  59. package/dist/controller/canonicalWatermark.js +37 -0
  60. package/dist/controller/canonicalYjsRoom.js +1 -1
  61. package/dist/controller/hiddenEditorApi.d.ts +1 -1
  62. package/dist/controller/hiddenEditorApi.js +2 -17
  63. package/dist/controller/hiddenEditorManager.d.ts +4 -3
  64. package/dist/controller/hiddenEditorManager.js +79 -23
  65. package/dist/document-operations.d.ts +1 -14
  66. package/dist/document-operations.js +1 -278
  67. package/dist/docx/canonicalSave.d.ts +1 -1
  68. package/dist/docx/canonicalSave.js +1 -1
  69. package/dist/docx/canonicalSessionInput.js +1 -1
  70. package/dist/docx/containerChildren.js +1 -1
  71. package/dist/docx/createDocx.d.ts +4 -0
  72. package/dist/docx/createDocx.js +6 -0
  73. package/dist/docx/paragraphParser.js +2 -2
  74. package/dist/docx/paragraphPropertySource.d.ts +1 -1
  75. package/dist/docx/parser.js +1 -1
  76. package/dist/docx/reviewResolutionProvenance.d.ts +3 -2
  77. package/dist/docx/reviewResolutionProvenance.js +31 -8
  78. package/dist/docx/revisionIdNormalization.js +30 -7
  79. package/dist/docx/rezip.d.ts +1 -1
  80. package/dist/docx/rezip.js +1 -1
  81. package/dist/docx/serializer/tableSerializer.js +4 -36
  82. package/dist/docx/server/templatePlan/apply.d.ts +15 -0
  83. package/dist/docx/server/templatePlan/apply.js +658 -0
  84. package/dist/docx/server/templatePlan/blocks.d.ts +97 -0
  85. package/dist/docx/server/templatePlan/blocks.js +355 -0
  86. package/dist/docx/server/templatePlan/builders.d.ts +72 -0
  87. package/dist/docx/server/templatePlan/builders.js +237 -0
  88. package/dist/docx/server/templatePlan/emit.d.ts +118 -0
  89. package/dist/docx/server/templatePlan/emit.js +466 -0
  90. package/dist/docx/server/templatePlan/emphasis.d.ts +62 -0
  91. package/dist/docx/server/templatePlan/emphasis.js +173 -0
  92. package/dist/docx/server/templatePlan/inspect.d.ts +22 -0
  93. package/dist/docx/server/templatePlan/inspect.js +230 -0
  94. package/dist/docx/server/templatePlan/labels.d.ts +45 -0
  95. package/dist/docx/server/templatePlan/labels.js +155 -0
  96. package/dist/docx/server/templatePlan/package.d.ts +34 -0
  97. package/dist/docx/server/templatePlan/package.js +99 -0
  98. package/dist/docx/server/templatePlan/plan.d.ts +145 -0
  99. package/dist/docx/server/templatePlan/plan.js +875 -0
  100. package/dist/docx/server/templatePlan/planShape.d.ts +9 -0
  101. package/dist/docx/server/templatePlan/planShape.js +180 -0
  102. package/dist/docx/server/templatePlan/resources.d.ts +41 -0
  103. package/dist/docx/server/templatePlan/resources.js +136 -0
  104. package/dist/docx/server/templatePlan/story.d.ts +128 -0
  105. package/dist/docx/server/templatePlan/story.js +440 -0
  106. package/dist/docx/server/templatePlan/types.d.ts +442 -0
  107. package/dist/docx/server/templatePlan/types.js +29 -0
  108. package/dist/docx/server/templatePlan/verify.d.ts +40 -0
  109. package/dist/docx/server/templatePlan/verify.js +976 -0
  110. package/dist/docx/server/templatePlan/xml.d.ts +74 -0
  111. package/dist/docx/server/templatePlan/xml.js +125 -0
  112. package/dist/docx/settingsHeaderFooterUpdate.d.ts +9 -0
  113. package/dist/docx/settingsHeaderFooterUpdate.js +45 -10
  114. package/dist/docx/structuralXmlPatch.js +9 -1
  115. package/dist/docx/tableGridXml.d.ts +30 -0
  116. package/dist/docx/tableGridXml.js +54 -0
  117. package/dist/docx/tableParser.js +7 -0
  118. package/dist/i18n/loadMessages.d.ts +5 -0
  119. package/dist/i18n/loadMessages.js +46 -0
  120. package/dist/i18n/locales.d.ts +3 -0
  121. package/dist/i18n/locales.js +17 -0
  122. package/dist/i18n/messages.d.ts +3 -2
  123. package/dist/i18n/messages.js +4 -16
  124. package/dist/index.d.ts +3 -3
  125. package/dist/index.js +2 -3
  126. package/dist/internal/clipboardTransformPlugin.d.ts +3 -0
  127. package/dist/internal/clipboardTransformPlugin.js +13 -0
  128. package/dist/internal/extensionRuntime.d.ts +7 -0
  129. package/dist/internal/extensionRuntime.js +28 -0
  130. package/dist/internal/starterKitExtensions.d.ts +20 -0
  131. package/dist/internal/starterKitExtensions.js +123 -0
  132. package/dist/internal/wholeStoryRevisionResolution.js +1 -1
  133. package/dist/managers/ContextMenuManager.js +2 -1
  134. package/dist/managers/editorShortcuts.d.ts +1 -1
  135. package/dist/prosemirror/anchoredTextBoxes.d.ts +1 -1
  136. package/dist/prosemirror/attrs/index.js +1 -1
  137. package/dist/prosemirror/canonicalCommands.d.ts +1 -1
  138. package/dist/prosemirror/canonicalSelectionRange.d.ts +1 -1
  139. package/dist/prosemirror/canonicalSelectionRange.js +1 -1
  140. package/dist/prosemirror/canonicalTableCommands.js +3 -3
  141. package/dist/prosemirror/commands/comments.js +4 -4
  142. package/dist/prosemirror/commands/contentControls.d.ts +1 -1
  143. package/dist/prosemirror/commands/contentControls.js +1 -1
  144. package/dist/prosemirror/commands/formatPainter.d.ts +1 -1
  145. package/dist/prosemirror/commands/formatting.d.ts +1 -1
  146. package/dist/prosemirror/commands/pastePlainText.d.ts +1 -1
  147. package/dist/prosemirror/commands/pastePlainText.js +2 -3
  148. package/dist/prosemirror/commands/replaceRangeText.js +1 -1
  149. package/dist/prosemirror/commands/sectionBreak.js +1 -1
  150. package/dist/prosemirror/commands/tableCellMergeResolution.d.ts +1 -1
  151. package/dist/prosemirror/commands/tableMergeFoldDecisions.d.ts +1 -1
  152. package/dist/prosemirror/commentRecords.d.ts +1 -1
  153. package/dist/prosemirror/commentRecords.js +2 -2
  154. package/dist/prosemirror/contentControlRevisions.d.ts +1 -1
  155. package/dist/prosemirror/conversion/fromProseDoc.d.ts +0 -5
  156. package/dist/prosemirror/conversion/fromProseDoc.js +2 -9
  157. package/dist/prosemirror/conversion/index.d.ts +2 -2
  158. package/dist/prosemirror/conversion/index.js +2 -2
  159. package/dist/prosemirror/documentStructureCounts.d.ts +24 -0
  160. package/dist/prosemirror/documentStructureCounts.js +76 -0
  161. package/dist/prosemirror/extensions/ExtensionManager.d.ts +1 -1
  162. package/dist/prosemirror/extensions/ExtensionManager.js +4 -22
  163. package/dist/prosemirror/extensions/StarterKit.d.ts +4 -27
  164. package/dist/prosemirror/extensions/StarterKit.js +29 -115
  165. package/dist/prosemirror/extensions/core/ParagraphExtension.js +1 -1
  166. package/dist/prosemirror/extensions/core/historyCommands.d.ts +16 -0
  167. package/dist/prosemirror/extensions/core/historyCommands.js +19 -0
  168. package/dist/prosemirror/extensions/features/AutoBidiDetectionExtension.js +1 -1
  169. package/dist/prosemirror/extensions/features/BaseKeymapExtension.js +1 -1
  170. package/dist/prosemirror/extensions/features/ListExtension.js +7 -2
  171. package/dist/prosemirror/extensions/features/pastedCellSections.d.ts +1 -1
  172. package/dist/prosemirror/extensions/index.d.ts +2 -1
  173. package/dist/prosemirror/extensions/marks/FootnoteRefExtension.js +8 -3
  174. package/dist/prosemirror/extensions/marks/markUtils.d.ts +1 -1
  175. package/dist/prosemirror/extensions/nodes/TableExtension.d.ts +1 -1
  176. package/dist/prosemirror/extensions/nodes/TableExtension.js +8 -41
  177. package/dist/prosemirror/extensions/types.d.ts +1 -1
  178. package/dist/prosemirror/findReplaceSelection.d.ts +1 -1
  179. package/dist/prosemirror/hyperlinkRemoval.d.ts +1 -1
  180. package/dist/prosemirror/hyperlinkRemoval.js +7 -2
  181. package/dist/prosemirror/index.d.ts +3 -3
  182. package/dist/prosemirror/index.js +3 -3
  183. package/dist/prosemirror/insertionGaps.d.ts +1 -1
  184. package/dist/prosemirror/keptRangeBoundaries.d.ts +1 -1
  185. package/dist/prosemirror/keptRangeBoundaries.js +1 -1
  186. package/dist/prosemirror/listNumbering.d.ts +1 -1
  187. package/dist/prosemirror/listNumbering.js +1 -1
  188. package/dist/prosemirror/lockedControls.d.ts +1 -1
  189. package/dist/prosemirror/markupViewProjection.d.ts +1 -1
  190. package/dist/prosemirror/noteReferenceOccurrences.d.ts +1 -1
  191. package/dist/prosemirror/noteReferenceOccurrences.js +1 -1
  192. package/dist/prosemirror/noteReferenceReview.d.ts +2 -56
  193. package/dist/prosemirror/noteReferenceReview.js +2 -243
  194. package/dist/prosemirror/{extensions/features/ParaIdAllocatorExtension.d.ts → paraIds.d.ts} +13 -23
  195. package/dist/prosemirror/paraIds.js +152 -0
  196. package/dist/prosemirror/paragraphChangeTrackerMeta.d.ts +97 -0
  197. package/dist/prosemirror/paragraphChangeTrackerMeta.js +87 -0
  198. package/dist/prosemirror/paragraphMarkJoin.d.ts +1 -1
  199. package/dist/prosemirror/paragraphPropertyCarry.d.ts +1 -1
  200. package/dist/prosemirror/pastedCommentCopies.d.ts +1 -1
  201. package/dist/prosemirror/plugins/createDocScanPlugin.d.ts +1 -1
  202. package/dist/prosemirror/plugins/documentNumbering.d.ts +1 -1
  203. package/dist/prosemirror/plugins/documentNumbering.js +1 -1
  204. package/dist/prosemirror/plugins/documentStyles.js +1 -1
  205. package/dist/prosemirror/plugins/templateDirectives.d.ts +1 -1
  206. package/dist/prosemirror/rebaseParagraphRunFormatting.d.ts +1 -1
  207. package/dist/prosemirror/rebaseParagraphRuns.d.ts +1 -1
  208. package/dist/prosemirror/rejoinRunCarriers.d.ts +1 -1
  209. package/dist/prosemirror/replacedAnnotations.d.ts +1 -1
  210. package/dist/prosemirror/replacedAnnotations.js +17 -2
  211. package/dist/prosemirror/revisionCarriers.d.ts +1 -1
  212. package/dist/prosemirror/runFormattingInlineCarriers.d.ts +1 -1
  213. package/dist/prosemirror/sectionMarkEdits.d.ts +1 -1
  214. package/dist/prosemirror/selectionBounds.d.ts +10 -0
  215. package/dist/prosemirror/selectionBounds.js +22 -0
  216. package/dist/prosemirror/storyListNumbering.d.ts +1 -1
  217. package/dist/prosemirror/suggestionCommands.d.ts +47 -0
  218. package/dist/prosemirror/suggestionCommands.js +31 -0
  219. package/dist/prosemirror/tableCellPaste.d.ts +1 -1
  220. package/dist/prosemirror/tableCellPaste.js +1 -1
  221. package/dist/prosemirror/tableGridMutation.d.ts +1 -1
  222. package/dist/prosemirror/tableRunIn.js +1 -1
  223. package/dist/prosemirror/textInput.d.ts +1 -1
  224. package/dist/prosemirror/textInput.js +1 -1
  225. package/dist/server.d.ts +7 -2
  226. package/dist/server.js +6 -1
  227. package/dist/types/canonicalCapabilities.d.ts +13 -92
  228. package/dist/types/canonicalCapabilities.js +11 -85
  229. package/package.json +4 -4
  230. package/dist/ai-edits/apply.d.ts +0 -202
  231. package/dist/ai-edits/apply.js +0 -6759
  232. package/dist/ai-edits/note-story-inventory.d.ts +0 -5
  233. package/dist/ai-edits/note-story-inventory.js +0 -10
  234. package/dist/ai-edits/revisionStretches.d.ts +0 -32
  235. package/dist/ai-edits/revisionStretches.js +0 -147
  236. package/dist/prosemirror/extensions/core/HistoryExtension.d.ts +0 -18
  237. package/dist/prosemirror/extensions/core/HistoryExtension.js +0 -122
  238. package/dist/prosemirror/extensions/features/ParaIdAllocatorExtension.js +0 -408
  239. package/dist/prosemirror/extensions/features/ParagraphChangeTrackerExtension.d.ts +0 -135
  240. package/dist/prosemirror/extensions/features/ParagraphChangeTrackerExtension.js +0 -566
  241. package/dist/prosemirror/plugins/suggestionMode.d.ts +0 -92
  242. package/dist/prosemirror/plugins/suggestionMode.js +0 -1515
  243. package/dist/prosemirror/tablePositionedBookmarks.d.ts +0 -8
  244. package/dist/prosemirror/tablePositionedBookmarks.js +0 -80
@@ -0,0 +1,99 @@
1
+ import { RELATIONSHIP_TYPES, parseRelationships, resolveRelativePath } from "../../relsParser.js";
2
+ import { loadDocxArchive } from "../boundedArchive.js";
3
+ import { TemplatePlanError } from "./types.js";
4
+ import { Result } from "better-result";
5
+ import { createHash } from "node:crypto";
6
+ // src/docx/server/templatePlan/package.ts
7
+ /** A DOCX package opened for reading: its parts, and the parts its main document names. */
8
+ const sha256Hex = (bytes) => createHash("sha256").update(bytes).digest("hex");
9
+ const relationshipsPathFor = (partPath) => {
10
+ const slash = partPath.lastIndexOf("/");
11
+ return `${slash === -1 ? "" : `${partPath.slice(0, slash)}/`}_rels/${partPath.slice(slash + 1)}.rels`;
12
+ };
13
+ const PACKAGE_RELATIONSHIPS_PATH = "_rels/.rels";
14
+ const DEFAULT_DOCUMENT_PATH = "word/document.xml";
15
+ /** Open `bytes` within folio's archive and XML limits. */
16
+ const loadPackage = async (bytes) => {
17
+ const opened = await Result.tryPromise({
18
+ try: async () => {
19
+ const archive = await loadDocxArchive(bytes);
20
+ const paths = new Set(archive.entries);
21
+ const officeDocument = [...parseRelationships(await archive.readEntryString(PACKAGE_RELATIONSHIPS_PATH) ?? "").values()].find(({ type }) => type === RELATIONSHIP_TYPES.officeDocument);
22
+ const documentPath = officeDocument === void 0 ? DEFAULT_DOCUMENT_PATH : resolveRelativePath(PACKAGE_RELATIONSHIPS_PATH, officeDocument.target);
23
+ const documentXml = await archive.readEntryString(documentPath);
24
+ const documentRelationshipsPath = relationshipsPathFor(documentPath);
25
+ return {
26
+ archive,
27
+ paths,
28
+ documentPath,
29
+ documentXml,
30
+ documentRelationshipsPath,
31
+ documentRelationships: parseRelationships(await archive.readEntryString(documentRelationshipsPath) ?? "")
32
+ };
33
+ },
34
+ catch: (cause) => new TemplatePlanError({
35
+ message: "The DOCX package could not be read.",
36
+ code: "archive-unreadable",
37
+ cause
38
+ })
39
+ });
40
+ if (Result.isError(opened)) return opened;
41
+ const { archive, paths, documentPath, documentXml, documentRelationshipsPath, documentRelationships } = opened.value;
42
+ if (documentXml === null) return Result.err(new TemplatePlanError({
43
+ message: "The DOCX package has no main document part.",
44
+ code: "part-missing",
45
+ part: documentPath
46
+ }));
47
+ const resolveDocumentTarget = (target) => resolveRelativePath(documentRelationshipsPath, target);
48
+ const declaredPath = (kind) => {
49
+ const relationship = [...documentRelationships.values()].find(({ type, targetMode }) => type === RELATIONSHIP_TYPES[kind] && targetMode !== "External");
50
+ return relationship === void 0 ? null : resolveDocumentTarget(relationship.target);
51
+ };
52
+ return Result.ok({
53
+ bytes,
54
+ sha256: sha256Hex(bytes),
55
+ paths,
56
+ readText: async (path) => await archive.readEntryString(path),
57
+ readBytes: async (path) => await archive.readEntryUint8(path),
58
+ documentPath,
59
+ documentXml,
60
+ documentRelationshipsPath,
61
+ documentRelationships,
62
+ partPath: (kind) => {
63
+ const path = declaredPath(kind);
64
+ return path !== null && paths.has(path) ? path : null;
65
+ },
66
+ missingPartPath: (kind) => {
67
+ const path = declaredPath(kind);
68
+ return path === null || paths.has(path) ? null : path;
69
+ },
70
+ resolveDocumentTarget
71
+ });
72
+ };
73
+ /** Read an XML part, refusing one the archive could not hand out. */
74
+ const readPartText = async (pkg, path) => {
75
+ if (path === null) return Result.ok(null);
76
+ return await Result.tryPromise({
77
+ try: async () => await pkg.readText(path),
78
+ catch: (cause) => new TemplatePlanError({
79
+ message: `The part ${path} could not be read.`,
80
+ code: "xml-unreadable",
81
+ part: path,
82
+ cause
83
+ })
84
+ });
85
+ };
86
+ /**
87
+ * Run one public entry of the module. Whatever a hostile or malformed
88
+ * package makes a shared helper throw comes back as a typed refusal, so no
89
+ * caller has to guard the call.
90
+ */
91
+ const guarded = async (run) => Result.flatten(await Result.tryPromise({
92
+ try: run,
93
+ catch: (cause) => cause instanceof TemplatePlanError ? cause : new TemplatePlanError({
94
+ message: "The package could not be processed.",
95
+ code: "xml-unreadable",
96
+ cause
97
+ })
98
+ }));
99
+ export { guarded, loadPackage, readPartText, relationshipsPathFor, sha256Hex };
@@ -0,0 +1,145 @@
1
+ /**
2
+ * A template plan checked against its source and template and resolved into
3
+ * what the output must hold: per output paragraph the expected text and
4
+ * emphasis, derived from the source blocks alone. The writer emits it and the
5
+ * verifier compares the written package against it.
6
+ */
7
+ import { XmlElement } from "../../xmlParser.js";
8
+ import { AnalyzedBlock, AnalyzedDocument } from "./blocks.js";
9
+ import { BookmarkWrap } from "./builders.js";
10
+ import { StoryOrigin } from "./resources.js";
11
+ import { AtomKind, AtomLink, InlineAtom, ParagraphRead, StoryField } from "./story.js";
12
+ import { TemplatePlan, TemplatePlanError, TemplatePlanOmitReason, TemplatePlanReference } from "./types.js";
13
+ import { Result } from "better-result";
14
+ export type ExpectedPiece = {
15
+ kind: AtomKind;
16
+ text: string;
17
+ /** The emphasis the piece states over its paragraph's style. */
18
+ signature: string;
19
+ link: AtomLink | null;
20
+ /** The source atom, for what only the source can supply: notes, objects, symbols. */
21
+ atom: InlineAtom | null;
22
+ /** The part the atom was read from: the main document or a notes part. */
23
+ origin: PieceOrigin;
24
+ };
25
+ export type PieceOrigin = StoryOrigin;
26
+ export type ExpectedSegment = {
27
+ kind: "piece";
28
+ piece: ExpectedPiece;
29
+ } | {
30
+ kind: "reference";
31
+ reference: TemplatePlanReference;
32
+ pieces: ExpectedPiece[];
33
+ replacedText: string;
34
+ };
35
+ export type NumberingMint = {
36
+ key: string;
37
+ numId: number;
38
+ /** The template list the instance copies its level overrides from. */
39
+ baseNumId: number;
40
+ abstractNumId: number;
41
+ /** The number each restarted level begins with. */
42
+ starts: Map<number, number>;
43
+ };
44
+ export type ResolvedNumbering = {
45
+ kind: "style";
46
+ } | {
47
+ kind: "none";
48
+ } | {
49
+ kind: "direct";
50
+ numId: number;
51
+ ilvl: number;
52
+ };
53
+ export type ResolvedPart = {
54
+ block: AnalyzedBlock;
55
+ strippedPrefix: string;
56
+ /** The automatic label written as text before the part, or null. */
57
+ labelAsText: string | null;
58
+ };
59
+ export type ResolvedParagraph = {
60
+ parts: ResolvedPart[];
61
+ /** A paragraph style of the template; null leaves the paragraph unstyled. */
62
+ styleId: string | null;
63
+ numbering: ResolvedNumbering;
64
+ segments: ExpectedSegment[];
65
+ text: string;
66
+ /** One signature per UTF-16 unit of `text`. */
67
+ signatures: string[];
68
+ inlineObjects: number;
69
+ placement: "body" | "nested" | "slot";
70
+ };
71
+ export type ResolvedItem = {
72
+ kind: "template";
73
+ block: AnalyzedBlock;
74
+ } | {
75
+ kind: "paragraph";
76
+ paragraph: ResolvedParagraph;
77
+ } | {
78
+ kind: "table";
79
+ block: AnalyzedBlock;
80
+ styleId: string | null;
81
+ /** The resolved paragraph of each nested `w:p`. */
82
+ cells: Map<XmlElement, ResolvedParagraph>;
83
+ } | {
84
+ kind: "slot";
85
+ templateBlock: AnalyzedBlock;
86
+ paragraph: ResolvedParagraph;
87
+ };
88
+ export type ResolvedSlot = {
89
+ templateBlock: AnalyzedBlock;
90
+ paragraph: ResolvedParagraph;
91
+ };
92
+ export type ResolvedPlan = {
93
+ items: ResolvedItem[];
94
+ /** Slots that sit inside a kept template table. */
95
+ nestedSlots: ResolvedSlot[];
96
+ /** The output paragraph each placed source block ends up in. */
97
+ byBlockId: Map<string, ResolvedParagraph>;
98
+ omitted: Map<string, TemplatePlanOmitReason>;
99
+ mints: NumberingMint[];
100
+ /** The bookmark of every paragraph a reference targets. */
101
+ bookmarks: Map<ResolvedParagraph, BookmarkWrap>;
102
+ references: {
103
+ reference: TemplatePlanReference;
104
+ paragraph: ResolvedParagraph;
105
+ target: ResolvedParagraph;
106
+ replacedText: string;
107
+ instruction: string;
108
+ }[];
109
+ freezeKinds: ReadonlySet<string>;
110
+ keptTemplateBlocks: AnalyzedBlock[];
111
+ };
112
+ /**
113
+ * Whether `label` reads as a manual list label: up to three leading words
114
+ * ("Article", "§", "Annex No.") and one designator, a number, a roman numeral
115
+ * or a letter with its brackets and punctuation; or a single bullet. This is
116
+ * the only text a plan may have removed.
117
+ */
118
+ export declare const isManualLabel: (label: string) => boolean;
119
+ /** Whether a block holds no text and no object. */
120
+ export declare const isBlankBlock: ({ block }: AnalyzedBlock) => boolean;
121
+ export type SignatureContext = Pick<AnalyzedDocument, "styles" | "defaultStyleId" | "defaultEmphasis">;
122
+ export type ParagraphPiecesOptions = {
123
+ read: ParagraphRead;
124
+ /** Styles of the document the paragraph was read from. */
125
+ context: SignatureContext;
126
+ origin: PieceOrigin;
127
+ /** The fields of the story the paragraph belongs to. */
128
+ fields: readonly StoryField[];
129
+ };
130
+ /** The link a HYPERLINK field makes: its address and the place in it, if any. */
131
+ export declare const hyperlinkFieldLink: ({ instruction, kind }: StoryField) => AtomLink | null;
132
+ /** The pieces of one source paragraph, each with the emphasis it states. */
133
+ export declare const paragraphPieces: ({ read, context: { styles, defaultStyleId, defaultEmphasis }, origin, fields }: ParagraphPiecesOptions) => ExpectedPiece[];
134
+ /** The pieces of a segment list in order, reference results included. */
135
+ export declare const segmentPieces: (segments: readonly ExpectedSegment[]) => ExpectedPiece[];
136
+ /** The expected text and per-unit signatures of a piece list. */
137
+ export declare const piecesContent: (pieces: readonly ExpectedPiece[]) => {
138
+ text: string;
139
+ signatures: string[];
140
+ };
141
+ /**
142
+ * Check `plan` against the analysed source and template and resolve it.
143
+ * Every refusal the engine documents is decided here, before anything is written.
144
+ */
145
+ export declare const resolvePlan: (source: AnalyzedDocument, template: AnalyzedDocument, plan: TemplatePlan) => Result<ResolvedPlan, TemplatePlanError>;