@ohtaman/washi 0.9.0 → 0.10.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 +9 -10
- package/THIRD_PARTY_LICENSES.md +4 -4
- package/dist/{browser/washi.js → core-b430-tAc.js} +656 -661
- package/dist/solvers/browser-_washi-browser-node-runtime-BOEcR5J2.js +28 -0
- package/dist/solvers/browser-browser-worker-CT6498Is.js +13 -0
- package/dist/{lib/solvers/loader-b5PNpCmX.js → solvers/browser-loader-D21chr4P.js} +12 -23
- package/dist/{lib/solvers/loader-DCtyxsfF.js → solvers/browser-loader-DWFhT0yY.js} +13 -13
- package/dist/solvers/browser-lp-writer-DH_1sdsF.js +115 -0
- package/dist/solvers/glpk.js +310 -0
- package/dist/{lib/solvers/glpk.js → solvers/glpk.node.js} +5 -9
- package/dist/{lib/solvers/__vite-browser-external-oLchLuMx.js → solvers/highs-browser-__vite-browser-external-Cu-Zq4Hm.js} +1 -1
- package/dist/solvers/highs-browser-runtime.js +2410 -0
- package/dist/{lib/solvers → solvers}/highs-node-runtime.js +1 -1
- package/dist/{lib/solvers → solvers}/highs-worker.js +2 -2
- package/dist/{lib/solvers → solvers}/highs.js +64 -70
- package/dist/{browser/solvers/highs-loader-Csn3-0tq.js → solvers/highs.node.js} +520 -138
- package/dist/solvers/node-browser-worker-CN93BPoO.js +54 -0
- package/dist/{lib/solvers/lp-writer-CLScMFbS.js → solvers/node-lp-writer-CqMLgMIk.js} +1 -1
- package/dist/solvers/node-node-runtime-BUlNfXvx.js +10 -0
- package/dist/solvers/node-registry-CrYRRk9q.js +907 -0
- package/dist/solvers/node-types-BGqPkxwu.js +12 -0
- package/dist/{lib/solvers → solvers}/pumpkin-node-runtime.js +1 -1
- package/dist/{browser/solvers → solvers}/pumpkin-worker.js +2 -1
- package/dist/{lib/solvers → solvers}/pumpkin.js +174 -164
- package/dist/solvers/pumpkin.node.js +1228 -0
- package/dist/{lib/solvers → solvers}/z3.js +123 -120
- package/dist/types/core.d.ts +11 -0
- package/dist/types/core.d.ts.map +1 -0
- package/dist/types/index.d.ts +3 -4
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/modeler/core.d.ts +14 -0
- package/dist/types/modeler/core.d.ts.map +1 -0
- package/dist/types/modeler/index.d.ts +1 -13
- package/dist/types/modeler/index.d.ts.map +1 -1
- package/dist/types/modeler/model.d.ts +1 -1
- package/dist/types/modeler/model.d.ts.map +1 -1
- package/dist/types/modeler/solvers/browser-worker.d.ts +17 -0
- package/dist/types/modeler/solvers/browser-worker.d.ts.map +1 -0
- package/dist/types/modeler/solvers/glpk/loader.d.ts +2 -2
- package/dist/types/modeler/solvers/glpk/node-runtime.d.ts +5 -0
- package/dist/types/modeler/solvers/glpk/node-runtime.d.ts.map +1 -0
- package/dist/types/modeler/solvers/highs/worker-client.d.ts +5 -5
- package/dist/types/modeler/solvers/highs/worker-client.d.ts.map +1 -1
- package/dist/types/modeler/solvers/pumpkin/loader.d.ts +0 -4
- package/dist/types/modeler/solvers/pumpkin/loader.d.ts.map +1 -1
- package/dist/types/modeler/solvers/pumpkin/solver.d.ts.map +1 -1
- package/dist/types/modeler/solvers/pumpkin/worker-client.d.ts +4 -3
- package/dist/types/modeler/solvers/pumpkin/worker-client.d.ts.map +1 -1
- package/dist/types/modeler/solvers/types.d.ts +5 -1
- package/dist/types/modeler/solvers/types.d.ts.map +1 -1
- package/dist/types/modeler/solvers/z3/loader.d.ts +3 -8
- package/dist/types/modeler/solvers/z3/loader.d.ts.map +1 -1
- package/dist/types/modeler/solvers/z3/solver.d.ts +3 -2
- package/dist/types/modeler/solvers/z3/solver.d.ts.map +1 -1
- package/dist/types/modeler/types.d.ts +18 -3
- package/dist/types/modeler/types.d.ts.map +1 -1
- package/dist/washi.js +4 -0
- package/dist/washi.min.js +6 -0
- package/dist/washi.node.js +4 -0
- package/docs/getting-started/ai-agents.md +23 -22
- package/docs/getting-started/coding-agents.md +26 -17
- package/docs/getting-started/cross-origin.md +2 -1
- package/docs/getting-started/index.md +3 -1
- package/docs/getting-started/runtimes.md +53 -63
- package/docs/guide/objectives.md +3 -3
- package/docs/solvers/custom-solver.md +4 -9
- package/docs/solvers/glpk.md +2 -0
- package/docs/solvers/highs.md +8 -10
- package/docs/solvers/index.md +1 -1
- package/docs/solvers/pumpkin.md +7 -7
- package/docs/solvers/z3.md +18 -1
- package/llms-full.txt +124 -118
- package/llms.txt +23 -22
- package/package.json +31 -64
- package/skills/washi/SKILL.md +18 -18
- package/skills/washi/references/single-html.md +7 -12
- package/dist/browser/solvers/glpk.js +0 -1263
- package/dist/browser/solvers/glpk.min.js +0 -1
- package/dist/browser/solvers/highs-__vite-browser-external-xcxOpLMD.js +0 -7
- package/dist/browser/solvers/highs-browser-runtime-ccRmE4qj.js +0 -2021
- package/dist/browser/solvers/highs-worker.js +0 -55
- package/dist/browser/solvers/highs.js +0 -1454
- package/dist/browser/solvers/pumpkin-_washi-pumpkin-node-runtime-CEKUDK6d.js +0 -9
- package/dist/browser/solvers/pumpkin-loader-BI3n3dWO.js +0 -401
- package/dist/browser/solvers/pumpkin.js +0 -1796
- package/dist/browser/solvers/z3-built.js +0 -8245
- package/dist/browser/solvers/z3-built.wasm +0 -4
- package/dist/browser/solvers/z3.js +0 -7842
- package/dist/browser/solvers/z3.min.js +0 -5
- package/dist/browser/washi.min.js +0 -6
- package/dist/lib/solvers/highs-browser-runtime.js +0 -2413
- package/dist/lib/solvers/highs.wasm +0 -0
- package/dist/lib/solvers/highs.wasm.LICENSE +0 -21
- package/dist/lib/solvers/pumpkin-worker.js +0 -47
- package/dist/lib/solvers/pumpkin.wasm +0 -0
- package/dist/lib/solvers/pumpkin.wasm.LICENSE +0 -21
- package/dist/lib/solvers/z3-assets.js +0 -1
- package/dist/lib/solvers/z3-built.js +0 -8245
- package/dist/lib/solvers/z3-built.wasm +0 -4
- package/dist/lib/washi.js +0 -5662
- package/dist/types/modeler/solvers/z3/assets.d.ts +0 -11
- package/dist/types/modeler/solvers/z3/assets.d.ts.map +0 -1
- /package/dist/{lib/solvers/embedded-wasm-CSFlLV5N.js → solvers/browser-embedded-wasm-CSFlLV5N.js} +0 -0
- /package/dist/{lib/solvers/registry-CrYRRk9q.js → solvers/browser-registry-CrYRRk9q.js} +0 -0
- /package/dist/{lib/solvers/types-BGqPkxwu.js → solvers/browser-types-BGqPkxwu.js} +0 -0
- /package/dist/{lib/solvers → solvers}/highs-assets.js +0 -0
- /package/dist/{lib/solvers/rolldown-runtime-DtPi1Y-2.js → solvers/highs-browser-rolldown-runtime-DtPi1Y-2.js} +0 -0
- /package/dist/{browser/solvers → solvers}/highs-inline.js +0 -0
- /package/dist/{lib/solvers → solvers}/highs-runtime.js +0 -0
- /package/dist/{lib/solvers → solvers}/highs-worker-factory.js +0 -0
- /package/dist/{browser/solvers → solvers}/highs.wasm +0 -0
- /package/dist/{browser/solvers → solvers}/highs.wasm.LICENSE +0 -0
- /package/dist/{lib/solvers → solvers}/pumpkin-assets.js +0 -0
- /package/dist/{browser/solvers → solvers}/pumpkin-inline.js +0 -0
- /package/dist/{lib/solvers → solvers}/pumpkin-worker-factory.js +0 -0
- /package/dist/{browser/solvers → solvers}/pumpkin.wasm +0 -0
- /package/dist/{browser/solvers → solvers}/pumpkin.wasm.LICENSE +0 -0
package/docs/solvers/highs.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
**HiGHS** is an open-source mathematical optimization solver started at the University of Edinburgh ([highs.dev](https://highs.dev/) · [ERGO-Code/HiGHS](https://github.com/ERGO-Code/HiGHS)). It solves Linear Programming (LP), Mixed-Integer Programming (MIP), and convex Quadratic Programming (QP) problems.
|
|
4
4
|
|
|
5
|
-
In `@ohtaman/washi`, HiGHS is the built-in default solver under the MIT license. It ships as a single-threaded WebAssembly binary with zero external dependencies, runs in Node.js and
|
|
5
|
+
In `@ohtaman/washi`, HiGHS is the built-in default solver under the MIT license. It ships as a single-threaded WebAssembly binary with zero external dependencies, runs on the calling thread by default in both Node.js and browsers (with optional Web Worker execution via `useWorker: true`), and requires no `SharedArrayBuffer` or `COOP`/`COEP` headers (see [Cross-Origin Isolation](../getting-started/cross-origin.md)).
|
|
6
6
|
|
|
7
7
|
---
|
|
8
8
|
|
|
@@ -100,7 +100,7 @@ Pass execution options into `model.solve()` or the `HighsSolver` constructor. Hi
|
|
|
100
100
|
| `presolve` | `"on" \| "off" \| "choose"` | Controls model presolve before optimization. |
|
|
101
101
|
| `outputFlag` | `boolean` | Enables internal solver logs (`false` by default). |
|
|
102
102
|
| `relax` | `boolean` | Solves the continuous LP relaxation of a MIP model without modifying variable declarations. |
|
|
103
|
-
| `useWorker` | `boolean` | Runs HiGHS in a browser Web Worker
|
|
103
|
+
| `useWorker` | `boolean` | Runs HiGHS in a browser Web Worker when `true` (`false` by default in both browsers and Node.js). Passing `useWorker: true` in Node.js or environments without browser Web Workers throws an `Error`. |
|
|
104
104
|
| `wasmUrl` | `string` | Overrides the `highs.wasm` asset URL for this call (call `setHighsWasmUrl(null)` to reset to the bundled binary). |
|
|
105
105
|
| `signal` | `AbortSignal` | Cancels an in-flight solve. In a browser Web Worker, aborts preemptively and returns the last captured MIP incumbent if available; on the main thread or in Node.js, cancels cooperatively. |
|
|
106
106
|
| `onProgress` | `(ev) => void` | Receives live elapsed time, primal objective, dual bound, and gap updates. |
|
|
@@ -150,9 +150,7 @@ if (model.hasPrimalSolution) {
|
|
|
150
150
|
|
|
151
151
|
## Web Worker & WASM Configuration in Browsers
|
|
152
152
|
|
|
153
|
-
In browsers
|
|
154
|
-
|
|
155
|
-
To run on the main thread (for example, in environments that restrict Web Workers) or serve `highs.wasm` from a custom path, configure `useWorker`, `setHighsWasmUrl`, or `wasmUrl`:
|
|
153
|
+
In both browsers and Node.js, HiGHS runs on the calling thread by default (`useWorker: false`), so strict CSP (`worker-src 'none'`), `file://`, and sandboxed iframes work without configuration. To offload interactive UIs or long-running solves to a dedicated browser Web Worker (keeping UI rendering responsive and enabling immediate preemptive `AbortSignal` termination), pass `useWorker: true`, or configure `setHighsWasmUrl` / `wasmUrl` to load `highs.wasm` from a custom path:
|
|
156
154
|
|
|
157
155
|
```typescript
|
|
158
156
|
import { Model, expr, maximize } from "@ohtaman/washi";
|
|
@@ -165,18 +163,18 @@ const model = new Model({ solver: "highs" });
|
|
|
165
163
|
const x = model.continuous("x", { lb: 0, ub: 10 });
|
|
166
164
|
model.objective(maximize(expr`${x}`));
|
|
167
165
|
|
|
168
|
-
// Option 1:
|
|
169
|
-
await model.solve({ useWorker:
|
|
166
|
+
// Option 1: Enable a browser Web Worker or override wasmUrl per solve call
|
|
167
|
+
await model.solve({ useWorker: true, wasmUrl: "/assets/wasm/highs.wasm" });
|
|
170
168
|
|
|
171
169
|
// Option 2: Configure defaults on a HighsSolver instance
|
|
172
|
-
const
|
|
173
|
-
solver: new HighsSolver({ useWorker:
|
|
170
|
+
const workerModel = new Model({
|
|
171
|
+
solver: new HighsSolver({ useWorker: true }),
|
|
174
172
|
});
|
|
175
173
|
```
|
|
176
174
|
|
|
177
175
|
If `highs.wasm` fails to load or returns an HTML error page, WaSHI throws an error with the attempted URL instead of silently falling back to an external CDN.
|
|
178
176
|
|
|
179
|
-
For CSP-restricted pages where `fetch()` is blocked (`connect-src 'none'`), load the self-registering inline WASM pack (`@ohtaman/washi/
|
|
177
|
+
For CSP-restricted pages where `fetch()` is blocked (`connect-src 'none'`), load the self-registering inline WASM pack (`@ohtaman/washi/solvers/highs-inline` / `solvers/highs-inline.js`, usable via ESM `import` or a classic `<script>` tag) before the first `solve()` or `warmupHighs()` call—this works without `fetch()` (and also works with `{ useWorker: true }` if `worker-src blob:` is permitted). See [Runtime Environments & Deployment](../getting-started/runtimes.md#csp-fetch-free).
|
|
180
178
|
|
|
181
179
|
---
|
|
182
180
|
|
package/docs/solvers/index.md
CHANGED
|
@@ -10,7 +10,7 @@ WaSHI uses a pluggable solver architecture. You write a model once with the unif
|
|
|
10
10
|
| :--- | :--- | :--- | :--- | :--- |
|
|
11
11
|
| **[HiGHS](./highs.md)** | **MIT** | **LP, MIP, Convex QP** (continuous, integer, boolean) | Production optimization, operations research, portfolio QP | **Bundled default** (zero extra deps, no extra import; subpath API: `@ohtaman/washi/solvers/highs`) |
|
|
12
12
|
| **[Pumpkin](./pumpkin.md)** | **MIT** | **CP, Propositional Logic** (bounded integer & boolean only; no `Continuous`) | Non-overlapping scheduling, CP global constraints, discrete `unsatCore` | **Bundled** (`{ solver: "pumpkin" }`, zero extra deps, no extra import; subpath API: `@ohtaman/washi/solvers/pumpkin`) |
|
|
13
|
-
| **[Z3](./z3.md)** (`z3-solver`) | **MIT** | **SMT, SAT, LP/MIP** (continuous, integer, boolean) | Logical rules with continuous variables or decimal coefficients, mixed continuous/integer `unsatCore` diagnosis | **Optional peer** (`@ohtaman/washi/solvers/z3`, requires `z3-solver`); browsers require a Secure Context (`HTTPS`/`localhost`)
|
|
13
|
+
| **[Z3](./z3.md)** (`z3-solver`) | **MIT** | **SMT, SAT, LP/MIP** (continuous, integer, boolean) | Logical rules with continuous variables or decimal coefficients, mixed continuous/integer `unsatCore` diagnosis | **Optional peer** (`@ohtaman/washi/solvers/z3`, requires `z3-solver`); browsers require a Secure Context (`HTTPS`/`localhost`), `COOP`/`COEP` headers, and `registerZ3Solver({ z3JsUrl, z3WasmUrl })` |
|
|
14
14
|
| **[GLPK](./glpk.md)** (`glpk.js`) | **GPL-3.0** | **LP, MIP** (continuous, integer) | Academic benchmarks, legacy GLPK compatibility | **Optional peer** (`@ohtaman/washi/solvers/glpk`, requires `glpk.js`; note GPL-3.0 license) |
|
|
15
15
|
| **Mock** (`MockSolver`) | **MIT** | *Any* (fixed-response stub) | Fast CI unit tests without loading WebAssembly | **Built-in** (`solver: "mock"` or `new MockSolver(...)`) |
|
|
16
16
|
|
package/docs/solvers/pumpkin.md
CHANGED
|
@@ -87,7 +87,7 @@ Pass execution options into `model.solve()`, `model.check()`, or `new PumpkinSol
|
|
|
87
87
|
| Option | Type | Description |
|
|
88
88
|
| :--- | :--- | :--- |
|
|
89
89
|
| `timeLimit` | `number` | Maximum solve or check time in seconds. |
|
|
90
|
-
| `useWorker` | `boolean` | Runs Pumpkin in a browser Web Worker
|
|
90
|
+
| `useWorker` | `boolean` | Runs Pumpkin in a browser Web Worker when `true` (`false` by default in both browsers and Node.js). Passing `useWorker: true` in Node.js or environments without browser Web Workers throws an `Error`. |
|
|
91
91
|
| `wasmUrl` | `string \| null` | Overrides the `pumpkin.wasm` asset URL (`null` uses the bundled binary; call `setPumpkinWasmUrl()` to set a global URL). |
|
|
92
92
|
| `signal` | `AbortSignal` | Cancels an in-flight call. In a browser Web Worker, aborts preemptively and preserves the last captured incumbent if available; on the main thread or in Node.js, cancels cooperatively at checkpoints. |
|
|
93
93
|
| `onProgress` | `(ev) => void` | Receives live elapsed time and incumbent objective updates (`solve()` only; ignored by `check()`). |
|
|
@@ -139,9 +139,9 @@ Pumpkin solves **bounded integer and boolean** models only. Unsupported variable
|
|
|
139
139
|
|
|
140
140
|
## Browser Worker & WASM Hosting
|
|
141
141
|
|
|
142
|
-
|
|
142
|
+
In both browsers and Node.js, Pumpkin runs on the calling thread by default (`useWorker: false`), so `file://` URLs, CSP-restricted environments (`worker-src 'none'`), and sandboxed iframes work out of the box.
|
|
143
143
|
|
|
144
|
-
To
|
|
144
|
+
To offload solves to a dedicated browser Web Worker (or serve `pumpkin.wasm` from a custom URL):
|
|
145
145
|
|
|
146
146
|
```typescript
|
|
147
147
|
import { Model, expr, minimize } from "@ohtaman/washi";
|
|
@@ -154,16 +154,16 @@ const model = new Model({ solver: "pumpkin" });
|
|
|
154
154
|
const x = model.integer("x", { lb: 0, ub: 10 });
|
|
155
155
|
model.objective(minimize(expr`${x}`));
|
|
156
156
|
|
|
157
|
-
// Option 1:
|
|
158
|
-
await model.solve({ useWorker:
|
|
157
|
+
// Option 1: Opt into browser Web Worker execution for a single call
|
|
158
|
+
await model.solve({ useWorker: true });
|
|
159
159
|
|
|
160
160
|
// Option 2: Configure defaults on a PumpkinSolver instance
|
|
161
|
-
const
|
|
161
|
+
const workerModel = new Model({ solver: new PumpkinSolver({ useWorker: true }) });
|
|
162
162
|
```
|
|
163
163
|
|
|
164
164
|
If `pumpkin.wasm` fails to load or returns an HTML fallback page, WaSHI throws an error with the attempted URL instead of silently falling back to a CDN.
|
|
165
165
|
|
|
166
|
-
For CSP-restricted pages where `fetch()` is blocked (`connect-src 'none'`), load the self-registering inline WASM pack (`@ohtaman/washi/
|
|
166
|
+
For CSP-restricted pages where `fetch()` is blocked (`connect-src 'none'`), load the self-registering inline WASM pack (`@ohtaman/washi/solvers/pumpkin-inline` / `solvers/pumpkin-inline.js`, usable via ESM `import` or a classic `<script>` tag) before the first `solve()`, `check()`, or `warmupPumpkin()` call—this works without `fetch()` (and also works with `{ useWorker: true }` if `worker-src blob:` is permitted). See [Runtime Environments & Deployment](../getting-started/runtimes.md#csp-fetch-free).
|
|
167
167
|
|
|
168
168
|
---
|
|
169
169
|
|
package/docs/solvers/z3.md
CHANGED
|
@@ -87,7 +87,7 @@ Z3 validates options strictly and throws a runtime `Error` when unsupported opti
|
|
|
87
87
|
|
|
88
88
|
### Supported Options
|
|
89
89
|
|
|
90
|
-
- `z3JsUrl` / `z3WasmUrl`:
|
|
90
|
+
- `z3JsUrl` / `z3WasmUrl`: Required in browser environments unless configured via `registerZ3Solver({ z3JsUrl, z3WasmUrl })` (override per call if needed).
|
|
91
91
|
- `signal`: `AbortSignal` checked **before** Z3 starts solving (pre-solve cancellation only; it cannot interrupt an active Z3 call).
|
|
92
92
|
- `onProgress`: Applies to `solve()` only (ignored by `check()`). Invoked once after `solve()` completes with elapsed time and, when a solution exists, the final objective value.
|
|
93
93
|
|
|
@@ -107,6 +107,23 @@ In browsers, Z3 uses `SharedArrayBuffer` and Emscripten pthreads. Your page must
|
|
|
107
107
|
|
|
108
108
|
1. **Secure Context**: Served over `HTTPS` or `localhost`.
|
|
109
109
|
2. **Cross-Origin Isolation (`COOP`/`COEP`)**: Document responses must send `Cross-Origin-Opener-Policy: same-origin` and `Cross-Origin-Embedder-Policy: require-corp`.
|
|
110
|
+
3. **Explicit Asset Registration**: `@ohtaman/washi` does not bundle `z3-solver` or `z3-built.{js,wasm}`. Configure browser asset URLs once via `registerZ3Solver({ z3JsUrl, z3WasmUrl })` (Node.js requires zero configuration):
|
|
111
|
+
|
|
112
|
+
```typescript
|
|
113
|
+
import { registerZ3Solver } from "@ohtaman/washi/solvers/z3";
|
|
114
|
+
|
|
115
|
+
// Bundlers (Vite dev & build, webpack 5 — no optimizeDeps.exclude needed):
|
|
116
|
+
registerZ3Solver({
|
|
117
|
+
z3JsUrl: new URL("z3-solver/build/z3-built.js", import.meta.url).href,
|
|
118
|
+
z3WasmUrl: new URL("z3-solver/build/z3-built.wasm", import.meta.url).href,
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
// Or explicit CDN / self-hosted static URLs (pair with an Import Map for "z3-solver" if not using a bundler):
|
|
122
|
+
registerZ3Solver({
|
|
123
|
+
z3JsUrl: "https://cdn.jsdelivr.net/npm/z3-solver/build/z3-built.js",
|
|
124
|
+
z3WasmUrl: "https://cdn.jsdelivr.net/npm/z3-solver/build/z3-built.wasm",
|
|
125
|
+
});
|
|
126
|
+
```
|
|
110
127
|
|
|
111
128
|
See the [Cross-Origin Isolation Guide](../getting-started/cross-origin.md) for server setup. If you cannot configure these headers and only need bounded integers and booleans, use [Pumpkin](./pumpkin.md) instead.
|
|
112
129
|
|