@innovatorved/code-lab 0.1.5 → 0.1.7

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