@sobree/core 0.1.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 (127) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +106 -0
  3. package/dist/__vite-browser-external-DYxpcVy9.js +5 -0
  4. package/dist/__vite-browser-external-DYxpcVy9.js.map +1 -0
  5. package/dist/blob/cache.d.ts +69 -0
  6. package/dist/blob/fetch.d.ts +18 -0
  7. package/dist/blob/hash.d.ts +13 -0
  8. package/dist/blob/index.d.ts +33 -0
  9. package/dist/blob/memory.d.ts +2 -0
  10. package/dist/blob/types.d.ts +80 -0
  11. package/dist/createSobree.d.ts +132 -0
  12. package/dist/doc/api.d.ts +132 -0
  13. package/dist/doc/builders.d.ts +42 -0
  14. package/dist/doc/pageSetupBridge.d.ts +26 -0
  15. package/dist/doc/parts.d.ts +18 -0
  16. package/dist/doc/runs.d.ts +47 -0
  17. package/dist/doc/styles.d.ts +19 -0
  18. package/dist/doc/types.d.ts +800 -0
  19. package/dist/doc/walk.d.ts +30 -0
  20. package/dist/docx/export/contentTypes.d.ts +35 -0
  21. package/dist/docx/export/context.d.ts +59 -0
  22. package/dist/docx/export/document.d.ts +19 -0
  23. package/dist/docx/export/drawings.d.ts +10 -0
  24. package/dist/docx/export/headers.d.ts +19 -0
  25. package/dist/docx/export/index.d.ts +14 -0
  26. package/dist/docx/export/runs.d.ts +8 -0
  27. package/dist/docx/export/styles.d.ts +8 -0
  28. package/dist/docx/export/zip.d.ts +13 -0
  29. package/dist/docx/import/anchoredFrames.d.ts +34 -0
  30. package/dist/docx/import/comments.d.ts +3 -0
  31. package/dist/docx/import/document.d.ts +57 -0
  32. package/dist/docx/import/flowFrames.d.ts +11 -0
  33. package/dist/docx/import/footnotes.d.ts +3 -0
  34. package/dist/docx/import/headers.d.ts +50 -0
  35. package/dist/docx/import/index.d.ts +12 -0
  36. package/dist/docx/import/inlineFrames.d.ts +62 -0
  37. package/dist/docx/import/numbering.d.ts +2 -0
  38. package/dist/docx/import/paragraph.d.ts +24 -0
  39. package/dist/docx/import/paragraphs.d.ts +27 -0
  40. package/dist/docx/import/rels.d.ts +5 -0
  41. package/dist/docx/import/runs.d.ts +64 -0
  42. package/dist/docx/import/settings.d.ts +48 -0
  43. package/dist/docx/import/styles.d.ts +3 -0
  44. package/dist/docx/import/tables.d.ts +12 -0
  45. package/dist/docx/import/unzip.d.ts +13 -0
  46. package/dist/docx/shared/namespaces.d.ts +31 -0
  47. package/dist/docx/shared/pageSize.d.ts +27 -0
  48. package/dist/docx/shared/shading.d.ts +2 -0
  49. package/dist/docx/shared/units.d.ts +35 -0
  50. package/dist/docx/shared/xml.d.ts +29 -0
  51. package/dist/docx/types.d.ts +98 -0
  52. package/dist/editor/index.d.ts +1078 -0
  53. package/dist/editor/internal/blockRegistry.d.ts +91 -0
  54. package/dist/editor/internal/mutations.d.ts +63 -0
  55. package/dist/editor/internal/positionMap.d.ts +35 -0
  56. package/dist/editor/table.d.ts +96 -0
  57. package/dist/editor/view/docRenderer/anchorLayer.d.ts +26 -0
  58. package/dist/editor/view/docRenderer/block.d.ts +13 -0
  59. package/dist/editor/view/docRenderer/fontFallback.d.ts +28 -0
  60. package/dist/editor/view/docRenderer/index.d.ts +18 -0
  61. package/dist/editor/view/docRenderer/inline.d.ts +15 -0
  62. package/dist/editor/view/docRenderer/inlineFrame.d.ts +4 -0
  63. package/dist/editor/view/docRenderer/lists.d.ts +28 -0
  64. package/dist/editor/view/docRenderer/paragraph.d.ts +2 -0
  65. package/dist/editor/view/docRenderer/properties.d.ts +2 -0
  66. package/dist/editor/view/docRenderer/table.d.ts +15 -0
  67. package/dist/editor/view/docRenderer/units.d.ts +48 -0
  68. package/dist/editor/view/docSerialize/block.d.ts +14 -0
  69. package/dist/editor/view/docSerialize/index.d.ts +8 -0
  70. package/dist/editor/view/docSerialize/inline.d.ts +11 -0
  71. package/dist/editor/view/docSerialize/table.d.ts +12 -0
  72. package/dist/editor/view/imageResize.d.ts +16 -0
  73. package/dist/embed/floatingCorner.d.ts +44 -0
  74. package/dist/embed/viewport.d.ts +133 -0
  75. package/dist/fonts/embedAPI.d.ts +33 -0
  76. package/dist/fonts/emit.d.ts +24 -0
  77. package/dist/fonts/fontFaceRegistry.d.ts +20 -0
  78. package/dist/fonts/fsType.d.ts +36 -0
  79. package/dist/fonts/index.d.ts +19 -0
  80. package/dist/fonts/liveness.d.ts +2 -0
  81. package/dist/fonts/odttf.d.ts +33 -0
  82. package/dist/fonts/parse.d.ts +29 -0
  83. package/dist/fonts/types.d.ts +52 -0
  84. package/dist/headless.d.ts +168 -0
  85. package/dist/history/history.d.ts +100 -0
  86. package/dist/history/index.d.ts +4 -0
  87. package/dist/history/types.d.ts +54 -0
  88. package/dist/index.css +1 -0
  89. package/dist/index.d.ts +52 -0
  90. package/dist/index.js +10561 -0
  91. package/dist/index.js.map +1 -0
  92. package/dist/markdown/parse.d.ts +6 -0
  93. package/dist/pagination/cost.d.ts +32 -0
  94. package/dist/pagination/index.d.ts +2 -0
  95. package/dist/pagination/paginate.d.ts +10 -0
  96. package/dist/pagination/postConditions.d.ts +10 -0
  97. package/dist/pagination/types.d.ts +94 -0
  98. package/dist/paperStack/pageSetup.d.ts +42 -0
  99. package/dist/paperStack/paginationAdapter/buildItems.d.ts +19 -0
  100. package/dist/paperStack/paginationAdapter/distribute.d.ts +23 -0
  101. package/dist/paperStack/paginationAdapter/index.d.ts +18 -0
  102. package/dist/paperStack/paginationAdapter/paragraphLines.d.ts +23 -0
  103. package/dist/paperStack/paginationAdapter/splitList.d.ts +19 -0
  104. package/dist/paperStack/paginationAdapter/splitParagraph.d.ts +21 -0
  105. package/dist/paperStack/paginationAdapter/types.d.ts +30 -0
  106. package/dist/paperStack/paper.d.ts +107 -0
  107. package/dist/paperStack/paperStack.d.ts +245 -0
  108. package/dist/plugin.d.ts +24 -0
  109. package/dist/plugins/marks.d.ts +49 -0
  110. package/dist/plugins/sections.d.ts +15 -0
  111. package/dist/presence/attach.d.ts +48 -0
  112. package/dist/presence/awareness.d.ts +28 -0
  113. package/dist/presence/index.d.ts +19 -0
  114. package/dist/presence/overlay.d.ts +28 -0
  115. package/dist/presence/state.d.ts +36 -0
  116. package/dist/sobree.d.ts +211 -0
  117. package/dist/tokens.css +144 -0
  118. package/dist/util/selection.d.ts +13 -0
  119. package/dist/ydoc/apply.d.ts +68 -0
  120. package/dist/ydoc/index.d.ts +18 -0
  121. package/dist/ydoc/project.d.ts +41 -0
  122. package/dist/ydoc/runs.d.ts +51 -0
  123. package/dist/ydoc/schema.d.ts +123 -0
  124. package/dist/ydoc/seed.d.ts +45 -0
  125. package/dist/ydoc/textDiff.d.ts +59 -0
  126. package/dist/zoneEdit/index.d.ts +22 -0
  127. package/package.json +61 -0
@@ -0,0 +1,26 @@
1
+ import { PageSetup } from '../paperStack/pageSetup';
2
+ import { Block, SectionProperties } from './types';
3
+ export interface SectionMaterials {
4
+ section: SectionProperties;
5
+ headerFooterBodies: Record<string, Block[]>;
6
+ }
7
+ /**
8
+ * Translate `PageSetup` → `SectionProperties` plus the header/footer body
9
+ * blocks. Allocates part ids (`header1.xml`, `footer1.xml`, …) following
10
+ * Word's canonical numbering.
11
+ */
12
+ export declare function pageSetupToSection(setup: PageSetup): SectionMaterials;
13
+ /**
14
+ * Translate `SectionProperties` + header/footer bodies → a sparse
15
+ * `Partial<PageSetup>`. Keys are only present if the section actually
16
+ * specified them, so callers can merge cleanly with their current setup.
17
+ */
18
+ export declare function sectionToPageSetup(section: SectionProperties, bodies: Record<string, Block[]>): Partial<PageSetup>;
19
+ /**
20
+ * Parse a header/footer template (plain text with `{page}` / `{pages}`
21
+ * tokens) into Block[] — one paragraph per line. Field tokens become
22
+ * FieldRun nodes so Word's PAGE/NUMPAGES field codes emit naturally.
23
+ */
24
+ export declare function templateToBlocks(template: string): Block[];
25
+ /** Reverse of `templateToBlocks`. Used on import. */
26
+ export declare function blocksToTemplate(blocks: readonly Block[]): string;
@@ -0,0 +1,18 @@
1
+ import { SobreeDocument } from './types';
2
+ /**
3
+ * Walk the document and return the set of `rawParts` keys that
4
+ * something in the AST still points at. Anything else is an orphan.
5
+ */
6
+ export declare function collectLivePartPaths(doc: SobreeDocument): Set<string>;
7
+ /**
8
+ * Return a new document whose `rawParts` only contains live keys.
9
+ * Reports which keys were dropped. The document is otherwise unchanged
10
+ * — no AST mutation, no version bumps, no header/footer churn.
11
+ *
12
+ * Idempotent: pruning an already-clean doc is a no-op.
13
+ */
14
+ export declare function pruneOrphanParts(doc: SobreeDocument): {
15
+ doc: SobreeDocument;
16
+ kept: number;
17
+ pruned: string[];
18
+ };
@@ -0,0 +1,47 @@
1
+ import { InlineRun, RunProperties } from './types';
2
+ /**
3
+ * Character-length of a single InlineRun, matching the counting rules
4
+ * used by the DOM ↔ position map:
5
+ * - TextRun → `text.length`.
6
+ * - BreakRun / TabRun / DrawingRun → 1 each.
7
+ * - FieldRun → length of its cached value (empty = 0).
8
+ * - HyperlinkRun → sum of its children's lengths.
9
+ */
10
+ export declare function runLength(run: InlineRun): number;
11
+ export declare function runsLength(runs: readonly InlineRun[]): number;
12
+ /**
13
+ * Split a runs array at `offset` characters from the start. Returns two
14
+ * arrays whose concatenated content is equivalent to the input. Splitting
15
+ * *through* a TextRun produces two TextRuns with the same properties;
16
+ * splitting through an atom puts the whole atom on one side (ties go to
17
+ * "before" at the atom's end boundary and "after" at the start boundary).
18
+ */
19
+ export declare function splitRunsAt(runs: readonly InlineRun[], offset: number): {
20
+ before: InlineRun[];
21
+ after: InlineRun[];
22
+ };
23
+ /**
24
+ * Slice a runs array between two character offsets (inclusive `from`,
25
+ * exclusive `to`). Used by `applyRunProperties` / `wrapRange` to isolate
26
+ * the affected middle section.
27
+ */
28
+ export declare function sliceRuns(runs: readonly InlineRun[], from: number, to: number): InlineRun[];
29
+ /**
30
+ * Patch shape accepted by `applyRunPropertiesToRuns`. Keys set to
31
+ * `undefined` remove the corresponding property from affected runs;
32
+ * keys set to a value override.
33
+ */
34
+ export type RunPropertiesPatch = {
35
+ [K in keyof RunProperties]?: RunProperties[K] | undefined;
36
+ };
37
+ /**
38
+ * Return a new runs array with `patch` merged into every TextRun's
39
+ * properties (and recursively into HyperlinkRun children). Atoms
40
+ * without `properties` pass through unchanged.
41
+ */
42
+ export declare function applyRunPropertiesToRuns(runs: readonly InlineRun[], patch: RunPropertiesPatch): InlineRun[];
43
+ /**
44
+ * Concatenate runs and merge adjacent TextRuns with identical property
45
+ * shapes. Minor cleanup for operations that leave fragmentation behind.
46
+ */
47
+ export declare function mergeAdjacentTextRuns(runs: readonly InlineRun[]): InlineRun[];
@@ -0,0 +1,19 @@
1
+ import { NamedStyle, ParagraphProperties, RunProperties, SobreeDocument } from './types';
2
+ /**
3
+ * Style-cascade resolver — walks `styleId` up its `basedOn` chain and
4
+ * merges defaults base-first, leaf-last. The result is what the
5
+ * renderer should apply (block element inherits these to its runs)
6
+ * and what the toolbar's font / mark dropdowns should reflect.
7
+ *
8
+ * Falls back to the document's `Normal` style at the end of the chain
9
+ * so a paragraph with no explicit style still picks up the document's
10
+ * baseline run / paragraph defaults (see `defaultStyles()` in
11
+ * `./builders`).
12
+ *
13
+ * Cycles in `basedOn` are tolerated — we de-dupe by id and stop
14
+ * walking. Missing styles are silently skipped.
15
+ */
16
+ export declare function resolveStyleCascade(styles: readonly NamedStyle[] | SobreeDocument, styleId: string | undefined): {
17
+ runDefaults: RunProperties;
18
+ paragraphDefaults: ParagraphProperties;
19
+ };