@innovatorved/code-lab 0.1.5 → 0.1.6

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/dist/runtime.d.ts CHANGED
@@ -39,6 +39,7 @@ export declare const createVirtualFs: (options?: any) => any;
39
39
  export declare const createVirtualHttp: (portTable?: any, vfs?: any) => any;
40
40
  export declare const createVirtualNet: (portTable?: any) => any;
41
41
  export declare const transpileTS: (code: string, filename?: string) => string;
42
+ export declare const transpileForBrowser: (source: string, filename?: string) => string;
42
43
  export declare const preloadNpmPackages: (files?: Record<string, any>, onProgressOrCache?: ((pkg: string) => void) | Map<string, string>, onProgress?: (pkg: string) => void) => Promise<Record<string, string>>;
43
44
  export declare const createVirtualPortTable: () => any;
44
45
  export declare const executeInVirtualRuntime: (options?: any) => Promise<RuntimeExecutionResult>;
@@ -827,9 +827,78 @@ function __initVirtualRuntime(rootScope) {
827
827
  crc = CRC32_TABLE[(crc ^ bytes[i]) & 0xff] ^ (crc >>> 8);
828
828
  }
829
829
  return (crc ^ 0xffffffff) >>> 0;
830
+ },
831
+ // The full Node zlib constant surface. Packages such as axios read these at
832
+ // module-load time (e.g. `zlib.constants.Z_SYNC_FLUSH`) even when they never
833
+ // actually compress, so a missing table breaks the whole module graph.
834
+ constants: {
835
+ Z_NO_FLUSH: 0, Z_PARTIAL_FLUSH: 1, Z_SYNC_FLUSH: 2, Z_FULL_FLUSH: 3, Z_FINISH: 4,
836
+ Z_BLOCK: 5, Z_TREES: 6, Z_OK: 0, Z_STREAM_END: 1, Z_NEED_DICT: 2, Z_ERRNO: -1,
837
+ Z_STREAM_ERROR: -2, Z_DATA_ERROR: -3, Z_MEM_ERROR: -4, Z_BUF_ERROR: -5,
838
+ Z_VERSION_ERROR: -6, Z_NO_COMPRESSION: 0, Z_BEST_SPEED: 1, Z_BEST_COMPRESSION: 9,
839
+ Z_DEFAULT_COMPRESSION: -1, Z_FILTERED: 1, Z_HUFFMAN_ONLY: 2, Z_RLE: 3, Z_FIXED: 4,
840
+ Z_DEFAULT_STRATEGY: 0, ZLIB_VERNUM: 0x1310, DEFLATE: 1, INFLATE: 2, GZIP: 3,
841
+ GUNZIP: 4, DEFLATERAW: 5, INFLATERAW: 6, UNZIP: 7, BROTLI_DECODE: 8,
842
+ BROTLI_ENCODE: 9, Z_MIN_WINDOWBITS: 8, Z_MAX_WINDOWBITS: 15,
843
+ Z_DEFAULT_WINDOWBITS: 15, Z_MIN_CHUNK: 64, Z_MAX_CHUNK: Infinity,
844
+ Z_DEFAULT_CHUNK: 16384, Z_MIN_MEMLEVEL: 1, Z_MAX_MEMLEVEL: 9,
845
+ Z_DEFAULT_MEMLEVEL: 8, Z_MIN_LEVEL: -1, Z_MAX_LEVEL: 9, Z_DEFAULT_LEVEL: -1
830
846
  }
831
847
  };
832
848
 
849
+ // Compression: delegate to the host's real zlib when the runtime is embedded in
850
+ // Node (same process). In a pure browser worker there is no synchronous zlib, so
851
+ // the async APIs use CompressionStream/DecompressionStream and the *Sync variants
852
+ // throw a descriptive error instead of silently corrupting data.
853
+ (() => {
854
+ let hostZlib = null;
855
+ try { hostZlib = (typeof require === 'function') ? require('zlib') : null; } catch (_) { hostZlib = null; }
856
+ const names = [
857
+ 'gzip', 'gunzip', 'deflate', 'inflate', 'deflateRaw', 'inflateRaw', 'unzip',
858
+ 'gzipSync', 'gunzipSync', 'deflateSync', 'inflateSync', 'deflateRawSync', 'inflateRawSync', 'unzipSync',
859
+ 'createGzip', 'createGunzip', 'createDeflate', 'createInflate', 'createDeflateRaw', 'createInflateRaw'
860
+ ];
861
+ if (hostZlib) {
862
+ for (const n of names) {
863
+ if (typeof hostZlib[n] === 'function') VirtualZlib[n] = hostZlib[n].bind(hostZlib);
864
+ }
865
+ return;
866
+ }
867
+ const asyncVariant = (format, kind) => (data, optsOrCb, maybeCb) => {
868
+ const cb = typeof optsOrCb === 'function' ? optsOrCb : (typeof maybeCb === 'function' ? maybeCb : null);
869
+ const p = (async () => {
870
+ if (typeof CompressionStream === 'undefined' || typeof DecompressionStream === 'undefined' || typeof Response === 'undefined') {
871
+ throw new Error('zlib.' + kind + ' is not supported in this environment');
872
+ }
873
+ const decompress = /^(gunzip|unzip|inflate)/.test(kind);
874
+ const stream = decompress ? new DecompressionStream(format) : new CompressionStream(format);
875
+ const writer = stream.writable.getWriter();
876
+ const input = data instanceof Uint8Array ? data : VirtualBuffer.from(data);
877
+ writer.write(input);
878
+ writer.close();
879
+ const ab = await new Response(stream.readable).arrayBuffer();
880
+ return VirtualBuffer.from(ab);
881
+ })();
882
+ if (cb) { p.then((out) => cb(null, out), (err) => cb(err)); return undefined; }
883
+ return p;
884
+ };
885
+ VirtualZlib.gzip = asyncVariant('gzip', 'gzip');
886
+ VirtualZlib.gunzip = asyncVariant('gzip', 'gunzip');
887
+ VirtualZlib.unzip = asyncVariant('gzip', 'unzip');
888
+ VirtualZlib.deflate = asyncVariant('deflate', 'deflate');
889
+ VirtualZlib.inflate = asyncVariant('deflate', 'inflate');
890
+ VirtualZlib.deflateRaw = asyncVariant('deflate-raw', 'deflateRaw');
891
+ VirtualZlib.inflateRaw = asyncVariant('deflate-raw', 'inflateRaw');
892
+ const unsupported = (kind) => () => { throw new Error('zlib.' + kind + ' is not supported in a browser worker (use the async API)'); };
893
+ VirtualZlib.gzipSync = unsupported('gzipSync');
894
+ VirtualZlib.gunzipSync = unsupported('gunzipSync');
895
+ VirtualZlib.deflateSync = unsupported('deflateSync');
896
+ VirtualZlib.inflateSync = unsupported('inflateSync');
897
+ VirtualZlib.deflateRawSync = unsupported('deflateRawSync');
898
+ VirtualZlib.inflateRawSync = unsupported('inflateRawSync');
899
+ VirtualZlib.unzipSync = unsupported('unzipSync');
900
+ })();
901
+
833
902
  // =========================================================================
834
903
  // 4. PATH & OS SHIMS
835
904
  // =========================================================================
@@ -4868,7 +4937,13 @@ function __initVirtualRuntime(rootScope) {
4868
4937
  return cleaned ? `const { ${cleaned} } = require(${mod.trim()});` : '';
4869
4938
  });
4870
4939
  code = code.replace(/\bimport\s+([A-Za-z_$][A-Za-z0-9_$]*)\s+from\s+([^\n;]+);?/gm, 'const $1 = (function(m){ return m && m.__esModule ? m.default : m; })(require($2));');
4871
- code = code.replace(/\bimport\s+(\x00__LIT_\d+__\x00)\s*;?/gm, 'require($1);');
4940
+ // Dynamic `import("pkg")` — resolve through the CJS loader instead of the
4941
+ // host's dynamic import, which cannot see the virtual filesystem.
4942
+ code = code.replace(/\bimport\s*\(\s*(\x00__LIT_\d+__\x00)\s*\)/g, 'Promise.resolve().then(() => require($1))');
4943
+ // Side-effect import `import"pkg"` / `import "pkg"`. By this point the
4944
+ // specifier is literal-masked, and minified modules emit no whitespace
4945
+ // between `import` and the string, so `\s*` (not `\s+`) is required.
4946
+ code = code.replace(/\bimport\s*(\x00__LIT_\d+__\x00)\s*;?/gm, 'require($1);');
4872
4947
 
4873
4948
  // Convert ES module exports
4874
4949
  const exportedNames = [];
@@ -5001,8 +5076,12 @@ function __initVirtualRuntime(rootScope) {
5001
5076
  const builtinSet = new Set([
5002
5077
  'fs', 'fs/promises', 'path', 'os', 'crypto', 'zlib', 'http', 'https', 'net',
5003
5078
  'dns', 'dns/promises', 'string_decoder', 'child_process', 'process',
5004
- 'assert', 'assert/strict', 'events', 'util', 'url', 'querystring',
5005
- 'stream', 'stream/promises', 'test', 'perf_hooks', 'timers', 'timers/promises', 'buffer',
5079
+ 'assert', 'assert/strict', 'events', 'util', 'util/types', 'url', 'querystring',
5080
+ 'stream', 'stream/promises', 'stream/web', 'stream/consumers', 'test', 'perf_hooks',
5081
+ 'timers', 'timers/promises', 'buffer', 'tty', 'tls', 'dgram', 'readline', 'readline/promises',
5082
+ 'async_hooks', 'worker_threads', 'v8', 'vm', 'module', 'constants', 'domain',
5083
+ 'diagnostics_channel', 'http2', 'cluster', 'repl', 'inspector', 'trace_events',
5084
+ 'wasi', 'console',
5006
5085
  'bun', 'bun:test', 'bun:sqlite'
5007
5086
  ]);
5008
5087
 
@@ -6912,6 +6991,285 @@ function __initVirtualRuntime(rootScope) {
6912
6991
  })();
6913
6992
 
6914
6993
  // Built-in Node module table
6994
+ // ── Additional Node builtin shims ────────────────────────────────────────
6995
+ // Widely-used packages require these at load time (e.g. `debug` requires
6996
+ // `tty`). Without an entry `require('tty')` throws MODULE_NOT_FOUND and the
6997
+ // whole app fails to start. Implementations are deliberately minimal but
6998
+ // shape-compatible; anything that genuinely cannot work in the sandbox
6999
+ // throws an explicit, descriptive error rather than silently misbehaving.
7000
+ const VirtualTty = {
7001
+ isatty() { return false; },
7002
+ ReadStream: class TtyReadStream extends EventEmitter {},
7003
+ WriteStream: class TtyWriteStream extends EventEmitter {
7004
+ constructor(fd) { super(); this.fd = fd; this.columns = 80; this.rows = 24; this.isTTY = false; }
7005
+ getColorDepth() { return 1; }
7006
+ hasColors() { return false; }
7007
+ cursorTo() { return true; }
7008
+ clearLine() { return true; }
7009
+ moveCursor() { return true; }
7010
+ }
7011
+ };
7012
+
7013
+ function makeReadlineInterface() {
7014
+ const iface = new EventEmitter();
7015
+ iface.terminal = false;
7016
+ iface.line = '';
7017
+ iface.cursor = 0;
7018
+ iface.question = (query, cb) => { if (typeof cb === 'function') queueMicrotask(() => cb('')); };
7019
+ iface.prompt = () => {};
7020
+ iface.setPrompt = () => {};
7021
+ iface.getPrompt = () => '';
7022
+ iface.write = () => {};
7023
+ iface.pause = () => iface;
7024
+ iface.resume = () => iface;
7025
+ iface.close = () => { queueMicrotask(() => iface.emit('close')); return iface; };
7026
+ iface[Symbol.asyncIterator] = async function* () {};
7027
+ return iface;
7028
+ }
7029
+ const VirtualReadline = {
7030
+ createInterface: makeReadlineInterface,
7031
+ Interface: class ReadlineInterface extends EventEmitter {},
7032
+ clearLine: () => true,
7033
+ clearScreenDown: () => true,
7034
+ cursorTo: () => true,
7035
+ moveCursor: () => true,
7036
+ emitKeypressEvents: () => {}
7037
+ };
7038
+ const VirtualReadlinePromises = {
7039
+ createInterface: () => {
7040
+ const iface = makeReadlineInterface();
7041
+ iface.question = () => Promise.resolve('');
7042
+ return iface;
7043
+ },
7044
+ Interface: class ReadlinePromisesInterface extends EventEmitter {}
7045
+ };
7046
+
7047
+ const VirtualAsyncHooks = {
7048
+ AsyncLocalStorage: class AsyncLocalStorage {
7049
+ constructor() { this._store = undefined; }
7050
+ getStore() { return this._store; }
7051
+ run(store, fn, ...args) {
7052
+ const prev = this._store;
7053
+ this._store = store;
7054
+ try { return fn(...args); } finally { this._store = prev; }
7055
+ }
7056
+ exit(fn, ...args) {
7057
+ const prev = this._store;
7058
+ this._store = undefined;
7059
+ try { return fn(...args); } finally { this._store = prev; }
7060
+ }
7061
+ enterWith(store) { this._store = store; }
7062
+ disable() { this._store = undefined; }
7063
+ },
7064
+ AsyncResource: class AsyncResource {
7065
+ constructor(type) { this.type = type || 'AsyncResource'; }
7066
+ runInAsyncScope(fn, thisArg, ...args) { return fn.apply(thisArg, args); }
7067
+ emitDestroy() { return this; }
7068
+ asyncId() { return 0; }
7069
+ triggerAsyncId() { return 0; }
7070
+ static bind(fn) { return fn; }
7071
+ },
7072
+ createHook() { return { enable() {}, disable() {} }; },
7073
+ executionAsyncId() { return 0; },
7074
+ triggerAsyncId() { return 0; },
7075
+ executionAsyncResource() { return null; }
7076
+ };
7077
+
7078
+ const VirtualWorkerThreads = {
7079
+ isMainThread: true,
7080
+ threadId: 0,
7081
+ parentPort: null,
7082
+ workerData: null,
7083
+ resourceLimits: {},
7084
+ SHARE_ENV: Symbol('nodejs.worker_threads.SHARE_ENV'),
7085
+ receiveMessageOnPort() { return undefined; },
7086
+ Worker: class Worker extends EventEmitter {
7087
+ constructor(filename) {
7088
+ super();
7089
+ this.threadId = -1;
7090
+ this.filename = filename;
7091
+ queueMicrotask(() => this.emit('error', new Error('worker_threads.Worker is not supported in the virtual runtime.')));
7092
+ }
7093
+ postMessage() {}
7094
+ terminate() { return Promise.resolve(0); }
7095
+ ref() { return this; }
7096
+ unref() { return this; }
7097
+ },
7098
+ MessageChannel: class MessageChannel {},
7099
+ MessagePort: class MessagePort extends EventEmitter {}
7100
+ };
7101
+
7102
+ const VirtualV8 = {
7103
+ serialize(value) { return VirtualBuffer.from(JSON.stringify(value === undefined ? null : value), 'utf8'); },
7104
+ deserialize(buf) { try { return JSON.parse(String(buf)); } catch (_) { return undefined; } },
7105
+ getHeapStatistics() {
7106
+ return {
7107
+ total_heap_size: 0, total_heap_size_executable: 0, total_physical_size: 0,
7108
+ total_available_size: 0, used_heap_size: 0, heap_size_limit: 0,
7109
+ malloced_memory: 0, peak_malloced_memory: 0, does_zap_garbage: 0,
7110
+ number_of_native_contexts: 1, number_of_detached_contexts: 0
7111
+ };
7112
+ },
7113
+ getHeapSpaceStatistics() { return []; },
7114
+ setFlagsFromString() {},
7115
+ cachedDataVersionTag() { return 0; },
7116
+ Serializer: class Serializer {
7117
+ constructor() { this._value = undefined; }
7118
+ writeHeader() {}
7119
+ writeValue(value) { this._value = value; }
7120
+ releaseBuffer() { return VirtualBuffer.from(JSON.stringify(this._value === undefined ? null : this._value), 'utf8'); }
7121
+ },
7122
+ Deserializer: class Deserializer {
7123
+ constructor(buffer) { this._buffer = buffer; }
7124
+ readHeader() { return true; }
7125
+ readValue() { try { return JSON.parse(String(this._buffer)); } catch (_) { return undefined; } }
7126
+ }
7127
+ };
7128
+
7129
+ const VirtualVm = {
7130
+ createContext(sandbox) { return sandbox && typeof sandbox === 'object' ? sandbox : {}; },
7131
+ isContext() { return false; },
7132
+ createScript() { throw new Error('vm code compilation is not supported in the virtual runtime.'); },
7133
+ runInContext() { throw new Error('vm.runInContext is not supported in the virtual runtime.'); },
7134
+ runInNewContext() { throw new Error('vm.runInNewContext is not supported in the virtual runtime.'); },
7135
+ runInThisContext() { throw new Error('vm.runInThisContext is not supported in the virtual runtime.'); },
7136
+ compileFunction() { throw new Error('vm.compileFunction is not supported in the virtual runtime.'); },
7137
+ Script: class Script {
7138
+ runInThisContext() { throw new Error('vm.Script is not supported in the virtual runtime.'); }
7139
+ runInContext() { throw new Error('vm.Script is not supported in the virtual runtime.'); }
7140
+ runInNewContext() { throw new Error('vm.Script is not supported in the virtual runtime.'); }
7141
+ }
7142
+ };
7143
+
7144
+ const VirtualDomain = {
7145
+ create() {
7146
+ const d = new EventEmitter();
7147
+ d.members = [];
7148
+ d.add = () => d;
7149
+ d.remove = () => d;
7150
+ d.bind = (fn) => fn;
7151
+ d.intercept = (fn) => fn;
7152
+ d.run = (fn, ...args) => fn(...args);
7153
+ d.dispose = () => d;
7154
+ return d;
7155
+ },
7156
+ createDomain() { return VirtualDomain.create(); }
7157
+ };
7158
+
7159
+ const VirtualDiagnosticsChannel = {
7160
+ _channels: new Map(),
7161
+ channel(name) {
7162
+ const key = String(name);
7163
+ if (!VirtualDiagnosticsChannel._channels.has(key)) {
7164
+ const ch = new EventEmitter();
7165
+ ch.name = key;
7166
+ ch.hasSubscribers = false;
7167
+ ch.subscribe = () => { ch.hasSubscribers = true; };
7168
+ ch.unsubscribe = () => { ch.hasSubscribers = false; };
7169
+ VirtualDiagnosticsChannel._channels.set(key, ch);
7170
+ }
7171
+ return VirtualDiagnosticsChannel._channels.get(key);
7172
+ },
7173
+ subscribe(name, cb) {
7174
+ const ch = VirtualDiagnosticsChannel.channel(name);
7175
+ ch.subscribe();
7176
+ if (typeof cb === 'function') ch.on('message', cb);
7177
+ },
7178
+ unsubscribe(name) { VirtualDiagnosticsChannel.channel(name).unsubscribe(); },
7179
+ Channel: class Channel extends EventEmitter {}
7180
+ };
7181
+
7182
+ const notSupported = (what) => () => { throw new Error(what + ' is not supported in the virtual runtime.'); };
7183
+ const VirtualTls = {
7184
+ DEFAULT_MIN_VERSION: 'TLSv1.2',
7185
+ DEFAULT_MAX_VERSION: 'TLSv1.3',
7186
+ rootCertificates: [],
7187
+ createSecureContext() { return { context: {} }; },
7188
+ SecureContext: class SecureContext {},
7189
+ TLSSocket: class TLSSocket extends EventEmitter {},
7190
+ Server: class TLSServer extends EventEmitter {},
7191
+ checkServerIdentity() { return undefined; },
7192
+ connect: notSupported('tls.connect'),
7193
+ createServer: notSupported('tls.createServer')
7194
+ };
7195
+ const VirtualDgram = {
7196
+ createSocket(type) {
7197
+ const sock = new EventEmitter();
7198
+ sock.type = type || 'udp4';
7199
+ sock.bind = (...args) => { const cb = args[args.length - 1]; if (typeof cb === 'function') queueMicrotask(cb); return sock; };
7200
+ sock.close = (cb) => { queueMicrotask(() => { sock.emit('close'); if (typeof cb === 'function') cb(); }); return sock; };
7201
+ sock.send = notSupported('dgram.send');
7202
+ sock.address = () => ({ address: '0.0.0.0', family: 'IPv4', port: 0 });
7203
+ sock.setBroadcast = () => sock;
7204
+ sock.setTTL = () => sock;
7205
+ sock.addMembership = () => {};
7206
+ sock.dropMembership = () => {};
7207
+ return sock;
7208
+ },
7209
+ Socket: class Socket extends EventEmitter {}
7210
+ };
7211
+ const VirtualHttp2 = {
7212
+ constants: { NGHTTP2_REFUSED_STREAM: 7, NGHTTP2_CANCEL: 8 },
7213
+ connect: notSupported('http2.connect'),
7214
+ createServer: notSupported('http2.createServer'),
7215
+ createSecureServer: notSupported('http2.createSecureServer')
7216
+ };
7217
+ const VirtualCluster = {
7218
+ isPrimary: true,
7219
+ isMaster: true,
7220
+ isWorker: false,
7221
+ workers: {},
7222
+ fork: notSupported('cluster.fork'),
7223
+ setupPrimary: notSupported('cluster.setupPrimary'),
7224
+ setupMaster: notSupported('cluster.setupMaster'),
7225
+ disconnect: () => {}
7226
+ };
7227
+ const VirtualRepl = { start: notSupported('repl.start') };
7228
+ const VirtualInspector = {
7229
+ open: () => null,
7230
+ close: () => {},
7231
+ url: () => '',
7232
+ Session: class Session { connect() {} disconnect() {} post() {} }
7233
+ };
7234
+ const VirtualTraceEvents = {
7235
+ createTracing: () => ({ enable() {}, disable() {} }),
7236
+ getEnabledCategories: () => ''
7237
+ };
7238
+ const VirtualWasi = {
7239
+ WASI: class WASI { constructor() { throw new Error('wasi is not supported in the virtual runtime.'); } }
7240
+ };
7241
+
7242
+ const VirtualStreamWeb = {
7243
+ ReadableStream: typeof ReadableStream !== 'undefined' ? ReadableStream : undefined,
7244
+ WritableStream: typeof WritableStream !== 'undefined' ? WritableStream : undefined,
7245
+ TransformStream: typeof TransformStream !== 'undefined' ? TransformStream : undefined
7246
+ };
7247
+ async function consumeStream(kind, stream) {
7248
+ const chunks = [];
7249
+ if (stream && typeof stream[Symbol.asyncIterator] === 'function') {
7250
+ for await (const chunk of stream) chunks.push(chunk);
7251
+ } else if (stream && typeof stream.on === 'function') {
7252
+ await new Promise((resolve, reject) => {
7253
+ stream.on('data', (c) => chunks.push(c));
7254
+ stream.on('end', resolve);
7255
+ stream.on('error', reject);
7256
+ });
7257
+ }
7258
+ const bufs = chunks.map((c) => (typeof c === 'string' ? VirtualBuffer.from(c) : VirtualBuffer.from(c)));
7259
+ const buf = VirtualBuffer.concat(bufs);
7260
+ if (kind === 'buffer') return buf;
7261
+ if (kind === 'arrayBuffer') return buf.buffer ? buf.buffer.slice(buf.byteOffset, buf.byteOffset + buf.byteLength) : new ArrayBuffer(0);
7262
+ if (kind === 'text') return buf.toString('utf8');
7263
+ if (kind === 'json') return JSON.parse(buf.toString('utf8'));
7264
+ return buf;
7265
+ }
7266
+ const VirtualStreamConsumers = {
7267
+ text: (s) => consumeStream('text', s),
7268
+ json: (s) => consumeStream('json', s),
7269
+ buffer: (s) => consumeStream('buffer', s),
7270
+ arrayBuffer: (s) => consumeStream('arrayBuffer', s)
7271
+ };
7272
+
6915
7273
  const builtinModules = {
6916
7274
  fs: vfs,
6917
7275
  'node:fs': vfs,
@@ -6972,8 +7330,58 @@ function __initVirtualRuntime(rootScope) {
6972
7330
  bun: BunObj,
6973
7331
  'node:bun': BunObj,
6974
7332
  'bun:test': bunTestModule,
6975
- 'bun:sqlite': { Database: SqliteDatabase }
7333
+ 'bun:sqlite': { Database: SqliteDatabase },
7334
+ tty: VirtualTty,
7335
+ tls: VirtualTls,
7336
+ dgram: VirtualDgram,
7337
+ readline: VirtualReadline,
7338
+ 'readline/promises': VirtualReadlinePromises,
7339
+ async_hooks: VirtualAsyncHooks,
7340
+ worker_threads: VirtualWorkerThreads,
7341
+ v8: VirtualV8,
7342
+ vm: VirtualVm,
7343
+ domain: VirtualDomain,
7344
+ diagnostics_channel: VirtualDiagnosticsChannel,
7345
+ http2: VirtualHttp2,
7346
+ cluster: VirtualCluster,
7347
+ repl: VirtualRepl,
7348
+ inspector: VirtualInspector,
7349
+ trace_events: VirtualTraceEvents,
7350
+ wasi: VirtualWasi,
7351
+ constants: vfs.constants,
7352
+ 'util/types': VirtualUtil.types,
7353
+ 'stream/web': VirtualStreamWeb,
7354
+ 'stream/consumers': VirtualStreamConsumers
7355
+ };
7356
+
7357
+ // Auto-alias every builtin under the `node:` prefix (node:tty, node:readline…)
7358
+ // so both spellings resolve identically without hand-maintaining two lists.
7359
+ for (const __builtinName of Object.keys(builtinModules)) {
7360
+ if (!__builtinName.startsWith('node:') && !__builtinName.startsWith('bun:')) {
7361
+ builtinModules['node:' + __builtinName] = builtinModules[__builtinName];
7362
+ }
7363
+ }
7364
+
7365
+ // `module` must reference the now-complete builtin table, so it is attached
7366
+ // after the object literal above.
7367
+ const VirtualModule = {
7368
+ builtinModules: Object.keys(builtinModules),
7369
+ Module: class Module {},
7370
+ isBuiltin(name) { return Object.prototype.hasOwnProperty.call(builtinModules, String(name)); },
7371
+ createRequire(from) {
7372
+ const base = typeof from === 'string' ? from : '/workspace';
7373
+ const dir = /\.(?:js|mjs|cjs|ts|json)$/.test(base) ? VirtualPath.dirname(base) : base;
7374
+ const req = (id) => {
7375
+ if (Object.prototype.hasOwnProperty.call(builtinModules, id)) return builtinModules[id];
7376
+ return loadModule(resolveModulePath(id, dir), false);
7377
+ };
7378
+ req.resolve = (id) => resolveModulePath(id, dir);
7379
+ req.cache = {};
7380
+ return req;
7381
+ }
6976
7382
  };
7383
+ builtinModules.module = VirtualModule;
7384
+ builtinModules['node:module'] = VirtualModule;
6977
7385
 
6978
7386
  const moduleCache = new Map();
6979
7387
  let mainModule = null;
@@ -7841,26 +8249,58 @@ if (typeof module !== 'undefined' && module.exports) {
7841
8249
  })();
7842
8250
 
7843
8251
  const CodeLabRuntime = _root.CodeLabRuntime;
7844
- const executeInVirtualRuntime = CodeLabRuntime.executeInVirtualRuntime;
7845
- const executeInWorker = CodeLabRuntime.executeInWorker;
7846
- const cancelWorkerExecution = CodeLabRuntime.cancelWorkerExecution;
7847
- const preloadNpmPackages = CodeLabRuntime.preloadNpmPackages;
7848
- const transpileTS = CodeLabRuntime.transpileTS;
8252
+ const VirtualBuffer = CodeLabRuntime.VirtualBuffer;
8253
+ const VirtualCrypto = CodeLabRuntime.VirtualCrypto;
8254
+ const VirtualZlib = CodeLabRuntime.VirtualZlib;
8255
+ const VirtualPath = CodeLabRuntime.VirtualPath;
8256
+ const VirtualOs = CodeLabRuntime.VirtualOs;
8257
+ const VirtualAssert = CodeLabRuntime.VirtualAssert;
8258
+ const EventEmitter = CodeLabRuntime.EventEmitter;
8259
+ const VirtualUtil = CodeLabRuntime.VirtualUtil;
8260
+ const VirtualUrl = CodeLabRuntime.VirtualUrl;
8261
+ const VirtualQuerystring = CodeLabRuntime.VirtualQuerystring;
8262
+ const VirtualStream = CodeLabRuntime.VirtualStream;
8263
+ const VirtualStreamPromises = CodeLabRuntime.VirtualStreamPromises;
8264
+ const VirtualStringDecoder = CodeLabRuntime.VirtualStringDecoder;
8265
+ const VirtualDns = CodeLabRuntime.VirtualDns;
7849
8266
  const createVirtualFs = CodeLabRuntime.createVirtualFs;
7850
8267
  const createVirtualHttp = CodeLabRuntime.createVirtualHttp;
7851
8268
  const createVirtualNet = CodeLabRuntime.createVirtualNet;
8269
+ const transpileTS = CodeLabRuntime.transpileTS;
8270
+ const transpileForBrowser = CodeLabRuntime.transpileForBrowser;
8271
+ const preloadNpmPackages = CodeLabRuntime.preloadNpmPackages;
7852
8272
  const createVirtualPortTable = CodeLabRuntime.createVirtualPortTable;
8273
+ const executeInVirtualRuntime = CodeLabRuntime.executeInVirtualRuntime;
8274
+ const createWorkerRuntimeSource = CodeLabRuntime.createWorkerRuntimeSource;
8275
+ const cancelWorkerExecution = CodeLabRuntime.cancelWorkerExecution;
8276
+ const executeInWorker = CodeLabRuntime.executeInWorker;
7853
8277
 
7854
8278
  export {
7855
8279
  CodeLabRuntime,
7856
- executeInVirtualRuntime,
7857
- executeInWorker,
7858
- cancelWorkerExecution,
7859
- preloadNpmPackages,
7860
- transpileTS,
8280
+ VirtualBuffer,
8281
+ VirtualCrypto,
8282
+ VirtualZlib,
8283
+ VirtualPath,
8284
+ VirtualOs,
8285
+ VirtualAssert,
8286
+ EventEmitter,
8287
+ VirtualUtil,
8288
+ VirtualUrl,
8289
+ VirtualQuerystring,
8290
+ VirtualStream,
8291
+ VirtualStreamPromises,
8292
+ VirtualStringDecoder,
8293
+ VirtualDns,
7861
8294
  createVirtualFs,
7862
8295
  createVirtualHttp,
7863
8296
  createVirtualNet,
7864
- createVirtualPortTable
8297
+ transpileTS,
8298
+ transpileForBrowser,
8299
+ preloadNpmPackages,
8300
+ createVirtualPortTable,
8301
+ executeInVirtualRuntime,
8302
+ createWorkerRuntimeSource,
8303
+ cancelWorkerExecution,
8304
+ executeInWorker
7865
8305
  };
7866
8306
  export default CodeLabRuntime;