@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.
- package/README.md +264 -0
- package/dist/README.md +264 -0
- package/dist/serial/README.md +264 -0
- package/dist/serial/swmmrs.d.ts +395 -0
- package/dist/serial/swmmrs.js +3169 -0
- package/dist/serial/swmmrs_bg.wasm +0 -0
- package/dist/snippets/swmmrs-parallel-5d1c71108133e81d/worker-pool/browser.js +98 -0
- package/dist/swmmrs.d.ts +422 -0
- package/dist/swmmrs.js +3330 -0
- package/dist/swmmrs_bg.wasm +0 -0
- package/index.d.ts +2 -0
- package/index.js +2 -0
- package/lib/swmmrs/client.d.ts +11 -0
- package/lib/swmmrs/client.d.ts.map +1 -0
- package/lib/swmmrs/client.js +82 -0
- package/lib/swmmrs/client.js.map +1 -0
- package/lib/swmmrs/enums.d.ts +41 -0
- package/lib/swmmrs/enums.d.ts.map +1 -0
- package/lib/swmmrs/enums.js +2 -0
- package/lib/swmmrs/enums.js.map +1 -0
- package/lib/swmmrs/exceptions.d.ts +98 -0
- package/lib/swmmrs/exceptions.d.ts.map +1 -0
- package/lib/swmmrs/exceptions.js +86 -0
- package/lib/swmmrs/exceptions.js.map +1 -0
- package/lib/swmmrs/index.d.ts +27 -0
- package/lib/swmmrs/index.d.ts.map +1 -0
- package/lib/swmmrs/index.js +13 -0
- package/lib/swmmrs/index.js.map +1 -0
- package/lib/swmmrs/objects/amm.d.ts +114 -0
- package/lib/swmmrs/objects/amm.d.ts.map +1 -0
- package/lib/swmmrs/objects/amm.js +19 -0
- package/lib/swmmrs/objects/amm.js.map +1 -0
- package/lib/swmmrs/objects/collections.d.ts +109 -0
- package/lib/swmmrs/objects/collections.d.ts.map +1 -0
- package/lib/swmmrs/objects/collections.js +158 -0
- package/lib/swmmrs/objects/collections.js.map +1 -0
- package/lib/swmmrs/objects/definitions.d.ts +215 -0
- package/lib/swmmrs/objects/definitions.d.ts.map +1 -0
- package/lib/swmmrs/objects/definitions.js +69 -0
- package/lib/swmmrs/objects/definitions.js.map +1 -0
- package/lib/swmmrs/objects/lids.d.ts +446 -0
- package/lib/swmmrs/objects/lids.d.ts.map +1 -0
- package/lib/swmmrs/objects/lids.js +90 -0
- package/lib/swmmrs/objects/lids.js.map +1 -0
- package/lib/swmmrs/objects/links.d.ts +615 -0
- package/lib/swmmrs/objects/links.d.ts.map +1 -0
- package/lib/swmmrs/objects/links.js +90 -0
- package/lib/swmmrs/objects/links.js.map +1 -0
- package/lib/swmmrs/objects/nodes.d.ts +494 -0
- package/lib/swmmrs/objects/nodes.d.ts.map +1 -0
- package/lib/swmmrs/objects/nodes.js +147 -0
- package/lib/swmmrs/objects/nodes.js.map +1 -0
- package/lib/swmmrs/objects/options.d.ts +112 -0
- package/lib/swmmrs/objects/options.d.ts.map +1 -0
- package/lib/swmmrs/objects/options.js +27 -0
- package/lib/swmmrs/objects/options.js.map +1 -0
- package/lib/swmmrs/objects/rtk.d.ts +82 -0
- package/lib/swmmrs/objects/rtk.d.ts.map +1 -0
- package/lib/swmmrs/objects/rtk.js +19 -0
- package/lib/swmmrs/objects/rtk.js.map +1 -0
- package/lib/swmmrs/objects/subcatchments.d.ts +575 -0
- package/lib/swmmrs/objects/subcatchments.d.ts.map +1 -0
- package/lib/swmmrs/objects/subcatchments.js +243 -0
- package/lib/swmmrs/objects/subcatchments.js.map +1 -0
- package/lib/swmmrs/output.d.ts +412 -0
- package/lib/swmmrs/output.d.ts.map +1 -0
- package/lib/swmmrs/output.js +507 -0
- package/lib/swmmrs/output.js.map +1 -0
- package/lib/swmmrs/protocol.d.ts +80 -0
- package/lib/swmmrs/protocol.d.ts.map +1 -0
- package/lib/swmmrs/protocol.js +2 -0
- package/lib/swmmrs/protocol.js.map +1 -0
- package/lib/swmmrs/runtime.d.ts +22 -0
- package/lib/swmmrs/runtime.d.ts.map +1 -0
- package/lib/swmmrs/runtime.js +146 -0
- package/lib/swmmrs/runtime.js.map +1 -0
- package/lib/swmmrs/scenarios.d.ts +41 -0
- package/lib/swmmrs/scenarios.d.ts.map +1 -0
- package/lib/swmmrs/scenarios.js +2 -0
- package/lib/swmmrs/scenarios.js.map +1 -0
- package/lib/swmmrs/simulation.d.ts +249 -0
- package/lib/swmmrs/simulation.d.ts.map +1 -0
- package/lib/swmmrs/simulation.js +415 -0
- package/lib/swmmrs/simulation.js.map +1 -0
- package/lib/swmmrs/snapshots.d.ts +192 -0
- package/lib/swmmrs/snapshots.d.ts.map +1 -0
- package/lib/swmmrs/snapshots.js +2 -0
- package/lib/swmmrs/snapshots.js.map +1 -0
- package/lib/swmmrs/types.d.ts +123 -0
- package/lib/swmmrs/types.d.ts.map +1 -0
- package/lib/swmmrs/types.js +2 -0
- package/lib/swmmrs/types.js.map +1 -0
- package/lib/swmmrs/worker.d.ts +2 -0
- package/lib/swmmrs/worker.d.ts.map +1 -0
- package/lib/swmmrs/worker.js +488 -0
- package/lib/swmmrs/worker.js.map +1 -0
- package/package.json +33 -0
- package/src/swmmrs/client.ts +76 -0
- package/src/swmmrs/enums.ts +73 -0
- package/src/swmmrs/exceptions.ts +120 -0
- package/src/swmmrs/index.ts +79 -0
- package/src/swmmrs/objects/amm.ts +113 -0
- package/src/swmmrs/objects/collections.ts +153 -0
- package/src/swmmrs/objects/definitions.ts +246 -0
- package/src/swmmrs/objects/lids.ts +487 -0
- package/src/swmmrs/objects/links.ts +626 -0
- package/src/swmmrs/objects/nodes.ts +504 -0
- package/src/swmmrs/objects/options.ts +114 -0
- package/src/swmmrs/objects/rtk.ts +79 -0
- package/src/swmmrs/objects/subcatchments.ts +650 -0
- package/src/swmmrs/output.ts +798 -0
- package/src/swmmrs/protocol.ts +62 -0
- package/src/swmmrs/runtime.ts +188 -0
- package/src/swmmrs/scenarios.ts +40 -0
- package/src/swmmrs/simulation.ts +406 -0
- package/src/swmmrs/snapshots.ts +199 -0
- package/src/swmmrs/types.ts +123 -0
- package/src/swmmrs/worker.ts +233 -0
- package/worker-node.js +142 -0
- package/worker.js +1 -0
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { FileContents } from "./types.js";
|
|
2
|
+
/** True when this module is running in Node rather than a browser page/worker. */
|
|
3
|
+
export declare const isNodeRuntime: boolean;
|
|
4
|
+
export interface RuntimeInfo {
|
|
5
|
+
readonly maxThreads: number;
|
|
6
|
+
readonly defaultThreads: number;
|
|
7
|
+
readonly parallel: boolean;
|
|
8
|
+
}
|
|
9
|
+
/** Return host solver capacity without requiring browser globals in Node. */
|
|
10
|
+
export declare function runtimeInfo(): Promise<RuntimeInfo>;
|
|
11
|
+
export interface WorkerCreationOptions {
|
|
12
|
+
workerUrl?: string | URL;
|
|
13
|
+
}
|
|
14
|
+
/** Convert supported model input values to bytes without requiring browser globals. */
|
|
15
|
+
export declare function bytes(value: FileContents): Promise<Uint8Array>;
|
|
16
|
+
/** Read a generated wasm file from disk in Node. Browser callers should use loadWasm. */
|
|
17
|
+
export declare function wasmInput(url: string | URL): Promise<Uint8Array>;
|
|
18
|
+
/** Initialize generated wasm with file bytes in Node and its normal URL loader in browsers. */
|
|
19
|
+
export declare function loadWasm(bindings: unknown, moduleUrl: string | URL): Promise<unknown>;
|
|
20
|
+
/** Create one isolated worker using browser Worker or node:worker_threads. */
|
|
21
|
+
export declare function createWorker(options?: WorkerCreationOptions): Promise<Worker>;
|
|
22
|
+
//# sourceMappingURL=runtime.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../src/swmmrs/runtime.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAgB/C,kFAAkF;AAClF,eAAO,MAAM,aAAa,SAA4D,CAAC;AAYvF,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;CAC5B;AAWD,6EAA6E;AAC7E,wBAAsB,WAAW,IAAI,OAAO,CAAC,WAAW,CAAC,CAQxD;AAED,MAAM,WAAW,qBAAqB;IACpC,SAAS,CAAC,EAAE,MAAM,GAAG,GAAG,CAAC;CAC1B;AAiFD,uFAAuF;AACvF,wBAAsB,KAAK,CAAC,KAAK,EAAE,YAAY,GAAG,OAAO,CAAC,UAAU,CAAC,CAMpE;AAWD,yFAAyF;AACzF,wBAAsB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,GAAG,OAAO,CAAC,UAAU,CAAC,CAKtE;AACD,+FAA+F;AAC/F,wBAAsB,QAAQ,CAAC,QAAQ,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,GAAG,GAAG,GAAG,OAAO,CAAC,OAAO,CAAC,CAI3F;AAED,8EAA8E;AAC9E,wBAAsB,YAAY,CAAC,OAAO,GAAE,qBAA0B,GAAG,OAAO,CAAC,MAAM,CAAC,CAgBvF"}
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
const encoder = new TextEncoder();
|
|
2
|
+
const runtimeGlobal = globalThis;
|
|
3
|
+
/** True when this module is running in Node rather than a browser page/worker. */
|
|
4
|
+
export const isNodeRuntime = typeof runtimeGlobal.process?.versions?.node === "string";
|
|
5
|
+
function hardwareConcurrency() {
|
|
6
|
+
const browserValue = runtimeGlobal.navigator?.hardwareConcurrency;
|
|
7
|
+
if (typeof browserValue === "number" && Number.isFinite(browserValue) && browserValue > 0)
|
|
8
|
+
return Math.floor(browserValue);
|
|
9
|
+
const os = runtimeGlobal.process?.getBuiltinModule?.("node:os");
|
|
10
|
+
const nodeValue = os?.availableParallelism?.();
|
|
11
|
+
return typeof nodeValue === "number" && Number.isFinite(nodeValue) && nodeValue > 0 ? Math.floor(nodeValue) : 1;
|
|
12
|
+
}
|
|
13
|
+
const hostThreadCapacity = hardwareConcurrency();
|
|
14
|
+
async function runtimeCapacity() {
|
|
15
|
+
if (!isNodeRuntime || runtimeGlobal.navigator?.hardwareConcurrency !== undefined || hostThreadCapacity > 1) {
|
|
16
|
+
return hostThreadCapacity;
|
|
17
|
+
}
|
|
18
|
+
const os = await dynamicImport("node:os");
|
|
19
|
+
const value = os.availableParallelism?.();
|
|
20
|
+
return typeof value === "number" && Number.isFinite(value) && value > 0 ? Math.floor(value) : hostThreadCapacity;
|
|
21
|
+
}
|
|
22
|
+
/** Return host solver capacity without requiring browser globals in Node. */
|
|
23
|
+
export async function runtimeInfo() {
|
|
24
|
+
const parallel = isNodeRuntime || Boolean(runtimeGlobal.crossOriginIsolated);
|
|
25
|
+
const maxThreads = await runtimeCapacity();
|
|
26
|
+
return {
|
|
27
|
+
maxThreads,
|
|
28
|
+
defaultThreads: isNodeRuntime ? 1 : parallel ? maxThreads : 1,
|
|
29
|
+
parallel,
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
async function dynamicImport(specifier) {
|
|
33
|
+
return import(specifier);
|
|
34
|
+
}
|
|
35
|
+
function messageError(reason) {
|
|
36
|
+
return reason instanceof Error ? reason : new Error(String(reason));
|
|
37
|
+
}
|
|
38
|
+
/** DOM-shaped adapter around node:worker_threads.Worker. */
|
|
39
|
+
class NodeWorkerAdapter {
|
|
40
|
+
#worker;
|
|
41
|
+
#terminated = false;
|
|
42
|
+
#failed = false;
|
|
43
|
+
#pendingError;
|
|
44
|
+
#onerror = null;
|
|
45
|
+
onmessage = null;
|
|
46
|
+
onmessageerror = null;
|
|
47
|
+
get onerror() {
|
|
48
|
+
return this.#onerror;
|
|
49
|
+
}
|
|
50
|
+
set onerror(handler) {
|
|
51
|
+
this.#onerror = handler;
|
|
52
|
+
const pending = this.#pendingError;
|
|
53
|
+
if (handler && pending) {
|
|
54
|
+
this.#pendingError = undefined;
|
|
55
|
+
queueMicrotask(() => handler(this.#errorEvent(pending)));
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
constructor(worker) {
|
|
59
|
+
this.#worker = worker;
|
|
60
|
+
worker.on("message", (data) => this.onmessage?.({ data }));
|
|
61
|
+
worker.on("messageerror", (error) => this.onmessageerror?.({ data: error }));
|
|
62
|
+
worker.on("error", (error) => this.#reportError(error));
|
|
63
|
+
worker.on("exit", (code) => {
|
|
64
|
+
if (!this.#terminated && code !== 0)
|
|
65
|
+
this.#reportError(new Error(`SWMM worker exited with code ${code}`));
|
|
66
|
+
else if (!this.#terminated && code === 0)
|
|
67
|
+
this.#reportError(new Error("SWMM worker exited unexpectedly"));
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
postMessage(message, transfer) {
|
|
71
|
+
this.#worker.postMessage(message, transfer);
|
|
72
|
+
}
|
|
73
|
+
terminate() {
|
|
74
|
+
this.#terminated = true;
|
|
75
|
+
void this.#worker.terminate();
|
|
76
|
+
}
|
|
77
|
+
#errorEvent(error) {
|
|
78
|
+
return { message: error.message, error, preventDefault() { } };
|
|
79
|
+
}
|
|
80
|
+
#reportError(reason) {
|
|
81
|
+
if (this.#terminated || this.#failed)
|
|
82
|
+
return;
|
|
83
|
+
this.#failed = true;
|
|
84
|
+
const error = messageError(reason);
|
|
85
|
+
if (this.#onerror)
|
|
86
|
+
this.#onerror(this.#errorEvent(error));
|
|
87
|
+
else
|
|
88
|
+
this.#pendingError = error;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
/** Convert supported model input values to bytes without requiring browser globals. */
|
|
92
|
+
export async function bytes(value) {
|
|
93
|
+
if (typeof value === "string")
|
|
94
|
+
return encoder.encode(value);
|
|
95
|
+
if (typeof Blob !== "undefined" && value instanceof Blob)
|
|
96
|
+
return new Uint8Array(await value.arrayBuffer());
|
|
97
|
+
if (value instanceof ArrayBuffer)
|
|
98
|
+
return new Uint8Array(value);
|
|
99
|
+
if (ArrayBuffer.isView(value))
|
|
100
|
+
return new Uint8Array(value.buffer, value.byteOffset, value.byteLength);
|
|
101
|
+
throw new TypeError("SWMM files must be strings, Blobs, ArrayBuffers, or typed arrays");
|
|
102
|
+
}
|
|
103
|
+
function wasmInitializer(bindings) {
|
|
104
|
+
if (!bindings || typeof bindings !== "object" || !("default" in bindings)) {
|
|
105
|
+
throw new TypeError("WASM bindings must export a default initializer");
|
|
106
|
+
}
|
|
107
|
+
const initializer = bindings.default;
|
|
108
|
+
if (typeof initializer !== "function")
|
|
109
|
+
throw new TypeError("WASM bindings must export a default initializer");
|
|
110
|
+
return initializer;
|
|
111
|
+
}
|
|
112
|
+
/** Read a generated wasm file from disk in Node. Browser callers should use loadWasm. */
|
|
113
|
+
export async function wasmInput(url) {
|
|
114
|
+
if (!isNodeRuntime)
|
|
115
|
+
throw new Error("wasmInput is only available in Node");
|
|
116
|
+
const fs = await dynamicImport("node:fs/promises");
|
|
117
|
+
const value = await fs.readFile(url);
|
|
118
|
+
return new Uint8Array(value.buffer, value.byteOffset, value.byteLength);
|
|
119
|
+
}
|
|
120
|
+
/** Initialize generated wasm with file bytes in Node and its normal URL loader in browsers. */
|
|
121
|
+
export async function loadWasm(bindings, moduleUrl) {
|
|
122
|
+
const initializer = wasmInitializer(bindings);
|
|
123
|
+
if (!isNodeRuntime)
|
|
124
|
+
return initializer();
|
|
125
|
+
return initializer({ module_or_path: await wasmInput(new URL("./swmmrs_bg.wasm", moduleUrl)) });
|
|
126
|
+
}
|
|
127
|
+
/** Create one isolated worker using browser Worker or node:worker_threads. */
|
|
128
|
+
export async function createWorker(options = {}) {
|
|
129
|
+
if (!isNodeRuntime) {
|
|
130
|
+
const WorkerConstructor = runtimeGlobal.Worker;
|
|
131
|
+
if (typeof WorkerConstructor !== "function")
|
|
132
|
+
throw new Error("SWMM needs browser workers");
|
|
133
|
+
const url = options.workerUrl ?? new URL("./worker.js", import.meta.url);
|
|
134
|
+
return new WorkerConstructor(url, { type: "module" });
|
|
135
|
+
}
|
|
136
|
+
const { Worker: NodeWorker } = await dynamicImport("node:worker_threads");
|
|
137
|
+
if (!NodeWorker)
|
|
138
|
+
throw new Error("Node worker_threads are unavailable");
|
|
139
|
+
const target = options.workerUrl ?? new URL("./worker.js", import.meta.url);
|
|
140
|
+
const bootstrap = new URL("../../worker-node.js", import.meta.url);
|
|
141
|
+
return new NodeWorkerAdapter(new NodeWorker(bootstrap, {
|
|
142
|
+
type: "module",
|
|
143
|
+
workerData: { target: target instanceof URL ? target.href : target, name: "" },
|
|
144
|
+
}));
|
|
145
|
+
}
|
|
146
|
+
//# sourceMappingURL=runtime.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime.js","sourceRoot":"","sources":["../../src/swmmrs/runtime.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,GAAG,IAAI,WAAW,EAAE,CAAC;AAYlC,MAAM,aAAa,GAAG,UAA2B,CAAC;AAElD,kFAAkF;AAClF,MAAM,CAAC,MAAM,aAAa,GAAG,OAAO,aAAa,CAAC,OAAO,EAAE,QAAQ,EAAE,IAAI,KAAK,QAAQ,CAAC;AAEvF,SAAS,mBAAmB;IAC1B,MAAM,YAAY,GAAG,aAAa,CAAC,SAAS,EAAE,mBAAmB,CAAC;IAClE,IAAI,OAAO,YAAY,KAAK,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,YAAY,CAAC,IAAI,YAAY,GAAG,CAAC;QAAE,OAAO,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;IAC3H,MAAM,EAAE,GAAG,aAAa,CAAC,OAAO,EAAE,gBAAgB,EAAE,CAAC,SAAS,CAA6B,CAAC;IAC5F,MAAM,SAAS,GAAG,EAAE,EAAE,oBAAoB,EAAE,EAAE,CAAC;IAC/C,OAAO,OAAO,SAAS,KAAK,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,SAAS,CAAC,IAAI,SAAS,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAClH,CAAC;AAED,MAAM,kBAAkB,GAAG,mBAAmB,EAAE,CAAC;AAQjD,KAAK,UAAU,eAAe;IAC5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@
|
|
|
1
|
+
import type { SimulationInfo } from "./types.js";
|
|
2
|
+
/** Transferable bytes and files captured at one quiescent simulation boundary. */
|
|
3
|
+
export interface CheckpointBundle {
|
|
4
|
+
/** Bundle format identifier. */
|
|
5
|
+
readonly format: "swmmrs.checkpoint.bundle";
|
|
6
|
+
/** Supported bundle format version. */
|
|
7
|
+
readonly version: 1;
|
|
8
|
+
/** Isolated solver root used for manifest paths; never use it as a host path. */
|
|
9
|
+
readonly root: string;
|
|
10
|
+
/** Manifest path relative to `root`. */
|
|
11
|
+
readonly manifestPath: string;
|
|
12
|
+
/** Canonical core checkpoint JSON, untouched by the binding. */
|
|
13
|
+
readonly manifest: Uint8Array;
|
|
14
|
+
/** Manifest sidecars and validated external dependencies, keyed relative to `root`. */
|
|
15
|
+
readonly files: Readonly<Record<string, Uint8Array>>;
|
|
16
|
+
}
|
|
17
|
+
type Operation<Args extends unknown[], Result> = {
|
|
18
|
+
args: Args;
|
|
19
|
+
result: Result;
|
|
20
|
+
};
|
|
21
|
+
/** Worker protocol additions for hotstarts, checkpoints, resume, and state load. */
|
|
22
|
+
export interface ScenarioOperations {
|
|
23
|
+
useHotstart: Operation<[Uint8Array | null], void>;
|
|
24
|
+
saveHotstart: Operation<[], Uint8Array>;
|
|
25
|
+
exportCheckpoint: Operation<[], CheckpointBundle>;
|
|
26
|
+
loadCheckpointState: Operation<[CheckpointBundle], void>;
|
|
27
|
+
/** The thread count is the final argument, matching the ordinary open operation. */
|
|
28
|
+
resumeCheckpoint: Operation<[CheckpointBundle, number], SimulationInfo>;
|
|
29
|
+
}
|
|
30
|
+
/** Low-level scenario operation names; prefer the methods on `Simulation` for execution. */
|
|
31
|
+
export type ScenarioMethod = keyof ScenarioOperations;
|
|
32
|
+
/** Argument tuple for a low-level scenario operation.
|
|
33
|
+
* @typeParam K - Scenario operation name.
|
|
34
|
+
*/
|
|
35
|
+
export type ScenarioArgs<K extends ScenarioMethod> = ScenarioOperations[K]["args"];
|
|
36
|
+
/** Resolved result type for a low-level scenario operation.
|
|
37
|
+
* @typeParam K - Scenario operation name.
|
|
38
|
+
*/
|
|
39
|
+
export type ScenarioResult<K extends ScenarioMethod> = ScenarioOperations[K]["result"];
|
|
40
|
+
export {};
|
|
41
|
+
//# sourceMappingURL=scenarios.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scenarios.d.ts","sourceRoot":"","sources":["../../src/swmmrs/scenarios.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEjD,kFAAkF;AAClF,MAAM,WAAW,gBAAgB;IAC/B,gCAAgC;IAChC,QAAQ,CAAC,MAAM,EAAE,0BAA0B,CAAC;IAC5C,uCAAuC;IACvC,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAC;IACpB,iFAAiF;IACjF,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,wCAAwC;IACxC,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,gEAAgE;IAChE,QAAQ,CAAC,QAAQ,EAAE,UAAU,CAAC;IAC9B,uFAAuF;IACvF,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC,CAAC;CACtD;AAED,KAAK,SAAS,CAAC,IAAI,SAAS,OAAO,EAAE,EAAE,MAAM,IAAI;IAAE,IAAI,EAAE,IAAI,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAEhF,oFAAoF;AACpF,MAAM,WAAW,kBAAkB;IACjC,WAAW,EAAE,SAAS,CAAC,CAAC,UAAU,GAAG,IAAI,CAAC,EAAE,IAAI,CAAC,CAAC;IAClD,YAAY,EAAE,SAAS,CAAC,EAAE,EAAE,UAAU,CAAC,CAAC;IACxC,gBAAgB,EAAE,SAAS,CAAC,EAAE,EAAE,gBAAgB,CAAC,CAAC;IAClD,mBAAmB,EAAE,SAAS,CAAC,CAAC,gBAAgB,CAAC,EAAE,IAAI,CAAC,CAAC;IACzD,oFAAoF;IACpF,gBAAgB,EAAE,SAAS,CAAC,CAAC,gBAAgB,EAAE,MAAM,CAAC,EAAE,cAAc,CAAC,CAAC;CACzE;AAED,4FAA4F;AAC5F,MAAM,MAAM,cAAc,GAAG,MAAM,kBAAkB,CAAC;AACtD;;GAEG;AACH,MAAM,MAAM,YAAY,CAAC,CAAC,SAAS,cAAc,IAAI,kBAAkB,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;AACnF;;GAEG;AACH,MAAM,MAAM,cAAc,CAAC,CAAC,SAAS,cAAc,IAAI,kBAAkB,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scenarios.js","sourceRoot":"","sources":["../../src/swmmrs/scenarios.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
import type { ModelTime, SimulationState } from "./enums.js";
|
|
2
|
+
import { ObjectCollection, NodeCollection, LinkCollection, SubcatchmentCollection, RainGageCollection } from "./objects/collections.js";
|
|
3
|
+
import { SimulationOptionsView, type SchedulePatch } from "./objects/options.js";
|
|
4
|
+
import { Definition, Aquifer, SnowmeltParameterSet } from "./objects/definitions.js";
|
|
5
|
+
import { AmmModel, type AmmAssignment } from "./objects/amm.js";
|
|
6
|
+
import { UnitHydrograph, type RdiiAssignment } from "./objects/rtk.js";
|
|
7
|
+
import { LidControl } from "./objects/lids.js";
|
|
8
|
+
import type { CheckpointBundle } from "./scenarios.js";
|
|
9
|
+
import type { NodeResults, LinkResults, SimulationStatistics } from "./snapshots.js";
|
|
10
|
+
import type { FileContents, SimulationOptions, RunOptions, StepOptions, SimulationInfo, SimulationStatus, RunResults } from "./types.js";
|
|
11
|
+
/**
|
|
12
|
+
* One isolated project, worker pool, and in-memory file system. Open with
|
|
13
|
+
* {@link open}, not the private constructor, and always await {@link close}.
|
|
14
|
+
* Handles and collections share this owner's lifecycle. Only one iterator or
|
|
15
|
+
* manual advancement may own the solver; result reads and allowed controls can
|
|
16
|
+
* run between observations. Records already returned remain usable after close.
|
|
17
|
+
*/
|
|
18
|
+
export declare class Simulation implements AsyncIterable<ModelTime>, AsyncDisposable {
|
|
19
|
+
#private;
|
|
20
|
+
/** Configured-order node handles and aligned snapshot reads. */
|
|
21
|
+
readonly nodes: NodeCollection;
|
|
22
|
+
/** Configured-order link handles and aligned snapshot reads. */
|
|
23
|
+
readonly links: LinkCollection;
|
|
24
|
+
/** Configured-order subcatchment handles and aligned snapshot reads. */
|
|
25
|
+
readonly subcatchments: SubcatchmentCollection;
|
|
26
|
+
/** Configured-order rain-gage handles; no collection snapshot API. */
|
|
27
|
+
readonly rainGages: RainGageCollection;
|
|
28
|
+
/** Stable model-option view, distinct from worker creation options. */
|
|
29
|
+
readonly options: SimulationOptionsView;
|
|
30
|
+
/** Pollutant identities; definition editing is not exposed. */
|
|
31
|
+
readonly pollutants: ObjectCollection<Definition>;
|
|
32
|
+
/** Land-use identities. */
|
|
33
|
+
readonly landUses: ObjectCollection<Definition>;
|
|
34
|
+
/** Time-pattern identities. */
|
|
35
|
+
readonly timePatterns: ObjectCollection<Definition>;
|
|
36
|
+
/** Curve identities. */
|
|
37
|
+
readonly curves: ObjectCollection<Definition>;
|
|
38
|
+
/** Time-series identities; data editing is not exposed. */
|
|
39
|
+
readonly timeSeries: ObjectCollection<Definition>;
|
|
40
|
+
/** Control-rule identities. */
|
|
41
|
+
readonly controls: ObjectCollection<Definition>;
|
|
42
|
+
/** Transect identities. */
|
|
43
|
+
readonly transects: ObjectCollection<Definition>;
|
|
44
|
+
/** Editable aquifer definitions. */
|
|
45
|
+
readonly aquifers: ObjectCollection<Aquifer>;
|
|
46
|
+
/** Editable snowmelt parameter sets. */
|
|
47
|
+
readonly snowmeltSets: ObjectCollection<SnowmeltParameterSet>;
|
|
48
|
+
/** Custom cross-section shape identities. */
|
|
49
|
+
readonly shapes: ObjectCollection<Definition>;
|
|
50
|
+
/** Street identities. */
|
|
51
|
+
readonly streets: ObjectCollection<Definition>;
|
|
52
|
+
/** Inlet-design identities. */
|
|
53
|
+
readonly inletDesigns: ObjectCollection<Definition>;
|
|
54
|
+
/** Editable AMM definitions; node assignments are separate. */
|
|
55
|
+
readonly ammModels: ObjectCollection<AmmModel>;
|
|
56
|
+
/** Editable RTK definitions; RDII assignments are separate. */
|
|
57
|
+
readonly unitHydrographs: ObjectCollection<UnitHydrograph>;
|
|
58
|
+
/** Editable LID-control layers; unit placements belong to subcatchments. */
|
|
59
|
+
readonly lidControls: ObjectCollection<LidControl>;
|
|
60
|
+
private constructor();
|
|
61
|
+
/** Parse an INP in a new independent worker.
|
|
62
|
+
* @param input - INP contents, never a host path.
|
|
63
|
+
* @param files - Supporting-file contents keyed by INP-relative paths; defaults to an empty record.
|
|
64
|
+
* @param options - Worker URL and thread capacity; defaults to an empty record.
|
|
65
|
+
* @returns An owner in `open`; close it when finished.
|
|
66
|
+
* @throws Rejects malformed input, invalid thread capacity, unavailable runtime prerequisites, or solver parse failures.
|
|
67
|
+
*/
|
|
68
|
+
static open(input: FileContents, files?: Readonly<Record<string, FileContents>>, options?: SimulationOptions): Promise<Simulation>;
|
|
69
|
+
/** Restore a checkpoint in an independent worker without rerunning the model.
|
|
70
|
+
* @param checkpoint - Complete bundle, including manifest sidecars and dependencies.
|
|
71
|
+
* @param options - Worker creation options (the second argument); defaults to an empty record.
|
|
72
|
+
* @returns An independent owner; no worker or mutable state is shared with the source.
|
|
73
|
+
* @throws Rejects unsupported, corrupt, mismatched, or incomplete checkpoint bundles.
|
|
74
|
+
*/
|
|
75
|
+
static resume(checkpoint: CheckpointBundle, options?: SimulationOptions): Promise<Simulation>;
|
|
76
|
+
/** Read native lifecycle state, including after cleanup.
|
|
77
|
+
* @returns The current state, or `closed` after close completes.
|
|
78
|
+
*/
|
|
79
|
+
getState(): Promise<SimulationState>;
|
|
80
|
+
/** Read model identities, units, solver build, effective threads, and schedule while healthy.
|
|
81
|
+
* @returns Detached model information.
|
|
82
|
+
*/
|
|
83
|
+
info(): Promise<SimulationInfo>;
|
|
84
|
+
/** Read lifecycle and progress before close.
|
|
85
|
+
* @returns Detached status; unavailable after cleanup.
|
|
86
|
+
*/
|
|
87
|
+
status(): Promise<SimulationStatus>;
|
|
88
|
+
/** Update calendar boundaries in `open` or `ended`; accepted edits return `ended` to `open`.
|
|
89
|
+
* @param patch - Sparse timezone-free schedule. Omitted times retain their values.
|
|
90
|
+
* @returns Resolves after the schedule update is accepted.
|
|
91
|
+
*/
|
|
92
|
+
updateSchedule(patch: SchedulePatch): Promise<void>;
|
|
93
|
+
/** Read the complete AMM node-assignment list.
|
|
94
|
+
* @returns Canonical node/model IDs and areas in project land-area units.
|
|
95
|
+
*/
|
|
96
|
+
ammAssignments(): Promise<readonly AmmAssignment[]>;
|
|
97
|
+
/** Atomically replace all AMM assignments in `open` or `ended`; accepted edits return the owner to `open`.
|
|
98
|
+
* @param assignments - Complete replacement list; an empty list clears all assignments.
|
|
99
|
+
* @returns Resolves after all assignments are accepted.
|
|
100
|
+
*/
|
|
101
|
+
replaceAmmAssignments(assignments: readonly AmmAssignment[]): Promise<void>;
|
|
102
|
+
/** Read the complete RTK RDII assignment list.
|
|
103
|
+
* @returns Canonical node/unit-hydrograph IDs and project land areas.
|
|
104
|
+
*/
|
|
105
|
+
rdiiAssignments(): Promise<readonly RdiiAssignment[]>;
|
|
106
|
+
/** Atomically replace all RTK assignments in `open` or `ended`; accepted edits return the owner to `open`.
|
|
107
|
+
* @param assignments - Complete replacement list; an empty list clears all assignments.
|
|
108
|
+
* @returns Resolves after all assignments are accepted.
|
|
109
|
+
*/
|
|
110
|
+
replaceRdiiAssignments(assignments: readonly RdiiAssignment[]): Promise<void>;
|
|
111
|
+
/** Configure hotstart input in `open` or `ended`; accepted edits return the owner to `open`.
|
|
112
|
+
* @param input - Hotstart file contents, or null to clear the configured input.
|
|
113
|
+
* @returns Resolves after the configuration write.
|
|
114
|
+
*/
|
|
115
|
+
useHotstart(input: FileContents | null): Promise<void>;
|
|
116
|
+
/** Save current hydraulic state in `running` or `complete`.
|
|
117
|
+
* @returns Caller-owned EPA hotstart bytes.
|
|
118
|
+
*/
|
|
119
|
+
saveHotstart(): Promise<Uint8Array>;
|
|
120
|
+
/** Capture a quiescent `running` or `complete` owner, including validated dependencies.
|
|
121
|
+
* @returns Complete portable checkpoint bundle with manifest sidecars.
|
|
122
|
+
*/
|
|
123
|
+
saveCheckpoint(): Promise<CheckpointBundle>;
|
|
124
|
+
/** Stage physical and numerical checkpoint state in an `open` owner.
|
|
125
|
+
* Declarations, files, and persistent forcings remain those of the receiver.
|
|
126
|
+
* @param checkpoint - Compatible bundle with all required dependencies.
|
|
127
|
+
* @returns Resolves with the owner still `open`; state is applied by its next start.
|
|
128
|
+
* @throws Rejects incompatible identity, unsupported dependencies, corrupt manifests, or missing sidecars.
|
|
129
|
+
*/
|
|
130
|
+
loadCheckpointState(checkpoint: CheckpointBundle): Promise<void>;
|
|
131
|
+
/** Save a checkpoint and resume it in a new independent owner.
|
|
132
|
+
* @param options - Worker options for the child; defaults to an empty record.
|
|
133
|
+
* @returns Independent simulation with copied run state and forcings.
|
|
134
|
+
*/
|
|
135
|
+
fork(options?: SimulationOptions): Promise<Simulation>;
|
|
136
|
+
/** Start an `open` or `ended` model.
|
|
137
|
+
* @param options - Run options; `saveResults` defaults to true.
|
|
138
|
+
* @returns Resolves after solver initialization succeeds.
|
|
139
|
+
*/
|
|
140
|
+
start({ saveResults }?: RunOptions): Promise<void>;
|
|
141
|
+
/** Advance one routing step in a started run, without an active iterator.
|
|
142
|
+
* @returns New model time, or null at natural completion.
|
|
143
|
+
*/
|
|
144
|
+
step(): Promise<ModelTime | null>;
|
|
145
|
+
/** Advance an observation interval in a started run.
|
|
146
|
+
* @param seconds - Positive 32-bit integer interval in seconds.
|
|
147
|
+
* @param strict - Defaults to true: land exactly on the boundary. False allows whole-step overshoot.
|
|
148
|
+
* @returns New model time, or null at natural completion.
|
|
149
|
+
*/
|
|
150
|
+
stride(seconds: number, strict?: boolean): Promise<ModelTime | null>;
|
|
151
|
+
/** Automatic start and routing-step advancement; exhaustion retains final statistics.
|
|
152
|
+
* @returns The same async generator as {@link steps} with default options.
|
|
153
|
+
*/
|
|
154
|
+
[Symbol.asyncIterator](): AsyncGenerator<ModelTime, void, unknown>;
|
|
155
|
+
/** Iterate observations, lazily starting `open` or `ended` owners on the first `next()`.
|
|
156
|
+
* Early exit releases advancement ownership, leaving the run available to finish or resume.
|
|
157
|
+
* @param options - Observation/run options; routing-step cadence, strict boundaries, and retained results by default.
|
|
158
|
+
* @returns Generator of observation times. Natural exhaustion leaves final statistics available.
|
|
159
|
+
* @throws Rejects invalid intervals/flags or competing advancement/finalization.
|
|
160
|
+
*/
|
|
161
|
+
steps({ seconds, strict, saveResults }?: StepOptions): AsyncGenerator<ModelTime, void, unknown>;
|
|
162
|
+
/** End active iteration at its next observation boundary, without closing the owner.
|
|
163
|
+
* @returns Immediately; the iterator performs the end operation at its next boundary.
|
|
164
|
+
* @throws Synchronously throws LifecycleError if no iterator owns advancement.
|
|
165
|
+
*/
|
|
166
|
+
terminate(): void;
|
|
167
|
+
/** Direct node result read retained for prototype callers; requires results to be available.
|
|
168
|
+
* @param id - Node ID resolved in the worker, not by a local collection lookup.
|
|
169
|
+
* @returns Detached node hydraulics; unknown IDs reject the promise.
|
|
170
|
+
*/
|
|
171
|
+
node(id: string): Promise<NodeResults>;
|
|
172
|
+
/** Direct link result read retained for prototype callers.
|
|
173
|
+
* @param id - Link ID resolved in the worker.
|
|
174
|
+
* @returns Detached link hydraulics; unknown IDs reject the promise.
|
|
175
|
+
*/
|
|
176
|
+
link(id: string): Promise<LinkResults>;
|
|
177
|
+
/** Direct equivalent of `nodes.get(id).setExternalInflow(flow)`.
|
|
178
|
+
* @param id - Node ID resolved in the worker.
|
|
179
|
+
* @param flow - Persistent additive inflow in project flow units.
|
|
180
|
+
* @returns Resolves after updating the forcing in `open`, `running`, or `ended`.
|
|
181
|
+
*/
|
|
182
|
+
setNodeExternalInflow(id: string, flow: number): Promise<void>;
|
|
183
|
+
/** Direct equivalent of `links.get(id).setTargetSetting(setting)`; requires `running`.
|
|
184
|
+
* @param id - Link ID resolved in the worker.
|
|
185
|
+
* @param setting - Dimensionless opening or pump speed factor.
|
|
186
|
+
* @returns Resolves after updating the target; unknown IDs reject the promise.
|
|
187
|
+
*/
|
|
188
|
+
setLinkTargetSetting(id: string, setting: number): Promise<void>;
|
|
189
|
+
/** Read system statistics in `running` or `complete`, before ending the run.
|
|
190
|
+
* @returns Detached cumulative totals, continuity balances, and routing diagnostics.
|
|
191
|
+
*/
|
|
192
|
+
statistics(): Promise<SimulationStatistics>;
|
|
193
|
+
/** End the run, write requested reports, and finalize binary output; safe to repeat in `ended`.
|
|
194
|
+
* Supports partial runs and retains the owner for result reads and reruns.
|
|
195
|
+
* @returns Finalized report and caller-owned output bytes; output is empty with `saveResults: false`.
|
|
196
|
+
*/
|
|
197
|
+
finish(): Promise<RunResults>;
|
|
198
|
+
/** Start, run to completion, and finalize with one worker request.
|
|
199
|
+
* @param options - Run options; `saveResults` defaults to true.
|
|
200
|
+
* @returns Finalized files, retaining the owner in `ended` until closed or reused.
|
|
201
|
+
*/
|
|
202
|
+
run({ saveResults }?: RunOptions): Promise<RunResults>;
|
|
203
|
+
/** End a `running` or `complete` run without detailed report tables.
|
|
204
|
+
* @returns Resolves after flushing output/summary statistics and entering `ended`.
|
|
205
|
+
*/
|
|
206
|
+
end(): Promise<void>;
|
|
207
|
+
/** Append and flush only the runtime footer in `ended`, once, even without saved results.
|
|
208
|
+
* JavaScript exposes this before close removes its in-memory files; Python report paths survive close.
|
|
209
|
+
* @returns Resolves after the footer is flushed, without detailed report tables.
|
|
210
|
+
*/
|
|
211
|
+
finalizeReport(): Promise<void>;
|
|
212
|
+
/** Generate requested detailed report tables and footer in `ended`, once.
|
|
213
|
+
* @returns Resolves after flushing the report.
|
|
214
|
+
* @throws Rejects when the run did not retain binary results.
|
|
215
|
+
*/
|
|
216
|
+
report(): Promise<void>;
|
|
217
|
+
/** Discard run/results/output state in `open` or `ended` without reparsing the INP.
|
|
218
|
+
* Retains declarations and persistent forcings; clears staged checkpoint state.
|
|
219
|
+
* @returns Resolves with the owner in `open`.
|
|
220
|
+
*/
|
|
221
|
+
resetSolver(): Promise<void>;
|
|
222
|
+
/** Put active Dynamic Wave workers to sleep; requires `running`.
|
|
223
|
+
* @returns Resolves after the power-state operation; lifecycle state is unchanged.
|
|
224
|
+
*/
|
|
225
|
+
sleepWorkers(): Promise<void>;
|
|
226
|
+
/** Copy a project or generated file before close; does not flush or finalize a run.
|
|
227
|
+
* @param name - Path in the worker's project file system, not a host path.
|
|
228
|
+
* @returns Caller-owned bytes. Call {@link finish} first for finalized report/output files.
|
|
229
|
+
*/
|
|
230
|
+
readFile(name: string): Promise<Uint8Array>;
|
|
231
|
+
/** Release the project, workers, and in-memory files. Repeated calls share cleanup.
|
|
232
|
+
* @returns Resolves when cleanup finishes; all owner-bound handles then become unusable.
|
|
233
|
+
*/
|
|
234
|
+
close(): Promise<void>;
|
|
235
|
+
/** Await resource cleanup for `await using`.
|
|
236
|
+
* @returns The same cleanup promise as {@link close}.
|
|
237
|
+
*/
|
|
238
|
+
[Symbol.asyncDispose](): Promise<void>;
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* Open, run, finalize, and close one INP model. Also exported as the package default.
|
|
242
|
+
* @param input - INP contents, never a host path.
|
|
243
|
+
* @param files - Supporting-file contents keyed by INP-relative paths; defaults to an empty record.
|
|
244
|
+
* @param options - Worker and run options; retained results by default.
|
|
245
|
+
* @returns Finalized report and caller-owned binary output after cleanup.
|
|
246
|
+
* @throws Preserves the run error if cleanup also fails, attaching the secondary failure as `cleanupError`.
|
|
247
|
+
*/
|
|
248
|
+
export declare function runSwmm(input: FileContents, files?: Readonly<Record<string, FileContents>>, options?: SimulationOptions & RunOptions): Promise<RunResults>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