@ohtaman/washi 0.2.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/README.ja.md +138 -122
  2. package/README.md +138 -122
  3. package/README.zh-CN.md +140 -124
  4. package/dist/browser/solvers/glpk.js +10 -2
  5. package/dist/browser/solvers/glpk.min.js +1 -1
  6. package/dist/browser/solvers/z3.js +34 -12
  7. package/dist/browser/solvers/z3.min.js +2 -2
  8. package/dist/browser/washi.js +562 -397
  9. package/dist/browser/washi.min.js +4 -4
  10. package/dist/lib/{constraint-XWdn0ID9.js → constraint-BRuB3ooC.js} +0 -3
  11. package/dist/lib/solvers/glpk.js +10 -2
  12. package/dist/lib/solvers/z3.js +35 -10
  13. package/dist/lib/washi.js +562 -412
  14. package/dist/types/index.d.ts +5 -7
  15. package/dist/types/index.d.ts.map +1 -1
  16. package/dist/types/modeler/constraint.d.ts +0 -3
  17. package/dist/types/modeler/constraint.d.ts.map +1 -1
  18. package/dist/types/modeler/expression.d.ts +23 -12
  19. package/dist/types/modeler/expression.d.ts.map +1 -1
  20. package/dist/types/modeler/index.d.ts +2 -4
  21. package/dist/types/modeler/index.d.ts.map +1 -1
  22. package/dist/types/modeler/model.d.ts +123 -40
  23. package/dist/types/modeler/model.d.ts.map +1 -1
  24. package/dist/types/modeler/parser.d.ts +9 -8
  25. package/dist/types/modeler/parser.d.ts.map +1 -1
  26. package/dist/types/modeler/quad-expr.d.ts +3 -1
  27. package/dist/types/modeler/quad-expr.d.ts.map +1 -1
  28. package/dist/types/modeler/solvers/glpk/solver.d.ts.map +1 -1
  29. package/dist/types/modeler/solvers/highs/solver.d.ts +1 -1
  30. package/dist/types/modeler/solvers/highs/solver.d.ts.map +1 -1
  31. package/dist/types/modeler/solvers/types.d.ts +1 -1
  32. package/dist/types/modeler/solvers/z3/loader.d.ts +12 -0
  33. package/dist/types/modeler/solvers/z3/loader.d.ts.map +1 -1
  34. package/dist/types/modeler/types.d.ts +8 -3
  35. package/dist/types/modeler/types.d.ts.map +1 -1
  36. package/dist/types/modeler/variable.d.ts +7 -6
  37. package/dist/types/modeler/variable.d.ts.map +1 -1
  38. package/package.json +11 -3
  39. package/dist/types/modeler/mip-compat.d.ts +0 -43
  40. package/dist/types/modeler/mip-compat.d.ts.map +0 -1
  41. package/dist/types/modeler/pulp-compat.d.ts +0 -67
  42. package/dist/types/modeler/pulp-compat.d.ts.map +0 -1
@@ -68,9 +68,6 @@ var e = Object.create, t = Object.defineProperty, n = Object.getOwnPropertyDescr
68
68
  constructor(e, t, n, r) {
69
69
  this.id = ++g, this.lhs = e, this.sense = t, this.rhs = n, this.name = r || `c_${this.id}`;
70
70
  }
71
- get pi() {
72
- return this.dual;
73
- }
74
71
  and(e) {
75
72
  return new h("and", [this, e]);
76
73
  }
@@ -7197,11 +7194,16 @@ function pt() {
7197
7194
  }
7198
7195
  async function mt(e, t) {
7199
7196
  try {
7200
- let n = await fetch(e, {
7197
+ let n = null;
7198
+ try {
7199
+ let t = await fetch(e, { method: "HEAD" });
7200
+ t.ok && (n = t);
7201
+ } catch {}
7202
+ if (n ||= await fetch(e, {
7201
7203
  method: "GET",
7202
- headers: { Range: "bytes=0-3" }
7203
- });
7204
- if (!n.ok) throw Error(`server responded with HTTP status ${n.status} (${n.statusText || "Not Found"})`);
7204
+ headers: { Range: "bytes=0-3" },
7205
+ cache: "no-store"
7206
+ }), !n.ok) throw Error(`server responded with HTTP status ${n.status} (${n.statusText || "Not Found"})`);
7205
7207
  if ((n.headers.get("content-type") || "").includes("text/html")) throw Error(`server responded with "text/html" instead of expected ${t} (check SPA fallback routing)`);
7206
7208
  } catch (n) {
7207
7209
  throw Error(`[WaSHI] Failed to load Z3 asset (${t}) from "${e}": ${n.message || String(n)}. Deploy local assets with correct MIME types; no CDN fallback is attempted.`, { cause: n });
@@ -7224,10 +7226,30 @@ function ht(e = {}) {
7224
7226
  }
7225
7227
  async function gt(e) {
7226
7228
  let t = globalThis;
7227
- if (typeof t.initZ3 == "function") return t.initZ3;
7228
- if (typeof document < "u") await new Promise((t, n) => {
7229
- let r = document.createElement("script");
7230
- r.src = e, r.crossOrigin = "anonymous", r.onload = () => t(), r.onerror = () => n(/* @__PURE__ */ Error(`[WaSHI] Failed to load Z3 runtime script from "${e}".`)), document.head.appendChild(r);
7229
+ if (t.global === void 0 && (t.global = t), typeof t.initZ3 == "function") return t.initZ3;
7230
+ if (typeof document < "u") await new Promise((n, r) => {
7231
+ let i = null, a = (e) => {
7232
+ try {
7233
+ let t = typeof document < "u" && document.baseURI ? document.baseURI : void 0, n = new URL(e, t);
7234
+ return n.origin + n.pathname;
7235
+ } catch {
7236
+ return e;
7237
+ }
7238
+ }, o = a(e), s = (t) => {
7239
+ t.filename && (a(t.filename) === o || t.filename === e || t.filename.endsWith(o) || o.endsWith(t.filename)) && (i = t.error || t.message);
7240
+ }, c = typeof window < "u" && typeof window.addEventListener == "function";
7241
+ c && window.addEventListener("error", s);
7242
+ let l = document.createElement("script");
7243
+ l.src = e, l.crossOrigin = "anonymous", l.onload = () => {
7244
+ if (c && window.removeEventListener("error", s), typeof t.initZ3 != "function" && i) {
7245
+ let t = i instanceof Error ? `${i.name}: ${i.message}` : typeof i == "string" ? i : i?.message ? `${i.name ? i.name + ": " : ""}${i.message}` : String(i);
7246
+ r(/* @__PURE__ */ Error(`[WaSHI] Failed to evaluate Z3 runtime script from "${e}": ${t}`));
7247
+ return;
7248
+ }
7249
+ n();
7250
+ }, l.onerror = () => {
7251
+ c && window.removeEventListener("error", s), r(/* @__PURE__ */ Error(`[WaSHI] Failed to load Z3 runtime script from "${e}".`));
7252
+ }, document.head.appendChild(l);
7231
7253
  });
7232
7254
  else if (typeof globalThis.importScripts == "function") globalThis.importScripts(e);
7233
7255
  else throw Error("[WaSHI] Cannot load z3-built.js in this environment: neither document nor importScripts is available.");
@@ -7525,4 +7547,4 @@ function bt() {
7525
7547
  }
7526
7548
  bt();
7527
7549
  //#endregion
7528
- export { yt as Z3Solver, vt as killZ3Threads, _t as loadZ3, lt as notifyZ3WorkerError, ct as registerZ3ErrorHandler, bt as registerZ3Solver, ft as resetZ3LoaderCache, ht as resolveZ3AssetUrls, dt as setZ3Assets, ot as unlockAllZ3Semaphores, pt as validateZ3BrowserEnvironment };
7550
+ export { yt as Z3Solver, gt as ensureInitZ3Loaded, vt as killZ3Threads, _t as loadZ3, lt as notifyZ3WorkerError, mt as probeAssetUrl, ct as registerZ3ErrorHandler, bt as registerZ3Solver, ft as resetZ3LoaderCache, ht as resolveZ3AssetUrls, dt as setZ3Assets, ot as unlockAllZ3Semaphores, pt as validateZ3BrowserEnvironment };