@wasm-oj/server 0.2.1 → 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/THIRD_PARTY_NOTICES.md +57 -30
- package/crates/runtime-core/src/capabilities.rs +70 -4
- package/crates/runtime-core/src/lib.rs +5 -1
- package/crates/runtime-core/src/run/mod.rs +10 -1
- package/crates/runtime-core/src/run/web.rs +7 -1
- package/crates/runtime-core/src/stdio.rs +120 -28
- package/crates/runtime-core/src/web.rs +8 -3
- package/dist/chunks/{go-toolchain-Dbt-lp2L.js → go-toolchain-DRQSILaC.js} +4 -16
- package/dist/chunks/process-keepalive-BWLUz55N.js +16 -0
- package/dist/chunks/{rust-toolchain-CJ3sMxPE.js → rust-toolchain-CK5h2WT8.js} +1 -1
- package/dist/chunks/{toolchains-C6KuA1yM.js → toolchains-uz3XbZGI.js} +21 -25
- package/dist/go-stage.mjs +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.js +176 -173
- package/dist/java-stage.mjs +765 -81
- package/dist/rustc-stage.mjs +1 -1
- package/dist/server-build-stage.mjs +157 -131
- package/dist/server-runner-stage.mjs +7 -5
- package/licenses/quickjs-node-stdlib-LICENSES.txt +259 -0
- package/package.json +3 -3
- package/dist/chunks/java-toolchain-DajoRCHu.js +0 -44
- package/dist/chunks/python-toolchain-Dx834o2A.js +0 -4
- package/dist/python-stage.mjs +0 -90
package/dist/go-stage.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as decodeGoToolchainManifest, c as goCompileDependencyArguments, d as reachableGoDependencies, f as validateGoStandardLibrary, i as GO_TOOLCHAIN, l as goImportConfig, o as deterministicGoCompilerEnvironment, r as GO_OUTPUT_PATH, s as goCompileArguments, t as GO_ARCHIVE_PATH, u as goLinkArguments } from "./chunks/go-toolchain-
|
|
1
|
+
import { a as decodeGoToolchainManifest, c as goCompileDependencyArguments, d as reachableGoDependencies, f as validateGoStandardLibrary, i as GO_TOOLCHAIN, l as goImportConfig, o as deterministicGoCompilerEnvironment, r as GO_OUTPUT_PATH, s as goCompileArguments, t as GO_ARCHIVE_PATH, u as goLinkArguments } from "./chunks/go-toolchain-DRQSILaC.js";
|
|
2
2
|
import { writeFileSync } from "node:fs";
|
|
3
3
|
import { mkdtemp, readFile, rm, writeFile } from "node:fs/promises";
|
|
4
4
|
import { spawn } from "node:child_process";
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -24,37 +24,37 @@ var CLANG_COMPRESSED_PACKAGE_SHA256 = "7f10d90b8e52b270f04874641a1d0bf9e94e85b4f
|
|
|
24
24
|
/** SHA-256 after browser-side gzip decompression. */
|
|
25
25
|
var CLANG_PACKAGE_SHA256 = "21ded33b9c6d4e1aaad5528c940bdaf6c3e84be77ea8f522f018ca7289a2a224";
|
|
26
26
|
/** SHA-256 of the pinned cc1/wasm-ld argv manifest; regenerated by scripts/pin-clang-cc1-argv.mjs. */
|
|
27
|
-
var CLANG_CC1_PINS_SHA256 = "
|
|
27
|
+
var CLANG_CC1_PINS_SHA256 = "895eee17c63b1112c84adcc4ddbcb38e0c18e53bff15f50a8689b9b82d87b1ff";
|
|
28
28
|
var CLANG_MANIFEST_SHA256 = "6382dcdfb6a2da49032a0e08da3b1fb490eb24432be85c3c12e3e871a5065273";
|
|
29
29
|
/** Updated atomically with the generated toolchain-admitted PCH assets. */
|
|
30
|
-
var CLANG_LIBCXX_PCH_MANIFEST_SHA256 = "
|
|
30
|
+
var CLANG_LIBCXX_PCH_MANIFEST_SHA256 = "9bbe41d77c786f1c36169369c909268530b05726e1581683f6edd9a2983eebd0";
|
|
31
31
|
var CLANG_LIBCXX_PCH = Object.freeze({
|
|
32
32
|
"cpp-debug": Object.freeze({
|
|
33
33
|
path: CLANG_LIBCXX_PCH_DEBUG_ASSET_PATH,
|
|
34
|
-
sha256: "
|
|
35
|
-
compressedSha256: "
|
|
34
|
+
sha256: "c420c4643c48826643e75585d5bfdc281f11883d4bda28b283e3c706f3046b3a",
|
|
35
|
+
compressedSha256: "a3811351bae3289caf096f2d4bb6d2ee5db84b97e05514e87190d36b65c500cf"
|
|
36
36
|
}),
|
|
37
37
|
"cpp-release": Object.freeze({
|
|
38
38
|
path: CLANG_LIBCXX_PCH_RELEASE_ASSET_PATH,
|
|
39
|
-
sha256: "
|
|
40
|
-
compressedSha256: "
|
|
39
|
+
sha256: "c4b2132cc6d698e97dd1386431fdb54faaaf38b35b2528c7bc854f860d1f64b1",
|
|
40
|
+
compressedSha256: "ef004fc05ec50af697a37f7c9c814bf62e9676d0de162d6ac35305533939f93f"
|
|
41
41
|
})
|
|
42
42
|
});
|
|
43
|
-
var PYTHON_VERSION = "3.14.
|
|
44
|
-
var PYTHON_PACKAGE_SHA256 = "
|
|
43
|
+
var PYTHON_VERSION = "3.14.7";
|
|
44
|
+
var PYTHON_PACKAGE_SHA256 = "a42c98f5f00582638c8e445440c506bbf94d5e55b3415d1f8d82d11c56cd4b56";
|
|
45
45
|
var PYTHON_PACKAGE = `${`wasm-oj/cpython@${PYTHON_VERSION}`}#sha256:${PYTHON_PACKAGE_SHA256}`;
|
|
46
46
|
var PYTHON_PACKAGE_ASSET_PATH = `/toolchains/python-${PYTHON_VERSION}-wasip1.webc.gz.bin`;
|
|
47
47
|
var PYTHON_PACKAGE_MANIFEST_ASSET_PATH = `/toolchains/python-${PYTHON_VERSION}-wasip1.manifest.json`;
|
|
48
|
-
var PYTHON_COMPRESSED_PACKAGE_SHA256 = "
|
|
49
|
-
var PYTHON_PACKAGE_MANIFEST_SHA256 = "
|
|
50
|
-
var PYTHON_RUNTIME_FILES_ARCHIVE_SHA256 = "
|
|
48
|
+
var PYTHON_COMPRESSED_PACKAGE_SHA256 = "10027f0e32c77dfa0ce1c413b6cb27307d6744fe5e18e6da8cea738bd020260c";
|
|
49
|
+
var PYTHON_PACKAGE_MANIFEST_SHA256 = "53a24b258363a8494af164121111a34b49c85fa0e054627fe131feba6f359cd5";
|
|
50
|
+
var PYTHON_RUNTIME_FILES_ARCHIVE_SHA256 = "c1acac884af1c86833db5b65f8cc0a2304fce74dea0a05d9b40bde0a4e3e7c0e";
|
|
51
51
|
var QUICKJS_VERSION = "0.15.1";
|
|
52
52
|
var QUICKJS_PACKAGE = `wasm-oj/quickjs-ng@${QUICKJS_VERSION}`;
|
|
53
53
|
var QUICKJS_ASSET_PATH = `/toolchains/quickjs-${QUICKJS_VERSION}.wasm.gz.bin`;
|
|
54
|
-
var QUICKJS_ASSET_SHA256 = "
|
|
54
|
+
var QUICKJS_ASSET_SHA256 = "dc6e02e8610269e61b341331661515616451cec929fd534fa96d1c4f47fbcc9a";
|
|
55
55
|
var TYPESCRIPT_VERSION = "7.0.2";
|
|
56
56
|
var TYPESCRIPT_ASSET_PATH = `/toolchains/typescript-${TYPESCRIPT_VERSION}.wasm.gz.bin`;
|
|
57
|
-
var TYPESCRIPT_ASSET_SHA256 = "
|
|
57
|
+
var TYPESCRIPT_ASSET_SHA256 = "29c6ee0e46151e2644049ae96162b1b1d46dcb13310e2a928114bb9030c3ea92";
|
|
58
58
|
var RUST_VERSION = "1.91.1-dev";
|
|
59
59
|
var RUST_PACKAGE_ASSET_PATH = `/toolchains/rust-${RUST_VERSION}.webc.gz.bin`;
|
|
60
60
|
var RUST_PACKAGE_MANIFEST_ASSET_PATH = `/toolchains/rust-${RUST_VERSION}.manifest.json`;
|
|
@@ -73,16 +73,14 @@ var GO_COMPRESSED_STANDARD_LIBRARY_SHA256 = "aeffc384fdc624544f174ba5fc3c2239571
|
|
|
73
73
|
var GO_STANDARD_LIBRARY_SHA256 = "e1ec64b08efd02b35b7ffdaf3970875aaae98325fa4795eafca94ebae2d0d192";
|
|
74
74
|
var GO_COMPILER_SHA256 = "9e557f5b86961fd604217d7521461c5d2b7322e383fa30dead5669b77db12201";
|
|
75
75
|
var GO_LINKER_SHA256 = "2eefca10af935a307ab7946447146bd30e0ea0fb5460be54dc1c55844d155580";
|
|
76
|
-
var JAVA_VERSION = "teavm-0.13.1-
|
|
76
|
+
var JAVA_VERSION = "teavm-0.13.1-wasmgc-wasip1";
|
|
77
77
|
var JAVA_COMPILER_PACKAGE = `wasm-oj/java-teavm@${JAVA_VERSION}`;
|
|
78
|
-
var JAVA_COMPILER_ASSET_PATH = "/toolchains/java-teavm-0.13.1.
|
|
78
|
+
var JAVA_COMPILER_ASSET_PATH = "/toolchains/java-teavm-0.13.1.compiler.wasm";
|
|
79
79
|
var JAVA_COMPILE_CLASSLIB_ASSET_PATH = "/toolchains/java-teavm-0.13.1.compile-classlib.bin";
|
|
80
80
|
var JAVA_RUNTIME_CLASSLIB_ASSET_PATH = "/toolchains/java-teavm-0.13.1.runtime-classlib.bin";
|
|
81
|
-
var
|
|
82
|
-
var
|
|
83
|
-
var
|
|
84
|
-
var JAVA_COMPILE_CLASSLIB_SHA256 = "acfe3fb09e5f2c0c7c8dc2339c66fcdadc1f8e1bf1c74be446926175ef770868";
|
|
85
|
-
var JAVA_RUNTIME_CLASSLIB_SHA256 = "21a9394586e416af2fca4eb0ed08521cbc8924e1d1afaa07863a59a3cfae54ab";
|
|
81
|
+
var JAVA_COMPILER_SHA256 = "8c37bce1c6fceeaffeffe93e10834309b67c8b6fb58c6f8a24547afe8be67f5d";
|
|
82
|
+
var JAVA_COMPILE_CLASSLIB_SHA256 = "738a82b7d7e7ff8d98b07bb076785da7035847a166afb8446fd150c4efce6103";
|
|
83
|
+
var JAVA_RUNTIME_CLASSLIB_SHA256 = "0ed234b66cdde19cb29e6c2865a3636d792d3cf72f102e73a7b3fdede80b79e6";
|
|
86
84
|
Object.freeze({
|
|
87
85
|
[CLANG_PACKAGE_ASSET_PATH]: CLANG_COMPRESSED_PACKAGE_SHA256,
|
|
88
86
|
[CLANG_CC1_PINS_ASSET_PATH]: CLANG_CC1_PINS_SHA256,
|
|
@@ -99,7 +97,7 @@ Object.freeze({
|
|
|
99
97
|
[GO_PACKAGE_ASSET_PATH]: GO_COMPRESSED_PACKAGE_SHA256,
|
|
100
98
|
[GO_PACKAGE_MANIFEST_ASSET_PATH]: GO_PACKAGE_MANIFEST_SHA256,
|
|
101
99
|
[GO_STANDARD_LIBRARY_ASSET_PATH]: GO_COMPRESSED_STANDARD_LIBRARY_SHA256,
|
|
102
|
-
[JAVA_COMPILER_ASSET_PATH]:
|
|
100
|
+
[JAVA_COMPILER_ASSET_PATH]: JAVA_COMPILER_SHA256,
|
|
103
101
|
[JAVA_COMPILE_CLASSLIB_ASSET_PATH]: JAVA_COMPILE_CLASSLIB_SHA256,
|
|
104
102
|
[JAVA_RUNTIME_CLASSLIB_ASSET_PATH]: JAVA_RUNTIME_CLASSLIB_SHA256
|
|
105
103
|
});
|
|
@@ -142,8 +140,6 @@ var TOOLCHAIN_CONTENT_SHA256 = Object.freeze({
|
|
|
142
140
|
/** Exact executable/compiler content used by cache keys and cost calibration. */
|
|
143
141
|
function toolchainContentIdentity(language) {
|
|
144
142
|
if (language === "java") return [
|
|
145
|
-
JAVA_COMPILER_COMPRESSED_PACKAGE_SHA256,
|
|
146
|
-
JAVA_COMPILER_PACKAGE_SHA256,
|
|
147
143
|
JAVA_COMPILER_SHA256,
|
|
148
144
|
JAVA_COMPILE_CLASSLIB_SHA256,
|
|
149
145
|
JAVA_RUNTIME_CLASSLIB_SHA256
|
|
@@ -194,7 +190,7 @@ var TOOLCHAINS = Object.freeze({
|
|
|
194
190
|
runtimePackage: PYTHON_PACKAGE,
|
|
195
191
|
targets: ["wasip1"],
|
|
196
192
|
version: PYTHON_VERSION,
|
|
197
|
-
note: "
|
|
193
|
+
note: "Python source files executed by the source-built CPython wasm32-wasip1 interpreter and standard library."
|
|
198
194
|
}),
|
|
199
195
|
javascript: freezeToolchain({
|
|
200
196
|
language: "javascript",
|
|
@@ -325,7 +321,7 @@ Object.freeze({
|
|
|
325
321
|
var decoder$3 = new TextDecoder();
|
|
326
322
|
async function decodeClangPins(bytes) {
|
|
327
323
|
const digest = await sha256Hex(bytes);
|
|
328
|
-
if (digest !== "
|
|
324
|
+
if (digest !== "895eee17c63b1112c84adcc4ddbcb38e0c18e53bff15f50a8689b9b82d87b1ff") throw new Error(`The pinned cc1 manifest drifted from its contract: expected ${CLANG_CC1_PINS_SHA256}, received ${digest}. Regenerate it with scripts/pin-clang-cc1-argv.mjs and update CLANG_CC1_PINS_SHA256.`);
|
|
329
325
|
const parsed = JSON.parse(decoder$3.decode(bytes));
|
|
330
326
|
if (parsed.schema !== WASM_OJ_SCHEMAS.clangPins) throw new Error(`Unsupported cc1 pin schema '${parsed.schema}'.`);
|
|
331
327
|
for (const key of [
|
|
@@ -779,8 +775,8 @@ Object.freeze({
|
|
|
779
775
|
});
|
|
780
776
|
new TextEncoder();
|
|
781
777
|
Object.freeze({
|
|
782
|
-
runtimeCoreWasmSha256: "
|
|
783
|
-
runtimeSourceRootSha256: "
|
|
778
|
+
runtimeCoreWasmSha256: "1e297ad276694e9fb8a23afdc6ccc0b2ae56a223ced19d5cae26fe4661daa11e",
|
|
779
|
+
runtimeSourceRootSha256: "27c52cb1887aa8a7e0d8a238514fc8881cf86c68267e2a1691f110423692e2b6",
|
|
784
780
|
wasmerNativeVersion: "7.2.1",
|
|
785
781
|
wasmerSdkVersion: "0.10.0",
|
|
786
782
|
wasmerSdkWasmSha256: "49a6646209f5ab5e7c737eac33407d87d9a9959ac83e5ecaaab9261b2323589e",
|
|
@@ -791,7 +787,7 @@ Object.freeze({
|
|
|
791
787
|
* Release verification independently checks the component bytes before this
|
|
792
788
|
* identity is admitted into a calibrated release.
|
|
793
789
|
*/
|
|
794
|
-
var WASM_OJ_RUNTIME_IDENTITY_SHA256 = "
|
|
790
|
+
var WASM_OJ_RUNTIME_IDENTITY_SHA256 = "d3e44cafdc1c17a7e6bd4591ef04ec8161af805a519b5bbff437b15e5accd442";
|
|
795
791
|
//#endregion
|
|
796
792
|
//#region src/core/cost-profile.ts
|
|
797
793
|
function coordinates(language, target, optimization) {
|
|
@@ -840,34 +836,6 @@ function parseClangDiagnostics(output) {
|
|
|
840
836
|
});
|
|
841
837
|
return diagnostics;
|
|
842
838
|
}
|
|
843
|
-
function parsePythonDiagnostics(output) {
|
|
844
|
-
const diagnostics = [];
|
|
845
|
-
const lines = output.split(/\r?\n/);
|
|
846
|
-
for (let index = 0; index < lines.length; index += 1) {
|
|
847
|
-
const location = lines[index].match(/^\s*File "([^"]+)", line (\d+)/);
|
|
848
|
-
if (!location) continue;
|
|
849
|
-
let column = 1;
|
|
850
|
-
let message = "Python compilation failed";
|
|
851
|
-
const caret = (lines[index + 2] ?? "").indexOf("^");
|
|
852
|
-
if (caret >= 0) column = caret + 1;
|
|
853
|
-
for (let cursor = index + 1; cursor < Math.min(lines.length, index + 6); cursor += 1) {
|
|
854
|
-
const error = lines[cursor].match(/^([A-Za-z]+(?:Error|Exception)):\s*(.+)$/);
|
|
855
|
-
if (error) {
|
|
856
|
-
message = `${error[1]}: ${error[2]}`;
|
|
857
|
-
break;
|
|
858
|
-
}
|
|
859
|
-
}
|
|
860
|
-
diagnostics.push({
|
|
861
|
-
file: projectPath(location[1]),
|
|
862
|
-
line: Number(location[2]),
|
|
863
|
-
column,
|
|
864
|
-
severity: "error",
|
|
865
|
-
message,
|
|
866
|
-
source: "python"
|
|
867
|
-
});
|
|
868
|
-
}
|
|
869
|
-
return diagnostics;
|
|
870
|
-
}
|
|
871
839
|
function parseTypeScriptDiagnostics(output) {
|
|
872
840
|
const diagnostics = [];
|
|
873
841
|
const pattern = /^(.*?)\((\d+),(\d+)\):\s+(error|warning|message)\s+TS(\d+):\s+(.+)$/gm;
|
|
@@ -991,14 +959,14 @@ var WASM_OJ_LIBCXX_PCH_HEADER = `#pragma once
|
|
|
991
959
|
var decoder$1 = new TextDecoder();
|
|
992
960
|
async function decodeLibcxxPchManifest(bytes) {
|
|
993
961
|
const digest = await sha256Hex(bytes);
|
|
994
|
-
if (digest !== "
|
|
962
|
+
if (digest !== "9bbe41d77c786f1c36169369c909268530b05726e1581683f6edd9a2983eebd0") throw new Error(`Pinned libc++ PCH manifest digest mismatch: expected ${CLANG_LIBCXX_PCH_MANIFEST_SHA256}, received ${digest}.`);
|
|
995
963
|
let value;
|
|
996
964
|
try {
|
|
997
965
|
value = JSON.parse(decoder$1.decode(bytes));
|
|
998
966
|
} catch (error) {
|
|
999
967
|
throw new Error("Pinned libc++ PCH manifest is not valid JSON.", { cause: error });
|
|
1000
968
|
}
|
|
1001
|
-
if (!isRecord$1(value) || value.schema !== WASM_OJ_SCHEMAS.clangLibcxxPch || value.version !== "22.0.0-git20542-10" || value.clangPackageSha256 !== "21ded33b9c6d4e1aaad5528c940bdaf6c3e84be77ea8f522f018ca7289a2a224" || value.clangPinsSha256 !== "
|
|
969
|
+
if (!isRecord$1(value) || value.schema !== WASM_OJ_SCHEMAS.clangLibcxxPch || value.version !== "22.0.0-git20542-10" || value.clangPackageSha256 !== "21ded33b9c6d4e1aaad5528c940bdaf6c3e84be77ea8f522f018ca7289a2a224" || value.clangPinsSha256 !== "895eee17c63b1112c84adcc4ddbcb38e0c18e53bff15f50a8689b9b82d87b1ff" || value.header !== WASM_OJ_LIBCXX_PCH_HEADER || !isRecord$1(value.profiles)) throw new Error("Pinned libc++ PCH manifest is not admitted by the active Clang toolchain contract.");
|
|
1002
970
|
if (value.headerSha256 !== await sha256Hex(WASM_OJ_LIBCXX_PCH_HEADER)) throw new Error("Pinned libc++ PCH header digest does not match its canonical source.");
|
|
1003
971
|
const manifestProfiles = value.profiles;
|
|
1004
972
|
const profiles = Object.fromEntries(await Promise.all(["cpp-debug", "cpp-release"].map(async (profile) => {
|
|
@@ -1142,6 +1110,7 @@ if hasattr(_os, "getrandom"):
|
|
|
1142
1110
|
|
|
1143
1111
|
_entry = _sys.argv[1]
|
|
1144
1112
|
_sys.argv = [_entry, *_sys.argv[2:]]
|
|
1113
|
+
_sys.path[0] = _os.path.dirname(_entry)
|
|
1145
1114
|
_runpy.run_path(_entry, run_name="__main__")
|
|
1146
1115
|
`;
|
|
1147
1116
|
/**
|
|
@@ -1201,21 +1170,9 @@ function projectDependencyPackages(project, ecosystem) {
|
|
|
1201
1170
|
return project.dependencies?.packages.filter((item) => item.package.ecosystem === ecosystem) ?? [];
|
|
1202
1171
|
}
|
|
1203
1172
|
function pythonDependencyFiles(project) {
|
|
1204
|
-
const
|
|
1205
|
-
const
|
|
1206
|
-
|
|
1207
|
-
const installedPath = `site-packages/${path}`;
|
|
1208
|
-
artifactFiles[installedPath] = bytes.slice();
|
|
1209
|
-
if (path.endsWith(".py")) sourceFiles.push({
|
|
1210
|
-
path: installedPath,
|
|
1211
|
-
language: "python",
|
|
1212
|
-
content: decodeDependencyText(bytes, item.package.id, path)
|
|
1213
|
-
});
|
|
1214
|
-
}
|
|
1215
|
-
return {
|
|
1216
|
-
sourceFiles,
|
|
1217
|
-
artifactFiles
|
|
1218
|
-
};
|
|
1173
|
+
const files = {};
|
|
1174
|
+
for (const item of projectDependencyPackages(project, "pypi")) for (const [path, bytes] of Object.entries(item.files)) files[`site-packages/${path}`] = bytes.slice();
|
|
1175
|
+
return files;
|
|
1219
1176
|
}
|
|
1220
1177
|
function npmDependencyFiles(project) {
|
|
1221
1178
|
const files = {};
|
|
@@ -1951,6 +1908,9 @@ function canonicalRuntimeBundleFiles(files) {
|
|
|
1951
1908
|
return canonicalFileRecord(files);
|
|
1952
1909
|
}
|
|
1953
1910
|
//#endregion
|
|
1911
|
+
//#region src/runtime/quickjs/stdlib.generated.ts
|
|
1912
|
+
var QUICKJS_BUFFER_DECLARATION = "declare module \"buffer\" {\nexport class Buffer extends Uint8Array {\n length: number\n write(string: string, offset?: number, length?: number, encoding?: string): number;\n toString(encoding?: string, start?: number, end?: number): string;\n toJSON(): { type: 'Buffer', data: any[] };\n equals(otherBuffer: Buffer): boolean;\n compare(otherBuffer: Uint8Array, targetStart?: number, targetEnd?: number, sourceStart?: number, sourceEnd?: number): number;\n copy(targetBuffer: Buffer, targetStart?: number, sourceStart?: number, sourceEnd?: number): number;\n slice(start?: number, end?: number): Buffer;\n writeUIntLE(value: number, offset: number, byteLength: number, noAssert?: boolean): number;\n writeUIntBE(value: number, offset: number, byteLength: number, noAssert?: boolean): number;\n writeIntLE(value: number, offset: number, byteLength: number, noAssert?: boolean): number;\n writeIntBE(value: number, offset: number, byteLength: number, noAssert?: boolean): number;\n readUIntLE(offset: number, byteLength: number, noAssert?: boolean): number;\n readUIntBE(offset: number, byteLength: number, noAssert?: boolean): number;\n readIntLE(offset: number, byteLength: number, noAssert?: boolean): number;\n readIntBE(offset: number, byteLength: number, noAssert?: boolean): number;\n readUInt8(offset: number, noAssert?: boolean): number;\n readUInt16LE(offset: number, noAssert?: boolean): number;\n readUInt16BE(offset: number, noAssert?: boolean): number;\n readUInt32LE(offset: number, noAssert?: boolean): number;\n readUInt32BE(offset: number, noAssert?: boolean): number;\n readBigUInt64LE(offset: number): BigInt;\n readBigUInt64BE(offset: number): BigInt;\n readInt8(offset: number, noAssert?: boolean): number;\n readInt16LE(offset: number, noAssert?: boolean): number;\n readInt16BE(offset: number, noAssert?: boolean): number;\n readInt32LE(offset: number, noAssert?: boolean): number;\n readInt32BE(offset: number, noAssert?: boolean): number;\n readBigInt64LE(offset: number): BigInt;\n readBigInt64BE(offset: number): BigInt;\n readFloatLE(offset: number, noAssert?: boolean): number;\n readFloatBE(offset: number, noAssert?: boolean): number;\n readDoubleLE(offset: number, noAssert?: boolean): number;\n readDoubleBE(offset: number, noAssert?: boolean): number;\n reverse(): this;\n swap16(): Buffer;\n swap32(): Buffer;\n swap64(): Buffer;\n writeUInt8(value: number, offset: number, noAssert?: boolean): number;\n writeUInt16LE(value: number, offset: number, noAssert?: boolean): number;\n writeUInt16BE(value: number, offset: number, noAssert?: boolean): number;\n writeUInt32LE(value: number, offset: number, noAssert?: boolean): number;\n writeUInt32BE(value: number, offset: number, noAssert?: boolean): number;\n writeBigUInt64LE(value: number, offset: number): BigInt;\n writeBigUInt64BE(value: number, offset: number): BigInt;\n writeInt8(value: number, offset: number, noAssert?: boolean): number;\n writeInt16LE(value: number, offset: number, noAssert?: boolean): number;\n writeInt16BE(value: number, offset: number, noAssert?: boolean): number;\n writeInt32LE(value: number, offset: number, noAssert?: boolean): number;\n writeInt32BE(value: number, offset: number, noAssert?: boolean): number;\n writeBigInt64LE(value: number, offset: number): BigInt;\n writeBigInt64BE(value: number, offset: number): BigInt;\n writeFloatLE(value: number, offset: number, noAssert?: boolean): number;\n writeFloatBE(value: number, offset: number, noAssert?: boolean): number;\n writeDoubleLE(value: number, offset: number, noAssert?: boolean): number;\n writeDoubleBE(value: number, offset: number, noAssert?: boolean): number;\n fill(value: any, offset?: number, end?: number): this;\n indexOf(value: string | number | Buffer, byteOffset?: number, encoding?: string): number;\n lastIndexOf(value: string | number | Buffer, byteOffset?: number, encoding?: string): number;\n includes(value: string | number | Buffer, byteOffset?: number, encoding?: string): boolean;\n\n /**\n * Allocates a new buffer containing the given {str}.\n *\n * @param str String to store in buffer.\n * @param encoding encoding to use, optional. Default is 'utf8'\n */\n constructor (str: string, encoding?: string);\n /**\n * Allocates a new buffer of {size} octets.\n *\n * @param size count of octets to allocate.\n */\n constructor (size: number);\n /**\n * Allocates a new buffer containing the given {array} of octets.\n *\n * @param array The octets to store.\n */\n constructor (array: Uint8Array);\n /**\n * Produces a Buffer backed by the same allocated memory as\n * the given {ArrayBuffer}.\n *\n *\n * @param arrayBuffer The ArrayBuffer with which to share memory.\n */\n constructor (arrayBuffer: ArrayBuffer);\n /**\n * Allocates a new buffer containing the given {array} of octets.\n *\n * @param array The octets to store.\n */\n constructor (array: any[]);\n /**\n * Copies the passed {buffer} data onto a new {Buffer} instance.\n *\n * @param buffer The buffer to copy.\n */\n constructor (buffer: Buffer);\n prototype: Buffer;\n /**\n * Allocates a new Buffer using an {array} of octets.\n *\n * @param array\n */\n static from(array: any[]): Buffer;\n /**\n * When passed a reference to the .buffer property of a TypedArray instance,\n * the newly created Buffer will share the same allocated memory as the TypedArray.\n * The optional {byteOffset} and {length} arguments specify a memory range\n * within the {arrayBuffer} that will be shared by the Buffer.\n *\n * @param arrayBuffer The .buffer property of a TypedArray or a new ArrayBuffer()\n * @param byteOffset\n * @param length\n */\n static from(arrayBuffer: ArrayBuffer, byteOffset?: number, length?: number): Buffer;\n /**\n * Copies the passed {buffer} data onto a new Buffer instance.\n *\n * @param buffer\n */\n static from(buffer: Buffer | Uint8Array): Buffer;\n /**\n * Creates a new Buffer containing the given JavaScript string {str}.\n * If provided, the {encoding} parameter identifies the character encoding.\n * If not provided, {encoding} defaults to 'utf8'.\n *\n * @param str\n */\n static from(str: string, encoding?: string): Buffer;\n /**\n * Returns true if {obj} is a Buffer\n *\n * @param obj object to test.\n */\n static isBuffer(obj: any): obj is Buffer;\n /**\n * Returns true if {encoding} is a valid encoding argument.\n * Valid string encodings in Node 0.12: 'ascii'|'utf8'|'utf16le'|'ucs2'(alias of 'utf16le')|'base64'|'binary'(deprecated)|'hex'\n *\n * @param encoding string to test.\n */\n static isEncoding(encoding: string): boolean;\n /**\n * Gives the actual byte length of a string. encoding defaults to 'utf8'.\n * This is not the same as String.prototype.length since that returns the number of characters in a string.\n *\n * @param string string to test.\n * @param encoding encoding used to evaluate (defaults to 'utf8')\n */\n static byteLength(string: string, encoding?: string): number;\n /**\n * Returns a buffer which is the result of concatenating all the buffers in the list together.\n *\n * If the list has no items, or if the totalLength is 0, then it returns a zero-length buffer.\n * If the list has exactly one item, then the first item of the list is returned.\n * If the list has more than one item, then a new Buffer is created.\n *\n * @param list An array of Buffer objects to concatenate\n * @param totalLength Total length of the buffers when concatenated.\n * If totalLength is not provided, it is read from the buffers in the list. However, this adds an additional loop to the function, so it is faster to provide the length explicitly.\n */\n static concat(list: Uint8Array[], totalLength?: number): Buffer;\n /**\n * The same as buf1.compare(buf2).\n */\n static compare(buf1: Uint8Array, buf2: Uint8Array): number;\n /**\n * Allocates a new buffer of {size} octets.\n *\n * @param size count of octets to allocate.\n * @param fill if specified, buffer will be initialized by calling buf.fill(fill).\n * If parameter is omitted, buffer will be filled with zeros.\n * @param encoding encoding used for call to buf.fill while initializing\n */\n static alloc(size: number, fill?: string | Buffer | number, encoding?: string): Buffer;\n /**\n * Allocates a new buffer of {size} octets, leaving memory not initialized, so the contents\n * of the newly created Buffer are unknown and may contain sensitive data.\n *\n * @param size count of octets to allocate\n */\n static allocUnsafe(size: number): Buffer;\n /**\n * Allocates a new non-pooled buffer of {size} octets, leaving memory not initialized, so the contents\n * of the newly created Buffer are unknown and may contain sensitive data.\n *\n * @param size count of octets to allocate\n */\n static allocUnsafeSlow(size: number): Buffer;\n}\n\nconst buffer: { Buffer: typeof Buffer }; export default buffer;\n}\n";
|
|
1913
|
+
//#endregion
|
|
1954
1914
|
//#region src/core/quickjs-runtime.ts
|
|
1955
1915
|
var QUICKJS_STD_MODULE_DECLARATION = String.raw`
|
|
1956
1916
|
declare module "std" {
|
|
@@ -1959,9 +1919,80 @@ declare module "std" {
|
|
|
1959
1919
|
in: { readAsString(): string };
|
|
1960
1920
|
out: { puts(value: string): void };
|
|
1961
1921
|
};
|
|
1962
|
-
export
|
|
1922
|
+
export default std;
|
|
1923
|
+
export const err: typeof std.err;
|
|
1924
|
+
export const out: typeof std.out;
|
|
1925
|
+
const input: typeof std.in;
|
|
1926
|
+
export { input as in };
|
|
1963
1927
|
}
|
|
1964
1928
|
`;
|
|
1929
|
+
var QUICKJS_NODE_MODULE_DECLARATION = QUICKJS_BUFFER_DECLARATION + String.raw`
|
|
1930
|
+
type BufferEncoding = "ascii" | "utf8" | "utf-8" | "utf16le" | "utf-16le" | "ucs2" | "ucs-2" | "base64" | "latin1" | "binary" | "hex";
|
|
1931
|
+
type Buffer = import("buffer").Buffer;
|
|
1932
|
+
declare const Buffer: typeof import("buffer").Buffer;
|
|
1933
|
+
interface NodeReadable extends AsyncIterable<Buffer | string> {
|
|
1934
|
+
on(event: "data", callback: (chunk: Buffer | string) => void): this;
|
|
1935
|
+
on(event: "readable" | "end" | "close", callback: () => void): this;
|
|
1936
|
+
on(event: "error", callback: (error: Error) => void): this;
|
|
1937
|
+
setEncoding(encoding: BufferEncoding): this;
|
|
1938
|
+
read(size?: number): Buffer | string | null;
|
|
1939
|
+
resume(): this;
|
|
1940
|
+
pause(): this;
|
|
1941
|
+
pipe<T extends NodeWritable>(destination: T, options?: { end?: boolean }): T;
|
|
1942
|
+
}
|
|
1943
|
+
interface NodeWritable {
|
|
1944
|
+
write(value: string | Uint8Array, callback?: (error?: Error | null) => void): boolean;
|
|
1945
|
+
write(value: string | Uint8Array, encoding?: BufferEncoding, callback?: (error?: Error | null) => void): boolean;
|
|
1946
|
+
end(value?: string | Uint8Array): this;
|
|
1947
|
+
on(event: "error", callback: (error: Error) => void): this;
|
|
1948
|
+
on(event: "drain" | "finish" | "close", callback: () => void): this;
|
|
1949
|
+
}
|
|
1950
|
+
interface NodeProcess {
|
|
1951
|
+
stdin: NodeReadable;
|
|
1952
|
+
stdout: NodeWritable;
|
|
1953
|
+
stderr: NodeWritable;
|
|
1954
|
+
env: Record<string, string | undefined>;
|
|
1955
|
+
argv: string[];
|
|
1956
|
+
nextTick(callback: (...args: any[]) => void, ...args: any[]): void;
|
|
1957
|
+
}
|
|
1958
|
+
declare const process: NodeProcess;
|
|
1959
|
+
declare module "fs" {
|
|
1960
|
+
export function readFileSync(file: number | string, options?: null | { encoding?: null }): Buffer;
|
|
1961
|
+
export function readFileSync(file: number | string, options: BufferEncoding | { encoding: BufferEncoding }): string;
|
|
1962
|
+
export function readSync(fd: number, buffer: ArrayBufferView, offset?: number, length?: number, position?: number | null): number;
|
|
1963
|
+
export function writeFileSync(file: number | string, data: string | ArrayBufferView, options?: BufferEncoding | { encoding?: BufferEncoding }): void;
|
|
1964
|
+
export function writeSync(fd: number, buffer: ArrayBufferView, offset?: number, length?: number, position?: number | null): number;
|
|
1965
|
+
export function writeSync(fd: number, value: string, position?: number | null, encoding?: BufferEncoding): number;
|
|
1966
|
+
const fs: { readFileSync: typeof readFileSync; readSync: typeof readSync; writeFileSync: typeof writeFileSync; writeSync: typeof writeSync };
|
|
1967
|
+
export default fs;
|
|
1968
|
+
}
|
|
1969
|
+
declare module "node:fs" { export * from "fs"; export { default } from "fs"; }
|
|
1970
|
+
declare module "process" { const value: NodeProcess; export default value; export const stdin: NodeReadable; export const stdout: NodeWritable; export const stderr: NodeWritable; export const nextTick: NodeProcess["nextTick"]; export const env: NodeProcess["env"]; export const argv: string[]; }
|
|
1971
|
+
declare module "node:process" { export * from "process"; export { default } from "process"; }
|
|
1972
|
+
declare module "node:buffer" { export * from "buffer"; export { default } from "buffer"; }
|
|
1973
|
+
declare module "readline" {
|
|
1974
|
+
export class Interface implements AsyncIterable<string> {
|
|
1975
|
+
constructor(options: { input: NodeReadable; output?: NodeWritable; terminal?: boolean; crlfDelay?: number });
|
|
1976
|
+
on(event: "line", callback: (line: string) => void): this;
|
|
1977
|
+
on(event: "close" | "pause" | "resume", callback: () => void): this;
|
|
1978
|
+
on(event: "error", callback: (error: Error) => void): this;
|
|
1979
|
+
close(): void;
|
|
1980
|
+
pause(): this;
|
|
1981
|
+
resume(): this;
|
|
1982
|
+
[Symbol.asyncIterator](): AsyncIterator<string>;
|
|
1983
|
+
}
|
|
1984
|
+
export function createInterface(options: { input: NodeReadable; output?: NodeWritable; terminal?: boolean; crlfDelay?: number }): Interface;
|
|
1985
|
+
const readline: { createInterface: typeof createInterface; Interface: typeof Interface };
|
|
1986
|
+
export default readline;
|
|
1987
|
+
}
|
|
1988
|
+
declare module "node:readline" { export * from "readline"; export { default } from "readline"; }
|
|
1989
|
+
`;
|
|
1990
|
+
var QUICKJS_COMMONJS_DECLARATION = String.raw`
|
|
1991
|
+
declare function require(name: "fs" | "node:fs"): typeof import("fs");
|
|
1992
|
+
declare function require(name: "readline" | "node:readline"): typeof import("readline");
|
|
1993
|
+
declare function require(name: "buffer" | "node:buffer"): typeof import("buffer");
|
|
1994
|
+
declare function require(name: "process" | "node:process"): NodeProcess;
|
|
1995
|
+
`;
|
|
1965
1996
|
//#endregion
|
|
1966
1997
|
//#region src/compiler/language-driver.ts
|
|
1967
1998
|
/** Internal registry for WASM-OJ's built-in compiler pipelines. */
|
|
@@ -1996,26 +2027,6 @@ var LanguageDriverRegistry = class {
|
|
|
1996
2027
|
}
|
|
1997
2028
|
};
|
|
1998
2029
|
//#endregion
|
|
1999
|
-
//#region src/compiler/java-toolchain.ts
|
|
2000
|
-
var JAVA_COMPILE_TIMEOUT_MS = 18e4;
|
|
2001
|
-
Object.freeze({
|
|
2002
|
-
version: JAVA_VERSION,
|
|
2003
|
-
package: JAVA_COMPILER_PACKAGE,
|
|
2004
|
-
compilerAsset: JAVA_COMPILER_ASSET_PATH,
|
|
2005
|
-
compilerCompressedSha256: JAVA_COMPILER_COMPRESSED_PACKAGE_SHA256,
|
|
2006
|
-
compilerPackageSha256: JAVA_COMPILER_PACKAGE_SHA256,
|
|
2007
|
-
compileClasslibAsset: JAVA_COMPILE_CLASSLIB_ASSET_PATH,
|
|
2008
|
-
compileClasslibSha256: JAVA_COMPILE_CLASSLIB_SHA256,
|
|
2009
|
-
runtimeClasslibAsset: JAVA_RUNTIME_CLASSLIB_ASSET_PATH,
|
|
2010
|
-
runtimeClasslibSha256: JAVA_RUNTIME_CLASSLIB_SHA256
|
|
2011
|
-
});
|
|
2012
|
-
function javaMainClass(entry, source) {
|
|
2013
|
-
const className = entry.split("/").at(-1)?.replace(/\.java$/u, "") ?? "";
|
|
2014
|
-
if (!/^[A-Za-z_$][\w$]*$/u.test(className)) throw new Error(`Java entry '${entry}' must name a valid .java class file.`);
|
|
2015
|
-
const packageName = source.match(/^\s*package\s+([A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*)*)\s*;/m)?.[1];
|
|
2016
|
-
return packageName ? `${packageName}.${className}` : className;
|
|
2017
|
-
}
|
|
2018
|
-
//#endregion
|
|
2019
2030
|
//#region src/compiler/wasmer-engine.ts
|
|
2020
2031
|
var encoder = new TextEncoder();
|
|
2021
2032
|
var typescriptCompilerBytes;
|
|
@@ -2103,50 +2114,29 @@ function sumFileSize(files) {
|
|
|
2103
2114
|
async function buildPython(project, cacheKey, requestId) {
|
|
2104
2115
|
const started = performance.now();
|
|
2105
2116
|
const dependencies = pythonDependencyFiles(project);
|
|
2106
|
-
|
|
2107
|
-
const pythonFiles = compilerFiles.filter((file) => file.path.endsWith(".py"));
|
|
2108
|
-
progress(requestId, "compiling", `Byte-compiling ${pythonFiles.length} Python file${pythonFiles.length === 1 ? "" : "s"}`, .55);
|
|
2109
|
-
const frontend = await requireHost().compilePython({ files: compilerFiles });
|
|
2110
|
-
if (!frontend.success) return {
|
|
2111
|
-
success: false,
|
|
2112
|
-
diagnostics: ensureFailureDiagnostic(frontend.diagnostics, {
|
|
2113
|
-
file: project.config.entry,
|
|
2114
|
-
source: "python",
|
|
2115
|
-
message: frontend.stderr.trim() || "Python byte-compilation failed without a diagnostic."
|
|
2116
|
-
}),
|
|
2117
|
-
stdout: frontend.stdout,
|
|
2118
|
-
stderr: frontend.stderr,
|
|
2119
|
-
cacheHit: false
|
|
2120
|
-
};
|
|
2117
|
+
progress(requestId, "compiling", "Packaging Python sources", .55);
|
|
2121
2118
|
const files = Object.fromEntries(project.files.map((file) => [file.path, file.content]));
|
|
2122
|
-
Object.assign(files, dependencies
|
|
2119
|
+
Object.assign(files, dependencies);
|
|
2123
2120
|
files[PYTHON_RUNNER_PATH] = PYTHON_DETERMINISTIC_RUNNER;
|
|
2124
|
-
|
|
2125
|
-
const compiledPath = `build/${file.path.replace(/\.py$/, ".pyc")}`;
|
|
2126
|
-
const bytecode = frontend.bytecode[compiledPath];
|
|
2127
|
-
if (!bytecode) throw new Error(`Python stage omitted '${compiledPath}'.`);
|
|
2128
|
-
files[compiledPath] = bytecode;
|
|
2129
|
-
}
|
|
2130
|
-
const entry = `build/${project.config.entry.replace(/\.py$/, ".pyc")}`;
|
|
2121
|
+
const entry = project.config.entry;
|
|
2131
2122
|
const manifest = createRuntimeBundleManifest(project, PYTHON_PACKAGE, "python", entry);
|
|
2132
2123
|
files["wasm-oj.manifest.json"] = manifest;
|
|
2133
2124
|
const bundleFiles = canonicalRuntimeBundleFiles(files);
|
|
2134
|
-
const artifact = {
|
|
2135
|
-
kind: "runtime-bundle",
|
|
2136
|
-
...createArtifactBase(project, cacheKey, started, sumFileSize(bundleFiles), toolchainPackageIdentities("python")),
|
|
2137
|
-
name: `${project.name}.python-${project.config.target}.json`,
|
|
2138
|
-
runtimePackage: PYTHON_PACKAGE,
|
|
2139
|
-
command: "python",
|
|
2140
|
-
entry,
|
|
2141
|
-
files: bundleFiles,
|
|
2142
|
-
manifest
|
|
2143
|
-
};
|
|
2144
2125
|
return {
|
|
2145
2126
|
success: true,
|
|
2146
|
-
diagnostics:
|
|
2147
|
-
artifact
|
|
2148
|
-
|
|
2149
|
-
|
|
2127
|
+
diagnostics: [],
|
|
2128
|
+
artifact: {
|
|
2129
|
+
kind: "runtime-bundle",
|
|
2130
|
+
...createArtifactBase(project, cacheKey, started, sumFileSize(bundleFiles), toolchainPackageIdentities("python")),
|
|
2131
|
+
name: `${project.name}.python-${project.config.target}.json`,
|
|
2132
|
+
runtimePackage: PYTHON_PACKAGE,
|
|
2133
|
+
command: "python",
|
|
2134
|
+
entry,
|
|
2135
|
+
files: bundleFiles,
|
|
2136
|
+
manifest
|
|
2137
|
+
},
|
|
2138
|
+
stdout: "",
|
|
2139
|
+
stderr: "",
|
|
2150
2140
|
cacheHit: false
|
|
2151
2141
|
};
|
|
2152
2142
|
}
|
|
@@ -2203,7 +2193,7 @@ async function buildJava(project, cacheKey, requestId) {
|
|
|
2203
2193
|
stderr: "",
|
|
2204
2194
|
cacheHit: false
|
|
2205
2195
|
};
|
|
2206
|
-
progress(requestId, "compiling", `Compiling Java ${
|
|
2196
|
+
progress(requestId, "compiling", `Compiling Java ${entry.path}`, .3);
|
|
2207
2197
|
const compiled = await requireHost().compileJava({
|
|
2208
2198
|
entry: project.config.entry,
|
|
2209
2199
|
files: project.files,
|
|
@@ -2258,9 +2248,8 @@ async function transpileScriptProject(project, requestId) {
|
|
|
2258
2248
|
files: {
|
|
2259
2249
|
...Object.fromEntries(project.files.map((file) => [`/project/${file.path}`, file.content])),
|
|
2260
2250
|
...Object.fromEntries(Object.entries(dependencyFiles).filter(([, contents]) => typeof contents === "string").map(([path, contents]) => [`/project/${path}`, contents])),
|
|
2261
|
-
[declarationPath]: QUICKJS_STD_MODULE_DECLARATION
|
|
2251
|
+
[declarationPath]: QUICKJS_STD_MODULE_DECLARATION + QUICKJS_NODE_MODULE_DECLARATION + QUICKJS_COMMONJS_DECLARATION
|
|
2262
2252
|
},
|
|
2263
|
-
javascript: project.config.language === "javascript",
|
|
2264
2253
|
sources: [
|
|
2265
2254
|
declarationPath,
|
|
2266
2255
|
...scriptFiles.map((file) => `/project/${file.path}`),
|
|
@@ -2302,40 +2291,54 @@ async function buildScript(project, cacheKey, requestId) {
|
|
|
2302
2291
|
stderr: "",
|
|
2303
2292
|
cacheHit: false
|
|
2304
2293
|
};
|
|
2305
|
-
|
|
2306
|
-
|
|
2307
|
-
|
|
2308
|
-
|
|
2309
|
-
|
|
2310
|
-
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
|
|
2316
|
-
|
|
2317
|
-
|
|
2318
|
-
|
|
2319
|
-
|
|
2294
|
+
let files;
|
|
2295
|
+
let diagnostics = [];
|
|
2296
|
+
let stderr = "";
|
|
2297
|
+
if (project.config.language === "javascript") {
|
|
2298
|
+
progress(requestId, "compiling", "Preparing JavaScript modules", .5);
|
|
2299
|
+
files = {
|
|
2300
|
+
...Object.fromEntries(emittedSourceFiles(project).map((file) => [file.path, file.content])),
|
|
2301
|
+
...npmDependencyFiles(project)
|
|
2302
|
+
};
|
|
2303
|
+
} else {
|
|
2304
|
+
progress(requestId, "compiling", "Compiling TypeScript with TypeScript/WASI", .5);
|
|
2305
|
+
const transpiled = await transpileScriptProject(project, requestId);
|
|
2306
|
+
files = transpiled.files;
|
|
2307
|
+
stderr = transpiled.output.stderr;
|
|
2308
|
+
diagnostics = parseTypeScriptDiagnostics(transpiled.response?.diagnostics ?? "");
|
|
2309
|
+
const emittedOutputsPresent = emittedSourceFiles(project).every((file) => Object.hasOwn(files, emittedScriptPath(file.path)));
|
|
2310
|
+
if (!transpiled.output.ok || !transpiled.response || transpiled.response.status !== 0 || !emittedOutputsPresent || diagnostics.some((diagnostic) => diagnostic.severity === "error")) return {
|
|
2311
|
+
success: false,
|
|
2312
|
+
diagnostics: ensureFailureDiagnostic(diagnostics, {
|
|
2313
|
+
file: project.config.entry,
|
|
2314
|
+
source: "typescript",
|
|
2315
|
+
message: stderr.trim() || transpiled.response?.diagnostics.trim() || `TypeScript 7.0.2 did not return every compiled output.`
|
|
2316
|
+
}),
|
|
2317
|
+
stdout: "",
|
|
2318
|
+
stderr,
|
|
2319
|
+
cacheHit: false
|
|
2320
|
+
};
|
|
2321
|
+
}
|
|
2320
2322
|
const entry = emittedScriptPath(project.config.entry);
|
|
2321
2323
|
const manifest = createRuntimeBundleManifest(project, QUICKJS_PACKAGE, "qjs", entry);
|
|
2322
2324
|
files["wasm-oj.manifest.json"] = manifest;
|
|
2323
2325
|
const bundleFiles = canonicalRuntimeBundleFiles(files);
|
|
2326
|
+
const artifact = {
|
|
2327
|
+
kind: "runtime-bundle",
|
|
2328
|
+
...createArtifactBase(project, cacheKey, started, sumFileSize(bundleFiles), toolchainPackageIdentities(project.config.language)),
|
|
2329
|
+
name: `${project.name}.${project.config.language === "typescript" ? "typescript" : "javascript"}-${project.config.target}.json`,
|
|
2330
|
+
runtimePackage: QUICKJS_PACKAGE,
|
|
2331
|
+
command: "qjs",
|
|
2332
|
+
entry,
|
|
2333
|
+
files: bundleFiles,
|
|
2334
|
+
manifest
|
|
2335
|
+
};
|
|
2324
2336
|
return {
|
|
2325
2337
|
success: true,
|
|
2326
2338
|
diagnostics,
|
|
2327
|
-
artifact
|
|
2328
|
-
kind: "runtime-bundle",
|
|
2329
|
-
...createArtifactBase(project, cacheKey, started, sumFileSize(bundleFiles), toolchainPackageIdentities(project.config.language)),
|
|
2330
|
-
name: `${project.name}.${project.config.language === "typescript" ? "typescript" : "javascript"}-${project.config.target}.json`,
|
|
2331
|
-
runtimePackage: QUICKJS_PACKAGE,
|
|
2332
|
-
command: "qjs",
|
|
2333
|
-
entry,
|
|
2334
|
-
files: bundleFiles,
|
|
2335
|
-
manifest
|
|
2336
|
-
},
|
|
2339
|
+
artifact,
|
|
2337
2340
|
stdout: "",
|
|
2338
|
-
stderr
|
|
2341
|
+
stderr,
|
|
2339
2342
|
cacheHit: false
|
|
2340
2343
|
};
|
|
2341
2344
|
}
|
|
@@ -2406,9 +2409,6 @@ function clearCompilerHostCaches() {
|
|
|
2406
2409
|
typescriptCompilerBytes = void 0;
|
|
2407
2410
|
}
|
|
2408
2411
|
//#endregion
|
|
2409
|
-
//#region src/compiler/python-toolchain.ts
|
|
2410
|
-
var PYTHON_COMPILE_TIMEOUT_MS = 18e4;
|
|
2411
|
-
//#endregion
|
|
2412
2412
|
//#region src/compiler/rust-toolchain.ts
|
|
2413
2413
|
var RUST_TARGET_TRIPLE = "wasm32-wasip1-threads";
|
|
2414
2414
|
var RUST_EDITION = "2024";
|
|
@@ -2441,6 +2441,19 @@ var GO_TOOLCHAIN = Object.freeze({
|
|
|
2441
2441
|
linkerSha256: GO_LINKER_SHA256
|
|
2442
2442
|
});
|
|
2443
2443
|
//#endregion
|
|
2444
|
+
//#region src/compiler/java-toolchain.ts
|
|
2445
|
+
var JAVA_COMPILE_TIMEOUT_MS = 18e4;
|
|
2446
|
+
Object.freeze({
|
|
2447
|
+
version: JAVA_VERSION,
|
|
2448
|
+
package: JAVA_COMPILER_PACKAGE,
|
|
2449
|
+
compilerAsset: JAVA_COMPILER_ASSET_PATH,
|
|
2450
|
+
compilerSha256: JAVA_COMPILER_SHA256,
|
|
2451
|
+
compileClasslibAsset: JAVA_COMPILE_CLASSLIB_ASSET_PATH,
|
|
2452
|
+
compileClasslibSha256: JAVA_COMPILE_CLASSLIB_SHA256,
|
|
2453
|
+
runtimeClasslibAsset: JAVA_RUNTIME_CLASSLIB_ASSET_PATH,
|
|
2454
|
+
runtimeClasslibSha256: JAVA_RUNTIME_CLASSLIB_SHA256
|
|
2455
|
+
});
|
|
2456
|
+
//#endregion
|
|
2444
2457
|
//#region src/server/wasmer-runtime.ts
|
|
2445
2458
|
var initialization;
|
|
2446
2459
|
async function initializeServerWasmerSdk() {
|
|
@@ -2619,7 +2632,6 @@ function sameRecord(expected, actual) {
|
|
|
2619
2632
|
var SERVER_STAGE_SCRIPTS = Object.freeze([
|
|
2620
2633
|
"server-build-stage.mjs",
|
|
2621
2634
|
"server-runner-stage.mjs",
|
|
2622
|
-
"python-stage.mjs",
|
|
2623
2635
|
"rustc-stage.mjs",
|
|
2624
2636
|
"go-stage.mjs",
|
|
2625
2637
|
"java-stage.mjs"
|
|
@@ -2711,7 +2723,6 @@ var ServerCompiler = class {
|
|
|
2711
2723
|
loadToolchainAsset: (assetPath) => this.loadToolchainAsset(assetPath),
|
|
2712
2724
|
loadToolchainFile: (assetPath) => this.loadToolchainFile(assetPath),
|
|
2713
2725
|
compileRust: (request) => this.compileRust(request),
|
|
2714
|
-
compilePython: (request) => this.compilePython(request),
|
|
2715
2726
|
compileGo: (request) => this.compileGo(request),
|
|
2716
2727
|
compileJava: (request) => this.compileJava(request),
|
|
2717
2728
|
progress: (_requestId, phase, label, value) => {
|
|
@@ -2913,14 +2924,6 @@ var ServerCompiler = class {
|
|
|
2913
2924
|
wasm: result.wasmBase64 ? new Uint8Array(Buffer.from(result.wasmBase64, "base64")) : void 0
|
|
2914
2925
|
};
|
|
2915
2926
|
}
|
|
2916
|
-
async compilePython(request) {
|
|
2917
|
-
const result = await this.runCompilerStage("python-stage.mjs", { request }, PYTHON_COMPILE_TIMEOUT_MS, [PYTHON_PACKAGE_ASSET_PATH]);
|
|
2918
|
-
return {
|
|
2919
|
-
...result,
|
|
2920
|
-
bytecode: Object.fromEntries(Object.entries(result.bytecodeBase64).map(([path, base64]) => [path, new Uint8Array(Buffer.from(base64, "base64"))])),
|
|
2921
|
-
diagnostics: parsePythonDiagnostics(`${result.stderr}\n${result.stdout}`)
|
|
2922
|
-
};
|
|
2923
|
-
}
|
|
2924
2927
|
async compileGo(request) {
|
|
2925
2928
|
const result = await this.runCompilerStage("go-stage.mjs", {
|
|
2926
2929
|
compilerExecutable: this.compilerExecutable,
|