@danielsimonjr/mathts-workbook 0.4.0 → 0.4.2

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 (55) hide show
  1. package/README.md +247 -247
  2. package/dist/{chunk-ZVCYWKM5.js → chunk-4P6ZKIDU.js} +1 -1
  3. package/dist/cli.d.ts +18 -19
  4. package/dist/cli.d.ts.map +1 -0
  5. package/dist/cli.js +13 -8
  6. package/dist/contract.d.ts +16 -0
  7. package/dist/contract.d.ts.map +1 -0
  8. package/dist/doc.d.ts +29 -0
  9. package/dist/doc.d.ts.map +1 -0
  10. package/dist/edit.d.ts +44 -0
  11. package/dist/edit.d.ts.map +1 -0
  12. package/dist/executor.d.ts +98 -0
  13. package/dist/executor.d.ts.map +1 -0
  14. package/dist/formatter.d.ts +9 -0
  15. package/dist/formatter.d.ts.map +1 -0
  16. package/dist/fs-atomic.d.ts +11 -0
  17. package/dist/fs-atomic.d.ts.map +1 -0
  18. package/dist/graph.d.ts +41 -0
  19. package/dist/graph.d.ts.map +1 -0
  20. package/dist/html.d.ts +43 -0
  21. package/dist/html.d.ts.map +1 -0
  22. package/dist/index.d.ts +18 -501
  23. package/dist/index.d.ts.map +1 -0
  24. package/dist/index.js +1 -1
  25. package/dist/introspect.d.ts +29 -0
  26. package/dist/introspect.d.ts.map +1 -0
  27. package/dist/ipynb.d.ts +24 -0
  28. package/dist/ipynb.d.ts.map +1 -0
  29. package/dist/markdown.d.ts +20 -0
  30. package/dist/markdown.d.ts.map +1 -0
  31. package/dist/parser.d.ts +47 -0
  32. package/dist/parser.d.ts.map +1 -0
  33. package/dist/pdf.d.ts +12 -0
  34. package/dist/pdf.d.ts.map +1 -0
  35. package/dist/rpc.d.ts +45 -0
  36. package/dist/rpc.d.ts.map +1 -0
  37. package/dist/run-worker.d.ts +2 -2
  38. package/dist/run-worker.d.ts.map +1 -0
  39. package/dist/session.d.ts +68 -0
  40. package/dist/session.d.ts.map +1 -0
  41. package/dist/svg-math.d.ts +19 -0
  42. package/dist/svg-math.d.ts.map +1 -0
  43. package/dist/svg.d.ts +9 -0
  44. package/dist/svg.d.ts.map +1 -0
  45. package/dist/tex.d.ts +17 -0
  46. package/dist/tex.d.ts.map +1 -0
  47. package/dist/timeout-runner.d.ts +22 -0
  48. package/dist/timeout-runner.d.ts.map +1 -0
  49. package/dist/types.d.ts +103 -0
  50. package/dist/types.d.ts.map +1 -0
  51. package/dist/worker-protocol.d.ts +44 -0
  52. package/dist/worker-protocol.d.ts.map +1 -0
  53. package/dist/yaml-safe.d.ts +34 -0
  54. package/dist/yaml-safe.d.ts.map +1 -0
  55. package/package.json +14 -13
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Machine-contract constants shared by the CLI and the public API.
3
+ *
4
+ * `SCHEMA_VERSION` is the version of the `--json` envelope shape. Clients
5
+ * negotiate with the rule: ignore unknown fields when `major` matches; refuse
6
+ * on a `major` mismatch. Additive fields bump `minor`; breaking changes bump
7
+ * `major`.
8
+ */
9
+ export declare const SCHEMA_VERSION: {
10
+ readonly major: 1;
11
+ readonly minor: 0;
12
+ };
13
+ export declare const VERSION: string;
14
+ /** Canonical dispatchable command list (advertised by `capabilities`; a test guards drift). */
15
+ export declare const COMMAND_NAMES: readonly ['run', 'describe', 'validate', 'graph', 'strip', 'new', 'capabilities', 'templates', 'cell', 'serve', 'functions', 'meta', 'import', 'export'];
16
+ //# sourceMappingURL=contract.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contract.d.ts","sourceRoot":"","sources":["../src/contract.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,eAAO,MAAM,cAAc;aAAK,KAAK,EAAE,CAAC;aAAE,KAAK,EAAE,CAAC;CAAW,CAAC;AAO9D,eAAO,MAAM,OAAO,EAAE,MAAwB,CAAC;AAE/C,+FAA+F;AAC/F,eAAO,MAAM,aAAa,YACxB,KAAK,EACL,UAAU,EACV,UAAU,EACV,OAAO,EACP,OAAO,EACP,KAAK,EACL,cAAc,EACd,WAAW,EACX,MAAM,EACN,OAAO,EACP,WAAW,EACX,MAAM,EACN,QAAQ,EACR,QAAQ,CACA,CAAC"}
package/dist/doc.d.ts ADDED
@@ -0,0 +1,29 @@
1
+ /**
2
+ * The structured "describe" document model — shared by the `describe` CLI
3
+ * command and the serve JSON-RPC router (kept out of cli.ts to avoid a cycle).
4
+ */
5
+ import type { Workbook } from './types';
6
+ export interface DescribeDoc {
7
+ version: string;
8
+ metadata: Workbook['metadata'];
9
+ runtime: Workbook['runtime'];
10
+ cells: Array<{
11
+ id: string;
12
+ type: string;
13
+ content: string;
14
+ dependsOn: string[];
15
+ metadata: Record<string, unknown>;
16
+ output: unknown;
17
+ error: unknown;
18
+ }>;
19
+ graph: {
20
+ edges: Array<{
21
+ from: string;
22
+ to: string;
23
+ }>;
24
+ cycles: string[][];
25
+ };
26
+ }
27
+ /** Build the `describe` payload for a (possibly missing) workbook. */
28
+ export declare function describeData(wb: Workbook | undefined): DescribeDoc;
29
+ //# sourceMappingURL=doc.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"doc.d.ts","sourceRoot":"","sources":["../src/doc.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAGxC,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,QAAQ,CAAC,UAAU,CAAC,CAAC;IAC/B,OAAO,EAAE,QAAQ,CAAC,SAAS,CAAC,CAAC;IAC7B,KAAK,EAAE,KAAK,CAAC;QACX,EAAE,EAAE,MAAM,CAAC;QACX,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,EAAE,MAAM,CAAC;QAChB,SAAS,EAAE,MAAM,EAAE,CAAC;QACpB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAClC,MAAM,EAAE,OAAO,CAAC;QAChB,KAAK,EAAE,OAAO,CAAC;KAChB,CAAC,CAAC;IACH,KAAK,EAAE;QAAE,KAAK,EAAE,KAAK,CAAC;YAAE,IAAI,EAAE,MAAM,CAAC;YAAC,EAAE,EAAE,MAAM,CAAA;SAAE,CAAC,CAAC;QAAC,MAAM,EAAE,MAAM,EAAE,EAAE,CAAA;KAAE,CAAC;CAC3E;AAED,sEAAsE;AACtE,wBAAgB,YAAY,CAAC,EAAE,EAAE,QAAQ,GAAG,SAAS,GAAG,WAAW,CAsBlE"}
package/dist/edit.d.ts ADDED
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Pure, immutable cell-mutation operations on a Workbook.
3
+ *
4
+ * Every op returns a NEW workbook (the input is never mutated) and enforces the
5
+ * runnable-valid invariants — unique + identifier-safe ids, supported cell
6
+ * types, existing `depends_on` references, no self-dependency, and no dependency
7
+ * cycle. An op that would break an invariant throws; callers must not write the
8
+ * file on a throw.
9
+ */
10
+ import type { Workbook, CellType } from './types';
11
+ export interface CellPosition {
12
+ before?: string;
13
+ after?: string;
14
+ at?: number;
15
+ }
16
+ export interface RemoveResult {
17
+ workbook: Workbook;
18
+ /** Cells whose `depends_on` was edited to detach the removed cell (force). */
19
+ changedCells: string[];
20
+ }
21
+ export declare function addCell(wb: Workbook, spec: {
22
+ id: string;
23
+ type: CellType;
24
+ content?: string;
25
+ dependsOn?: string[];
26
+ }, position?: CellPosition): Workbook;
27
+ export declare function editCell(wb: Workbook, id: string, changes: {
28
+ content?: string;
29
+ type?: CellType;
30
+ dependsOn?: string[];
31
+ }): Workbook;
32
+ export declare function removeCell(wb: Workbook, id: string, options?: {
33
+ force?: boolean;
34
+ }): RemoveResult;
35
+ export declare function moveCell(wb: Workbook, id: string, position: CellPosition): Workbook;
36
+ export declare function renameCell(wb: Workbook, oldId: string, newId: string): Workbook;
37
+ /** Update workbook-level metadata fields (only the provided ones). */
38
+ export declare function setMetadata(wb: Workbook, changes: {
39
+ title?: string;
40
+ author?: string;
41
+ description?: string;
42
+ tags?: string[];
43
+ }): Workbook;
44
+ //# sourceMappingURL=edit.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"edit.d.ts","sourceRoot":"","sources":["../src/edit.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAQ,QAAQ,EAAE,MAAM,SAAS,CAAC;AAIxD,MAAM,WAAW,YAAY;IAC3B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,EAAE,CAAC,EAAE,MAAM,CAAC;CACb;AAED,MAAM,WAAW,YAAY;IAC3B,QAAQ,EAAE,QAAQ,CAAC;IACnB,8EAA8E;IAC9E,YAAY,EAAE,MAAM,EAAE,CAAC;CACxB;AAkFD,wBAAgB,OAAO,CACrB,EAAE,EAAE,QAAQ,EACZ,IAAI,EAAE;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,QAAQ,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,EAAE,CAAA;CAAE,EAC5E,QAAQ,CAAC,EAAE,YAAY,GACtB,QAAQ,CAiBV;AAED,wBAAgB,QAAQ,CACtB,EAAE,EAAE,QAAQ,EACZ,EAAE,EAAE,MAAM,EACV,OAAO,EAAE;IAAE,OAAO,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,QAAQ,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,EAAE,CAAA;CAAE,GACnE,QAAQ,CAyBV;AAED,wBAAgB,UAAU,CAAC,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;IAAE,KAAK,CAAC,EAAE,OAAO,CAAA;CAAE,GAAG,YAAY,CAoBhG;AAED,wBAAgB,QAAQ,CAAC,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,YAAY,GAAG,QAAQ,CASnF;AAED,wBAAgB,UAAU,CAAC,EAAE,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,QAAQ,CA6B/E;AAED,sEAAsE;AACtE,wBAAgB,WAAW,CACzB,EAAE,EAAE,QAAQ,EACZ,OAAO,EAAE;IAAE,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,EAAE,CAAA;CAAE,GAClF,QAAQ,CAOV"}
@@ -0,0 +1,98 @@
1
+ /**
2
+ * Workbook executor
3
+ */
4
+ import type { Workbook, WorkbookEvent, RunResult } from './types';
5
+ /**
6
+ * Event handler type
7
+ */
8
+ type EventHandler = (event: WorkbookEvent) => void;
9
+ /**
10
+ * Workbook executor with reactive execution support
11
+ */
12
+ export declare class WorkbookExecutor {
13
+ private workbook;
14
+ private graph;
15
+ private outputs;
16
+ private handlers;
17
+ constructor(workbook: Workbook);
18
+ /**
19
+ * Subscribe to execution events
20
+ */
21
+ on(handler: EventHandler): () => void;
22
+ /**
23
+ * Emit an event to all handlers
24
+ */
25
+ private emit;
26
+ /**
27
+ * Run all cells in order
28
+ */
29
+ runAll(): Promise<void>;
30
+ /**
31
+ * Run a specific cell
32
+ */
33
+ runCell(cellId: string): Promise<unknown>;
34
+ /**
35
+ * Execute a single cell
36
+ */
37
+ private executeCell;
38
+ /**
39
+ * Build the evaluation scope from a cell's DIRECT dependency outputs.
40
+ *
41
+ * Dependency outputs are injected as named variables keyed by the
42
+ * dependency's cell id, so a cell can reference an earlier cell's result by
43
+ * that id. Injection is non-transitive: only ids in `cell.dependsOn` are
44
+ * injected (a dependency's own dependencies are not). An output of
45
+ * `undefined` (cell never ran) is skipped, so the reference fails loudly.
46
+ */
47
+ private buildScope;
48
+ /**
49
+ * Execute a code cell by evaluating its content as a MathTS expression.
50
+ *
51
+ * Evaluation goes through the MathTS expression engine — property and
52
+ * method access route through the expression sandbox, so this does not
53
+ * have the arbitrary-code-execution exposure of the `Function` constructor.
54
+ */
55
+ private executeCode;
56
+ /**
57
+ * Execute a test cell: evaluate its assertion expression in the dependency
58
+ * scope. The result must be a boolean — `runReport` classifies `true` as a
59
+ * pass and `false` as a fail. A non-boolean result is a usage error (a test
60
+ * that doesn't assert), surfaced via throw like any other evaluation error.
61
+ */
62
+ private executeTest;
63
+ /**
64
+ * Execute a data cell — parse its content as YAML (a superset of JSON) using
65
+ * the same hardened options + prototype-pollution guard as the document
66
+ * parser, so both YAML entry points are consistent.
67
+ */
68
+ private executeData;
69
+ /**
70
+ * Run every cell in dependency order and return a structured report.
71
+ *
72
+ * Unlike {@link runAll} (the event-stream API, which throws on the first cell
73
+ * error), `runReport` is the headless/report API: it is **continue-on-error**
74
+ * (one failing cell does not abort the rest) and never throws on a cell
75
+ * failure. A dependency cycle is refused up front. Test cells are classified
76
+ * as `pass`/`fail`/`error`; all other cells as `success`/`error`.
77
+ */
78
+ /**
79
+ * Seed the output cache (for incremental session runs): non-stale cells'
80
+ * outputs are provided so downstream cells can read them as scope without
81
+ * re-execution. Replaces any existing cached outputs.
82
+ */
83
+ seedOutputs(entries: Map<string, unknown>): void;
84
+ runReport(options?: {
85
+ only?: string;
86
+ runIds?: Set<string>;
87
+ }): Promise<RunResult>;
88
+ /**
89
+ * Get output from a previous cell
90
+ */
91
+ getOutput(cellId: string): unknown;
92
+ }
93
+ /**
94
+ * Create an executor for a workbook
95
+ */
96
+ export declare function createExecutor(workbook: Workbook): WorkbookExecutor;
97
+ export {};
98
+ //# sourceMappingURL=executor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"executor.d.ts","sourceRoot":"","sources":["../src/executor.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EACV,QAAQ,EAER,aAAa,EAGb,SAAS,EACV,MAAM,SAAS,CAAC;AAKjB;;GAEG;AACH,KAAK,YAAY,GAAG,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAC;AAEnD;;GAEG;AACH,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,QAAQ,CAAW;IAC3B,OAAO,CAAC,KAAK,CAAkB;IAC/B,OAAO,CAAC,OAAO,CAAmC;IAClD,OAAO,CAAC,QAAQ,CAAsB;IAEtC,YAAY,QAAQ,EAAE,QAAQ,EAG7B;IAED;;OAEG;IACH,EAAE,CAAC,OAAO,EAAE,YAAY,GAAG,MAAM,IAAI,CAQpC;IAED;;OAEG;IACH,OAAO,CAAC,IAAI;IAMZ;;OAEG;IACG,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC,CAS5B;IAED;;OAEG;IACG,OAAO,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAgD9C;IAED;;OAEG;YACW,WAAW;IAiBzB;;;;;;;;OAQG;IACH,OAAO,CAAC,UAAU;IAelB;;;;;;OAMG;YACW,WAAW;IAIzB;;;;;OAKG;YACW,WAAW;IAQzB;;;;OAIG;YACW,WAAW;IAKzB;;;;;;;;OAQG;IACH;;;;OAIG;IACH,WAAW,CAAC,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAE/C;IAEK,SAAS,CAAC,OAAO,GAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,CAAA;KAAO,GAAG,OAAO,CAAC,SAAS,CAAC,CAwDzF;IAED;;OAEG;IACH,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAEjC;CACF;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,QAAQ,EAAE,QAAQ,GAAG,gBAAgB,CAEnE"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Human-readable rendering of cell results for terminal output.
3
+ *
4
+ * `formatResult` is called inside the executor's continue-on-error loop, so it
5
+ * MUST NOT throw — circular references, BigInt, and unserializable values all
6
+ * fall back to safe markers rather than crashing the run.
7
+ */
8
+ export declare function formatResult(value: unknown): string;
9
+ //# sourceMappingURL=formatter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formatter.d.ts","sourceRoot":"","sources":["../src/formatter.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAkDH,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CA8BnD"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Atomic file write shared by the CLI write commands and the serve session.
3
+ */
4
+ /**
5
+ * Write `content` to `file` atomically: write a uniquely-named sibling temp
6
+ * file (exclusive create, so a pre-planted symlink can't be hijacked), then
7
+ * rename over the target (atomic on the same filesystem; replaces a symlink
8
+ * rather than writing through it). On any failure the temp file is removed.
9
+ */
10
+ export declare function writeFileAtomic(file: string, content: string): void;
11
+ //# sourceMappingURL=fs-atomic.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fs-atomic.d.ts","sourceRoot":"","sources":["../src/fs-atomic.ts"],"names":[],"mappings":"AAAA;;GAEG;AAMH;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,CAanE"}
@@ -0,0 +1,41 @@
1
+ /**
2
+ * Dependency graph management
3
+ */
4
+ import type { Cell, DependencyGraph, DependencyNode } from './types';
5
+ /**
6
+ * Build dependency graph from cells
7
+ */
8
+ export declare function buildDependencyGraph(cells: Cell[]): DependencyGraph;
9
+ /**
10
+ * Topological sort for execution order
11
+ */
12
+ export declare function topologicalSort(nodes: Map<string, DependencyNode>): string[];
13
+ /**
14
+ * Get all cells that depend on a given cell
15
+ */
16
+ export declare function getDependents(graph: DependencyGraph, cellId: string): string[];
17
+ /**
18
+ * All transitive dependencies of `id` plus `id` itself (its ancestor closure).
19
+ * Used to run a single cell together with everything it needs. Cycle-safe via
20
+ * a visited set; returns `[]` if `id` is not in the graph.
21
+ */
22
+ export declare function getAncestors(graph: DependencyGraph, id: string): string[];
23
+ /**
24
+ * Render the dependency graph as a Mermaid `graph TD` diagram.
25
+ *
26
+ * Cell ids are validated identifiers (`[A-Za-z_][A-Za-z0-9_]*`), so they are
27
+ * safe to use verbatim as both the node id and its quoted label — Mermaid
28
+ * syntax injection is impossible and no cell content appears in the output.
29
+ */
30
+ export declare function toMermaid(graph: DependencyGraph): string;
31
+ /**
32
+ * Render the dependency graph as Graphviz DOT (the DOT analog of toMermaid).
33
+ * Cell ids are validated identifiers ([A-Za-z_][A-Za-z0-9_]*), safe verbatim as
34
+ * both node id and quoted label; no cell content appears in the output.
35
+ */
36
+ export declare function toDOT(graph: DependencyGraph): string;
37
+ /**
38
+ * Detect circular dependencies
39
+ */
40
+ export declare function detectCycles(graph: DependencyGraph): string[][];
41
+ //# sourceMappingURL=graph.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"graph.d.ts","sourceRoot":"","sources":["../src/graph.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAErE;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,IAAI,EAAE,GAAG,eAAe,CA0BnE;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,cAAc,CAAC,GAAG,MAAM,EAAE,CAuB5E;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,eAAe,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAmB9E;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,eAAe,EAAE,EAAE,EAAE,MAAM,GAAG,MAAM,EAAE,CAezE;AAED;;;;;;GAMG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,eAAe,GAAG,MAAM,CAcxD;AAED;;;;GAIG;AACH,wBAAgB,KAAK,CAAC,KAAK,EAAE,eAAe,GAAG,MAAM,CAepD;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,eAAe,GAAG,MAAM,EAAE,EAAE,CAoC/D"}
package/dist/html.d.ts ADDED
@@ -0,0 +1,43 @@
1
+ /**
2
+ * Assemble a generic document structure into one self-contained HTML5 file —
3
+ * markdown prose, MathML equations, embedded code + outputs, test badges, and
4
+ * (pre-rendered) charts, with an inlined stylesheet (no external requests).
5
+ *
6
+ * Operates on a plain `RenderDoc` (not the workbook's `Workbook` type) to avoid
7
+ * a dependency inversion. `parse` is injected by the caller (the assembled
8
+ * `parse` lives in the functions package) to render equation expressions; cell
9
+ * outputs are pre-formatted strings supplied by the caller. All user content is
10
+ * HTML-escaped before embedding.
11
+ */
12
+ export interface RenderCell {
13
+ type: string;
14
+ content: string;
15
+ id?: string;
16
+ /** Pre-formatted output string (the caller formats values); omitted if none. */
17
+ output?: string;
18
+ error?: string;
19
+ /** For `test` cells: whether the assertion passed. */
20
+ passed?: boolean;
21
+ /** For `chart` cells: pre-rendered inline SVG. */
22
+ chartSvg?: string;
23
+ /** For `chart` cells in a TeX export: pre-rendered embeddable TikZ. */
24
+ chartTikz?: string;
25
+ /** Optional diagnostic note (e.g. a chart whose data didn't resolve). */
26
+ note?: string;
27
+ }
28
+ export interface RenderDoc {
29
+ title?: string;
30
+ author?: string;
31
+ description?: string;
32
+ tags?: string[];
33
+ cells: RenderCell[];
34
+ }
35
+ export interface ToHtmlOptions {
36
+ /** Parser for equation expressions (e.g. the functions package `parse`). */
37
+ parse?: (expr: string) => unknown;
38
+ }
39
+ /** A small static stylesheet (explicit colors, system fonts — no external assets). */
40
+ export declare function toCSS(): string;
41
+ /** Render a generic document structure to a self-contained HTML5 string. */
42
+ export declare function toHTML(doc: RenderDoc, options?: ToHtmlOptions): string;
43
+ //# sourceMappingURL=html.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"html.d.ts","sourceRoot":"","sources":["../src/html.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAKH,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,gFAAgF;IAChF,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,sDAAsD;IACtD,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,kDAAkD;IAClD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,uEAAuE;IACvE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,yEAAyE;IACzE,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,SAAS;IACxB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,KAAK,EAAE,UAAU,EAAE,CAAC;CACrB;AAED,MAAM,WAAW,aAAa;IAC5B,4EAA4E;IAC5E,KAAK,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC;CACnC;AAyED,sFAAsF;AACtF,wBAAgB,KAAK,IAAI,MAAM,CA8B9B;AAED,4EAA4E;AAC5E,wBAAgB,MAAM,CAAC,GAAG,EAAE,SAAS,EAAE,OAAO,GAAE,aAAkB,GAAG,MAAM,CA6B1E"}