@ohtaman/washi 0.7.0 → 0.8.1
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.ja.md +60 -23
- package/README.md +59 -22
- package/README.zh-CN.md +62 -25
- package/THIRD_PARTY_LICENSES.md +34 -1
- package/dist/browser/solvers/glpk.js +289 -238
- package/dist/browser/solvers/glpk.min.js +1 -1
- package/dist/browser/solvers/highs-__vite-browser-external-Dn-83hnF.js +7 -0
- package/dist/browser/solvers/highs-browser-runtime-0Bgq5ksG.js +2021 -0
- package/dist/browser/{loader-DewlSho8.js → solvers/highs-loader-BLY3wzDH.js} +190 -149
- package/dist/browser/solvers/highs-worker.js +54 -0
- package/dist/browser/solvers/highs.js +1414 -0
- package/dist/browser/solvers/highs.wasm +0 -0
- package/dist/browser/solvers/pumpkin-_washi-pumpkin-node-runtime-CEKUDK6d.js +9 -0
- package/dist/browser/solvers/pumpkin-loader-CvdaKxf4.js +320 -0
- package/dist/browser/solvers/pumpkin-worker.js +45 -0
- package/dist/browser/solvers/pumpkin.js +1777 -0
- package/dist/browser/solvers/pumpkin.wasm +0 -0
- package/dist/browser/solvers/pumpkin.wasm.LICENSE +21 -0
- package/dist/browser/solvers/z3.js +1600 -1335
- package/dist/browser/solvers/z3.min.js +2 -2
- package/dist/browser/washi.js +3313 -1699
- package/dist/browser/washi.min.js +5 -3
- package/dist/lib/solvers/__vite-browser-external-oLchLuMx.js +7 -0
- package/dist/lib/solvers/glpk.js +174 -132
- package/dist/lib/solvers/highs-browser-runtime.js +2413 -0
- package/dist/lib/{highs-node-runtime.js → solvers/highs-node-runtime.js} +1 -1
- package/dist/lib/solvers/highs-runtime.js +16 -0
- package/dist/lib/solvers/highs-worker.js +54 -0
- package/dist/lib/solvers/highs.js +410 -0
- package/dist/lib/solvers/highs.wasm +0 -0
- package/dist/lib/{loader-BZUQNvh4.js → solvers/loader-CDpPXN_F.js} +138 -116
- package/dist/lib/solvers/loader-Ow74Fa1B.js +311 -0
- package/dist/lib/solvers/lp-writer-CLScMFbS.js +115 -0
- package/dist/lib/solvers/pumpkin-assets.js +1 -0
- package/dist/lib/solvers/pumpkin-node-runtime.js +15 -0
- package/dist/lib/solvers/pumpkin-worker-factory.js +1 -0
- package/dist/lib/solvers/pumpkin-worker.js +45 -0
- package/dist/lib/solvers/pumpkin.js +868 -0
- package/dist/lib/solvers/pumpkin.wasm +0 -0
- package/dist/lib/solvers/pumpkin.wasm.LICENSE +21 -0
- package/dist/lib/solvers/registry-CrYRRk9q.js +907 -0
- package/dist/lib/solvers/rolldown-runtime-DtPi1Y-2.js +13 -0
- package/dist/lib/solvers/types-BGqPkxwu.js +12 -0
- package/dist/lib/solvers/z3.js +489 -307
- package/dist/lib/washi.js +3905 -1410
- package/dist/types/decomposition/benders.d.ts.map +1 -1
- package/dist/types/index.d.ts +4 -5
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/modeler/boolean-expr.d.ts +137 -29
- package/dist/types/modeler/boolean-expr.d.ts.map +1 -1
- package/dist/types/modeler/constraint.d.ts +40 -4
- package/dist/types/modeler/constraint.d.ts.map +1 -1
- package/dist/types/modeler/expression.d.ts +129 -2
- package/dist/types/modeler/expression.d.ts.map +1 -1
- package/dist/types/modeler/index.d.ts +4 -6
- package/dist/types/modeler/index.d.ts.map +1 -1
- package/dist/types/modeler/linearizer.d.ts +11 -2
- package/dist/types/modeler/linearizer.d.ts.map +1 -1
- package/dist/types/modeler/lp-writer.d.ts.map +1 -1
- package/dist/types/modeler/model.d.ts +86 -126
- package/dist/types/modeler/model.d.ts.map +1 -1
- package/dist/types/modeler/parser.d.ts.map +1 -1
- package/dist/types/modeler/quad-expr.d.ts +8 -2
- package/dist/types/modeler/quad-expr.d.ts.map +1 -1
- package/dist/types/modeler/solution-validator.d.ts +12 -12
- package/dist/types/modeler/solution-validator.d.ts.map +1 -1
- package/dist/types/modeler/solvers/glpk/loader.d.ts +4 -0
- package/dist/types/modeler/solvers/glpk/loader.d.ts.map +1 -1
- package/dist/types/modeler/solvers/glpk/solver.d.ts +2 -2
- package/dist/types/modeler/solvers/glpk/solver.d.ts.map +1 -1
- package/dist/types/modeler/solvers/highs/driver.d.ts.map +1 -1
- package/dist/types/modeler/solvers/highs/loader.d.ts +8 -6
- package/dist/types/modeler/solvers/highs/loader.d.ts.map +1 -1
- package/dist/types/modeler/solvers/highs/solver.d.ts.map +1 -1
- package/dist/types/modeler/solvers/highs/worker-client.d.ts +16 -0
- package/dist/types/modeler/solvers/highs/worker-client.d.ts.map +1 -1
- package/dist/types/modeler/solvers/index.d.ts +2 -1
- package/dist/types/modeler/solvers/index.d.ts.map +1 -1
- package/dist/types/modeler/solvers/mock.d.ts +2 -3
- package/dist/types/modeler/solvers/mock.d.ts.map +1 -1
- package/dist/types/modeler/solvers/pumpkin/assets.d.ts +2 -0
- package/dist/types/modeler/solvers/pumpkin/assets.d.ts.map +1 -0
- package/dist/types/modeler/solvers/pumpkin/index.d.ts +6 -0
- package/dist/types/modeler/solvers/pumpkin/index.d.ts.map +1 -0
- package/dist/types/modeler/solvers/pumpkin/loader.d.ts +40 -0
- package/dist/types/modeler/solvers/pumpkin/loader.d.ts.map +1 -0
- package/dist/types/modeler/solvers/pumpkin/node-runtime.d.ts +3 -0
- package/dist/types/modeler/solvers/pumpkin/node-runtime.d.ts.map +1 -0
- package/dist/types/modeler/solvers/pumpkin/solver.d.ts +23 -0
- package/dist/types/modeler/solvers/pumpkin/solver.d.ts.map +1 -0
- package/dist/types/modeler/solvers/pumpkin/worker-client.d.ts +74 -0
- package/dist/types/modeler/solvers/pumpkin/worker-client.d.ts.map +1 -0
- package/dist/types/modeler/solvers/pumpkin/worker-factory.d.ts +3 -0
- package/dist/types/modeler/solvers/pumpkin/worker-factory.d.ts.map +1 -0
- package/dist/types/modeler/solvers/pumpkin/worker.d.ts +7 -0
- package/dist/types/modeler/solvers/pumpkin/worker.d.ts.map +1 -0
- package/dist/types/modeler/solvers/pumpkin.d.ts +2 -0
- package/dist/types/modeler/solvers/pumpkin.d.ts.map +1 -0
- package/dist/types/modeler/solvers/types.d.ts +7 -9
- package/dist/types/modeler/solvers/types.d.ts.map +1 -1
- package/dist/types/modeler/solvers/z3/loader.d.ts +4 -0
- package/dist/types/modeler/solvers/z3/loader.d.ts.map +1 -1
- package/dist/types/modeler/solvers/z3/solver.d.ts +2 -15
- package/dist/types/modeler/solvers/z3/solver.d.ts.map +1 -1
- package/dist/types/modeler/types.d.ts +12 -15
- package/dist/types/modeler/types.d.ts.map +1 -1
- package/dist/types/modeler/validation.d.ts +26 -2
- package/dist/types/modeler/validation.d.ts.map +1 -1
- package/dist/types/modeler/variable.d.ts +9 -5
- package/dist/types/modeler/variable.d.ts.map +1 -1
- package/docs/examples/diet-sensitivity.md +33 -14
- package/docs/examples/ecommerce-coupons.md +17 -9
- package/docs/examples/index.md +36 -27
- package/docs/examples/knapsack.md +11 -5
- package/docs/examples/portfolio-qp.md +21 -8
- package/docs/examples/production.md +10 -5
- package/docs/examples/project-scheduling.md +119 -0
- package/docs/examples/shift-scheduling.md +29 -18
- package/docs/examples/smt-security.md +27 -11
- package/docs/examples/transportation.md +23 -13
- package/docs/examples/traveling-salesperson.md +34 -22
- package/docs/examples/unsat-core.md +27 -14
- package/docs/examples/vehicle-routing.md +74 -28
- package/docs/getting-started/ai-agents.md +190 -82
- package/docs/getting-started/coding-agents.md +177 -0
- package/docs/getting-started/cross-origin.md +27 -14
- package/docs/getting-started/index.md +49 -43
- package/docs/getting-started/runtimes.md +94 -40
- package/docs/guide/constraint-programming.md +171 -0
- package/docs/guide/constraints.md +115 -33
- package/docs/guide/decomposition.md +118 -88
- package/docs/guide/expressions.md +106 -43
- package/docs/guide/formulation-tips.md +47 -28
- package/docs/guide/objectives.md +102 -75
- package/docs/guide/unsat-core.md +62 -50
- package/docs/guide/variables.md +81 -35
- package/docs/solvers/custom-solver.md +163 -122
- package/docs/solvers/glpk.md +58 -17
- package/docs/solvers/highs.md +124 -57
- package/docs/solvers/index.md +33 -20
- package/docs/solvers/pumpkin.md +171 -0
- package/docs/solvers/z3.md +63 -25
- package/llms-full.txt +2232 -932
- package/llms.txt +144 -91
- package/package.json +55 -19
- package/skills/washi/SKILL.md +107 -34
- package/dist/browser/_washi-node-only-BvRk9kiK.js +0 -0
- package/dist/browser/browser-runtime-TLCY0hkc.js +0 -1793
- package/dist/browser/highs-worker.js +0 -39
- package/dist/browser/highs.wasm +0 -0
- package/dist/lib/_washi-node-only-BvRk9kiK.js +0 -0
- package/dist/lib/highs-browser-runtime.js +0 -2185
- package/dist/lib/highs-runtime.js +0 -2
- package/dist/lib/highs-worker.js +0 -39
- package/dist/lib/highs.wasm +0 -0
- package/dist/lib/registry-D7TZ3Wh_.js +0 -1034
- package/docs/ja/getting-started/ai-agents.md +0 -280
- package/docs/zh/getting-started/ai-agents.md +0 -280
- /package/dist/browser/{highs.wasm.LICENSE → solvers/highs.wasm.LICENSE} +0 -0
- /package/dist/lib/{highs-assets.js → solvers/highs-assets.js} +0 -0
- /package/dist/lib/{highs-worker-factory.js → solvers/highs-worker-factory.js} +0 -0
- /package/dist/lib/{highs.wasm.LICENSE → solvers/highs.wasm.LICENSE} +0 -0
|
Binary file
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
//#region \0washi-pumpkin-node-runtime
|
|
2
|
+
async function e() {
|
|
3
|
+
throw Error("This distribution is for browsers. Use the npm entry in Node.js.");
|
|
4
|
+
}
|
|
5
|
+
async function t() {
|
|
6
|
+
throw Error("This distribution is for browsers. Use the npm entry in Node.js.");
|
|
7
|
+
}
|
|
8
|
+
//#endregion
|
|
9
|
+
export { t as readBundledPumpkinWasmBytes, e as readPumpkinWasmFileUrl };
|
|
@@ -0,0 +1,320 @@
|
|
|
1
|
+
//#region \0washi-browser-pumpkin-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("pumpkin.wasm");
|
|
9
|
+
}
|
|
10
|
+
//#endregion
|
|
11
|
+
//#region src/modeler/solvers/pumpkin/runtime.js
|
|
12
|
+
function r() {
|
|
13
|
+
function e(e) {
|
|
14
|
+
let t, n;
|
|
15
|
+
try {
|
|
16
|
+
let r = d(e, _.__wbindgen_malloc, _.__wbindgen_realloc), i = g, a = _.check_json(r, i);
|
|
17
|
+
return t = a[0], n = a[1], o(a[0], a[1]);
|
|
18
|
+
} finally {
|
|
19
|
+
_.__wbindgen_free(t, n, 1);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
function t(e, t) {
|
|
23
|
+
let n, r;
|
|
24
|
+
try {
|
|
25
|
+
let i = d(e, _.__wbindgen_malloc, _.__wbindgen_realloc), s = g, c = _.check_with_callback(i, s, u(t) ? 0 : a(t));
|
|
26
|
+
return n = c[0], r = c[1], o(c[0], c[1]);
|
|
27
|
+
} finally {
|
|
28
|
+
_.__wbindgen_free(n, r, 1);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
function n(e) {
|
|
32
|
+
let t, n;
|
|
33
|
+
try {
|
|
34
|
+
let r = d(e, _.__wbindgen_malloc, _.__wbindgen_realloc), i = g, a = _.solve_json(r, i);
|
|
35
|
+
return t = a[0], n = a[1], o(a[0], a[1]);
|
|
36
|
+
} finally {
|
|
37
|
+
_.__wbindgen_free(t, n, 1);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
function r(e, t, n) {
|
|
41
|
+
let r, i;
|
|
42
|
+
try {
|
|
43
|
+
let s = d(e, _.__wbindgen_malloc, _.__wbindgen_realloc), c = g, l = _.solve_with_callback(s, c, u(t) ? 0 : a(t), u(n) ? 0 : a(n));
|
|
44
|
+
return r = l[0], i = l[1], o(l[0], l[1]);
|
|
45
|
+
} finally {
|
|
46
|
+
_.__wbindgen_free(r, i, 1);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
function i() {
|
|
50
|
+
return {
|
|
51
|
+
__proto__: null,
|
|
52
|
+
"./pumpkin_bg.js": {
|
|
53
|
+
__proto__: null,
|
|
54
|
+
__wbg___wbindgen_boolean_get_4f1baf9a00be3c74: function(e) {
|
|
55
|
+
let t = e, n = typeof t == "boolean" ? t : void 0;
|
|
56
|
+
return u(n) ? 16777215 : +!!n;
|
|
57
|
+
},
|
|
58
|
+
__wbg___wbindgen_is_undefined_be5b34249ff1fc15: function(e) {
|
|
59
|
+
return e === void 0;
|
|
60
|
+
},
|
|
61
|
+
__wbg___wbindgen_throw_4c88d8bf264fd984: function(e, t) {
|
|
62
|
+
throw Error(o(e, t));
|
|
63
|
+
},
|
|
64
|
+
__wbg_call_40b008ba32f73991: function() {
|
|
65
|
+
return l(function(e, t) {
|
|
66
|
+
return e.call(t);
|
|
67
|
+
}, arguments);
|
|
68
|
+
},
|
|
69
|
+
__wbg_call_a410eb4b59ed5965: function() {
|
|
70
|
+
return l(function(e, t, n) {
|
|
71
|
+
return e.call(t, n);
|
|
72
|
+
}, arguments);
|
|
73
|
+
},
|
|
74
|
+
__wbg_now_e7c6795a7f81e10f: function(e) {
|
|
75
|
+
return e.now();
|
|
76
|
+
},
|
|
77
|
+
__wbg_performance_7e4e4494fdc9d07a: function(e) {
|
|
78
|
+
return e.performance;
|
|
79
|
+
},
|
|
80
|
+
__wbg_static_accessor_GLOBAL_THIS_003ee833af9699fc: function() {
|
|
81
|
+
let e = typeof globalThis > "u" ? void 0 : globalThis;
|
|
82
|
+
return u(e) ? 0 : a(e);
|
|
83
|
+
},
|
|
84
|
+
__wbg_static_accessor_GLOBAL_e4293fb22cbe77da: function() {
|
|
85
|
+
let e = typeof globalThis > "u" ? void 0 : globalThis;
|
|
86
|
+
return u(e) ? 0 : a(e);
|
|
87
|
+
},
|
|
88
|
+
__wbg_static_accessor_SELF_53bb20457401453d: function() {
|
|
89
|
+
let e = typeof self > "u" ? void 0 : self;
|
|
90
|
+
return u(e) ? 0 : a(e);
|
|
91
|
+
},
|
|
92
|
+
__wbg_static_accessor_WINDOW_b5e0810bfecb7feb: function() {
|
|
93
|
+
let e = typeof window > "u" ? void 0 : window;
|
|
94
|
+
return u(e) ? 0 : a(e);
|
|
95
|
+
},
|
|
96
|
+
__wbindgen_generic_0000000000000001: function(e, t) {
|
|
97
|
+
return o(e, t);
|
|
98
|
+
},
|
|
99
|
+
__wbindgen_init_externref_table: function() {
|
|
100
|
+
let e = _.__wbindgen_externrefs;
|
|
101
|
+
e.set(0, void 0), e.set(1024, void 0), e.set(1025, null), e.set(1026, !0), e.set(1027, !1);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
function a(e) {
|
|
107
|
+
let t = _.__externref_table_alloc();
|
|
108
|
+
return _.__wbindgen_externrefs.set(t, e), t;
|
|
109
|
+
}
|
|
110
|
+
function o(e, t) {
|
|
111
|
+
return e >>>= 0, m(c().subarray(e, e + t));
|
|
112
|
+
}
|
|
113
|
+
let s = null;
|
|
114
|
+
function c() {
|
|
115
|
+
return (s === null || s.byteLength === 0) && (s = new Uint8Array(_.memory.buffer)), s;
|
|
116
|
+
}
|
|
117
|
+
function l(e, t) {
|
|
118
|
+
try {
|
|
119
|
+
return e.apply(this, t);
|
|
120
|
+
} catch (e) {
|
|
121
|
+
let t = a(e);
|
|
122
|
+
_.__wbindgen_exn_store(t);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
function u(e) {
|
|
126
|
+
return e == null;
|
|
127
|
+
}
|
|
128
|
+
function d(e, t, n) {
|
|
129
|
+
if (n === void 0) {
|
|
130
|
+
let n = h.encode(e), r = t(n.length, 1) >>> 0;
|
|
131
|
+
return c().subarray(r, r + n.length).set(n), g = n.length, r;
|
|
132
|
+
}
|
|
133
|
+
let r = e.length, i = t(r, 1) >>> 0, a = c(), o = 0;
|
|
134
|
+
for (; o < r; o++) {
|
|
135
|
+
let t = e.charCodeAt(o);
|
|
136
|
+
if (t > 127) break;
|
|
137
|
+
a[i + o] = t;
|
|
138
|
+
}
|
|
139
|
+
if (o !== r) {
|
|
140
|
+
o !== 0 && (e = e.slice(o)), i = n(i, r, r = o + e.length * 3, 1) >>> 0;
|
|
141
|
+
let t = c().subarray(i + o, i + r), a = h.encodeInto(e, t);
|
|
142
|
+
o += a.written, i = n(i, r, o, 1) >>> 0;
|
|
143
|
+
}
|
|
144
|
+
return g = o, i;
|
|
145
|
+
}
|
|
146
|
+
let f = new TextDecoder("utf-8", { ignoreBOM: !0 });
|
|
147
|
+
f.decode();
|
|
148
|
+
let p = 0;
|
|
149
|
+
function m(e) {
|
|
150
|
+
return p += e.length, p >= 2146435072 && (f = new TextDecoder("utf-8", { ignoreBOM: !0 }), f.decode(), p = e.length), f.decode(e);
|
|
151
|
+
}
|
|
152
|
+
let h = new TextEncoder();
|
|
153
|
+
"encodeInto" in h || (h.encodeInto = function(e, t) {
|
|
154
|
+
let n = h.encode(e);
|
|
155
|
+
return t.set(n), {
|
|
156
|
+
read: e.length,
|
|
157
|
+
written: n.length
|
|
158
|
+
};
|
|
159
|
+
});
|
|
160
|
+
let g = 0, _;
|
|
161
|
+
function v(e, t) {
|
|
162
|
+
if (_ = e.exports, s = null, !_ || !(_.memory instanceof WebAssembly.Memory) || typeof _.__wbindgen_start != "function" || typeof _.__wbindgen_malloc != "function" || typeof _.__wbindgen_free != "function" || typeof _.check_json != "function" || typeof _.check_with_callback != "function" || typeof _.solve_json != "function" || typeof _.solve_with_callback != "function") throw Error("[WaSHI] Invalid Pumpkin WebAssembly module: missing expected solver exports.");
|
|
163
|
+
return _.__wbindgen_start(), _;
|
|
164
|
+
}
|
|
165
|
+
async function y(e, t) {
|
|
166
|
+
if (typeof Response == "function" && e instanceof Response) {
|
|
167
|
+
if (!e.ok) throw Error(`failed to fetch Wasm: ${e.status} ${e.statusText} fetching '${e.url}'`);
|
|
168
|
+
if (typeof WebAssembly.instantiateStreaming == "function") try {
|
|
169
|
+
return await WebAssembly.instantiateStreaming(e, t);
|
|
170
|
+
} catch (t) {
|
|
171
|
+
if (n(e.type) && e.headers.get("Content-Type") !== "application/wasm") console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", t);
|
|
172
|
+
else throw t;
|
|
173
|
+
}
|
|
174
|
+
let r = await e.arrayBuffer();
|
|
175
|
+
return await WebAssembly.instantiate(r, t);
|
|
176
|
+
}
|
|
177
|
+
{
|
|
178
|
+
let n = await WebAssembly.instantiate(e, t);
|
|
179
|
+
return n instanceof WebAssembly.Instance ? {
|
|
180
|
+
instance: n,
|
|
181
|
+
module: e
|
|
182
|
+
} : n;
|
|
183
|
+
}
|
|
184
|
+
function n(e) {
|
|
185
|
+
switch (e) {
|
|
186
|
+
case "basic":
|
|
187
|
+
case "cors":
|
|
188
|
+
case "default": return !0;
|
|
189
|
+
}
|
|
190
|
+
return !1;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
let b;
|
|
194
|
+
async function x(e) {
|
|
195
|
+
return _ === void 0 ? (b === void 0 && (b = S(e), b.catch(() => {
|
|
196
|
+
b = void 0;
|
|
197
|
+
})), b) : _;
|
|
198
|
+
}
|
|
199
|
+
async function S(e) {
|
|
200
|
+
e !== void 0 && (Object.getPrototypeOf(e) === Object.prototype ? {module_or_path: e} = e : console.warn("using deprecated parameters for the initialization function; pass a single object instead"));
|
|
201
|
+
let t = i();
|
|
202
|
+
(typeof e == "string" || typeof Request == "function" && e instanceof Request || typeof URL == "function" && e instanceof URL) && (e = fetch(e));
|
|
203
|
+
let { instance: n, module: r } = await y(await e, t);
|
|
204
|
+
return v(n, r);
|
|
205
|
+
}
|
|
206
|
+
return {
|
|
207
|
+
check_json: e,
|
|
208
|
+
check_with_callback: t,
|
|
209
|
+
solve_json: n,
|
|
210
|
+
solve_with_callback: r,
|
|
211
|
+
__wbg_init: x
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
async function i(e) {
|
|
215
|
+
let t = r();
|
|
216
|
+
return await t.__wbg_init({ module_or_path: e }), {
|
|
217
|
+
check_json: t.check_json,
|
|
218
|
+
check_with_callback: t.check_with_callback,
|
|
219
|
+
solve_json: t.solve_json,
|
|
220
|
+
solve_with_callback: t.solve_with_callback
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
//#endregion
|
|
224
|
+
//#region src/modeler/solvers/pumpkin/loader.ts
|
|
225
|
+
var a = 4, o = null, s = /* @__PURE__ */ new Map(), c = /* @__PURE__ */ new Set(), l = 0, u = null;
|
|
226
|
+
function d(e) {
|
|
227
|
+
u = e;
|
|
228
|
+
}
|
|
229
|
+
function f() {
|
|
230
|
+
return !1;
|
|
231
|
+
}
|
|
232
|
+
function p(e) {
|
|
233
|
+
return e.byteLength >= 8 && e[0] === 0 && e[1] === 97 && e[2] === 115 && e[3] === 109;
|
|
234
|
+
}
|
|
235
|
+
function m(e) {
|
|
236
|
+
if (e !== null && typeof e != "string") throw Error(`Invalid pumpkin.wasm URL: expected string or null, got ${typeof e}.`);
|
|
237
|
+
if (e === "") throw Error("Invalid pumpkin.wasm URL: expected non-empty string or null (received empty string \"\").");
|
|
238
|
+
e !== o && (o = e, _());
|
|
239
|
+
}
|
|
240
|
+
function h() {
|
|
241
|
+
return o;
|
|
242
|
+
}
|
|
243
|
+
function g() {
|
|
244
|
+
return o ?? n();
|
|
245
|
+
}
|
|
246
|
+
function _() {
|
|
247
|
+
l++, s.clear(), c.clear(), u?.();
|
|
248
|
+
}
|
|
249
|
+
function v(e) {
|
|
250
|
+
let t = x(e) ?? "__bundled__";
|
|
251
|
+
return c.has(t);
|
|
252
|
+
}
|
|
253
|
+
function y() {
|
|
254
|
+
if (typeof Worker > "u" || typeof window > "u" || typeof Worker.prototype.unref == "function") return !1;
|
|
255
|
+
let e = typeof window.origin == "string" ? window.origin : (() => {
|
|
256
|
+
try {
|
|
257
|
+
return window.location?.origin;
|
|
258
|
+
} catch {
|
|
259
|
+
return;
|
|
260
|
+
}
|
|
261
|
+
})();
|
|
262
|
+
return !(!e || e === "null" || e.startsWith("file:"));
|
|
263
|
+
}
|
|
264
|
+
async function b(e) {
|
|
265
|
+
if (typeof fetch != "function") throw Error(`[WaSHI] Global fetch() is unavailable to load Pumpkin WebAssembly from "${e}"; no CDN fallback is attempted.`);
|
|
266
|
+
let t;
|
|
267
|
+
try {
|
|
268
|
+
t = await fetch(e);
|
|
269
|
+
} catch (t) {
|
|
270
|
+
throw Error(`[WaSHI] Failed to fetch pumpkin.wasm from "${e}" (no CDN fallback is attempted): ${t instanceof Error ? t.message : String(t)}. Ensure pumpkin.wasm is hosted cleanly or call setPumpkinWasmUrl(url).`);
|
|
271
|
+
}
|
|
272
|
+
if (!t.ok) throw Error(`[WaSHI] Failed to fetch pumpkin.wasm from "${e}": HTTP ${t.status} ${t.statusText}; no CDN fallback is attempted.`);
|
|
273
|
+
let n = t.headers?.get("content-type")?.toLowerCase() ?? "";
|
|
274
|
+
if (n.includes("text/html")) throw Error(`[WaSHI] Invalid response while loading pumpkin.wasm from "${e}": received HTML ("${n}") instead of a WebAssembly binary; no CDN fallback is attempted.`);
|
|
275
|
+
let r = await t.arrayBuffer(), i = new Uint8Array(r);
|
|
276
|
+
if (!p(i)) throw Error(`[WaSHI] Invalid WebAssembly binary loaded from "${e}": expected \\0asm magic header; no CDN fallback is attempted.`);
|
|
277
|
+
return i;
|
|
278
|
+
}
|
|
279
|
+
function x(e) {
|
|
280
|
+
if (e === void 0) return o;
|
|
281
|
+
if (e !== null && typeof e != "string") throw Error(`Invalid pumpkin.wasm URL: expected string or null, got ${typeof e}.`);
|
|
282
|
+
if (e === "") throw Error("Invalid pumpkin.wasm URL: expected non-empty string or null (received empty string \"\").");
|
|
283
|
+
return e;
|
|
284
|
+
}
|
|
285
|
+
async function S(e) {
|
|
286
|
+
if (e !== null) {
|
|
287
|
+
if (f() && e.startsWith("file://")) {
|
|
288
|
+
let { readPumpkinWasmFileUrl: t } = await import("./pumpkin-_washi-pumpkin-node-runtime-CEKUDK6d.js"), n = await t(new URL(e));
|
|
289
|
+
if (!p(n)) throw Error(`[WaSHI] Invalid WebAssembly binary at "${e}": expected \\0asm magic header.`);
|
|
290
|
+
return n;
|
|
291
|
+
}
|
|
292
|
+
return b(e);
|
|
293
|
+
}
|
|
294
|
+
if (f() && typeof window > "u") {
|
|
295
|
+
let { readBundledPumpkinWasmBytes: e } = await import("./pumpkin-_washi-pumpkin-node-runtime-CEKUDK6d.js"), t = await e();
|
|
296
|
+
if (!p(t)) throw Error("[WaSHI] Bundled pumpkin.wasm on disk has an invalid WebAssembly magic header.");
|
|
297
|
+
return t;
|
|
298
|
+
}
|
|
299
|
+
return b(n());
|
|
300
|
+
}
|
|
301
|
+
async function C(e) {
|
|
302
|
+
let t = x(e), n = t ?? "__bundled__", r = s.get(n);
|
|
303
|
+
if (r) return s.delete(n), s.set(n, r), r;
|
|
304
|
+
let o = l, u = null;
|
|
305
|
+
for (u = (async () => {
|
|
306
|
+
try {
|
|
307
|
+
let e = await i(await S(t));
|
|
308
|
+
return l === o && s.get(n) === u && c.add(n), e;
|
|
309
|
+
} catch (e) {
|
|
310
|
+
throw l === o && (c.delete(n), s.get(n) === u && s.delete(n)), t !== null && e instanceof Error && e.message.includes("Invalid Pumpkin WebAssembly module") ? Error(`[WaSHI] Invalid Pumpkin WebAssembly module loaded from "${t}" (${e.message}); no CDN fallback is attempted.`) : e;
|
|
311
|
+
}
|
|
312
|
+
})(); s.size >= a;) {
|
|
313
|
+
let e = s.keys().next().value;
|
|
314
|
+
if (e === void 0) break;
|
|
315
|
+
s.delete(e), c.delete(e);
|
|
316
|
+
}
|
|
317
|
+
return s.set(n, u), u;
|
|
318
|
+
}
|
|
319
|
+
//#endregion
|
|
320
|
+
export { d as a, m as c, n as d, C as i, y as l, v as n, _ as o, p as r, g as s, h as t, t as u };
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { i as e } from "./pumpkin-loader-CvdaKxf4.js";
|
|
2
|
+
//#region src/modeler/solvers/pumpkin/worker.ts
|
|
3
|
+
var t = globalThis;
|
|
4
|
+
t.onmessage = async (n) => {
|
|
5
|
+
let { id: r, type: i, requestJson: a, wasmUrl: o } = n.data;
|
|
6
|
+
try {
|
|
7
|
+
let n = await e(o === void 0 ? null : o), s = performance.now();
|
|
8
|
+
if (i === "check") {
|
|
9
|
+
let e = n.check_with_callback(a, null), i = Math.max((performance.now() - s) / 1e3, 1e-6);
|
|
10
|
+
t.postMessage({
|
|
11
|
+
id: r,
|
|
12
|
+
type: "CHECK_SUCCESS",
|
|
13
|
+
responseJson: e,
|
|
14
|
+
runTime: i
|
|
15
|
+
});
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
if (i === "solve") {
|
|
19
|
+
let e = n.solve_with_callback(a, (e) => {
|
|
20
|
+
let n = Math.max((performance.now() - s) / 1e3, 1e-6);
|
|
21
|
+
return t.postMessage({
|
|
22
|
+
id: r,
|
|
23
|
+
type: "SOLVE_PROGRESS",
|
|
24
|
+
payloadJson: e,
|
|
25
|
+
elapsedTime: n
|
|
26
|
+
}), !1;
|
|
27
|
+
}, null), i = Math.max((performance.now() - s) / 1e3, 1e-6);
|
|
28
|
+
t.postMessage({
|
|
29
|
+
id: r,
|
|
30
|
+
type: "SOLVE_SUCCESS",
|
|
31
|
+
responseJson: e,
|
|
32
|
+
runTime: i
|
|
33
|
+
});
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
throw Error(`[WaSHI] Unknown Pumpkin worker command "${String(i)}".`);
|
|
37
|
+
} catch (e) {
|
|
38
|
+
t.postMessage({
|
|
39
|
+
id: r,
|
|
40
|
+
type: "SOLVER_ERROR",
|
|
41
|
+
error: e instanceof Error ? e.message : String(e)
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
//#endregion
|