@tellegen/engine 0.2.0 → 0.4.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.
Files changed (60) hide show
  1. package/README.md +71 -20
  2. package/dist/data/populated_places.json +1 -0
  3. package/dist/generated/{contracts.d.ts → api-types.d.ts} +26 -18
  4. package/dist/generated/api-types.d.ts.map +1 -0
  5. package/dist/generated/api-types.js +8 -0
  6. package/dist/generated/api-types.js.map +1 -0
  7. package/dist/generated/study-schema.d.ts +2 -0
  8. package/dist/generated/study-schema.d.ts.map +1 -0
  9. package/dist/generated/study-schema.js +3 -0
  10. package/dist/generated/study-schema.js.map +1 -0
  11. package/dist/generated/study-types.d.ts +426 -0
  12. package/dist/generated/study-types.d.ts.map +1 -0
  13. package/dist/generated/study-types.js +4 -0
  14. package/dist/generated/study-types.js.map +1 -0
  15. package/dist/generated/synth-schema.d.ts +2 -0
  16. package/dist/generated/synth-schema.d.ts.map +1 -0
  17. package/dist/generated/synth-schema.js +3 -0
  18. package/dist/generated/synth-schema.js.map +1 -0
  19. package/dist/generated/synth-types.d.ts +482 -0
  20. package/dist/generated/synth-types.d.ts.map +1 -0
  21. package/dist/generated/synth-types.js +4 -0
  22. package/dist/generated/synth-types.js.map +1 -0
  23. package/dist/host.d.ts +35 -2
  24. package/dist/host.d.ts.map +1 -1
  25. package/dist/host.js +103 -17
  26. package/dist/host.js.map +1 -1
  27. package/dist/index.d.ts +549 -122
  28. package/dist/index.d.ts.map +1 -1
  29. package/dist/index.js +780 -109
  30. package/dist/index.js.map +1 -1
  31. package/dist/input-limit.d.ts +1 -1
  32. package/dist/input-limit.js +1 -1
  33. package/dist/module.d.ts +2 -0
  34. package/dist/module.d.ts.map +1 -1
  35. package/dist/module.js.map +1 -1
  36. package/dist/protocol.d.ts +182 -31
  37. package/dist/protocol.d.ts.map +1 -1
  38. package/dist/protocol.js +153 -26
  39. package/dist/protocol.js.map +1 -1
  40. package/dist/study-document.d.ts +46 -0
  41. package/dist/study-document.d.ts.map +1 -0
  42. package/dist/study-document.js +183 -0
  43. package/dist/study-document.js.map +1 -0
  44. package/dist/study-document.test.d.ts +2 -0
  45. package/dist/study-document.test.d.ts.map +1 -0
  46. package/dist/study-document.test.js +119 -0
  47. package/dist/study-document.test.js.map +1 -0
  48. package/dist/wasm-pkg/LICENSE +17 -4
  49. package/dist/wasm-pkg/tellegen.d.ts +332 -85
  50. package/dist/wasm-pkg/tellegen.js +1324 -250
  51. package/dist/wasm-pkg/tellegen_bg.wasm +0 -0
  52. package/dist/wasm-pkg/tellegen_bg.wasm.d.ts +57 -9
  53. package/dist/worker.js +20 -5
  54. package/dist/worker.js.map +1 -1
  55. package/package.json +32 -11
  56. package/dist/generated/contracts.d.ts.map +0 -1
  57. package/dist/generated/contracts.js +0 -8
  58. package/dist/generated/contracts.js.map +0 -1
  59. package/dist/wasm-pkg/LICENSE-APACHE +0 -201
  60. package/dist/wasm-pkg/LICENSE-MIT +0 -19
package/README.md CHANGED
@@ -1,6 +1,7 @@
1
1
  # @tellegen/engine
2
2
 
3
- Browser package for tellegen case ingestion, wasm solves, Study lifecycle calls, previews, commits, and sensitivity queries.
3
+ Parses cases, runs WebAssembly solves, and exposes `Study` preview, commit, and
4
+ sensitivity calls in browsers.
4
5
 
5
6
  The package has no SvelteKit dependency. Host apps import the top level package and use either the direct functions or the `browserWasmTransport` facade:
6
7
 
@@ -9,13 +10,17 @@ import {
9
10
  browserWasmTransport,
10
11
  createStudy,
11
12
  ingestJsonDrop,
12
- solveJson,
13
+ solveModule,
13
14
  } from "@tellegen/engine";
14
15
  ```
15
16
 
16
17
  The wasm files are resolved relative to the package module. Host apps must serve
17
18
  package asset files from `node_modules`.
18
19
 
20
+ Under a Content Security Policy the engine needs `script-src 'wasm-unsafe-eval'`
21
+ (to compile WebAssembly; never `'unsafe-eval'`) and `worker-src 'self'`: its
22
+ workers are same-origin module workers.
23
+
19
24
  ## Browser Ingestion
20
25
 
21
26
  Case and JSON entry points accept the original bytes:
@@ -28,14 +33,50 @@ const casePayload = await ingestCase(bytes, "raw");
28
33
  const jsonPayload = await ingestJsonDrop(bytes);
29
34
  ```
30
35
 
31
- `ingestJsonDrop(bytes)` classifies and parses JSON in one call. Its
32
- `IngestedJsonDrop` result is discriminated by `kind`: balanced packages,
33
- multiconductor packages, and model JSON have a `null` format; transmission and
34
- distribution results carry the selected format; `ambiguous` and `unknown`
35
- results have a `null` payload.
36
+ Every solvable ingest payload includes `module_json`, a generation-2 PowerIO
37
+ IR module. Pass that value to `createStudy`, `solveModule`, and geographic
38
+ transforms. The engine does not expose a second network JSON boundary.
36
39
 
37
- Every byte-buffer API rejects inputs larger than `MAX_ENGINE_INPUT_BYTES`
38
- (128 MiB) before worker dispatch.
40
+ `ingestJsonDrop(bytes)` classifies and parses JSON in one call. Its
41
+ `IngestedJsonDrop` result is discriminated by `kind`: PowerIO modules have a
42
+ `null` format; transmission and distribution results carry the selected
43
+ format; `ambiguous` and `unknown` results have a `null` payload. Historical
44
+ bare model JSON is now `unknown`; regenerate it as `pio-ir` from source data.
45
+
46
+ Every API that accepts a byte buffer rejects inputs larger than
47
+ `MAX_ENGINE_INPUT_BYTES` (128 MiB) before worker dispatch.
48
+
49
+ ## Synthetic Grid Generation
50
+
51
+ `createSynthSession(request, { osm?, places?, signal? })` generates a
52
+ geo-referenced transmission grid for a region, one stage per `advance()`, on a
53
+ dedicated worker. Request and report types come from `@tellegen/engine/synth`.
54
+ The populated places table ships as `dist/data/populated_places.json`;
55
+ `syntheticPlacesUrl()`, `fetchSyntheticPlaces()` and `loadSyntheticPlaces()`
56
+ locate and load it. The
57
+ [synthetic generation guide](https://eigenergy.github.io/tellegen/synthetic-generation.html)
58
+ describes the stages, the demand model and the evidence.
59
+
60
+ ## Data Sources
61
+
62
+ The package ships data from third parties:
63
+
64
+ - **Natural Earth** populated places (`dist/data/populated_places.json`) and
65
+ country areas (compiled into the wasm): public domain,
66
+ [naturalearthdata.com](https://www.naturalearthdata.com/about/terms-of-use/).
67
+ - **Ember**, *Yearly Electricity Data*, through **Our World in Data**,
68
+ *Energy dataset*: national electricity demand, compiled into the wasm.
69
+ Licensed under [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/);
70
+ the table keeps each country's latest year, so changes were made. Its
71
+ population column is Our World in Data's series, compiled from the sources
72
+ at [ourworldindata.org/population-sources](https://ourworldindata.org/population-sources).
73
+ - **National transmission voltage levels**, compiled into the wasm from the
74
+ operator, regulator and standards documents each entry cites.
75
+
76
+ Grids generated with `source: "osm"` contain data from OpenStreetMap, ©
77
+ OpenStreetMap contributors, under the ODbL 1.0. The
78
+ [third-party notices](https://eigenergy.github.io/tellegen/third-party-notices.html)
79
+ give the full credits.
39
80
 
40
81
  ## Migrating To 0.2
41
82
 
@@ -44,26 +85,27 @@ Every byte-buffer API rejects inputs larger than `MAX_ENGINE_INPUT_BYTES`
44
85
  - Replace `classifyJson(text)` with `await classifyJson(bytes)`. It now returns
45
86
  `{ kind, format }` instead of a kind string.
46
87
  - If migrating code that imported `isStudyPackageText` from `@tellegen/svelte`,
47
- replace it with `(await classifyJson(bytes)).kind === "balanced-package"`,
48
- or use `await ingestJsonDrop(bytes)` when the document should also be parsed.
88
+ use `await ingestJsonDrop(bytes)`. A stored document reports `kind: "module"`;
89
+ its payload determines whether it contains a supported balanced or
90
+ multiconductor value.
49
91
  - Update `JsonDropKind` handling: `bmopf` and `pmd` are now
50
92
  `kind: "distribution"` with a `format`; `not-json` is `unknown`; and
51
93
  `transmission` and `ambiguous` are additional outcomes.
52
94
 
53
- ## Contracts
95
+ ## Generated types
54
96
 
55
- The public contract version is `CONTRACT_VERSION`, which matches the package version. `CONTRACT_SOURCE_SHA256` records the `crates/tellegen/src/api.rs` content used to generate `src/generated/contracts.ts`.
97
+ `ENGINE_VERSION` is the package version. `API_SOURCE_SHA256` records the `crates/tellegen/src/api.rs` content used to generate `src/generated/api-types.ts`.
56
98
 
57
99
  Run the generator after Rust API changes:
58
100
 
59
101
  ```sh
60
- npm run contracts
102
+ npm run types
61
103
  ```
62
104
 
63
105
  CI runs `npm run build:engine` from the repository root, and that runs
64
- `contracts:check`. A stale generated contract fails the build.
106
+ `types:check`. Stale generated types fail the build.
65
107
 
66
- Breaking contract changes:
108
+ Breaking changes to the generated types:
67
109
 
68
110
  - Removing or renaming exported request or response fields.
69
111
  - Changing field units, enum tags, formulation ids, solve status tags, or sensitivity operand/parameter shapes.
@@ -85,8 +127,17 @@ npm run build:engine
85
127
  npm run pack:engine
86
128
  ```
87
129
 
88
- The first framework release publishes this package and `@tellegen/svelte`.
89
130
  `@tellegen/engine` is the lower level browser package for custom UIs and for the
90
- Svelte package. The hosted demo under `apps/web` is private and consumes
91
- `@tellegen/svelte` through the same workspace file dependency used by the local
92
- examples.
131
+ Svelte package. It releases through Changesets with the other npm packages. The
132
+ hosted demo under `apps/web` is private and consumes `@tellegen/svelte` through
133
+ the same workspace file dependency used by the local examples.
134
+
135
+ ## Citing
136
+
137
+ If you use this package in published work, please cite the tellegen paper:
138
+ Samuel Talkington, Frederik Geth, Qian Zhang, Le Xie, and Skyler Liu. 2026.
139
+ *Interactive Power Flow in the Browser*. The Inaugural ACM Conference on Digital
140
+ Transformation (ACM DXConf 2026), Ann Arbor, MI, USA.
141
+ [doi:10.1145/3847238.3849038](https://doi.org/10.1145/3847238.3849038). The
142
+ [repository README](https://github.com/eigenergy/tellegen#citing) has the BibTeX
143
+ entry.