@swmmrs/swmmrs 0.1.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 (120) hide show
  1. package/README.md +264 -0
  2. package/dist/README.md +264 -0
  3. package/dist/serial/README.md +264 -0
  4. package/dist/serial/swmmrs.d.ts +395 -0
  5. package/dist/serial/swmmrs.js +3169 -0
  6. package/dist/serial/swmmrs_bg.wasm +0 -0
  7. package/dist/snippets/swmmrs-parallel-5d1c71108133e81d/worker-pool/browser.js +98 -0
  8. package/dist/swmmrs.d.ts +422 -0
  9. package/dist/swmmrs.js +3330 -0
  10. package/dist/swmmrs_bg.wasm +0 -0
  11. package/index.d.ts +2 -0
  12. package/index.js +2 -0
  13. package/lib/swmmrs/client.d.ts +11 -0
  14. package/lib/swmmrs/client.d.ts.map +1 -0
  15. package/lib/swmmrs/client.js +82 -0
  16. package/lib/swmmrs/client.js.map +1 -0
  17. package/lib/swmmrs/enums.d.ts +41 -0
  18. package/lib/swmmrs/enums.d.ts.map +1 -0
  19. package/lib/swmmrs/enums.js +2 -0
  20. package/lib/swmmrs/enums.js.map +1 -0
  21. package/lib/swmmrs/exceptions.d.ts +98 -0
  22. package/lib/swmmrs/exceptions.d.ts.map +1 -0
  23. package/lib/swmmrs/exceptions.js +86 -0
  24. package/lib/swmmrs/exceptions.js.map +1 -0
  25. package/lib/swmmrs/index.d.ts +27 -0
  26. package/lib/swmmrs/index.d.ts.map +1 -0
  27. package/lib/swmmrs/index.js +13 -0
  28. package/lib/swmmrs/index.js.map +1 -0
  29. package/lib/swmmrs/objects/amm.d.ts +114 -0
  30. package/lib/swmmrs/objects/amm.d.ts.map +1 -0
  31. package/lib/swmmrs/objects/amm.js +19 -0
  32. package/lib/swmmrs/objects/amm.js.map +1 -0
  33. package/lib/swmmrs/objects/collections.d.ts +109 -0
  34. package/lib/swmmrs/objects/collections.d.ts.map +1 -0
  35. package/lib/swmmrs/objects/collections.js +158 -0
  36. package/lib/swmmrs/objects/collections.js.map +1 -0
  37. package/lib/swmmrs/objects/definitions.d.ts +215 -0
  38. package/lib/swmmrs/objects/definitions.d.ts.map +1 -0
  39. package/lib/swmmrs/objects/definitions.js +69 -0
  40. package/lib/swmmrs/objects/definitions.js.map +1 -0
  41. package/lib/swmmrs/objects/lids.d.ts +446 -0
  42. package/lib/swmmrs/objects/lids.d.ts.map +1 -0
  43. package/lib/swmmrs/objects/lids.js +90 -0
  44. package/lib/swmmrs/objects/lids.js.map +1 -0
  45. package/lib/swmmrs/objects/links.d.ts +615 -0
  46. package/lib/swmmrs/objects/links.d.ts.map +1 -0
  47. package/lib/swmmrs/objects/links.js +90 -0
  48. package/lib/swmmrs/objects/links.js.map +1 -0
  49. package/lib/swmmrs/objects/nodes.d.ts +494 -0
  50. package/lib/swmmrs/objects/nodes.d.ts.map +1 -0
  51. package/lib/swmmrs/objects/nodes.js +147 -0
  52. package/lib/swmmrs/objects/nodes.js.map +1 -0
  53. package/lib/swmmrs/objects/options.d.ts +112 -0
  54. package/lib/swmmrs/objects/options.d.ts.map +1 -0
  55. package/lib/swmmrs/objects/options.js +27 -0
  56. package/lib/swmmrs/objects/options.js.map +1 -0
  57. package/lib/swmmrs/objects/rtk.d.ts +82 -0
  58. package/lib/swmmrs/objects/rtk.d.ts.map +1 -0
  59. package/lib/swmmrs/objects/rtk.js +19 -0
  60. package/lib/swmmrs/objects/rtk.js.map +1 -0
  61. package/lib/swmmrs/objects/subcatchments.d.ts +575 -0
  62. package/lib/swmmrs/objects/subcatchments.d.ts.map +1 -0
  63. package/lib/swmmrs/objects/subcatchments.js +243 -0
  64. package/lib/swmmrs/objects/subcatchments.js.map +1 -0
  65. package/lib/swmmrs/output.d.ts +412 -0
  66. package/lib/swmmrs/output.d.ts.map +1 -0
  67. package/lib/swmmrs/output.js +507 -0
  68. package/lib/swmmrs/output.js.map +1 -0
  69. package/lib/swmmrs/protocol.d.ts +80 -0
  70. package/lib/swmmrs/protocol.d.ts.map +1 -0
  71. package/lib/swmmrs/protocol.js +2 -0
  72. package/lib/swmmrs/protocol.js.map +1 -0
  73. package/lib/swmmrs/runtime.d.ts +22 -0
  74. package/lib/swmmrs/runtime.d.ts.map +1 -0
  75. package/lib/swmmrs/runtime.js +146 -0
  76. package/lib/swmmrs/runtime.js.map +1 -0
  77. package/lib/swmmrs/scenarios.d.ts +41 -0
  78. package/lib/swmmrs/scenarios.d.ts.map +1 -0
  79. package/lib/swmmrs/scenarios.js +2 -0
  80. package/lib/swmmrs/scenarios.js.map +1 -0
  81. package/lib/swmmrs/simulation.d.ts +249 -0
  82. package/lib/swmmrs/simulation.d.ts.map +1 -0
  83. package/lib/swmmrs/simulation.js +415 -0
  84. package/lib/swmmrs/simulation.js.map +1 -0
  85. package/lib/swmmrs/snapshots.d.ts +192 -0
  86. package/lib/swmmrs/snapshots.d.ts.map +1 -0
  87. package/lib/swmmrs/snapshots.js +2 -0
  88. package/lib/swmmrs/snapshots.js.map +1 -0
  89. package/lib/swmmrs/types.d.ts +123 -0
  90. package/lib/swmmrs/types.d.ts.map +1 -0
  91. package/lib/swmmrs/types.js +2 -0
  92. package/lib/swmmrs/types.js.map +1 -0
  93. package/lib/swmmrs/worker.d.ts +2 -0
  94. package/lib/swmmrs/worker.d.ts.map +1 -0
  95. package/lib/swmmrs/worker.js +488 -0
  96. package/lib/swmmrs/worker.js.map +1 -0
  97. package/package.json +33 -0
  98. package/src/swmmrs/client.ts +76 -0
  99. package/src/swmmrs/enums.ts +73 -0
  100. package/src/swmmrs/exceptions.ts +120 -0
  101. package/src/swmmrs/index.ts +79 -0
  102. package/src/swmmrs/objects/amm.ts +113 -0
  103. package/src/swmmrs/objects/collections.ts +153 -0
  104. package/src/swmmrs/objects/definitions.ts +246 -0
  105. package/src/swmmrs/objects/lids.ts +487 -0
  106. package/src/swmmrs/objects/links.ts +626 -0
  107. package/src/swmmrs/objects/nodes.ts +504 -0
  108. package/src/swmmrs/objects/options.ts +114 -0
  109. package/src/swmmrs/objects/rtk.ts +79 -0
  110. package/src/swmmrs/objects/subcatchments.ts +650 -0
  111. package/src/swmmrs/output.ts +798 -0
  112. package/src/swmmrs/protocol.ts +62 -0
  113. package/src/swmmrs/runtime.ts +188 -0
  114. package/src/swmmrs/scenarios.ts +40 -0
  115. package/src/swmmrs/simulation.ts +406 -0
  116. package/src/swmmrs/snapshots.ts +199 -0
  117. package/src/swmmrs/types.ts +123 -0
  118. package/src/swmmrs/worker.ts +233 -0
  119. package/worker-node.js +142 -0
  120. package/worker.js +1 -0
@@ -0,0 +1,264 @@
1
+ # swmmrs for JavaScript and TypeScript
2
+
3
+ `@swmmrs/swmmrs` runs SWMM in a dedicated worker from a browser or from Node.js
4
+ 22 and later. A `Simulation` owns its worker, solver state, and in-memory project
5
+ files. The package is private and is built from this repository.
6
+
7
+ See the [JavaScript / TypeScript documentation](../docs/javascript/index.md) for
8
+ usage guides and the [API reference](../docs/javascript/api/index.md) for all
9
+ public signatures. After building the package, `npm run test:docs` type-checks
10
+ the documentation examples.
11
+
12
+ ## Build the browser package
13
+
14
+ Install Node.js 22 or later, `wasm-pack`, and the Rust toolchain used by this
15
+ repository. Then run these commands in `js`:
16
+
17
+ ```sh
18
+ npm ci
19
+ npm run build
20
+ npm start
21
+ ```
22
+
23
+ Open `http://127.0.0.1:8080/`. `npm run build` and `npm run build:wasm` produce
24
+ threaded WASM in `dist/` and serial WASM with unshared memory in `dist/serial/`.
25
+ The pinned Rust nightly toolchain rebuilds the standard library for WASM threads.
26
+ `npm run build:wasm -- --dev` builds both modules without optimization, and
27
+ `npm run build:ts` rebuilds JavaScript and declarations after TypeScript changes.
28
+
29
+ Alternatively, with [Just](https://just.systems/) installed, use the shared
30
+ build recipes from the repository root:
31
+
32
+ ```sh
33
+ just js-deps
34
+ just js-debug # Debug threaded and serial WASM, then TypeScript.
35
+ just js-release # Optimized threaded and serial WASM, then TypeScript.
36
+ ```
37
+
38
+ Both profiles write to the same `js/dist/` and `js/lib/` package paths; the
39
+ latest build replaces those assets. Cargo dependencies are locked in both modes.
40
+
41
+ The package exports ES modules. Import `index.js` when serving this directory, or
42
+ install `@swmmrs/swmmrs` as a local package dependency. Node uses
43
+ `node:worker_threads`; it does not need browser isolation headers.
44
+
45
+ ## Run a model
46
+
47
+ The API accepts file contents, not host paths or URLs. Valid values are strings,
48
+ `Blob`, `ArrayBuffer`, and array-buffer views. Supporting-file keys are relative
49
+ paths from the INP.
50
+
51
+ In Node.js, read files yourself and pass the resulting bytes:
52
+
53
+ ```javascript
54
+ import { readFile } from "node:fs/promises";
55
+ import { runSwmm } from "@swmmrs/swmmrs";
56
+
57
+ const input = await readFile("model.inp");
58
+ const files = { "rain.dat": await readFile("rain.dat") };
59
+ const { report, output } = await runSwmm(input, files, { threads: 1 });
60
+ console.log(report, output.byteLength);
61
+ ```
62
+
63
+ In a browser, fetch contents or pass `File` and `Blob` values:
64
+
65
+ ```typescript
66
+ import { runSwmm } from "@swmmrs/swmmrs";
67
+
68
+ export async function runBrowserModel() {
69
+ const response = await fetch("/models/model.inp");
70
+ if (!response.ok) throw new Error(`INP request failed: ${response.status}`);
71
+ const input = await response.text();
72
+ const rainfall = await fetch("/models/rain.dat");
73
+ if (!rainfall.ok) throw new Error(`Rainfall request failed: ${rainfall.status}`);
74
+ const files = { "rain.dat": await rainfall.blob() };
75
+ return runSwmm(input, files, { threads: 1 });
76
+ }
77
+ ```
78
+
79
+ `runSwmm()` starts the model, runs it to completion, finalizes report text and
80
+ binary output, and closes the owner. Set `saveResults: false` in the third
81
+ argument when report-period binary results are not needed. The returned
82
+ `output` is then an empty `Uint8Array`; detailed report tables are not written.
83
+
84
+ ## Inspect and control a run
85
+
86
+ Use `Simulation.open()` when the application needs configuration, progress,
87
+ quality reads, statistics, or runtime controls:
88
+
89
+ ```typescript
90
+ import { Simulation, type FileContents } from "@swmmrs/swmmrs";
91
+
92
+ export async function inspectAndControl(
93
+ input: FileContents,
94
+ files: Readonly<Record<string, FileContents>> = {},
95
+ ) {
96
+ const simulation = await Simulation.open(input, files, { threads: 1 });
97
+ try {
98
+ const node = simulation.nodes.get("J1");
99
+ const link = simulation.links.get("OR1");
100
+ await node.configure({ fullDepth: 6 });
101
+ await simulation.options.update({ reportStepSeconds: 60 });
102
+
103
+ for await (const time of simulation.steps({ seconds: 60, strict: true })) {
104
+ const { depth } = await node.results();
105
+ await link.setTargetSetting(depth > 2 ? 1 : 0.25);
106
+ console.log(time, depth, (await simulation.status()).percentComplete);
107
+ }
108
+
109
+ const statistics = await simulation.statistics();
110
+ const files = await simulation.finish();
111
+ return { statistics, ...files };
112
+ } finally {
113
+ await simulation.close();
114
+ }
115
+ }
116
+ ```
117
+
118
+ `steps()` and `stride()` default to `strict: true`, so interval observations
119
+ request exact boundaries. Pass positive whole seconds. Set `strict: false`
120
+ explicitly when whole routing-step boundaries are preferred. `step()` and
121
+ `stride()` return `null` at natural completion. Collection lookup is synchronous,
122
+ but configuration, results, quality, statistics, and controls are asynchronous.
123
+ Returned records are frozen copies. Handles remain owner-bound and expose
124
+ canonical IDs; related object references are IDs, not foreign handles.
125
+
126
+ `start()`, `run()`, and `steps()` default to `saveResults: true`. `finish()` ends
127
+ the run, flushes binary output, writes requested detailed report tables when
128
+ results are enabled, finalizes the report, and retains the owner for reads or
129
+ reruns. `end()` writes summary statistics, `finalizeReport()` appends only the
130
+ runtime footer, and `report()` appends the requested detailed tables and footer.
131
+
132
+ ## Specialized configuration
133
+
134
+ Node and link handles do not have public subtype constructors. Their
135
+ configuration records carry a `kind`; link records also carry a kind-tagged
136
+ `subtype`. The package exposes sparse configuration for node, link,
137
+ subcatchment, options, aquifer, snowmelt, AMM, RTK, and LID families.
138
+
139
+ ```typescript
140
+ import { type Simulation } from "@swmmrs/swmmrs";
141
+
142
+ export async function configureSpecialized(simulation: Simulation) {
143
+ await simulation.aquifers.get("A1").configure({ waterTableElevation: 10 });
144
+ await simulation.snowmeltSets.get("Snow").configureSurface("pervious", {
145
+ baseTemperature: 0,
146
+ });
147
+ await simulation.ammModels.get("M1").configure({ hotTemperature: 30 });
148
+ await simulation.unitHydrographs.get("UH1").configure({ rainGage: "Rain" });
149
+ await simulation.replaceAmmAssignments([
150
+ { node: "J1", model: "M1", area: 1 },
151
+ ]);
152
+ await simulation.replaceRdiiAssignments([
153
+ { node: "J1", unitHydrograph: "UH1", area: 1 },
154
+ ]);
155
+ await simulation.lidControls.get("Bio").configure("surface", {
156
+ roughness: 0.1,
157
+ });
158
+ const unit = await simulation.subcatchments.get("S1").lidUnits.access(0);
159
+ await unit.configure({ count: 2 });
160
+ }
161
+ ```
162
+
163
+ Definition collections such as `timeSeries` expose read-only identity handles.
164
+ They do not provide editable time-series definitions. Change those definitions
165
+ in the INP and open a new owner. See [specialized families](../docs/javascript/api/collections.md#specialized-families).
166
+
167
+ ## Quality, statistics, and output
168
+
169
+ Use `node.quality()`, `link.quality()`, or `subcatchment.quality()` for current
170
+ pollutant values. The matching collections provide quality snapshots. Per-object
171
+ statistics and family statistics snapshots are available while the run is
172
+ `running` or `complete`. Capture `simulation.statistics()` before `finish()`
173
+ for system totals, diagnostics, continuity errors, and pollutant balances.
174
+
175
+ For report-period time series, pass finalized or valid incomplete output bytes to
176
+ the standalone `OutputReader`. It provides immutable metadata, exact-case name
177
+ selectors or integer indexes, integer or `ModelTime` half-open bounds,
178
+ `lowMemory` reads, duplicate selections, and system or family series:
179
+
180
+ ```typescript
181
+ import { OutputReader, type FileContents } from "@swmmrs/swmmrs";
182
+
183
+ export async function readOutput(output: FileContents) {
184
+ const reader = await OutputReader.open(output);
185
+ try {
186
+ return await reader.nodeSeries("J1", "invert_depth");
187
+ } finally {
188
+ await reader.close();
189
+ }
190
+ }
191
+ ```
192
+
193
+ See [binary output reader](../docs/javascript/api/output.md).
194
+
195
+ ## Lifecycle and scenarios
196
+
197
+ `resetSolver()` clears stale run and output state while retaining declarations and
198
+ returns the owner to `open`. `sleepWorkers()` asks active Dynamic Wave workers to
199
+ sleep while `running`. `terminate()` cooperatively ends an active iterator at
200
+ its next observation boundary. `run()` and `runSwmm()` are single native worker
201
+ requests with no progress callback, `AbortSignal`, or hard interrupt. `close()`
202
+ is cleanup, not interruption.
203
+
204
+ For continuation, use `saveHotstart()` and `useHotstart(bytes)` for selected EPA
205
+ `.hsf` physical state. Use `saveCheckpoint()` for a complete `CheckpointBundle`
206
+ containing a manifest and sidecar/dependency bytes, then `Simulation.resume(bundle)`
207
+ for fuller continuation. `fork()` creates an independent in-process child.
208
+ `loadCheckpointState(bundle)` loads classified warm state into an already opened
209
+ compatible receiver, which keeps its own dates, declarations, forcings,
210
+ accounting, and output history. The native checkpoint JSON alone is not a complete
211
+ JavaScript bundle. See [hotstarts, checkpoints, and forks](../docs/javascript/guides/checkpoints-and-forks.md).
212
+
213
+ ## Browser assets and threads
214
+
215
+ Serve `index.js`, `worker.js`, the generated `lib/` directory, and all of `dist/`,
216
+ including `dist/snippets/` and `dist/serial/`, from the same build. Serve `.wasm`
217
+ with `Content-Type: application/wasm`. Both WASM builds expose the same API.
218
+
219
+ Serial browser execution with `threads: 1` needs no cross-origin isolation.
220
+ Browser `threads > 1` requires these response headers and
221
+ `globalThis.crossOriginIsolated === true`:
222
+
223
+ ```text
224
+ Cross-Origin-Opener-Policy: same-origin
225
+ Cross-Origin-Embedder-Policy: require-corp
226
+ Cross-Origin-Resource-Policy: same-origin
227
+ ```
228
+
229
+ Browser defaults are `navigator.hardwareConcurrency || 1` on an isolated page and
230
+ `1` otherwise. Node defaults to `1`; explicit counts use `worker_threads` when
231
+ within host capacity. The browser setup has been tested with Chromium, not every
232
+ browser or bundler.
233
+
234
+ ## Handle errors
235
+
236
+ Native failures preserve `code`, `operation`, and partial `report` when available.
237
+ Catch `SwmmError` or a specific `SolverError`, `LifecycleError`, `ValidationError`,
238
+ `ObjectNotFoundError`, `WorkerError`, or `OutputError`. JavaScript-side type and
239
+ range failures use `TypeError` or `RangeError`. Close failed owners and open a new
240
+ one for retries.
241
+
242
+ ## Run checks
243
+
244
+ The commands below build their WASM prerequisites:
245
+
246
+ ```sh
247
+ npm run typecheck
248
+ npx playwright install chromium
249
+ npm test
250
+ npm run test:package
251
+ npm run test:docs
252
+ ```
253
+
254
+ Set `CHROMIUM_PATH` to use an installed Chromium executable. Browser tests run
255
+ WASM and include serial and parallel paths. The documentation checker type-checks
256
+ all `typescript` fences as standalone modules.
257
+
258
+ ## Find the implementation
259
+
260
+ `src/swmmrs` holds the public TypeScript API, including simulation ownership,
261
+ objects, snapshots, output, and exceptions. `protocol.ts`, `client.ts`, and
262
+ `worker.ts` are private worker plumbing. `src/native` contains Rust adapters
263
+ organized by object family. The root `index.d.ts` re-exports declarations built
264
+ from the TypeScript source.
@@ -0,0 +1,395 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+
4
+ /**
5
+ * Standalone reader owning one validated SWMM output byte buffer.
6
+ */
7
+ export class OutputReader {
8
+ free(): void;
9
+ [Symbol.dispose](): void;
10
+ /**
11
+ * Opens and validates one finalized or recoverable output byte buffer.
12
+ */
13
+ constructor(bytes: Uint8Array);
14
+ /**
15
+ * Reads one link series identified by an already-resolved index/code pair.
16
+ */
17
+ outputLinkSeries(index: number, code: number, start: number, end: number): any;
18
+ /**
19
+ * Returns immutable output metadata.
20
+ */
21
+ outputMetadata(): any;
22
+ /**
23
+ * Reads one node series identified by an already-resolved index/code pair.
24
+ */
25
+ outputNodeSeries(index: number, code: number, start: number, end: number): any;
26
+ /**
27
+ * Reads selected cells through the deduplicated adjacent-run strategy.
28
+ */
29
+ outputReadBulkSeries(selections: any, start: number, end: number): any;
30
+ /**
31
+ * Reads selected cells through one complete payload per period.
32
+ */
33
+ outputReadBulkSeriesByPeriod(selections: any, start: number, end: number): any;
34
+ /**
35
+ * Reads exact stored report-date serial values over a period range.
36
+ */
37
+ outputReadStoredDates(start: number, end: number): any;
38
+ /**
39
+ * Reads one subcatchment series identified by an already-resolved index/code pair.
40
+ */
41
+ outputSubcatchmentSeries(index: number, code: number, start: number, end: number): any;
42
+ /**
43
+ * Reads one system series identified by its stored result code.
44
+ */
45
+ outputSystemSeries(code: number, start: number, end: number): any;
46
+ }
47
+
48
+ /**
49
+ * An isolated project. Call close before freeing it to report cleanup errors.
50
+ */
51
+ export class Simulation {
52
+ free(): void;
53
+ [Symbol.dispose](): void;
54
+ ammAssignments(): any;
55
+ ammModelConfiguration(id: string): any;
56
+ aquiferConfiguration(id: string): any;
57
+ close(): void;
58
+ configureAmmModel(id: string, patch: any): void;
59
+ configureAquifer(id: string, value: any): void;
60
+ configureLidControl(id: string, layer: string, patch: any): void;
61
+ configureLidUnit(subcatchment_id: string, unit_index: number, patch: any): void;
62
+ configureLink(id: string, patch: any): void;
63
+ configureNode(id: string, patch: any): void;
64
+ configureOptions(patch: any): void;
65
+ configureSnowmelt(id: string, value: any): void;
66
+ configureSnowmeltSurface(id: string, surface: string, value: any): void;
67
+ configureSubcatchment(id: string, patch: any): void;
68
+ configureUnitHydrograph(id: string, patch: any): void;
69
+ /**
70
+ * Ends computation and flushes output and summary statistics without detailed report tables.
71
+ */
72
+ end(): void;
73
+ /**
74
+ * Publishes the complete core checkpoint and detaches it into bytes.
75
+ */
76
+ exportCheckpoint(): any;
77
+ /**
78
+ * Appends only the runtime footer to an ended run's summary report.
79
+ */
80
+ finalizeReport(): void;
81
+ /**
82
+ * Finalizes binary output, requested detailed report tables, and the runtime footer.
83
+ */
84
+ finish(): void;
85
+ /**
86
+ * Project units, object IDs, and the effective hydraulic lane count.
87
+ */
88
+ info(): any;
89
+ inletResults(id: string): any;
90
+ lidControlConfiguration(id: string): any;
91
+ lidUnitConfiguration(subcatchment_id: string, unit_index: number): any;
92
+ lidUnitCount(subcatchment_id: string): number;
93
+ lidUnitSnapshot(subcatchment_id: string, unit_index: number): any;
94
+ link(id: string): any;
95
+ linkConfiguration(id: string): any;
96
+ linkExternalPollutantMassFlux(id: string): any;
97
+ linkExternalPollutantMassFluxValue(id: string, pollutant_id: string): number;
98
+ /**
99
+ * Returns the complete optional inlet placement owned by a link.
100
+ */
101
+ linkInlet(id: string): any;
102
+ linkQuality(id: string): any;
103
+ linkQualitySnapshot(ids?: string[] | null): any;
104
+ linkStatistics(id: string): any;
105
+ linkStatisticsSnapshot(ids?: string[] | null): any;
106
+ links(ids?: string[] | null): any;
107
+ /**
108
+ * Imports only the core physical checkpoint state into this open owner.
109
+ */
110
+ loadCheckpointState(value: any): void;
111
+ maximumRoutingStepSeconds(): number;
112
+ /**
113
+ * Input and external files are bytes; external names are relative to the model.
114
+ */
115
+ constructor(input: Uint8Array, files: any);
116
+ node(id: string): any;
117
+ nodeConfiguration(id: string): any;
118
+ nodeExternalInflow(id: string): number;
119
+ nodeExternalPollutantMassFlux(id: string): any;
120
+ nodeExternalPollutantMassFluxValue(id: string, pollutant_id: string): number;
121
+ nodeQuality(id: string): any;
122
+ nodeQualitySnapshot(ids?: string[] | null): any;
123
+ nodeStatistics(id: string): any;
124
+ nodeStatisticsSnapshot(ids?: string[] | null): any;
125
+ nodeTotalInflowVolume(id: string): number;
126
+ /**
127
+ * One coherent columnar snapshot, preserving the requested ID order.
128
+ */
129
+ nodes(ids?: string[] | null): any;
130
+ options(): any;
131
+ outfallFixedStage(id: string): any;
132
+ outfallStatistics(id: string): any;
133
+ overrideLinkPollutantConcentrations(id: string, values: any): void;
134
+ overrideNodePollutantConcentrations(id: string, values: any): void;
135
+ pumpStatistics(id: string): any;
136
+ rainGage(id: string): any;
137
+ rainGageExternalPrecipitationRate(id: string): any;
138
+ rainGageRainfallOverride(id: string): any;
139
+ rdiiAssignments(): any;
140
+ /**
141
+ * Reads an input or generated file before close removes the project.
142
+ */
143
+ readFile(name: string): Uint8Array;
144
+ replaceAmmAssignments(assignments: any): void;
145
+ replaceRdiiAssignments(assignments: any): void;
146
+ /**
147
+ * Generates the requested report tables and footer on demand.
148
+ */
149
+ report(): void;
150
+ resetSolver(): void;
151
+ static resumeCheckpoint(value: any): Simulation;
152
+ /**
153
+ * Runs to completion without a worker message for every routing step.
154
+ */
155
+ run(save_results?: boolean | null): void;
156
+ /**
157
+ * Writes an EPA hotstart from the current active run and returns its bytes.
158
+ */
159
+ saveHotstart(): Uint8Array;
160
+ setLinkFlowLimit(id: string, value: any): void;
161
+ setLinkTargetSetting(id: string, setting: any): void;
162
+ setNodeExternalInflow(id: string, flow: any): void;
163
+ setOutfallStage(id: string, value: any): void;
164
+ setRainGagePrecipitation(id: string, value: any): void;
165
+ setRainGageRainfallOverride(id: string, value: any): void;
166
+ setSubcatchmentExternalRainfall(id: string, value: any): void;
167
+ setSubcatchmentExternalSnowfall(id: string, value: any): void;
168
+ setSubcatchmentPrecipitationScaleFactors(id: string, rainfall: any, snowfall: any): void;
169
+ sleepWorkers(): void;
170
+ snowmeltConfiguration(id: string): any;
171
+ snowmeltSurfaceConfiguration(id: string, surface: string): any;
172
+ start(save_results?: boolean | null): void;
173
+ statistics(): any;
174
+ /**
175
+ * Lifecycle, model-time, progress, and warning state in one owner read.
176
+ */
177
+ status(): any;
178
+ /**
179
+ * Timezone-free model timestamp, or undefined at natural completion.
180
+ */
181
+ step(): string | undefined;
182
+ storageStatistics(id: string): any;
183
+ /**
184
+ * Advances by a positive whole number of seconds.
185
+ */
186
+ stride(seconds: number, strict: boolean): string | undefined;
187
+ subcatchment(id: string): any;
188
+ subcatchmentConfiguration(id: string): any;
189
+ subcatchmentExternalForcing(id: string): any;
190
+ subcatchmentExternalPollutantBuildupIncrement(id: string): any;
191
+ subcatchmentExternalPollutantBuildupIncrementValue(id: string, pollutant_id: string): number;
192
+ subcatchmentLidSnapshot(subcatchment_id: string): any;
193
+ subcatchmentNamedSetting(id: string, kind: string, name: string): number;
194
+ subcatchmentNamedSettings(id: string, kind: string): any;
195
+ subcatchmentPrecipitationScaleFactors(id: string): any;
196
+ subcatchmentQuality(id: string): any;
197
+ subcatchmentQualitySnapshot(ids?: string[] | null): any;
198
+ subcatchmentStatistics(id: string): any;
199
+ subcatchmentStatisticsSnapshot(ids?: string[] | null): any;
200
+ subcatchments(ids?: string[] | null): any;
201
+ unitHydrographConfiguration(id: string): any;
202
+ updateInlet(id: string, patch: any): void;
203
+ updateLinkExternalPollutantMassFlux(id: string, values: any, replace: boolean): void;
204
+ updateNodeExternalPollutantMassFlux(id: string, values: any, replace: boolean): void;
205
+ updateSchedule(patch: any): void;
206
+ updateSubcatchmentExternalPollutantBuildupIncrement(id: string, values: any, replace: boolean): void;
207
+ updateSubcatchmentNamedSettings(id: string, kind: string, values: any, replace: boolean): void;
208
+ /**
209
+ * Configures or clears an EPA hotstart input from caller-owned bytes.
210
+ */
211
+ useHotstart(value: any): void;
212
+ useRainGageExternalPrecipitation(id: string, value: any): void;
213
+ readonly state: string;
214
+ }
215
+
216
+ /**
217
+ * Validates the single caller lane without creating Workers.
218
+ *
219
+ * # Arguments
220
+ * * `threads` - Requested caller-inclusive capacity, which must be one.
221
+ * * `module_url` - Generated JavaScript entry URL, unused without Workers.
222
+ *
223
+ * # Returns
224
+ * Success when the requested capacity is one.
225
+ *
226
+ * # Errors
227
+ * Rejects any capacity other than one.
228
+ */
229
+ export function initThreadPool(threads: number, module_url: string): Promise<void>;
230
+
231
+ /**
232
+ * Completes shutdown without releasing resources because no Workers exist.
233
+ *
234
+ * # Returns
235
+ * Success for every call.
236
+ */
237
+ export function terminateThreadPool(): void;
238
+
239
+ export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
240
+
241
+ export interface InitOutput {
242
+ readonly memory: WebAssembly.Memory;
243
+ readonly __wbg_simulation_free: (a: number, b: number) => void;
244
+ readonly simulation_close: (a: number, b: number) => void;
245
+ readonly simulation_end: (a: number, b: number) => void;
246
+ readonly simulation_finalizeReport: (a: number, b: number) => void;
247
+ readonly simulation_finish: (a: number, b: number) => void;
248
+ readonly simulation_info: (a: number, b: number) => void;
249
+ readonly simulation_link: (a: number, b: number, c: number, d: number) => void;
250
+ readonly simulation_links: (a: number, b: number, c: number, d: number) => void;
251
+ readonly simulation_new: (a: number, b: number, c: number, d: number) => void;
252
+ readonly simulation_node: (a: number, b: number, c: number, d: number) => void;
253
+ readonly simulation_nodes: (a: number, b: number, c: number, d: number) => void;
254
+ readonly simulation_readFile: (a: number, b: number, c: number, d: number) => void;
255
+ readonly simulation_report: (a: number, b: number) => void;
256
+ readonly simulation_resetSolver: (a: number, b: number) => void;
257
+ readonly simulation_run: (a: number, b: number, c: number) => void;
258
+ readonly simulation_setLinkTargetSetting: (a: number, b: number, c: number, d: number, e: number) => void;
259
+ readonly simulation_setNodeExternalInflow: (a: number, b: number, c: number, d: number, e: number) => void;
260
+ readonly simulation_sleepWorkers: (a: number, b: number) => void;
261
+ readonly simulation_start: (a: number, b: number, c: number) => void;
262
+ readonly simulation_state: (a: number, b: number) => void;
263
+ readonly simulation_step: (a: number, b: number) => void;
264
+ readonly simulation_stride: (a: number, b: number, c: number, d: number) => void;
265
+ readonly simulation_configureLink: (a: number, b: number, c: number, d: number, e: number) => void;
266
+ readonly simulation_inletResults: (a: number, b: number, c: number, d: number) => void;
267
+ readonly simulation_linkConfiguration: (a: number, b: number, c: number, d: number) => void;
268
+ readonly simulation_linkExternalPollutantMassFlux: (a: number, b: number, c: number, d: number) => void;
269
+ readonly simulation_linkExternalPollutantMassFluxValue: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
270
+ readonly simulation_linkInlet: (a: number, b: number, c: number, d: number) => void;
271
+ readonly simulation_linkQuality: (a: number, b: number, c: number, d: number) => void;
272
+ readonly simulation_linkQualitySnapshot: (a: number, b: number, c: number, d: number) => void;
273
+ readonly simulation_linkStatistics: (a: number, b: number, c: number, d: number) => void;
274
+ readonly simulation_linkStatisticsSnapshot: (a: number, b: number, c: number, d: number) => void;
275
+ readonly simulation_overrideLinkPollutantConcentrations: (a: number, b: number, c: number, d: number, e: number) => void;
276
+ readonly simulation_pumpStatistics: (a: number, b: number, c: number, d: number) => void;
277
+ readonly simulation_setLinkFlowLimit: (a: number, b: number, c: number, d: number, e: number) => void;
278
+ readonly simulation_updateInlet: (a: number, b: number, c: number, d: number, e: number) => void;
279
+ readonly simulation_updateLinkExternalPollutantMassFlux: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
280
+ readonly simulation_configureSubcatchment: (a: number, b: number, c: number, d: number, e: number) => void;
281
+ readonly simulation_rainGage: (a: number, b: number, c: number, d: number) => void;
282
+ readonly simulation_rainGageExternalPrecipitationRate: (a: number, b: number, c: number, d: number) => void;
283
+ readonly simulation_rainGageRainfallOverride: (a: number, b: number, c: number, d: number) => void;
284
+ readonly simulation_setRainGagePrecipitation: (a: number, b: number, c: number, d: number, e: number) => void;
285
+ readonly simulation_setRainGageRainfallOverride: (a: number, b: number, c: number, d: number, e: number) => void;
286
+ readonly simulation_setSubcatchmentExternalRainfall: (a: number, b: number, c: number, d: number, e: number) => void;
287
+ readonly simulation_setSubcatchmentExternalSnowfall: (a: number, b: number, c: number, d: number, e: number) => void;
288
+ readonly simulation_setSubcatchmentPrecipitationScaleFactors: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
289
+ readonly simulation_subcatchment: (a: number, b: number, c: number, d: number) => void;
290
+ readonly simulation_subcatchmentConfiguration: (a: number, b: number, c: number, d: number) => void;
291
+ readonly simulation_subcatchmentExternalForcing: (a: number, b: number, c: number, d: number) => void;
292
+ readonly simulation_subcatchmentExternalPollutantBuildupIncrement: (a: number, b: number, c: number, d: number) => void;
293
+ readonly simulation_subcatchmentExternalPollutantBuildupIncrementValue: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
294
+ readonly simulation_subcatchmentNamedSetting: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => void;
295
+ readonly simulation_subcatchmentNamedSettings: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
296
+ readonly simulation_subcatchmentPrecipitationScaleFactors: (a: number, b: number, c: number, d: number) => void;
297
+ readonly simulation_subcatchmentQuality: (a: number, b: number, c: number, d: number) => void;
298
+ readonly simulation_subcatchmentQualitySnapshot: (a: number, b: number, c: number, d: number) => void;
299
+ readonly simulation_subcatchmentStatistics: (a: number, b: number, c: number, d: number) => void;
300
+ readonly simulation_subcatchmentStatisticsSnapshot: (a: number, b: number, c: number, d: number) => void;
301
+ readonly simulation_subcatchments: (a: number, b: number, c: number, d: number) => void;
302
+ readonly simulation_updateSubcatchmentExternalPollutantBuildupIncrement: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
303
+ readonly simulation_updateSubcatchmentNamedSettings: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => void;
304
+ readonly simulation_useRainGageExternalPrecipitation: (a: number, b: number, c: number, d: number, e: number) => void;
305
+ readonly simulation_configureNode: (a: number, b: number, c: number, d: number, e: number) => void;
306
+ readonly simulation_nodeConfiguration: (a: number, b: number, c: number, d: number) => void;
307
+ readonly simulation_nodeExternalInflow: (a: number, b: number, c: number, d: number) => void;
308
+ readonly simulation_nodeExternalPollutantMassFlux: (a: number, b: number, c: number, d: number) => void;
309
+ readonly simulation_nodeExternalPollutantMassFluxValue: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
310
+ readonly simulation_nodeQuality: (a: number, b: number, c: number, d: number) => void;
311
+ readonly simulation_nodeQualitySnapshot: (a: number, b: number, c: number, d: number) => void;
312
+ readonly simulation_nodeStatistics: (a: number, b: number, c: number, d: number) => void;
313
+ readonly simulation_nodeStatisticsSnapshot: (a: number, b: number, c: number, d: number) => void;
314
+ readonly simulation_nodeTotalInflowVolume: (a: number, b: number, c: number, d: number) => void;
315
+ readonly simulation_outfallFixedStage: (a: number, b: number, c: number, d: number) => void;
316
+ readonly simulation_outfallStatistics: (a: number, b: number, c: number, d: number) => void;
317
+ readonly simulation_overrideNodePollutantConcentrations: (a: number, b: number, c: number, d: number, e: number) => void;
318
+ readonly simulation_setOutfallStage: (a: number, b: number, c: number, d: number, e: number) => void;
319
+ readonly simulation_storageStatistics: (a: number, b: number, c: number, d: number) => void;
320
+ readonly simulation_updateNodeExternalPollutantMassFlux: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
321
+ readonly simulation_configureLidControl: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
322
+ readonly simulation_configureLidUnit: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
323
+ readonly simulation_lidControlConfiguration: (a: number, b: number, c: number, d: number) => void;
324
+ readonly simulation_lidUnitConfiguration: (a: number, b: number, c: number, d: number, e: number) => void;
325
+ readonly simulation_lidUnitCount: (a: number, b: number, c: number, d: number) => void;
326
+ readonly simulation_lidUnitSnapshot: (a: number, b: number, c: number, d: number, e: number) => void;
327
+ readonly simulation_subcatchmentLidSnapshot: (a: number, b: number, c: number, d: number) => void;
328
+ readonly simulation_configureOptions: (a: number, b: number, c: number) => void;
329
+ readonly simulation_maximumRoutingStepSeconds: (a: number, b: number) => void;
330
+ readonly simulation_options: (a: number, b: number) => void;
331
+ readonly simulation_statistics: (a: number, b: number) => void;
332
+ readonly simulation_status: (a: number, b: number) => void;
333
+ readonly simulation_updateSchedule: (a: number, b: number, c: number) => void;
334
+ readonly __wbg_outputreader_free: (a: number, b: number) => void;
335
+ readonly outputreader_new: (a: number, b: number, c: number) => void;
336
+ readonly outputreader_outputLinkSeries: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
337
+ readonly outputreader_outputMetadata: (a: number, b: number) => void;
338
+ readonly outputreader_outputNodeSeries: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
339
+ readonly outputreader_outputReadBulkSeries: (a: number, b: number, c: number, d: number, e: number) => void;
340
+ readonly outputreader_outputReadBulkSeriesByPeriod: (a: number, b: number, c: number, d: number, e: number) => void;
341
+ readonly outputreader_outputReadStoredDates: (a: number, b: number, c: number, d: number) => void;
342
+ readonly outputreader_outputSubcatchmentSeries: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
343
+ readonly outputreader_outputSystemSeries: (a: number, b: number, c: number, d: number, e: number) => void;
344
+ readonly simulation_exportCheckpoint: (a: number, b: number) => void;
345
+ readonly simulation_loadCheckpointState: (a: number, b: number, c: number) => void;
346
+ readonly simulation_resumeCheckpoint: (a: number, b: number) => void;
347
+ readonly simulation_saveHotstart: (a: number, b: number) => void;
348
+ readonly simulation_useHotstart: (a: number, b: number, c: number) => void;
349
+ readonly simulation_ammAssignments: (a: number, b: number) => void;
350
+ readonly simulation_ammModelConfiguration: (a: number, b: number, c: number, d: number) => void;
351
+ readonly simulation_aquiferConfiguration: (a: number, b: number, c: number, d: number) => void;
352
+ readonly simulation_configureAmmModel: (a: number, b: number, c: number, d: number, e: number) => void;
353
+ readonly simulation_configureAquifer: (a: number, b: number, c: number, d: number, e: number) => void;
354
+ readonly simulation_configureSnowmelt: (a: number, b: number, c: number, d: number, e: number) => void;
355
+ readonly simulation_configureSnowmeltSurface: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
356
+ readonly simulation_configureUnitHydrograph: (a: number, b: number, c: number, d: number, e: number) => void;
357
+ readonly simulation_rdiiAssignments: (a: number, b: number) => void;
358
+ readonly simulation_replaceAmmAssignments: (a: number, b: number, c: number) => void;
359
+ readonly simulation_replaceRdiiAssignments: (a: number, b: number, c: number) => void;
360
+ readonly simulation_snowmeltConfiguration: (a: number, b: number, c: number, d: number) => void;
361
+ readonly simulation_snowmeltSurfaceConfiguration: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
362
+ readonly simulation_unitHydrographConfiguration: (a: number, b: number, c: number, d: number) => void;
363
+ readonly initThreadPool: (a: number, b: number, c: number) => number;
364
+ readonly terminateThreadPool: (a: number) => void;
365
+ readonly __wasm_bindgen_func_elem_6787: (a: number, b: number, c: number, d: number) => void;
366
+ readonly __wasm_bindgen_func_elem_6789: (a: number, b: number, c: number, d: number) => void;
367
+ readonly __wbindgen_export: (a: number, b: number) => number;
368
+ readonly __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
369
+ readonly __wbindgen_export3: (a: number) => void;
370
+ readonly __wbindgen_export4: (a: number, b: number) => void;
371
+ readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
372
+ readonly __wbindgen_export5: (a: number, b: number, c: number) => void;
373
+ }
374
+
375
+ export type SyncInitInput = BufferSource | WebAssembly.Module;
376
+
377
+ /**
378
+ * Instantiates the given `module`, which can either be bytes or
379
+ * a precompiled `WebAssembly.Module`.
380
+ *
381
+ * @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
382
+ *
383
+ * @returns {InitOutput}
384
+ */
385
+ export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
386
+
387
+ /**
388
+ * If `module_or_path` is {RequestInfo} or {URL}, makes a request and
389
+ * for everything else, calls `WebAssembly.instantiate` directly.
390
+ *
391
+ * @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
392
+ *
393
+ * @returns {Promise<InitOutput>}
394
+ */
395
+ export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;