@matheos/core 0.0.0-stage → 0.2.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 +44 -2
- package/dist/evaluate.d.ts +13 -0
- package/dist/evaluate.js +612 -0
- package/dist/evaluate.js.map +1 -0
- package/dist/graph.d.ts +24 -0
- package/dist/graph.js +68 -0
- package/dist/graph.js.map +1 -0
- package/dist/html.d.ts +8 -0
- package/dist/html.js +245 -0
- package/dist/html.js.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -0
- package/dist/model.d.ts +218 -0
- package/dist/model.js +2 -0
- package/dist/model.js.map +1 -0
- package/dist/parse.d.ts +2 -0
- package/dist/parse.js +286 -0
- package/dist/parse.js.map +1 -0
- package/dist/plot.d.ts +17 -0
- package/dist/plot.js +79 -0
- package/dist/plot.js.map +1 -0
- package/dist/printer.d.ts +26 -0
- package/dist/printer.js +328 -0
- package/dist/printer.js.map +1 -0
- package/dist/units.d.ts +21 -0
- package/dist/units.js +168 -0
- package/dist/units.js.map +1 -0
- package/package.json +67 -4
package/README.md
CHANGED
|
@@ -1,3 +1,45 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @matheos/core
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The engine behind [Matheos](https://matheos.fly.dev): plain-text `.mth` calculation documents for
|
|
4
|
+
structural engineers. Markdown prose plus unit-aware math blocks, checks with utilization,
|
|
5
|
+
catalogues, loops, plots; rendered to a printable A4 report. No DOM: runs in Node and in the
|
|
6
|
+
browser.
|
|
7
|
+
|
|
8
|
+
```ts
|
|
9
|
+
import { parse, evaluate, statements } from '@matheos/core';
|
|
10
|
+
import { toHtml } from '@matheos/core/html';
|
|
11
|
+
|
|
12
|
+
const text = `
|
|
13
|
+
---
|
|
14
|
+
title: Floor beam
|
|
15
|
+
---
|
|
16
|
+
\`\`\`math
|
|
17
|
+
L = 6.0 m ? # span
|
|
18
|
+
q_Ed = 25 kN/m ?
|
|
19
|
+
M_Ed = q_Ed L^2 / 8 to kNm
|
|
20
|
+
W_pl_y = 628.4 cm^3
|
|
21
|
+
f_y = 355 MPa
|
|
22
|
+
M_c_Rd = W_pl_y f_y / 1.0 to kNm
|
|
23
|
+
check M_Ed <= M_c_Rd warn 80%
|
|
24
|
+
\`\`\`
|
|
25
|
+
`;
|
|
26
|
+
|
|
27
|
+
const doc = parse(text);
|
|
28
|
+
const rendered = evaluate(doc, { resolve: (file) => catalogues[file] }); // catalogues: JSON tables named in the front matter
|
|
29
|
+
const failed = statements(rendered).filter((s) => s.kind === 'check' && !s.verdict);
|
|
30
|
+
const html = toHtml(rendered); // a self-contained page: KaTeX from a CDN unless `head` is given
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
- `parse(text)` → `Document` (front matter, blocks, statements with positions).
|
|
34
|
+
- `evaluate(doc, { resolve? })` → `Rendered`: per statement the LaTeX line (`name = formula = substituted = result`),
|
|
35
|
+
verdict and η for checks, errors with positions, warnings, the final scope.
|
|
36
|
+
- `toHtml(rendered, { head?, assets? })` → the report. `head` replaces the CDN KaTeX link (inline the CSS for
|
|
37
|
+
offline use); `assets` resolves relative image paths.
|
|
38
|
+
- `statements(rendered)` → every statement in document order, loops included.
|
|
39
|
+
|
|
40
|
+
Grammar and authoring guide: the `matheos guide` command of `@matheos/cli`, or
|
|
41
|
+
[SKILL.md](https://github.com/Suharevillya/matheos-issues/blob/main/SKILL.md). Bugs:
|
|
42
|
+
[matheos-issues](https://github.com/Suharevillya/matheos-issues/issues).
|
|
43
|
+
|
|
44
|
+
Versioning: semantic; the grammar is additive within a major. The web app, the CLI and the FrameLab
|
|
45
|
+
integration pin a version and upgrade by bumping it.
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Document, Pos, Rendered, RenderedStatement } from './model.js';
|
|
2
|
+
export interface EvalOptions {
|
|
3
|
+
/** Loads a catalogue file named in the front matter (`catalogs:`); undefined means not found. */
|
|
4
|
+
resolve?: (path: string) => unknown;
|
|
5
|
+
/** internal: recursion depth of the loop expansion pass */
|
|
6
|
+
depth?: number;
|
|
7
|
+
}
|
|
8
|
+
/** `c_z'` in an expression: the prime is part of the name (`c_z$p` for math.js, which would read `'` as transpose); strings are left alone. */
|
|
9
|
+
export declare function primes(s: string): string;
|
|
10
|
+
export declare function evaluate(doc: Document, options?: EvalOptions): Rendered;
|
|
11
|
+
/** Every rendered statement, loops included, in document order. */
|
|
12
|
+
export declare function statements(r: Rendered): RenderedStatement[];
|
|
13
|
+
export type { Pos };
|