wasm-idle 1.0.12 → 1.1.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.
- package/README.md +17 -7
- package/dist/playground/applicationAssets.js +2 -0
- package/dist/playground/commonlisp.d.ts +8 -0
- package/dist/playground/commonlisp.js +33 -0
- package/dist/playground/commonlispAssets.d.ts +30 -0
- package/dist/playground/commonlispAssets.js +184 -0
- package/dist/playground/index.d.ts +1 -1
- package/dist/playground/index.js +14 -0
- package/dist/playground/javaRuntimeStdin.d.ts +9 -0
- package/dist/playground/javaRuntimeStdin.js +145 -0
- package/dist/playground/lean4.d.ts +13 -0
- package/dist/playground/lean4.js +50 -0
- package/dist/playground/lean4Assets.d.ts +25 -0
- package/dist/playground/lean4Assets.js +123 -0
- package/dist/playground/loadingProgress.js +4 -1
- package/dist/playground/wasmCommonLispVersion.d.ts +32 -0
- package/dist/playground/wasmCommonLispVersion.js +33 -0
- package/dist/playground/wasmLean4Version.d.ts +110 -0
- package/dist/playground/wasmLean4Version.js +111 -0
- package/dist/playground/worker/java.js +17 -29
- package/dist/playground/worker/python.js +85 -122
- package/dist/playground/worker/python.runtime.cases.d.ts +1 -0
- package/dist/playground/worker/python.runtime.cases.js +374 -0
- package/dist/playground/worker/pythonDebugPreview.d.ts +2 -0
- package/dist/playground/worker/pythonDebugPreview.js +55 -0
- package/dist/playground/worker/pythonExecution.d.ts +8 -0
- package/dist/playground/worker/pythonExecution.js +167 -0
- package/dist/playground/worker/pythonStdio.d.ts +32 -0
- package/dist/playground/worker/pythonStdio.js +253 -0
- package/package.json +17 -9
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { StaticWorkerRuntimeSandbox } from './staticWorkerRuntime';
|
|
2
|
+
import { LEAN4_DEFAULT_WASM_MEMORY_BYTES, preflightLean4RuntimeAssets, resolveLean4RuntimeAssetConfig } from './lean4Assets';
|
|
3
|
+
function lean4ExecutionOptions(options = {}) {
|
|
4
|
+
return {
|
|
5
|
+
...options,
|
|
6
|
+
limits: {
|
|
7
|
+
...options.limits,
|
|
8
|
+
maxWasmMemoryBytes: options.limits?.maxWasmMemoryBytes ?? LEAN4_DEFAULT_WASM_MEMORY_BYTES
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
/** Upstream Lean 4 frontend and IR interpreter (`lean --run`) compiled to wasm32 Emscripten. */
|
|
13
|
+
export default class Lean4 extends StaticWorkerRuntimeSandbox {
|
|
14
|
+
defaultExecutionLimits = Object.freeze({
|
|
15
|
+
maxWasmMemoryBytes: LEAN4_DEFAULT_WASM_MEMORY_BYTES
|
|
16
|
+
});
|
|
17
|
+
evidence;
|
|
18
|
+
constructor() {
|
|
19
|
+
const evidence = { current: undefined };
|
|
20
|
+
super({
|
|
21
|
+
displayName: 'Lean 4',
|
|
22
|
+
languageId: 'LEAN4',
|
|
23
|
+
defaultActivePath: 'Main.lean',
|
|
24
|
+
workerLifetime: { mode: 'per-run' },
|
|
25
|
+
runtimePreflightDelivery: 'transfer-owned',
|
|
26
|
+
inlineVerifiedWorker: true,
|
|
27
|
+
requireExactWorkerResponseUrl: true,
|
|
28
|
+
moduleWorker: true,
|
|
29
|
+
includeExecutionLimits: true,
|
|
30
|
+
onEvidence(value) {
|
|
31
|
+
evidence.current = value;
|
|
32
|
+
},
|
|
33
|
+
stdin: { mode: 'streaming', sourceHintPattern: /\b(?:getStdin|getLine|readToEnd)\b/u },
|
|
34
|
+
resolveRuntimeAssets: resolveLean4RuntimeAssetConfig,
|
|
35
|
+
async preflightRuntimeAssets(urls, context) {
|
|
36
|
+
evidence.current = undefined;
|
|
37
|
+
return context.createOwnedDelivery(await preflightLean4RuntimeAssets(urls.baseUrl, context));
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
this.evidence = evidence;
|
|
41
|
+
}
|
|
42
|
+
async load(...args) {
|
|
43
|
+
args[4] = lean4ExecutionOptions(args[4]);
|
|
44
|
+
return super.load(...args);
|
|
45
|
+
}
|
|
46
|
+
async run(...args) {
|
|
47
|
+
args[5] = lean4ExecutionOptions(args[5]);
|
|
48
|
+
return super.run(...args);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { type ExecutionLimits, type RuntimeAssetCacheOptions } from '@wasm-idle/core';
|
|
2
|
+
import type { PlaygroundRuntimeAssets } from './assets';
|
|
3
|
+
/** Linear memory needed to start Lean, import Init, and interpret a small program. */
|
|
4
|
+
export declare const LEAN4_INITIAL_MEMORY_BYTES: number;
|
|
5
|
+
/** Default limit: importing the 277 MB Init library grows the heap to about 370 MiB. */
|
|
6
|
+
export declare const LEAN4_DEFAULT_WASM_MEMORY_BYTES: number;
|
|
7
|
+
export declare const LEAN4_RUNTIME_MANIFEST: import("@wasm-idle/core").RuntimeRegistryManifest;
|
|
8
|
+
export declare function resolveLean4RuntimeAssetConfig(runtimeAssets: string | PlaygroundRuntimeAssets, currentUrl: string): {
|
|
9
|
+
baseUrl: string;
|
|
10
|
+
workerUrl: string;
|
|
11
|
+
manifestFingerprint: "e60eb3fdcc108fa7c6127c5a8925ffb622706facb17bc4f84e9ed27f82495fa1";
|
|
12
|
+
workerReceipt: {
|
|
13
|
+
readonly bytes: 15759;
|
|
14
|
+
readonly sha256: "469ef5ec7accf4c221d06134ccd4989f14e9229c61dd35c386617a015aec6f03";
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
export declare function preflightLean4RuntimeAssets(baseUrl: string, options: {
|
|
18
|
+
limits: ExecutionLimits;
|
|
19
|
+
persistentCache?: RuntimeAssetCacheOptions;
|
|
20
|
+
signal?: AbortSignal;
|
|
21
|
+
reportProgress?: (value: number, stage: string) => void;
|
|
22
|
+
fetch?: typeof globalThis.fetch;
|
|
23
|
+
}): Promise<Readonly<{
|
|
24
|
+
fingerprint: "e60eb3fdcc108fa7c6127c5a8925ffb622706facb17bc4f84e9ed27f82495fa1";
|
|
25
|
+
}>>;
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { defineRuntimeRegistryManifest, preflightRuntimeAssets, ResourceLimitError, RuntimeConfigurationError } from '@wasm-idle/core';
|
|
2
|
+
import { WASM_LEAN4_PROFILE as profile } from './wasmLean4Version';
|
|
3
|
+
/** Linear memory needed to start Lean, import Init, and interpret a small program. */
|
|
4
|
+
export const LEAN4_INITIAL_MEMORY_BYTES = 256 * 1024 * 1024;
|
|
5
|
+
/** Default limit: importing the 277 MB Init library grows the heap to about 370 MiB. */
|
|
6
|
+
export const LEAN4_DEFAULT_WASM_MEMORY_BYTES = 1024 ** 3;
|
|
7
|
+
const assets = Object.entries(profile.assets);
|
|
8
|
+
function mediaType(name) {
|
|
9
|
+
if (name.endsWith('.mjs'))
|
|
10
|
+
return 'text/javascript';
|
|
11
|
+
if (name.endsWith('.json'))
|
|
12
|
+
return 'application/json';
|
|
13
|
+
if (name.startsWith('lean.wasm'))
|
|
14
|
+
return 'application/wasm';
|
|
15
|
+
return 'application/octet-stream';
|
|
16
|
+
}
|
|
17
|
+
export const LEAN4_RUNTIME_MANIFEST = defineRuntimeRegistryManifest({
|
|
18
|
+
schemaVersion: 2,
|
|
19
|
+
manifestId: 'wasm-idle/lean4',
|
|
20
|
+
revision: profile.assets['producer-receipt.json'].sha256,
|
|
21
|
+
runtimes: [
|
|
22
|
+
{
|
|
23
|
+
runtimeId: 'LEAN4',
|
|
24
|
+
identity: {
|
|
25
|
+
languageId: 'LEAN4',
|
|
26
|
+
implementationId: 'lean4-emscripten',
|
|
27
|
+
implementationVersion: profile.version,
|
|
28
|
+
profile: {
|
|
29
|
+
profileId: profile.profileId,
|
|
30
|
+
manifestSchemaVersion: 1,
|
|
31
|
+
manifestSha256: profile.assets['producer-receipt.json'].sha256,
|
|
32
|
+
protocolVersion: 1,
|
|
33
|
+
trustProfileId: profile.profileId,
|
|
34
|
+
trustProfileSchemaVersion: 1
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
capabilities: {
|
|
38
|
+
stdin: 'streaming',
|
|
39
|
+
workspace: true,
|
|
40
|
+
abort: true,
|
|
41
|
+
artifacts: false,
|
|
42
|
+
streamingOutput: true
|
|
43
|
+
},
|
|
44
|
+
workerLifetime: { mode: 'per-run' },
|
|
45
|
+
requiredBrowserFeatures: ['wasm', 'wasm-exceptions', 'shared-array-buffer'],
|
|
46
|
+
assetRoot: '.',
|
|
47
|
+
assets: assets.map(([name, receipt]) => ({
|
|
48
|
+
key: name,
|
|
49
|
+
path: name,
|
|
50
|
+
compressedSha256: receipt.sha256,
|
|
51
|
+
uncompressedSha256: receipt.uncompressed?.sha256 ?? receipt.sha256,
|
|
52
|
+
compressedBytes: receipt.bytes,
|
|
53
|
+
uncompressedBytes: receipt.uncompressed?.bytes ?? receipt.bytes,
|
|
54
|
+
encoding: receipt.encoding ?? 'identity',
|
|
55
|
+
mediaType: mediaType(name)
|
|
56
|
+
})),
|
|
57
|
+
contracts: {
|
|
58
|
+
routeId: 'LEAN4',
|
|
59
|
+
runtimeAssetKey: 'lean4',
|
|
60
|
+
documentationId: 'lean4',
|
|
61
|
+
syncTarget: 'sync:wasm-lean4',
|
|
62
|
+
browserTestId: 'LEAN4'
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
]
|
|
66
|
+
});
|
|
67
|
+
export function resolveLean4RuntimeAssetConfig(runtimeAssets, currentUrl) {
|
|
68
|
+
const root = typeof runtimeAssets === 'string' ? runtimeAssets : runtimeAssets.rootUrl || '';
|
|
69
|
+
const override = typeof runtimeAssets === 'string' ? undefined : runtimeAssets.lean4?.baseUrl;
|
|
70
|
+
const baseUrl = new URL(override ?? `${root.replace(/\/+$/, '')}/wasm-lean4/`, currentUrl);
|
|
71
|
+
if (!['http:', 'https:'].includes(baseUrl.protocol) ||
|
|
72
|
+
baseUrl.username ||
|
|
73
|
+
baseUrl.password ||
|
|
74
|
+
baseUrl.search ||
|
|
75
|
+
baseUrl.hash) {
|
|
76
|
+
throw new RuntimeConfigurationError('Lean 4 requires a credential-free HTTP(S) asset directory.', { runtimeId: 'LEAN4' });
|
|
77
|
+
}
|
|
78
|
+
if (!baseUrl.pathname.endsWith('/'))
|
|
79
|
+
baseUrl.pathname += '/';
|
|
80
|
+
const workerUrl = new URL('runner-worker.js', baseUrl);
|
|
81
|
+
workerUrl.searchParams.set('v', profile.workerReceipt.sha256);
|
|
82
|
+
return {
|
|
83
|
+
baseUrl: baseUrl.href,
|
|
84
|
+
workerUrl: workerUrl.href,
|
|
85
|
+
manifestFingerprint: profile.assets['producer-receipt.json'].sha256,
|
|
86
|
+
workerReceipt: profile.workerReceipt
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
export async function preflightLean4RuntimeAssets(baseUrl, options) {
|
|
90
|
+
if (options.limits.maxWasmMemoryBytes < LEAN4_INITIAL_MEMORY_BYTES) {
|
|
91
|
+
throw new ResourceLimitError('Lean 4 needs at least 256 MiB of Wasm memory.', {
|
|
92
|
+
runtimeId: 'LEAN4',
|
|
93
|
+
phase: 'asset',
|
|
94
|
+
resource: 'wasm-memory',
|
|
95
|
+
actual: LEAN4_INITIAL_MEMORY_BYTES,
|
|
96
|
+
limit: options.limits.maxWasmMemoryBytes
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
const loaded = new Map();
|
|
100
|
+
const total = assets.reduce((sum, [, asset]) => sum + asset.bytes, 0);
|
|
101
|
+
const result = await preflightRuntimeAssets({
|
|
102
|
+
manifest: LEAN4_RUNTIME_MANIFEST,
|
|
103
|
+
runtimeId: 'LEAN4',
|
|
104
|
+
rootUrl: baseUrl,
|
|
105
|
+
assetUrls: Object.fromEntries(assets.map(([name, asset]) => [name, new URL(`${name}?v=${asset.sha256}`, baseUrl)])),
|
|
106
|
+
limits: options.limits,
|
|
107
|
+
persistentCache: options.persistentCache,
|
|
108
|
+
signal: options.signal,
|
|
109
|
+
fetch: options.fetch,
|
|
110
|
+
redirect: 'error',
|
|
111
|
+
requireExactResponseUrl: true,
|
|
112
|
+
maxConcurrentDownloads: 3,
|
|
113
|
+
maxTotalDeliveryBytes: total,
|
|
114
|
+
reportProgress(progress) {
|
|
115
|
+
loaded.set(progress.assetKey, progress.loadedBytes);
|
|
116
|
+
options.reportProgress?.(0.04 + (0.13 * [...loaded.values()].reduce((a, b) => a + b, 0)) / total, `Downloading Lean 4 ${progress.assetKey}`);
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
return Object.freeze({
|
|
120
|
+
fingerprint: profile.assets['producer-receipt.json'].sha256,
|
|
121
|
+
...Object.fromEntries(Object.entries(result.assets).map(([name, asset]) => [name, asset.bytes]))
|
|
122
|
+
});
|
|
123
|
+
}
|
|
@@ -89,7 +89,10 @@ export function createLoadingProgressController({ onChange }) {
|
|
|
89
89
|
const estimate = typeof event.estimatedFraction === 'number' && Number.isFinite(event.estimatedFraction)
|
|
90
90
|
? event.estimatedFraction
|
|
91
91
|
: estimatedPhaseProgress[event.phase];
|
|
92
|
-
|
|
92
|
+
// Cap new estimates, not a previously completed byte measurement. Otherwise a
|
|
93
|
+
// late unmeasured sample regresses the same visible phase from 100% to 99%.
|
|
94
|
+
// A different measured phase still uses its own local denominator below.
|
|
95
|
+
const estimatedValue = Math.max(state.value, Math.min(0.99, Math.max(estimate, 0)));
|
|
93
96
|
const { measurement } = event;
|
|
94
97
|
if (!measurement) {
|
|
95
98
|
state = {
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export declare const WASM_COMMONLISP_PROFILE: {
|
|
2
|
+
readonly schemaVersion: 1;
|
|
3
|
+
readonly profileId: "ecl-26.5.5-emscripten-6.0.0-wasm-llvm-71568b3";
|
|
4
|
+
readonly licenseExpression: "LGPL-2.1-or-later";
|
|
5
|
+
readonly source: "74780fa2cd2874889793a657d55b557488d3e346";
|
|
6
|
+
readonly version: "26.5.5";
|
|
7
|
+
readonly producerRevision: "71568b3cb598c0705bd75a59730ffd74ef8dee2d";
|
|
8
|
+
readonly assets: {
|
|
9
|
+
readonly 'producer-receipt.json': {
|
|
10
|
+
readonly bytes: 6154;
|
|
11
|
+
readonly sha256: "56f1eb7cf6470619cb3393e99d5c8ad1841a001ab758f388c006ca1d801ba071";
|
|
12
|
+
};
|
|
13
|
+
readonly 'ecl.mjs': {
|
|
14
|
+
readonly bytes: 77142;
|
|
15
|
+
readonly sha256: "c9a2df8f418f637a2f5dc4a52842463a5a9df1a2dc5d24038ad01adb93969fa7";
|
|
16
|
+
};
|
|
17
|
+
readonly 'ecl.wasm.gz': {
|
|
18
|
+
readonly bytes: 1535867;
|
|
19
|
+
readonly sha256: "2d8d273a602db2e9677dd185351cf3019f3c31be0e0d6b4c14f7356f8f353a16";
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
readonly runtime: {
|
|
23
|
+
readonly 'ecl.wasm': {
|
|
24
|
+
readonly bytes: 4560196;
|
|
25
|
+
readonly sha256: "9aa43374a0fd991d841628eb209fbfd78e938636732692662f719383e52184c4";
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
readonly workerReceipt: {
|
|
29
|
+
readonly bytes: 11814;
|
|
30
|
+
readonly sha256: "46b24c0fbde93dfaa71ddbce697d717c772ad8fd03f8486ad2102c41145606c6";
|
|
31
|
+
};
|
|
32
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// Generated by sync:wasm-commonlisp from the reviewed asset lock.
|
|
2
|
+
export const WASM_COMMONLISP_PROFILE = {
|
|
3
|
+
schemaVersion: 1,
|
|
4
|
+
profileId: 'ecl-26.5.5-emscripten-6.0.0-wasm-llvm-71568b3',
|
|
5
|
+
licenseExpression: 'LGPL-2.1-or-later',
|
|
6
|
+
source: '74780fa2cd2874889793a657d55b557488d3e346',
|
|
7
|
+
version: '26.5.5',
|
|
8
|
+
producerRevision: '71568b3cb598c0705bd75a59730ffd74ef8dee2d',
|
|
9
|
+
assets: {
|
|
10
|
+
'producer-receipt.json': {
|
|
11
|
+
bytes: 6154,
|
|
12
|
+
sha256: '56f1eb7cf6470619cb3393e99d5c8ad1841a001ab758f388c006ca1d801ba071'
|
|
13
|
+
},
|
|
14
|
+
'ecl.mjs': {
|
|
15
|
+
bytes: 77142,
|
|
16
|
+
sha256: 'c9a2df8f418f637a2f5dc4a52842463a5a9df1a2dc5d24038ad01adb93969fa7'
|
|
17
|
+
},
|
|
18
|
+
'ecl.wasm.gz': {
|
|
19
|
+
bytes: 1535867,
|
|
20
|
+
sha256: '2d8d273a602db2e9677dd185351cf3019f3c31be0e0d6b4c14f7356f8f353a16'
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
runtime: {
|
|
24
|
+
'ecl.wasm': {
|
|
25
|
+
bytes: 4560196,
|
|
26
|
+
sha256: '9aa43374a0fd991d841628eb209fbfd78e938636732692662f719383e52184c4'
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
workerReceipt: {
|
|
30
|
+
bytes: 11814,
|
|
31
|
+
sha256: '46b24c0fbde93dfaa71ddbce697d717c772ad8fd03f8486ad2102c41145606c6'
|
|
32
|
+
}
|
|
33
|
+
};
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
export declare const WASM_LEAN4_PROFILE: {
|
|
2
|
+
readonly schemaVersion: 1;
|
|
3
|
+
readonly profileId: "lean4-4.34.1-wasm32-emscripten-v1";
|
|
4
|
+
readonly source: "5045d0056413266e57c625dcd7c365b10e377c52";
|
|
5
|
+
readonly version: "4.34.1";
|
|
6
|
+
readonly license: "Apache-2.0 AND MIT";
|
|
7
|
+
readonly producer: {
|
|
8
|
+
readonly repository: "https://github.com/seo-rii/wasm-llvm";
|
|
9
|
+
readonly revision: "5369745f777673710c25cd67c52310b004cfe41a";
|
|
10
|
+
readonly path: "artifacts/lean-browser";
|
|
11
|
+
};
|
|
12
|
+
readonly assets: {
|
|
13
|
+
readonly 'producer-receipt.json': {
|
|
14
|
+
readonly upstream: "producer-receipt.json";
|
|
15
|
+
readonly bytes: 4596;
|
|
16
|
+
readonly sha256: "e60eb3fdcc108fa7c6127c5a8925ffb622706facb17bc4f84e9ed27f82495fa1";
|
|
17
|
+
};
|
|
18
|
+
readonly 'lean.mjs': {
|
|
19
|
+
readonly upstream: "lean.mjs";
|
|
20
|
+
readonly bytes: 108528;
|
|
21
|
+
readonly sha256: "16d6d6cb07c844bedf745f856a364ec61e86c13c4fe13a2e57c0c698a5c5f727";
|
|
22
|
+
};
|
|
23
|
+
readonly 'lean.wasm.gz.bin': {
|
|
24
|
+
readonly upstream: "lean.wasm.gz";
|
|
25
|
+
readonly logicalName: "lean.wasm";
|
|
26
|
+
readonly encoding: "gzip";
|
|
27
|
+
readonly bytes: 20239874;
|
|
28
|
+
readonly sha256: "89dc3cb841d487f9e29c1dc3069e7aeb1a63e5ec0267b8250552e3fe90f855bf";
|
|
29
|
+
readonly uncompressed: {
|
|
30
|
+
readonly bytes: 113033667;
|
|
31
|
+
readonly sha256: "d81dbde2ba4aaf0546affca2756477b6d1365a5633080d7119f737e5906ed919";
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
readonly 'lean-init.index.json': {
|
|
35
|
+
readonly upstream: "lean-init.index.json";
|
|
36
|
+
readonly bytes: 321866;
|
|
37
|
+
readonly sha256: "030b375cee435f12f7163c58c16d128340f9e20fa27a77ab646198be61906555";
|
|
38
|
+
};
|
|
39
|
+
readonly 'lean-init-00.pack.gz.bin': {
|
|
40
|
+
readonly upstream: "lean-init-00.pack.gz";
|
|
41
|
+
readonly logicalName: "lean-init-00.pack";
|
|
42
|
+
readonly encoding: "gzip";
|
|
43
|
+
readonly bytes: 22626621;
|
|
44
|
+
readonly sha256: "c2cea0798b8b3e910188eb79d3d0101452c874f693294d2cf8c360fde125c08e";
|
|
45
|
+
readonly uncompressed: {
|
|
46
|
+
readonly bytes: 50331648;
|
|
47
|
+
readonly sha256: "19734bd892d96cbf4ec7b1d13e1bdccbbee022f3288908ee535e2facfc99d483";
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
readonly 'lean-init-01.pack.gz.bin': {
|
|
51
|
+
readonly upstream: "lean-init-01.pack.gz";
|
|
52
|
+
readonly logicalName: "lean-init-01.pack";
|
|
53
|
+
readonly encoding: "gzip";
|
|
54
|
+
readonly bytes: 22633878;
|
|
55
|
+
readonly sha256: "6e65383d8de425a0c0f5b48430aa5be7c9f2066138080bf213a0435b0fd1d874";
|
|
56
|
+
readonly uncompressed: {
|
|
57
|
+
readonly bytes: 50331648;
|
|
58
|
+
readonly sha256: "2ea9fcd0ede724bfc93bf032b7ee3d09724fbd83a17afaaaad534859e74b1200";
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
readonly 'lean-init-02.pack.gz.bin': {
|
|
62
|
+
readonly upstream: "lean-init-02.pack.gz";
|
|
63
|
+
readonly logicalName: "lean-init-02.pack";
|
|
64
|
+
readonly encoding: "gzip";
|
|
65
|
+
readonly bytes: 23039094;
|
|
66
|
+
readonly sha256: "57cc57d61067fc77d8b72008299e25956a121cd3fdf628941420966de1f762e5";
|
|
67
|
+
readonly uncompressed: {
|
|
68
|
+
readonly bytes: 50331648;
|
|
69
|
+
readonly sha256: "75273ea353191316cb8fc31900ef36ffa7424a4bd62061cdbbba8477510ed3bc";
|
|
70
|
+
};
|
|
71
|
+
};
|
|
72
|
+
readonly 'lean-init-03.pack.gz.bin': {
|
|
73
|
+
readonly upstream: "lean-init-03.pack.gz";
|
|
74
|
+
readonly logicalName: "lean-init-03.pack";
|
|
75
|
+
readonly encoding: "gzip";
|
|
76
|
+
readonly bytes: 22382973;
|
|
77
|
+
readonly sha256: "e310ddf310d6d89dc7cc583f01213a1eab2684c1ada9e77368ca16637009d72a";
|
|
78
|
+
readonly uncompressed: {
|
|
79
|
+
readonly bytes: 50331648;
|
|
80
|
+
readonly sha256: "480c12f5b808c18f692e9f5f5666bee3c6a2b0473075a3dd1417039b2bf05553";
|
|
81
|
+
};
|
|
82
|
+
};
|
|
83
|
+
readonly 'lean-init-04.pack.gz.bin': {
|
|
84
|
+
readonly upstream: "lean-init-04.pack.gz";
|
|
85
|
+
readonly logicalName: "lean-init-04.pack";
|
|
86
|
+
readonly encoding: "gzip";
|
|
87
|
+
readonly bytes: 21886461;
|
|
88
|
+
readonly sha256: "f1345c223483bbb8e3c25e73042c5526efbd24301df95c74d30b4799493e6697";
|
|
89
|
+
readonly uncompressed: {
|
|
90
|
+
readonly bytes: 50331648;
|
|
91
|
+
readonly sha256: "5daed6ecf33bfb049e294c72ed161d6a0260440aa371b2be34f26b78377e1178";
|
|
92
|
+
};
|
|
93
|
+
};
|
|
94
|
+
readonly 'lean-init-05.pack.gz.bin': {
|
|
95
|
+
readonly upstream: "lean-init-05.pack.gz";
|
|
96
|
+
readonly logicalName: "lean-init-05.pack";
|
|
97
|
+
readonly encoding: "gzip";
|
|
98
|
+
readonly bytes: 9812693;
|
|
99
|
+
readonly sha256: "9f8deb32469cbe66669381c8f0fb5d379d506f7935beb29393b19d2c52ac8a52";
|
|
100
|
+
readonly uncompressed: {
|
|
101
|
+
readonly bytes: 24923128;
|
|
102
|
+
readonly sha256: "73ca4bd7a0d07f15d3b88298b7dd273406a92e36da96cb555ebb986ee85b7b14";
|
|
103
|
+
};
|
|
104
|
+
};
|
|
105
|
+
};
|
|
106
|
+
readonly workerReceipt: {
|
|
107
|
+
readonly bytes: 15759;
|
|
108
|
+
readonly sha256: "469ef5ec7accf4c221d06134ccd4989f14e9229c61dd35c386617a015aec6f03";
|
|
109
|
+
};
|
|
110
|
+
};
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
// Generated by sync:wasm-lean4 from the reviewed asset lock.
|
|
2
|
+
export const WASM_LEAN4_PROFILE = {
|
|
3
|
+
schemaVersion: 1,
|
|
4
|
+
profileId: 'lean4-4.34.1-wasm32-emscripten-v1',
|
|
5
|
+
source: '5045d0056413266e57c625dcd7c365b10e377c52',
|
|
6
|
+
version: '4.34.1',
|
|
7
|
+
license: 'Apache-2.0 AND MIT',
|
|
8
|
+
producer: {
|
|
9
|
+
repository: 'https://github.com/seo-rii/wasm-llvm',
|
|
10
|
+
revision: '5369745f777673710c25cd67c52310b004cfe41a',
|
|
11
|
+
path: 'artifacts/lean-browser'
|
|
12
|
+
},
|
|
13
|
+
assets: {
|
|
14
|
+
'producer-receipt.json': {
|
|
15
|
+
upstream: 'producer-receipt.json',
|
|
16
|
+
bytes: 4596,
|
|
17
|
+
sha256: 'e60eb3fdcc108fa7c6127c5a8925ffb622706facb17bc4f84e9ed27f82495fa1'
|
|
18
|
+
},
|
|
19
|
+
'lean.mjs': {
|
|
20
|
+
upstream: 'lean.mjs',
|
|
21
|
+
bytes: 108528,
|
|
22
|
+
sha256: '16d6d6cb07c844bedf745f856a364ec61e86c13c4fe13a2e57c0c698a5c5f727'
|
|
23
|
+
},
|
|
24
|
+
'lean.wasm.gz.bin': {
|
|
25
|
+
upstream: 'lean.wasm.gz',
|
|
26
|
+
logicalName: 'lean.wasm',
|
|
27
|
+
encoding: 'gzip',
|
|
28
|
+
bytes: 20239874,
|
|
29
|
+
sha256: '89dc3cb841d487f9e29c1dc3069e7aeb1a63e5ec0267b8250552e3fe90f855bf',
|
|
30
|
+
uncompressed: {
|
|
31
|
+
bytes: 113033667,
|
|
32
|
+
sha256: 'd81dbde2ba4aaf0546affca2756477b6d1365a5633080d7119f737e5906ed919'
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
'lean-init.index.json': {
|
|
36
|
+
upstream: 'lean-init.index.json',
|
|
37
|
+
bytes: 321866,
|
|
38
|
+
sha256: '030b375cee435f12f7163c58c16d128340f9e20fa27a77ab646198be61906555'
|
|
39
|
+
},
|
|
40
|
+
'lean-init-00.pack.gz.bin': {
|
|
41
|
+
upstream: 'lean-init-00.pack.gz',
|
|
42
|
+
logicalName: 'lean-init-00.pack',
|
|
43
|
+
encoding: 'gzip',
|
|
44
|
+
bytes: 22626621,
|
|
45
|
+
sha256: 'c2cea0798b8b3e910188eb79d3d0101452c874f693294d2cf8c360fde125c08e',
|
|
46
|
+
uncompressed: {
|
|
47
|
+
bytes: 50331648,
|
|
48
|
+
sha256: '19734bd892d96cbf4ec7b1d13e1bdccbbee022f3288908ee535e2facfc99d483'
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
'lean-init-01.pack.gz.bin': {
|
|
52
|
+
upstream: 'lean-init-01.pack.gz',
|
|
53
|
+
logicalName: 'lean-init-01.pack',
|
|
54
|
+
encoding: 'gzip',
|
|
55
|
+
bytes: 22633878,
|
|
56
|
+
sha256: '6e65383d8de425a0c0f5b48430aa5be7c9f2066138080bf213a0435b0fd1d874',
|
|
57
|
+
uncompressed: {
|
|
58
|
+
bytes: 50331648,
|
|
59
|
+
sha256: '2ea9fcd0ede724bfc93bf032b7ee3d09724fbd83a17afaaaad534859e74b1200'
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
'lean-init-02.pack.gz.bin': {
|
|
63
|
+
upstream: 'lean-init-02.pack.gz',
|
|
64
|
+
logicalName: 'lean-init-02.pack',
|
|
65
|
+
encoding: 'gzip',
|
|
66
|
+
bytes: 23039094,
|
|
67
|
+
sha256: '57cc57d61067fc77d8b72008299e25956a121cd3fdf628941420966de1f762e5',
|
|
68
|
+
uncompressed: {
|
|
69
|
+
bytes: 50331648,
|
|
70
|
+
sha256: '75273ea353191316cb8fc31900ef36ffa7424a4bd62061cdbbba8477510ed3bc'
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
'lean-init-03.pack.gz.bin': {
|
|
74
|
+
upstream: 'lean-init-03.pack.gz',
|
|
75
|
+
logicalName: 'lean-init-03.pack',
|
|
76
|
+
encoding: 'gzip',
|
|
77
|
+
bytes: 22382973,
|
|
78
|
+
sha256: 'e310ddf310d6d89dc7cc583f01213a1eab2684c1ada9e77368ca16637009d72a',
|
|
79
|
+
uncompressed: {
|
|
80
|
+
bytes: 50331648,
|
|
81
|
+
sha256: '480c12f5b808c18f692e9f5f5666bee3c6a2b0473075a3dd1417039b2bf05553'
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
'lean-init-04.pack.gz.bin': {
|
|
85
|
+
upstream: 'lean-init-04.pack.gz',
|
|
86
|
+
logicalName: 'lean-init-04.pack',
|
|
87
|
+
encoding: 'gzip',
|
|
88
|
+
bytes: 21886461,
|
|
89
|
+
sha256: 'f1345c223483bbb8e3c25e73042c5526efbd24301df95c74d30b4799493e6697',
|
|
90
|
+
uncompressed: {
|
|
91
|
+
bytes: 50331648,
|
|
92
|
+
sha256: '5daed6ecf33bfb049e294c72ed161d6a0260440aa371b2be34f26b78377e1178'
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
'lean-init-05.pack.gz.bin': {
|
|
96
|
+
upstream: 'lean-init-05.pack.gz',
|
|
97
|
+
logicalName: 'lean-init-05.pack',
|
|
98
|
+
encoding: 'gzip',
|
|
99
|
+
bytes: 9812693,
|
|
100
|
+
sha256: '9f8deb32469cbe66669381c8f0fb5d379d506f7935beb29393b19d2c52ac8a52',
|
|
101
|
+
uncompressed: {
|
|
102
|
+
bytes: 24923128,
|
|
103
|
+
sha256: '73ca4bd7a0d07f15d3b88298b7dd273406a92e36da96cb555ebb986ee85b7b14'
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
},
|
|
107
|
+
workerReceipt: {
|
|
108
|
+
bytes: 15759,
|
|
109
|
+
sha256: '469ef5ec7accf4c221d06134ccd4989f14e9229c61dd35c386617a015aec6f03'
|
|
110
|
+
}
|
|
111
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { acceptCompiledTeaVmModule, loadStreamingJavaCompiler } from './javaStreaming';
|
|
2
|
-
import {
|
|
2
|
+
import { createJavaStdinBridge, prepareJavaRuntimeStdinInjection } from '../javaRuntimeStdin';
|
|
3
3
|
import { resolveJavaSourceIdentity } from '../javaSource';
|
|
4
4
|
import { waitForBufferedStdin } from '../stdinBuffer';
|
|
5
5
|
import { configureWorkerRuntimeAssets, handleWorkerAssetMessage, loadWorkerRuntimeAsset } from './assets';
|
|
@@ -9,9 +9,6 @@ let runtimeLoad = null;
|
|
|
9
9
|
let loadedBaseUrl = '';
|
|
10
10
|
let stdoutBuffer = '';
|
|
11
11
|
let stderrBuffer = '';
|
|
12
|
-
let stdinBufferJava = null;
|
|
13
|
-
let stdinChunkJava = new Uint8Array(0);
|
|
14
|
-
let stdinChunkOffsetJava = 0;
|
|
15
12
|
let compiledCode = '';
|
|
16
13
|
let compiledStdin = '';
|
|
17
14
|
let compiledMainClass = '';
|
|
@@ -111,7 +108,7 @@ self.addEventListener('message', async (event) => {
|
|
|
111
108
|
stdoutBuffer = '';
|
|
112
109
|
stderrBuffer = '';
|
|
113
110
|
const explicitStdin = hasExplicitStdin === true;
|
|
114
|
-
const stdinInjection =
|
|
111
|
+
const stdinInjection = prepareJavaRuntimeStdinInjection(code);
|
|
115
112
|
const sourceIdentity = resolveJavaSourceIdentity(code);
|
|
116
113
|
const sourcePath = typeof activePath === 'string' && activePath ? activePath : sourceIdentity.sourcePath;
|
|
117
114
|
const sourceFileName = sourcePath.split('/').pop() || sourcePath;
|
|
@@ -233,29 +230,19 @@ self.addEventListener('message', async (event) => {
|
|
|
233
230
|
self.postMessage({ results: true });
|
|
234
231
|
return;
|
|
235
232
|
}
|
|
236
|
-
stdinBufferJava = new Int32Array(buffer);
|
|
237
|
-
|
|
238
|
-
|
|
233
|
+
const stdinBufferJava = new Int32Array(buffer);
|
|
234
|
+
const stdinBridge = createJavaStdinBridge(stdin, explicitStdin, () => {
|
|
235
|
+
// Publish prompts before the host blocks waiting for interactive input.
|
|
236
|
+
flushStdout();
|
|
237
|
+
flushStderr();
|
|
238
|
+
return waitForBufferedStdin(stdinBufferJava, () => self.postMessage({ buffer: true }));
|
|
239
|
+
});
|
|
239
240
|
const workerGlobal = globalThis;
|
|
240
241
|
const previousWindow = workerGlobal.window;
|
|
242
|
+
const hadStdinBridge = Object.prototype.hasOwnProperty.call(workerGlobal, 'wasmIdleJavaStdin');
|
|
243
|
+
const previousStdinBridge = workerGlobal.wasmIdleJavaStdin;
|
|
241
244
|
workerGlobal.window = workerGlobal;
|
|
242
|
-
workerGlobal.wasmIdleJavaStdin =
|
|
243
|
-
readByte() {
|
|
244
|
-
while (true) {
|
|
245
|
-
if (stdinChunkOffsetJava < stdinChunkJava.length) {
|
|
246
|
-
return stdinChunkJava[stdinChunkOffsetJava++] ?? -1;
|
|
247
|
-
}
|
|
248
|
-
if (explicitStdin)
|
|
249
|
-
return -1;
|
|
250
|
-
const chunk = waitForBufferedStdin(stdinBufferJava, () => self.postMessage({ buffer: true }));
|
|
251
|
-
if (chunk === null) {
|
|
252
|
-
return -1;
|
|
253
|
-
}
|
|
254
|
-
stdinChunkJava = new TextEncoder().encode(chunk);
|
|
255
|
-
stdinChunkOffsetJava = 0;
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
};
|
|
245
|
+
workerGlobal.wasmIdleJavaStdin = stdinBridge;
|
|
259
246
|
try {
|
|
260
247
|
const module = await runtimeLoad(compiledWasm, {
|
|
261
248
|
installImports(imports) {
|
|
@@ -280,16 +267,17 @@ self.addEventListener('message', async (event) => {
|
|
|
280
267
|
self.postMessage({ results: true, mainClass: compiledMainClass });
|
|
281
268
|
}
|
|
282
269
|
finally {
|
|
283
|
-
|
|
270
|
+
stdinBridge.dispose();
|
|
271
|
+
if (hadStdinBridge)
|
|
272
|
+
workerGlobal.wasmIdleJavaStdin = previousStdinBridge;
|
|
273
|
+
else
|
|
274
|
+
delete workerGlobal.wasmIdleJavaStdin;
|
|
284
275
|
if (previousWindow === undefined) {
|
|
285
276
|
Reflect.deleteProperty(workerGlobal, 'window');
|
|
286
277
|
}
|
|
287
278
|
else {
|
|
288
279
|
workerGlobal.window = previousWindow;
|
|
289
280
|
}
|
|
290
|
-
stdinChunkJava = new Uint8Array(0);
|
|
291
|
-
stdinChunkOffsetJava = 0;
|
|
292
|
-
stdinBufferJava = null;
|
|
293
281
|
}
|
|
294
282
|
}
|
|
295
283
|
catch (error) {
|