mosage 0.2.0 → 0.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.
- package/README.md +16 -15
- package/bin.js +2 -0
- package/dist/build-C7NW_3Pk.js +14 -0
- package/dist/check-CP4873Wx.js +41 -0
- package/dist/cli/bin.d.ts +1 -0
- package/dist/cli/bin.js +228 -0
- package/dist/config-DPm1BBAb.js +2619 -0
- package/dist/config-TlTe7Ona.d.ts +24 -0
- package/dist/context-BqsdSrAQ.js +1084 -0
- package/dist/dev-Biz42qlu.js +17 -0
- package/dist/diagram-xlVDekYk.js +763 -0
- package/dist/export-Bi6nuxjT.js +31 -0
- package/dist/import-D2jNB07F.js +25 -0
- package/dist/index.d.ts +455 -0
- package/dist/index.js +693 -0
- package/dist/{cli.js → init-Bbtj2pxF.js} +34 -68
- package/dist/preview-CLm51aRt.js +19 -0
- package/dist/sdk-DjpX6mCv.js +51 -0
- package/dist/vite/index.d.ts +25 -0
- package/dist/vite/index.js +2 -0
- package/env.d.ts +83 -0
- package/package.json +59 -12
- package/{template/.agents/skills → skills}/create-doc/SKILL.md +1 -1
- package/{template/.agents/skills → skills}/create-theme/SKILL.md +1 -1
- package/{template/.agents/skills → skills}/doc-authoring/SKILL.md +8 -9
- package/{template/.agents/skills → skills}/doc-authoring/references/assets.md +1 -1
- package/{template/.agents/skills → skills}/doc-authoring/references/design-system.md +1 -1
- package/{template/.agents/skills → skills}/doc-authoring/references/long-form.md +4 -4
- package/{template/.agents/skills → skills}/doc-authoring/references/pagination.md +1 -1
- package/src/app/app.tsx +42 -0
- package/src/app/components/data-table.tsx +196 -0
- package/src/app/components/design-panel/design-panel.tsx +318 -0
- package/src/app/components/design-panel/design-provider.tsx +121 -0
- package/src/app/components/design-panel/use-design.ts +85 -0
- package/src/app/components/diagram.tsx +76 -0
- package/src/app/components/doc-assets.tsx +129 -0
- package/src/app/components/doc-search.tsx +248 -0
- package/src/app/components/doc-sidebar.tsx +162 -0
- package/src/app/components/flow-page.tsx +93 -0
- package/src/app/components/footnote.tsx +204 -0
- package/src/app/components/image-placeholder.tsx +50 -0
- package/src/app/components/inspector/inspector.tsx +518 -0
- package/src/app/components/numbering.tsx +224 -0
- package/src/app/components/page-frame.tsx +70 -0
- package/src/app/components/sidebar/folder-item.tsx +212 -0
- package/src/app/components/sidebar/icon-picker.tsx +99 -0
- package/src/app/components/sidebar/sidebar.tsx +252 -0
- package/src/app/components/table-of-contents.tsx +93 -0
- package/src/app/components/theme-toggle.tsx +50 -0
- package/src/app/components/themes/markdown.tsx +249 -0
- package/src/app/components/themes/theme-preview.tsx +74 -0
- package/src/app/components/ui/menu.tsx +143 -0
- package/src/app/index.html +12 -0
- package/src/app/lib/agent-bridge.ts +140 -0
- package/src/app/lib/assets.ts +151 -0
- package/src/app/lib/design-presets.ts +109 -0
- package/src/app/lib/design.ts +88 -0
- package/src/app/lib/diagnostics.ts +282 -0
- package/src/app/lib/doc-preview.tsx +29 -0
- package/src/app/lib/docs.ts +26 -0
- package/src/app/lib/docx/extract.ts +1623 -0
- package/src/app/lib/docx/fonts.test.ts +136 -0
- package/src/app/lib/docx/fonts.ts +166 -0
- package/src/app/lib/docx/media.ts +102 -0
- package/src/app/lib/docx/model.ts +206 -0
- package/src/app/lib/docx/paragraph.test.ts +92 -0
- package/src/app/lib/docx/paragraph.ts +107 -0
- package/src/app/lib/docx/props.ts +187 -0
- package/src/app/lib/docx/styles.ts +306 -0
- package/src/app/lib/docx/units.ts +35 -0
- package/src/app/lib/docx/write.test.ts +507 -0
- package/src/app/lib/docx/write.ts +581 -0
- package/src/app/lib/docx/xml.ts +39 -0
- package/src/app/lib/export-docx.ts +289 -0
- package/src/app/lib/export-dom.ts +318 -0
- package/src/app/lib/export-html.ts +156 -0
- package/src/app/lib/export-image.ts +70 -0
- package/src/app/lib/export-pdf.ts +165 -0
- package/src/app/lib/flow-measure.test.ts +31 -0
- package/src/app/lib/flow-measure.ts +183 -0
- package/src/app/lib/flow.test.ts +110 -0
- package/src/app/lib/flow.ts +136 -0
- package/src/app/lib/folders.ts +192 -0
- package/src/app/lib/footnotes.test.tsx +102 -0
- package/src/app/lib/footnotes.ts +94 -0
- package/src/app/lib/inspector/fiber.ts +99 -0
- package/src/app/lib/labels.test.ts +18 -0
- package/src/app/lib/labels.ts +181 -0
- package/src/app/lib/outline.ts +118 -0
- package/src/app/lib/page-context.tsx +43 -0
- package/src/app/lib/page-range.test.ts +95 -0
- package/src/app/lib/page-range.ts +90 -0
- package/src/app/lib/print-ready.ts +69 -0
- package/src/app/lib/rasterize.ts +173 -0
- package/src/app/lib/scan.ts +26 -0
- package/src/app/lib/sdk.test.ts +32 -0
- package/src/app/lib/sdk.ts +115 -0
- package/src/app/lib/themes.ts +31 -0
- package/src/app/lib/use-doc-module.ts +53 -0
- package/src/app/lib/use-doc-pages.ts +147 -0
- package/src/app/lib/utils.ts +6 -0
- package/src/app/lib/view-mode.test.ts +91 -0
- package/src/app/lib/view-mode.ts +104 -0
- package/src/app/main.tsx +14 -0
- package/src/app/routes/assets.tsx +257 -0
- package/src/app/routes/doc.tsx +877 -0
- package/src/app/routes/home-shell.tsx +203 -0
- package/src/app/routes/home.tsx +269 -0
- package/src/app/routes/themes.tsx +121 -0
- package/src/app/styles.css +97 -0
- package/src/app/virtual.d.ts +30 -0
- package/template/AGENTS.md +1 -1
- package/template/README.md +24 -52
- package/template/docs/getting-started/index.tsx +2 -2
- package/template/mosage.config.ts +1 -1
- package/template/package.json +1 -1
- package/template/tsconfig.json +1 -1
- package/README.zh-TW.md +0 -28
- /package/{template/.agents/skills → skills}/apply-comments/SKILL.md +0 -0
- /package/{template/.agents/skills → skills}/current-doc/SKILL.md +0 -0
- /package/{template/.agents/skills → skills}/doc-authoring/references/tables-and-charts.md +0 -0
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { i as EXPORT_FORMATS } from "./cli/bin.js";
|
|
2
|
+
import { i as listDocIds } from "./config-DPm1BBAb.js";
|
|
3
|
+
import { i as exportDocument, r as closeRenderSession, t as cliContext } from "./context-BqsdSrAQ.js";
|
|
4
|
+
import chalk from "chalk";
|
|
5
|
+
//#region src/cli/export.ts
|
|
6
|
+
/**
|
|
7
|
+
* The Download menu without a browser window — the same render pipeline, driven
|
|
8
|
+
* from a script. This is what makes a document something CI can produce on a
|
|
9
|
+
* schedule rather than something a person has to click.
|
|
10
|
+
*/
|
|
11
|
+
async function exportDocs(docIds, opts = {}) {
|
|
12
|
+
const format = opts.format ?? "pdf";
|
|
13
|
+
if (!EXPORT_FORMATS.includes(format)) throw new Error(`Unknown format "${format}". Expected one of: ${EXPORT_FORMATS.join(", ")}`);
|
|
14
|
+
const ctx = await cliContext();
|
|
15
|
+
const targets = docIds.length > 0 ? docIds : opts.all ? await listDocIds(ctx) : [];
|
|
16
|
+
if (targets.length === 0) throw new Error("Nothing to export. Name a document id, or pass --all.");
|
|
17
|
+
try {
|
|
18
|
+
for (const docId of targets) {
|
|
19
|
+
const result = await exportDocument(ctx, docId, {
|
|
20
|
+
format,
|
|
21
|
+
...opts.outDir !== void 0 ? { outDir: opts.outDir } : {}
|
|
22
|
+
});
|
|
23
|
+
const files = result.files.join(", ");
|
|
24
|
+
process.stdout.write(`${chalk.green("✓")} ${chalk.bold(docId)} ${chalk.dim(`${result.pageCount}p`)} → ${files}\n`);
|
|
25
|
+
}
|
|
26
|
+
} finally {
|
|
27
|
+
await closeRenderSession();
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
//#endregion
|
|
31
|
+
export { exportDocs };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { a as importMarkdown, t as cliContext } from "./context-BqsdSrAQ.js";
|
|
2
|
+
import chalk from "chalk";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
//#region src/cli/import.ts
|
|
5
|
+
async function importDoc(file, opts = {}) {
|
|
6
|
+
const ctx = await cliContext();
|
|
7
|
+
const relative = path.relative(ctx.userCwd, path.resolve(ctx.userCwd, file));
|
|
8
|
+
const result = await importMarkdown(ctx, {
|
|
9
|
+
file: relative,
|
|
10
|
+
...opts.id !== void 0 ? { docId: opts.id } : {},
|
|
11
|
+
...opts.title !== void 0 ? { title: opts.title } : {},
|
|
12
|
+
...opts.subtitle !== void 0 ? { subtitle: opts.subtitle } : {},
|
|
13
|
+
...opts.author !== void 0 ? { author: opts.author } : {},
|
|
14
|
+
...opts.theme !== void 0 ? { theme: opts.theme } : {},
|
|
15
|
+
...opts.pageSize !== void 0 ? { pageSize: opts.pageSize } : {},
|
|
16
|
+
...opts.orientation !== void 0 ? { orientation: opts.orientation } : {},
|
|
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
ADDED
|
@@ -0,0 +1,455 @@
|
|
|
1
|
+
import { n as MoSageConfig, t as MoSageBuildConfig } from "./config-TlTe7Ona.js";
|
|
2
|
+
import { CSSProperties, ComponentType, ReactNode } from "react";
|
|
3
|
+
//#region src/app/components/data-table.d.ts
|
|
4
|
+
type DataAlign = 'left' | 'center' | 'right';
|
|
5
|
+
type DataFormat = 'text' | 'number' | 'integer' | 'percent' | ((value: unknown, row: Record<string, unknown>) => ReactNode);
|
|
6
|
+
type DataColumn = {
|
|
7
|
+
key: string;
|
|
8
|
+
label?: ReactNode;
|
|
9
|
+
align?: DataAlign;
|
|
10
|
+
format?: DataFormat;
|
|
11
|
+
/** Column width. A number is px; `tableLayout: fixed` means these are honoured. */
|
|
12
|
+
width?: number | string;
|
|
13
|
+
};
|
|
14
|
+
type DataTableProps = {
|
|
15
|
+
/** Rows as parsed from a `.csv`/`.tsv` import, or any array of objects. */
|
|
16
|
+
rows: Array<Record<string, unknown>>;
|
|
17
|
+
/** Columns to print, in order. Derived from the first row when omitted. */
|
|
18
|
+
columns?: Array<DataColumn | string>;
|
|
19
|
+
/** Numbers the table and prints the caption above it. */
|
|
20
|
+
caption?: ReactNode;
|
|
21
|
+
/** Stable id for `<Ref to>`. Only meaningful alongside `caption`. */
|
|
22
|
+
id?: string;
|
|
23
|
+
/** Print at most this many rows, with a note about what was left out. */
|
|
24
|
+
limit?: number;
|
|
25
|
+
/** Tighter rows, for a dense appendix table. */
|
|
26
|
+
compact?: boolean;
|
|
27
|
+
/** What an empty cell prints as. Defaults to an em dash. */
|
|
28
|
+
emptyValue?: ReactNode;
|
|
29
|
+
style?: CSSProperties;
|
|
30
|
+
className?: string;
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* A print-shaped table from data, so the numbers in a report come from a file
|
|
34
|
+
* instead of being retyped into JSX. Alignment and grouping follow the column's
|
|
35
|
+
* contents, which is the part people get wrong by hand.
|
|
36
|
+
*/
|
|
37
|
+
declare function DataTable({ rows, columns, caption, id, limit, compact, emptyValue, style, className }: DataTableProps): import("react").JSX.Element;
|
|
38
|
+
//#endregion
|
|
39
|
+
//#region src/app/lib/labels.d.ts
|
|
40
|
+
type LabelKind = 'figure' | 'table' | 'footnote';
|
|
41
|
+
type LabelEntry = {
|
|
42
|
+
/** Author-supplied id for `<Ref to>`, or a generated one. */
|
|
43
|
+
id: string;
|
|
44
|
+
kind: LabelKind;
|
|
45
|
+
/** 1-based, counted per kind across the whole document. */
|
|
46
|
+
number: number;
|
|
47
|
+
/** Caption text, for a list of figures. */
|
|
48
|
+
text: string;
|
|
49
|
+
/** 1-based page the item sits on. */
|
|
50
|
+
page: number;
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* The words wrapped around a number. Numbering is structural; what it is
|
|
54
|
+
* *called* is a document's own business — `圖 3` and `Figure 3` are the same
|
|
55
|
+
* entry. Set it once in `meta.labels`.
|
|
56
|
+
*/
|
|
57
|
+
type LabelVocabulary = {
|
|
58
|
+
figure: string;
|
|
59
|
+
table: string;
|
|
60
|
+
/** Heading above a page's footnotes. Empty string renders no heading. */
|
|
61
|
+
footnotes: string;
|
|
62
|
+
/** Page suffix for a cross-reference. `{page}` is replaced. */
|
|
63
|
+
onPage: string;
|
|
64
|
+
};
|
|
65
|
+
/** The document's numbered items of one kind, in order. Empty on the first render pass. */
|
|
66
|
+
declare function useDocLabels(kind: LabelKind): LabelEntry[];
|
|
67
|
+
/** One numbered item by id, once the scan has run. */
|
|
68
|
+
declare function useDocLabel(id: string): LabelEntry | null;
|
|
69
|
+
//#endregion
|
|
70
|
+
//#region src/app/components/diagram.d.ts
|
|
71
|
+
type DiagramSource = {
|
|
72
|
+
svg: string;
|
|
73
|
+
width: number;
|
|
74
|
+
height: number;
|
|
75
|
+
};
|
|
76
|
+
type DiagramProps = {
|
|
77
|
+
/** The compiled module from `import chart from './architecture.mmd'`. */
|
|
78
|
+
chart: DiagramSource;
|
|
79
|
+
/** Caption text. Given one, the drawing is numbered like any other figure. */
|
|
80
|
+
caption?: ReactNode;
|
|
81
|
+
captionText?: string;
|
|
82
|
+
kind?: LabelKind;
|
|
83
|
+
id?: string;
|
|
84
|
+
/**
|
|
85
|
+
* Drawn width in CSS px. Defaults to the diagram's natural size, capped to
|
|
86
|
+
* the column — a diagram wider than the text block is a layout fault, and
|
|
87
|
+
* `mosage check` would report it as one.
|
|
88
|
+
*/
|
|
89
|
+
width?: number;
|
|
90
|
+
align?: 'left' | 'center';
|
|
91
|
+
style?: CSSProperties;
|
|
92
|
+
className?: string;
|
|
93
|
+
};
|
|
94
|
+
/**
|
|
95
|
+
* A diagram compiled from Mermaid-flavoured text at build time. The SVG is
|
|
96
|
+
* inlined rather than referenced through `<img>` so it inherits the document's
|
|
97
|
+
* theme variables — an `<img src="data:…">` would be painted in a document of
|
|
98
|
+
* its own, with none of this one's colours or faces.
|
|
99
|
+
*/
|
|
100
|
+
declare function Diagram({ chart, caption, captionText, kind, id, width, align, style, className }: DiagramProps): import("react").JSX.Element;
|
|
101
|
+
//#endregion
|
|
102
|
+
//#region src/app/components/footnote.d.ts
|
|
103
|
+
type CollectedNote = {
|
|
104
|
+
id: string;
|
|
105
|
+
content: ReactNode;
|
|
106
|
+
};
|
|
107
|
+
type FootnoteProps = {
|
|
108
|
+
/** Stable id, so `<Ref to>` can point at the note. Generated when omitted. */
|
|
109
|
+
id?: string;
|
|
110
|
+
children?: ReactNode;
|
|
111
|
+
};
|
|
112
|
+
/**
|
|
113
|
+
* A note anchored to this point in the text. Inside a `flow()` section the
|
|
114
|
+
* framework lifts it to the foot of whatever page the marker lands on; on a
|
|
115
|
+
* fixed page, put a `<Footnotes />` where you want them printed.
|
|
116
|
+
*/
|
|
117
|
+
declare function Footnote({ id, children }: FootnoteProps): import("react").JSX.Element;
|
|
118
|
+
type FootnotesProps = {
|
|
119
|
+
/** Notes to print. Omitted on a fixed page, where they are collected from it. */
|
|
120
|
+
notes?: CollectedNote[];
|
|
121
|
+
style?: CSSProperties;
|
|
122
|
+
className?: string;
|
|
123
|
+
};
|
|
124
|
+
declare function Footnotes({ notes, style, className }: FootnotesProps): import("react").JSX.Element | null;
|
|
125
|
+
//#endregion
|
|
126
|
+
//#region src/app/components/image-placeholder.d.ts
|
|
127
|
+
type ImagePlaceholderProps = {
|
|
128
|
+
/** What the final image should show — the user reads this when replacing it. */
|
|
129
|
+
hint: string;
|
|
130
|
+
width?: number | string;
|
|
131
|
+
height?: number | string;
|
|
132
|
+
style?: CSSProperties;
|
|
133
|
+
className?: string;
|
|
134
|
+
};
|
|
135
|
+
/**
|
|
136
|
+
* Stands in for an image the user has to supply (a chart from their data, a
|
|
137
|
+
* product screenshot). Use it instead of inventing filler — never for
|
|
138
|
+
* decoration.
|
|
139
|
+
*/
|
|
140
|
+
declare function ImagePlaceholder({ hint, width, height, style, className }: ImagePlaceholderProps): import("react").JSX.Element;
|
|
141
|
+
//#endregion
|
|
142
|
+
//#region src/app/components/numbering.d.ts
|
|
143
|
+
type FigureProps = {
|
|
144
|
+
/** Stable id, so `<Ref to>` can point at it. Generated when omitted. */
|
|
145
|
+
id?: string;
|
|
146
|
+
/** What the caption says after the number. */
|
|
147
|
+
caption?: ReactNode;
|
|
148
|
+
/** `figure` numbers with figures, `table` with tables. Defaults to `figure`. */
|
|
149
|
+
kind?: LabelKind;
|
|
150
|
+
/** Tables conventionally caption above, figures below. */
|
|
151
|
+
captionPosition?: 'above' | 'below';
|
|
152
|
+
/** Plain-text caption for the list of figures, when `caption` carries markup. */
|
|
153
|
+
captionText?: string;
|
|
154
|
+
style?: CSSProperties;
|
|
155
|
+
captionStyle?: CSSProperties;
|
|
156
|
+
className?: string;
|
|
157
|
+
children?: ReactNode;
|
|
158
|
+
};
|
|
159
|
+
/**
|
|
160
|
+
* A numbered figure or table. The number comes from a scan of the rendered
|
|
161
|
+
* pages, not from a counter in the source, so inserting a figure halfway
|
|
162
|
+
* through a document renumbers everything after it — including the references
|
|
163
|
+
* to it — without anyone editing a number.
|
|
164
|
+
*
|
|
165
|
+
* Caption and content are one block, so a `flow()` section never separates them.
|
|
166
|
+
*/
|
|
167
|
+
declare function Figure({ id, caption, kind, captionPosition, captionText, style, captionStyle, className, children }: FigureProps): import("react").JSX.Element;
|
|
168
|
+
type RefProps = {
|
|
169
|
+
/** The `id` of a `<Figure>` or `<Footnote>`. */
|
|
170
|
+
to: string;
|
|
171
|
+
/**
|
|
172
|
+
* Append the page. `auto` (the default) adds it only when the target sits on
|
|
173
|
+
* another sheet, which is the only time a reader needs it.
|
|
174
|
+
*/
|
|
175
|
+
showPage?: boolean | 'auto';
|
|
176
|
+
style?: CSSProperties;
|
|
177
|
+
className?: string;
|
|
178
|
+
};
|
|
179
|
+
/**
|
|
180
|
+
* A cross-reference that resolves after layout: "Figure 3", plus the page when
|
|
181
|
+
* the target is elsewhere. Never write "see Figure 3 on page 12" by hand — both
|
|
182
|
+
* numbers move.
|
|
183
|
+
*/
|
|
184
|
+
declare function Ref({ to, showPage, style, className }: RefProps): import("react").JSX.Element;
|
|
185
|
+
type ListOfProps = {
|
|
186
|
+
kind?: LabelKind;
|
|
187
|
+
/** Show the page number column with dot leaders. Defaults to true. */
|
|
188
|
+
showPageNumbers?: boolean;
|
|
189
|
+
style?: CSSProperties;
|
|
190
|
+
className?: string;
|
|
191
|
+
};
|
|
192
|
+
/**
|
|
193
|
+
* The document's figures or tables as a contents list. Same lifecycle as
|
|
194
|
+
* `<TableOfContents>`: empty on the first render pass, filled once the scan has
|
|
195
|
+
* run — including before an export serializes.
|
|
196
|
+
*/
|
|
197
|
+
declare function ListOf({ kind, showPageNumbers, style, className }: ListOfProps): import("react").JSX.Element;
|
|
198
|
+
declare function ListOfFigures(props: Omit<ListOfProps, 'kind'>): import("react").JSX.Element;
|
|
199
|
+
declare function ListOfTables(props: Omit<ListOfProps, 'kind'>): import("react").JSX.Element;
|
|
200
|
+
//#endregion
|
|
201
|
+
//#region src/app/components/table-of-contents.d.ts
|
|
202
|
+
type TableOfContentsProps = {
|
|
203
|
+
/** Deepest heading level to list. Defaults to 2 (h1 + h2). */
|
|
204
|
+
maxLevel?: number;
|
|
205
|
+
/** Show the page number column with dot leaders. Defaults to true. */
|
|
206
|
+
showPageNumbers?: boolean;
|
|
207
|
+
/** List headings that sit on the same page as the TOC itself. Defaults to false. */
|
|
208
|
+
includeOwnPage?: boolean;
|
|
209
|
+
/** Indent per heading level, in px. Defaults to 20. */
|
|
210
|
+
indent?: number;
|
|
211
|
+
style?: CSSProperties;
|
|
212
|
+
className?: string;
|
|
213
|
+
};
|
|
214
|
+
/**
|
|
215
|
+
* Renders the document's headings as a contents list. The outline is filled in
|
|
216
|
+
* by a DOM scan after the pages render, so this component is empty on the very
|
|
217
|
+
* first pass and populated on the next — including during PDF/HTML export,
|
|
218
|
+
* which scans before serializing.
|
|
219
|
+
*/
|
|
220
|
+
declare function TableOfContents({ maxLevel, showPageNumbers, includeOwnPage, indent, style, className }: TableOfContentsProps): import("react").JSX.Element;
|
|
221
|
+
//#endregion
|
|
222
|
+
//#region src/app/lib/design.d.ts
|
|
223
|
+
type DesignPalette = {
|
|
224
|
+
bg: string;
|
|
225
|
+
text: string;
|
|
226
|
+
muted: string;
|
|
227
|
+
accent: string;
|
|
228
|
+
rule: string;
|
|
229
|
+
};
|
|
230
|
+
type DesignFonts = {
|
|
231
|
+
heading: string;
|
|
232
|
+
body: string;
|
|
233
|
+
mono: string;
|
|
234
|
+
};
|
|
235
|
+
type DesignTypeScale = {
|
|
236
|
+
title: number;
|
|
237
|
+
h1: number;
|
|
238
|
+
h2: number;
|
|
239
|
+
h3: number;
|
|
240
|
+
body: number;
|
|
241
|
+
caption: number;
|
|
242
|
+
};
|
|
243
|
+
type DesignSystem = {
|
|
244
|
+
palette: DesignPalette;
|
|
245
|
+
fonts: DesignFonts;
|
|
246
|
+
typeScale: DesignTypeScale;
|
|
247
|
+
/** Page margin in CSS px — the printable text block's inset from the sheet edge. */
|
|
248
|
+
margin: number;
|
|
249
|
+
/** Body line-height multiplier. Headings tighten this themselves. */
|
|
250
|
+
leading: number;
|
|
251
|
+
radius: number;
|
|
252
|
+
};
|
|
253
|
+
declare function designToCssVars(d: DesignSystem): Record<string, string>;
|
|
254
|
+
declare function cssVarsToString(vars: Record<string, string>): string;
|
|
255
|
+
declare const defaultDesign: DesignSystem;
|
|
256
|
+
//#endregion
|
|
257
|
+
//#region src/app/lib/sdk.d.ts
|
|
258
|
+
/** The only sheets a document may be laid out on. */
|
|
259
|
+
declare const PAGE_SIZE_NAMES: readonly ["A4", "B4", "A3"];
|
|
260
|
+
type PageSizeName = (typeof PAGE_SIZE_NAMES)[number];
|
|
261
|
+
declare const ORIENTATIONS: readonly ["portrait", "landscape"];
|
|
262
|
+
type Orientation = (typeof ORIENTATIONS)[number];
|
|
263
|
+
/**
|
|
264
|
+
* Portrait dimensions in CSS pixels at 96dpi — the unit authors write in —
|
|
265
|
+
* paired with the physical millimetres used when printing. Keeping both means a
|
|
266
|
+
* page laid out at 794×1123 on screen maps to a real A4 sheet with no rescaling.
|
|
267
|
+
*/
|
|
268
|
+
declare const PAGE_SIZES: Record<PageSizeName, {
|
|
269
|
+
width: number;
|
|
270
|
+
height: number;
|
|
271
|
+
mm: readonly [number, number];
|
|
272
|
+
}>;
|
|
273
|
+
declare const DEFAULT_PAGE_SIZE: PageSizeName;
|
|
274
|
+
declare const DEFAULT_ORIENTATION: Orientation;
|
|
275
|
+
declare function isPageSizeName(value: unknown): value is PageSizeName;
|
|
276
|
+
declare function isOrientation(value: unknown): value is Orientation;
|
|
277
|
+
type PageGeometry = {
|
|
278
|
+
width: number;
|
|
279
|
+
height: number;
|
|
280
|
+
/** The printed sheet in millimetres, across then down — what a Word section is sized in. */
|
|
281
|
+
mm: readonly [number, number];
|
|
282
|
+
/** Value for the `@page { size: … }` descriptor, orientation included. */
|
|
283
|
+
css: string;
|
|
284
|
+
};
|
|
285
|
+
type DocPage = ComponentType;
|
|
286
|
+
/**
|
|
287
|
+
* A run of continuous content the framework paginates itself. Build one with
|
|
288
|
+
* `flow(...)` and put it in the page array alongside fixed pages.
|
|
289
|
+
*/
|
|
290
|
+
type FlowSection = {
|
|
291
|
+
readonly __odFlow: true;
|
|
292
|
+
blocks: ReactNode[];
|
|
293
|
+
/** Rendered on every page the section expands into. */
|
|
294
|
+
footer?: ComponentType;
|
|
295
|
+
/** Page padding override in px; defaults to the design's `margin`. */
|
|
296
|
+
padding?: number;
|
|
297
|
+
};
|
|
298
|
+
/** What a document's default export may contain: fixed pages, flow sections, or both. */
|
|
299
|
+
type DocEntry = DocPage | FlowSection;
|
|
300
|
+
type DocMeta = {
|
|
301
|
+
title?: string;
|
|
302
|
+
subtitle?: string;
|
|
303
|
+
author?: string;
|
|
304
|
+
pageSize?: PageSizeName;
|
|
305
|
+
orientation?: Orientation;
|
|
306
|
+
/** Id of a theme under `themes/` this document was built from. Adds a back-link. */
|
|
307
|
+
theme?: string;
|
|
308
|
+
/** ISO 8601 timestamp. Set once at scaffold time; used to sort the doc list. */
|
|
309
|
+
createdAt?: string;
|
|
310
|
+
/** What numbered items are called — `圖`/`表` instead of `Figure`/`Table`. */
|
|
311
|
+
labels?: Partial<LabelVocabulary>;
|
|
312
|
+
};
|
|
313
|
+
type DocModule = {
|
|
314
|
+
default: DocEntry[];
|
|
315
|
+
meta?: DocMeta;
|
|
316
|
+
design?: DesignSystem;
|
|
317
|
+
};
|
|
318
|
+
declare function resolvePageGeometry(meta?: DocMeta): PageGeometry;
|
|
319
|
+
//#endregion
|
|
320
|
+
//#region src/app/lib/flow.d.ts
|
|
321
|
+
/**
|
|
322
|
+
* Wraps continuous content so the framework paginates it, instead of the author
|
|
323
|
+
* hand-splitting sections into fixed pages. Each direct child is one atomic
|
|
324
|
+
* block — a heading, a paragraph, a table — that never straddles a page break.
|
|
325
|
+
*/
|
|
326
|
+
declare function flow(children: ReactNode, opts?: {
|
|
327
|
+
footer?: ComponentType;
|
|
328
|
+
padding?: number;
|
|
329
|
+
}): FlowSection;
|
|
330
|
+
declare function isFlowSection(entry: DocEntry): entry is FlowSection;
|
|
331
|
+
type BlockMetrics = {
|
|
332
|
+
height: number;
|
|
333
|
+
/** Height this block's footnotes add to the foot of whatever page it lands on. */
|
|
334
|
+
footnoteHeight?: number;
|
|
335
|
+
/** A heading must not be the last block on a page. */
|
|
336
|
+
keepWithNext?: boolean;
|
|
337
|
+
/** A caption must not open a page without the figure it belongs to. */
|
|
338
|
+
keepWithPrevious?: boolean;
|
|
339
|
+
/** Always start a new page before this block. */
|
|
340
|
+
breakBefore?: boolean;
|
|
341
|
+
};
|
|
342
|
+
type PaginationResult = {
|
|
343
|
+
/** Block indices per page, in order. */
|
|
344
|
+
pages: number[][];
|
|
345
|
+
/** Blocks taller than one page — they stay whole and overflow. */
|
|
346
|
+
overflowing: number[];
|
|
347
|
+
};
|
|
348
|
+
type PaginateOptions = {
|
|
349
|
+
/** Rule and padding a page's footnote area costs before its first note. */
|
|
350
|
+
footnoteOverhead?: number;
|
|
351
|
+
};
|
|
352
|
+
/**
|
|
353
|
+
* Greedy top-to-bottom packing: fill a page until the next block would cross
|
|
354
|
+
* the bottom edge, then push that block — plus anything glued to it — onto the
|
|
355
|
+
* next page. Blocks are atomic; nothing is split mid-block.
|
|
356
|
+
*
|
|
357
|
+
* Footnotes are packed from the same budget: a block that carries notes brings
|
|
358
|
+
* their height with it, because those notes print at the foot of whichever page
|
|
359
|
+
* the block lands on.
|
|
360
|
+
*/
|
|
361
|
+
declare function paginateBlocks(blocks: BlockMetrics[], available: number, opts?: PaginateOptions): PaginationResult;
|
|
362
|
+
//#endregion
|
|
363
|
+
//#region src/app/lib/outline.d.ts
|
|
364
|
+
type OutlineEntry = {
|
|
365
|
+
id: string;
|
|
366
|
+
text: string;
|
|
367
|
+
level: number;
|
|
368
|
+
/** 1-based page the heading sits on. */
|
|
369
|
+
page: number;
|
|
370
|
+
};
|
|
371
|
+
/**
|
|
372
|
+
* The document's headings, filled in after the pages render. Empty on the first
|
|
373
|
+
* pass — a `<TableOfContents>` renders its rows on the second, once the scan
|
|
374
|
+
* has run.
|
|
375
|
+
*/
|
|
376
|
+
declare function useDocOutline(): OutlineEntry[];
|
|
377
|
+
//#endregion
|
|
378
|
+
//#region src/app/lib/page-context.d.ts
|
|
379
|
+
/** 1-based page number of the page currently rendering. `0` outside a page. */
|
|
380
|
+
declare function useDocPageNumber(): number;
|
|
381
|
+
/** Total page count of the document being rendered. `0` outside a page. */
|
|
382
|
+
declare function useDocPageCount(): number;
|
|
383
|
+
//#endregion
|
|
384
|
+
//#region src/data/delimited.d.ts
|
|
385
|
+
type CellValue = string | number | null;
|
|
386
|
+
type DelimitedTable = {
|
|
387
|
+
columns: string[];
|
|
388
|
+
rows: Array<Record<string, CellValue>>;
|
|
389
|
+
};
|
|
390
|
+
type ParseOptions = {
|
|
391
|
+
/** Defaults to `,`. Tabs for `.tsv`. */
|
|
392
|
+
delimiter?: string;
|
|
393
|
+
/** Treat the first row as data and name columns `column1`, `column2`, … */
|
|
394
|
+
noHeader?: boolean;
|
|
395
|
+
};
|
|
396
|
+
declare function parseDelimited(text: string, opts?: ParseOptions): DelimitedTable;
|
|
397
|
+
//#endregion
|
|
398
|
+
//#region src/diagram/parse.d.ts
|
|
399
|
+
type Direction = 'TD' | 'LR';
|
|
400
|
+
type NodeShape = 'rect' | 'round' | 'stadium' | 'diamond' | 'circle';
|
|
401
|
+
type DiagramNode = {
|
|
402
|
+
id: string;
|
|
403
|
+
label: string;
|
|
404
|
+
shape: NodeShape;
|
|
405
|
+
};
|
|
406
|
+
type EdgeStyle = 'solid' | 'dashed' | 'thick';
|
|
407
|
+
type DiagramEdge = {
|
|
408
|
+
from: string;
|
|
409
|
+
to: string;
|
|
410
|
+
label: string | null;
|
|
411
|
+
style: EdgeStyle;
|
|
412
|
+
/** A `---` link draws no arrowhead. */
|
|
413
|
+
arrow: boolean;
|
|
414
|
+
};
|
|
415
|
+
type Diagram$1 = {
|
|
416
|
+
direction: Direction;
|
|
417
|
+
nodes: DiagramNode[];
|
|
418
|
+
edges: DiagramEdge[];
|
|
419
|
+
};
|
|
420
|
+
declare class DiagramSyntaxError extends Error {
|
|
421
|
+
readonly line: number;
|
|
422
|
+
constructor(message: string, line: number);
|
|
423
|
+
}
|
|
424
|
+
//#endregion
|
|
425
|
+
//#region src/diagram/layout.d.ts
|
|
426
|
+
type LayoutOptions = {
|
|
427
|
+
fontSize?: number;
|
|
428
|
+
/** Gap between consecutive ranks, along the flow direction. */
|
|
429
|
+
rankGap?: number;
|
|
430
|
+
/** Gap between siblings within a rank. */
|
|
431
|
+
nodeGap?: number;
|
|
432
|
+
maxLabelWidth?: number;
|
|
433
|
+
padding?: number;
|
|
434
|
+
};
|
|
435
|
+
//#endregion
|
|
436
|
+
//#region src/diagram/render.d.ts
|
|
437
|
+
type RenderOptions = {
|
|
438
|
+
fontSize?: number;
|
|
439
|
+
/** Suffix for the arrowhead marker ids, so two diagrams on a page cannot collide. */
|
|
440
|
+
idSuffix?: string;
|
|
441
|
+
};
|
|
442
|
+
//#endregion
|
|
443
|
+
//#region src/diagram/index.d.ts
|
|
444
|
+
type CompiledDiagram = {
|
|
445
|
+
svg: string;
|
|
446
|
+
width: number;
|
|
447
|
+
height: number;
|
|
448
|
+
/** The parsed graph, so a caller can inspect what was drawn without re-parsing. */
|
|
449
|
+
source: Diagram$1;
|
|
450
|
+
};
|
|
451
|
+
type CompileOptions = LayoutOptions & RenderOptions;
|
|
452
|
+
/** Mermaid-flavoured text in, themed SVG out. One call, no browser. */
|
|
453
|
+
declare function compileDiagram(source: string, options?: CompileOptions): CompiledDiagram;
|
|
454
|
+
//#endregion
|
|
455
|
+
export { type BlockMetrics, type CellValue, type CompileOptions, type CompiledDiagram, DEFAULT_ORIENTATION, 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 MoSageBuildConfig, type MoSageConfig, ORIENTATIONS, type Orientation, type OutlineEntry, PAGE_SIZES, PAGE_SIZE_NAMES, type PageGeometry, type PageSizeName, type PaginationResult, Ref, type RefProps, TableOfContents, type TableOfContentsProps, compileDiagram, cssVarsToString, defaultDesign, designToCssVars, flow, isFlowSection, isOrientation, isPageSizeName, paginateBlocks, parseDelimited, resolvePageGeometry, useDocLabel, useDocLabels, useDocOutline, useDocPageCount, useDocPageNumber };
|