@danielsimonjr/mathts-workbook 0.1.2 → 0.1.3
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 +17 -21
- package/dist/{chunk-64JBL36K.js → chunk-L7UWFWMV.js} +11 -15
- package/dist/cli.js +1 -1
- package/dist/index.d.ts +7 -5
- package/dist/index.js +1 -1
- package/package.json +5 -4
package/README.md
CHANGED
|
@@ -19,22 +19,18 @@ mtsw run example.mtsw
|
|
|
19
19
|
# Run specific cell
|
|
20
20
|
mtsw run example.mtsw -c compute
|
|
21
21
|
|
|
22
|
-
# Watch for changes
|
|
23
|
-
mtsw watch example.mtsw
|
|
24
|
-
|
|
25
22
|
# Validate structure
|
|
26
23
|
mtsw validate example.mtsw
|
|
27
24
|
|
|
28
25
|
# Show dependency graph
|
|
29
26
|
mtsw graph example.mtsw
|
|
30
27
|
|
|
31
|
-
# Create from template
|
|
28
|
+
# Create from template (basic | tensor-physics | data-science)
|
|
32
29
|
mtsw new my-workbook -t tensor-physics
|
|
33
|
-
|
|
34
|
-
# Export
|
|
35
|
-
mtsw export example.mtsw -f html
|
|
36
30
|
```
|
|
37
31
|
|
|
32
|
+
> Note: `mtsw watch` and `mtsw export` appear in the CLI help text but are not yet implemented.
|
|
33
|
+
|
|
38
34
|
### Programmatic API
|
|
39
35
|
|
|
40
36
|
```typescript
|
|
@@ -69,14 +65,14 @@ if (result.success && result.workbook) {
|
|
|
69
65
|
## Workbook Format (.mtsw)
|
|
70
66
|
|
|
71
67
|
```yaml
|
|
72
|
-
version:
|
|
68
|
+
version: '1.0'
|
|
73
69
|
metadata:
|
|
74
|
-
title:
|
|
75
|
-
author:
|
|
70
|
+
title: 'Matrix Analysis'
|
|
71
|
+
author: 'Your Name'
|
|
76
72
|
|
|
77
73
|
runtime:
|
|
78
74
|
engine: mathts
|
|
79
|
-
execution: reactive
|
|
75
|
+
execution: reactive # reactive | sequential | manual
|
|
80
76
|
|
|
81
77
|
cells:
|
|
82
78
|
- markdown: |
|
|
@@ -99,16 +95,16 @@ cells:
|
|
|
99
95
|
|
|
100
96
|
## Cell Types
|
|
101
97
|
|
|
102
|
-
| Type
|
|
103
|
-
|
|
104
|
-
| `markdown`
|
|
105
|
-
| `code`
|
|
106
|
-
| `tensor`
|
|
107
|
-
| `equation`
|
|
108
|
-
| `visualization` | Three.js/D3/Plotly rendering
|
|
109
|
-
| `data`
|
|
110
|
-
| `test`
|
|
111
|
-
| `export`
|
|
98
|
+
| Type | Description |
|
|
99
|
+
| --------------- | --------------------------------- |
|
|
100
|
+
| `markdown` | Documentation with LaTeX math |
|
|
101
|
+
| `code` | TypeScript/JavaScript execution |
|
|
102
|
+
| `tensor` | Einstein notation for tensor math |
|
|
103
|
+
| `equation` | LaTeX equations with labels |
|
|
104
|
+
| `visualization` | Three.js/D3/Plotly rendering |
|
|
105
|
+
| `data` | YAML/JSON/CSV data |
|
|
106
|
+
| `test` | Assertions with timeout |
|
|
107
|
+
| `export` | Publication output |
|
|
112
108
|
|
|
113
109
|
## Execution Modes
|
|
114
110
|
|
|
@@ -112,6 +112,8 @@ function getDependents(graph, cellId) {
|
|
|
112
112
|
}
|
|
113
113
|
|
|
114
114
|
// src/executor.ts
|
|
115
|
+
import { evaluate } from "@danielsimonjr/mathts-functions";
|
|
116
|
+
import { parse as parseYaml } from "yaml";
|
|
115
117
|
var WorkbookExecutor = class {
|
|
116
118
|
workbook;
|
|
117
119
|
graph;
|
|
@@ -214,11 +216,13 @@ var WorkbookExecutor = class {
|
|
|
214
216
|
}
|
|
215
217
|
}
|
|
216
218
|
/**
|
|
217
|
-
* Execute a code cell by evaluating its content
|
|
219
|
+
* Execute a code cell by evaluating its content as a MathTS expression.
|
|
218
220
|
*
|
|
219
|
-
*
|
|
220
|
-
*
|
|
221
|
-
*
|
|
221
|
+
* Dependency outputs are injected as named variables in the evaluation
|
|
222
|
+
* scope, so a cell can reference the result of an earlier cell by its id.
|
|
223
|
+
* Evaluation goes through the MathTS expression engine — property and
|
|
224
|
+
* method access route through the expression sandbox, so this does not
|
|
225
|
+
* have the arbitrary-code-execution exposure of the `Function` constructor.
|
|
222
226
|
*/
|
|
223
227
|
async executeCode(cell) {
|
|
224
228
|
const scope = {};
|
|
@@ -230,21 +234,13 @@ var WorkbookExecutor = class {
|
|
|
230
234
|
}
|
|
231
235
|
}
|
|
232
236
|
}
|
|
233
|
-
|
|
234
|
-
const scopeValues = scopeKeys.map((k) => scope[k]);
|
|
235
|
-
try {
|
|
236
|
-
const fn = new Function(...scopeKeys, `return (${cell.content});`);
|
|
237
|
-
return fn(...scopeValues);
|
|
238
|
-
} catch {
|
|
239
|
-
const fn = new Function(...scopeKeys, cell.content);
|
|
240
|
-
return fn(...scopeValues);
|
|
241
|
-
}
|
|
237
|
+
return evaluate(cell.content, scope);
|
|
242
238
|
}
|
|
243
239
|
/**
|
|
244
|
-
* Execute a data cell
|
|
240
|
+
* Execute a data cell — parse its content as YAML (a superset of JSON).
|
|
245
241
|
*/
|
|
246
242
|
async executeData(cell) {
|
|
247
|
-
return cell.content;
|
|
243
|
+
return parseYaml(cell.content);
|
|
248
244
|
}
|
|
249
245
|
/**
|
|
250
246
|
* Get output from a previous cell
|
package/dist/cli.js
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -156,15 +156,17 @@ declare class WorkbookExecutor {
|
|
|
156
156
|
*/
|
|
157
157
|
private executeCell;
|
|
158
158
|
/**
|
|
159
|
-
* Execute a code cell by evaluating its content
|
|
159
|
+
* Execute a code cell by evaluating its content as a MathTS expression.
|
|
160
160
|
*
|
|
161
|
-
*
|
|
162
|
-
*
|
|
163
|
-
*
|
|
161
|
+
* Dependency outputs are injected as named variables in the evaluation
|
|
162
|
+
* scope, so a cell can reference the result of an earlier cell by its id.
|
|
163
|
+
* Evaluation goes through the MathTS expression engine — property and
|
|
164
|
+
* method access route through the expression sandbox, so this does not
|
|
165
|
+
* have the arbitrary-code-execution exposure of the `Function` constructor.
|
|
164
166
|
*/
|
|
165
167
|
private executeCode;
|
|
166
168
|
/**
|
|
167
|
-
* Execute a data cell
|
|
169
|
+
* Execute a data cell — parse its content as YAML (a superset of JSON).
|
|
168
170
|
*/
|
|
169
171
|
private executeData;
|
|
170
172
|
/**
|
package/dist/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@danielsimonjr/mathts-workbook",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"description": "Scientific workbook runtime for MathTS (.mtsw format)",
|
|
5
5
|
"author": "Daniel Simon Jr.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -34,14 +34,15 @@
|
|
|
34
34
|
"build:prod": "tsup src/index.ts src/cli.ts --format esm --dts --clean --minify --treeshake"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@danielsimonjr/mathts-core": "
|
|
37
|
+
"@danielsimonjr/mathts-core": "0.1.3",
|
|
38
|
+
"@danielsimonjr/mathts-functions": "0.2.2",
|
|
38
39
|
"yaml": "^2.3.0"
|
|
39
40
|
},
|
|
40
41
|
"devDependencies": {
|
|
41
42
|
"@types/node": "^25.5.2",
|
|
42
43
|
"tsup": "^8.0.0",
|
|
43
44
|
"typescript": "^5.3.0",
|
|
44
|
-
"vitest": "^
|
|
45
|
+
"vitest": "^4.1.5"
|
|
45
46
|
},
|
|
46
47
|
"publishConfig": {
|
|
47
48
|
"access": "public"
|
|
@@ -49,7 +50,7 @@
|
|
|
49
50
|
"repository": {
|
|
50
51
|
"type": "git",
|
|
51
52
|
"url": "https://github.com/danielsimonjr/mathts",
|
|
52
|
-
"directory": "
|
|
53
|
+
"directory": "workbook"
|
|
53
54
|
},
|
|
54
55
|
"keywords": [
|
|
55
56
|
"notebook",
|