@open-document/core 0.1.0 → 0.3.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.
- package/dist/{build-BWZJ1gvL.js → build-C3pMGxJN.js} +2 -6
- package/dist/check-Dtwb1wvU.js +42 -0
- package/dist/cli/bin.d.ts +1 -1
- package/dist/cli/bin.js +124 -13
- package/dist/{config-EBFfKtWH.d.ts → config-CSC5lHsR.d.ts} +3 -2
- package/dist/config-Dg1AMP0r.js +2461 -0
- package/dist/context-FoX0afRf.js +26 -0
- package/dist/{dev-CZtw1oqs.js → dev-Cdd7NZRQ.js} +2 -6
- package/dist/diagram-xlVDekYk.js +763 -0
- package/dist/export-ClJ4T1uU.js +36 -0
- package/dist/import-D7Psi8WK.js +25 -0
- package/dist/index.d.ts +238 -117
- package/dist/index.js +516 -57
- package/dist/ops/index.d.ts +98 -8
- package/dist/ops/index.js +3 -202
- package/dist/ops-Ci5Xw6QG.js +1270 -0
- package/dist/{preview-DUfQl7Ij.js → preview-BhbCiAKC.js} +2 -6
- package/dist/sdk-CWMsH9Ms.d.ts +123 -0
- package/dist/vite/index.d.ts +9 -4
- package/dist/vite/index.js +2 -5
- package/env.d.ts +33 -1
- package/package.json +17 -6
- package/skills/create-doc/SKILL.md +6 -2
- package/skills/current-doc/SKILL.md +120 -0
- package/skills/doc-authoring/SKILL.md +79 -0
- package/skills/doc-authoring/references/long-form.md +131 -0
- package/src/app/components/data-table.tsx +196 -0
- package/src/app/components/diagram.tsx +76 -0
- package/src/app/components/flow-page.tsx +20 -3
- package/src/app/components/footnote.tsx +196 -0
- package/src/app/components/inspector/inspector.tsx +16 -0
- package/src/app/components/numbering.tsx +208 -0
- package/src/app/lib/agent-bridge.ts +128 -0
- package/src/app/lib/diagnostics.ts +282 -0
- package/src/app/lib/export-html.ts +35 -11
- package/src/app/lib/export-pdf.ts +54 -19
- package/src/app/lib/flow-measure.ts +100 -31
- package/src/app/lib/flow.test.ts +46 -0
- package/src/app/lib/flow.ts +28 -3
- package/src/app/lib/footnotes.test.tsx +102 -0
- package/src/app/lib/footnotes.ts +94 -0
- package/src/app/lib/labels.ts +175 -0
- package/src/app/lib/page-context.tsx +6 -1
- package/src/app/lib/scan.ts +26 -0
- package/src/app/lib/sdk.ts +3 -0
- package/src/app/lib/use-doc-pages.ts +50 -15
- package/src/app/routes/doc.tsx +25 -5
- package/dist/config-DBp4mOOf.js +0 -1121
- package/dist/design-BJLvOcCO.js +0 -53
- package/dist/edit-ops-DSdUroVO.js +0 -1225
- package/dist/sync-6GTPAt2t.js +0 -86
- package/dist/sync-C6CsPmyK.js +0 -3
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { g as listDocIds } from "./config-Dg1AMP0r.js";
|
|
2
|
+
import { h as exportDocument, m as closeRenderSession } from "./ops-Ci5Xw6QG.js";
|
|
3
|
+
import { t as cliContext } from "./context-FoX0afRf.js";
|
|
4
|
+
import chalk from "chalk";
|
|
5
|
+
//#region src/cli/export.ts
|
|
6
|
+
const FORMATS = [
|
|
7
|
+
"pdf",
|
|
8
|
+
"html",
|
|
9
|
+
"png"
|
|
10
|
+
];
|
|
11
|
+
/**
|
|
12
|
+
* The Download menu without a browser window — the same render pipeline, driven
|
|
13
|
+
* from a script. This is what makes a document something CI can produce on a
|
|
14
|
+
* schedule rather than something a person has to click.
|
|
15
|
+
*/
|
|
16
|
+
async function exportDocs(docIds, opts = {}) {
|
|
17
|
+
const format = opts.format ?? "pdf";
|
|
18
|
+
if (!FORMATS.includes(format)) throw new Error(`Unknown format "${format}". Expected one of: ${FORMATS.join(", ")}`);
|
|
19
|
+
const ctx = await cliContext();
|
|
20
|
+
const targets = docIds.length > 0 ? docIds : opts.all ? await listDocIds(ctx) : [];
|
|
21
|
+
if (targets.length === 0) throw new Error("Nothing to export. Name a document id, or pass --all.");
|
|
22
|
+
try {
|
|
23
|
+
for (const docId of targets) {
|
|
24
|
+
const result = await exportDocument(ctx, docId, {
|
|
25
|
+
format,
|
|
26
|
+
...opts.outDir !== void 0 ? { outDir: opts.outDir } : {}
|
|
27
|
+
});
|
|
28
|
+
const files = result.files.join(", ");
|
|
29
|
+
process.stdout.write(`${chalk.green("✓")} ${chalk.bold(docId)} ${chalk.dim(`${result.pageCount}p`)} → ${files}\n`);
|
|
30
|
+
}
|
|
31
|
+
} finally {
|
|
32
|
+
await closeRenderSession();
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
//#endregion
|
|
36
|
+
export { exportDocs };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { _ as importMarkdown } from "./ops-Ci5Xw6QG.js";
|
|
2
|
+
import { t as cliContext } from "./context-FoX0afRf.js";
|
|
3
|
+
import chalk from "chalk";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
//#region src/cli/import.ts
|
|
6
|
+
async function importDoc(file, opts = {}) {
|
|
7
|
+
const ctx = await cliContext();
|
|
8
|
+
const relative = path.relative(ctx.userCwd, path.resolve(ctx.userCwd, file));
|
|
9
|
+
const result = await importMarkdown(ctx, {
|
|
10
|
+
file: relative,
|
|
11
|
+
...opts.id !== void 0 ? { docId: opts.id } : {},
|
|
12
|
+
...opts.title !== void 0 ? { title: opts.title } : {},
|
|
13
|
+
...opts.subtitle !== void 0 ? { subtitle: opts.subtitle } : {},
|
|
14
|
+
...opts.author !== void 0 ? { author: opts.author } : {},
|
|
15
|
+
...opts.theme !== void 0 ? { theme: opts.theme } : {},
|
|
16
|
+
...opts.pageSize !== void 0 ? { pageSize: opts.pageSize } : {},
|
|
17
|
+
...opts.cover !== void 0 ? { cover: opts.cover } : {},
|
|
18
|
+
...opts.contents !== void 0 ? { contents: opts.contents } : {}
|
|
19
|
+
});
|
|
20
|
+
process.stdout.write(`${chalk.green("✓")} ${chalk.bold(result.title)} → ${result.entry} ${chalk.dim(`(${result.blocks} blocks)`)}\n`);
|
|
21
|
+
if (result.assets.length > 0) process.stdout.write(chalk.dim(` copied ${result.assets.length} asset(s)\n`));
|
|
22
|
+
for (const missing of result.missingAssets) process.stdout.write(chalk.yellow(` ! image not found, left as written: ${missing}\n`));
|
|
23
|
+
}
|
|
24
|
+
//#endregion
|
|
25
|
+
export { importDoc };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,98 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import * as react2 from "react";
|
|
1
|
+
import { C as useDocLabels, S as useDocLabel, _ as defaultDesign, a as DocPage, b as LabelKind, c as PAGE_SIZES, d as resolvePageGeometry, f as DesignFonts, g as cssVarsToString, h as DesignTypeScale, i as DocModule, l as PageGeometry, m as DesignSystem, n as DocEntry, o as FlowSection, p as DesignPalette, r as DocMeta, s as Orientation, t as DEFAULT_PAGE_SIZE, u as PageSizeName, v as designToCssVars, x as LabelVocabulary, y as LabelEntry } from "./sdk-CWMsH9Ms.js";
|
|
2
|
+
import { n as OpenDocConfig, t as OpenDocBuildConfig } from "./config-CSC5lHsR.js";
|
|
4
3
|
import { CSSProperties, ComponentType, ReactNode } from "react";
|
|
5
|
-
|
|
4
|
+
//#region src/app/components/data-table.d.ts
|
|
5
|
+
type DataAlign = 'left' | 'center' | 'right';
|
|
6
|
+
type DataFormat = 'text' | 'number' | 'integer' | 'percent' | ((value: unknown, row: Record<string, unknown>) => ReactNode);
|
|
7
|
+
type DataColumn = {
|
|
8
|
+
key: string;
|
|
9
|
+
label?: ReactNode;
|
|
10
|
+
align?: DataAlign;
|
|
11
|
+
format?: DataFormat;
|
|
12
|
+
/** Column width. A number is px; `tableLayout: fixed` means these are honoured. */
|
|
13
|
+
width?: number | string;
|
|
14
|
+
};
|
|
15
|
+
type DataTableProps = {
|
|
16
|
+
/** Rows as parsed from a `.csv`/`.tsv` import, or any array of objects. */
|
|
17
|
+
rows: Array<Record<string, unknown>>;
|
|
18
|
+
/** Columns to print, in order. Derived from the first row when omitted. */
|
|
19
|
+
columns?: Array<DataColumn | string>;
|
|
20
|
+
/** Numbers the table and prints the caption above it. */
|
|
21
|
+
caption?: ReactNode;
|
|
22
|
+
/** Stable id for `<Ref to>`. Only meaningful alongside `caption`. */
|
|
23
|
+
id?: string;
|
|
24
|
+
/** Print at most this many rows, with a note about what was left out. */
|
|
25
|
+
limit?: number;
|
|
26
|
+
/** Tighter rows, for a dense appendix table. */
|
|
27
|
+
compact?: boolean;
|
|
28
|
+
/** What an empty cell prints as. Defaults to an em dash. */
|
|
29
|
+
emptyValue?: ReactNode;
|
|
30
|
+
style?: CSSProperties;
|
|
31
|
+
className?: string;
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* A print-shaped table from data, so the numbers in a report come from a file
|
|
35
|
+
* instead of being retyped into JSX. Alignment and grouping follow the column's
|
|
36
|
+
* contents, which is the part people get wrong by hand.
|
|
37
|
+
*/
|
|
38
|
+
declare function DataTable({ rows, columns, caption, id, limit, compact, emptyValue, style, className }: DataTableProps): import("react").JSX.Element;
|
|
39
|
+
//#endregion
|
|
40
|
+
//#region src/app/components/diagram.d.ts
|
|
41
|
+
type DiagramSource = {
|
|
42
|
+
svg: string;
|
|
43
|
+
width: number;
|
|
44
|
+
height: number;
|
|
45
|
+
};
|
|
46
|
+
type DiagramProps = {
|
|
47
|
+
/** The compiled module from `import chart from './architecture.mmd'`. */
|
|
48
|
+
chart: DiagramSource;
|
|
49
|
+
/** Caption text. Given one, the drawing is numbered like any other figure. */
|
|
50
|
+
caption?: ReactNode;
|
|
51
|
+
captionText?: string;
|
|
52
|
+
kind?: LabelKind;
|
|
53
|
+
id?: string;
|
|
54
|
+
/**
|
|
55
|
+
* Drawn width in CSS px. Defaults to the diagram's natural size, capped to
|
|
56
|
+
* the column — a diagram wider than the text block is a layout fault, and
|
|
57
|
+
* `open-doc check` would report it as one.
|
|
58
|
+
*/
|
|
59
|
+
width?: number;
|
|
60
|
+
align?: 'left' | 'center';
|
|
61
|
+
style?: CSSProperties;
|
|
62
|
+
className?: string;
|
|
63
|
+
};
|
|
64
|
+
/**
|
|
65
|
+
* A diagram compiled from Mermaid-flavoured text at build time. The SVG is
|
|
66
|
+
* inlined rather than referenced through `<img>` so it inherits the document's
|
|
67
|
+
* theme variables — an `<img src="data:…">` would be painted in a document of
|
|
68
|
+
* its own, with none of this one's colours or faces.
|
|
69
|
+
*/
|
|
70
|
+
declare function Diagram({ chart, caption, captionText, kind, id, width, align, style, className }: DiagramProps): import("react").JSX.Element;
|
|
71
|
+
//#endregion
|
|
72
|
+
//#region src/app/components/footnote.d.ts
|
|
73
|
+
type CollectedNote = {
|
|
74
|
+
id: string;
|
|
75
|
+
content: ReactNode;
|
|
76
|
+
};
|
|
77
|
+
type FootnoteProps = {
|
|
78
|
+
/** Stable id, so `<Ref to>` can point at the note. Generated when omitted. */
|
|
79
|
+
id?: string;
|
|
80
|
+
children?: ReactNode;
|
|
81
|
+
};
|
|
82
|
+
/**
|
|
83
|
+
* A note anchored to this point in the text. Inside a `flow()` section the
|
|
84
|
+
* framework lifts it to the foot of whatever page the marker lands on; on a
|
|
85
|
+
* fixed page, put a `<Footnotes />` where you want them printed.
|
|
86
|
+
*/
|
|
87
|
+
declare function Footnote({ id, children }: FootnoteProps): import("react").JSX.Element;
|
|
88
|
+
type FootnotesProps = {
|
|
89
|
+
/** Notes to print. Omitted on a fixed page, where they are collected from it. */
|
|
90
|
+
notes?: CollectedNote[];
|
|
91
|
+
style?: CSSProperties;
|
|
92
|
+
className?: string;
|
|
93
|
+
};
|
|
94
|
+
declare function Footnotes({ notes, style, className }: FootnotesProps): import("react").JSX.Element | null;
|
|
95
|
+
//#endregion
|
|
6
96
|
//#region src/app/components/image-placeholder.d.ts
|
|
7
97
|
type ImagePlaceholderProps = {
|
|
8
98
|
/** What the final image should show — the user reads this when replacing it. */
|
|
@@ -17,14 +107,66 @@ type ImagePlaceholderProps = {
|
|
|
17
107
|
* product screenshot). Use it instead of inventing filler — never for
|
|
18
108
|
* decoration.
|
|
19
109
|
*/
|
|
20
|
-
declare function ImagePlaceholder({
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
110
|
+
declare function ImagePlaceholder({ hint, width, height, style, className }: ImagePlaceholderProps): import("react").JSX.Element;
|
|
111
|
+
//#endregion
|
|
112
|
+
//#region src/app/components/numbering.d.ts
|
|
113
|
+
type FigureProps = {
|
|
114
|
+
/** Stable id, so `<Ref to>` can point at it. Generated when omitted. */
|
|
115
|
+
id?: string;
|
|
116
|
+
/** What the caption says after the number. */
|
|
117
|
+
caption?: ReactNode;
|
|
118
|
+
/** `figure` numbers with figures, `table` with tables. Defaults to `figure`. */
|
|
119
|
+
kind?: LabelKind;
|
|
120
|
+
/** Tables conventionally caption above, figures below. */
|
|
121
|
+
captionPosition?: 'above' | 'below';
|
|
122
|
+
/** Plain-text caption for the list of figures, when `caption` carries markup. */
|
|
123
|
+
captionText?: string;
|
|
124
|
+
style?: CSSProperties;
|
|
125
|
+
captionStyle?: CSSProperties;
|
|
126
|
+
className?: string;
|
|
127
|
+
children?: ReactNode;
|
|
128
|
+
};
|
|
129
|
+
/**
|
|
130
|
+
* A numbered figure or table. The number comes from a scan of the rendered
|
|
131
|
+
* pages, not from a counter in the source, so inserting a figure halfway
|
|
132
|
+
* through a document renumbers everything after it — including the references
|
|
133
|
+
* to it — without anyone editing a number.
|
|
134
|
+
*
|
|
135
|
+
* Caption and content are one block, so a `flow()` section never separates them.
|
|
136
|
+
*/
|
|
137
|
+
declare function Figure({ id, caption, kind, captionPosition, captionText, style, captionStyle, className, children }: FigureProps): import("react").JSX.Element;
|
|
138
|
+
type RefProps = {
|
|
139
|
+
/** The `id` of a `<Figure>` or `<Footnote>`. */
|
|
140
|
+
to: string;
|
|
141
|
+
/**
|
|
142
|
+
* Append the page. `auto` (the default) adds it only when the target sits on
|
|
143
|
+
* another sheet, which is the only time a reader needs it.
|
|
144
|
+
*/
|
|
145
|
+
showPage?: boolean | 'auto';
|
|
146
|
+
style?: CSSProperties;
|
|
147
|
+
className?: string;
|
|
148
|
+
};
|
|
149
|
+
/**
|
|
150
|
+
* A cross-reference that resolves after layout: "Figure 3", plus the page when
|
|
151
|
+
* the target is elsewhere. Never write "see Figure 3 on page 12" by hand — both
|
|
152
|
+
* numbers move.
|
|
153
|
+
*/
|
|
154
|
+
declare function Ref({ to, showPage, style, className }: RefProps): import("react").JSX.Element;
|
|
155
|
+
type ListOfProps = {
|
|
156
|
+
kind?: LabelKind;
|
|
157
|
+
/** Show the page number column with dot leaders. Defaults to true. */
|
|
158
|
+
showPageNumbers?: boolean;
|
|
159
|
+
style?: CSSProperties;
|
|
160
|
+
className?: string;
|
|
161
|
+
};
|
|
162
|
+
/**
|
|
163
|
+
* The document's figures or tables as a contents list. Same lifecycle as
|
|
164
|
+
* `<TableOfContents>`: empty on the first render pass, filled once the scan has
|
|
165
|
+
* run — including before an export serializes.
|
|
166
|
+
*/
|
|
167
|
+
declare function ListOf({ kind, showPageNumbers, style, className }: ListOfProps): import("react").JSX.Element;
|
|
168
|
+
declare function ListOfFigures(props: Omit<ListOfProps, 'kind'>): import("react").JSX.Element;
|
|
169
|
+
declare function ListOfTables(props: Omit<ListOfProps, 'kind'>): import("react").JSX.Element;
|
|
28
170
|
//#endregion
|
|
29
171
|
//#region src/app/components/table-of-contents.d.ts
|
|
30
172
|
type TableOfContentsProps = {
|
|
@@ -45,105 +187,7 @@ type TableOfContentsProps = {
|
|
|
45
187
|
* first pass and populated on the next — including during PDF/HTML export,
|
|
46
188
|
* which scans before serializing.
|
|
47
189
|
*/
|
|
48
|
-
declare function TableOfContents({
|
|
49
|
-
maxLevel,
|
|
50
|
-
showPageNumbers,
|
|
51
|
-
includeOwnPage,
|
|
52
|
-
indent,
|
|
53
|
-
style,
|
|
54
|
-
className
|
|
55
|
-
}: TableOfContentsProps): react2.JSX.Element;
|
|
56
|
-
|
|
57
|
-
//#endregion
|
|
58
|
-
//#region src/app/lib/design.d.ts
|
|
59
|
-
type DesignPalette = {
|
|
60
|
-
bg: string;
|
|
61
|
-
text: string;
|
|
62
|
-
muted: string;
|
|
63
|
-
accent: string;
|
|
64
|
-
rule: string;
|
|
65
|
-
};
|
|
66
|
-
type DesignFonts = {
|
|
67
|
-
heading: string;
|
|
68
|
-
body: string;
|
|
69
|
-
mono: string;
|
|
70
|
-
};
|
|
71
|
-
type DesignTypeScale = {
|
|
72
|
-
title: number;
|
|
73
|
-
h1: number;
|
|
74
|
-
h2: number;
|
|
75
|
-
h3: number;
|
|
76
|
-
body: number;
|
|
77
|
-
caption: number;
|
|
78
|
-
};
|
|
79
|
-
type DesignSystem = {
|
|
80
|
-
palette: DesignPalette;
|
|
81
|
-
fonts: DesignFonts;
|
|
82
|
-
typeScale: DesignTypeScale;
|
|
83
|
-
/** Page margin in CSS px — the printable text block's inset from the sheet edge. */
|
|
84
|
-
margin: number;
|
|
85
|
-
/** Body line-height multiplier. Headings tighten this themselves. */
|
|
86
|
-
leading: number;
|
|
87
|
-
radius: number;
|
|
88
|
-
};
|
|
89
|
-
declare function designToCssVars(d: DesignSystem): Record<string, string>;
|
|
90
|
-
declare function cssVarsToString(vars: Record<string, string>): string;
|
|
91
|
-
declare const defaultDesign: DesignSystem;
|
|
92
|
-
|
|
93
|
-
//#endregion
|
|
94
|
-
//#region src/app/lib/sdk.d.ts
|
|
95
|
-
type PageSizeName = 'A4' | 'Letter' | 'A5' | 'Legal';
|
|
96
|
-
type Orientation = 'portrait' | 'landscape';
|
|
97
|
-
/**
|
|
98
|
-
* Page dimensions in CSS pixels at 96dpi — the unit authors write in — paired
|
|
99
|
-
* with the physical `@page size` used when printing. Keeping both means a page
|
|
100
|
-
* laid out at 794×1123 on screen maps to a real A4 sheet with no rescaling.
|
|
101
|
-
*/
|
|
102
|
-
declare const PAGE_SIZES: Record<PageSizeName, {
|
|
103
|
-
width: number;
|
|
104
|
-
height: number;
|
|
105
|
-
css: string;
|
|
106
|
-
}>;
|
|
107
|
-
declare const DEFAULT_PAGE_SIZE: PageSizeName;
|
|
108
|
-
type PageGeometry = {
|
|
109
|
-
width: number;
|
|
110
|
-
height: number;
|
|
111
|
-
/** Value for the `@page { size: … }` descriptor, orientation included. */
|
|
112
|
-
css: string;
|
|
113
|
-
};
|
|
114
|
-
type DocPage = ComponentType;
|
|
115
|
-
/**
|
|
116
|
-
* A run of continuous content the framework paginates itself. Build one with
|
|
117
|
-
* `flow(...)` and put it in the page array alongside fixed pages.
|
|
118
|
-
*/
|
|
119
|
-
type FlowSection = {
|
|
120
|
-
readonly __odFlow: true;
|
|
121
|
-
blocks: ReactNode[];
|
|
122
|
-
/** Rendered on every page the section expands into. */
|
|
123
|
-
footer?: ComponentType;
|
|
124
|
-
/** Page padding override in px; defaults to the design's `margin`. */
|
|
125
|
-
padding?: number;
|
|
126
|
-
};
|
|
127
|
-
/** What a document's default export may contain: fixed pages, flow sections, or both. */
|
|
128
|
-
type DocEntry = DocPage | FlowSection;
|
|
129
|
-
type DocMeta = {
|
|
130
|
-
title?: string;
|
|
131
|
-
subtitle?: string;
|
|
132
|
-
author?: string;
|
|
133
|
-
pageSize?: PageSizeName;
|
|
134
|
-
orientation?: Orientation;
|
|
135
|
-
/** Id of a theme under `themes/` this document was built from. Adds a back-link. */
|
|
136
|
-
theme?: string;
|
|
137
|
-
/** ISO 8601 timestamp. Set once at scaffold time; used to sort the doc list. */
|
|
138
|
-
createdAt?: string;
|
|
139
|
-
};
|
|
140
|
-
type DocModule = {
|
|
141
|
-
default: DocEntry[];
|
|
142
|
-
meta?: DocMeta;
|
|
143
|
-
design?: DesignSystem;
|
|
144
|
-
};
|
|
145
|
-
declare function resolvePageGeometry(meta?: DocMeta): PageGeometry;
|
|
146
|
-
|
|
190
|
+
declare function TableOfContents({ maxLevel, showPageNumbers, includeOwnPage, indent, style, className }: TableOfContentsProps): import("react").JSX.Element;
|
|
147
191
|
//#endregion
|
|
148
192
|
//#region src/app/lib/flow.d.ts
|
|
149
193
|
/**
|
|
@@ -158,6 +202,8 @@ declare function flow(children: ReactNode, opts?: {
|
|
|
158
202
|
declare function isFlowSection(entry: DocEntry): entry is FlowSection;
|
|
159
203
|
type BlockMetrics = {
|
|
160
204
|
height: number;
|
|
205
|
+
/** Height this block's footnotes add to the foot of whatever page it lands on. */
|
|
206
|
+
footnoteHeight?: number;
|
|
161
207
|
/** A heading must not be the last block on a page. */
|
|
162
208
|
keepWithNext?: boolean;
|
|
163
209
|
/** A caption must not open a page without the figure it belongs to. */
|
|
@@ -171,16 +217,22 @@ type PaginationResult = {
|
|
|
171
217
|
/** Blocks taller than one page — they stay whole and overflow. */
|
|
172
218
|
overflowing: number[];
|
|
173
219
|
};
|
|
220
|
+
type PaginateOptions = {
|
|
221
|
+
/** Rule and padding a page's footnote area costs before its first note. */
|
|
222
|
+
footnoteOverhead?: number;
|
|
223
|
+
};
|
|
174
224
|
/**
|
|
175
225
|
* Greedy top-to-bottom packing: fill a page until the next block would cross
|
|
176
226
|
* the bottom edge, then push that block — plus anything glued to it — onto the
|
|
177
227
|
* next page. Blocks are atomic; nothing is split mid-block.
|
|
228
|
+
*
|
|
229
|
+
* Footnotes are packed from the same budget: a block that carries notes brings
|
|
230
|
+
* their height with it, because those notes print at the foot of whichever page
|
|
231
|
+
* the block lands on.
|
|
178
232
|
*/
|
|
179
|
-
declare function paginateBlocks(blocks: BlockMetrics[], available: number): PaginationResult;
|
|
180
|
-
|
|
233
|
+
declare function paginateBlocks(blocks: BlockMetrics[], available: number, opts?: PaginateOptions): PaginationResult;
|
|
181
234
|
//#endregion
|
|
182
235
|
//#region src/app/lib/outline.d.ts
|
|
183
|
-
/** Blocks of the first flow section, for thumbnails that skip measurement. */
|
|
184
236
|
type OutlineEntry = {
|
|
185
237
|
id: string;
|
|
186
238
|
text: string;
|
|
@@ -194,13 +246,82 @@ type OutlineEntry = {
|
|
|
194
246
|
* has run.
|
|
195
247
|
*/
|
|
196
248
|
declare function useDocOutline(): OutlineEntry[];
|
|
197
|
-
|
|
198
249
|
//#endregion
|
|
199
250
|
//#region src/app/lib/page-context.d.ts
|
|
200
251
|
/** 1-based page number of the page currently rendering. `0` outside a page. */
|
|
201
252
|
declare function useDocPageNumber(): number;
|
|
202
253
|
/** Total page count of the document being rendered. `0` outside a page. */
|
|
203
254
|
declare function useDocPageCount(): number;
|
|
204
|
-
|
|
205
255
|
//#endregion
|
|
206
|
-
|
|
256
|
+
//#region src/data/delimited.d.ts
|
|
257
|
+
type CellValue = string | number | null;
|
|
258
|
+
type DelimitedTable = {
|
|
259
|
+
columns: string[];
|
|
260
|
+
rows: Array<Record<string, CellValue>>;
|
|
261
|
+
};
|
|
262
|
+
type ParseOptions = {
|
|
263
|
+
/** Defaults to `,`. Tabs for `.tsv`. */
|
|
264
|
+
delimiter?: string;
|
|
265
|
+
/** Treat the first row as data and name columns `column1`, `column2`, … */
|
|
266
|
+
noHeader?: boolean;
|
|
267
|
+
};
|
|
268
|
+
declare function parseDelimited(text: string, opts?: ParseOptions): DelimitedTable;
|
|
269
|
+
//#endregion
|
|
270
|
+
//#region src/diagram/parse.d.ts
|
|
271
|
+
type Direction = 'TD' | 'LR';
|
|
272
|
+
type NodeShape = 'rect' | 'round' | 'stadium' | 'diamond' | 'circle';
|
|
273
|
+
type DiagramNode = {
|
|
274
|
+
id: string;
|
|
275
|
+
label: string;
|
|
276
|
+
shape: NodeShape;
|
|
277
|
+
};
|
|
278
|
+
type EdgeStyle = 'solid' | 'dashed' | 'thick';
|
|
279
|
+
type DiagramEdge = {
|
|
280
|
+
from: string;
|
|
281
|
+
to: string;
|
|
282
|
+
label: string | null;
|
|
283
|
+
style: EdgeStyle;
|
|
284
|
+
/** A `---` link draws no arrowhead. */
|
|
285
|
+
arrow: boolean;
|
|
286
|
+
};
|
|
287
|
+
type Diagram$1 = {
|
|
288
|
+
direction: Direction;
|
|
289
|
+
nodes: DiagramNode[];
|
|
290
|
+
edges: DiagramEdge[];
|
|
291
|
+
};
|
|
292
|
+
declare class DiagramSyntaxError extends Error {
|
|
293
|
+
readonly line: number;
|
|
294
|
+
constructor(message: string, line: number);
|
|
295
|
+
}
|
|
296
|
+
//#endregion
|
|
297
|
+
//#region src/diagram/layout.d.ts
|
|
298
|
+
type LayoutOptions = {
|
|
299
|
+
fontSize?: number;
|
|
300
|
+
/** Gap between consecutive ranks, along the flow direction. */
|
|
301
|
+
rankGap?: number;
|
|
302
|
+
/** Gap between siblings within a rank. */
|
|
303
|
+
nodeGap?: number;
|
|
304
|
+
maxLabelWidth?: number;
|
|
305
|
+
padding?: number;
|
|
306
|
+
};
|
|
307
|
+
//#endregion
|
|
308
|
+
//#region src/diagram/render.d.ts
|
|
309
|
+
type RenderOptions = {
|
|
310
|
+
fontSize?: number;
|
|
311
|
+
/** Suffix for the arrowhead marker ids, so two diagrams on a page cannot collide. */
|
|
312
|
+
idSuffix?: string;
|
|
313
|
+
};
|
|
314
|
+
//#endregion
|
|
315
|
+
//#region src/diagram/index.d.ts
|
|
316
|
+
type CompiledDiagram = {
|
|
317
|
+
svg: string;
|
|
318
|
+
width: number;
|
|
319
|
+
height: number;
|
|
320
|
+
/** The parsed graph, so a caller can inspect what was drawn without re-parsing. */
|
|
321
|
+
source: Diagram$1;
|
|
322
|
+
};
|
|
323
|
+
type CompileOptions = LayoutOptions & RenderOptions;
|
|
324
|
+
/** Mermaid-flavoured text in, themed SVG out. One call, no browser. */
|
|
325
|
+
declare function compileDiagram(source: string, options?: CompileOptions): CompiledDiagram;
|
|
326
|
+
//#endregion
|
|
327
|
+
export { type BlockMetrics, type CellValue, type CompileOptions, type CompiledDiagram, DEFAULT_PAGE_SIZE, type DataAlign, type DataColumn, type DataFormat, DataTable, type DataTableProps, type DelimitedTable, type DesignFonts, type DesignPalette, type DesignSystem, type DesignTypeScale, Diagram, type DiagramProps, type DiagramSource, DiagramSyntaxError, type DocEntry, type DocMeta, type DocModule, type DocPage, Figure, type FigureProps, type FlowSection, Footnote, type FootnoteProps, Footnotes, type FootnotesProps, ImagePlaceholder, type ImagePlaceholderProps, type LabelEntry, type LabelKind, type LabelVocabulary, ListOf, ListOfFigures, type ListOfProps, ListOfTables, type OpenDocBuildConfig, type OpenDocConfig, type Orientation, type OutlineEntry, PAGE_SIZES, type PageGeometry, type PageSizeName, type PaginationResult, Ref, type RefProps, TableOfContents, type TableOfContentsProps, compileDiagram, cssVarsToString, defaultDesign, designToCssVars, flow, isFlowSection, paginateBlocks, parseDelimited, resolvePageGeometry, useDocLabel, useDocLabels, useDocOutline, useDocPageCount, useDocPageNumber };
|