@danielsimonjr/mathts-workbook 0.1.2 → 0.1.4

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 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: "1.0"
68
+ version: '1.0'
73
69
  metadata:
74
- title: "Matrix Analysis"
75
- author: "Your Name"
70
+ title: 'Matrix Analysis'
71
+ author: 'Your Name'
76
72
 
77
73
  runtime:
78
74
  engine: mathts
79
- execution: reactive # reactive | sequential | manual
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 | Description |
103
- |------|-------------|
104
- | `markdown` | Documentation with LaTeX math |
105
- | `code` | TypeScript/JavaScript execution |
106
- | `tensor` | Einstein notation for tensor math |
107
- | `equation` | LaTeX equations with labels |
108
- | `visualization` | Three.js/D3/Plotly rendering |
109
- | `data` | YAML/JSON/CSV data |
110
- | `test` | Assertions with timeout |
111
- | `export` | Publication output |
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 with scope from dependency outputs.
219
+ * Execute a code cell by evaluating its content as a MathTS expression.
218
220
  *
219
- * Uses the Function constructor to evaluate expressions. Cell dependencies
220
- * are injected as named variables in the evaluation scope, allowing cells
221
- * to reference outputs of earlier cells by their id.
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
- const scopeKeys = Object.keys(scope);
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
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  createExecutor,
4
4
  parseWorkbook
5
- } from "./chunk-64JBL36K.js";
5
+ } from "./chunk-L7UWFWMV.js";
6
6
 
7
7
  // src/cli.ts
8
8
  var HELP = `
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 with scope from dependency outputs.
159
+ * Execute a code cell by evaluating its content as a MathTS expression.
160
160
  *
161
- * Uses the Function constructor to evaluate expressions. Cell dependencies
162
- * are injected as named variables in the evaluation scope, allowing cells
163
- * to reference outputs of earlier cells by their id.
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
@@ -8,7 +8,7 @@ import {
8
8
  serializeWorkbook,
9
9
  stripOutputs,
10
10
  topologicalSort
11
- } from "./chunk-64JBL36K.js";
11
+ } from "./chunk-L7UWFWMV.js";
12
12
  export {
13
13
  VERSION,
14
14
  WorkbookExecutor,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@danielsimonjr/mathts-workbook",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
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.3",
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": "^2.0.0"
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": "packages/workbook"
53
+ "directory": "workbook"
53
54
  },
54
55
  "keywords": [
55
56
  "notebook",