@open-document/core 0.12.0 → 0.13.1

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 (48) hide show
  1. package/dist/{build-DfUfpeTR.js → build-CvsOak5B.js} +1 -1
  2. package/dist/{check-CHxiOkQG.js → check-CbUBwYmf.js} +3 -3
  3. package/dist/cli/bin.js +47 -10
  4. package/dist/config-BWtOZ1jc.d.ts +45 -0
  5. package/dist/{config-9IdbhVuT.js → config-CltJJVsw.js} +398 -493
  6. package/dist/{context-BLI1-64_.js → context-CWgfsHoE.js} +2 -1
  7. package/dist/deploy-gcp-BUiSuqz7.js +758 -0
  8. package/dist/{dev-yNYKv5mm.js → dev-B8H2qT6G.js} +1 -1
  9. package/dist/{diagram-BK4jTZr4.js → diagram-CKf3ptOE.js} +293 -13
  10. package/dist/{diff-Bs205mOx.js → diff-BvIjjgnc.js} +2 -2
  11. package/dist/{export-tkquS5O5.js → export-DX30_s2q.js} +3 -3
  12. package/dist/{sdk-CHEGeINh.d.ts → flow-CS5apebG.d.ts} +72 -3
  13. package/dist/{import-D1hIKIr3.js → import-DgsdJT5e.js} +2 -2
  14. package/dist/index.d.ts +155 -59
  15. package/dist/index.js +896 -90
  16. package/dist/open-doc-plugin-DnX5usgI.js +320 -0
  17. package/dist/ops/index.d.ts +98 -13
  18. package/dist/ops/index.js +3 -3
  19. package/dist/{ops-Dgqujq5a.js → ops-CSR5RlrE.js} +2 -1
  20. package/dist/{preview-BImdTH6K.js → preview-DYMUNjXL.js} +1 -1
  21. package/dist/{templates-DT5zzqHq.js → templates-B5Tz0AKb.js} +3 -3
  22. package/dist/vite/index.d.ts +1 -1
  23. package/dist/vite/index.js +2 -1
  24. package/package.json +1 -1
  25. package/skills/doc-authoring/SKILL.md +15 -16
  26. package/skills/doc-authoring/references/long-form.md +43 -2
  27. package/skills/doc-authoring/references/pagination.md +14 -2
  28. package/skills/doc-authoring/references/tables-and-charts.md +21 -17
  29. package/src/app/components/callout.tsx +101 -0
  30. package/src/app/components/chart.tsx +191 -33
  31. package/src/app/components/code-block.tsx +249 -0
  32. package/src/app/components/data-table.tsx +146 -18
  33. package/src/app/components/flow-page.tsx +57 -8
  34. package/src/app/components/numbering.tsx +226 -12
  35. package/src/app/components/page-frame.tsx +42 -0
  36. package/src/app/lib/chart.test.ts +15 -0
  37. package/src/app/lib/chart.ts +134 -9
  38. package/src/app/lib/diagnostics.ts +45 -1
  39. package/src/app/lib/export-dom.ts +15 -2
  40. package/src/app/lib/export-pdf.ts +9 -1
  41. package/src/app/lib/flow-measure.ts +33 -4
  42. package/src/app/lib/flow.test.ts +20 -1
  43. package/src/app/lib/flow.ts +120 -20
  44. package/src/app/lib/labels.ts +29 -10
  45. package/src/app/lib/sdk.ts +6 -0
  46. package/src/app/lib/use-doc-pages.ts +23 -8
  47. package/src/app/routes/doc.tsx +1 -0
  48. package/dist/config-P61niZMf.d.ts +0 -24
package/dist/index.d.ts CHANGED
@@ -1,6 +1,33 @@
1
- import { A as LabelEntry, C as DesignFonts, D as cssVarsToString, E as DesignTypeScale, M as LabelVocabulary, N as useDocLabel, O as defaultDesign, P as useDocLabels, S as useRecord, T as DesignSystem, _ as isPageSizeName, a as DocModule, b as Field, d as Orientation, f as PAGE_SIZES, g as isOrientation, h as PageSizeName, i as DocMeta, j as LabelKind, k as designToCssVars, l as FlowSection, m as PageGeometry, n as DEFAULT_PAGE_SIZE, o as DocPage, p as PAGE_SIZE_NAMES, r as DocEntry, t as DEFAULT_ORIENTATION, u as ORIENTATIONS, v as resolvePageGeometry, w as DesignPalette, x as FieldProps, y as DataRecord } from "./sdk-CHEGeINh.js";
2
- import { n as OpenDocConfig, t as OpenDocBuildConfig } from "./config-P61niZMf.js";
3
- import { CSSProperties, ComponentType, ReactNode } from "react";
1
+ import { A as DesignPalette, B as useDocLabels, C as isPageSizeName, D as FieldProps, E as Field, F as designToCssVars, I as LabelEntry, L as LabelKind, M as DesignTypeScale, N as cssVarsToString, O as useRecord, P as defaultDesign, R as LabelVocabulary, S as isOrientation, T as DataRecord, _ as Orientation, a as isFlowSection, b as PageGeometry, c as DEFAULT_PAGE_SIZE, d as DocModule, f as DocPage, g as ORIENTATIONS, h as FlowSection, i as flow, j as DesignSystem, k as DesignFonts, l as DocEntry, n as BlockSlice, o as paginateBlocks, r as PaginationResult, s as DEFAULT_ORIENTATION, t as BlockMetrics, u as DocMeta, v as PAGE_SIZES, w as resolvePageGeometry, x as PageSizeName, y as PAGE_SIZE_NAMES, z as useDocLabel } from "./flow-CS5apebG.js";
2
+ import { i as OpenDocGcpDeployConfig, n as OpenDocConfig, r as OpenDocDeployConfig, t as OpenDocBuildConfig } from "./config-BWtOZ1jc.js";
3
+ import { CSSProperties, ReactNode } from "react";
4
+ //#region src/app/lib/source-loc.d.ts
5
+ /**
6
+ * In dev, `loc-tags-plugin` stamps `data-od-loc` onto the call site of a
7
+ * framework component that forwards it. The component puts it back on the
8
+ * host that prints the call site's words, so the inspector can select what it
9
+ * rendered — a table, a caption, a footnote — and find the source behind it.
10
+ * `data-od-prop` says which attribute of the call site those words come from.
11
+ */
12
+ declare const LOC_PROP = "data-od-loc";
13
+ //#endregion
14
+ //#region src/app/components/callout.d.ts
15
+ type CalloutVariant = 'info' | 'tip' | 'warning' | 'danger' | 'neutral';
16
+ type CalloutProps = {
17
+ variant?: CalloutVariant;
18
+ title?: ReactNode;
19
+ children?: ReactNode;
20
+ style?: CSSProperties;
21
+ className?: string;
22
+ [LOC_PROP]?: string;
23
+ };
24
+ /**
25
+ * A structured admonition box (`info`, `tip`, `warning`, `danger`, `neutral`)
26
+ * rendered as a `<blockquote data-od-callout>` so Word and PDF exporters keep
27
+ * its panel border and shading intact.
28
+ */
29
+ declare function Callout({ variant, title, children, style, className, [LOC_PROP]: loc }: CalloutProps): import("react").JSX.Element;
30
+ //#endregion
4
31
  //#region src/app/lib/chart.d.ts
5
32
  /**
6
33
  * Chart geometry, kept pure so it can be tested without a DOM.
@@ -11,7 +38,7 @@ import { CSSProperties, ComponentType, ReactNode } from "react";
11
38
  * after the page break was decided. Text widths come from the same estimate
12
39
  * the diagram compiler uses, for the same reason.
13
40
  */
14
- type ChartType = 'bar' | 'line' | 'pie';
41
+ type ChartType = 'bar' | 'line' | 'pie' | 'area' | 'horizontal-bar';
15
42
  type ChartFormat = 'number' | 'integer' | 'percent' | ((value: number) => string);
16
43
  //#endregion
17
44
  //#region src/app/components/chart.d.ts
@@ -50,20 +77,48 @@ type ChartProps = {
50
77
  * it prints; the Word export places it as a picture.
51
78
  */
52
79
  declare function Chart({ type, data, x, y, labels, stacked, format, values, colors, width, height, caption, captionText, kind, id, style, className }: ChartProps): import("react").JSX.Element;
80
+ type SparklineProps = {
81
+ /** Numeric values to plot in order. */
82
+ data: number[];
83
+ /** Line with subtle fill, or compact inline bars. Defaults to 'line'. */
84
+ type?: 'line' | 'bar';
85
+ width?: number;
86
+ height?: number;
87
+ color?: string;
88
+ /** Highlight the final data point with a dot on line sparklines. Defaults to true. */
89
+ showEndDot?: boolean;
90
+ style?: CSSProperties;
91
+ className?: string;
92
+ };
93
+ /**
94
+ * A compact word-sized chart that sits inline inside a paragraph or table cell.
95
+ */
96
+ declare function Sparkline({ data, type, width, height, color, showEndDot, style, className }: SparklineProps): import("react").JSX.Element | null;
53
97
  //#endregion
54
- //#region src/app/lib/source-loc.d.ts
98
+ //#region src/app/components/code-block.d.ts
99
+ type CodeBlockProps = {
100
+ code?: string;
101
+ children?: string;
102
+ lang?: string;
103
+ title?: ReactNode;
104
+ lineNumbers?: boolean;
105
+ /** 1-based line numbers to highlight. */
106
+ highlightLines?: number[];
107
+ style?: CSSProperties;
108
+ className?: string;
109
+ [LOC_PROP]?: string;
110
+ };
55
111
  /**
56
- * In dev, `loc-tags-plugin` stamps `data-od-loc` onto the call site of a
57
- * framework component that forwards it. The component puts it back on the
58
- * host that prints the call site's words, so the inspector can select what it
59
- * rendered — a table, a caption, a footnote — and find the source behind it.
60
- * `data-od-prop` says which attribute of the call site those words come from.
112
+ * Print-ready syntax-highlighted code block with optional header bar, line
113
+ * numbers, and highlighted lines. Uses `--od-*` variables so it harmonizes with
114
+ * the document's design system and exports cleanly to PDF, HTML, and Word.
61
115
  */
62
- declare const LOC_PROP = "data-od-loc";
116
+ declare function CodeBlock({ code, children, lang, title, lineNumbers, highlightLines, style, className, [LOC_PROP]: loc }: CodeBlockProps): import("react").JSX.Element;
63
117
  //#endregion
64
118
  //#region src/app/components/data-table.d.ts
65
119
  type DataAlign = 'left' | 'center' | 'right';
66
- type DataFormat = 'text' | 'number' | 'integer' | 'percent' | ((value: unknown, row: Record<string, unknown>) => ReactNode);
120
+ type DataFormat = 'text' | 'number' | 'integer' | 'percent' | 'currency' | 'delta' | ((value: unknown, row: Record<string, unknown>) => ReactNode);
121
+ type DataSummaryOp = 'sum' | 'avg' | 'min' | 'max' | 'count' | ((values: number[]) => ReactNode);
67
122
  type DataColumn = {
68
123
  key: string;
69
124
  label?: ReactNode;
@@ -71,6 +126,10 @@ type DataColumn = {
71
126
  format?: DataFormat;
72
127
  /** Column width. A number is px; `tableLayout: fixed` means these are honoured. */
73
128
  width?: number | string;
129
+ /** Draws a proportional horizontal bar behind numeric cells in this column. */
130
+ dataBar?: boolean;
131
+ /** Aggregation for this column when `summaryRow` is enabled on the table. */
132
+ summary?: DataSummaryOp | ReactNode;
74
133
  };
75
134
  type DataTableProps = {
76
135
  /** Rows as parsed from a `.csv`/`.tsv` import, or any array of objects. */
@@ -85,6 +144,12 @@ type DataTableProps = {
85
144
  limit?: number;
86
145
  /** Tighter rows, for a dense appendix table. */
87
146
  compact?: boolean;
147
+ /** Allows `flow()` to split this table across pages and repeat the `<thead>` on each sheet. */
148
+ splittable?: boolean;
149
+ /** Appends a summary footer row. Pass `true` to use column `summary` ops, or a record of values/ops. */
150
+ summaryRow?: boolean | Record<string, DataSummaryOp | ReactNode>;
151
+ /** Label printed in the first column of the summary row when not overridden. Defaults to 'Total'. */
152
+ summaryLabel?: ReactNode;
88
153
  /** What an empty cell prints as. Defaults to an em dash. */
89
154
  emptyValue?: ReactNode;
90
155
  style?: CSSProperties;
@@ -97,7 +162,7 @@ type DataTableProps = {
97
162
  * instead of being retyped into JSX. Alignment and grouping follow the column's
98
163
  * contents, which is the part people get wrong by hand.
99
164
  */
100
- declare function DataTable({ rows, columns, caption, id, limit, compact, emptyValue, style, className, [LOC_PROP]: loc }: DataTableProps): import("react").JSX.Element;
165
+ declare function DataTable({ rows, columns, caption, id, limit, compact, splittable, summaryRow, summaryLabel, emptyValue, style, className, [LOC_PROP]: loc }: DataTableProps): import("react").JSX.Element;
101
166
  //#endregion
102
167
  //#region src/app/components/diagram.d.ts
103
168
  type DiagramSource = {
@@ -187,6 +252,8 @@ type FigureProps = {
187
252
  captionPosition?: 'above' | 'below';
188
253
  /** Plain-text caption for the list of figures, when `caption` carries markup. */
189
254
  captionText?: string;
255
+ /** When false, prints the caption without registering a new label number (e.g. continued table slices). */
256
+ numbered?: boolean;
190
257
  style?: CSSProperties;
191
258
  captionStyle?: CSSProperties;
192
259
  className?: string;
@@ -202,7 +269,7 @@ type FigureProps = {
202
269
  *
203
270
  * Caption and content are one block, so a `flow()` section never separates them.
204
271
  */
205
- declare function Figure({ id, caption, kind, captionPosition, captionText, style, captionStyle, className, children, [LOC_PROP]: loc }: FigureProps): import("react").JSX.Element;
272
+ declare function Figure({ id, caption, kind, captionPosition, captionText, numbered, style, captionStyle, className, children, [LOC_PROP]: loc }: FigureProps): import("react").JSX.Element;
206
273
  type RefProps = {
207
274
  /** The `id` of a `<Figure>` or `<Footnote>`. */
208
275
  to: string;
@@ -235,6 +302,44 @@ type ListOfProps = {
235
302
  declare function ListOf({ kind, showPageNumbers, style, className }: ListOfProps): import("react").JSX.Element;
236
303
  declare function ListOfFigures(props: Omit<ListOfProps, 'kind'>): import("react").JSX.Element;
237
304
  declare function ListOfTables(props: Omit<ListOfProps, 'kind'>): import("react").JSX.Element;
305
+ type CiteProps = {
306
+ /** Stable citation key (e.g. 'rfc9110' or 'q3-audit'). */
307
+ id: string;
308
+ /** Citation details printed in `<Bibliography />`. Needs only to be supplied on one `<Cite>` for that id, or in `<Bibliography items={...} />`. */
309
+ source?: string;
310
+ style?: CSSProperties;
311
+ className?: string;
312
+ };
313
+ /**
314
+ * An inline bibliographic citation (`[1]`), numbered in order of first
315
+ * appearance across the rendered pages. Multiple `<Cite id="x" />` calls share
316
+ * the same number.
317
+ */
318
+ declare function Cite({ id, source, style, className }: CiteProps): import("react").JSX.Element;
319
+ type BibliographyItem = {
320
+ id?: string;
321
+ title?: ReactNode;
322
+ source?: ReactNode;
323
+ author?: string;
324
+ year?: string | number;
325
+ url?: string;
326
+ note?: string;
327
+ };
328
+ type BibliographyProps = {
329
+ /** Optional catalog of reference details keyed by citation `id` (or an array with `id`). Merged with inline `<Cite source="..." />` texts. */
330
+ items?: Record<string, string | BibliographyItem> | BibliographyItem[];
331
+ /** Optional heading text above the reference list. Pass `""` to omit. */
332
+ title?: ReactNode;
333
+ /** Show page numbers where each citation first appeared. */
334
+ showPageNumbers?: boolean;
335
+ style?: CSSProperties;
336
+ className?: string;
337
+ };
338
+ /**
339
+ * Renders the numbered list of all `<Cite>` references in order of appearance,
340
+ * plus any additional uncited entries passed in `items`.
341
+ */
342
+ declare function Bibliography({ items, title, showPageNumbers, style, className }: BibliographyProps): import("react").JSX.Element;
238
343
  //#endregion
239
344
  //#region src/app/components/table-of-contents.d.ts
240
345
  type TableOfContentsProps = {
@@ -257,50 +362,6 @@ type TableOfContentsProps = {
257
362
  */
258
363
  declare function TableOfContents({ maxLevel, showPageNumbers, includeOwnPage, indent, style, className }: TableOfContentsProps): import("react").JSX.Element;
259
364
  //#endregion
260
- //#region src/app/lib/flow.d.ts
261
- /**
262
- * Wraps continuous content so the framework paginates it, instead of the author
263
- * hand-splitting sections into fixed pages. Each direct child is one atomic
264
- * block — a heading, a paragraph, a table — that never straddles a page break.
265
- */
266
- declare function flow(children: ReactNode, opts?: {
267
- header?: ComponentType;
268
- footer?: ComponentType;
269
- padding?: number;
270
- }): FlowSection;
271
- declare function isFlowSection(entry: DocEntry): entry is FlowSection;
272
- type BlockMetrics = {
273
- height: number;
274
- /** Height this block's footnotes add to the foot of whatever page it lands on. */
275
- footnoteHeight?: number;
276
- /** A heading must not be the last block on a page. */
277
- keepWithNext?: boolean;
278
- /** A caption must not open a page without the figure it belongs to. */
279
- keepWithPrevious?: boolean;
280
- /** Always start a new page before this block. */
281
- breakBefore?: boolean;
282
- };
283
- type PaginationResult = {
284
- /** Block indices per page, in order. */
285
- pages: number[][];
286
- /** Blocks taller than one page — they stay whole and overflow. */
287
- overflowing: number[];
288
- };
289
- type PaginateOptions = {
290
- /** Rule and padding a page's footnote area costs before its first note. */
291
- footnoteOverhead?: number;
292
- };
293
- /**
294
- * Greedy top-to-bottom packing: fill a page until the next block would cross
295
- * the bottom edge, then push that block — plus anything glued to it — onto the
296
- * next page. Blocks are atomic; nothing is split mid-block.
297
- *
298
- * Footnotes are packed from the same budget: a block that carries notes brings
299
- * their height with it, because those notes print at the foot of whichever page
300
- * the block lands on.
301
- */
302
- declare function paginateBlocks(blocks: BlockMetrics[], available: number, opts?: PaginateOptions): PaginationResult;
303
- //#endregion
304
365
  //#region src/app/lib/outline.d.ts
305
366
  type OutlineEntry = {
306
367
  id: string;
@@ -343,6 +404,7 @@ type DiagramNode = {
343
404
  id: string;
344
405
  label: string;
345
406
  shape: NodeShape;
407
+ subgraph?: string;
346
408
  };
347
409
  type EdgeStyle = 'solid' | 'dashed' | 'thick';
348
410
  type DiagramEdge = {
@@ -353,10 +415,30 @@ type DiagramEdge = {
353
415
  /** A `---` link draws no arrowhead. */
354
416
  arrow: boolean;
355
417
  };
418
+ type DiagramSubgraph = {
419
+ id: string;
420
+ label: string;
421
+ nodeIds: string[];
422
+ };
423
+ type SequenceParticipant = {
424
+ id: string;
425
+ label: string;
426
+ };
427
+ type SequenceMessage = {
428
+ from: string;
429
+ to: string;
430
+ label: string;
431
+ style: EdgeStyle;
432
+ arrow: boolean;
433
+ };
356
434
  type Diagram$1 = {
435
+ kind?: 'flowchart' | 'sequence';
357
436
  direction: Direction;
358
437
  nodes: DiagramNode[];
359
438
  edges: DiagramEdge[];
439
+ subgraphs?: DiagramSubgraph[];
440
+ participants?: SequenceParticipant[];
441
+ messages?: SequenceMessage[];
360
442
  };
361
443
  declare class DiagramSyntaxError extends Error {
362
444
  readonly line: number;
@@ -364,6 +446,20 @@ declare class DiagramSyntaxError extends Error {
364
446
  }
365
447
  //#endregion
366
448
  //#region src/diagram/layout.d.ts
449
+ type LaidOutSubgraph = {
450
+ id: string;
451
+ label: string;
452
+ x: number;
453
+ y: number;
454
+ width: number;
455
+ height: number;
456
+ };
457
+ type LaidOutLifeline = {
458
+ id: string;
459
+ x: number;
460
+ y1: number;
461
+ y2: number;
462
+ };
367
463
  type LayoutOptions = {
368
464
  fontSize?: number;
369
465
  /** Gap between consecutive ranks, along the flow direction. */
@@ -393,4 +489,4 @@ type CompileOptions = LayoutOptions & RenderOptions;
393
489
  /** Mermaid-flavoured text in, themed SVG out. One call, no browser. */
394
490
  declare function compileDiagram(source: string, options?: CompileOptions): CompiledDiagram;
395
491
  //#endregion
396
- export { type BlockMetrics, type CellValue, Chart, type ChartFormat, type ChartProps, type ChartType, type CompileOptions, type CompiledDiagram, DEFAULT_ORIENTATION, DEFAULT_PAGE_SIZE, type DataAlign, type DataColumn, type DataFormat, type DataRecord, 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, Field, type FieldProps, 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, ORIENTATIONS, type OpenDocBuildConfig, type OpenDocConfig, 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, useRecord };
492
+ export { Bibliography, type BibliographyItem, type BibliographyProps, type BlockMetrics, type BlockSlice, Callout, type CalloutProps, type CalloutVariant, type CellValue, Chart, type ChartFormat, type ChartProps, type ChartType, Cite, type CiteProps, CodeBlock, type CodeBlockProps, type CompileOptions, type CompiledDiagram, DEFAULT_ORIENTATION, DEFAULT_PAGE_SIZE, type DataAlign, type DataColumn, type DataFormat, type DataRecord, type DataSummaryOp, DataTable, type DataTableProps, type DelimitedTable, type DesignFonts, type DesignPalette, type DesignSystem, type DesignTypeScale, Diagram, type DiagramProps, type DiagramSource, type DiagramSubgraph, DiagramSyntaxError, type DocEntry, type DocMeta, type DocModule, type DocPage, Field, type FieldProps, Figure, type FigureProps, type FlowSection, Footnote, type FootnoteProps, Footnotes, type FootnotesProps, ImagePlaceholder, type ImagePlaceholderProps, type LabelEntry, type LabelKind, type LabelVocabulary, type LaidOutLifeline, type LaidOutSubgraph, ListOf, ListOfFigures, type ListOfProps, ListOfTables, ORIENTATIONS, type OpenDocBuildConfig, type OpenDocConfig, type OpenDocDeployConfig, type OpenDocGcpDeployConfig, type Orientation, type OutlineEntry, PAGE_SIZES, PAGE_SIZE_NAMES, type PageGeometry, type PageSizeName, type PaginationResult, Ref, type RefProps, type SequenceMessage, type SequenceParticipant, Sparkline, type SparklineProps, TableOfContents, type TableOfContentsProps, compileDiagram, cssVarsToString, defaultDesign, designToCssVars, flow, isFlowSection, isOrientation, isPageSizeName, paginateBlocks, parseDelimited, resolvePageGeometry, useDocLabel, useDocLabels, useDocOutline, useDocPageCount, useDocPageNumber, useRecord };