wasm-idle 1.0.8 → 1.0.10

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 (79) hide show
  1. package/README.md +60 -26
  2. package/dist/playground/applicationAssets.js +18 -0
  3. package/dist/playground/assetBridge.d.ts +1 -1
  4. package/dist/playground/assetBridge.js +172 -117
  5. package/dist/playground/assets.d.ts +74 -4
  6. package/dist/playground/assets.js +127 -4
  7. package/dist/playground/cachedClang.js +44 -5
  8. package/dist/playground/clang.d.ts +5 -0
  9. package/dist/playground/clang.js +100 -0
  10. package/dist/playground/clangWorkerProtocol.d.ts +13 -1
  11. package/dist/playground/fennel.d.ts +9 -0
  12. package/dist/playground/fennel.js +30 -0
  13. package/dist/playground/fennelBootstrap.d.ts +31 -0
  14. package/dist/playground/fennelBootstrap.js +118 -0
  15. package/dist/playground/grain.d.ts +9 -0
  16. package/dist/playground/grain.js +127 -0
  17. package/dist/playground/hy.d.ts +21 -0
  18. package/dist/playground/hy.js +24 -0
  19. package/dist/playground/index.d.ts +1 -1
  20. package/dist/playground/index.js +49 -0
  21. package/dist/playground/lua.d.ts +19 -0
  22. package/dist/playground/lua.js +64 -39
  23. package/dist/playground/objectivec.d.ts +3 -1
  24. package/dist/playground/objectivec.js +6 -2
  25. package/dist/playground/options.js +1 -1
  26. package/dist/playground/postgresql.d.ts +36 -0
  27. package/dist/playground/postgresql.js +543 -0
  28. package/dist/playground/python.d.ts +5 -0
  29. package/dist/playground/python.js +13 -0
  30. package/dist/playground/rescript.d.ts +5 -0
  31. package/dist/playground/rescript.js +58 -0
  32. package/dist/playground/rescriptPreflight.d.ts +26 -0
  33. package/dist/playground/rescriptPreflight.js +381 -0
  34. package/dist/playground/runtimeAssetCache.d.ts +6 -0
  35. package/dist/playground/runtimeAssetCache.js +109 -0
  36. package/dist/playground/staticRuntimeModuleVersion.d.ts +1 -1
  37. package/dist/playground/staticRuntimeModuleVersion.js +1 -1
  38. package/dist/playground/staticRuntimePreflightExecute.d.ts +2 -1
  39. package/dist/playground/staticRuntimePreflightExecute.js +9 -0
  40. package/dist/playground/staticRuntimePreflightProtocol.d.ts +1 -1
  41. package/dist/playground/v.d.ts +46 -0
  42. package/dist/playground/v.js +703 -0
  43. package/dist/playground/wasmBashVersion.d.ts +25 -25
  44. package/dist/playground/wasmBashVersion.js +12 -12
  45. package/dist/playground/wasmElixirVersion.d.ts +9 -9
  46. package/dist/playground/wasmElixirVersion.js +9 -9
  47. package/dist/playground/wasmFennelVersion.d.ts +23 -0
  48. package/dist/playground/wasmFennelVersion.js +16 -0
  49. package/dist/playground/wasmGrainVersion.d.ts +24 -0
  50. package/dist/playground/wasmGrainVersion.js +25 -0
  51. package/dist/playground/wasmHaskellVersion.d.ts +1 -1
  52. package/dist/playground/wasmHaskellVersion.js +1 -1
  53. package/dist/playground/wasmHyVersion.d.ts +7 -0
  54. package/dist/playground/wasmHyVersion.js +15 -0
  55. package/dist/playground/wasmLispVersion.d.ts +1 -1
  56. package/dist/playground/wasmLispVersion.js +1 -1
  57. package/dist/playground/wasmOcamlVersion.d.ts +4 -4
  58. package/dist/playground/wasmOcamlVersion.js +3 -3
  59. package/dist/playground/wasmPrologVersion.d.ts +19 -19
  60. package/dist/playground/wasmPrologVersion.js +18 -18
  61. package/dist/playground/wasmReScriptVersion.d.ts +20 -0
  62. package/dist/playground/wasmReScriptVersion.js +20 -0
  63. package/dist/playground/wasmTypeScriptVersion.d.ts +5 -5
  64. package/dist/playground/wasmTypeScriptVersion.js +5 -5
  65. package/dist/playground/worker/cachedClangCompile.js +44 -5
  66. package/dist/playground/worker/clang.js +44 -11
  67. package/dist/playground/worker/clangStreaming.js +6 -0
  68. package/dist/playground/worker/lua.js +48 -11
  69. package/dist/playground/worker/postgresql.d.ts +1 -0
  70. package/dist/playground/worker/postgresql.js +205 -0
  71. package/dist/playground/worker/python.js +113 -12
  72. package/dist/playground/worker/runtimeModule.d.ts +1 -1
  73. package/dist/playground/worker/runtimeModule.js +1 -1
  74. package/dist/playground/worker/staticRuntimePreflight.js +2 -1
  75. package/dist/playground/worker/v.d.ts +1 -0
  76. package/dist/playground/worker/v.js +106 -0
  77. package/dist/testPublicEnv.d.ts +2 -0
  78. package/dist/testPublicEnv.js +8 -0
  79. package/package.json +59 -48
@@ -0,0 +1,30 @@
1
+ import { resolveFennelCompilerUrl } from './assets';
2
+ import Lua from './lua';
3
+ import { WASM_FENNEL_COMPILER_RECEIPT } from './wasmFennelVersion';
4
+ import { RuntimeConfigurationError } from '@wasm-idle/core';
5
+ /**
6
+ * Fennel runs the pinned official `fennel.lua` compiler on the shared wasm-lua (wasmoon)
7
+ * worker. The worker fetches and verifies the compiler against its receipt before use.
8
+ */
9
+ class Fennel extends Lua {
10
+ constructor() {
11
+ super({
12
+ label: 'Fennel',
13
+ runtimeId: 'FENNEL',
14
+ defaultActivePath: 'main.fnl',
15
+ resolveWorkerLoadExtras(runtimeAssets, currentUrl) {
16
+ const compilerUrl = resolveFennelCompilerUrl(runtimeAssets, currentUrl);
17
+ if (!compilerUrl) {
18
+ throw new RuntimeConfigurationError('Fennel compiler is not configured. Set PUBLIC_WASM_FENNEL_COMPILER_URL or runtimeAssets.fennel.compilerUrl.', { runtimeId: 'FENNEL' });
19
+ }
20
+ return {
21
+ fennelCompiler: {
22
+ url: compilerUrl,
23
+ receipt: { ...WASM_FENNEL_COMPILER_RECEIPT }
24
+ }
25
+ };
26
+ }
27
+ });
28
+ }
29
+ }
30
+ export default Fennel;
@@ -0,0 +1,31 @@
1
+ import type { WasmFennelCompilerReceipt } from './wasmFennelVersion';
2
+ /**
3
+ * Fennel runs the official, receipt-verified `fennel.lua` compiler on the wasm-lua VM.
4
+ * These helpers build the Lua entry chunks that load that compiler and hand it the user's
5
+ * Fennel source; they never parse or translate Fennel themselves.
6
+ */
7
+ export interface FennelCompilerAsset {
8
+ url: string;
9
+ receipt: WasmFennelCompilerReceipt;
10
+ }
11
+ export interface FennelDiagnostic {
12
+ fileName: string | null;
13
+ lineNumber: number;
14
+ columnNumber?: number;
15
+ severity: 'error';
16
+ message: string;
17
+ }
18
+ export declare function luaQuotedString(value: string): string;
19
+ /** Lua chunk that only compiles the Fennel source, raising the compiler error on failure. */
20
+ export declare function buildFennelCompileChunk(fennelSource: string, code: string, fileName: string): string;
21
+ /** Lua chunk that evaluates the Fennel program through `fennel.eval`. */
22
+ export declare function buildFennelRunChunk(fennelSource: string, code: string, fileName: string): string;
23
+ /** Drops the host Lua traceback that wasmoon appends to errors raised by the entry chunk. */
24
+ export declare function stripHostLuaTraceback(message: string): string;
25
+ export declare function parseFennelDiagnostic(message: string, fileName: string): FennelDiagnostic;
26
+ /**
27
+ * Verifies the fetched fennel.lua asset against its pinned receipt. Accepts either the
28
+ * gzip delivery bytes or bytes a server already decoded via Content-Encoding.
29
+ */
30
+ export declare function verifyFennelCompilerBytes(bytes: Uint8Array, receipt: WasmFennelCompilerReceipt): Promise<string>;
31
+ export declare function loadFennelCompilerSource(asset: FennelCompilerAsset): Promise<string>;
@@ -0,0 +1,118 @@
1
+ const GZIP_MAGIC_0 = 0x1f;
2
+ const GZIP_MAGIC_1 = 0x8b;
3
+ const SHA256_PATTERN = /^[a-f0-9]{64}$/u;
4
+ export function luaQuotedString(value) {
5
+ let quoted = '"';
6
+ for (const character of value) {
7
+ const codePoint = character.codePointAt(0);
8
+ if (character === '\\')
9
+ quoted += '\\\\';
10
+ else if (character === '"')
11
+ quoted += '\\"';
12
+ else if (codePoint < 0x20 || codePoint === 0x7f)
13
+ quoted += `\\${String(codePoint).padStart(3, '0')}`;
14
+ else
15
+ quoted += character;
16
+ }
17
+ return `${quoted}"`;
18
+ }
19
+ function fennelLoaderChunk(fennelSource) {
20
+ // fennel.lua is a single chunk ending in `return mod`; wrapping it in a vararg function
21
+ // keeps it byte-for-byte unmodified while letting the entry chunk reuse the module.
22
+ return `local fennel = (function(...)\n${fennelSource}\nend)("fennel")\npackage.loaded.fennel = fennel\n`;
23
+ }
24
+ function fennelOptions(fileName) {
25
+ return `{ filename = ${luaQuotedString(fileName)}, ["error-pinpoint"] = false }`;
26
+ }
27
+ /** Lua chunk that only compiles the Fennel source, raising the compiler error on failure. */
28
+ export function buildFennelCompileChunk(fennelSource, code, fileName) {
29
+ return (fennelLoaderChunk(fennelSource) +
30
+ `local options = ${fennelOptions(fileName)}\n` +
31
+ // Match fennel.eval, which rejects unknown globals against the current environment.
32
+ `options.allowedGlobals = require("fennel.specials")["current-global-names"]()\n` +
33
+ `local ok, err = pcall(fennel.compileString, ${luaQuotedString(code)}, options)\n` +
34
+ `if not ok then error(tostring(err), 0) end\n`);
35
+ }
36
+ /** Lua chunk that evaluates the Fennel program through `fennel.eval`. */
37
+ export function buildFennelRunChunk(fennelSource, code, fileName) {
38
+ return (fennelLoaderChunk(fennelSource) +
39
+ `local ok, err = xpcall(fennel.eval, function(e) return tostring(e) end, ${luaQuotedString(code)}, ${fennelOptions(fileName)})\n` +
40
+ `if not ok then error(err, 0) end\n`);
41
+ }
42
+ /** Drops the host Lua traceback that wasmoon appends to errors raised by the entry chunk. */
43
+ export function stripHostLuaTraceback(message) {
44
+ const index = message.indexOf('\nstack traceback:');
45
+ return (index === -1 ? message : message.slice(0, index)).trimEnd();
46
+ }
47
+ export function parseFennelDiagnostic(message, fileName) {
48
+ const clean = stripHostLuaTraceback(message.replace(/^Error:\s*/u, ''));
49
+ const firstLine = clean.split('\n', 1)[0] ?? '';
50
+ const match = /^([^:\n]+):(\d+):(?:(\d+):)?\s*([\s\S]*)$/u.exec(firstLine);
51
+ return {
52
+ fileName: match?.[1] || fileName,
53
+ lineNumber: Math.max(1, Number(match?.[2] || 1)),
54
+ columnNumber: match?.[3] ? Math.max(1, Number(match[3]) + 1) : undefined,
55
+ severity: 'error',
56
+ message: (match?.[4] || clean || message).trim()
57
+ };
58
+ }
59
+ async function sha256Hex(bytes) {
60
+ const digest = await crypto.subtle.digest('SHA-256', bytes);
61
+ return Array.from(new Uint8Array(digest), (byte) => byte.toString(16).padStart(2, '0')).join('');
62
+ }
63
+ async function gunzip(bytes) {
64
+ const stream = new Blob([bytes])
65
+ .stream()
66
+ .pipeThrough(new DecompressionStream('gzip'));
67
+ return new Uint8Array(await new Response(stream).arrayBuffer());
68
+ }
69
+ function assertReceipt(receipt) {
70
+ if (!SHA256_PATTERN.test(receipt.sha256) ||
71
+ !SHA256_PATTERN.test(receipt.uncompressedSha256) ||
72
+ !Number.isSafeInteger(receipt.bytes) ||
73
+ !Number.isSafeInteger(receipt.uncompressedBytes)) {
74
+ throw new Error('Fennel compiler receipt is malformed');
75
+ }
76
+ }
77
+ /**
78
+ * Verifies the fetched fennel.lua asset against its pinned receipt. Accepts either the
79
+ * gzip delivery bytes or bytes a server already decoded via Content-Encoding.
80
+ */
81
+ export async function verifyFennelCompilerBytes(bytes, receipt) {
82
+ assertReceipt(receipt);
83
+ let decoded = bytes;
84
+ if (bytes[0] === GZIP_MAGIC_0 && bytes[1] === GZIP_MAGIC_1) {
85
+ if (bytes.byteLength !== receipt.bytes) {
86
+ throw new Error(`Fennel compiler asset is ${bytes.byteLength} bytes; receipt expects ${receipt.bytes}`);
87
+ }
88
+ if ((await sha256Hex(bytes)) !== receipt.sha256) {
89
+ throw new Error('Fennel compiler asset SHA-256 does not match its pinned receipt');
90
+ }
91
+ decoded = await gunzip(bytes);
92
+ }
93
+ if (decoded.byteLength !== receipt.uncompressedBytes) {
94
+ throw new Error(`Fennel compiler source is ${decoded.byteLength} bytes; receipt expects ${receipt.uncompressedBytes}`);
95
+ }
96
+ if ((await sha256Hex(decoded)) !== receipt.uncompressedSha256) {
97
+ throw new Error('Fennel compiler source SHA-256 does not match its pinned receipt');
98
+ }
99
+ return new TextDecoder('utf-8', { fatal: true }).decode(decoded);
100
+ }
101
+ export async function loadFennelCompilerSource(asset) {
102
+ if (!asset?.url)
103
+ throw new Error('Fennel compiler URL is not configured');
104
+ const response = await fetch(asset.url);
105
+ if (!response.ok) {
106
+ throw new Error(`Failed to fetch Fennel compiler (${response.status})`);
107
+ }
108
+ const declaredLength = Number(response.headers.get('content-length'));
109
+ const maxBytes = Math.max(asset.receipt.bytes, asset.receipt.uncompressedBytes);
110
+ if (Number.isFinite(declaredLength) && declaredLength > maxBytes) {
111
+ throw new Error(`Fennel compiler asset exceeds its ${maxBytes} byte receipt`);
112
+ }
113
+ const bytes = new Uint8Array(await response.arrayBuffer());
114
+ if (bytes.byteLength > maxBytes) {
115
+ throw new Error(`Fennel compiler asset exceeds its ${maxBytes} byte receipt`);
116
+ }
117
+ return await verifyFennelCompilerBytes(bytes, asset.receipt);
118
+ }
@@ -0,0 +1,9 @@
1
+ import { StaticWorkerRuntimeSandbox } from './staticWorkerRuntime';
2
+ /** Upstream Grain compiler (js_of_ocaml build) plus a WASI host for the program it emits. */
3
+ declare class Grain extends StaticWorkerRuntimeSandbox {
4
+ readonly memoryEvidence: {
5
+ current: unknown;
6
+ };
7
+ constructor();
8
+ }
9
+ export default Grain;
@@ -0,0 +1,127 @@
1
+ import { resolveGrainBaseUrl } from './assets';
2
+ import { StaticWorkerRuntimeSandbox } from './staticWorkerRuntime';
3
+ import { bundledGrainProfile as profile, bundledGrainWorkerReceipt } from './wasmGrainVersion';
4
+ import { preflightRuntimeAssets } from '@wasm-idle/core';
5
+ const registry = {
6
+ schemaVersion: 2,
7
+ manifestId: 'wasm-idle/grain-preflight',
8
+ revision: profile.compilerJavaScript.sha256,
9
+ runtimes: [
10
+ {
11
+ runtimeId: 'GRAIN',
12
+ identity: {
13
+ languageId: 'GRAIN',
14
+ implementationId: 'grainc',
15
+ implementationVersion: profile.grainVersion,
16
+ profile: {
17
+ profileId: profile.profileId,
18
+ manifestSchemaVersion: 1,
19
+ manifestSha256: profile.compilerJavaScript.sha256,
20
+ protocolVersion: 1,
21
+ trustProfileId: 'wasm-idle-static-worker-v1',
22
+ trustProfileSchemaVersion: 1
23
+ }
24
+ },
25
+ capabilities: {
26
+ stdin: 'streaming',
27
+ workspace: true,
28
+ abort: true,
29
+ artifacts: false,
30
+ streamingOutput: true
31
+ },
32
+ workerLifetime: { mode: 'per-run' },
33
+ requiredBrowserFeatures: ['wasm'],
34
+ assetRoot: '.',
35
+ assets: [
36
+ {
37
+ key: 'compilerBytes',
38
+ path: 'grainc.js.gz.bin',
39
+ mediaType: 'text/javascript',
40
+ compressedSha256: profile.compilerStorage.sha256,
41
+ compressedBytes: profile.compilerStorage.bytes,
42
+ uncompressedSha256: profile.compilerJavaScript.sha256,
43
+ uncompressedBytes: profile.compilerJavaScript.bytes,
44
+ encoding: 'gzip'
45
+ },
46
+ {
47
+ key: 'stdlibBytes',
48
+ path: 'stdlib.pack.gz.bin',
49
+ mediaType: 'application/octet-stream',
50
+ compressedSha256: profile.stdlibStorage.sha256,
51
+ compressedBytes: profile.stdlibStorage.bytes,
52
+ uncompressedSha256: profile.stdlibPack.sha256,
53
+ uncompressedBytes: profile.stdlibPack.bytes,
54
+ encoding: 'gzip'
55
+ }
56
+ ],
57
+ contracts: {
58
+ routeId: 'grain',
59
+ runtimeAssetKey: 'grain',
60
+ documentationId: 'GRAIN',
61
+ syncTarget: 'sync:wasm-grain',
62
+ browserTestId: 'browser:grain'
63
+ }
64
+ }
65
+ ]
66
+ };
67
+ /** Upstream Grain compiler (js_of_ocaml build) plus a WASI host for the program it emits. */
68
+ class Grain extends StaticWorkerRuntimeSandbox {
69
+ memoryEvidence;
70
+ constructor() {
71
+ const memoryEvidence = { current: undefined };
72
+ super({
73
+ displayName: 'Grain',
74
+ languageId: 'GRAIN',
75
+ defaultActivePath: 'main.gr',
76
+ workerLifetime: { mode: 'per-run' },
77
+ runtimePreflightDelivery: 'transfer-owned',
78
+ stdin: {
79
+ mode: 'streaming',
80
+ sourceHintPattern: /\bFile\.(?:fdRead|stdin)\b|"wasi\/file"/u
81
+ },
82
+ inlineVerifiedWorker: true,
83
+ moduleWorker: true,
84
+ includeExecutionLimits: true,
85
+ enforcePhaseTimeouts: true,
86
+ onEvidence(evidence) {
87
+ memoryEvidence.current = evidence;
88
+ },
89
+ resolveRuntimeAssets(runtimeAssets, currentUrl) {
90
+ const baseUrl = resolveGrainBaseUrl(runtimeAssets, currentUrl);
91
+ return {
92
+ baseUrl,
93
+ workerUrl: new URL('runner-worker.js', baseUrl).href,
94
+ manifestUrl: new URL('runtime-build.json', baseUrl).href,
95
+ manifestFingerprint: profile.compilerJavaScript.sha256,
96
+ preflightKey: profile.stdlibPack.sha256,
97
+ workerReceipt: bundledGrainWorkerReceipt
98
+ };
99
+ },
100
+ async preflightRuntimeAssets(urls, context) {
101
+ memoryEvidence.current = undefined;
102
+ const result = await preflightRuntimeAssets({
103
+ manifest: registry,
104
+ runtimeId: 'GRAIN',
105
+ rootUrl: urls.baseUrl,
106
+ limits: context.limits,
107
+ persistentCache: context.persistentCache,
108
+ signal: context.signal,
109
+ redirect: 'error',
110
+ requireExactResponseUrl: true,
111
+ maxTotalDeliveryBytes: profile.compilerStorage.bytes + profile.stdlibStorage.bytes,
112
+ reportProgress(progress) {
113
+ context.reportProgress(0.1, `Preflighting Grain ${progress.assetKey}`);
114
+ }
115
+ });
116
+ return context.createOwnedDelivery(Object.freeze({
117
+ protocol: 'wasm-idle-grain-preflight',
118
+ profileId: profile.profileId,
119
+ compilerBytes: result.assets.compilerBytes.bytes,
120
+ stdlibBytes: result.assets.stdlibBytes.bytes
121
+ }));
122
+ }
123
+ });
124
+ this.memoryEvidence = memoryEvidence;
125
+ }
126
+ }
127
+ export default Grain;
@@ -0,0 +1,21 @@
1
+ import Python from './python';
2
+ import { type PlaygroundRuntimeAssets } from './assets';
3
+ export type HyWorkerExtension = {
4
+ language: 'hy';
5
+ version: string;
6
+ wheels: {
7
+ url: string;
8
+ fileName: string;
9
+ bytes: number;
10
+ sha256: string;
11
+ }[];
12
+ };
13
+ /**
14
+ * Hy runs on the shared Pyodide worker: the pinned Hy and funcparserlib wheels are fetched from
15
+ * local static assets, verified against code-pinned receipts, and unpacked into site-packages.
16
+ */
17
+ declare class Hy extends Python {
18
+ protected readonly workerLanguage: "hy";
19
+ protected workerLoadExtension(runtimeAssets: string | PlaygroundRuntimeAssets, currentUrl: string): HyWorkerExtension;
20
+ }
21
+ export default Hy;
@@ -0,0 +1,24 @@
1
+ import Python from './python';
2
+ import { resolveHyBaseUrl } from './assets';
3
+ import { WASM_HY_VERSION, WASM_HY_WHEELS } from './wasmHyVersion';
4
+ /**
5
+ * Hy runs on the shared Pyodide worker: the pinned Hy and funcparserlib wheels are fetched from
6
+ * local static assets, verified against code-pinned receipts, and unpacked into site-packages.
7
+ */
8
+ class Hy extends Python {
9
+ workerLanguage = 'hy';
10
+ workerLoadExtension(runtimeAssets, currentUrl) {
11
+ const baseUrl = resolveHyBaseUrl(runtimeAssets, currentUrl);
12
+ return {
13
+ language: 'hy',
14
+ version: WASM_HY_VERSION,
15
+ wheels: WASM_HY_WHEELS.map((wheel) => ({
16
+ url: `${baseUrl}${wheel.fileName}`,
17
+ fileName: wheel.fileName,
18
+ bytes: wheel.bytes,
19
+ sha256: wheel.sha256
20
+ }))
21
+ };
22
+ }
23
+ }
24
+ export default Hy;
@@ -1,6 +1,6 @@
1
1
  import type { BoundSandbox, PlaygroundBinding, Sandbox, SandboxRuntimeAssets } from './sandbox';
2
2
  import { type PlaygroundBindingOptions } from '@wasm-idle/core';
3
- export declare const supportedLanguages: ("C" | "CPP" | "OBJC" | "D" | "TINYGO" | "RUBY" | "PERL" | "TCL" | "AWK" | "PASCAL" | "JANET" | "JULIA" | "NIM" | "BASH" | "BQN" | "CLOJURESCRIPT" | "FORTH" | "J" | "PROLOG" | "C3" | "PYTHON3" | "JAVA" | "RUST" | "GO" | "CSHARP" | "FSHARP" | "VBNET" | "ELIXIR" | "ERLANG" | "GLEAM" | "FORTRAN" | "LFORTRAN" | "COBOL" | "OCAML" | "JAVASCRIPT" | "TYPESCRIPT" | "ASSEMBLYSCRIPT" | "WAT" | "WASM" | "LUA" | "ZIG" | "LISP" | "HASKELL" | "R" | "OCTAVE" | "DUCKDB" | "SQLITE" | "PHP")[];
3
+ export declare const supportedLanguages: ("C" | "CPP" | "OBJC" | "OBJECTIVECXX" | "D" | "TINYGO" | "RUBY" | "PERL" | "TCL" | "AWK" | "PASCAL" | "JANET" | "JULIA" | "NIM" | "BASH" | "BQN" | "CLOJURESCRIPT" | "FORTH" | "J" | "PROLOG" | "RESCRIPT" | "C3" | "PYTHON3" | "JAVA" | "RUST" | "GO" | "CSHARP" | "FSHARP" | "VBNET" | "ELIXIR" | "ERLANG" | "GLEAM" | "GRAIN" | "HY" | "FORTRAN" | "LFORTRAN" | "COBOL" | "V" | "OCAML" | "JAVASCRIPT" | "TYPESCRIPT" | "ASSEMBLYSCRIPT" | "WAT" | "WASM" | "LUA" | "FENNEL" | "ZIG" | "LISP" | "HASKELL" | "R" | "OCTAVE" | "DUCKDB" | "SQLITE" | "POSTGRESQL" | "PHP")[];
4
4
  export declare function createPlaygroundBinding(runtimeAssets: SandboxRuntimeAssets, options?: PlaygroundBindingOptions): PlaygroundBinding;
5
5
  declare function playground(language: string): Promise<Sandbox>;
6
6
  declare function playground(language: string, runtimeAssets: SandboxRuntimeAssets, options?: PlaygroundBindingOptions): Promise<BoundSandbox>;
@@ -14,6 +14,13 @@ const sandboxRoutes = [
14
14
  return new Python();
15
15
  }
16
16
  },
17
+ {
18
+ languageId: 'HY',
19
+ load: async () => {
20
+ const { default: Hy } = await import('./hy');
21
+ return new Hy();
22
+ }
23
+ },
17
24
  {
18
25
  languageId: 'C',
19
26
  load: async () => {
@@ -35,6 +42,13 @@ const sandboxRoutes = [
35
42
  return new ObjectiveC();
36
43
  }
37
44
  },
45
+ {
46
+ languageId: 'OBJECTIVECXX',
47
+ load: async () => {
48
+ const { default: ObjectiveC } = await import('./objectivec');
49
+ return new ObjectiveC('OBJECTIVECXX');
50
+ }
51
+ },
38
52
  {
39
53
  languageId: 'JAVA',
40
54
  load: async () => {
@@ -112,6 +126,13 @@ const sandboxRoutes = [
112
126
  return new Gleam();
113
127
  }
114
128
  },
129
+ {
130
+ languageId: 'GRAIN',
131
+ load: async () => {
132
+ const { default: Grain } = await import('./grain');
133
+ return new Grain();
134
+ }
135
+ },
115
136
  {
116
137
  languageId: 'PERL',
117
138
  load: async () => {
@@ -147,6 +168,13 @@ const sandboxRoutes = [
147
168
  return new ClojureScript();
148
169
  }
149
170
  },
171
+ {
172
+ languageId: 'RESCRIPT',
173
+ load: async () => {
174
+ const { default: ReScript } = await import('./rescript');
175
+ return new ReScript();
176
+ }
177
+ },
150
178
  {
151
179
  languageId: 'FORTH',
152
180
  load: async () => {
@@ -217,6 +245,13 @@ const sandboxRoutes = [
217
245
  return new Cobol();
218
246
  }
219
247
  },
248
+ {
249
+ languageId: 'V',
250
+ load: async () => {
251
+ const { default: VLang } = await import('./v');
252
+ return new VLang();
253
+ }
254
+ },
220
255
  {
221
256
  languageId: 'TINYGO',
222
257
  load: async () => {
@@ -273,6 +308,13 @@ const sandboxRoutes = [
273
308
  return new Lua();
274
309
  }
275
310
  },
311
+ {
312
+ languageId: 'FENNEL',
313
+ load: async () => {
314
+ const { default: Fennel } = await import('./fennel');
315
+ return new Fennel();
316
+ }
317
+ },
276
318
  {
277
319
  languageId: 'ZIG',
278
320
  load: async () => {
@@ -329,6 +371,13 @@ const sandboxRoutes = [
329
371
  return new Sqlite();
330
372
  }
331
373
  },
374
+ {
375
+ languageId: 'POSTGRESQL',
376
+ load: async () => {
377
+ const { default: Postgresql } = await import('./postgresql');
378
+ return new Postgresql();
379
+ }
380
+ },
332
381
  {
333
382
  languageId: 'PHP',
334
383
  load: async () => {
@@ -1,6 +1,20 @@
1
1
  import { type PlaygroundRuntimeAssets } from './assets';
2
2
  import { type CompilerDiagnostic, type SandboxExecutionOptions } from './options';
3
3
  import type { Sandbox, SandboxProgress } from './sandbox';
4
+ /**
5
+ * Describes a language that runs on the wasm-lua (wasmoon) VM. Lua itself uses the
6
+ * default dialect; Fennel reuses this sandbox and worker with the pinned fennel.lua compiler.
7
+ */
8
+ export interface LuaSandboxDialect {
9
+ label: string;
10
+ runtimeId: string;
11
+ defaultActivePath: string;
12
+ /**
13
+ * Extra worker load fields. The value is also part of the worker identity, so a change
14
+ * replaces the loaded worker.
15
+ */
16
+ resolveWorkerLoadExtras?: (runtimeAssets: string | PlaygroundRuntimeAssets, currentUrl: string) => Record<string, unknown>;
17
+ }
4
18
  declare class Lua implements Sandbox {
5
19
  output: any;
6
20
  worker?: Worker;
@@ -17,8 +31,13 @@ declare class Lua implements Sandbox {
17
31
  private activeOperation;
18
32
  private disposed;
19
33
  private disposePromise;
34
+ private readonly dialect;
35
+ private readonly label;
36
+ private readonly runtimeId;
37
+ private workerIdentity;
20
38
  private readonly disposeCancellation;
21
39
  private readonly workerSession;
40
+ constructor(dialect?: LuaSandboxDialect);
22
41
  private requireOperationIdle;
23
42
  private beginOperation;
24
43
  private isOperationActive;