@ohtaman/washi 0.8.2 → 0.9.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 (47) hide show
  1. package/README.md +3 -0
  2. package/dist/browser/solvers/{highs-__vite-browser-external-Dn-83hnF.js → highs-__vite-browser-external-xcxOpLMD.js} +1 -1
  3. package/dist/browser/solvers/{highs-browser-runtime-0Bgq5ksG.js → highs-browser-runtime-ccRmE4qj.js} +1 -1
  4. package/dist/browser/solvers/highs-inline.js +51 -0
  5. package/dist/{lib/solvers/loader-CDpPXN_F.js → browser/solvers/highs-loader-Csn3-0tq.js} +241 -149
  6. package/dist/browser/solvers/highs-worker.js +17 -16
  7. package/dist/browser/solvers/highs.js +295 -255
  8. package/dist/browser/solvers/pumpkin-inline.js +51 -0
  9. package/dist/{lib/solvers/loader-Ow74Fa1B.js → browser/solvers/pumpkin-loader-BI3n3dWO.js} +145 -55
  10. package/dist/browser/solvers/pumpkin-worker.js +24 -23
  11. package/dist/browser/solvers/pumpkin.js +307 -288
  12. package/dist/browser/washi.js +365 -316
  13. package/dist/browser/washi.min.js +4 -4
  14. package/dist/lib/solvers/embedded-wasm-CSFlLV5N.js +49 -0
  15. package/dist/lib/solvers/highs-node-runtime.js +1 -7
  16. package/dist/lib/solvers/highs-worker.js +19 -17
  17. package/dist/lib/solvers/highs.js +153 -112
  18. package/dist/{browser/solvers/highs-loader-BLY3wzDH.js → lib/solvers/loader-DCtyxsfF.js} +56 -36
  19. package/dist/{browser/solvers/pumpkin-loader-CvdaKxf4.js → lib/solvers/loader-b5PNpCmX.js} +58 -33
  20. package/dist/lib/solvers/pumpkin-worker.js +25 -23
  21. package/dist/lib/solvers/pumpkin.js +212 -192
  22. package/dist/lib/washi.js +365 -316
  23. package/dist/types/modeler/model.d.ts +7 -0
  24. package/dist/types/modeler/model.d.ts.map +1 -1
  25. package/dist/types/modeler/solvers/embedded-wasm.d.ts +36 -0
  26. package/dist/types/modeler/solvers/embedded-wasm.d.ts.map +1 -0
  27. package/dist/types/modeler/solvers/highs/loader.d.ts.map +1 -1
  28. package/dist/types/modeler/solvers/highs/node-runtime.d.ts.map +1 -1
  29. package/dist/types/modeler/solvers/highs/worker-client.d.ts.map +1 -1
  30. package/dist/types/modeler/solvers/inline-pack.d.ts +6 -0
  31. package/dist/types/modeler/solvers/inline-pack.d.ts.map +1 -0
  32. package/dist/types/modeler/solvers/pumpkin/loader.d.ts +1 -1
  33. package/dist/types/modeler/solvers/pumpkin/loader.d.ts.map +1 -1
  34. package/dist/types/modeler/solvers/pumpkin/solver.d.ts.map +1 -1
  35. package/dist/types/modeler/solvers/pumpkin/worker-client.d.ts.map +1 -1
  36. package/dist/types/modeler/solvers/pumpkin/worker.d.ts +1 -0
  37. package/dist/types/modeler/solvers/pumpkin/worker.d.ts.map +1 -1
  38. package/docs/getting-started/ai-agents.md +56 -1
  39. package/docs/getting-started/coding-agents.md +38 -5
  40. package/docs/getting-started/runtimes.md +63 -1
  41. package/docs/solvers/highs.md +2 -0
  42. package/docs/solvers/pumpkin.md +2 -0
  43. package/llms-full.txt +123 -2
  44. package/llms.txt +56 -1
  45. package/package.json +12 -1
  46. package/skills/washi/SKILL.md +75 -14
  47. package/skills/washi/references/single-html.md +330 -0
@@ -0,0 +1,49 @@
1
+ //#region src/modeler/solvers/embedded-wasm.ts
2
+ var e = {
3
+ highs: null,
4
+ pumpkin: null
5
+ };
6
+ function t(e) {
7
+ return e === "highs" ? "v1.16.0:d1c2cb62726e24a7:2bd77844c41e9c91" : "0.5.0:fc7ddaf3ae17fcc8:ea94cc1b794de550";
8
+ }
9
+ function n(e) {
10
+ return Symbol.for(`washi.embeddedWasm.${e}.${t(e)}`);
11
+ }
12
+ function r(e) {
13
+ return e instanceof Uint8Array || ArrayBuffer.isView(e) && Object.prototype.toString.call(e) === "[object Uint8Array]";
14
+ }
15
+ function i(e, t, n) {
16
+ if (!r(t)) throw Error(`[WaSHI] Invalid ${e} ${n}: expected Uint8Array.`);
17
+ let i = new Uint8Array(t.byteLength);
18
+ if (i.set(new Uint8Array(t.buffer, t.byteOffset, t.byteLength)), i.byteLength < 8 || i[0] !== 0 || i[1] !== 97 || i[2] !== 115 || i[3] !== 109) throw Error(`[WaSHI] Invalid ${e} ${n}: expected at least 8 bytes starting with \\0asm magic header.`);
19
+ return i;
20
+ }
21
+ function a(e) {
22
+ let r = t(e), a = n(e), o = globalThis[a];
23
+ if (o === void 0) return null;
24
+ if (typeof o != "object" || !o) throw Error(`[WaSHI] Invalid embedded WASM pack registered for ${e} (${r}).`);
25
+ let s = o;
26
+ if (s.solver !== e || s.compatId !== r || typeof s.getBytes != "function") throw Error(`[WaSHI] Invalid embedded WASM pack registered for ${e} (${r}).`);
27
+ return i(e, s.getBytes(), "embedded inline WASM binary");
28
+ }
29
+ function o(t) {
30
+ let n = e[t];
31
+ if (n !== null) return n;
32
+ let r = a(t), i = r === null ? { kind: "url" } : {
33
+ kind: "embedded",
34
+ bytes: r
35
+ };
36
+ return e[t] = i, i;
37
+ }
38
+ function s(t) {
39
+ return e[t];
40
+ }
41
+ function c(t, n) {
42
+ let r = i(t, n, "worker embedded WASM binary");
43
+ e[t] === null && (e[t] = {
44
+ kind: "embedded",
45
+ bytes: r
46
+ });
47
+ }
48
+ //#endregion
49
+ export { o as n, s as r, c as t };
@@ -12,13 +12,7 @@ export async function loadNodeHighs() {
12
12
  if (existsSync(candidate)) wasmPath = candidate;
13
13
  } catch {}
14
14
  const locateFile = (file, dir) => options.locateFile ? options.locateFile(file, dir) : (file.endsWith(".wasm") && wasmPath ? wasmPath : (dir || "") + file);
15
- const instantiateWasm = options.wasmBinary
16
- ? (imports, successCallback) => {
17
- WebAssembly.instantiate(options.wasmBinary, imports).then((res) => successCallback("instance" in res ? res.instance : res));
18
- return {};
19
- }
20
- : options.instantiateWasm;
21
- const module = await createHiGHS({ ...options, locateFile, ...(instantiateWasm ? { instantiateWasm } : {}) });
15
+ const module = await createHiGHS({ ...options, locateFile });
22
16
  return new Highs(module);
23
17
  };
24
18
  }
@@ -1,37 +1,39 @@
1
- import { s as e, t } from "./loader-CDpPXN_F.js";
1
+ import { t as e } from "./embedded-wasm-CSFlLV5N.js";
2
+ import { s as t, t as n } from "./loader-DCtyxsfF.js";
2
3
  //#region src/modeler/solvers/highs/worker.ts
3
- self.onmessage = async (n) => {
4
- let { type: r, id: i, lpString: a, options: o, reportProgress: s } = n.data;
5
- if (r === "WARMUP") {
4
+ self.onmessage = async (r) => {
5
+ let { type: i, id: a, lpString: o, options: s, reportProgress: c, embeddedWasmBinary: l } = r.data;
6
+ if (i === "WARMUP") {
6
7
  try {
7
- await t(o), self.postMessage({
8
+ l !== void 0 && e("highs", l), await n(s), self.postMessage({
8
9
  type: "WARMUP_SUCCESS",
9
- id: i
10
+ id: a
10
11
  });
11
12
  } catch (e) {
12
13
  self.postMessage({
13
14
  type: "WARMUP_ERROR",
14
- id: i,
15
+ id: a,
15
16
  error: e?.message || String(e)
16
17
  });
17
18
  }
18
19
  return;
19
20
  }
20
- if (r === "SOLVE") try {
21
- let { result: t, runTime: n } = await e(a, {
22
- ...o,
23
- ...s ? {
21
+ if (i === "SOLVE") try {
22
+ l !== void 0 && e("highs", l);
23
+ let { result: n, runTime: r } = await t(o, {
24
+ ...s,
25
+ ...c ? {
24
26
  onProgress: (e) => {
25
27
  self.postMessage({
26
28
  type: "SOLVE_PROGRESS",
27
- id: i,
29
+ id: a,
28
30
  progress: e
29
31
  });
30
32
  },
31
33
  onIncumbent: (e) => {
32
34
  self.postMessage({
33
35
  type: "SOLVE_INCUMBENT",
34
- id: i,
36
+ id: a,
35
37
  incumbent: e
36
38
  });
37
39
  }
@@ -39,14 +41,14 @@ self.onmessage = async (n) => {
39
41
  });
40
42
  self.postMessage({
41
43
  type: "SOLVE_SUCCESS",
42
- id: i,
43
- result: t,
44
- runTime: n
44
+ id: a,
45
+ result: n,
46
+ runTime: r
45
47
  });
46
48
  } catch (e) {
47
49
  self.postMessage({
48
50
  type: "SOLVE_ERROR",
49
- id: i,
51
+ id: a,
50
52
  error: e?.message || String(e)
51
53
  });
52
54
  }
@@ -1,12 +1,13 @@
1
1
  import { a as e, i as t, n, t as r } from "./registry-CrYRRk9q.js";
2
2
  import { n as i, r as a } from "./lp-writer-CLScMFbS.js";
3
- import { a as o, c as s, d as c, f as l, h as u, i as d, l as f, m as p, n as m, o as h, p as g, r as _, s as v, t as y, u as b } from "./loader-CDpPXN_F.js";
4
- import { createHighsWorker as x } from "./highs-worker-factory.js";
3
+ import { n as o, r as s } from "./embedded-wasm-CSFlLV5N.js";
4
+ import { a as c, c as l, d as u, f as d, h as f, i as p, l as m, m as h, n as g, o as _, p as v, r as y, s as b, t as x, u as S } from "./loader-DCtyxsfF.js";
5
+ import { createHighsWorker as C } from "./highs-worker-factory.js";
5
6
  export * from "./highs-assets.js";
6
7
  export * from "./highs-worker-factory.js";
7
8
  //#region src/modeler/solvers/highs/worker-client.ts
8
- var S = null, C = null, w = null, T = 0, E = /* @__PURE__ */ new Map();
9
- function D(e, t) {
9
+ var w = null, T = null, E = null, D = !1, O = 0, k = /* @__PURE__ */ new Map();
10
+ function A(e, t) {
10
11
  return e ? {
11
12
  Status: "Interrupted",
12
13
  StatusCode: 17,
@@ -30,52 +31,55 @@ function D(e, t) {
30
31
  Rows: []
31
32
  };
32
33
  }
33
- function O(e) {
34
- let t = E.values().next().value;
35
- if (t && !t.dispatched) {
36
- t.dispatched = !0;
37
- try {
38
- t.kind === "WARMUP" ? e.postMessage({
39
- type: "WARMUP",
40
- id: t.id,
41
- options: t.workerOptions
42
- }) : e.postMessage({
43
- type: "SOLVE",
44
- id: t.id,
45
- lpString: t.lpString,
46
- options: t.workerOptions,
47
- ...t.reportProgress ? { reportProgress: !0 } : {}
48
- });
49
- } catch (n) {
50
- E.delete(t.id), t.cleanupAbort?.(), t.reject(n), O(e);
51
- }
34
+ function j(e) {
35
+ let t = k.values().next().value;
36
+ if (!t || t.dispatched) return;
37
+ t.dispatched = !0;
38
+ let n = {}, r = !1;
39
+ t.embeddedWasmBinary !== null && !D && (n.embeddedWasmBinary = t.embeddedWasmBinary, r = !0);
40
+ try {
41
+ t.kind === "WARMUP" ? e.postMessage({
42
+ type: "WARMUP",
43
+ id: t.id,
44
+ options: t.workerOptions,
45
+ ...n
46
+ }) : e.postMessage({
47
+ type: "SOLVE",
48
+ id: t.id,
49
+ lpString: t.lpString,
50
+ options: t.workerOptions,
51
+ ...n,
52
+ ...t.reportProgress ? { reportProgress: !0 } : {}
53
+ }), r && (D = !0);
54
+ } catch (n) {
55
+ k.delete(t.id), t.cleanupAbort?.(), t.reject(n), j(e);
52
56
  }
53
57
  }
54
- function k() {
55
- let e = S;
56
- e && (S = null, C = null, w = null, e.terminate());
57
- for (let e of E.values()) e.dispatched = !1;
58
- if (E.size > 0) try {
59
- let e = j();
60
- if (e) O(e);
58
+ function M() {
59
+ let e = w;
60
+ e && (w = null, T = null, E = null, D = !1, e.terminate());
61
+ for (let e of k.values()) e.dispatched = !1;
62
+ if (k.size > 0) try {
63
+ let e = P();
64
+ if (e) j(e);
61
65
  else {
62
66
  let e = /* @__PURE__ */ Error("[WaSHI] Failed to recreate HiGHS Worker after interruption.");
63
- for (let t of Array.from(E.values())) E.delete(t.id), t.cleanupAbort?.(), t.reject(e);
67
+ for (let t of Array.from(k.values())) k.delete(t.id), t.cleanupAbort?.(), t.reject(e);
64
68
  }
65
69
  } catch (e) {
66
- for (let t of Array.from(E.values())) E.delete(t.id), t.cleanupAbort?.(), t.reject(e);
70
+ for (let t of Array.from(k.values())) k.delete(t.id), t.cleanupAbort?.(), t.reject(e);
67
71
  }
68
72
  }
69
- function A() {
73
+ function N() {
70
74
  return typeof window < "u" && typeof Worker < "u" && typeof Worker?.prototype?.unref != "function";
71
75
  }
72
- function j() {
73
- if (!A()) return null;
74
- if (!S) {
76
+ function P() {
77
+ if (!N()) return null;
78
+ if (!w) {
75
79
  let e;
76
80
  try {
77
- e = x(), e.onmessage = (t) => {
78
- let { type: n, id: r, result: i, runTime: a, error: o, progress: s, incumbent: c } = t.data, l = E.get(r);
81
+ e = C(), e.onmessage = (t) => {
82
+ let { type: n, id: r, result: i, runTime: a, error: o, progress: s, incumbent: c } = t.data, l = k.get(r);
79
83
  if (l) {
80
84
  if (n === "SOLVE_PROGRESS") {
81
85
  if (l.kind === "SOLVE" && s) {
@@ -83,10 +87,10 @@ function j() {
83
87
  try {
84
88
  l.onProgress?.(s);
85
89
  } catch (e) {
86
- let t = E.get(r);
90
+ let t = k.get(r);
87
91
  if (t) {
88
- let n = E.keys().next().value;
89
- E.delete(r), t.cleanupAbort?.(), n === r && k(), t.reject(e);
92
+ let n = k.keys().next().value;
93
+ k.delete(r), t.cleanupAbort?.(), n === r && M(), t.reject(e);
90
94
  }
91
95
  }
92
96
  }
@@ -96,131 +100,168 @@ function j() {
96
100
  l.kind === "SOLVE" && c && (l.lastIncumbent = c);
97
101
  return;
98
102
  }
99
- E.delete(r), l.cleanupAbort?.(), l.kind === "WARMUP" ? n === "WARMUP_SUCCESS" ? (S === e && (C = e, w = l.wasmUrl), l.resolve()) : l.reject(Error(o || "Worker warmup failed")) : n === "SOLVE_SUCCESS" ? (S === e && (C = e, w = l.wasmUrl), l.resolve({
103
+ k.delete(r), l.cleanupAbort?.(), l.kind === "WARMUP" ? n === "WARMUP_SUCCESS" ? (w === e && (T = e, E = l.targetKey), l.resolve()) : l.reject(Error(o || "Worker warmup failed")) : n === "SOLVE_SUCCESS" ? (w === e && (T = e, E = l.targetKey), l.resolve({
100
104
  result: i,
101
105
  runTime: a
102
- })) : l.reject(Error(o || "Worker solve failed")), S === e && O(e);
106
+ })) : l.reject(Error(o || "Worker solve failed")), w === e && j(e);
103
107
  }
104
108
  };
105
109
  let t = (t) => {
106
- if (S === e) {
107
- S = null, C = null, w = null, e.terminate();
108
- for (let e of E.values()) e.cleanupAbort?.(), e.reject(t);
109
- E.clear();
110
+ if (w === e) {
111
+ w = null, T = null, E = null, D = !1, e.terminate();
112
+ for (let e of k.values()) e.cleanupAbort?.(), e.reject(t);
113
+ k.clear();
110
114
  }
111
115
  };
112
- e.onerror = (e) => t(/* @__PURE__ */ Error(`[WaSHI] HiGHS Worker failed to load or execute. Check Worker assets, CORS and CSP. ${e?.message || ""}`)), e.onmessageerror = () => t(/* @__PURE__ */ Error("[WaSHI] Could not deserialize the HiGHS Worker response.")), S = e;
116
+ e.onerror = (e) => t(/* @__PURE__ */ Error(`[WaSHI] HiGHS Worker failed to load or execute. Check Worker assets, CORS and CSP. ${e?.message || ""}`)), e.onmessageerror = () => t(/* @__PURE__ */ Error("[WaSHI] Could not deserialize the HiGHS Worker response.")), w = e;
113
117
  } catch (e) {
114
- throw S = null, e;
118
+ throw w = null, e;
115
119
  }
116
120
  }
117
- return S;
121
+ return w;
118
122
  }
119
- function M(e) {
123
+ function F(e) {
120
124
  let t = typeof window < "u" ? typeof window.origin == "string" ? window.origin : window.location?.origin : void 0;
121
125
  return e.useWorker ?? (typeof window < "u" && t !== "null" && !t?.startsWith("file:"));
122
126
  }
123
- function N(e) {
124
- if (e.useWorker === !0 && !A()) throw Error("[WaSHI] Web Worker execution was requested (useWorker: true), but browser Web Workers are unavailable in this environment.");
125
- return M(e) ? j() : null;
127
+ function I(e) {
128
+ if (e.useWorker === !0 && !N()) throw Error("[WaSHI] Web Worker execution was requested (useWorker: true), but browser Web Workers are unavailable in this environment.");
129
+ return F(e) ? P() : null;
126
130
  }
127
- function P(e, t) {
131
+ async function L(e, t) {
132
+ let n = t ? o("highs") : s("highs"), r = n?.kind === "embedded" ? n.bytes : null;
133
+ if (e.wasmUrl) {
134
+ let t = await c(e.wasmUrl);
135
+ return {
136
+ wasmUrl: t,
137
+ embeddedWasmBinary: r,
138
+ targetKey: `url:${t}`
139
+ };
140
+ }
141
+ if (g()) {
142
+ let e = await c();
143
+ return {
144
+ wasmUrl: e,
145
+ embeddedWasmBinary: r,
146
+ targetKey: `url:${e}`
147
+ };
148
+ }
149
+ if (!n) return {
150
+ wasmUrl: null,
151
+ embeddedWasmBinary: null,
152
+ targetKey: null
153
+ };
154
+ if (n.kind === "embedded") return {
155
+ wasmUrl: null,
156
+ embeddedWasmBinary: r,
157
+ targetKey: "__embedded__"
158
+ };
159
+ let i = await c();
160
+ return {
161
+ wasmUrl: i,
162
+ embeddedWasmBinary: null,
163
+ targetKey: `url:${i}`
164
+ };
165
+ }
166
+ function R(e, t) {
128
167
  let { signal: n, onProgress: r, onIncumbent: i, ...a } = e, o = {};
129
168
  for (let [e, t] of Object.entries(a)) {
130
169
  if (typeof t == "function") throw Error(`[WaSHI] HiGHS Worker option "${e}" cannot be a function (functions cannot be cloned across Web Worker boundaries).`);
131
170
  o[e] = t;
132
171
  }
133
- return o.wasmUrl = t, o;
172
+ return t === null ? delete o.wasmUrl : o.wasmUrl = t, o;
134
173
  }
135
- async function F(e = {}) {
136
- if (e.useWorker === !0 && !A()) return !1;
137
- if (!M(e) || !A()) return _(e);
138
- if (!S || !C || C !== S) return !1;
139
- let t = await o(e.wasmUrl);
140
- return w === t;
174
+ async function z(e = {}) {
175
+ if (e.useWorker === !0 && !N()) return !1;
176
+ if (!F(e) || !N()) return y(e);
177
+ if (!w || !T || T !== w) return !1;
178
+ let { targetKey: t } = await L(e, !1);
179
+ return t !== null && E === t;
141
180
  }
142
- function I(e, t, n) {
181
+ function B(e, t, n) {
143
182
  if (!e) return;
144
183
  let r = () => {
145
- let e = E.get(t.id);
184
+ let e = k.get(t.id);
146
185
  if (!e) return;
147
- let r = E.keys().next().value;
148
- E.delete(t.id), e.cleanupAbort?.(), r === t.id && k(), n();
186
+ let r = k.keys().next().value;
187
+ k.delete(t.id), e.cleanupAbort?.(), r === t.id && M(), n();
149
188
  };
150
189
  e.addEventListener("abort", r, { once: !0 }), t.cleanupAbort = () => e.removeEventListener("abort", r);
151
190
  }
152
- async function L(e = {}) {
153
- s(e);
191
+ async function V(e = {}) {
192
+ l(e);
154
193
  let { signal: t } = e;
155
194
  if (t?.aborted) return { cached: !1 };
156
- let n = await o(e.wasmUrl);
195
+ let n = await L(e, !0);
157
196
  if (t?.aborted) return { cached: !1 };
158
- let r = N(e);
197
+ let r = I(e);
159
198
  if (!r) {
160
- let n = await _(e);
199
+ let n = await y(e);
161
200
  return n || t?.aborted ? { cached: n } : t ? (await new Promise((n, r) => {
162
201
  let i = !1, a = () => {
163
202
  i || (i = !0, n());
164
203
  };
165
- t.addEventListener("abort", a, { once: !0 }), y(e).then(() => {
204
+ t.addEventListener("abort", a, { once: !0 }), x(e).then(() => {
166
205
  t.removeEventListener("abort", a), i || (i = !0, n());
167
206
  }, (e) => {
168
207
  t.removeEventListener("abort", a), i || (i = !0, r(e));
169
208
  });
170
- }), { cached: n }) : (await y(e), { cached: n });
209
+ }), { cached: n }) : (await x(e), { cached: n });
171
210
  }
172
- if (C === r && w === n) return { cached: !0 };
173
- let i = P(e, n), a = `req_${++T}`;
211
+ if (T === r && E === n.targetKey) return { cached: !0 };
212
+ let i = R(e, n.wasmUrl), a = `req_${++O}`;
174
213
  return await new Promise((e, o) => {
175
214
  let s = {
176
215
  kind: "WARMUP",
177
216
  id: a,
178
217
  workerOptions: i,
179
- wasmUrl: n,
218
+ embeddedWasmBinary: n.embeddedWasmBinary,
219
+ targetKey: n.targetKey,
180
220
  resolve: e,
181
221
  reject: o
182
222
  };
183
- I(t, s, e), E.set(a, s), O(r);
223
+ B(t, s, e), k.set(a, s), j(r);
184
224
  }), { cached: !1 };
185
225
  }
186
- async function R(e, t = {}) {
187
- if (s(t), t.signal?.aborted) return {
188
- result: D(),
226
+ async function H(e, t = {}) {
227
+ if (l(t), t.signal?.aborted) return {
228
+ result: A(),
189
229
  runTime: 0
190
230
  };
191
- let n = await o(t.wasmUrl);
231
+ let n = await L(t, !0);
192
232
  if (t.signal?.aborted) return {
193
- result: D(),
233
+ result: A(),
194
234
  runTime: 0
195
235
  };
196
- let r = N(t);
197
- if (!r) return v(e, t);
198
- let { signal: i, onProgress: a } = t, c = P(t, n), l = !!(a || i), u = `req_${++T}`, d = performance.now();
199
- return new Promise((t, o) => {
200
- let s = {
236
+ let r = I(t);
237
+ if (!r) return b(e, t);
238
+ let { signal: i, onProgress: a } = t, o = R(t, n.wasmUrl), s = !!(a || i), c = `req_${++O}`, u = performance.now();
239
+ return new Promise((t, l) => {
240
+ let d = {
201
241
  kind: "SOLVE",
202
- id: u,
242
+ id: c,
203
243
  lpString: e,
204
- workerOptions: c,
205
- wasmUrl: n,
206
- reportProgress: l,
207
- startTime: d,
244
+ workerOptions: o,
245
+ embeddedWasmBinary: n.embeddedWasmBinary,
246
+ targetKey: n.targetKey,
247
+ reportProgress: s,
248
+ startTime: u,
208
249
  onProgress: a,
209
250
  resolve: t,
210
- reject: o
251
+ reject: l
211
252
  };
212
- I(i, s, () => {
213
- let e = (performance.now() - s.startTime) / 1e3;
214
- s.resolve({
215
- result: D(s.lastIncumbent, s.lastProgress),
253
+ B(i, d, () => {
254
+ let e = (performance.now() - d.startTime) / 1e3;
255
+ d.resolve({
256
+ result: A(d.lastIncumbent, d.lastProgress),
216
257
  runTime: e
217
258
  });
218
- }), E.set(u, s), O(r);
259
+ }), k.set(c, d), j(r);
219
260
  });
220
261
  }
221
262
  //#endregion
222
263
  //#region src/modeler/solvers/highs/solver.ts
223
- function z(e, t) {
264
+ function U(e, t) {
224
265
  if (typeof t == "number") switch (t) {
225
266
  case 0: return "NotSolved";
226
267
  case 1:
@@ -278,8 +319,8 @@ function z(e, t) {
278
319
  }
279
320
  return "Unknown";
280
321
  }
281
- function B(e, t, n) {
282
- switch (z(e, t)) {
322
+ function W(e, t, n) {
323
+ switch (U(e, t)) {
283
324
  case "Optimal": return "Optimal";
284
325
  case "Infeasible": return "Infeasible";
285
326
  case "Unbounded": return "Unbounded";
@@ -296,7 +337,7 @@ function B(e, t, n) {
296
337
  default: return "Unknown";
297
338
  }
298
339
  }
299
- var V = class n {
340
+ var G = class n {
300
341
  static capabilities = {
301
342
  supportsMIP: !0,
302
343
  supportsQP: !0,
@@ -310,16 +351,16 @@ var V = class n {
310
351
  this.options = e;
311
352
  }
312
353
  async solve(n, r = {}, o = {}) {
313
- let c = a(r), l = c ? o : r, u = {
354
+ let s = a(r), c = s ? o : r, u = {
314
355
  ...this.options,
315
- ...l
356
+ ...c
316
357
  };
317
- s(u);
358
+ l(u);
318
359
  let d = n.objective?.constant ?? 0;
319
360
  if (typeof d != "number" || !Number.isFinite(d)) throw Error(`Solver "${this.name}" encountered non-finite objective constant: ${String(d)}.`);
320
361
  let f = d === 0 ? 0 : d;
321
362
  for (let t of n.variables) e(t);
322
- let { lpString: p, nameToVar: m, nameToConstraint: h } = c ? r : i(n, { relax: u.relax }), g = Object.create(null), _ = !1, v = /* @__PURE__ */ new Set();
363
+ let { lpString: p, nameToVar: m, nameToConstraint: h } = s ? r : i(n, { relax: u.relax }), g = Object.create(null), _ = !1, v = /* @__PURE__ */ new Set();
323
364
  for (let [e, n] of m.entries()) {
324
365
  v.add(n);
325
366
  let r = t(n);
@@ -332,7 +373,7 @@ var V = class n {
332
373
  ...f === 0 ? {} : { objectiveOffset: f },
333
374
  ..._ ? { initialValues: g } : {}
334
375
  });
335
- let { result: b, runTime: x } = await R(p, y), S = b?.ObjectiveOffsetApplied ? 0 : f, C = z(b?.Status, b?.StatusCode), w = u.relax ? !1 : typeof b?.IsMip == "boolean" ? b.IsMip : n.variables.some((e) => e.type === "Integer" || e.type === "Binary"), T = b?.HasPrimalSolution === !0, E = B(b?.Status, b?.StatusCode, T), D = null;
376
+ let { result: b, runTime: x } = await H(p, y), S = b?.ObjectiveOffsetApplied ? 0 : f, C = U(b?.Status, b?.StatusCode), w = u.relax ? !1 : typeof b?.IsMip == "boolean" ? b.IsMip : n.variables.some((e) => e.type === "Integer" || e.type === "Binary"), T = b?.HasPrimalSolution === !0, E = W(b?.Status, b?.StatusCode, T), D = null;
336
377
  T && typeof b?.ObjectiveValue == "number" && Number.isFinite(b.ObjectiveValue) && (D = b.ObjectiveValue + S);
337
378
  let O, k, A;
338
379
  if (typeof b?.MipDualBound == "number" && Number.isFinite(b.MipDualBound) ? O = b.MipDualBound + S : !w && C === "Optimal" && D !== null && (O = D), D !== null && O !== void 0 && Number.isFinite(O) && (A = Math.abs(D - O)), S !== 0 && w && D !== null && O !== void 0 && A !== void 0) {
@@ -401,10 +442,10 @@ var V = class n {
401
442
  raw: b
402
443
  };
403
444
  }
404
- }, H = V;
405
- function U() {
406
- r("highs", (e) => new V(e)), n((e) => new V(e));
445
+ }, K = G;
446
+ function q() {
447
+ r("highs", (e) => new G(e)), n((e) => new G(e));
407
448
  }
408
- U();
449
+ q();
409
450
  //#endregion
410
- export { f as HIGHS_CONSTANTS, b as HIGHS_STATUS_NAMES, H as HiGHS, c as Highs, l as HighsError, g as HighsModel, V as HighsSolver, p as HighsUnsupportedOptionError, u as bindHighsFunctions, y as getHighs, m as getHighsWasmUrl, _ as isHighsCached, F as isHighsWarmed, d as isValidWasmHeader, B as mapHighsStatus, z as mapHighsTerminationStatus, U as registerHighsSolver, o as resolveBrowserWasmUrl, h as setHighsWasmUrl, R as solveLp, v as solveLpWithHighs, s as validateHighsOptions, L as warmupHighs };
451
+ export { m as HIGHS_CONSTANTS, S as HIGHS_STATUS_NAMES, K as HiGHS, u as Highs, d as HighsError, v as HighsModel, G as HighsSolver, h as HighsUnsupportedOptionError, f as bindHighsFunctions, x as getHighs, g as getHighsWasmUrl, y as isHighsCached, z as isHighsWarmed, p as isValidWasmHeader, W as mapHighsStatus, U as mapHighsTerminationStatus, q as registerHighsSolver, c as resolveBrowserWasmUrl, _ as setHighsWasmUrl, H as solveLp, b as solveLpWithHighs, l as validateHighsOptions, V as warmupHighs };
@@ -1,18 +1,6 @@
1
- //#region \0washi-browser-assets
2
- var e = import.meta.url;
3
- function t(t) {
4
- if (!e) throw Error("[WaSHI] Load the browser IIFE using an external script src, or use the browser ESM build.");
5
- return new URL(t, e).href;
6
- }
7
- function n() {
8
- return t("highs.wasm");
9
- }
10
- //#endregion
11
- //#region \0washi-node-runtime
12
- function r() {
13
- throw Error("This distribution is for browsers. Use the npm entry in Node.js.");
14
- }
15
- //#endregion
1
+ import { n as e, r as t } from "./embedded-wasm-CSFlLV5N.js";
2
+ import { getBundledWasmUrl as n } from "./highs-assets.js";
3
+ import { loadNodeHighs as r } from "./highs-node-runtime.js";
16
4
  //#region src/modeler/solvers/highs/driver.ts
17
5
  function i(e, t, n) {
18
6
  if (n <= 0 || !t) return /* @__PURE__ */ new Float64Array();
@@ -454,31 +442,63 @@ function S(e) {
454
442
  async function C(e) {
455
443
  return e || y || n();
456
444
  }
457
- async function w(e = {}) {
458
- let t = await C(e.wasmUrl);
445
+ async function w(e, t) {
446
+ let n = !!(typeof process < "u" && process.versions?.node && process.type !== "renderer");
447
+ if (e.wasmUrl) {
448
+ let t = n ? null : await C(e.wasmUrl);
449
+ return {
450
+ isNode: n,
451
+ wasmUrl: t,
452
+ wasmBinary: null,
453
+ key: t ? `url:${t}` : "node"
454
+ };
455
+ }
456
+ if (y) {
457
+ let e = n ? null : await C();
458
+ return {
459
+ isNode: n,
460
+ wasmUrl: e,
461
+ wasmBinary: null,
462
+ key: e ? `url:${e}` : "node"
463
+ };
464
+ }
465
+ if (t === null) return null;
466
+ if (t.kind === "embedded") return {
467
+ isNode: n,
468
+ wasmUrl: null,
469
+ wasmBinary: t.bytes,
470
+ key: "__embedded__"
471
+ };
472
+ let r = n ? null : await C();
459
473
  return {
460
- isNode: !1,
461
- wasmUrl: t,
462
- key: t ?? "node"
474
+ isNode: n,
475
+ wasmUrl: r,
476
+ wasmBinary: null,
477
+ key: r ? `url:${r}` : "node"
463
478
  };
464
479
  }
465
480
  async function T(e = {}) {
466
- let { key: t } = await w(e);
467
- return v === t;
481
+ let n = await w(e, t("highs"));
482
+ return n !== null && v === n.key;
468
483
  }
469
- async function E(e = {}) {
470
- let { isNode: t, wasmUrl: n, key: i } = await w(e);
471
- if (g && _ === i) return g;
472
- _ = i, v = null;
473
- let a = null;
474
- return a = (async () => {
475
- let e = t ? await r() : (await import("./highs-browser-runtime-0Bgq5ksG.js")).default;
476
- return t ? await e() : await e({ locateFile: (e) => e.endsWith(".wasm") ? n : e });
477
- })().then((e) => (g === a && (v = i), e)).catch((e) => {
478
- g === a && (g = null, _ = null, v = null);
479
- let t = e instanceof Error ? e.message : String(e);
480
- throw Error(`[WaSHI] Failed to initialize HiGHS${n ? ` from "${n}"` : ""}. Deploy the package's WASM asset or explicitly set wasmUrl; no CDN fallback is attempted. ${t}`, { cause: e });
481
- }), g = a, a;
484
+ async function E(t = {}) {
485
+ let n = await w(t, e("highs"));
486
+ if (!n) throw Error("[WaSHI] Failed to resolve HiGHS WASM target.");
487
+ let { isNode: i, wasmUrl: a, wasmBinary: o, key: s } = n;
488
+ if (g && _ === s) return g;
489
+ _ = s, v = null;
490
+ let c = null;
491
+ return c = (async () => {
492
+ let e = i ? await r() : (await import("./highs-browser-runtime.js")).default;
493
+ return o ? await e({
494
+ wasmBinary: o.slice(),
495
+ locateFile: (e) => e
496
+ }) : i ? await e() : await e({ locateFile: (e) => e.endsWith(".wasm") ? a : e });
497
+ })().then((e) => (g === c && (v = s), e)).catch((e) => {
498
+ g === c && (g = null, _ = null, v = null);
499
+ let t = e instanceof Error ? e.message : String(e), n = o ? " from embedded inline WASM" : a ? ` from "${a}"` : "";
500
+ throw Error(`[WaSHI] Failed to initialize HiGHS${n}. Deploy the package's WASM asset or explicitly set wasmUrl; no CDN fallback is attempted. ${t}`, { cause: e });
501
+ }), g = c, c;
482
502
  }
483
503
  async function D(e, t = {}) {
484
504
  if (h(t), t.signal?.aborted) return {
@@ -681,4 +701,4 @@ async function D(e, t = {}) {
681
701
  };
682
702
  }
683
703
  //#endregion
684
- export { n as _, C as a, h as c, f as d, a as f, t as g, l as h, S as i, c as l, o as m, x as n, b as o, d as p, T as r, D as s, E as t, s as u };
704
+ export { C as a, h as c, f as d, a as f, l as h, S as i, c as l, o as m, x as n, b as o, d as p, T as r, D as s, E as t, s as u };