wasm-idle 0.7.2 → 1.0.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 (386) hide show
  1. package/README.md +760 -81
  2. package/dist/index.d.ts +4 -9
  3. package/dist/index.js +2 -4
  4. package/dist/playground/applicationAssets.d.ts +4 -0
  5. package/dist/playground/applicationAssets.js +277 -0
  6. package/dist/playground/assemblyscript.d.ts +41 -0
  7. package/dist/playground/assemblyscript.js +630 -0
  8. package/dist/playground/assetBridge.d.ts +18 -7
  9. package/dist/playground/assetBridge.js +824 -100
  10. package/dist/playground/assets.d.ts +813 -19
  11. package/dist/playground/assets.js +2096 -156
  12. package/dist/playground/awk.d.ts +5 -0
  13. package/dist/playground/awk.js +60 -0
  14. package/dist/playground/bash.d.ts +53 -0
  15. package/dist/playground/bash.js +1096 -0
  16. package/dist/playground/bashWorkerProtocol.d.ts +88 -0
  17. package/dist/playground/bashWorkerProtocol.js +135 -0
  18. package/dist/playground/bqn.d.ts +5 -0
  19. package/dist/playground/bqn.js +57 -0
  20. package/dist/playground/bqnPreflight.d.ts +26 -0
  21. package/dist/playground/bqnPreflight.js +399 -0
  22. package/dist/playground/c3.d.ts +15 -0
  23. package/dist/playground/c3.js +154 -0
  24. package/dist/playground/clang.d.ts +35 -19
  25. package/dist/playground/clang.js +241 -52
  26. package/dist/playground/clangAssetIntegrity.d.ts +32 -0
  27. package/dist/playground/clangAssetIntegrity.js +8 -0
  28. package/dist/playground/clojurescript.d.ts +5 -0
  29. package/dist/playground/clojurescript.js +59 -0
  30. package/dist/playground/clojurescriptPreflight.d.ts +26 -0
  31. package/dist/playground/clojurescriptPreflight.js +383 -0
  32. package/dist/playground/cobol.d.ts +46 -0
  33. package/dist/playground/cobol.js +703 -0
  34. package/dist/playground/d.d.ts +47 -0
  35. package/dist/playground/d.js +644 -0
  36. package/dist/playground/dOuterAssets.d.ts +16 -0
  37. package/dist/playground/dOuterAssets.js +163 -0
  38. package/dist/playground/dotnet.d.ts +99 -0
  39. package/dist/playground/dotnet.js +1131 -0
  40. package/dist/playground/duckdb.d.ts +36 -0
  41. package/dist/playground/duckdb.js +542 -0
  42. package/dist/playground/elixir.d.ts +18 -10
  43. package/dist/playground/elixir.js +630 -96
  44. package/dist/playground/elixirAssets.d.ts +6 -0
  45. package/dist/playground/elixirAssets.js +33 -0
  46. package/dist/playground/executionObservation.d.ts +22 -0
  47. package/dist/playground/executionObservation.js +65 -0
  48. package/dist/playground/forth.d.ts +5 -0
  49. package/dist/playground/forth.js +53 -0
  50. package/dist/playground/forthPreflight.d.ts +24 -0
  51. package/dist/playground/forthPreflight.js +198 -0
  52. package/dist/playground/fortran.d.ts +47 -0
  53. package/dist/playground/fortran.js +651 -0
  54. package/dist/playground/fortranAssets.d.ts +6 -0
  55. package/dist/playground/fortranAssets.js +27 -0
  56. package/dist/playground/gleam.d.ts +6 -0
  57. package/dist/playground/gleam.js +33 -0
  58. package/dist/playground/go.d.ts +17 -11
  59. package/dist/playground/go.js +376 -72
  60. package/dist/playground/goDebugInstrumentation.d.ts +1 -0
  61. package/dist/playground/goDebugInstrumentation.js +229 -0
  62. package/dist/playground/haskell.d.ts +44 -0
  63. package/dist/playground/haskell.js +678 -0
  64. package/dist/playground/haskellAssets.d.ts +24 -0
  65. package/dist/playground/haskellAssets.js +93 -0
  66. package/dist/playground/index.d.ts +1 -1
  67. package/dist/playground/index.js +360 -111
  68. package/dist/playground/j.d.ts +5 -0
  69. package/dist/playground/j.js +60 -0
  70. package/dist/playground/jPreflight.d.ts +26 -0
  71. package/dist/playground/jPreflight.js +372 -0
  72. package/dist/playground/janet.d.ts +5 -0
  73. package/dist/playground/janet.js +64 -0
  74. package/dist/playground/java.d.ts +24 -10
  75. package/dist/playground/java.js +706 -84
  76. package/dist/playground/javaSource.d.ts +5 -0
  77. package/dist/playground/javaSource.js +16 -0
  78. package/dist/playground/javaStdin.d.ts +1 -1
  79. package/dist/playground/javaStdin.js +13 -4
  80. package/dist/playground/julia.d.ts +5 -0
  81. package/dist/playground/julia.js +64 -0
  82. package/dist/playground/lfortran.d.ts +8 -0
  83. package/dist/playground/lfortran.js +30 -0
  84. package/dist/playground/lfortranAssets.d.ts +21 -0
  85. package/dist/playground/lfortranAssets.js +118 -0
  86. package/dist/playground/lisp.d.ts +45 -0
  87. package/dist/playground/lisp.js +640 -0
  88. package/dist/playground/lispAssets.d.ts +9 -0
  89. package/dist/playground/lispAssets.js +74 -0
  90. package/dist/playground/lldbManifest.d.ts +3 -0
  91. package/dist/playground/lldbManifest.js +155 -0
  92. package/dist/playground/lldbSession.d.ts +115 -0
  93. package/dist/playground/lldbSession.js +1347 -0
  94. package/dist/playground/loadingProgress.d.ts +16 -0
  95. package/dist/playground/loadingProgress.js +166 -0
  96. package/dist/playground/lua.d.ts +44 -0
  97. package/dist/playground/lua.js +630 -0
  98. package/dist/playground/nim.d.ts +5 -0
  99. package/dist/playground/nim.js +76 -0
  100. package/dist/playground/objectivec.d.ts +39 -0
  101. package/dist/playground/objectivec.js +288 -0
  102. package/dist/playground/ocaml.d.ts +28 -10
  103. package/dist/playground/ocaml.js +815 -253
  104. package/dist/playground/octave.d.ts +43 -0
  105. package/dist/playground/octave.js +783 -0
  106. package/dist/playground/options.d.ts +19 -40
  107. package/dist/playground/options.js +2 -1
  108. package/dist/playground/pascal.d.ts +5 -0
  109. package/dist/playground/pascal.js +60 -0
  110. package/dist/playground/perl.d.ts +5 -0
  111. package/dist/playground/perl.js +61 -0
  112. package/dist/playground/php.d.ts +44 -0
  113. package/dist/playground/php.js +665 -0
  114. package/dist/playground/prolog.d.ts +6 -0
  115. package/dist/playground/prolog.js +75 -0
  116. package/dist/playground/python.d.ts +20 -14
  117. package/dist/playground/python.js +445 -101
  118. package/dist/playground/pythonPackageLock.d.ts +6 -0
  119. package/dist/playground/pythonPackageLock.js +56 -0
  120. package/dist/playground/r.d.ts +44 -0
  121. package/dist/playground/r.js +637 -0
  122. package/dist/playground/ruby.d.ts +46 -0
  123. package/dist/playground/ruby.js +732 -0
  124. package/dist/playground/rubyAssets.d.ts +23 -0
  125. package/dist/playground/rubyAssets.js +68 -0
  126. package/dist/playground/rubyTestPreflight.d.ts +2 -0
  127. package/dist/playground/rubyTestPreflight.js +18 -0
  128. package/dist/playground/runtimeModule.d.ts +1 -0
  129. package/dist/playground/runtimeModule.js +5 -0
  130. package/dist/playground/rust.d.ts +44 -13
  131. package/dist/playground/rust.js +714 -76
  132. package/dist/playground/rustExecutableGraph.d.ts +85 -0
  133. package/dist/playground/rustExecutableGraph.js +946 -0
  134. package/dist/playground/rustWorkerLimits.d.ts +17 -0
  135. package/dist/playground/rustWorkerLimits.js +34 -0
  136. package/dist/playground/sandbox.d.ts +16 -10
  137. package/dist/playground/sharedBuffer.d.ts +6 -0
  138. package/dist/playground/sharedBuffer.js +12 -0
  139. package/dist/playground/sqlite.d.ts +38 -0
  140. package/dist/playground/sqlite.js +550 -0
  141. package/dist/playground/staticRuntimeModuleVersion.d.ts +1 -0
  142. package/dist/playground/staticRuntimeModuleVersion.js +2 -0
  143. package/dist/playground/staticRuntimePreflight.d.ts +13 -0
  144. package/dist/playground/staticRuntimePreflight.js +231 -0
  145. package/dist/playground/staticRuntimePreflightExecute.d.ts +8 -0
  146. package/dist/playground/staticRuntimePreflightExecute.js +66 -0
  147. package/dist/playground/staticRuntimePreflightProtocol.d.ts +68 -0
  148. package/dist/playground/staticRuntimePreflightProtocol.js +339 -0
  149. package/dist/playground/staticStdinRing.d.ts +45 -0
  150. package/dist/playground/staticStdinRing.js +158 -0
  151. package/dist/playground/staticWorkerRuntime.d.ts +154 -0
  152. package/dist/playground/staticWorkerRuntime.js +1917 -0
  153. package/dist/playground/stdinBuffer.d.ts +9 -7
  154. package/dist/playground/stdinBuffer.js +9 -18
  155. package/dist/playground/swift.d.ts +5 -0
  156. package/dist/playground/swift.js +17 -0
  157. package/dist/playground/tcl.d.ts +5 -0
  158. package/dist/playground/tcl.js +62 -0
  159. package/dist/playground/teavmConfig.d.ts +1 -1
  160. package/dist/playground/teavmConfig.js +2 -2
  161. package/dist/playground/tinygo.d.ts +48 -18
  162. package/dist/playground/tinygo.js +1202 -329
  163. package/dist/playground/tinygoExecutableGraph.d.ts +44 -0
  164. package/dist/playground/tinygoExecutableGraph.js +449 -0
  165. package/dist/playground/typescript.d.ts +55 -0
  166. package/dist/playground/typescript.js +924 -0
  167. package/dist/playground/wasm.d.ts +43 -0
  168. package/dist/playground/wasm.js +608 -0
  169. package/dist/playground/wasmAwkVersion.d.ts +59 -0
  170. package/dist/playground/wasmAwkVersion.js +31 -0
  171. package/dist/playground/wasmBashVersion.d.ts +63 -0
  172. package/dist/playground/wasmBashVersion.js +36 -0
  173. package/dist/playground/wasmBqnVersion.d.ts +24 -0
  174. package/dist/playground/wasmBqnVersion.js +24 -0
  175. package/dist/playground/wasmC3Version.d.ts +20 -0
  176. package/dist/playground/wasmC3Version.js +21 -0
  177. package/dist/playground/wasmClojureScriptVersion.d.ts +21 -0
  178. package/dist/playground/wasmClojureScriptVersion.js +21 -0
  179. package/dist/playground/wasmDIntegrity.d.ts +15 -0
  180. package/dist/playground/wasmDIntegrity.js +15 -0
  181. package/dist/playground/wasmDVersion.d.ts +1 -0
  182. package/dist/playground/wasmDVersion.js +1 -0
  183. package/dist/playground/wasmDebugVersion.d.ts +6 -0
  184. package/dist/playground/wasmDebugVersion.js +6 -0
  185. package/dist/playground/wasmDotnetVersion.d.ts +1 -0
  186. package/dist/playground/wasmDotnetVersion.js +1 -0
  187. package/dist/playground/wasmElixirVersion.d.ts +21 -1
  188. package/dist/playground/wasmElixirVersion.js +21 -1
  189. package/dist/playground/wasmForthVersion.d.ts +18 -0
  190. package/dist/playground/wasmForthVersion.js +18 -0
  191. package/dist/playground/wasmFortranExecutionAssets.d.ts +15 -0
  192. package/dist/playground/wasmFortranExecutionAssets.js +15 -0
  193. package/dist/playground/wasmFortranVersion.d.ts +1 -0
  194. package/dist/playground/wasmFortranVersion.js +1 -0
  195. package/dist/playground/wasmGleamVersion.d.ts +5 -0
  196. package/dist/playground/wasmGleamVersion.js +5 -0
  197. package/dist/playground/wasmGoVersion.d.ts +1 -1
  198. package/dist/playground/wasmGoVersion.js +1 -1
  199. package/dist/playground/wasmHaskellVersion.d.ts +1 -0
  200. package/dist/playground/wasmHaskellVersion.js +1 -0
  201. package/dist/playground/wasmJVersion.d.ts +24 -0
  202. package/dist/playground/wasmJVersion.js +24 -0
  203. package/dist/playground/wasmJanetVersion.d.ts +53 -0
  204. package/dist/playground/wasmJanetVersion.js +30 -0
  205. package/dist/playground/wasmJuliaVersion.d.ts +71 -0
  206. package/dist/playground/wasmJuliaVersion.js +39 -0
  207. package/dist/playground/wasmLfortranVersion.d.ts +28 -0
  208. package/dist/playground/wasmLfortranVersion.js +29 -0
  209. package/dist/playground/wasmLispVersion.d.ts +1 -0
  210. package/dist/playground/wasmLispVersion.js +1 -0
  211. package/dist/playground/wasmLuaVersion.d.ts +1 -0
  212. package/dist/playground/wasmLuaVersion.js +1 -0
  213. package/dist/playground/wasmNimVersion.d.ts +125 -0
  214. package/dist/playground/wasmNimVersion.js +66 -0
  215. package/dist/playground/wasmObjectiveCVersion.d.ts +27 -0
  216. package/dist/playground/wasmObjectiveCVersion.js +27 -0
  217. package/dist/playground/wasmOcamlVersion.d.ts +12 -1
  218. package/dist/playground/wasmOcamlVersion.js +12 -1
  219. package/dist/playground/wasmOctaveVersion.d.ts +1 -0
  220. package/dist/playground/wasmOctaveVersion.js +1 -0
  221. package/dist/playground/wasmPascalVersion.d.ts +61 -0
  222. package/dist/playground/wasmPascalVersion.js +34 -0
  223. package/dist/playground/wasmPerlVersion.d.ts +71 -0
  224. package/dist/playground/wasmPerlVersion.js +39 -0
  225. package/dist/playground/wasmPrologVersion.d.ts +31 -0
  226. package/dist/playground/wasmPrologVersion.js +31 -0
  227. package/dist/playground/wasmRVersion.d.ts +1 -0
  228. package/dist/playground/wasmRVersion.js +1 -0
  229. package/dist/playground/wasmRustVersion.d.ts +1306 -1
  230. package/dist/playground/wasmRustVersion.js +1458 -1
  231. package/dist/playground/wasmSwiftVersion.d.ts +1 -0
  232. package/dist/playground/wasmSwiftVersion.js +1 -0
  233. package/dist/playground/wasmTclVersion.d.ts +85 -0
  234. package/dist/playground/wasmTclVersion.js +46 -0
  235. package/dist/playground/wasmTinyGoVersion.d.ts +98 -1
  236. package/dist/playground/wasmTinyGoVersion.js +107 -1
  237. package/dist/playground/wasmTypeScriptVersion.d.ts +5 -0
  238. package/dist/playground/wasmTypeScriptVersion.js +5 -0
  239. package/dist/playground/wasmWatVersion.d.ts +1 -0
  240. package/dist/playground/wasmWatVersion.js +1 -0
  241. package/dist/playground/wasmZigVersion.d.ts +13 -0
  242. package/dist/playground/wasmZigVersion.js +13 -0
  243. package/dist/playground/wat.d.ts +44 -0
  244. package/dist/playground/wat.js +622 -0
  245. package/dist/playground/worker/assemblyscript.js +339 -0
  246. package/dist/playground/worker/assets.d.ts +7 -0
  247. package/dist/playground/worker/assets.js +288 -39
  248. package/dist/playground/worker/bash.js +338 -0
  249. package/dist/playground/worker/bashNestedBootstrap.d.ts +6 -0
  250. package/dist/playground/worker/bashNestedBootstrap.js +59 -0
  251. package/dist/playground/worker/bashRuntime.d.ts +89 -0
  252. package/dist/playground/worker/bashRuntime.js +982 -0
  253. package/dist/playground/worker/clang.js +92 -13
  254. package/dist/playground/worker/cobol.js +107 -0
  255. package/dist/playground/worker/d.js +199 -0
  256. package/dist/playground/worker/dotnet.js +141 -0
  257. package/dist/playground/worker/duckdb.d.ts +1 -0
  258. package/dist/playground/worker/duckdb.js +136 -0
  259. package/dist/playground/worker/elixir.js +307 -41
  260. package/dist/playground/worker/fortran.d.ts +1 -0
  261. package/dist/playground/worker/fortran.js +295 -0
  262. package/dist/playground/worker/go.js +246 -40
  263. package/dist/playground/worker/haskell.d.ts +7 -0
  264. package/dist/playground/worker/haskell.js +465 -0
  265. package/dist/playground/worker/java.js +59 -20
  266. package/dist/playground/worker/lisp.d.ts +1 -0
  267. package/dist/playground/worker/lisp.js +195 -0
  268. package/dist/playground/worker/lua.d.ts +1 -0
  269. package/dist/playground/worker/lua.js +163 -0
  270. package/dist/playground/worker/objectivec.d.ts +1 -0
  271. package/dist/playground/worker/objectivec.js +10 -0
  272. package/dist/playground/worker/ocaml.js +206 -58
  273. package/dist/playground/worker/php.d.ts +1 -0
  274. package/dist/playground/worker/php.js +261 -0
  275. package/dist/playground/worker/python.js +201 -44
  276. package/dist/playground/worker/r.d.ts +1 -0
  277. package/dist/playground/worker/r.js +192 -0
  278. package/dist/playground/worker/ruby.d.ts +1 -0
  279. package/dist/playground/worker/ruby.js +248 -0
  280. package/dist/playground/worker/runtimeAssetFetch.d.ts +15 -0
  281. package/dist/playground/worker/runtimeAssetFetch.js +375 -0
  282. package/dist/playground/worker/rust.js +546 -20
  283. package/dist/playground/worker/sqlite.d.ts +1 -0
  284. package/dist/playground/worker/sqlite.js +112 -0
  285. package/dist/playground/worker/staticRuntimePreflight.d.ts +1 -0
  286. package/dist/playground/worker/staticRuntimePreflight.js +56 -0
  287. package/dist/playground/worker/tinygo.js +34 -9
  288. package/dist/playground/worker/typescript.d.ts +1 -0
  289. package/dist/playground/worker/typescript.js +251 -0
  290. package/dist/playground/worker/wasm.d.ts +1 -0
  291. package/dist/playground/worker/wasm.js +273 -0
  292. package/dist/playground/worker/wat.d.ts +1 -0
  293. package/dist/playground/worker/wat.js +188 -0
  294. package/dist/playground/worker/zig.d.ts +8 -0
  295. package/dist/playground/worker/zig.js +578 -0
  296. package/dist/playground/workerProgress.d.ts +15 -0
  297. package/dist/playground/workerProgress.js +72 -0
  298. package/dist/playground/workerSession.d.ts +28 -0
  299. package/dist/playground/workerSession.js +164 -0
  300. package/dist/playground/zig.d.ts +46 -0
  301. package/dist/playground/zig.js +690 -0
  302. package/dist/playground/zigAssets.d.ts +6 -0
  303. package/dist/playground/zigAssets.js +49 -0
  304. package/package.json +234 -105
  305. package/dist/clang/app.d.ts +0 -75
  306. package/dist/clang/app.js +0 -744
  307. package/dist/clang/apply.d.ts +0 -2
  308. package/dist/clang/apply.js +0 -11
  309. package/dist/clang/color.d.ts +0 -3
  310. package/dist/clang/color.js +0 -3
  311. package/dist/clang/encode.d.ts +0 -4
  312. package/dist/clang/encode.js +0 -20
  313. package/dist/clang/error.d.ts +0 -14
  314. package/dist/clang/error.js +0 -27
  315. package/dist/clang/gccCompat.d.ts +0 -15
  316. package/dist/clang/gccCompat.js +0 -767
  317. package/dist/clang/index.d.ts +0 -85
  318. package/dist/clang/index.js +0 -1077
  319. package/dist/clang/memory/index.d.ts +0 -4
  320. package/dist/clang/memory/index.js +0 -4
  321. package/dist/clang/memory/memFs.d.ts +0 -35
  322. package/dist/clang/memory/memFs.js +0 -132
  323. package/dist/clang/memory/memory.d.ts +0 -22
  324. package/dist/clang/memory/memory.js +0 -73
  325. package/dist/clang/memory/tar.d.ts +0 -2
  326. package/dist/clang/memory/tar.js +0 -59
  327. package/dist/clang/url.d.ts +0 -4
  328. package/dist/clang/url.js +0 -5
  329. package/dist/clang/wasm.d.ts +0 -4
  330. package/dist/clang/wasm.js +0 -50
  331. package/dist/clangd/config.d.ts +0 -18
  332. package/dist/clangd/config.js +0 -14
  333. package/dist/clangd/jsonStream.d.ts +0 -9
  334. package/dist/clangd/jsonStream.js +0 -48
  335. package/dist/clangd/session.d.ts +0 -18
  336. package/dist/clangd/session.js +0 -112
  337. package/dist/clangd/worker.js +0 -131
  338. package/dist/debug/controller.svelte.d.ts +0 -43
  339. package/dist/debug/controller.svelte.js +0 -268
  340. package/dist/debug/editor/index.d.ts +0 -2
  341. package/dist/debug/editor/index.js +0 -1
  342. package/dist/debug/editor/monaco.d.ts +0 -26
  343. package/dist/debug/editor/monaco.js +0 -128
  344. package/dist/debug/expression.d.ts +0 -26
  345. package/dist/debug/expression.js +0 -547
  346. package/dist/debug/index.d.ts +0 -8
  347. package/dist/debug/index.js +0 -5
  348. package/dist/debug/language/cpp.d.ts +0 -2
  349. package/dist/debug/language/cpp.js +0 -7
  350. package/dist/debug/language/index.d.ts +0 -3
  351. package/dist/debug/language/index.js +0 -2
  352. package/dist/debug/language/python.d.ts +0 -2
  353. package/dist/debug/language/python.js +0 -14
  354. package/dist/debug/language/types.d.ts +0 -6
  355. package/dist/debug/locals.d.ts +0 -2
  356. package/dist/debug/locals.js +0 -8
  357. package/dist/lsp/cpp/server.d.ts +0 -2
  358. package/dist/lsp/cpp/server.js +0 -68
  359. package/dist/lsp/index.d.ts +0 -5
  360. package/dist/lsp/index.js +0 -4
  361. package/dist/lsp/python/main.worker.js +0 -92
  362. package/dist/lsp/python/package/arcturus_python_lsp/__init__.py +0 -3
  363. package/dist/lsp/python/package/arcturus_python_lsp/server.py +0 -462
  364. package/dist/lsp/python/server.d.ts +0 -2
  365. package/dist/lsp/python/server.js +0 -54
  366. package/dist/lsp/registry.d.ts +0 -2
  367. package/dist/lsp/registry.js +0 -12
  368. package/dist/lsp/runtime.d.ts +0 -5
  369. package/dist/lsp/runtime.js +0 -31
  370. package/dist/lsp/types.d.ts +0 -17
  371. package/dist/terminal/Terminal.svelte +0 -422
  372. package/dist/terminal/Terminal.svelte.d.ts +0 -26
  373. package/dist/terminal/index.d.ts +0 -7
  374. package/dist/terminal/index.js +0 -5
  375. package/dist/terminal/plugin/index.d.ts +0 -9
  376. package/dist/terminal/plugin/index.js +0 -19
  377. package/dist/terminal/theme.d.ts +0 -49
  378. package/dist/terminal/theme.js +0 -49
  379. package/dist/terminal/types.d.ts +0 -18
  380. package/dist/utils/vscodeJsonrpcBrowser.d.ts +0 -5
  381. package/dist/utils/vscodeJsonrpcBrowser.js +0 -4
  382. /package/dist/{clangd/worker.d.ts → playground/worker/assemblyscript.d.ts} +0 -0
  383. /package/dist/{debug/language/types.js → playground/worker/bash.d.ts} +0 -0
  384. /package/dist/{lsp/python/main.worker.d.ts → playground/worker/cobol.d.ts} +0 -0
  385. /package/dist/{lsp/types.js → playground/worker/d.d.ts} +0 -0
  386. /package/dist/{terminal/types.js → playground/worker/dotnet.d.ts} +0 -0
@@ -1,185 +1,158 @@
1
- import { env as publicEnv } from '$env/dynamic/public';
1
+ import { env as dynamicPublicEnv } from '$env/dynamic/public';
2
+ import { BUNDLED_CLANG_ASSET_INTEGRITY } from './clangAssetIntegrity';
3
+ import { snapshotDOuterAssetConfig } from './dOuterAssets';
4
+ import { snapshotFortranExecutionAssetReceipts } from './fortranAssets';
2
5
  import { normalizeTeaVmBaseUrl, resolveTeaVmBaseUrl } from './teavmConfig';
6
+ import { WASM_GLEAM_ASSET_VERSION, WASM_GLEAM_RUNNER_RECEIPT } from './wasmGleamVersion';
7
+ import { WASM_FORTH_ASSET_VERSION, WASM_FORTH_RUNTIME_PROFILE, WASM_FORTH_RUNNER_RECEIPT } from './wasmForthVersion';
8
+ import { WASM_BQN_ASSET_VERSION, WASM_BQN_RUNTIME_PROFILE, WASM_BQN_RUNNER_RECEIPT } from './wasmBqnVersion';
9
+ import { WASM_BASH_RUNTIME_BUNDLE } from './wasmBashVersion';
10
+ import { WASM_CLOJURESCRIPT_ASSET_VERSION, WASM_CLOJURESCRIPT_RUNNER_RECEIPT, WASM_CLOJURESCRIPT_RUNTIME_PROFILE } from './wasmClojureScriptVersion';
11
+ import { WASM_J_ASSET_VERSION, WASM_J_RUNNER_RECEIPT, WASM_J_RUNTIME_PROFILE } from './wasmJVersion';
12
+ import { WASM_JANET_RUNTIME_BUNDLE } from './wasmJanetVersion';
13
+ import { WASM_JULIA_RUNTIME_BUNDLE } from './wasmJuliaVersion';
14
+ import { WASM_LISP_ASSET_VERSION } from './wasmLispVersion';
15
+ import { WASM_NIM_RUNTIME_BUNDLE } from './wasmNimVersion';
16
+ import { WASM_PASCAL_RUNTIME_BUNDLE } from './wasmPascalVersion';
17
+ import { WASM_AWK_RUNTIME_BUNDLE } from './wasmAwkVersion';
18
+ import { WASM_PROLOG_ASSET_VERSION, WASM_PROLOG_RUNNER_RECEIPT, WASM_PROLOG_RUNTIME_PROFILE } from './wasmPrologVersion';
19
+ import { WASM_PERL_RUNTIME_BUNDLE } from './wasmPerlVersion';
20
+ import { WASM_TCL_RUNTIME_BUNDLE } from './wasmTclVersion';
21
+ import { WASM_TINYGO_EXECUTABLE_GRAPH_PROFILE } from './wasmTinyGoVersion';
22
+ import { WASM_OBJECTIVEC_ASSET_RECEIPTS } from './wasmObjectiveCVersion';
23
+ import { WASM_DEBUG_RUNTIME_PROFILE } from './wasmDebugVersion';
24
+ import { RUBY_RUNTIME_BUNDLE, RUBY_RUNTIME_MANIFEST_PATH, RUBY_RUNTIME_MODULE_STORAGE_PATH, RUBY_RUNTIME_WASM_STORAGE_PATH, TEAVM_RUNTIME_ASSET_NAMES, TEAVM_RUNTIME_ASSET_RECEIPTS, RuntimeConfigurationError, snapshotBashRuntimePreflightProfile, snapshotAwkRuntimePreflightProfile, snapshotJanetRuntimePreflightProfile, snapshotJuliaRuntimePreflightProfile, snapshotNimRuntimePreflightProfile, snapshotPascalRuntimePreflightProfile, snapshotPerlRuntimePreflightProfile, snapshotPrologRuntimePreflightProfile, snapshotRubyRuntimePreflightProfile, snapshotTclRuntimePreflightProfile, snapshotTeaVmRuntimeAssetReceipts } from '@wasm-idle/core';
25
+ import { WASM_FORTRAN_EXECUTION_ASSET_RECEIPTS } from './wasmFortranExecutionAssets';
26
+ import { WASM_D_OUTER_ASSET_RECEIPTS } from './wasmDIntegrity';
27
+ import { WASM_ZIG_ASSET_RECEIPTS } from './wasmZigVersion';
28
+ import { snapshotZigExecutionAssetReceipts } from './zigAssets';
29
+ const publicEnv = (dynamicPublicEnv || {});
3
30
  export const PYTHON_RUNTIME_LOAD_ASSETS = [
31
+ 'pyodide.mjs',
4
32
  'pyodide.asm.js',
5
33
  'pyodide-lock.json',
6
34
  'pyodide.asm.wasm',
7
35
  'python_stdlib.zip'
8
36
  ];
9
- export const JAVA_RUNTIME_LOAD_ASSETS = [
10
- 'compiler.wasm-runtime.js',
11
- 'compiler.wasm',
12
- 'compile-classlib-teavm.bin',
13
- 'runtime-classlib-teavm.bin'
14
- ];
37
+ export const JAVA_RUNTIME_LOAD_ASSETS = TEAVM_RUNTIME_ASSET_NAMES;
15
38
  export const CLANG_RUNTIME_LOAD_ASSETS = [
16
- 'bin/memfs.zip',
17
- 'bin/clang.zip',
18
- 'bin/lld.zip',
19
- 'bin/sysroot.tar.zip'
39
+ 'runtime-manifest.v1.json',
40
+ 'bin/memfs.wasm.gz',
41
+ 'bin/clang.wasm.gz',
42
+ 'bin/lld.wasm.gz',
43
+ 'bin/sysroot.tar.gz'
20
44
  ];
21
45
  export const CLANGD_RUNTIME_LOAD_ASSETS = ['clangd.js', 'clangd.wasm.gz'];
22
- const PYTHON_VIRTUAL_BASE_URL = 'https://wasm-idle.invalid/python/';
23
- const JAVA_VIRTUAL_BASE_URL = 'https://wasm-idle.invalid/java/';
24
- const CLANG_VIRTUAL_BASE_URL = 'https://wasm-idle.invalid/clang/';
25
- const CLANGD_VIRTUAL_BASE_URL = 'https://wasm-idle.invalid/clangd/';
46
+ export const RUNTIME_LOAD_ASSETS = {
47
+ python: PYTHON_RUNTIME_LOAD_ASSETS,
48
+ java: JAVA_RUNTIME_LOAD_ASSETS,
49
+ clang: CLANG_RUNTIME_LOAD_ASSETS,
50
+ clangd: CLANGD_RUNTIME_LOAD_ASSETS
51
+ };
26
52
  const normalizeBaseUrl = (baseUrl, currentUrl = '') => {
27
53
  const normalized = baseUrl.endsWith('/') ? baseUrl : `${baseUrl}/`;
28
54
  return currentUrl ? new URL(normalized, currentUrl).href : normalized;
29
55
  };
30
56
  const resolveConfiguredUrl = (url, currentUrl = '') => currentUrl ? new URL(url, currentUrl).href : url;
31
- const normalizeRootUrl = (rootUrl) => rootUrl.endsWith('/') ? rootUrl.slice(0, -1) : rootUrl;
32
- const resolvePythonBaseUrl = (rootUrl = '', currentUrl = '') => normalizeBaseUrl(`${normalizeRootUrl(rootUrl) || ''}/pyodide/`, currentUrl);
33
- const resolvePythonRuntimeAssetConfig = (options, currentUrl = '') => {
34
- if (typeof options === 'string') {
35
- return {
36
- baseUrl: resolvePythonBaseUrl(options, currentUrl),
37
- useAssetBridge: false
38
- };
39
- }
40
- const runtimeConfig = options?.python;
41
- if (runtimeConfig?.baseUrl) {
42
- return {
43
- baseUrl: normalizeBaseUrl(runtimeConfig.baseUrl, currentUrl),
44
- loader: runtimeConfig.loader,
45
- useAssetBridge: !!runtimeConfig.loader
46
- };
47
- }
48
- if (options?.rootUrl) {
49
- return {
50
- baseUrl: resolvePythonBaseUrl(options.rootUrl, currentUrl),
51
- loader: runtimeConfig?.loader,
52
- useAssetBridge: !!runtimeConfig?.loader
53
- };
57
+ const resolveAllowedBaseUrls = (urls, currentUrl = '') => urls?.map((url) => normalizeBaseUrl(url, currentUrl));
58
+ const useAssetBridgeForConfig = (config, integrity = config?.integrity) => !!config?.loader || !!integrity || !!config?.allowedBaseUrls?.length;
59
+ const resolveRuntimeAssetIntegrity = (runtime, config) => {
60
+ if (runtime === 'java') {
61
+ return snapshotTeaVmRuntimeAssetReceipts(config?.integrity === undefined ? TEAVM_RUNTIME_ASSET_RECEIPTS : config.integrity);
54
62
  }
55
- if (runtimeConfig?.loader) {
56
- return {
57
- baseUrl: PYTHON_VIRTUAL_BASE_URL,
58
- loader: runtimeConfig.loader,
59
- useAssetBridge: true
60
- };
63
+ if (config?.integrity)
64
+ return config.integrity;
65
+ if (runtime === 'clang' && !config?.baseUrl && !config?.loader) {
66
+ return BUNDLED_CLANG_ASSET_INTEGRITY;
61
67
  }
62
- return {
63
- baseUrl: resolvePythonBaseUrl('', currentUrl),
64
- useAssetBridge: false
65
- };
68
+ return undefined;
66
69
  };
67
- const resolveJavaBaseUrl = (rootUrl = '', currentUrl = '') => resolveTeaVmBaseUrl(rootUrl, currentUrl);
68
- const resolveJavaRuntimeAssetConfig = (options, currentUrl = '') => {
69
- if (typeof options === 'string') {
70
- return {
71
- baseUrl: resolveJavaBaseUrl(options, currentUrl),
72
- useAssetBridge: false
73
- };
74
- }
75
- const runtimeConfig = options?.java;
76
- if (runtimeConfig?.baseUrl) {
77
- return {
78
- baseUrl: currentUrl
79
- ? new URL(normalizeTeaVmBaseUrl(runtimeConfig.baseUrl), currentUrl).href
80
- : normalizeTeaVmBaseUrl(runtimeConfig.baseUrl),
81
- loader: runtimeConfig.loader,
82
- useAssetBridge: !!runtimeConfig.loader
83
- };
84
- }
85
- if (options?.rootUrl) {
86
- return {
87
- baseUrl: resolveJavaBaseUrl(options.rootUrl, currentUrl),
88
- loader: runtimeConfig?.loader,
89
- useAssetBridge: !!runtimeConfig?.loader
90
- };
91
- }
92
- if (runtimeConfig?.loader) {
93
- return {
94
- baseUrl: JAVA_VIRTUAL_BASE_URL,
95
- loader: runtimeConfig.loader,
96
- useAssetBridge: true
97
- };
70
+ const normalizeRootUrl = (rootUrl) => rootUrl.endsWith('/') ? rootUrl.slice(0, -1) : rootUrl;
71
+ const resolveFolderRuntimeBaseUrl = (folder, rootUrl = '', currentUrl = '') => normalizeBaseUrl(rootUrl ? `${normalizeRootUrl(rootUrl) || ''}/${folder}/` : `${folder}/`, currentUrl);
72
+ const normalizeTeaVmConfiguredBaseUrl = (baseUrl, currentUrl = '') => currentUrl
73
+ ? new URL(normalizeTeaVmBaseUrl(baseUrl), currentUrl).href
74
+ : normalizeTeaVmBaseUrl(baseUrl);
75
+ const RUNTIME_ASSET_FOLDERS = {
76
+ python: {
77
+ folder: 'pyodide',
78
+ virtualBaseUrl: 'https://wasm-idle.invalid/python/'
79
+ },
80
+ java: {
81
+ folder: 'teavm',
82
+ virtualBaseUrl: 'https://wasm-idle.invalid/java/',
83
+ resolveRootBaseUrl: (rootUrl, currentUrl) => {
84
+ const configuredBaseUrl = (publicEnv.PUBLIC_TEAVM_BASE_URL || '').trim();
85
+ return configuredBaseUrl || rootUrl
86
+ ? resolveTeaVmBaseUrl(rootUrl, currentUrl, configuredBaseUrl)
87
+ : normalizeBaseUrl('teavm/', currentUrl);
88
+ },
89
+ resolveConfiguredBaseUrl: normalizeTeaVmConfiguredBaseUrl
90
+ },
91
+ clang: {
92
+ folder: 'clang',
93
+ virtualBaseUrl: 'https://wasm-idle.invalid/clang/'
94
+ },
95
+ clangd: {
96
+ folder: 'clangd',
97
+ virtualBaseUrl: 'https://wasm-idle.invalid/clangd/'
98
98
  }
99
- return {
100
- baseUrl: resolveJavaBaseUrl('', currentUrl),
101
- useAssetBridge: false
102
- };
103
99
  };
104
- const resolveClangRuntimeAssetConfig = (options, currentUrl = '') => {
100
+ const resolveRuntimeRootBaseUrl = (config, rootUrl = '', currentUrl = '') => config.resolveRootBaseUrl?.(rootUrl, currentUrl) ||
101
+ resolveFolderRuntimeBaseUrl(config.folder, rootUrl, currentUrl);
102
+ const resolveRuntimeConfiguredBaseUrl = (config, baseUrl, currentUrl = '') => config.resolveConfiguredBaseUrl?.(baseUrl, currentUrl) || normalizeBaseUrl(baseUrl, currentUrl);
103
+ export function resolveRuntimeAssetConfig(runtime, options, currentUrl = '') {
104
+ const runtimeFolder = RUNTIME_ASSET_FOLDERS[runtime];
105
105
  if (typeof options === 'string') {
106
+ const integrity = resolveRuntimeAssetIntegrity(runtime, undefined);
106
107
  return {
107
- baseUrl: normalizeBaseUrl(`${normalizeRootUrl(options) || ''}/clang/`, currentUrl),
108
- useAssetBridge: false
108
+ baseUrl: resolveRuntimeRootBaseUrl(runtimeFolder, options, currentUrl),
109
+ ...(integrity ? { integrity } : {}),
110
+ useAssetBridge: !!integrity
109
111
  };
110
112
  }
111
- const runtimeConfig = options?.clang;
113
+ const runtimeConfig = options?.[runtime];
114
+ const integrity = resolveRuntimeAssetIntegrity(runtime, runtimeConfig);
115
+ const allowedBaseUrls = resolveAllowedBaseUrls(runtimeConfig?.allowedBaseUrls, currentUrl);
112
116
  if (runtimeConfig?.baseUrl) {
113
117
  return {
114
- baseUrl: normalizeBaseUrl(runtimeConfig.baseUrl, currentUrl),
118
+ baseUrl: resolveRuntimeConfiguredBaseUrl(runtimeFolder, runtimeConfig.baseUrl, currentUrl),
115
119
  loader: runtimeConfig.loader,
116
- useAssetBridge: !!runtimeConfig.loader
120
+ integrity,
121
+ allowedBaseUrls,
122
+ useAssetBridge: useAssetBridgeForConfig(runtimeConfig, integrity)
117
123
  };
118
124
  }
119
125
  if (options?.rootUrl) {
120
126
  return {
121
- baseUrl: normalizeBaseUrl(`${normalizeRootUrl(options.rootUrl) || ''}/clang/`, currentUrl),
127
+ baseUrl: resolveRuntimeRootBaseUrl(runtimeFolder, options.rootUrl, currentUrl),
122
128
  loader: runtimeConfig?.loader,
123
- useAssetBridge: !!runtimeConfig?.loader
129
+ integrity,
130
+ allowedBaseUrls,
131
+ useAssetBridge: useAssetBridgeForConfig(runtimeConfig, integrity)
124
132
  };
125
133
  }
126
134
  if (runtimeConfig?.loader) {
127
135
  return {
128
- baseUrl: CLANG_VIRTUAL_BASE_URL,
136
+ baseUrl: runtimeFolder.virtualBaseUrl,
129
137
  loader: runtimeConfig.loader,
138
+ integrity,
139
+ allowedBaseUrls,
130
140
  useAssetBridge: true
131
141
  };
132
142
  }
133
- return {
134
- baseUrl: normalizeBaseUrl('/clang/', currentUrl),
135
- useAssetBridge: false
136
- };
137
- };
138
- const resolveClangdRuntimeAssetConfig = (options, currentUrl = '') => {
139
- if (typeof options === 'string') {
140
- return {
141
- baseUrl: normalizeBaseUrl(`${normalizeRootUrl(options) || ''}/clangd/`, currentUrl),
142
- useAssetBridge: false
143
- };
144
- }
145
- const runtimeConfig = options?.clangd;
146
- if (runtimeConfig?.baseUrl) {
147
- return {
148
- baseUrl: normalizeBaseUrl(runtimeConfig.baseUrl, currentUrl),
149
- loader: runtimeConfig.loader,
150
- useAssetBridge: !!runtimeConfig.loader
151
- };
152
- }
153
- if (options?.rootUrl) {
154
- return {
155
- baseUrl: normalizeBaseUrl(`${normalizeRootUrl(options.rootUrl) || ''}/clangd/`, currentUrl),
156
- loader: runtimeConfig?.loader,
157
- useAssetBridge: !!runtimeConfig?.loader
158
- };
159
- }
160
- if (runtimeConfig?.loader) {
143
+ if (runtimeConfig?.integrity || runtimeConfig?.allowedBaseUrls?.length) {
161
144
  return {
162
- baseUrl: CLANGD_VIRTUAL_BASE_URL,
163
- loader: runtimeConfig.loader,
145
+ baseUrl: resolveRuntimeRootBaseUrl(runtimeFolder, '', currentUrl),
146
+ integrity,
147
+ allowedBaseUrls,
164
148
  useAssetBridge: true
165
149
  };
166
150
  }
167
151
  return {
168
- baseUrl: normalizeBaseUrl('/clangd/', currentUrl),
169
- useAssetBridge: false
152
+ baseUrl: resolveRuntimeRootBaseUrl(runtimeFolder, '', currentUrl),
153
+ ...(integrity ? { integrity } : {}),
154
+ useAssetBridge: !!integrity
170
155
  };
171
- };
172
- export function resolveRuntimeAssetConfig(runtime, options, currentUrl = '') {
173
- switch (runtime) {
174
- case 'python':
175
- return resolvePythonRuntimeAssetConfig(options, currentUrl);
176
- case 'java':
177
- return resolveJavaRuntimeAssetConfig(options, currentUrl);
178
- case 'clang':
179
- return resolveClangRuntimeAssetConfig(options, currentUrl);
180
- case 'clangd':
181
- return resolveClangdRuntimeAssetConfig(options, currentUrl);
182
- }
183
156
  }
184
157
  export function resolveRustCompilerUrl(options, currentUrl = '') {
185
158
  const configuredCompilerUrl = (typeof options === 'object' && options?.rust?.compilerUrl) ||
@@ -188,6 +161,58 @@ export function resolveRustCompilerUrl(options, currentUrl = '') {
188
161
  return '';
189
162
  return currentUrl ? new URL(configuredCompilerUrl, currentUrl).href : configuredCompilerUrl;
190
163
  }
164
+ export function resolveDebugRuntimeUrls(options, currentUrl = '') {
165
+ const configuredDebug = typeof options === 'object' ? options?.debug : undefined;
166
+ const publicBaseUrl = (publicEnv.PUBLIC_WASM_DEBUG_RUNTIME_URL || '').trim();
167
+ const configuredBaseUrl = configuredDebug?.baseUrl || publicBaseUrl;
168
+ const rootUrl = (typeof options === 'string' ? options : options?.rootUrl) || '';
169
+ const bundledBaseUrl = resolveFolderRuntimeBaseUrl('wasm-debug', rootUrl, currentUrl);
170
+ const baseUrl = configuredBaseUrl
171
+ ? normalizeBaseUrl(configuredBaseUrl, currentUrl)
172
+ : bundledBaseUrl;
173
+ const configuredManifestUrl = configuredDebug?.manifestUrl;
174
+ const manifestUrl = configuredManifestUrl
175
+ ? resolveConfiguredUrl(configuredManifestUrl, currentUrl)
176
+ : new URL('runtime-manifest.v2.json', baseUrl).href;
177
+ const bundledManifestUrl = new URL('runtime-manifest.v2.json', bundledBaseUrl).href;
178
+ const explicitManifestSha256 = (configuredDebug
179
+ ? configuredDebug.manifestSha256
180
+ : publicEnv.PUBLIC_WASM_DEBUG_RUNTIME_MANIFEST_SHA256)?.trim();
181
+ const manifestReceipt = explicitManifestSha256
182
+ ? Object.freeze({ sha256: explicitManifestSha256 })
183
+ : baseUrl === bundledBaseUrl && manifestUrl === bundledManifestUrl
184
+ ? WASM_DEBUG_RUNTIME_PROFILE.manifestReceipt
185
+ : undefined;
186
+ return {
187
+ baseUrl,
188
+ manifestUrl,
189
+ manifestReceipt
190
+ };
191
+ }
192
+ export function resolveRustDebugModuleUrl(options, currentUrl = '') {
193
+ const configuredDebugModuleUrl = typeof options === 'object' ? options?.rust?.debugModuleUrl : undefined;
194
+ if (configuredDebugModuleUrl) {
195
+ return currentUrl
196
+ ? new URL(configuredDebugModuleUrl, currentUrl).href
197
+ : configuredDebugModuleUrl;
198
+ }
199
+ const compilerUrl = resolveRustCompilerUrl(options, currentUrl);
200
+ if (!compilerUrl)
201
+ return '';
202
+ try {
203
+ const compiler = currentUrl ? new URL(compilerUrl, currentUrl) : new URL(compilerUrl);
204
+ const debugModule = new URL('./debug-instrumenter.js', compiler);
205
+ debugModule.search = compiler.search;
206
+ return debugModule.href;
207
+ }
208
+ catch {
209
+ const queryIndex = compilerUrl.indexOf('?');
210
+ const path = queryIndex >= 0 ? compilerUrl.slice(0, queryIndex) : compilerUrl;
211
+ const query = queryIndex >= 0 ? compilerUrl.slice(queryIndex) : '';
212
+ const slashIndex = path.lastIndexOf('/');
213
+ return `${slashIndex >= 0 ? path.slice(0, slashIndex + 1) : ''}debug-instrumenter.js${query}`;
214
+ }
215
+ }
191
216
  export function resolveGoCompilerUrl(options, currentUrl = '') {
192
217
  const configuredCompilerUrl = (typeof options === 'object' && options?.go?.compilerUrl) ||
193
218
  (publicEnv.PUBLIC_WASM_GO_COMPILER_URL || '').trim();
@@ -195,6 +220,57 @@ export function resolveGoCompilerUrl(options, currentUrl = '') {
195
220
  return '';
196
221
  return currentUrl ? new URL(configuredCompilerUrl, currentUrl).href : configuredCompilerUrl;
197
222
  }
223
+ export function resolveDModuleUrl(options, currentUrl = '') {
224
+ const configuredModuleUrl = (typeof options === 'object' && options?.d?.moduleUrl) ||
225
+ (publicEnv.PUBLIC_WASM_D_MODULE_URL || '').trim();
226
+ if (configuredModuleUrl) {
227
+ return resolveConfiguredUrl(configuredModuleUrl, currentUrl);
228
+ }
229
+ if (typeof options === 'string') {
230
+ return resolveConfiguredUrl(`${normalizeRootUrl(options) || ''}/wasm-d/index.js`, currentUrl);
231
+ }
232
+ if (options?.rootUrl) {
233
+ return resolveConfiguredUrl(`${normalizeRootUrl(options.rootUrl) || ''}/wasm-d/index.js`, currentUrl);
234
+ }
235
+ return '';
236
+ }
237
+ export function resolveDRuntimeAssetConfig(options, currentUrl = '') {
238
+ const moduleUrl = resolveDModuleUrl(options, currentUrl);
239
+ if (!moduleUrl) {
240
+ throw new TypeError('D runtime is not configured. Set PUBLIC_WASM_D_MODULE_URL or runtimeAssets.d.moduleUrl.');
241
+ }
242
+ const configuredManifestUrl = (typeof options === 'object' && options?.d?.manifestUrl) ||
243
+ (publicEnv.PUBLIC_WASM_D_MANIFEST_URL || '').trim();
244
+ let manifestUrl;
245
+ if (configuredManifestUrl) {
246
+ manifestUrl = resolveConfiguredUrl(configuredManifestUrl, currentUrl);
247
+ }
248
+ else {
249
+ const module = new URL(moduleUrl);
250
+ const manifest = new URL('runtime/runtime-manifest.v1.json', module);
251
+ manifest.search = module.search;
252
+ manifestUrl = manifest.href;
253
+ }
254
+ return snapshotDOuterAssetConfig({
255
+ moduleUrl,
256
+ manifestUrl,
257
+ integrity: (typeof options === 'object' && options?.d?.integrity) || WASM_D_OUTER_ASSET_RECEIPTS
258
+ });
259
+ }
260
+ export function resolveDotnetModuleUrl(options, currentUrl = '') {
261
+ const configuredModuleUrl = (typeof options === 'object' && options?.dotnet?.moduleUrl) ||
262
+ (publicEnv.PUBLIC_WASM_DOTNET_MODULE_URL || '').trim();
263
+ if (configuredModuleUrl) {
264
+ return resolveConfiguredUrl(configuredModuleUrl, currentUrl);
265
+ }
266
+ if (typeof options === 'string') {
267
+ return resolveConfiguredUrl(`${normalizeRootUrl(options) || ''}/wasm-dotnet/index.js`, currentUrl);
268
+ }
269
+ if (options?.rootUrl) {
270
+ return resolveConfiguredUrl(`${normalizeRootUrl(options.rootUrl) || ''}/wasm-dotnet/index.js`, currentUrl);
271
+ }
272
+ return '';
273
+ }
198
274
  export function resolveOcamlModuleUrl(options, currentUrl = '') {
199
275
  const configuredModuleUrl = (typeof options === 'object' && options?.ocaml?.moduleUrl) ||
200
276
  (publicEnv.PUBLIC_WASM_OCAML_MODULE_URL || '').trim();
@@ -251,51 +327,92 @@ function deriveTinyGoModuleUrlFromAppUrl(appUrl, currentUrl = '') {
251
327
  const [withoutQuery, query = ''] = withoutHash.split('?', 2);
252
328
  let moduleUrlPath = withoutQuery;
253
329
  if (moduleUrlPath.endsWith('/index.html')) {
254
- moduleUrlPath = `${moduleUrlPath.slice(0, -'index.html'.length)}runtime.js`;
330
+ moduleUrlPath = `${moduleUrlPath.slice(0, -'index.html'.length)}upstream.js`;
255
331
  }
256
332
  else if (moduleUrlPath.endsWith('/')) {
257
- moduleUrlPath = `${moduleUrlPath}runtime.js`;
333
+ moduleUrlPath = `${moduleUrlPath}upstream.js`;
258
334
  }
259
335
  else {
260
- moduleUrlPath = `${moduleUrlPath.replace(/\/$/, '')}/runtime.js`;
336
+ moduleUrlPath = `${moduleUrlPath.replace(/\/$/, '')}/upstream.js`;
261
337
  }
262
338
  return `${moduleUrlPath}${query ? `?${query}` : ''}${hash ? `#${hash}` : ''}`;
263
339
  }
340
+ function pinTinyGoExecutableModuleUrl(moduleUrl, currentUrl = '') {
341
+ const entryReceipt = WASM_TINYGO_EXECUTABLE_GRAPH_PROFILE.modules[WASM_TINYGO_EXECUTABLE_GRAPH_PROFILE.entryPath];
342
+ if (!entryReceipt) {
343
+ throw new RuntimeConfigurationError('TinyGo executable graph entry receipt is missing', {
344
+ phase: 'asset',
345
+ runtimeId: 'TINYGO'
346
+ });
347
+ }
348
+ let parsed;
349
+ try {
350
+ parsed = currentUrl ? new URL(moduleUrl, currentUrl) : new URL(moduleUrl);
351
+ }
352
+ catch {
353
+ // Relative URLs without a current document stay relative until browser resolution.
354
+ }
355
+ if (parsed?.protocol === 'http:' || parsed?.protocol === 'https:') {
356
+ if (parsed.username || parsed.password || parsed.hash) {
357
+ throw new RuntimeConfigurationError('TinyGo executable module URL is unsafe', {
358
+ phase: 'asset',
359
+ runtimeId: 'TINYGO'
360
+ });
361
+ }
362
+ const receiptQuery = `?v=${entryReceipt.sha256}`;
363
+ if (parsed.search && parsed.search !== receiptQuery) {
364
+ throw new RuntimeConfigurationError('TinyGo executable module URL must use its exact receipt query pin', { phase: 'asset', runtimeId: 'TINYGO' });
365
+ }
366
+ parsed.search = receiptQuery;
367
+ return parsed.href;
368
+ }
369
+ if (!parsed) {
370
+ const [withoutHash, hash = ''] = moduleUrl.split('#', 2);
371
+ const [withoutQuery, query = ''] = withoutHash.split('?', 2);
372
+ if (hash || (query && query !== `v=${entryReceipt.sha256}`)) {
373
+ throw new RuntimeConfigurationError('TinyGo executable module URL must use its exact receipt query pin', { phase: 'asset', runtimeId: 'TINYGO' });
374
+ }
375
+ return `${withoutQuery}?v=${entryReceipt.sha256}`;
376
+ }
377
+ return moduleUrl;
378
+ }
264
379
  export function resolveTinyGoModuleUrl(options, currentUrl = '') {
265
380
  const configuredModuleUrl = (typeof options === 'object' && options?.tinygo?.moduleUrl) ||
266
381
  (publicEnv.PUBLIC_WASM_TINYGO_MODULE_URL || '').trim();
267
382
  if (configuredModuleUrl) {
268
- return resolveConfiguredUrl(configuredModuleUrl, currentUrl);
383
+ return pinTinyGoExecutableModuleUrl(resolveConfiguredUrl(configuredModuleUrl, currentUrl), currentUrl);
269
384
  }
270
385
  const configuredLegacyAppUrl = (typeof options === 'object' && options?.tinygo?.appUrl) ||
271
386
  (publicEnv.PUBLIC_WASM_TINYGO_APP_URL || '').trim();
272
387
  if (configuredLegacyAppUrl) {
273
- return deriveTinyGoModuleUrlFromAppUrl(configuredLegacyAppUrl, currentUrl);
388
+ return pinTinyGoExecutableModuleUrl(deriveTinyGoModuleUrlFromAppUrl(configuredLegacyAppUrl, currentUrl), currentUrl);
274
389
  }
275
390
  if (typeof options === 'string') {
276
- return resolveConfiguredUrl(`${normalizeRootUrl(options) || ''}/wasm-tinygo/runtime.js`, currentUrl);
391
+ return pinTinyGoExecutableModuleUrl(resolveConfiguredUrl(`${normalizeRootUrl(options) || ''}/wasm-tinygo/upstream.js`, currentUrl), currentUrl);
277
392
  }
278
393
  if (options?.rootUrl) {
279
- return resolveConfiguredUrl(`${normalizeRootUrl(options.rootUrl) || ''}/wasm-tinygo/runtime.js`, currentUrl);
394
+ return pinTinyGoExecutableModuleUrl(resolveConfiguredUrl(`${normalizeRootUrl(options.rootUrl) || ''}/wasm-tinygo/upstream.js`, currentUrl), currentUrl);
280
395
  }
281
396
  return '';
282
397
  }
283
- export function resolveTinyGoHostCompileUrls(options, currentUrl = '') {
284
- if (typeof options === 'object' && options?.tinygo?.disableHostCompile) {
285
- return [];
398
+ export function resolveElixirBundleUrl(options, currentUrl = '') {
399
+ const configuredBundleUrl = (typeof options === 'object' && options?.elixir?.bundleUrl) ||
400
+ (publicEnv.PUBLIC_WASM_ELIXIR_BUNDLE_URL || '').trim();
401
+ if (configuredBundleUrl) {
402
+ return resolveConfiguredUrl(configuredBundleUrl, currentUrl);
286
403
  }
287
- const configuredHostCompileUrl = (typeof options === 'object' && options?.tinygo?.hostCompileUrl) ||
288
- (publicEnv.PUBLIC_WASM_TINYGO_HOST_COMPILE_URL || '').trim();
289
- if (configuredHostCompileUrl) {
290
- return [resolveConfiguredUrl(configuredHostCompileUrl, currentUrl)];
404
+ if (typeof options === 'string') {
405
+ return resolveConfiguredUrl(`${normalizeRootUrl(options) || ''}/wasm-elixir/bundle.avm`, currentUrl);
291
406
  }
292
- return [];
293
- }
294
- export function resolveTinyGoHostCompileUrl(options, currentUrl = '') {
295
- return resolveTinyGoHostCompileUrls(options, currentUrl)[0] || '';
407
+ if (options?.rootUrl) {
408
+ return resolveConfiguredUrl(`${normalizeRootUrl(options.rootUrl) || ''}/wasm-elixir/bundle.avm`, currentUrl);
409
+ }
410
+ return '';
296
411
  }
297
- export function resolveElixirBundleUrl(options, currentUrl = '') {
298
- const configuredBundleUrl = (typeof options === 'object' && options?.elixir?.bundleUrl) ||
412
+ export function resolveErlangBundleUrl(options, currentUrl = '') {
413
+ const configuredBundleUrl = (typeof options === 'object' && options?.erlang?.bundleUrl) ||
414
+ (publicEnv.PUBLIC_WASM_ERLANG_BUNDLE_URL || '').trim() ||
415
+ (typeof options === 'object' && options?.elixir?.bundleUrl) ||
299
416
  (publicEnv.PUBLIC_WASM_ELIXIR_BUNDLE_URL || '').trim();
300
417
  if (configuredBundleUrl) {
301
418
  return resolveConfiguredUrl(configuredBundleUrl, currentUrl);
@@ -308,3 +425,1826 @@ export function resolveElixirBundleUrl(options, currentUrl = '') {
308
425
  }
309
426
  return '';
310
427
  }
428
+ export function resolveTypeScriptModuleUrl(options, currentUrl = '') {
429
+ const configuredModuleUrl = (typeof options === 'object' && options?.typescript?.moduleUrl) ||
430
+ (publicEnv.PUBLIC_WASM_TYPESCRIPT_MODULE_URL || '').trim();
431
+ if (configuredModuleUrl) {
432
+ return resolveConfiguredUrl(configuredModuleUrl, currentUrl);
433
+ }
434
+ if (typeof options === 'string') {
435
+ return resolveConfiguredUrl(`${normalizeRootUrl(options) || ''}/wasm-typescript/index.js`, currentUrl);
436
+ }
437
+ if (options?.rootUrl) {
438
+ return resolveConfiguredUrl(`${normalizeRootUrl(options.rootUrl) || ''}/wasm-typescript/index.js`, currentUrl);
439
+ }
440
+ return '';
441
+ }
442
+ export function resolveWatModuleUrl(options, currentUrl = '') {
443
+ const configuredModuleUrl = (typeof options === 'object' && options?.wat?.moduleUrl) ||
444
+ (publicEnv.PUBLIC_WASM_WAT_MODULE_URL || '').trim();
445
+ if (configuredModuleUrl) {
446
+ return resolveConfiguredUrl(configuredModuleUrl, currentUrl);
447
+ }
448
+ if (typeof options === 'string') {
449
+ return resolveConfiguredUrl(`${normalizeRootUrl(options) || ''}/wasm-wat/index.js`, currentUrl);
450
+ }
451
+ if (options?.rootUrl) {
452
+ return resolveConfiguredUrl(`${normalizeRootUrl(options.rootUrl) || ''}/wasm-wat/index.js`, currentUrl);
453
+ }
454
+ return '';
455
+ }
456
+ export function resolveLuaModuleUrl(options, currentUrl = '') {
457
+ const configuredModuleUrl = (typeof options === 'object' && options?.lua?.moduleUrl) ||
458
+ (publicEnv.PUBLIC_WASM_LUA_MODULE_URL || '').trim();
459
+ if (configuredModuleUrl) {
460
+ return resolveConfiguredUrl(configuredModuleUrl, currentUrl);
461
+ }
462
+ if (typeof options === 'string') {
463
+ return resolveConfiguredUrl(`${normalizeRootUrl(options) || ''}/wasm-lua/index.js`, currentUrl);
464
+ }
465
+ if (options?.rootUrl) {
466
+ return resolveConfiguredUrl(`${normalizeRootUrl(options.rootUrl) || ''}/wasm-lua/index.js`, currentUrl);
467
+ }
468
+ return '';
469
+ }
470
+ export function resolveZigCompilerUrl(options, currentUrl = '') {
471
+ const configuredCompilerUrl = (typeof options === 'object' && options?.zig?.compilerUrl) ||
472
+ (publicEnv.PUBLIC_WASM_ZIG_COMPILER_URL || '').trim();
473
+ if (configuredCompilerUrl) {
474
+ return resolveConfiguredUrl(configuredCompilerUrl, currentUrl);
475
+ }
476
+ if (typeof options === 'string') {
477
+ return resolveConfiguredUrl(`${normalizeRootUrl(options) || ''}/wasm-zig/zig_small.wasm`, currentUrl);
478
+ }
479
+ if (options?.rootUrl) {
480
+ return resolveConfiguredUrl(`${normalizeRootUrl(options.rootUrl) || ''}/wasm-zig/zig_small.wasm`, currentUrl);
481
+ }
482
+ return '';
483
+ }
484
+ export function resolveHaskellModuleUrl(options, currentUrl = '') {
485
+ const configuredModuleUrl = (typeof options === 'object' && options?.haskell?.moduleUrl) ||
486
+ (publicEnv.PUBLIC_WASM_HASKELL_MODULE_URL || '').trim();
487
+ if (configuredModuleUrl) {
488
+ return resolveConfiguredUrl(configuredModuleUrl, currentUrl);
489
+ }
490
+ if (typeof options === 'string') {
491
+ return resolveConfiguredUrl(`${normalizeRootUrl(options) || ''}/wasm-haskell/dyld.mjs`, currentUrl);
492
+ }
493
+ if (options?.rootUrl) {
494
+ return resolveConfiguredUrl(`${normalizeRootUrl(options.rootUrl) || ''}/wasm-haskell/dyld.mjs`, currentUrl);
495
+ }
496
+ return '';
497
+ }
498
+ export function resolveHaskellRootfsUrl(options, currentUrl = '') {
499
+ const configuredRootfsUrl = (typeof options === 'object' && options?.haskell?.rootfsUrl) ||
500
+ (publicEnv.PUBLIC_WASM_HASKELL_ROOTFS_URL || '').trim();
501
+ if (configuredRootfsUrl) {
502
+ return resolveConfiguredUrl(configuredRootfsUrl, currentUrl);
503
+ }
504
+ if (typeof options === 'string') {
505
+ return resolveConfiguredUrl(`${normalizeRootUrl(options) || ''}/wasm-haskell/rootfs.tar.zst`, currentUrl);
506
+ }
507
+ if (options?.rootUrl) {
508
+ return resolveConfiguredUrl(`${normalizeRootUrl(options.rootUrl) || ''}/wasm-haskell/rootfs.tar.zst`, currentUrl);
509
+ }
510
+ return '';
511
+ }
512
+ export function resolveHaskellBsdtarUrl(options, currentUrl = '') {
513
+ const configuredBsdtarUrl = (typeof options === 'object' && options?.haskell?.bsdtarUrl) ||
514
+ (publicEnv.PUBLIC_WASM_HASKELL_BSDTAR_URL || '').trim();
515
+ if (configuredBsdtarUrl) {
516
+ return resolveConfiguredUrl(configuredBsdtarUrl, currentUrl);
517
+ }
518
+ if (typeof options === 'string') {
519
+ return resolveConfiguredUrl(`${normalizeRootUrl(options) || ''}/wasm-haskell/bsdtar.wasm`, currentUrl);
520
+ }
521
+ if (options?.rootUrl) {
522
+ return resolveConfiguredUrl(`${normalizeRootUrl(options.rootUrl) || ''}/wasm-haskell/bsdtar.wasm`, currentUrl);
523
+ }
524
+ return '';
525
+ }
526
+ export function resolveFortranBaseUrl(options, currentUrl = '') {
527
+ const configuredBaseUrl = (typeof options === 'object' && options?.fortran?.baseUrl) ||
528
+ (publicEnv.PUBLIC_WASM_FORTRAN_BASE_URL || '').trim();
529
+ if (configuredBaseUrl) {
530
+ return normalizeBaseUrl(configuredBaseUrl, currentUrl);
531
+ }
532
+ if (typeof options === 'string') {
533
+ return normalizeBaseUrl(`${normalizeRootUrl(options) || ''}/wasm-fortran/`, currentUrl);
534
+ }
535
+ if (options?.rootUrl) {
536
+ return normalizeBaseUrl(`${normalizeRootUrl(options.rootUrl) || ''}/wasm-fortran/`, currentUrl);
537
+ }
538
+ return normalizeBaseUrl('/wasm-fortran/', currentUrl);
539
+ }
540
+ function resolveFortranAssetUrl(options, currentUrl, configKey, envKey, defaultAsset) {
541
+ const env = publicEnv;
542
+ const configuredUrl = (typeof options === 'object' && options?.fortran?.[configKey]) ||
543
+ (env[envKey] || '').trim();
544
+ if (configuredUrl) {
545
+ return resolveConfiguredUrl(configuredUrl, currentUrl);
546
+ }
547
+ return resolveConfiguredUrl(new URL(defaultAsset, resolveFortranBaseUrl(options, currentUrl)).href, currentUrl);
548
+ }
549
+ export function resolveFortranF2cWasmUrl(options, currentUrl = '') {
550
+ return resolveFortranAssetUrl(options, currentUrl, 'f2cWasmUrl', 'PUBLIC_WASM_FORTRAN_F2C_WASM_URL', 'f2c.wasm');
551
+ }
552
+ export function resolveFortranLibf2cUrl(options, currentUrl = '') {
553
+ return resolveFortranAssetUrl(options, currentUrl, 'libf2cUrl', 'PUBLIC_WASM_FORTRAN_LIBF2C_URL', 'libf2c.a');
554
+ }
555
+ export function resolveFortranF2cHeaderUrl(options, currentUrl = '') {
556
+ return resolveFortranAssetUrl(options, currentUrl, 'f2cHeaderUrl', 'PUBLIC_WASM_FORTRAN_F2C_HEADER_URL', 'f2c.h');
557
+ }
558
+ export function resolveFortranAnalyzerUrl(options, currentUrl = '') {
559
+ return resolveFortranAssetUrl(options, currentUrl, 'analyzerUrl', 'PUBLIC_WASM_FORTRAN_ANALYZER_URL', 'analyzer.js');
560
+ }
561
+ export function resolveFortranRuntimeAssetConfig(options, currentUrl = '') {
562
+ const configuredIntegrity = typeof options === 'object' ? options?.fortran?.integrity : undefined;
563
+ return {
564
+ baseUrl: resolveFortranBaseUrl(options, currentUrl),
565
+ f2cWasmUrl: resolveFortranF2cWasmUrl(options, currentUrl),
566
+ libf2cUrl: resolveFortranLibf2cUrl(options, currentUrl),
567
+ f2cHeaderUrl: resolveFortranF2cHeaderUrl(options, currentUrl),
568
+ analyzerUrl: resolveFortranAnalyzerUrl(options, currentUrl),
569
+ integrity: snapshotFortranExecutionAssetReceipts(configuredIntegrity === undefined
570
+ ? WASM_FORTRAN_EXECUTION_ASSET_RECEIPTS
571
+ : configuredIntegrity)
572
+ };
573
+ }
574
+ export function resolveCobolBaseUrl(options, currentUrl = '') {
575
+ const configuredBaseUrl = (typeof options === 'object' && options?.cobol?.baseUrl) ||
576
+ (publicEnv.PUBLIC_WASM_COBOL_BASE_URL || '').trim();
577
+ if (configuredBaseUrl) {
578
+ return normalizeBaseUrl(configuredBaseUrl, currentUrl);
579
+ }
580
+ if (typeof options === 'string') {
581
+ return normalizeBaseUrl(`${normalizeRootUrl(options) || ''}/wasm-cobol/`, currentUrl);
582
+ }
583
+ if (options?.rootUrl) {
584
+ return normalizeBaseUrl(`${normalizeRootUrl(options.rootUrl) || ''}/wasm-cobol/`, currentUrl);
585
+ }
586
+ return normalizeBaseUrl('/wasm-cobol/', currentUrl);
587
+ }
588
+ export function resolveObjectiveCBaseUrl(options, currentUrl = '') {
589
+ const configuredBaseUrl = (typeof options === 'object' && options?.objectivec?.baseUrl) ||
590
+ (publicEnv.PUBLIC_WASM_OBJECTIVEC_BASE_URL || '').trim();
591
+ if (configuredBaseUrl) {
592
+ return normalizeBaseUrl(configuredBaseUrl, currentUrl);
593
+ }
594
+ if (typeof options === 'string') {
595
+ return normalizeBaseUrl(`${normalizeRootUrl(options) || ''}/wasm-objectivec/`, currentUrl);
596
+ }
597
+ if (options?.rootUrl) {
598
+ return normalizeBaseUrl(`${normalizeRootUrl(options.rootUrl) || ''}/wasm-objectivec/`, currentUrl);
599
+ }
600
+ return normalizeBaseUrl('/wasm-objectivec/', currentUrl);
601
+ }
602
+ function resolveObjectiveCAssetUrl(options, currentUrl, configKey, envKey, defaultAsset) {
603
+ const env = publicEnv;
604
+ const configuredUrl = (typeof options === 'object' && options?.objectivec?.[configKey]) ||
605
+ (env[envKey] || '').trim();
606
+ if (configuredUrl) {
607
+ return resolveConfiguredUrl(configuredUrl, currentUrl);
608
+ }
609
+ return resolveConfiguredUrl(new URL(defaultAsset, resolveObjectiveCBaseUrl(options, currentUrl)).href, currentUrl);
610
+ }
611
+ export function resolveObjectiveCLibobjcUrl(options, currentUrl = '') {
612
+ return resolveObjectiveCAssetUrl(options, currentUrl, 'libobjcUrl', 'PUBLIC_WASM_OBJECTIVEC_LIBOBJC_URL', 'libobjc.a');
613
+ }
614
+ export function resolveObjectiveCHeadersUrl(options, currentUrl = '') {
615
+ return resolveObjectiveCAssetUrl(options, currentUrl, 'headersUrl', 'PUBLIC_WASM_OBJECTIVEC_HEADERS_URL', 'headers.json');
616
+ }
617
+ export function resolveObjectiveCLibgnustepBaseUrl(options, currentUrl = '') {
618
+ return resolveObjectiveCAssetUrl(options, currentUrl, 'libgnustepBaseUrl', 'PUBLIC_WASM_OBJECTIVEC_GNUSTEP_BASE_URL', 'libgnustep-base.a');
619
+ }
620
+ export function resolveObjectiveCLibgnustepBaseObjectUrl(options, currentUrl = '') {
621
+ return resolveObjectiveCAssetUrl(options, currentUrl, 'libgnustepBaseObjectUrl', 'PUBLIC_WASM_OBJECTIVEC_GNUSTEP_BASE_OBJECT_URL', 'libgnustep-base.o');
622
+ }
623
+ export function resolveObjectiveCFoundationHeadersUrl(options, currentUrl = '') {
624
+ return resolveObjectiveCAssetUrl(options, currentUrl, 'foundationHeadersUrl', 'PUBLIC_WASM_OBJECTIVEC_FOUNDATION_HEADERS_URL', 'foundation-headers.json');
625
+ }
626
+ export function resolveObjectiveCLibffiUrl(options, currentUrl = '') {
627
+ return resolveObjectiveCAssetUrl(options, currentUrl, 'libffiUrl', 'PUBLIC_WASM_OBJECTIVEC_LIBFFI_URL', 'libffi.a');
628
+ }
629
+ export function resolveObjectiveCRuntimeAssetConfig(options, currentUrl = '') {
630
+ const configuredIntegrity = typeof options === 'object' ? options?.objectivec?.integrity : undefined;
631
+ let integrity = WASM_OBJECTIVEC_ASSET_RECEIPTS;
632
+ if (configuredIntegrity !== undefined) {
633
+ if (!configuredIntegrity ||
634
+ typeof configuredIntegrity !== 'object' ||
635
+ Array.isArray(configuredIntegrity)) {
636
+ throw new TypeError('Objective-C runtime asset integrity receipt is required.');
637
+ }
638
+ const expectedAssetNames = Object.keys(WASM_OBJECTIVEC_ASSET_RECEIPTS).sort();
639
+ const receivedAssetNames = Object.keys(configuredIntegrity).sort();
640
+ if (receivedAssetNames.length !== expectedAssetNames.length ||
641
+ receivedAssetNames.some((assetName, index) => assetName !== expectedAssetNames[index])) {
642
+ throw new TypeError('Objective-C runtime asset integrity receipt is incomplete.');
643
+ }
644
+ integrity = Object.freeze(Object.fromEntries(expectedAssetNames.map((assetName) => {
645
+ const receipt = configuredIntegrity[assetName];
646
+ const bytes = receipt?.bytes;
647
+ const sha256 = receipt?.sha256;
648
+ if (!Number.isSafeInteger(bytes) ||
649
+ bytes <= 0 ||
650
+ typeof sha256 !== 'string' ||
651
+ !/^[a-f0-9]{64}$/u.test(sha256)) {
652
+ throw new TypeError(`Objective-C runtime asset integrity receipt is invalid for ${assetName}.`);
653
+ }
654
+ return [assetName, Object.freeze({ bytes: bytes, sha256 })];
655
+ })));
656
+ }
657
+ return {
658
+ baseUrl: resolveObjectiveCBaseUrl(options, currentUrl),
659
+ libobjcUrl: resolveObjectiveCLibobjcUrl(options, currentUrl),
660
+ headersUrl: resolveObjectiveCHeadersUrl(options, currentUrl),
661
+ libgnustepBaseUrl: resolveObjectiveCLibgnustepBaseUrl(options, currentUrl),
662
+ libgnustepBaseObjectUrl: resolveObjectiveCLibgnustepBaseObjectUrl(options, currentUrl),
663
+ foundationHeadersUrl: resolveObjectiveCFoundationHeadersUrl(options, currentUrl),
664
+ libffiUrl: resolveObjectiveCLibffiUrl(options, currentUrl),
665
+ integrity
666
+ };
667
+ }
668
+ export function resolveZigStdlibUrl(options, currentUrl = '') {
669
+ const configuredStdlibUrl = (typeof options === 'object' && options?.zig?.stdlibUrl) ||
670
+ (publicEnv.PUBLIC_WASM_ZIG_STDLIB_URL || '').trim();
671
+ if (configuredStdlibUrl) {
672
+ return resolveConfiguredUrl(configuredStdlibUrl, currentUrl);
673
+ }
674
+ if (typeof options === 'string') {
675
+ return resolveConfiguredUrl(`${normalizeRootUrl(options) || ''}/wasm-zig/std.tar.gz`, currentUrl);
676
+ }
677
+ if (options?.rootUrl) {
678
+ return resolveConfiguredUrl(`${normalizeRootUrl(options.rootUrl) || ''}/wasm-zig/std.tar.gz`, currentUrl);
679
+ }
680
+ return '';
681
+ }
682
+ export function resolveZigRuntimeAssetConfig(options, currentUrl = '') {
683
+ const configuredIntegrity = typeof options === 'object' ? options?.zig?.integrity : undefined;
684
+ return {
685
+ compilerUrl: resolveZigCompilerUrl(options, currentUrl),
686
+ stdlibUrl: resolveZigStdlibUrl(options, currentUrl),
687
+ integrity: snapshotZigExecutionAssetReceipts(configuredIntegrity === undefined ? WASM_ZIG_ASSET_RECEIPTS : configuredIntegrity)
688
+ };
689
+ }
690
+ export function resolveLispModuleUrl(options, currentUrl = '') {
691
+ const configuredModuleUrl = (typeof options === 'object' && options?.lisp?.moduleUrl) ||
692
+ (publicEnv.PUBLIC_WASM_LISP_MODULE_URL || '').trim();
693
+ if (configuredModuleUrl) {
694
+ return resolveConfiguredUrl(configuredModuleUrl, currentUrl);
695
+ }
696
+ if (typeof options === 'string') {
697
+ return resolveConfiguredUrl(`${normalizeRootUrl(options) || ''}/wasm-lisp/index.js`, currentUrl);
698
+ }
699
+ if (options?.rootUrl) {
700
+ return resolveConfiguredUrl(`${normalizeRootUrl(options.rootUrl) || ''}/wasm-lisp/index.js`, currentUrl);
701
+ }
702
+ return '';
703
+ }
704
+ function deriveLispManifestUrl(moduleUrl, currentUrl) {
705
+ if (!moduleUrl)
706
+ return '';
707
+ try {
708
+ const module = new URL(moduleUrl, currentUrl || undefined);
709
+ const manifest = new URL('runtime-manifest.v2.json', module);
710
+ manifest.search = module.search;
711
+ return manifest.href;
712
+ }
713
+ catch {
714
+ const queryIndex = moduleUrl.indexOf('?');
715
+ const query = queryIndex >= 0 ? moduleUrl.slice(queryIndex) : '';
716
+ const path = queryIndex >= 0 ? moduleUrl.slice(0, queryIndex) : moduleUrl;
717
+ return `${path.replace(/[^/]*$/u, '')}runtime-manifest.v2.json${query}`;
718
+ }
719
+ }
720
+ export function resolveLispRuntimeAssetConfig(options, currentUrl = '') {
721
+ const configured = typeof options === 'object' ? options?.lisp : undefined;
722
+ const configuredModuleUrl = configured?.moduleUrl;
723
+ const publicModuleUrl = (publicEnv.PUBLIC_WASM_LISP_MODULE_URL || '').trim();
724
+ const rootUrl = typeof options === 'string' ? options : options?.rootUrl;
725
+ const moduleUrl = configuredModuleUrl
726
+ ? resolveConfiguredUrl(configuredModuleUrl, currentUrl)
727
+ : publicModuleUrl
728
+ ? resolveConfiguredUrl(publicModuleUrl, currentUrl)
729
+ : rootUrl !== undefined
730
+ ? resolveConfiguredUrl(`${normalizeRootUrl(rootUrl) || ''}/wasm-lisp/index.js`, currentUrl)
731
+ : '';
732
+ const configuredManifestUrl = configured?.manifestUrl || (publicEnv.PUBLIC_WASM_LISP_MANIFEST_URL || '').trim();
733
+ const configuredFingerprint = configured?.manifestFingerprint?.trim() ||
734
+ (publicEnv.PUBLIC_WASM_LISP_MANIFEST_FINGERPRINT || '').trim();
735
+ const usesBundledRoot = !configuredModuleUrl && !publicModuleUrl && rootUrl !== undefined;
736
+ return {
737
+ moduleUrl,
738
+ manifestUrl: configuredManifestUrl
739
+ ? resolveConfiguredUrl(configuredManifestUrl, currentUrl)
740
+ : deriveLispManifestUrl(moduleUrl, currentUrl),
741
+ manifestFingerprint: configuredFingerprint || (usesBundledRoot ? WASM_LISP_ASSET_VERSION : '')
742
+ };
743
+ }
744
+ const RUBY_RUNTIME_CONFIG_KEYS = [
745
+ 'baseUrl',
746
+ 'manifestUrl',
747
+ 'moduleUrl',
748
+ 'wasmUrl',
749
+ 'profileId',
750
+ 'artifactRevision',
751
+ 'rubyVersion',
752
+ 'rubyRevision',
753
+ 'rubyWasmVersion',
754
+ 'rubyWasmRevision',
755
+ 'wasiSdkVersion',
756
+ 'manifestFingerprint',
757
+ 'manifestReceipt',
758
+ 'moduleJavaScriptReceipt',
759
+ 'wasmReceipt'
760
+ ];
761
+ function snapshotRubyRuntimeAssetConfig(options) {
762
+ const source = typeof options === 'object' ? options?.ruby : undefined;
763
+ if (!source)
764
+ return undefined;
765
+ const snapshot = {};
766
+ for (const key of RUBY_RUNTIME_CONFIG_KEYS)
767
+ snapshot[key] = source[key];
768
+ return Object.freeze(snapshot);
769
+ }
770
+ function resolveRubyBaseUrlFromSnapshot(options, configured, currentUrl = '') {
771
+ const configuredBaseUrl = configured?.baseUrl;
772
+ if (configuredBaseUrl)
773
+ return normalizeBaseUrl(configuredBaseUrl, currentUrl);
774
+ if (typeof options === 'string') {
775
+ return normalizeBaseUrl(`${normalizeRootUrl(options) || ''}/wasm-ruby/`, currentUrl);
776
+ }
777
+ if (options?.rootUrl) {
778
+ return normalizeBaseUrl(`${normalizeRootUrl(options.rootUrl) || ''}/wasm-ruby/`, currentUrl);
779
+ }
780
+ return normalizeBaseUrl('/wasm-ruby/', currentUrl);
781
+ }
782
+ export function resolveRubyBaseUrl(options, currentUrl = '') {
783
+ return resolveRubyBaseUrlFromSnapshot(options, snapshotRubyRuntimeAssetConfig(options), currentUrl);
784
+ }
785
+ export function resolveRubyRuntimeAssetConfig(options, currentUrl = '') {
786
+ const configured = snapshotRubyRuntimeAssetConfig(options);
787
+ const publicModuleUrl = (publicEnv.PUBLIC_WASM_RUBY_MODULE_URL || '').trim();
788
+ const publicWasmUrl = (publicEnv.PUBLIC_WASM_RUBY_WASM_URL || '').trim();
789
+ const usesCustomTrustBoundary = Boolean((configured && RUBY_RUNTIME_CONFIG_KEYS.some((key) => configured[key] !== undefined)) ||
790
+ publicModuleUrl ||
791
+ publicWasmUrl);
792
+ let preflightProfile;
793
+ try {
794
+ preflightProfile = snapshotRubyRuntimePreflightProfile(usesCustomTrustBoundary
795
+ ? {
796
+ profileId: configured?.profileId?.trim(),
797
+ artifactRevision: configured?.artifactRevision?.trim(),
798
+ rubyVersion: configured?.rubyVersion?.trim(),
799
+ rubyRevision: configured?.rubyRevision?.trim(),
800
+ rubyWasmVersion: configured?.rubyWasmVersion?.trim(),
801
+ rubyWasmRevision: configured?.rubyWasmRevision?.trim(),
802
+ wasiSdkVersion: configured?.wasiSdkVersion?.trim(),
803
+ manifestFingerprint: configured?.manifestFingerprint?.trim(),
804
+ manifestReceipt: configured?.manifestReceipt,
805
+ moduleJavaScriptReceipt: configured?.moduleJavaScriptReceipt,
806
+ wasmReceipt: configured?.wasmReceipt
807
+ }
808
+ : RUBY_RUNTIME_BUNDLE.profile);
809
+ }
810
+ catch (cause) {
811
+ throw new RuntimeConfigurationError('Ruby runtime custom assets require one complete profile and receipt bundle.', { cause, runtimeId: 'RUBY' });
812
+ }
813
+ const baseUrl = resolveRubyBaseUrlFromSnapshot(options, configured, currentUrl);
814
+ const resolvePinnedUrl = (configuredUrl, path, pin) => {
815
+ const sentinelOrigin = 'https://wasm-idle.invalid';
816
+ const candidate = resolveConfiguredUrl(configuredUrl || `${baseUrl}${path}`, currentUrl);
817
+ let url;
818
+ let expected;
819
+ try {
820
+ url = new URL(candidate, currentUrl || sentinelOrigin);
821
+ expected = new URL(`${baseUrl}${path}`, currentUrl || sentinelOrigin);
822
+ }
823
+ catch (cause) {
824
+ throw new RuntimeConfigurationError(`Ruby runtime ${path} URL is invalid.`, {
825
+ cause,
826
+ runtimeId: 'RUBY'
827
+ });
828
+ }
829
+ if ((url.protocol !== 'http:' && url.protocol !== 'https:') ||
830
+ url.username ||
831
+ url.password ||
832
+ url.hash ||
833
+ url.origin !== expected.origin ||
834
+ url.pathname !== expected.pathname ||
835
+ (url.search && url.search !== `?v=${pin}`)) {
836
+ throw new RuntimeConfigurationError(`Ruby runtime ${path} URL must use its canonical query-pinned path.`, { runtimeId: 'RUBY' });
837
+ }
838
+ if (!url.search)
839
+ url.searchParams.set('v', pin);
840
+ return currentUrl || candidate.startsWith('http://') || candidate.startsWith('https://')
841
+ ? url.href
842
+ : `${url.pathname}${url.search}`;
843
+ };
844
+ const manifestUrl = resolvePinnedUrl(configured?.manifestUrl, RUBY_RUNTIME_MANIFEST_PATH, preflightProfile.manifestFingerprint);
845
+ const moduleUrl = resolvePinnedUrl(configured?.moduleUrl || publicModuleUrl, RUBY_RUNTIME_MODULE_STORAGE_PATH, preflightProfile.moduleJavaScriptReceipt.sha256);
846
+ const wasmUrl = resolvePinnedUrl(configured?.wasmUrl || publicWasmUrl, RUBY_RUNTIME_WASM_STORAGE_PATH, preflightProfile.wasmReceipt.sha256);
847
+ return {
848
+ baseUrl,
849
+ manifestUrl,
850
+ moduleUrl,
851
+ wasmUrl,
852
+ preflightKey: JSON.stringify({
853
+ baseUrl,
854
+ manifestUrl,
855
+ moduleUrl,
856
+ wasmUrl,
857
+ profile: preflightProfile
858
+ }),
859
+ preflightProfile
860
+ };
861
+ }
862
+ export function resolveRubyWasmUrl(options, currentUrl = '') {
863
+ return resolveRubyRuntimeAssetConfig(options, currentUrl).wasmUrl;
864
+ }
865
+ export function resolveRBaseUrl(options, currentUrl = '') {
866
+ const configuredBaseUrl = (typeof options === 'object' && options?.r?.baseUrl) ||
867
+ (publicEnv.PUBLIC_WASM_R_BASE_URL || '').trim();
868
+ if (configuredBaseUrl) {
869
+ return normalizeBaseUrl(configuredBaseUrl, currentUrl);
870
+ }
871
+ if (typeof options === 'string') {
872
+ return normalizeBaseUrl(`${normalizeRootUrl(options) || ''}/webr/`, currentUrl);
873
+ }
874
+ if (options?.rootUrl) {
875
+ return normalizeBaseUrl(`${normalizeRootUrl(options.rootUrl) || ''}/webr/`, currentUrl);
876
+ }
877
+ return '';
878
+ }
879
+ export function resolveOctaveBaseUrl(options, currentUrl = '') {
880
+ const configuredBaseUrl = (typeof options === 'object' && options?.octave?.baseUrl) ||
881
+ (publicEnv.PUBLIC_WASM_OCTAVE_BASE_URL || '').trim();
882
+ if (configuredBaseUrl) {
883
+ return normalizeBaseUrl(configuredBaseUrl, currentUrl);
884
+ }
885
+ if (typeof options === 'string') {
886
+ return normalizeBaseUrl(`${normalizeRootUrl(options) || ''}/wasm-octave/runtime/`, currentUrl);
887
+ }
888
+ if (options?.rootUrl) {
889
+ return normalizeBaseUrl(`${normalizeRootUrl(options.rootUrl) || ''}/wasm-octave/runtime/`, currentUrl);
890
+ }
891
+ return normalizeBaseUrl('/wasm-octave/runtime/', currentUrl);
892
+ }
893
+ export function resolveOctaveWorkerUrl(options, currentUrl = '') {
894
+ const configuredWorkerUrl = (typeof options === 'object' && options?.octave?.workerUrl) ||
895
+ (publicEnv.PUBLIC_WASM_OCTAVE_WORKER_URL || '').trim();
896
+ if (configuredWorkerUrl) {
897
+ return resolveConfiguredUrl(configuredWorkerUrl, currentUrl);
898
+ }
899
+ if (typeof options === 'string') {
900
+ return resolveConfiguredUrl(`${normalizeRootUrl(options) || ''}/wasm-octave/runner-worker.js`, currentUrl);
901
+ }
902
+ if (options?.rootUrl) {
903
+ return resolveConfiguredUrl(`${normalizeRootUrl(options.rootUrl) || ''}/wasm-octave/runner-worker.js`, currentUrl);
904
+ }
905
+ return resolveConfiguredUrl('/wasm-octave/runner-worker.js', currentUrl);
906
+ }
907
+ export function resolveOctaveManifestUrl(options, currentUrl = '') {
908
+ const configuredManifestUrl = (typeof options === 'object' && options?.octave?.manifestUrl) ||
909
+ (publicEnv.PUBLIC_WASM_OCTAVE_MANIFEST_URL || '').trim();
910
+ if (configuredManifestUrl) {
911
+ return resolveConfiguredUrl(configuredManifestUrl, currentUrl);
912
+ }
913
+ if (typeof options === 'string') {
914
+ return resolveConfiguredUrl(`${normalizeRootUrl(options) || ''}/wasm-octave/runtime/runtime-manifest.v1.json`, currentUrl);
915
+ }
916
+ if (options?.rootUrl) {
917
+ return resolveConfiguredUrl(`${normalizeRootUrl(options.rootUrl) || ''}/wasm-octave/runtime/runtime-manifest.v1.json`, currentUrl);
918
+ }
919
+ return resolveConfiguredUrl('/wasm-octave/runtime/runtime-manifest.v1.json', currentUrl);
920
+ }
921
+ export function resolveOctaveRuntimeAssetConfig(options, currentUrl = '') {
922
+ return {
923
+ baseUrl: resolveOctaveBaseUrl(options, currentUrl),
924
+ workerUrl: resolveOctaveWorkerUrl(options, currentUrl),
925
+ manifestUrl: resolveOctaveManifestUrl(options, currentUrl)
926
+ };
927
+ }
928
+ export function resolvePrologBaseUrl(options, currentUrl = '') {
929
+ const configuredBaseUrl = (typeof options === 'object' && options?.prolog?.baseUrl) ||
930
+ (publicEnv.PUBLIC_WASM_PROLOG_BASE_URL || '').trim();
931
+ if (configuredBaseUrl) {
932
+ return normalizeBaseUrl(configuredBaseUrl, currentUrl);
933
+ }
934
+ if (typeof options === 'string') {
935
+ return normalizeBaseUrl(`${normalizeRootUrl(options) || ''}/wasm-prolog/`, currentUrl);
936
+ }
937
+ if (options?.rootUrl) {
938
+ return normalizeBaseUrl(`${normalizeRootUrl(options.rootUrl) || ''}/wasm-prolog/`, currentUrl);
939
+ }
940
+ return normalizeBaseUrl('/wasm-prolog/', currentUrl);
941
+ }
942
+ export function resolvePrologWorkerUrl(options, currentUrl = '') {
943
+ const configuredWorkerUrl = (typeof options === 'object' && options?.prolog?.workerUrl) ||
944
+ (publicEnv.PUBLIC_WASM_PROLOG_WORKER_URL || '').trim();
945
+ if (configuredWorkerUrl) {
946
+ return resolveConfiguredUrl(configuredWorkerUrl, currentUrl);
947
+ }
948
+ if (typeof options === 'string') {
949
+ return resolveConfiguredUrl(`${normalizeRootUrl(options) || ''}/wasm-prolog/runner-worker.js`, currentUrl);
950
+ }
951
+ if (options?.rootUrl) {
952
+ return resolveConfiguredUrl(`${normalizeRootUrl(options.rootUrl) || ''}/wasm-prolog/runner-worker.js`, currentUrl);
953
+ }
954
+ return resolveConfiguredUrl('/wasm-prolog/runner-worker.js', currentUrl);
955
+ }
956
+ export function resolvePrologManifestUrl(options, currentUrl = '') {
957
+ const configuredManifestUrl = typeof options === 'object' ? options?.prolog?.manifestUrl : undefined;
958
+ if (configuredManifestUrl)
959
+ return resolveConfiguredUrl(configuredManifestUrl, currentUrl);
960
+ return `${resolvePrologBaseUrl(options, currentUrl)}runtime-manifest.v2.json`;
961
+ }
962
+ export function resolvePrologRuntimeAssetConfig(options, currentUrl = '') {
963
+ const configured = typeof options === 'object' ? options?.prolog : undefined;
964
+ const manifestFingerprint = configured?.manifestFingerprint?.trim() || WASM_PROLOG_ASSET_VERSION;
965
+ const usesBundledProfile = manifestFingerprint === WASM_PROLOG_ASSET_VERSION;
966
+ const receipt = (configuredReceipt, bundledReceipt) => {
967
+ const selected = configuredReceipt || (usesBundledProfile ? bundledReceipt : undefined);
968
+ return selected
969
+ ? Object.freeze({
970
+ bytes: selected.bytes,
971
+ sha256: selected.sha256,
972
+ ...(selected.uncompressedBytes === undefined
973
+ ? {}
974
+ : { uncompressedBytes: selected.uncompressedBytes }),
975
+ ...(selected.uncompressedSha256 === undefined
976
+ ? {}
977
+ : { uncompressedSha256: selected.uncompressedSha256 })
978
+ })
979
+ : undefined;
980
+ };
981
+ const preflightProfile = snapshotPrologRuntimePreflightProfile({
982
+ profileId: configured?.profileId?.trim() ||
983
+ (usesBundledProfile ? WASM_PROLOG_RUNTIME_PROFILE.profileId : ''),
984
+ packageRevision: configured?.packageRevision?.trim() ||
985
+ (usesBundledProfile ? WASM_PROLOG_RUNTIME_PROFILE.packageRevision : ''),
986
+ swiplRevision: configured?.swiplRevision?.trim() ||
987
+ (usesBundledProfile ? WASM_PROLOG_RUNTIME_PROFILE.swiplRevision : ''),
988
+ manifestFingerprint,
989
+ manifestReceipt: receipt(configured?.manifestReceipt, WASM_PROLOG_RUNTIME_PROFILE.manifestReceipt),
990
+ javascriptReceipt: receipt(configured?.javascriptReceipt, WASM_PROLOG_RUNTIME_PROFILE.javascriptReceipt),
991
+ wasmReceipt: receipt(configured?.wasmReceipt, WASM_PROLOG_RUNTIME_PROFILE.wasmReceipt),
992
+ dataReceipt: receipt(configured?.dataReceipt, WASM_PROLOG_RUNTIME_PROFILE.dataReceipt)
993
+ });
994
+ return {
995
+ baseUrl: resolvePrologBaseUrl(options, currentUrl),
996
+ workerUrl: resolvePrologWorkerUrl(options, currentUrl),
997
+ manifestUrl: resolvePrologManifestUrl(options, currentUrl),
998
+ manifestFingerprint,
999
+ preflightKey: JSON.stringify(preflightProfile),
1000
+ preflightProfile,
1001
+ workerReceipt: configured?.workerReceipt || WASM_PROLOG_RUNNER_RECEIPT
1002
+ };
1003
+ }
1004
+ export function resolveGleamBaseUrl(options, currentUrl = '') {
1005
+ const configuredBaseUrl = (typeof options === 'object' && options?.gleam?.baseUrl) ||
1006
+ (publicEnv.PUBLIC_WASM_GLEAM_BASE_URL || '').trim();
1007
+ if (configuredBaseUrl) {
1008
+ return normalizeBaseUrl(configuredBaseUrl, currentUrl);
1009
+ }
1010
+ if (typeof options === 'string') {
1011
+ return normalizeBaseUrl(`${normalizeRootUrl(options) || ''}/wasm-gleam/`, currentUrl);
1012
+ }
1013
+ if (options?.rootUrl) {
1014
+ return normalizeBaseUrl(`${normalizeRootUrl(options.rootUrl) || ''}/wasm-gleam/`, currentUrl);
1015
+ }
1016
+ return normalizeBaseUrl('/wasm-gleam/', currentUrl);
1017
+ }
1018
+ export function resolveGleamWorkerUrl(options, currentUrl = '') {
1019
+ const configuredWorkerUrl = (typeof options === 'object' && options?.gleam?.workerUrl) ||
1020
+ (publicEnv.PUBLIC_WASM_GLEAM_WORKER_URL || '').trim();
1021
+ if (configuredWorkerUrl) {
1022
+ return resolveConfiguredUrl(configuredWorkerUrl, currentUrl);
1023
+ }
1024
+ if (typeof options === 'string') {
1025
+ return resolveConfiguredUrl(`${normalizeRootUrl(options) || ''}/wasm-gleam/runner-worker.js`, currentUrl);
1026
+ }
1027
+ if (options?.rootUrl) {
1028
+ return resolveConfiguredUrl(`${normalizeRootUrl(options.rootUrl) || ''}/wasm-gleam/runner-worker.js`, currentUrl);
1029
+ }
1030
+ return resolveConfiguredUrl('/wasm-gleam/runner-worker.js', currentUrl);
1031
+ }
1032
+ export function resolveGleamManifestUrl(options, currentUrl = '') {
1033
+ const configuredManifestUrl = (typeof options === 'object' && options?.gleam?.manifestUrl) ||
1034
+ (publicEnv.PUBLIC_WASM_GLEAM_MANIFEST_URL || '').trim();
1035
+ if (configuredManifestUrl) {
1036
+ return resolveConfiguredUrl(configuredManifestUrl, currentUrl);
1037
+ }
1038
+ if (typeof options === 'string') {
1039
+ return resolveConfiguredUrl(`${normalizeRootUrl(options) || ''}/wasm-gleam/source-manifest.v2.json`, currentUrl);
1040
+ }
1041
+ if (options?.rootUrl) {
1042
+ return resolveConfiguredUrl(`${normalizeRootUrl(options.rootUrl) || ''}/wasm-gleam/source-manifest.v2.json`, currentUrl);
1043
+ }
1044
+ return resolveConfiguredUrl('/wasm-gleam/source-manifest.v2.json', currentUrl);
1045
+ }
1046
+ export function resolveGleamRuntimeAssetConfig(options, currentUrl = '') {
1047
+ const configured = typeof options === 'object' ? options?.gleam : undefined;
1048
+ const envManifestFingerprint = (publicEnv.PUBLIC_WASM_GLEAM_MANIFEST_FINGERPRINT || '').trim();
1049
+ const envWorkerSha256 = (publicEnv.PUBLIC_WASM_GLEAM_WORKER_SHA256 || '').trim();
1050
+ const envWorkerBytesSource = (publicEnv.PUBLIC_WASM_GLEAM_WORKER_BYTES || '').trim();
1051
+ const envWorkerBytes = /^\d+$/u.test(envWorkerBytesSource)
1052
+ ? Number(envWorkerBytesSource)
1053
+ : Number.NaN;
1054
+ const envWorkerReceipt = /^[a-f0-9]{64}$/u.test(envWorkerSha256) &&
1055
+ Number.isSafeInteger(envWorkerBytes) &&
1056
+ envWorkerBytes > 0
1057
+ ? { bytes: envWorkerBytes, sha256: envWorkerSha256 }
1058
+ : undefined;
1059
+ const usesCustomUrls = Boolean(configured?.baseUrl ||
1060
+ configured?.workerUrl ||
1061
+ configured?.manifestUrl ||
1062
+ (publicEnv.PUBLIC_WASM_GLEAM_BASE_URL || '').trim() ||
1063
+ (publicEnv.PUBLIC_WASM_GLEAM_WORKER_URL || '').trim() ||
1064
+ (publicEnv.PUBLIC_WASM_GLEAM_MANIFEST_URL || '').trim());
1065
+ return {
1066
+ baseUrl: resolveGleamBaseUrl(options, currentUrl),
1067
+ workerUrl: resolveGleamWorkerUrl(options, currentUrl),
1068
+ manifestUrl: resolveGleamManifestUrl(options, currentUrl),
1069
+ manifestFingerprint: configured?.manifestFingerprint?.trim() ||
1070
+ envManifestFingerprint ||
1071
+ (!usesCustomUrls ? WASM_GLEAM_ASSET_VERSION : undefined),
1072
+ workerReceipt: configured?.workerReceipt ||
1073
+ envWorkerReceipt ||
1074
+ (!usesCustomUrls ? WASM_GLEAM_RUNNER_RECEIPT : undefined)
1075
+ };
1076
+ }
1077
+ export function resolvePerlBaseUrl(options, currentUrl = '') {
1078
+ const configuredBaseUrl = (typeof options === 'object' && options?.perl?.baseUrl) ||
1079
+ (publicEnv.PUBLIC_WASM_PERL_BASE_URL || '').trim();
1080
+ if (configuredBaseUrl) {
1081
+ return normalizeBaseUrl(configuredBaseUrl, currentUrl);
1082
+ }
1083
+ if (typeof options === 'string') {
1084
+ return normalizeBaseUrl(`${normalizeRootUrl(options) || ''}/wasm-perl/`, currentUrl);
1085
+ }
1086
+ if (options?.rootUrl) {
1087
+ return normalizeBaseUrl(`${normalizeRootUrl(options.rootUrl) || ''}/wasm-perl/`, currentUrl);
1088
+ }
1089
+ return normalizeBaseUrl('/wasm-perl/', currentUrl);
1090
+ }
1091
+ export function resolvePerlWorkerUrl(options, currentUrl = '') {
1092
+ const configuredWorkerUrl = (typeof options === 'object' && options?.perl?.workerUrl) ||
1093
+ (publicEnv.PUBLIC_WASM_PERL_WORKER_URL || '').trim();
1094
+ if (configuredWorkerUrl) {
1095
+ return resolveConfiguredUrl(configuredWorkerUrl, currentUrl);
1096
+ }
1097
+ if (typeof options === 'string') {
1098
+ return resolveConfiguredUrl(`${normalizeRootUrl(options) || ''}/wasm-perl/runner-worker.js`, currentUrl);
1099
+ }
1100
+ if (options?.rootUrl) {
1101
+ return resolveConfiguredUrl(`${normalizeRootUrl(options.rootUrl) || ''}/wasm-perl/runner-worker.js`, currentUrl);
1102
+ }
1103
+ return resolveConfiguredUrl('/wasm-perl/runner-worker.js', currentUrl);
1104
+ }
1105
+ export function resolvePerlManifestUrl(options, currentUrl = '') {
1106
+ const configuredManifestUrl = (typeof options === 'object' && options?.perl?.manifestUrl) ||
1107
+ (publicEnv.PUBLIC_WASM_PERL_MANIFEST_URL || '').trim();
1108
+ if (configuredManifestUrl)
1109
+ return resolveConfiguredUrl(configuredManifestUrl, currentUrl);
1110
+ return `${resolvePerlBaseUrl(options, currentUrl)}runtime-manifest.v2.json`;
1111
+ }
1112
+ export function resolvePerlRuntimeAssetConfig(options, currentUrl = '') {
1113
+ const configured = typeof options === 'object' ? options?.perl : undefined;
1114
+ const usesCustomUrls = Boolean(configured?.baseUrl ||
1115
+ configured?.workerUrl ||
1116
+ configured?.manifestUrl ||
1117
+ (publicEnv.PUBLIC_WASM_PERL_BASE_URL || '').trim() ||
1118
+ (publicEnv.PUBLIC_WASM_PERL_WORKER_URL || '').trim() ||
1119
+ (publicEnv.PUBLIC_WASM_PERL_MANIFEST_URL || '').trim());
1120
+ const hasConfiguredTrust = !!configured &&
1121
+ [
1122
+ configured.manifestFingerprint,
1123
+ configured.profileId,
1124
+ configured.artifactRevision,
1125
+ configured.webperlRevision,
1126
+ configured.perlRevision,
1127
+ configured.emscriptenRevision,
1128
+ configured.manifestReceipt,
1129
+ configured.javascriptReceipt,
1130
+ configured.wasmReceipt,
1131
+ configured.dataReceipt,
1132
+ configured.workerReceipt
1133
+ ].some((value) => value !== undefined);
1134
+ const usesCustomTrustBoundary = usesCustomUrls || hasConfiguredTrust;
1135
+ const selectedProfile = usesCustomTrustBoundary
1136
+ ? {
1137
+ profileId: configured?.profileId?.trim(),
1138
+ artifactRevision: configured?.artifactRevision?.trim(),
1139
+ webperlRevision: configured?.webperlRevision?.trim(),
1140
+ perlRevision: configured?.perlRevision?.trim(),
1141
+ emscriptenRevision: configured?.emscriptenRevision?.trim(),
1142
+ manifestFingerprint: configured?.manifestFingerprint?.trim(),
1143
+ manifestReceipt: configured?.manifestReceipt,
1144
+ javascriptReceipt: configured?.javascriptReceipt,
1145
+ wasmReceipt: configured?.wasmReceipt,
1146
+ dataReceipt: configured?.dataReceipt
1147
+ }
1148
+ : WASM_PERL_RUNTIME_BUNDLE.profile;
1149
+ const preflightProfile = snapshotPerlRuntimePreflightProfile(selectedProfile);
1150
+ const workerReceipt = usesCustomTrustBoundary
1151
+ ? configured?.workerReceipt
1152
+ : WASM_PERL_RUNTIME_BUNDLE.workerReceipt;
1153
+ if (!workerReceipt) {
1154
+ throw new RuntimeConfigurationError('WebPerl runtime requires one complete profile and runner receipt bundle.', { runtimeId: 'PERL' });
1155
+ }
1156
+ return {
1157
+ baseUrl: resolvePerlBaseUrl(options, currentUrl),
1158
+ workerUrl: resolvePerlWorkerUrl(options, currentUrl),
1159
+ manifestUrl: resolvePerlManifestUrl(options, currentUrl),
1160
+ manifestFingerprint: preflightProfile.manifestFingerprint,
1161
+ preflightKey: JSON.stringify(preflightProfile),
1162
+ preflightProfile,
1163
+ workerReceipt
1164
+ };
1165
+ }
1166
+ export function resolveTclBaseUrl(options, currentUrl = '') {
1167
+ const configuredBaseUrl = (typeof options === 'object' && options?.tcl?.baseUrl) ||
1168
+ (publicEnv.PUBLIC_WASM_TCL_BASE_URL || '').trim();
1169
+ if (configuredBaseUrl) {
1170
+ return normalizeBaseUrl(configuredBaseUrl, currentUrl);
1171
+ }
1172
+ if (typeof options === 'string') {
1173
+ return normalizeBaseUrl(`${normalizeRootUrl(options) || ''}/wasm-tcl/`, currentUrl);
1174
+ }
1175
+ if (options?.rootUrl) {
1176
+ return normalizeBaseUrl(`${normalizeRootUrl(options.rootUrl) || ''}/wasm-tcl/`, currentUrl);
1177
+ }
1178
+ return normalizeBaseUrl('/wasm-tcl/', currentUrl);
1179
+ }
1180
+ export function resolveTclWorkerUrl(options, currentUrl = '') {
1181
+ const configuredWorkerUrl = (typeof options === 'object' && options?.tcl?.workerUrl) ||
1182
+ (publicEnv.PUBLIC_WASM_TCL_WORKER_URL || '').trim();
1183
+ if (configuredWorkerUrl) {
1184
+ return resolveConfiguredUrl(configuredWorkerUrl, currentUrl);
1185
+ }
1186
+ if (typeof options === 'string') {
1187
+ return resolveConfiguredUrl(`${normalizeRootUrl(options) || ''}/wasm-tcl/runner-worker.js`, currentUrl);
1188
+ }
1189
+ if (options?.rootUrl) {
1190
+ return resolveConfiguredUrl(`${normalizeRootUrl(options.rootUrl) || ''}/wasm-tcl/runner-worker.js`, currentUrl);
1191
+ }
1192
+ return resolveConfiguredUrl('/wasm-tcl/runner-worker.js', currentUrl);
1193
+ }
1194
+ export function resolveTclManifestUrl(options, currentUrl = '') {
1195
+ const configuredManifestUrl = typeof options === 'object' ? options?.tcl?.manifestUrl : undefined;
1196
+ if (configuredManifestUrl)
1197
+ return resolveConfiguredUrl(configuredManifestUrl, currentUrl);
1198
+ return `${resolveTclBaseUrl(options, currentUrl)}runtime-manifest.v2.json`;
1199
+ }
1200
+ export function resolveTclRuntimeAssetConfig(options, currentUrl = '') {
1201
+ const configured = typeof options === 'object' ? options?.tcl : undefined;
1202
+ const hasConfiguredTrust = !!configured &&
1203
+ [
1204
+ configured.manifestFingerprint,
1205
+ configured.profileId,
1206
+ configured.artifactRevision,
1207
+ configured.waclRevision,
1208
+ configured.tclRevision,
1209
+ configured.requireJsRevision,
1210
+ configured.emscriptenRevision,
1211
+ configured.manifestReceipt,
1212
+ configured.requireJsReceipt,
1213
+ configured.customDataReceipt,
1214
+ configured.libraryDataReceipt,
1215
+ configured.glueReceipt,
1216
+ configured.wasmReceipt,
1217
+ configured.workerReceipt
1218
+ ].some((value) => value !== undefined);
1219
+ const selectedProfile = hasConfiguredTrust
1220
+ ? {
1221
+ profileId: configured?.profileId?.trim(),
1222
+ artifactRevision: configured?.artifactRevision?.trim(),
1223
+ waclRevision: configured?.waclRevision?.trim(),
1224
+ tclRevision: configured?.tclRevision?.trim(),
1225
+ requireJsRevision: configured?.requireJsRevision?.trim(),
1226
+ emscriptenRevision: configured?.emscriptenRevision?.trim(),
1227
+ manifestFingerprint: configured?.manifestFingerprint?.trim(),
1228
+ manifestReceipt: configured?.manifestReceipt,
1229
+ requireJsReceipt: configured?.requireJsReceipt,
1230
+ customDataReceipt: configured?.customDataReceipt,
1231
+ libraryDataReceipt: configured?.libraryDataReceipt,
1232
+ glueReceipt: configured?.glueReceipt,
1233
+ wasmReceipt: configured?.wasmReceipt
1234
+ }
1235
+ : WASM_TCL_RUNTIME_BUNDLE.profile;
1236
+ const preflightProfile = snapshotTclRuntimePreflightProfile(selectedProfile);
1237
+ const workerReceipt = hasConfiguredTrust
1238
+ ? configured?.workerReceipt
1239
+ : WASM_TCL_RUNTIME_BUNDLE.workerReceipt;
1240
+ if (!workerReceipt) {
1241
+ throw new RuntimeConfigurationError('Tcl runtime requires one complete profile and runner receipt bundle.', { runtimeId: 'TCL' });
1242
+ }
1243
+ return {
1244
+ baseUrl: resolveTclBaseUrl(options, currentUrl),
1245
+ workerUrl: resolveTclWorkerUrl(options, currentUrl),
1246
+ manifestUrl: resolveTclManifestUrl(options, currentUrl),
1247
+ manifestFingerprint: preflightProfile.manifestFingerprint,
1248
+ preflightKey: JSON.stringify(preflightProfile),
1249
+ preflightProfile,
1250
+ workerReceipt
1251
+ };
1252
+ }
1253
+ export function resolveAwkBaseUrl(options, currentUrl = '') {
1254
+ const configuredBaseUrl = (typeof options === 'object' && options?.awk?.baseUrl) ||
1255
+ (publicEnv.PUBLIC_WASM_AWK_BASE_URL || '').trim();
1256
+ if (configuredBaseUrl) {
1257
+ return normalizeBaseUrl(configuredBaseUrl, currentUrl);
1258
+ }
1259
+ if (typeof options === 'string') {
1260
+ return normalizeBaseUrl(`${normalizeRootUrl(options) || ''}/wasm-awk/`, currentUrl);
1261
+ }
1262
+ if (options?.rootUrl) {
1263
+ return normalizeBaseUrl(`${normalizeRootUrl(options.rootUrl) || ''}/wasm-awk/`, currentUrl);
1264
+ }
1265
+ return normalizeBaseUrl('/wasm-awk/', currentUrl);
1266
+ }
1267
+ export function resolveAwkWorkerUrl(options, currentUrl = '') {
1268
+ const configuredWorkerUrl = (typeof options === 'object' && options?.awk?.workerUrl) ||
1269
+ (publicEnv.PUBLIC_WASM_AWK_WORKER_URL || '').trim();
1270
+ if (configuredWorkerUrl) {
1271
+ return resolveConfiguredUrl(configuredWorkerUrl, currentUrl);
1272
+ }
1273
+ if (typeof options === 'string') {
1274
+ return resolveConfiguredUrl(`${normalizeRootUrl(options) || ''}/wasm-awk/runner-worker.v2.js`, currentUrl);
1275
+ }
1276
+ if (options?.rootUrl) {
1277
+ return resolveConfiguredUrl(`${normalizeRootUrl(options.rootUrl) || ''}/wasm-awk/runner-worker.v2.js`, currentUrl);
1278
+ }
1279
+ return resolveConfiguredUrl('/wasm-awk/runner-worker.v2.js', currentUrl);
1280
+ }
1281
+ function resolveAwkPinnedAssetUrl(configuredUrl, currentUrl, expectedFileName, pin) {
1282
+ const sentinelOrigin = 'https://wasm-idle.invalid';
1283
+ let url;
1284
+ try {
1285
+ url = new URL(configuredUrl, currentUrl || sentinelOrigin);
1286
+ }
1287
+ catch (cause) {
1288
+ throw new RuntimeConfigurationError(`AWK runtime ${expectedFileName} URL is invalid.`, {
1289
+ cause,
1290
+ runtimeId: 'AWK'
1291
+ });
1292
+ }
1293
+ if ((url.protocol !== 'http:' && url.protocol !== 'https:') ||
1294
+ url.username ||
1295
+ url.password ||
1296
+ url.hash ||
1297
+ !url.pathname.endsWith(`/${expectedFileName}`) ||
1298
+ (url.search && url.search !== `?v=${pin}`)) {
1299
+ throw new RuntimeConfigurationError(`AWK runtime ${expectedFileName} URL must use its query-pinned immutable path.`, { runtimeId: 'AWK' });
1300
+ }
1301
+ if (!url.search)
1302
+ url.searchParams.set('v', pin);
1303
+ return currentUrl || configuredUrl.startsWith('http://') || configuredUrl.startsWith('https://')
1304
+ ? url.href
1305
+ : `${url.pathname}${url.search}`;
1306
+ }
1307
+ export function resolveAwkRuntimeAssetConfig(options, currentUrl = '') {
1308
+ const configured = typeof options === 'object' ? options?.awk : undefined;
1309
+ const hasConfiguredTrust = !!configured &&
1310
+ [
1311
+ configured.profileId,
1312
+ configured.goVersion,
1313
+ configured.goawkVersion,
1314
+ configured.manifestFingerprint,
1315
+ configured.manifestReceipt,
1316
+ configured.workerReceipt,
1317
+ configured.goShimReceipt,
1318
+ configured.wasmReceipt
1319
+ ].some((value) => value !== undefined);
1320
+ const bundledProfile = snapshotAwkRuntimePreflightProfile(WASM_AWK_RUNTIME_BUNDLE.profile);
1321
+ let preflightProfile = bundledProfile;
1322
+ if (hasConfiguredTrust) {
1323
+ let configuredProfile;
1324
+ try {
1325
+ configuredProfile = snapshotAwkRuntimePreflightProfile({
1326
+ profileId: configured?.profileId?.trim(),
1327
+ goVersion: configured?.goVersion?.trim(),
1328
+ goawkVersion: configured?.goawkVersion?.trim(),
1329
+ manifestFingerprint: configured?.manifestFingerprint?.trim(),
1330
+ manifestReceipt: configured?.manifestReceipt,
1331
+ workerReceipt: configured?.workerReceipt,
1332
+ goShimReceipt: configured?.goShimReceipt,
1333
+ wasmReceipt: configured?.wasmReceipt
1334
+ });
1335
+ }
1336
+ catch (cause) {
1337
+ throw new RuntimeConfigurationError('AWK runtime custom assets require one complete profile and receipt bundle.', { cause, runtimeId: 'AWK' });
1338
+ }
1339
+ if (JSON.stringify(configuredProfile) !== JSON.stringify(bundledProfile)) {
1340
+ throw new RuntimeConfigurationError('AWK runtime public configuration accepts URL mirrors only; receipts must match the bundled profile.', { runtimeId: 'AWK' });
1341
+ }
1342
+ preflightProfile = configuredProfile;
1343
+ }
1344
+ const baseUrl = resolveAwkBaseUrl(options, currentUrl);
1345
+ const workerUrl = resolveAwkPinnedAssetUrl(configured?.workerUrl ||
1346
+ (publicEnv.PUBLIC_WASM_AWK_WORKER_URL || '').trim() ||
1347
+ `${baseUrl}runner-worker.v2.js`, currentUrl, 'runner-worker.v2.js', preflightProfile.workerReceipt.sha256);
1348
+ const manifestUrl = resolveAwkPinnedAssetUrl(configured?.manifestUrl || `${baseUrl}runtime-manifest.v2.json`, currentUrl, 'runtime-manifest.v2.json', preflightProfile.manifestFingerprint);
1349
+ const identity = { baseUrl, workerUrl, manifestUrl, profile: preflightProfile };
1350
+ return {
1351
+ baseUrl,
1352
+ workerUrl,
1353
+ manifestUrl,
1354
+ manifestFingerprint: preflightProfile.manifestFingerprint,
1355
+ preflightKey: JSON.stringify(identity),
1356
+ preflightProfile,
1357
+ workerReceipt: preflightProfile.workerReceipt
1358
+ };
1359
+ }
1360
+ export function resolvePascalBaseUrl(options, currentUrl = '') {
1361
+ const configuredBaseUrl = (typeof options === 'object' && options?.pascal?.baseUrl) ||
1362
+ (publicEnv.PUBLIC_WASM_PASCAL_BASE_URL || '').trim();
1363
+ if (configuredBaseUrl) {
1364
+ return normalizeBaseUrl(configuredBaseUrl, currentUrl);
1365
+ }
1366
+ if (typeof options === 'string') {
1367
+ return normalizeBaseUrl(`${normalizeRootUrl(options) || ''}/wasm-pascal/`, currentUrl);
1368
+ }
1369
+ if (options?.rootUrl) {
1370
+ return normalizeBaseUrl(`${normalizeRootUrl(options.rootUrl) || ''}/wasm-pascal/`, currentUrl);
1371
+ }
1372
+ return normalizeBaseUrl('/wasm-pascal/', currentUrl);
1373
+ }
1374
+ export function resolvePascalWorkerUrl(options, currentUrl = '') {
1375
+ const configuredWorkerUrl = (typeof options === 'object' && options?.pascal?.workerUrl) ||
1376
+ (publicEnv.PUBLIC_WASM_PASCAL_WORKER_URL || '').trim();
1377
+ if (configuredWorkerUrl) {
1378
+ return resolveConfiguredUrl(configuredWorkerUrl, currentUrl);
1379
+ }
1380
+ if (typeof options === 'string') {
1381
+ return resolveConfiguredUrl(`${normalizeRootUrl(options) || ''}/wasm-pascal/runner-worker.js`, currentUrl);
1382
+ }
1383
+ if (options?.rootUrl) {
1384
+ return resolveConfiguredUrl(`${normalizeRootUrl(options.rootUrl) || ''}/wasm-pascal/runner-worker.js`, currentUrl);
1385
+ }
1386
+ return resolveConfiguredUrl('/wasm-pascal/runner-worker.js', currentUrl);
1387
+ }
1388
+ export function resolvePascalRuntimeAssetConfig(options, currentUrl = '') {
1389
+ const configured = typeof options === 'object' ? options?.pascal : undefined;
1390
+ const usesCustomTrustBoundary = Boolean((configured && Object.values(configured).some((value) => value !== undefined)) ||
1391
+ (publicEnv.PUBLIC_WASM_PASCAL_BASE_URL || '').trim() ||
1392
+ (publicEnv.PUBLIC_WASM_PASCAL_WORKER_URL || '').trim());
1393
+ let preflightProfile;
1394
+ try {
1395
+ preflightProfile = snapshotPascalRuntimePreflightProfile(usesCustomTrustBoundary
1396
+ ? {
1397
+ profileId: configured?.profileId?.trim(),
1398
+ artifactRevision: configured?.artifactRevision?.trim(),
1399
+ pas2jsVersion: configured?.pas2jsVersion?.trim(),
1400
+ pas2jsRevision: configured?.pas2jsRevision?.trim(),
1401
+ manifestFingerprint: configured?.manifestFingerprint?.trim(),
1402
+ manifestReceipt: configured?.manifestReceipt,
1403
+ compilerJavaScriptReceipt: configured?.compilerJavaScriptReceipt,
1404
+ rtlJavaScriptReceipt: configured?.rtlJavaScriptReceipt,
1405
+ systemPascalReceipt: configured?.systemPascalReceipt
1406
+ }
1407
+ : WASM_PASCAL_RUNTIME_BUNDLE.profile);
1408
+ }
1409
+ catch (cause) {
1410
+ throw new RuntimeConfigurationError('Pascal runtime custom assets require one complete profile and receipt bundle.', { cause, runtimeId: 'PASCAL' });
1411
+ }
1412
+ const workerReceipt = usesCustomTrustBoundary
1413
+ ? configured?.workerReceipt
1414
+ : WASM_PASCAL_RUNTIME_BUNDLE.workerReceipt;
1415
+ if (!workerReceipt ||
1416
+ Object.keys(workerReceipt).sort().join(',') !== 'bytes,sha256' ||
1417
+ !Number.isSafeInteger(workerReceipt.bytes) ||
1418
+ workerReceipt.bytes <= 0 ||
1419
+ typeof workerReceipt.sha256 !== 'string' ||
1420
+ !/^[a-f0-9]{64}$/u.test(workerReceipt.sha256)) {
1421
+ throw new RuntimeConfigurationError('Pascal runtime custom assets require one complete profile and runner receipt bundle.', { runtimeId: 'PASCAL' });
1422
+ }
1423
+ const baseUrl = resolvePascalBaseUrl(options, currentUrl);
1424
+ const resolvePinnedUrl = (configuredUrl, path, pin) => {
1425
+ const sentinelOrigin = 'https://wasm-idle.invalid';
1426
+ const candidate = resolveConfiguredUrl(configuredUrl || `${baseUrl}${path}`, currentUrl);
1427
+ let url;
1428
+ let expected;
1429
+ try {
1430
+ url = new URL(candidate, currentUrl || sentinelOrigin);
1431
+ expected = new URL(`${baseUrl}${path}`, currentUrl || sentinelOrigin);
1432
+ }
1433
+ catch (cause) {
1434
+ throw new RuntimeConfigurationError(`Pascal runtime ${path} URL is invalid.`, {
1435
+ cause,
1436
+ runtimeId: 'PASCAL'
1437
+ });
1438
+ }
1439
+ if ((url.protocol !== 'http:' && url.protocol !== 'https:') ||
1440
+ url.username ||
1441
+ url.password ||
1442
+ url.hash ||
1443
+ url.origin !== expected.origin ||
1444
+ url.pathname !== expected.pathname ||
1445
+ (url.search && url.search !== `?v=${pin}`)) {
1446
+ throw new RuntimeConfigurationError(`Pascal runtime ${path} URL must use its canonical query-pinned path.`, { runtimeId: 'PASCAL' });
1447
+ }
1448
+ if (!url.search)
1449
+ url.searchParams.set('v', pin);
1450
+ return currentUrl || candidate.startsWith('http://') || candidate.startsWith('https://')
1451
+ ? url.href
1452
+ : `${url.pathname}${url.search}`;
1453
+ };
1454
+ const workerUrl = resolvePinnedUrl(configured?.workerUrl ||
1455
+ (publicEnv.PUBLIC_WASM_PASCAL_WORKER_URL || '').trim() ||
1456
+ resolvePascalWorkerUrl(options, currentUrl), 'runner-worker.js', workerReceipt.sha256);
1457
+ const manifestUrl = resolvePinnedUrl(configured?.manifestUrl, 'runtime-manifest.v2.json', preflightProfile.manifestFingerprint);
1458
+ const compilerJavaScriptUrl = resolvePinnedUrl(configured?.compilerJavaScriptUrl, 'compiler.js.gz.bin', preflightProfile.compilerJavaScriptReceipt.sha256);
1459
+ const rtlJavaScriptUrl = resolvePinnedUrl(configured?.rtlJavaScriptUrl, 'rtl.js.bin', preflightProfile.rtlJavaScriptReceipt.sha256);
1460
+ const systemPascalUrl = resolvePinnedUrl(configured?.systemPascalUrl, 'system.pas.bin', preflightProfile.systemPascalReceipt.sha256);
1461
+ const identity = {
1462
+ baseUrl,
1463
+ workerUrl,
1464
+ manifestUrl,
1465
+ compilerJavaScriptUrl,
1466
+ rtlJavaScriptUrl,
1467
+ systemPascalUrl,
1468
+ profile: preflightProfile,
1469
+ workerReceipt
1470
+ };
1471
+ return {
1472
+ baseUrl,
1473
+ workerUrl,
1474
+ manifestUrl,
1475
+ compilerJavaScriptUrl,
1476
+ rtlJavaScriptUrl,
1477
+ systemPascalUrl,
1478
+ manifestFingerprint: preflightProfile.manifestFingerprint,
1479
+ preflightKey: JSON.stringify(identity),
1480
+ preflightProfile,
1481
+ workerReceipt
1482
+ };
1483
+ }
1484
+ export function resolveClojureScriptBaseUrl(options, currentUrl = '') {
1485
+ const configuredBaseUrl = (typeof options === 'object' && options?.clojurescript?.baseUrl) ||
1486
+ (publicEnv.PUBLIC_WASM_CLOJURESCRIPT_BASE_URL || '').trim();
1487
+ if (configuredBaseUrl)
1488
+ return normalizeBaseUrl(configuredBaseUrl, currentUrl);
1489
+ if (typeof options === 'string') {
1490
+ return normalizeBaseUrl(`${normalizeRootUrl(options) || ''}/wasm-clojurescript/`, currentUrl);
1491
+ }
1492
+ if (options?.rootUrl) {
1493
+ return normalizeBaseUrl(`${normalizeRootUrl(options.rootUrl) || ''}/wasm-clojurescript/`, currentUrl);
1494
+ }
1495
+ return normalizeBaseUrl('/wasm-clojurescript/', currentUrl);
1496
+ }
1497
+ export function resolveClojureScriptWorkerUrl(options, currentUrl = '') {
1498
+ const configuredWorkerUrl = (typeof options === 'object' && options?.clojurescript?.workerUrl) ||
1499
+ (publicEnv.PUBLIC_WASM_CLOJURESCRIPT_WORKER_URL || '').trim();
1500
+ if (configuredWorkerUrl)
1501
+ return resolveConfiguredUrl(configuredWorkerUrl, currentUrl);
1502
+ if (typeof options === 'string') {
1503
+ return resolveConfiguredUrl(`${normalizeRootUrl(options) || ''}/wasm-clojurescript/runner-worker.js`, currentUrl);
1504
+ }
1505
+ if (options?.rootUrl) {
1506
+ return resolveConfiguredUrl(`${normalizeRootUrl(options.rootUrl) || ''}/wasm-clojurescript/runner-worker.js`, currentUrl);
1507
+ }
1508
+ return resolveConfiguredUrl('/wasm-clojurescript/runner-worker.js', currentUrl);
1509
+ }
1510
+ export function resolveClojureScriptManifestUrl(options, currentUrl = '') {
1511
+ const configuredManifestUrl = typeof options === 'object' ? options?.clojurescript?.manifestUrl : undefined;
1512
+ if (configuredManifestUrl) {
1513
+ return resolveConfiguredUrl(configuredManifestUrl, currentUrl);
1514
+ }
1515
+ return `${resolveClojureScriptBaseUrl(options, currentUrl)}runtime-manifest.v2.json`;
1516
+ }
1517
+ export function resolveClojureScriptRuntimeAssetConfig(options, currentUrl = '') {
1518
+ const configured = typeof options === 'object' ? options?.clojurescript : undefined;
1519
+ const manifestFingerprint = configured?.manifestFingerprint?.trim() || WASM_CLOJURESCRIPT_ASSET_VERSION;
1520
+ const usesBundledProfile = manifestFingerprint === WASM_CLOJURESCRIPT_ASSET_VERSION;
1521
+ const receipt = (configuredReceipt, bundledReceipt) => {
1522
+ const selected = configuredReceipt || (usesBundledProfile ? bundledReceipt : undefined);
1523
+ return selected
1524
+ ? Object.freeze({
1525
+ bytes: selected.bytes,
1526
+ sha256: selected.sha256,
1527
+ ...(selected.uncompressedBytes === undefined
1528
+ ? {}
1529
+ : { uncompressedBytes: selected.uncompressedBytes }),
1530
+ ...(selected.uncompressedSha256 === undefined
1531
+ ? {}
1532
+ : { uncompressedSha256: selected.uncompressedSha256 })
1533
+ })
1534
+ : undefined;
1535
+ };
1536
+ const preflightProfile = Object.freeze({
1537
+ profileId: configured?.profileId?.trim() ||
1538
+ (usesBundledProfile ? WASM_CLOJURESCRIPT_RUNTIME_PROFILE.profileId : ''),
1539
+ sourceRevision: configured?.sourceRevision?.trim() ||
1540
+ (usesBundledProfile ? WASM_CLOJURESCRIPT_RUNTIME_PROFILE.sourceRevision : ''),
1541
+ integrationRevision: configured?.integrationRevision?.trim() ||
1542
+ (usesBundledProfile ? WASM_CLOJURESCRIPT_RUNTIME_PROFILE.integrationRevision : ''),
1543
+ manifestFingerprint,
1544
+ manifestReceipt: receipt(configured?.manifestReceipt, WASM_CLOJURESCRIPT_RUNTIME_PROFILE.manifestReceipt),
1545
+ compilerReceipt: receipt(configured?.compilerReceipt, WASM_CLOJURESCRIPT_RUNTIME_PROFILE.compilerReceipt)
1546
+ });
1547
+ return {
1548
+ baseUrl: resolveClojureScriptBaseUrl(options, currentUrl),
1549
+ workerUrl: resolveClojureScriptWorkerUrl(options, currentUrl),
1550
+ manifestUrl: resolveClojureScriptManifestUrl(options, currentUrl),
1551
+ manifestFingerprint,
1552
+ preflightKey: JSON.stringify(preflightProfile),
1553
+ preflightProfile,
1554
+ workerReceipt: configured?.workerReceipt || WASM_CLOJURESCRIPT_RUNNER_RECEIPT
1555
+ };
1556
+ }
1557
+ export function resolveForthBaseUrl(options, currentUrl = '') {
1558
+ const configuredBaseUrl = (typeof options === 'object' && options?.forth?.baseUrl) ||
1559
+ (publicEnv.PUBLIC_WASM_FORTH_BASE_URL || '').trim();
1560
+ if (configuredBaseUrl) {
1561
+ return normalizeBaseUrl(configuredBaseUrl, currentUrl);
1562
+ }
1563
+ if (typeof options === 'string') {
1564
+ return normalizeBaseUrl(`${normalizeRootUrl(options) || ''}/wasm-forth/`, currentUrl);
1565
+ }
1566
+ if (options?.rootUrl) {
1567
+ return normalizeBaseUrl(`${normalizeRootUrl(options.rootUrl) || ''}/wasm-forth/`, currentUrl);
1568
+ }
1569
+ return normalizeBaseUrl('/wasm-forth/', currentUrl);
1570
+ }
1571
+ export function resolveForthWorkerUrl(options, currentUrl = '') {
1572
+ const configuredWorkerUrl = (typeof options === 'object' && options?.forth?.workerUrl) ||
1573
+ (publicEnv.PUBLIC_WASM_FORTH_WORKER_URL || '').trim();
1574
+ if (configuredWorkerUrl) {
1575
+ return resolveConfiguredUrl(configuredWorkerUrl, currentUrl);
1576
+ }
1577
+ return `${resolveForthBaseUrl(options, currentUrl)}runner-worker.js`;
1578
+ }
1579
+ export function resolveForthManifestUrl(options, currentUrl = '') {
1580
+ const configuredManifestUrl = typeof options === 'object' ? options?.forth?.manifestUrl : undefined;
1581
+ if (configuredManifestUrl) {
1582
+ return resolveConfiguredUrl(configuredManifestUrl, currentUrl);
1583
+ }
1584
+ return `${resolveForthBaseUrl(options, currentUrl)}runtime-manifest.v2.json`;
1585
+ }
1586
+ export function resolveForthRuntimeAssetConfig(options, currentUrl = '') {
1587
+ const configured = typeof options === 'object' ? options?.forth : undefined;
1588
+ const manifestFingerprint = configured?.manifestFingerprint?.trim() || WASM_FORTH_ASSET_VERSION;
1589
+ const usesBundledProfile = manifestFingerprint === WASM_FORTH_ASSET_VERSION;
1590
+ const manifestReceipt = configured?.manifestReceipt ||
1591
+ (usesBundledProfile ? WASM_FORTH_RUNTIME_PROFILE.manifestReceipt : undefined);
1592
+ const runtimeReceipt = configured?.runtimeReceipt ||
1593
+ (usesBundledProfile ? WASM_FORTH_RUNTIME_PROFILE.runtimeReceipt : undefined);
1594
+ const preflightProfile = Object.freeze({
1595
+ profileId: configured?.profileId?.trim() ||
1596
+ (usesBundledProfile ? WASM_FORTH_RUNTIME_PROFILE.profileId : ''),
1597
+ implementationVersion: configured?.implementationVersion?.trim() ||
1598
+ (usesBundledProfile ? WASM_FORTH_RUNTIME_PROFILE.implementationVersion : ''),
1599
+ manifestFingerprint,
1600
+ manifestReceipt: manifestReceipt
1601
+ ? Object.freeze({ bytes: manifestReceipt.bytes, sha256: manifestReceipt.sha256 })
1602
+ : undefined,
1603
+ runtimeReceipt: runtimeReceipt
1604
+ ? Object.freeze({ bytes: runtimeReceipt.bytes, sha256: runtimeReceipt.sha256 })
1605
+ : undefined
1606
+ });
1607
+ return {
1608
+ baseUrl: resolveForthBaseUrl(options, currentUrl),
1609
+ workerUrl: resolveForthWorkerUrl(options, currentUrl),
1610
+ manifestUrl: resolveForthManifestUrl(options, currentUrl),
1611
+ manifestFingerprint,
1612
+ preflightKey: JSON.stringify(preflightProfile),
1613
+ preflightProfile,
1614
+ workerReceipt: configured?.workerReceipt || WASM_FORTH_RUNNER_RECEIPT
1615
+ };
1616
+ }
1617
+ export function resolveJBaseUrl(options, currentUrl = '') {
1618
+ const configuredBaseUrl = (typeof options === 'object' && options?.j?.baseUrl) ||
1619
+ (publicEnv.PUBLIC_WASM_J_BASE_URL || '').trim();
1620
+ if (configuredBaseUrl) {
1621
+ return normalizeBaseUrl(configuredBaseUrl, currentUrl);
1622
+ }
1623
+ if (typeof options === 'string') {
1624
+ return normalizeBaseUrl(`${normalizeRootUrl(options) || ''}/wasm-j/`, currentUrl);
1625
+ }
1626
+ if (options?.rootUrl) {
1627
+ return normalizeBaseUrl(`${normalizeRootUrl(options.rootUrl) || ''}/wasm-j/`, currentUrl);
1628
+ }
1629
+ return normalizeBaseUrl('/wasm-j/', currentUrl);
1630
+ }
1631
+ export function resolveJWorkerUrl(options, currentUrl = '') {
1632
+ const configuredWorkerUrl = (typeof options === 'object' && options?.j?.workerUrl) ||
1633
+ (publicEnv.PUBLIC_WASM_J_WORKER_URL || '').trim();
1634
+ if (configuredWorkerUrl) {
1635
+ return resolveConfiguredUrl(configuredWorkerUrl, currentUrl);
1636
+ }
1637
+ if (typeof options === 'string') {
1638
+ return resolveConfiguredUrl(`${normalizeRootUrl(options) || ''}/wasm-j/runner-worker.js`, currentUrl);
1639
+ }
1640
+ if (options?.rootUrl) {
1641
+ return resolveConfiguredUrl(`${normalizeRootUrl(options.rootUrl) || ''}/wasm-j/runner-worker.js`, currentUrl);
1642
+ }
1643
+ return resolveConfiguredUrl('/wasm-j/runner-worker.js', currentUrl);
1644
+ }
1645
+ export function resolveJManifestUrl(options, currentUrl = '') {
1646
+ const configuredManifestUrl = typeof options === 'object' ? options?.j?.manifestUrl : undefined;
1647
+ if (configuredManifestUrl) {
1648
+ return resolveConfiguredUrl(configuredManifestUrl, currentUrl);
1649
+ }
1650
+ return `${resolveJBaseUrl(options, currentUrl)}runtime-manifest.v2.json`;
1651
+ }
1652
+ export function resolveJRuntimeAssetConfig(options, currentUrl = '') {
1653
+ const configured = typeof options === 'object' ? options?.j : undefined;
1654
+ const manifestFingerprint = configured?.manifestFingerprint?.trim() || WASM_J_ASSET_VERSION;
1655
+ const usesBundledProfile = manifestFingerprint === WASM_J_ASSET_VERSION;
1656
+ const receipt = (configuredReceipt, bundledReceipt) => {
1657
+ const selected = configuredReceipt || (usesBundledProfile ? bundledReceipt : undefined);
1658
+ return selected
1659
+ ? Object.freeze({
1660
+ bytes: selected.bytes,
1661
+ sha256: selected.sha256,
1662
+ ...(selected.uncompressedBytes === undefined
1663
+ ? {}
1664
+ : { uncompressedBytes: selected.uncompressedBytes }),
1665
+ ...(selected.uncompressedSha256 === undefined
1666
+ ? {}
1667
+ : { uncompressedSha256: selected.uncompressedSha256 })
1668
+ })
1669
+ : undefined;
1670
+ };
1671
+ const preflightProfile = Object.freeze({
1672
+ profileId: configured?.profileId?.trim() ||
1673
+ (usesBundledProfile ? WASM_J_RUNTIME_PROFILE.profileId : ''),
1674
+ sourceRevision: configured?.sourceRevision?.trim() ||
1675
+ (usesBundledProfile ? WASM_J_RUNTIME_PROFILE.sourceRevision : ''),
1676
+ manifestFingerprint,
1677
+ manifestReceipt: receipt(configured?.manifestReceipt, WASM_J_RUNTIME_PROFILE.manifestReceipt),
1678
+ moduleReceipt: receipt(configured?.moduleReceipt, WASM_J_RUNTIME_PROFILE.moduleReceipt),
1679
+ wasmReceipt: receipt(configured?.wasmReceipt, WASM_J_RUNTIME_PROFILE.wasmReceipt)
1680
+ });
1681
+ return {
1682
+ baseUrl: resolveJBaseUrl(options, currentUrl),
1683
+ workerUrl: resolveJWorkerUrl(options, currentUrl),
1684
+ manifestUrl: resolveJManifestUrl(options, currentUrl),
1685
+ manifestFingerprint,
1686
+ preflightKey: JSON.stringify(preflightProfile),
1687
+ preflightProfile,
1688
+ workerReceipt: configured?.workerReceipt || WASM_J_RUNNER_RECEIPT
1689
+ };
1690
+ }
1691
+ export function resolveBqnBaseUrl(options, currentUrl = '') {
1692
+ const configuredBaseUrl = (typeof options === 'object' && options?.bqn?.baseUrl) ||
1693
+ (publicEnv.PUBLIC_WASM_BQN_BASE_URL || '').trim();
1694
+ if (configuredBaseUrl) {
1695
+ return normalizeBaseUrl(configuredBaseUrl, currentUrl);
1696
+ }
1697
+ if (typeof options === 'string') {
1698
+ return normalizeBaseUrl(`${normalizeRootUrl(options) || ''}/wasm-bqn/`, currentUrl);
1699
+ }
1700
+ if (options?.rootUrl) {
1701
+ return normalizeBaseUrl(`${normalizeRootUrl(options.rootUrl) || ''}/wasm-bqn/`, currentUrl);
1702
+ }
1703
+ return normalizeBaseUrl('/wasm-bqn/', currentUrl);
1704
+ }
1705
+ export function resolveBqnWorkerUrl(options, currentUrl = '') {
1706
+ const configuredWorkerUrl = (typeof options === 'object' && options?.bqn?.workerUrl) ||
1707
+ (publicEnv.PUBLIC_WASM_BQN_WORKER_URL || '').trim();
1708
+ if (configuredWorkerUrl) {
1709
+ return resolveConfiguredUrl(configuredWorkerUrl, currentUrl);
1710
+ }
1711
+ if (typeof options === 'string') {
1712
+ return resolveConfiguredUrl(`${normalizeRootUrl(options) || ''}/wasm-bqn/runner-worker.js`, currentUrl);
1713
+ }
1714
+ if (options?.rootUrl) {
1715
+ return resolveConfiguredUrl(`${normalizeRootUrl(options.rootUrl) || ''}/wasm-bqn/runner-worker.js`, currentUrl);
1716
+ }
1717
+ return resolveConfiguredUrl('/wasm-bqn/runner-worker.js', currentUrl);
1718
+ }
1719
+ export function resolveBqnManifestUrl(options, currentUrl = '') {
1720
+ const configuredManifestUrl = typeof options === 'object' ? options?.bqn?.manifestUrl : undefined;
1721
+ if (configuredManifestUrl) {
1722
+ return resolveConfiguredUrl(configuredManifestUrl, currentUrl);
1723
+ }
1724
+ return `${resolveBqnBaseUrl(options, currentUrl)}runtime-manifest.v2.json`;
1725
+ }
1726
+ export function resolveBqnRuntimeAssetConfig(options, currentUrl = '') {
1727
+ const configured = typeof options === 'object' ? options?.bqn : undefined;
1728
+ const manifestFingerprint = configured?.manifestFingerprint?.trim() || WASM_BQN_ASSET_VERSION;
1729
+ const usesBundledProfile = manifestFingerprint === WASM_BQN_ASSET_VERSION;
1730
+ const receipt = (configuredReceipt, bundledReceipt) => {
1731
+ const selected = configuredReceipt || (usesBundledProfile ? bundledReceipt : undefined);
1732
+ return selected
1733
+ ? Object.freeze({
1734
+ bytes: selected.bytes,
1735
+ sha256: selected.sha256,
1736
+ ...(selected.uncompressedBytes === undefined
1737
+ ? {}
1738
+ : { uncompressedBytes: selected.uncompressedBytes }),
1739
+ ...(selected.uncompressedSha256 === undefined
1740
+ ? {}
1741
+ : { uncompressedSha256: selected.uncompressedSha256 })
1742
+ })
1743
+ : undefined;
1744
+ };
1745
+ const preflightProfile = Object.freeze({
1746
+ profileId: configured?.profileId?.trim() ||
1747
+ (usesBundledProfile ? WASM_BQN_RUNTIME_PROFILE.profileId : ''),
1748
+ sourceRevision: configured?.sourceRevision?.trim() ||
1749
+ (usesBundledProfile ? WASM_BQN_RUNTIME_PROFILE.sourceRevision : ''),
1750
+ manifestFingerprint,
1751
+ manifestReceipt: receipt(configured?.manifestReceipt, WASM_BQN_RUNTIME_PROFILE.manifestReceipt),
1752
+ moduleReceipt: receipt(configured?.moduleReceipt, WASM_BQN_RUNTIME_PROFILE.moduleReceipt),
1753
+ wasmReceipt: receipt(configured?.wasmReceipt, WASM_BQN_RUNTIME_PROFILE.wasmReceipt)
1754
+ });
1755
+ return {
1756
+ baseUrl: resolveBqnBaseUrl(options, currentUrl),
1757
+ workerUrl: resolveBqnWorkerUrl(options, currentUrl),
1758
+ manifestUrl: resolveBqnManifestUrl(options, currentUrl),
1759
+ manifestFingerprint,
1760
+ preflightKey: JSON.stringify(preflightProfile),
1761
+ preflightProfile,
1762
+ workerReceipt: configured?.workerReceipt || WASM_BQN_RUNNER_RECEIPT
1763
+ };
1764
+ }
1765
+ export function resolveJanetBaseUrl(options, currentUrl = '') {
1766
+ const configuredBaseUrl = (typeof options === 'object' && options?.janet?.baseUrl) ||
1767
+ (publicEnv.PUBLIC_WASM_JANET_BASE_URL || '').trim();
1768
+ if (configuredBaseUrl) {
1769
+ return normalizeBaseUrl(configuredBaseUrl, currentUrl);
1770
+ }
1771
+ if (typeof options === 'string') {
1772
+ return normalizeBaseUrl(`${normalizeRootUrl(options) || ''}/wasm-janet/`, currentUrl);
1773
+ }
1774
+ if (options?.rootUrl) {
1775
+ return normalizeBaseUrl(`${normalizeRootUrl(options.rootUrl) || ''}/wasm-janet/`, currentUrl);
1776
+ }
1777
+ return normalizeBaseUrl('/wasm-janet/', currentUrl);
1778
+ }
1779
+ export function resolveJanetWorkerUrl(options, currentUrl = '') {
1780
+ const configuredWorkerUrl = (typeof options === 'object' && options?.janet?.workerUrl) ||
1781
+ (publicEnv.PUBLIC_WASM_JANET_WORKER_URL || '').trim();
1782
+ if (configuredWorkerUrl) {
1783
+ return resolveConfiguredUrl(configuredWorkerUrl, currentUrl);
1784
+ }
1785
+ if (typeof options === 'string') {
1786
+ return resolveConfiguredUrl(`${normalizeRootUrl(options) || ''}/wasm-janet/runner-worker.js`, currentUrl);
1787
+ }
1788
+ if (options?.rootUrl) {
1789
+ return resolveConfiguredUrl(`${normalizeRootUrl(options.rootUrl) || ''}/wasm-janet/runner-worker.js`, currentUrl);
1790
+ }
1791
+ return resolveConfiguredUrl('/wasm-janet/runner-worker.js', currentUrl);
1792
+ }
1793
+ export function resolveJanetManifestUrl(options, currentUrl = '') {
1794
+ const configuredManifestUrl = (typeof options === 'object' && options?.janet?.manifestUrl) ||
1795
+ (publicEnv.PUBLIC_WASM_JANET_MANIFEST_URL || '').trim();
1796
+ if (configuredManifestUrl)
1797
+ return resolveConfiguredUrl(configuredManifestUrl, currentUrl);
1798
+ return `${resolveJanetBaseUrl(options, currentUrl)}runtime-manifest.v2.json`;
1799
+ }
1800
+ export function resolveJanetRuntimeAssetConfig(options, currentUrl = '') {
1801
+ const configured = typeof options === 'object' ? options?.janet : undefined;
1802
+ const envManifestFingerprint = (publicEnv.PUBLIC_WASM_JANET_MANIFEST_FINGERPRINT || '').trim();
1803
+ const envWorkerSha256 = (publicEnv.PUBLIC_WASM_JANET_WORKER_SHA256 || '').trim();
1804
+ const envWorkerBytesSource = (publicEnv.PUBLIC_WASM_JANET_WORKER_BYTES || '').trim();
1805
+ const usesCustomUrls = Boolean(configured?.baseUrl ||
1806
+ configured?.workerUrl ||
1807
+ configured?.manifestUrl ||
1808
+ (publicEnv.PUBLIC_WASM_JANET_BASE_URL || '').trim() ||
1809
+ (publicEnv.PUBLIC_WASM_JANET_WORKER_URL || '').trim() ||
1810
+ (publicEnv.PUBLIC_WASM_JANET_MANIFEST_URL || '').trim());
1811
+ const hasConfiguredTrust = !!configured &&
1812
+ [
1813
+ configured.manifestFingerprint,
1814
+ configured.profileId,
1815
+ configured.artifactRevision,
1816
+ configured.janetVersion,
1817
+ configured.emscriptenVersion,
1818
+ configured.manifestReceipt,
1819
+ configured.javascriptReceipt,
1820
+ configured.wasmReceipt,
1821
+ configured.workerReceipt
1822
+ ].some((value) => value !== undefined);
1823
+ const usesCustomTrustBoundary = usesCustomUrls ||
1824
+ hasConfiguredTrust ||
1825
+ Boolean(envManifestFingerprint || envWorkerSha256 || envWorkerBytesSource);
1826
+ const selectedProfile = usesCustomTrustBoundary
1827
+ ? {
1828
+ profileId: configured?.profileId?.trim(),
1829
+ artifactRevision: configured?.artifactRevision?.trim(),
1830
+ janetVersion: configured?.janetVersion?.trim(),
1831
+ emscriptenVersion: configured?.emscriptenVersion?.trim(),
1832
+ manifestFingerprint: configured?.manifestFingerprint?.trim(),
1833
+ manifestReceipt: configured?.manifestReceipt,
1834
+ javascriptReceipt: configured?.javascriptReceipt,
1835
+ wasmReceipt: configured?.wasmReceipt
1836
+ }
1837
+ : WASM_JANET_RUNTIME_BUNDLE.profile;
1838
+ const preflightProfile = snapshotJanetRuntimePreflightProfile(selectedProfile);
1839
+ const workerReceipt = usesCustomTrustBoundary
1840
+ ? configured?.workerReceipt
1841
+ : WASM_JANET_RUNTIME_BUNDLE.workerReceipt;
1842
+ if (!workerReceipt) {
1843
+ throw new RuntimeConfigurationError('Janet runtime requires one complete profile and runner receipt bundle.', { runtimeId: 'JANET' });
1844
+ }
1845
+ return {
1846
+ baseUrl: resolveJanetBaseUrl(options, currentUrl),
1847
+ workerUrl: resolveJanetWorkerUrl(options, currentUrl),
1848
+ manifestUrl: resolveJanetManifestUrl(options, currentUrl),
1849
+ manifestFingerprint: preflightProfile.manifestFingerprint,
1850
+ preflightKey: JSON.stringify(preflightProfile),
1851
+ preflightProfile,
1852
+ workerReceipt
1853
+ };
1854
+ }
1855
+ export function resolveJuliaBaseUrl(options, currentUrl = '') {
1856
+ const configuredBaseUrl = (typeof options === 'object' && options?.julia?.baseUrl) ||
1857
+ (publicEnv.PUBLIC_WASM_JULIA_BASE_URL || '').trim();
1858
+ if (configuredBaseUrl) {
1859
+ return normalizeBaseUrl(configuredBaseUrl, currentUrl);
1860
+ }
1861
+ if (typeof options === 'string') {
1862
+ return normalizeBaseUrl(`${normalizeRootUrl(options) || ''}/wasm-julia/`, currentUrl);
1863
+ }
1864
+ if (options?.rootUrl) {
1865
+ return normalizeBaseUrl(`${normalizeRootUrl(options.rootUrl) || ''}/wasm-julia/`, currentUrl);
1866
+ }
1867
+ return normalizeBaseUrl('/wasm-julia/', currentUrl);
1868
+ }
1869
+ export function resolveJuliaWorkerUrl(options, currentUrl = '') {
1870
+ const configuredWorkerUrl = (typeof options === 'object' && options?.julia?.workerUrl) ||
1871
+ (publicEnv.PUBLIC_WASM_JULIA_WORKER_URL || '').trim();
1872
+ if (configuredWorkerUrl) {
1873
+ return resolveConfiguredUrl(configuredWorkerUrl, currentUrl);
1874
+ }
1875
+ if (typeof options === 'string') {
1876
+ return resolveConfiguredUrl(`${normalizeRootUrl(options) || ''}/wasm-julia/runner-worker.js`, currentUrl);
1877
+ }
1878
+ if (options?.rootUrl) {
1879
+ return resolveConfiguredUrl(`${normalizeRootUrl(options.rootUrl) || ''}/wasm-julia/runner-worker.js`, currentUrl);
1880
+ }
1881
+ return resolveConfiguredUrl('/wasm-julia/runner-worker.js', currentUrl);
1882
+ }
1883
+ export function resolveJuliaRuntimeAssetConfig(options, currentUrl = '') {
1884
+ const configured = typeof options === 'object' ? options?.julia : undefined;
1885
+ const envManifestFingerprint = (publicEnv.PUBLIC_WASM_JULIA_MANIFEST_FINGERPRINT || '').trim();
1886
+ const envWorkerSha256 = (publicEnv.PUBLIC_WASM_JULIA_WORKER_SHA256 || '').trim();
1887
+ const envWorkerBytesSource = (publicEnv.PUBLIC_WASM_JULIA_WORKER_BYTES || '').trim();
1888
+ const usesCustomUrls = Boolean(configured?.baseUrl ||
1889
+ configured?.workerUrl ||
1890
+ configured?.manifestUrl ||
1891
+ (publicEnv.PUBLIC_WASM_JULIA_BASE_URL || '').trim() ||
1892
+ (publicEnv.PUBLIC_WASM_JULIA_WORKER_URL || '').trim() ||
1893
+ (publicEnv.PUBLIC_WASM_JULIA_MANIFEST_URL || '').trim());
1894
+ const hasConfiguredTrust = !!configured &&
1895
+ [
1896
+ configured.manifestFingerprint,
1897
+ configured.profileId,
1898
+ configured.packageRevision,
1899
+ configured.importedByCommit,
1900
+ configured.juliaVersion,
1901
+ configured.emscriptenVersion,
1902
+ configured.manifestReceipt,
1903
+ configured.javascriptReceipt,
1904
+ configured.wasmReceipt,
1905
+ configured.dataReceipt,
1906
+ configured.workerReceipt
1907
+ ].some((value) => value !== undefined);
1908
+ const usesCustomTrustBoundary = usesCustomUrls ||
1909
+ hasConfiguredTrust ||
1910
+ Boolean(envManifestFingerprint || envWorkerSha256 || envWorkerBytesSource);
1911
+ const selectedProfile = usesCustomTrustBoundary
1912
+ ? {
1913
+ profileId: configured?.profileId?.trim(),
1914
+ packageRevision: configured?.packageRevision?.trim(),
1915
+ importedByCommit: configured?.importedByCommit?.trim(),
1916
+ juliaVersion: configured?.juliaVersion?.trim(),
1917
+ emscriptenVersion: configured?.emscriptenVersion?.trim(),
1918
+ manifestFingerprint: configured?.manifestFingerprint?.trim(),
1919
+ manifestReceipt: configured?.manifestReceipt,
1920
+ javascriptReceipt: configured?.javascriptReceipt,
1921
+ wasmReceipt: configured?.wasmReceipt,
1922
+ dataReceipt: configured?.dataReceipt
1923
+ }
1924
+ : WASM_JULIA_RUNTIME_BUNDLE.profile;
1925
+ const preflightProfile = snapshotJuliaRuntimePreflightProfile(selectedProfile);
1926
+ const workerReceipt = usesCustomTrustBoundary
1927
+ ? configured?.workerReceipt
1928
+ : WASM_JULIA_RUNTIME_BUNDLE.workerReceipt;
1929
+ if (!workerReceipt) {
1930
+ throw new RuntimeConfigurationError('Julia runtime requires one complete profile and runner receipt bundle.', { runtimeId: 'JULIA' });
1931
+ }
1932
+ return {
1933
+ baseUrl: resolveJuliaBaseUrl(options, currentUrl),
1934
+ workerUrl: resolveJuliaWorkerUrl(options, currentUrl),
1935
+ manifestUrl: resolveJuliaManifestUrl(options, currentUrl),
1936
+ manifestFingerprint: preflightProfile.manifestFingerprint,
1937
+ preflightKey: JSON.stringify(preflightProfile),
1938
+ preflightProfile,
1939
+ workerReceipt
1940
+ };
1941
+ }
1942
+ export function resolveJuliaManifestUrl(options, currentUrl = '') {
1943
+ const configuredManifestUrl = (typeof options === 'object' && options?.julia?.manifestUrl) ||
1944
+ (publicEnv.PUBLIC_WASM_JULIA_MANIFEST_URL || '').trim();
1945
+ if (configuredManifestUrl)
1946
+ return resolveConfiguredUrl(configuredManifestUrl, currentUrl);
1947
+ return `${resolveJuliaBaseUrl(options, currentUrl)}runtime-manifest.v2.json`;
1948
+ }
1949
+ export function resolveNimBaseUrl(options, currentUrl = '') {
1950
+ const configuredBaseUrl = (typeof options === 'object' && options?.nim?.baseUrl) ||
1951
+ (publicEnv.PUBLIC_WASM_NIM_BASE_URL || '').trim();
1952
+ if (configuredBaseUrl) {
1953
+ return normalizeBaseUrl(configuredBaseUrl, currentUrl);
1954
+ }
1955
+ if (typeof options === 'string') {
1956
+ return normalizeBaseUrl(`${normalizeRootUrl(options) || ''}/wasm-nim/`, currentUrl);
1957
+ }
1958
+ if (options?.rootUrl) {
1959
+ return normalizeBaseUrl(`${normalizeRootUrl(options.rootUrl) || ''}/wasm-nim/`, currentUrl);
1960
+ }
1961
+ return normalizeBaseUrl('/wasm-nim/', currentUrl);
1962
+ }
1963
+ export function resolveNimWorkerUrl(options, currentUrl = '') {
1964
+ const configuredWorkerUrl = (typeof options === 'object' && options?.nim?.workerUrl) ||
1965
+ (publicEnv.PUBLIC_WASM_NIM_WORKER_URL || '').trim();
1966
+ if (configuredWorkerUrl) {
1967
+ return resolveConfiguredUrl(configuredWorkerUrl, currentUrl);
1968
+ }
1969
+ if (typeof options === 'string') {
1970
+ return resolveConfiguredUrl(`${normalizeRootUrl(options) || ''}/wasm-nim/runner-worker.js`, currentUrl);
1971
+ }
1972
+ if (options?.rootUrl) {
1973
+ return resolveConfiguredUrl(`${normalizeRootUrl(options.rootUrl) || ''}/wasm-nim/runner-worker.js`, currentUrl);
1974
+ }
1975
+ return resolveConfiguredUrl('/wasm-nim/runner-worker.js', currentUrl);
1976
+ }
1977
+ export function resolveNimRuntimeAssetConfig(options, currentUrl = '') {
1978
+ const configured = typeof options === 'object' ? options?.nim : undefined;
1979
+ const envManifestFingerprint = (publicEnv.PUBLIC_WASM_NIM_MANIFEST_FINGERPRINT || '').trim();
1980
+ const envWorkerSha256 = (publicEnv.PUBLIC_WASM_NIM_WORKER_SHA256 || '').trim();
1981
+ const envWorkerBytesSource = (publicEnv.PUBLIC_WASM_NIM_WORKER_BYTES || '').trim();
1982
+ const envWorkerBytes = /^\d+$/u.test(envWorkerBytesSource)
1983
+ ? Number(envWorkerBytesSource)
1984
+ : Number.NaN;
1985
+ const envWorkerReceipt = /^[a-f0-9]{64}$/u.test(envWorkerSha256) &&
1986
+ Number.isSafeInteger(envWorkerBytes) &&
1987
+ envWorkerBytes > 0
1988
+ ? { bytes: envWorkerBytes, sha256: envWorkerSha256 }
1989
+ : undefined;
1990
+ const usesCustomUrls = Boolean(configured?.baseUrl ||
1991
+ configured?.workerUrl ||
1992
+ configured?.manifestUrl ||
1993
+ (publicEnv.PUBLIC_WASM_NIM_BASE_URL || '').trim() ||
1994
+ (publicEnv.PUBLIC_WASM_NIM_WORKER_URL || '').trim() ||
1995
+ (publicEnv.PUBLIC_WASM_NIM_MANIFEST_URL || '').trim());
1996
+ const hasConfiguredTrust = !!configured &&
1997
+ [
1998
+ configured.manifestFingerprint,
1999
+ configured.profileId,
2000
+ configured.artifactRevision,
2001
+ configured.nimRevision,
2002
+ configured.llvmRevision,
2003
+ configured.memfsRevision,
2004
+ configured.emscriptenRevision,
2005
+ configured.manifestReceipt,
2006
+ configured.nimJavaScriptReceipt,
2007
+ configured.nimWasmReceipt,
2008
+ configured.nimbaseReceipt,
2009
+ configured.clangJavaScriptReceipt,
2010
+ configured.clangWasmReceipt,
2011
+ configured.lldWasmReceipt,
2012
+ configured.memfsWasmReceipt,
2013
+ configured.sysrootReceipt,
2014
+ configured.workerReceipt
2015
+ ].some((value) => value !== undefined);
2016
+ const usesCustomTrustBoundary = usesCustomUrls ||
2017
+ hasConfiguredTrust ||
2018
+ Boolean(envManifestFingerprint || envWorkerSha256 || envWorkerBytesSource);
2019
+ const selectedProfile = usesCustomTrustBoundary
2020
+ ? {
2021
+ profileId: configured?.profileId?.trim(),
2022
+ artifactRevision: configured?.artifactRevision?.trim(),
2023
+ nimRevision: configured?.nimRevision?.trim(),
2024
+ llvmRevision: configured?.llvmRevision?.trim(),
2025
+ memfsRevision: configured?.memfsRevision?.trim(),
2026
+ emscriptenRevision: configured?.emscriptenRevision?.trim(),
2027
+ manifestFingerprint: configured?.manifestFingerprint?.trim() || envManifestFingerprint,
2028
+ manifestReceipt: configured?.manifestReceipt,
2029
+ nimJavaScriptReceipt: configured?.nimJavaScriptReceipt,
2030
+ nimWasmReceipt: configured?.nimWasmReceipt,
2031
+ nimbaseReceipt: configured?.nimbaseReceipt,
2032
+ clangJavaScriptReceipt: configured?.clangJavaScriptReceipt,
2033
+ clangWasmReceipt: configured?.clangWasmReceipt,
2034
+ lldWasmReceipt: configured?.lldWasmReceipt,
2035
+ memfsWasmReceipt: configured?.memfsWasmReceipt,
2036
+ sysrootReceipt: configured?.sysrootReceipt
2037
+ }
2038
+ : WASM_NIM_RUNTIME_BUNDLE.profile;
2039
+ const preflightProfile = snapshotNimRuntimePreflightProfile(selectedProfile);
2040
+ const workerReceipt = usesCustomTrustBoundary
2041
+ ? configured?.workerReceipt || envWorkerReceipt
2042
+ : WASM_NIM_RUNTIME_BUNDLE.workerReceipt;
2043
+ if (!workerReceipt ||
2044
+ !Number.isSafeInteger(workerReceipt.bytes) ||
2045
+ workerReceipt.bytes <= 0 ||
2046
+ !/^[a-f0-9]{64}$/u.test(workerReceipt.sha256)) {
2047
+ throw new RuntimeConfigurationError('Nim runtime requires one complete profile and runner receipt bundle.', { runtimeId: 'NIM' });
2048
+ }
2049
+ const hasConfiguredManifestUrl = Boolean(configured?.manifestUrl || (publicEnv.PUBLIC_WASM_NIM_MANIFEST_URL || '').trim());
2050
+ const baseUrl = resolveNimBaseUrl(options, currentUrl);
2051
+ const resolvedManifestUrl = resolveNimManifestUrl(options, currentUrl);
2052
+ const manifestUrl = hasConfiguredManifestUrl
2053
+ ? resolvedManifestUrl
2054
+ : `${resolvedManifestUrl}?v=${preflightProfile.manifestFingerprint}`;
2055
+ try {
2056
+ const comparisonBaseUrl = new URL(baseUrl, 'https://wasm-idle.invalid/');
2057
+ const expectedManifestUrl = new URL('runtime-manifest.v2.json', comparisonBaseUrl);
2058
+ expectedManifestUrl.search = `?v=${preflightProfile.manifestFingerprint}`;
2059
+ if (new URL(manifestUrl, comparisonBaseUrl).href !== expectedManifestUrl.href) {
2060
+ throw new Error('manifest URL mismatch');
2061
+ }
2062
+ }
2063
+ catch (error) {
2064
+ throw new RuntimeConfigurationError('Nim runtime manifest URL must be the canonical query-pinned v2 manifest.', { cause: error, runtimeId: 'NIM' });
2065
+ }
2066
+ return {
2067
+ baseUrl,
2068
+ workerUrl: resolveNimWorkerUrl(options, currentUrl),
2069
+ manifestUrl,
2070
+ manifestFingerprint: preflightProfile.manifestFingerprint,
2071
+ preflightKey: JSON.stringify(preflightProfile),
2072
+ preflightProfile,
2073
+ workerReceipt
2074
+ };
2075
+ }
2076
+ export function resolveNimManifestUrl(options, currentUrl = '') {
2077
+ const configuredManifestUrl = (typeof options === 'object' && options?.nim?.manifestUrl) ||
2078
+ (publicEnv.PUBLIC_WASM_NIM_MANIFEST_URL || '').trim();
2079
+ if (configuredManifestUrl)
2080
+ return resolveConfiguredUrl(configuredManifestUrl, currentUrl);
2081
+ return `${resolveNimBaseUrl(options, currentUrl)}runtime-manifest.v2.json`;
2082
+ }
2083
+ export function resolveBashBaseUrl(options, currentUrl = '') {
2084
+ const configuredBaseUrl = typeof options === 'object' ? options?.bash?.baseUrl : undefined;
2085
+ if (configuredBaseUrl)
2086
+ return normalizeBaseUrl(configuredBaseUrl, currentUrl);
2087
+ if (typeof options === 'string') {
2088
+ return normalizeBaseUrl(`${normalizeRootUrl(options) || ''}/wasm-bash/`, currentUrl);
2089
+ }
2090
+ if (options?.rootUrl) {
2091
+ return normalizeBaseUrl(`${normalizeRootUrl(options.rootUrl) || ''}/wasm-bash/`, currentUrl);
2092
+ }
2093
+ return normalizeBaseUrl('/wasm-bash/', currentUrl);
2094
+ }
2095
+ export function resolveBashRuntimeAssetConfig(options, currentUrl = '') {
2096
+ const configured = typeof options === 'object' ? options?.bash : undefined;
2097
+ if (configured?.workerUrl !== undefined) {
2098
+ throw new RuntimeConfigurationError('Bash runtime workerUrl overrides are no longer supported; use the fixed verified bootstrap.', { runtimeId: 'BASH' });
2099
+ }
2100
+ const usesCustomTrustBoundary = Boolean(configured && Object.values(configured).some((value) => value !== undefined));
2101
+ let preflightProfile;
2102
+ try {
2103
+ preflightProfile = snapshotBashRuntimePreflightProfile(usesCustomTrustBoundary
2104
+ ? {
2105
+ profileId: configured?.profileId?.trim(),
2106
+ bashPackageVersion: configured?.bashPackageVersion?.trim(),
2107
+ bashSourceRevision: configured?.bashSourceRevision?.trim(),
2108
+ wasmerSdkVersion: configured?.wasmerSdkVersion?.trim(),
2109
+ wasmerSdkPackageIntegrity: configured?.wasmerSdkPackageIntegrity?.trim(),
2110
+ manifestFingerprint: configured?.manifestFingerprint?.trim(),
2111
+ manifestReceipt: configured?.manifestReceipt,
2112
+ sdkJavaScriptReceipt: configured?.sdkJavaScriptReceipt,
2113
+ wasmerWasmReceipt: configured?.wasmerWasmReceipt,
2114
+ webcReceipt: configured?.webcReceipt
2115
+ }
2116
+ : WASM_BASH_RUNTIME_BUNDLE.profile);
2117
+ }
2118
+ catch (cause) {
2119
+ throw new RuntimeConfigurationError('Bash runtime custom assets require one complete profile and receipt bundle.', { cause, runtimeId: 'BASH' });
2120
+ }
2121
+ const baseUrl = resolveBashBaseUrl(options, currentUrl);
2122
+ const manifestUrl = configured?.manifestUrl
2123
+ ? resolveConfiguredUrl(configured.manifestUrl, currentUrl)
2124
+ : `${baseUrl}runtime-manifest.v2.json?v=${preflightProfile.manifestFingerprint}`;
2125
+ const moduleUrl = configured?.moduleUrl
2126
+ ? resolveConfiguredUrl(configured.moduleUrl, currentUrl)
2127
+ : `${baseUrl}sdk/index.mjs.bin?v=${preflightProfile.sdkJavaScriptReceipt.sha256}`;
2128
+ const wasmerWasmUrl = configured?.wasmerWasmUrl
2129
+ ? resolveConfiguredUrl(configured.wasmerWasmUrl, currentUrl)
2130
+ : `${baseUrl}sdk/wasmer_js_bg.wasm.gz.bin?v=${preflightProfile.wasmerWasmReceipt.sha256}`;
2131
+ const webcUrl = configured?.webcUrl
2132
+ ? resolveConfiguredUrl(configured.webcUrl, currentUrl)
2133
+ : `${baseUrl}bash.webc.gz.bin?v=${preflightProfile.webcReceipt.sha256}`;
2134
+ const identity = {
2135
+ baseUrl,
2136
+ manifestUrl,
2137
+ moduleUrl,
2138
+ wasmerWasmUrl,
2139
+ webcUrl,
2140
+ profile: preflightProfile
2141
+ };
2142
+ return {
2143
+ baseUrl,
2144
+ manifestUrl,
2145
+ moduleUrl,
2146
+ wasmerWasmUrl,
2147
+ webcUrl,
2148
+ manifestFingerprint: preflightProfile.manifestFingerprint,
2149
+ preflightKey: JSON.stringify(identity),
2150
+ preflightProfile
2151
+ };
2152
+ }
2153
+ export function resolveSwiftBaseUrl(options, currentUrl = '') {
2154
+ const configuredBaseUrl = (typeof options === 'object' && options?.swift?.baseUrl) ||
2155
+ (publicEnv.PUBLIC_WASM_SWIFT_BASE_URL || '').trim();
2156
+ if (configuredBaseUrl) {
2157
+ return normalizeBaseUrl(configuredBaseUrl, currentUrl);
2158
+ }
2159
+ if (typeof options === 'string') {
2160
+ return normalizeBaseUrl(`${normalizeRootUrl(options) || ''}/wasm-swift/`, currentUrl);
2161
+ }
2162
+ if (options?.rootUrl) {
2163
+ return normalizeBaseUrl(`${normalizeRootUrl(options.rootUrl) || ''}/wasm-swift/`, currentUrl);
2164
+ }
2165
+ return normalizeBaseUrl('/wasm-swift/', currentUrl);
2166
+ }
2167
+ export function resolveSwiftWorkerUrl(options, currentUrl = '') {
2168
+ const configuredWorkerUrl = (typeof options === 'object' && options?.swift?.workerUrl) ||
2169
+ (publicEnv.PUBLIC_WASM_SWIFT_WORKER_URL || '').trim();
2170
+ if (configuredWorkerUrl) {
2171
+ return resolveConfiguredUrl(configuredWorkerUrl, currentUrl);
2172
+ }
2173
+ const configuredBaseUrl = (typeof options === 'object' && options?.swift?.baseUrl) ||
2174
+ (publicEnv.PUBLIC_WASM_SWIFT_BASE_URL || '').trim();
2175
+ if (configuredBaseUrl) {
2176
+ return resolveConfiguredUrl(`${normalizeBaseUrl(configuredBaseUrl, currentUrl)}runner-worker.js`, currentUrl);
2177
+ }
2178
+ if (typeof options === 'string') {
2179
+ return resolveConfiguredUrl(`${normalizeRootUrl(options) || ''}/wasm-swift/runner-worker.js`, currentUrl);
2180
+ }
2181
+ if (options?.rootUrl) {
2182
+ return resolveConfiguredUrl(`${normalizeRootUrl(options.rootUrl) || ''}/wasm-swift/runner-worker.js`, currentUrl);
2183
+ }
2184
+ return resolveConfiguredUrl('/wasm-swift/runner-worker.js', currentUrl);
2185
+ }
2186
+ export function resolveSwiftManifestUrl(options, currentUrl = '') {
2187
+ const configuredManifestUrl = (typeof options === 'object' && options?.swift?.manifestUrl) ||
2188
+ (publicEnv.PUBLIC_WASM_SWIFT_MANIFEST_URL || '').trim();
2189
+ if (configuredManifestUrl) {
2190
+ return resolveConfiguredUrl(configuredManifestUrl, currentUrl);
2191
+ }
2192
+ const configuredBaseUrl = (typeof options === 'object' && options?.swift?.baseUrl) ||
2193
+ (publicEnv.PUBLIC_WASM_SWIFT_BASE_URL || '').trim();
2194
+ if (configuredBaseUrl) {
2195
+ return resolveConfiguredUrl(`${normalizeBaseUrl(configuredBaseUrl, currentUrl)}runtime-manifest.v1.json`, currentUrl);
2196
+ }
2197
+ if (typeof options === 'string') {
2198
+ return resolveConfiguredUrl(`${normalizeRootUrl(options) || ''}/wasm-swift/runtime-manifest.v1.json`, currentUrl);
2199
+ }
2200
+ if (options?.rootUrl) {
2201
+ return resolveConfiguredUrl(`${normalizeRootUrl(options.rootUrl) || ''}/wasm-swift/runtime-manifest.v1.json`, currentUrl);
2202
+ }
2203
+ return resolveConfiguredUrl('/wasm-swift/runtime-manifest.v1.json', currentUrl);
2204
+ }
2205
+ export function resolveSwiftRuntimeAssetConfig(options, currentUrl = '') {
2206
+ return {
2207
+ baseUrl: resolveSwiftBaseUrl(options, currentUrl),
2208
+ workerUrl: resolveSwiftWorkerUrl(options, currentUrl),
2209
+ manifestUrl: resolveSwiftManifestUrl(options, currentUrl)
2210
+ };
2211
+ }
2212
+ export function resolveSqliteWasmUrl(options, currentUrl = '') {
2213
+ const configuredWasmUrl = (typeof options === 'object' && options?.sqlite?.wasmUrl) ||
2214
+ (publicEnv.PUBLIC_WASM_SQLITE_WASM_URL || '').trim();
2215
+ if (configuredWasmUrl) {
2216
+ return resolveConfiguredUrl(configuredWasmUrl, currentUrl);
2217
+ }
2218
+ return '';
2219
+ }
2220
+ function resolveStaticRuntimeModuleUrl(options, configuredModuleUrl, publicModuleUrl, folder, currentUrl = '') {
2221
+ const moduleUrl = configuredModuleUrl || publicModuleUrl.trim();
2222
+ if (moduleUrl)
2223
+ return resolveConfiguredUrl(moduleUrl, currentUrl);
2224
+ const rootUrl = typeof options === 'string' ? options : options?.rootUrl || '';
2225
+ return resolveConfiguredUrl(`${normalizeRootUrl(rootUrl) || ''}/${folder}/runtime.mjs`, currentUrl);
2226
+ }
2227
+ export function resolveAssemblyScriptRuntimeModuleUrl(options, currentUrl = '') {
2228
+ return resolveStaticRuntimeModuleUrl(options, typeof options === 'object' ? options?.assemblyscript?.moduleUrl : undefined, publicEnv.PUBLIC_WASM_ASSEMBLYSCRIPT_MODULE_URL || '', 'wasm-assemblyscript', currentUrl);
2229
+ }
2230
+ export function resolveDuckDbRuntimeModuleUrl(options, currentUrl = '') {
2231
+ return resolveStaticRuntimeModuleUrl(options, typeof options === 'object' ? options?.duckdb?.moduleUrl : undefined, publicEnv.PUBLIC_WASM_DUCKDB_MODULE_URL || '', 'wasm-duckdb', currentUrl);
2232
+ }
2233
+ export function resolvePhpRuntimeModuleUrl(options, currentUrl = '') {
2234
+ return resolveStaticRuntimeModuleUrl(options, typeof options === 'object' ? options?.php?.moduleUrl : undefined, publicEnv.PUBLIC_WASM_PHP_MODULE_URL || '', 'wasm-php', currentUrl);
2235
+ }
2236
+ export function resolveRubyRuntimeModuleUrl(options, currentUrl = '') {
2237
+ return resolveRubyRuntimeAssetConfig(options, currentUrl).moduleUrl;
2238
+ }
2239
+ export function resolveSqliteRuntimeModuleUrl(options, currentUrl = '') {
2240
+ return resolveStaticRuntimeModuleUrl(options, typeof options === 'object' ? options?.sqlite?.moduleUrl : undefined, publicEnv.PUBLIC_WASM_SQLITE_MODULE_URL || '', 'wasm-sqlite', currentUrl);
2241
+ }
2242
+ /** C3 uses one code-pinned compiler/worker receipt, served from this base URL. */
2243
+ export function resolveC3BaseUrl(options, currentUrl = '') {
2244
+ const configured = (typeof options === 'object' && options?.c3?.baseUrl) ||
2245
+ (publicEnv.PUBLIC_WASM_C3_BASE_URL || '').trim();
2246
+ if (configured)
2247
+ return normalizeBaseUrl(configured, currentUrl);
2248
+ const root = typeof options === 'string' ? options : options?.rootUrl;
2249
+ return normalizeBaseUrl(`${normalizeRootUrl(root || '') || ''}/wasm-c3/`, currentUrl);
2250
+ }