@ecmaos/kernel 0.1.1 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -18432,7 +18432,7 @@ Commands:
18432
18432
  }
18433
18433
  return 0;
18434
18434
  }
18435
- async function test$2(kernel) {
18435
+ async function test$2(kernel2) {
18436
18436
  const sampleRate = 44100;
18437
18437
  const noteLength = 0.25;
18438
18438
  const shortNoteLength = 0.125;
@@ -18506,17 +18506,17 @@ async function test$2(kernel) {
18506
18506
  finalBuffer.set(new Uint8Array(header), 0);
18507
18507
  finalBuffer.set(new Uint8Array(audioData), header.byteLength);
18508
18508
  try {
18509
- kernel.terminal.writeln("Playing test beeps...");
18510
- const fd2 = await kernel.filesystem.fs.open("/dev/audio", "w", 438);
18509
+ kernel2.terminal.writeln("Playing test beeps...");
18510
+ const fd2 = await kernel2.filesystem.fs.open("/dev/audio", "w", 438);
18511
18511
  await fd2.write(finalBuffer);
18512
18512
  await fd2.close();
18513
18513
  } catch (error) {
18514
- kernel.terminal.writeln(`Error playing audio: ${error}`);
18514
+ kernel2.terminal.writeln(`Error playing audio: ${error}`);
18515
18515
  return 1;
18516
18516
  }
18517
18517
  return 0;
18518
18518
  }
18519
- async function getDrivers$c(kernel) {
18519
+ async function getDrivers$c(kernel2) {
18520
18520
  const drivers = [];
18521
18521
  drivers.push({
18522
18522
  name: "audio",
@@ -18525,7 +18525,7 @@ async function getDrivers$c(kernel) {
18525
18525
  minor: 4,
18526
18526
  data: {
18527
18527
  version: pkg$c.version,
18528
- kernel: kernel.id,
18528
+ kernel: kernel2.id,
18529
18529
  context: new AudioContext()
18530
18530
  }
18531
18531
  }),
@@ -18858,7 +18858,7 @@ Commands:
18858
18858
  return 1;
18859
18859
  }
18860
18860
  }
18861
- async function getDrivers$b(kernel) {
18861
+ async function getDrivers$b(kernel2) {
18862
18862
  const drivers = [];
18863
18863
  if ("getBattery" in navigator) {
18864
18864
  const battery = await navigator.getBattery();
@@ -18868,7 +18868,7 @@ async function getDrivers$b(kernel) {
18868
18868
  major: 10,
18869
18869
  minor: 100,
18870
18870
  data: {
18871
- kernelId: kernel.id,
18871
+ kernelId: kernel2.id,
18872
18872
  charging: battery.charging,
18873
18873
  chargingTime: battery.chargingTime,
18874
18874
  dischargingTime: battery.dischargingTime,
@@ -18898,18 +18898,18 @@ const pkg$a = {
18898
18898
  };
18899
18899
  async function cli$a(options) {
18900
18900
  var _a3, _b2, _c, _d, _e, _f, _g;
18901
- const { args, terminal, kernel } = options;
18901
+ const { args, terminal, kernel: kernel2 } = options;
18902
18902
  if (!(navigator == null ? void 0 : navigator.bluetooth)) {
18903
18903
  terminal.writeln("Bluetooth API not available");
18904
18904
  return 1;
18905
18905
  }
18906
18906
  async function ensureBluetoothPermission() {
18907
- if (kernel.storage.local.getItem("permission:bluetooth") === "1")
18907
+ if (kernel2.storage.local.getItem("permission:bluetooth") === "1")
18908
18908
  return true;
18909
- if (kernel.storage.session.getItem("hide:permission:bluetooth") === "1")
18909
+ if (kernel2.storage.session.getItem("hide:permission:bluetooth") === "1")
18910
18910
  return false;
18911
18911
  return new Promise((resolve2) => {
18912
- const win = kernel.windows.create({
18912
+ const win = kernel2.windows.create({
18913
18913
  id: "bluetooth-permission",
18914
18914
  title: "Bluetooth Permission",
18915
18915
  modal: true,
@@ -18924,14 +18924,14 @@ async function cli$a(options) {
18924
18924
  var _a4;
18925
18925
  try {
18926
18926
  await navigator.bluetooth.requestDevice({ acceptAllDevices: true });
18927
- kernel.storage.local.setItem("permission:bluetooth", "1");
18927
+ kernel2.storage.local.setItem("permission:bluetooth", "1");
18928
18928
  win.close();
18929
18929
  resolve2(true);
18930
18930
  } catch (error) {
18931
- (_a4 = kernel.log) == null ? void 0 : _a4.error("Error requesting Bluetooth device", error);
18932
- kernel.storage.session.removeItem("permission:bluetooth");
18931
+ (_a4 = kernel2.log) == null ? void 0 : _a4.error("Error requesting Bluetooth device", error);
18932
+ kernel2.storage.session.removeItem("permission:bluetooth");
18933
18933
  win.close();
18934
- const dialog = kernel.windows.dialog({
18934
+ const dialog = kernel2.windows.dialog({
18935
18935
  title: "⚠️ Error",
18936
18936
  height: 250,
18937
18937
  html: `
@@ -19142,14 +19142,14 @@ Commands:
19142
19142
  return 1;
19143
19143
  }
19144
19144
  }
19145
- async function getDrivers$a(kernel) {
19145
+ async function getDrivers$a(kernel2) {
19146
19146
  const drivers = [{
19147
19147
  name: "bluetooth",
19148
19148
  init: () => ({
19149
19149
  major: 216,
19150
19150
  minor: 0,
19151
19151
  data: {
19152
- kernelId: kernel.id,
19152
+ kernelId: kernel2.id,
19153
19153
  available: !!(navigator == null ? void 0 : navigator.bluetooth)
19154
19154
  }
19155
19155
  }),
@@ -19437,13 +19437,13 @@ Commands:
19437
19437
  return 1;
19438
19438
  }
19439
19439
  }
19440
- async function getDrivers$9(kernel) {
19440
+ async function getDrivers$9(kernel2) {
19441
19441
  const drivers = [{
19442
19442
  name: "gamepad",
19443
19443
  init: () => ({
19444
19444
  major: 13,
19445
19445
  minor: 1,
19446
- data: { kernelId: kernel.id, version: pkg$9.version }
19446
+ data: { kernelId: kernel2.id, version: pkg$9.version }
19447
19447
  }),
19448
19448
  read: () => 0,
19449
19449
  write: () => 0
@@ -19719,7 +19719,7 @@ Commands:
19719
19719
  return 1;
19720
19720
  }
19721
19721
  }
19722
- async function getDrivers$8(kernel) {
19722
+ async function getDrivers$8(kernel2) {
19723
19723
  const drivers = [];
19724
19724
  if ("geolocation" in navigator) {
19725
19725
  let lastPosition = {
@@ -19766,7 +19766,7 @@ async function getDrivers$8(kernel) {
19766
19766
  major: 10,
19767
19767
  minor: 101,
19768
19768
  data: {
19769
- kernelId: kernel.id,
19769
+ kernelId: kernel2.id,
19770
19770
  version: pkg$8.version
19771
19771
  }
19772
19772
  }),
@@ -19824,7 +19824,7 @@ Launch chrome using: google-chrome --enable-unsafe-webgpu --enable-features=Vulk
19824
19824
  }
19825
19825
  return 0;
19826
19826
  }
19827
- async function getDrivers$7(kernel) {
19827
+ async function getDrivers$7(kernel2) {
19828
19828
  const drivers = [];
19829
19829
  if ("gpu" in navigator) {
19830
19830
  const adapter = await navigator.gpu.requestAdapter();
@@ -19840,7 +19840,7 @@ async function getDrivers$7(kernel) {
19840
19840
  data: {
19841
19841
  adapter,
19842
19842
  device,
19843
- kernelId: kernel.id,
19843
+ kernelId: kernel2.id,
19844
19844
  features: Array.from(adapter.features),
19845
19845
  limits: Object.fromEntries(
19846
19846
  Object.entries(adapter.limits).map(([k, v]) => [k, String(v)])
@@ -19855,7 +19855,7 @@ async function getDrivers$7(kernel) {
19855
19855
  }
19856
19856
  return drivers;
19857
19857
  }
19858
- async function test$1(kernel) {
19858
+ async function test$1(kernel2) {
19859
19859
  var _a3;
19860
19860
  if (!("gpu" in navigator)) throw new Error("WebGPU not available");
19861
19861
  const adapter = await navigator.gpu.requestAdapter();
@@ -19926,7 +19926,7 @@ async function test$1(kernel) {
19926
19926
  pass.draw(3, 1, 0, 0);
19927
19927
  pass.end();
19928
19928
  device.queue.submit([commandEncoder.finish()]);
19929
- if ((_a3 = kernel.terminal) == null ? void 0 : _a3.element) kernel.terminal.element.style.display = "none";
19929
+ if ((_a3 = kernel2.terminal) == null ? void 0 : _a3.element) kernel2.terminal.element.style.display = "none";
19930
19930
  canvas.style.position = "absolute";
19931
19931
  canvas.style.top = "0";
19932
19932
  canvas.style.left = "0";
@@ -19934,9 +19934,9 @@ async function test$1(kernel) {
19934
19934
  document.body.appendChild(canvas);
19935
19935
  setTimeout(() => {
19936
19936
  var _a4;
19937
- if ((_a4 = kernel.terminal) == null ? void 0 : _a4.element) kernel.terminal.element.style.display = "";
19937
+ if ((_a4 = kernel2.terminal) == null ? void 0 : _a4.element) kernel2.terminal.element.style.display = "";
19938
19938
  canvas.remove();
19939
- kernel.terminal.focus();
19939
+ kernel2.terminal.focus();
19940
19940
  }, 2e3);
19941
19941
  }
19942
19942
  const GPUDevice = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
@@ -20257,7 +20257,7 @@ Commands:
20257
20257
  return 1;
20258
20258
  }
20259
20259
  }
20260
- async function getDrivers$6(kernel) {
20260
+ async function getDrivers$6(kernel2) {
20261
20261
  const deviceMap = /* @__PURE__ */ new Map();
20262
20262
  const drivers = [{
20263
20263
  name: "hid",
@@ -20265,7 +20265,7 @@ async function getDrivers$6(kernel) {
20265
20265
  major: 13,
20266
20266
  minor: 64,
20267
20267
  data: {
20268
- kernelId: kernel.id,
20268
+ kernelId: kernel2.id,
20269
20269
  version: pkg$6.version
20270
20270
  }
20271
20271
  }),
@@ -20296,7 +20296,7 @@ async function getDrivers$6(kernel) {
20296
20296
  major: 13,
20297
20297
  minor: 64 + drivers.length,
20298
20298
  data: {
20299
- kernelId: kernel.id,
20299
+ kernelId: kernel2.id,
20300
20300
  version: pkg$6.version
20301
20301
  }
20302
20302
  }),
@@ -20434,13 +20434,13 @@ Commands:
20434
20434
  return 1;
20435
20435
  }
20436
20436
  }
20437
- async function getDrivers$5(kernel) {
20437
+ async function getDrivers$5(kernel2) {
20438
20438
  const drivers = [{
20439
20439
  name: "midi",
20440
20440
  init: () => ({
20441
20441
  major: 35,
20442
20442
  minor: 0,
20443
- data: { kernelId: kernel.id }
20443
+ data: { kernelId: kernel2.id }
20444
20444
  }),
20445
20445
  read: () => 0,
20446
20446
  write: () => 0
@@ -20502,22 +20502,22 @@ async function getDrivers$4() {
20502
20502
  }
20503
20503
  return drivers;
20504
20504
  }
20505
- async function listDisplays(kernel, presentationUrl) {
20505
+ async function listDisplays(kernel2, presentationUrl) {
20506
20506
  if (!("PresentationRequest" in globalThis)) throw new Error("PresentationRequest API not supported");
20507
20507
  try {
20508
20508
  const url = new URL(presentationUrl);
20509
20509
  const request = new globalThis.PresentationRequest([url.toString()]);
20510
20510
  const availability = await request.getAvailability();
20511
- kernel.terminal.writeln(`Available displays: ${availability ? "Yes" : "No"}`);
20511
+ kernel2.terminal.writeln(`Available displays: ${availability ? "Yes" : "No"}`);
20512
20512
  if (availability) {
20513
20513
  const connectionState = activeConnection ? "Connected" : "Not connected";
20514
- kernel.terminal.writeln(`Connection state: ${connectionState}`);
20514
+ kernel2.terminal.writeln(`Connection state: ${connectionState}`);
20515
20515
  }
20516
20516
  } catch (error) {
20517
- kernel.terminal.writeln(`Error checking displays: ${error instanceof Error ? error.message : "Unknown error"}`);
20517
+ kernel2.terminal.writeln(`Error checking displays: ${error instanceof Error ? error.message : "Unknown error"}`);
20518
20518
  }
20519
20519
  }
20520
- async function startPresentation(kernel, presentationUrl) {
20520
+ async function startPresentation(kernel2, presentationUrl) {
20521
20521
  if (!("PresentationRequest" in globalThis)) throw new Error("PresentationRequest API not supported");
20522
20522
  try {
20523
20523
  if (activeConnection) {
@@ -20531,19 +20531,19 @@ async function startPresentation(kernel, presentationUrl) {
20531
20531
  if (!available) throw new Error("No presentation displays available");
20532
20532
  const connection = await request.start();
20533
20533
  activeConnection = connection;
20534
- kernel.terminal.writeln(`Presentation started: ${url}`);
20534
+ kernel2.terminal.writeln(`Presentation started: ${url}`);
20535
20535
  connection.addEventListener("close", () => {
20536
20536
  activeConnection = null;
20537
- kernel.terminal.writeln("Presentation closed");
20537
+ kernel2.terminal.writeln("Presentation closed");
20538
20538
  });
20539
20539
  connection.addEventListener("terminate", () => {
20540
20540
  activeConnection = null;
20541
- kernel.terminal.writeln("Presentation terminated");
20541
+ kernel2.terminal.writeln("Presentation terminated");
20542
20542
  });
20543
20543
  } catch (error) {
20544
20544
  activeRequest = null;
20545
20545
  activeConnection = null;
20546
- kernel.terminal.writeln(`Error starting presentation: ${error instanceof Error ? error.message : "Unknown error"}`);
20546
+ kernel2.terminal.writeln(`Error starting presentation: ${error instanceof Error ? error.message : "Unknown error"}`);
20547
20547
  }
20548
20548
  }
20549
20549
  const PresentationDevice = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
@@ -20832,10 +20832,10 @@ Commands:
20832
20832
  return 1;
20833
20833
  }
20834
20834
  }
20835
- async function getDrivers$3(kernel) {
20835
+ async function getDrivers$3(kernel2) {
20836
20836
  const drivers = [{
20837
20837
  name: "sensors",
20838
- init: () => ({ major: 0, minor: 0, data: { kernelId: kernel.id, version: pkg$3.version } }),
20838
+ init: () => ({ major: 0, minor: 0, data: { kernelId: kernel2.id, version: pkg$3.version } }),
20839
20839
  read: () => 0,
20840
20840
  write: () => 0
20841
20841
  }];
@@ -21123,10 +21123,10 @@ async function createDriver(name) {
21123
21123
  }
21124
21124
  };
21125
21125
  }
21126
- async function getDrivers$2(kernel) {
21126
+ async function getDrivers$2(kernel2) {
21127
21127
  if (typeof navigator === "undefined" || !navigator.serial) return [];
21128
21128
  navigator.serial.addEventListener("connect", async (event) => {
21129
- kernel.events.emit("device:connect", event.target);
21129
+ kernel2.events.emit("device:connect", event.target);
21130
21130
  if (event.target && !availablePorts.has(event.target)) {
21131
21131
  availablePorts.add(event.target);
21132
21132
  }
@@ -21243,14 +21243,14 @@ Commands:
21243
21243
  return 1;
21244
21244
  }
21245
21245
  }
21246
- async function getDrivers$1(kernel) {
21246
+ async function getDrivers$1(kernel2) {
21247
21247
  const drivers = [
21248
21248
  {
21249
21249
  name: "usb",
21250
21250
  init: () => ({
21251
21251
  major: 8,
21252
21252
  minor: 0,
21253
- data: { kernelId: kernel.id }
21253
+ data: { kernelId: kernel2.id }
21254
21254
  }),
21255
21255
  read: () => 0,
21256
21256
  write: () => 0
@@ -21264,7 +21264,7 @@ async function getDrivers$1(kernel) {
21264
21264
  init: () => ({
21265
21265
  major: 8,
21266
21266
  minor: device.vendorId + device.productId,
21267
- data: { device, kernelId: kernel.id }
21267
+ data: { device, kernelId: kernel2.id }
21268
21268
  }),
21269
21269
  read: () => 0,
21270
21270
  write: () => 0
@@ -21316,7 +21316,7 @@ Commands:
21316
21316
  }
21317
21317
  return 0;
21318
21318
  }
21319
- async function getDrivers(kernel) {
21319
+ async function getDrivers(kernel2) {
21320
21320
  var _a3;
21321
21321
  const drivers = [];
21322
21322
  try {
@@ -21343,11 +21343,11 @@ async function getDrivers(kernel) {
21343
21343
  });
21344
21344
  }
21345
21345
  } catch (error) {
21346
- (_a3 = kernel.log) == null ? void 0 : _a3.error(`Failed to initialize WebGL device: ${error}`);
21346
+ (_a3 = kernel2.log) == null ? void 0 : _a3.error(`Failed to initialize WebGL device: ${error}`);
21347
21347
  }
21348
21348
  return drivers;
21349
21349
  }
21350
- async function showInfo(kernel) {
21350
+ async function showInfo(kernel2) {
21351
21351
  var _a3, _b2, _c, _d, _e, _f;
21352
21352
  const canvas = document.createElement("canvas");
21353
21353
  const context = canvas.getContext("webgl") || canvas.getContext("experimental-webgl");
@@ -21361,25 +21361,25 @@ async function showInfo(kernel) {
21361
21361
  shadingLanguage: context.getParameter(context.SHADING_LANGUAGE_VERSION),
21362
21362
  extensions: context.getSupportedExtensions() || []
21363
21363
  };
21364
- (_a3 = kernel.terminal) == null ? void 0 : _a3.writeln("\nWebGL Information:");
21365
- (_b2 = kernel.terminal) == null ? void 0 : _b2.writeln(`Vendor: ${info.vendor}`);
21366
- (_c = kernel.terminal) == null ? void 0 : _c.writeln(`Renderer: ${info.renderer}`);
21367
- (_d = kernel.terminal) == null ? void 0 : _d.writeln(`Version: ${info.version}`);
21368
- (_e = kernel.terminal) == null ? void 0 : _e.writeln(`Shading Language: ${info.shadingLanguage}`);
21369
- (_f = kernel.terminal) == null ? void 0 : _f.writeln("\nSupported Extensions:");
21364
+ (_a3 = kernel2.terminal) == null ? void 0 : _a3.writeln("\nWebGL Information:");
21365
+ (_b2 = kernel2.terminal) == null ? void 0 : _b2.writeln(`Vendor: ${info.vendor}`);
21366
+ (_c = kernel2.terminal) == null ? void 0 : _c.writeln(`Renderer: ${info.renderer}`);
21367
+ (_d = kernel2.terminal) == null ? void 0 : _d.writeln(`Version: ${info.version}`);
21368
+ (_e = kernel2.terminal) == null ? void 0 : _e.writeln(`Shading Language: ${info.shadingLanguage}`);
21369
+ (_f = kernel2.terminal) == null ? void 0 : _f.writeln("\nSupported Extensions:");
21370
21370
  info.extensions.forEach((ext) => {
21371
21371
  var _a4;
21372
- return (_a4 = kernel.terminal) == null ? void 0 : _a4.writeln(` ${ext}`);
21372
+ return (_a4 = kernel2.terminal) == null ? void 0 : _a4.writeln(` ${ext}`);
21373
21373
  });
21374
21374
  }
21375
- async function test(kernel) {
21375
+ async function test(kernel2) {
21376
21376
  var _a3;
21377
21377
  const canvas = document.createElement("canvas");
21378
21378
  const context = canvas.getContext("webgl") || canvas.getContext("experimental-webgl");
21379
21379
  if (!context) {
21380
21380
  throw new Error("WebGL not available");
21381
21381
  }
21382
- if ((_a3 = kernel.terminal) == null ? void 0 : _a3.element) kernel.terminal.element.style.display = "none";
21382
+ if ((_a3 = kernel2.terminal) == null ? void 0 : _a3.element) kernel2.terminal.element.style.display = "none";
21383
21383
  canvas.width = window.innerWidth;
21384
21384
  canvas.height = window.innerHeight;
21385
21385
  canvas.style.position = "absolute";
@@ -21390,9 +21390,9 @@ async function test(kernel) {
21390
21390
  await runWebGLTest(context);
21391
21391
  setTimeout(() => {
21392
21392
  var _a4, _b2;
21393
- if ((_a4 = kernel.terminal) == null ? void 0 : _a4.element) kernel.terminal.element.style.display = "";
21393
+ if ((_a4 = kernel2.terminal) == null ? void 0 : _a4.element) kernel2.terminal.element.style.display = "";
21394
21394
  canvas.remove();
21395
- (_b2 = kernel.terminal) == null ? void 0 : _b2.focus();
21395
+ (_b2 = kernel2.terminal) == null ? void 0 : _b2.focus();
21396
21396
  }, 3e3);
21397
21397
  }
21398
21398
  async function runWebGLTest(context) {
@@ -21493,7 +21493,7 @@ class Dom {
21493
21493
  async topbar(show) {
21494
21494
  if (!this._topbar) return;
21495
21495
  const { default: topbar } = await __vitePreload(async () => {
21496
- const { default: topbar2 } = await import("./topbar.min-B_SrfKMk.js").then((n) => n.t);
21496
+ const { default: topbar2 } = await import("./topbar.min-DotodHSt.js").then((n) => n.t);
21497
21497
  return { default: topbar2 };
21498
21498
  }, true ? [] : void 0);
21499
21499
  this._topbarShow = show ?? !this._topbarShow;
@@ -46169,7 +46169,7 @@ async function createSimpleWebSocket(url) {
46169
46169
  let WebSocket2;
46170
46170
  try {
46171
46171
  WebSocket2 = (await __vitePreload(async () => {
46172
- const { default: __vite_default__ } = await import("./browser-C139fYki.js").then((n) => n.b);
46172
+ const { default: __vite_default__ } = await import("./browser-C1zKI-gX.js").then((n) => n.b);
46173
46173
  return { default: __vite_default__ };
46174
46174
  }, true ? [] : void 0)).default;
46175
46175
  } catch (error) {
@@ -62695,7 +62695,7 @@ var TerminalEvents;
62695
62695
  TerminalEvents2["WRITELN"] = "terminal:writeln";
62696
62696
  })(TerminalEvents || (TerminalEvents = {}));
62697
62697
  class TerminalCommand {
62698
- constructor({ command, description, kernel, options, run, shell, terminal, stdin, stdout, stderr }) {
62698
+ constructor({ command, description, kernel: kernel2, options, run, shell, terminal, stdin, stdout, stderr }) {
62699
62699
  __publicField(this, "command", "");
62700
62700
  __publicField(this, "description", "");
62701
62701
  __publicField(this, "kernel");
@@ -62708,7 +62708,7 @@ class TerminalCommand {
62708
62708
  __publicField(this, "stderr");
62709
62709
  this.command = command;
62710
62710
  this.description = description;
62711
- this.kernel = kernel;
62711
+ this.kernel = kernel2;
62712
62712
  this.options = options;
62713
62713
  this.shell = shell;
62714
62714
  this.terminal = terminal;
@@ -62748,13 +62748,13 @@ class TerminalCommand {
62748
62748
  }).join(" ")}`;
62749
62749
  }
62750
62750
  }
62751
- const TerminalCommands = (kernel, shell, terminal) => {
62752
- const HelpOption = { name: "help", type: Boolean, description: kernel.i18n.t("Display help") };
62751
+ const TerminalCommands = (kernel2, shell, terminal) => {
62752
+ const HelpOption = { name: "help", type: Boolean, description: kernel2.i18n.t("Display help") };
62753
62753
  return {
62754
62754
  ai: new TerminalCommand({
62755
62755
  command: "ai",
62756
62756
  description: "Access an AI",
62757
- kernel,
62757
+ kernel: kernel2,
62758
62758
  shell,
62759
62759
  terminal,
62760
62760
  options: [
@@ -62762,13 +62762,13 @@ const TerminalCommands = (kernel, shell, terminal) => {
62762
62762
  { name: "prompt", type: String, defaultOption: true, description: "The prompt to send to the AI" }
62763
62763
  ],
62764
62764
  run: async (argv, process2) => {
62765
- return await ai({ kernel, shell, terminal, process: process2, args: [argv.prompt] });
62765
+ return await ai({ kernel: kernel2, shell, terminal, process: process2, args: [argv.prompt] });
62766
62766
  }
62767
62767
  }),
62768
62768
  cat: new TerminalCommand({
62769
62769
  command: "cat",
62770
62770
  description: "Concatenate files and print on the standard output",
62771
- kernel,
62771
+ kernel: kernel2,
62772
62772
  shell,
62773
62773
  terminal,
62774
62774
  options: [
@@ -62777,13 +62777,13 @@ const TerminalCommands = (kernel, shell, terminal) => {
62777
62777
  { name: "bytes", type: Number, description: "The number of bytes to read from the file" }
62778
62778
  ],
62779
62779
  run: async (argv, process2) => {
62780
- return await cat({ kernel, shell, terminal, process: process2, args: [argv.path, argv.bytes] });
62780
+ return await cat({ kernel: kernel2, shell, terminal, process: process2, args: [argv.path, argv.bytes] });
62781
62781
  }
62782
62782
  }),
62783
62783
  cd: new TerminalCommand({
62784
62784
  command: "cd",
62785
62785
  description: "Change the shell working directory",
62786
- kernel,
62786
+ kernel: kernel2,
62787
62787
  shell,
62788
62788
  terminal,
62789
62789
  options: [
@@ -62791,13 +62791,13 @@ const TerminalCommands = (kernel, shell, terminal) => {
62791
62791
  { name: "path", type: String, typeLabel: "{underline path}", defaultOption: true, description: "The path to the directory to change to" }
62792
62792
  ],
62793
62793
  run: async (argv) => {
62794
- return await cd({ kernel, shell, terminal, args: [argv.path || shell.cwd] });
62794
+ return await cd({ kernel: kernel2, shell, terminal, args: [argv.path || shell.cwd] });
62795
62795
  }
62796
62796
  }),
62797
62797
  chmod: new TerminalCommand({
62798
62798
  command: "chmod",
62799
62799
  description: "Change file mode bits",
62800
- kernel,
62800
+ kernel: kernel2,
62801
62801
  shell,
62802
62802
  terminal,
62803
62803
  options: [
@@ -62805,13 +62805,13 @@ const TerminalCommands = (kernel, shell, terminal) => {
62805
62805
  { name: "args", type: String, multiple: true, defaultOption: true, description: "The mode and path to the file or directory" }
62806
62806
  ],
62807
62807
  run: async (argv) => {
62808
- return await chmod({ kernel, shell, terminal, args: argv.args });
62808
+ return await chmod({ kernel: kernel2, shell, terminal, args: argv.args });
62809
62809
  }
62810
62810
  }),
62811
62811
  chown: new TerminalCommand({
62812
62812
  command: "chown",
62813
62813
  description: "Change file ownership",
62814
- kernel,
62814
+ kernel: kernel2,
62815
62815
  shell,
62816
62816
  terminal,
62817
62817
  options: [
@@ -62820,24 +62820,24 @@ const TerminalCommands = (kernel, shell, terminal) => {
62820
62820
  { name: "group", type: String, description: "The group to set for the file or directory" }
62821
62821
  ],
62822
62822
  run: async (argv) => {
62823
- return await chown({ kernel, shell, terminal, args: [argv.args[0], argv.args[1], argv.group] });
62823
+ return await chown({ kernel: kernel2, shell, terminal, args: [argv.args[0], argv.args[1], argv.group] });
62824
62824
  }
62825
62825
  }),
62826
62826
  clear: new TerminalCommand({
62827
62827
  command: "clear",
62828
62828
  description: "Clear the terminal screen",
62829
- kernel,
62829
+ kernel: kernel2,
62830
62830
  shell,
62831
62831
  terminal,
62832
62832
  options: [],
62833
62833
  run: async () => {
62834
- return await clear({ kernel, shell, terminal, args: [] });
62834
+ return await clear({ kernel: kernel2, shell, terminal, args: [] });
62835
62835
  }
62836
62836
  }),
62837
62837
  cp: new TerminalCommand({
62838
62838
  command: "cp",
62839
62839
  description: "Copy files",
62840
- kernel,
62840
+ kernel: kernel2,
62841
62841
  shell,
62842
62842
  terminal,
62843
62843
  options: [
@@ -62845,13 +62845,13 @@ const TerminalCommands = (kernel, shell, terminal) => {
62845
62845
  { name: "args", type: String, multiple: true, defaultOption: true, description: "The source and destination paths" }
62846
62846
  ],
62847
62847
  run: async (argv) => {
62848
- return await cp({ kernel, shell, terminal, args: argv.args });
62848
+ return await cp({ kernel: kernel2, shell, terminal, args: argv.args });
62849
62849
  }
62850
62850
  }),
62851
62851
  download: new TerminalCommand({
62852
62852
  command: "download",
62853
62853
  description: "Download a file from the filesystem",
62854
- kernel,
62854
+ kernel: kernel2,
62855
62855
  shell,
62856
62856
  terminal,
62857
62857
  options: [
@@ -62859,13 +62859,13 @@ const TerminalCommands = (kernel, shell, terminal) => {
62859
62859
  { name: "path", type: String, typeLabel: "{underline path}", defaultOption: true, multiple: true, description: "The path(s) to the file(s) to download" }
62860
62860
  ],
62861
62861
  run: async (argv) => {
62862
- return await download({ kernel, shell, terminal, args: argv.path });
62862
+ return await download({ kernel: kernel2, shell, terminal, args: argv.path });
62863
62863
  }
62864
62864
  }),
62865
62865
  echo: new TerminalCommand({
62866
62866
  command: "echo",
62867
62867
  description: "Print arguments to the standard output",
62868
- kernel,
62868
+ kernel: kernel2,
62869
62869
  shell,
62870
62870
  terminal,
62871
62871
  options: [
@@ -62873,13 +62873,13 @@ const TerminalCommands = (kernel, shell, terminal) => {
62873
62873
  { name: "text", type: String, typeLabel: "{underline text}", defaultOption: true, multiple: true, description: "The text to print" }
62874
62874
  ],
62875
62875
  run: async (argv, process2) => {
62876
- return await echo({ kernel, shell, terminal, process: process2, args: argv.text });
62876
+ return await echo({ kernel: kernel2, shell, terminal, process: process2, args: argv.text });
62877
62877
  }
62878
62878
  }),
62879
62879
  edit: new TerminalCommand({
62880
62880
  command: "edit",
62881
62881
  description: "Edit a file",
62882
- kernel,
62882
+ kernel: kernel2,
62883
62883
  shell,
62884
62884
  terminal,
62885
62885
  options: [
@@ -62887,13 +62887,13 @@ const TerminalCommands = (kernel, shell, terminal) => {
62887
62887
  { name: "path", type: String, typeLabel: "{underline path}", defaultOption: true, description: "The path to the file to edit" }
62888
62888
  ],
62889
62889
  run: async (argv) => {
62890
- return await edit({ kernel, shell, terminal, args: [argv.path] });
62890
+ return await edit({ kernel: kernel2, shell, terminal, args: [argv.path] });
62891
62891
  }
62892
62892
  }),
62893
62893
  env: new TerminalCommand({
62894
62894
  command: "env",
62895
62895
  description: "Print or set an environment variable",
62896
- kernel,
62896
+ kernel: kernel2,
62897
62897
  shell,
62898
62898
  terminal,
62899
62899
  options: [
@@ -62902,13 +62902,13 @@ const TerminalCommands = (kernel, shell, terminal) => {
62902
62902
  { name: "set", type: String, description: "Set the environment variable" }
62903
62903
  ],
62904
62904
  run: async (argv) => {
62905
- return await env({ kernel, shell, terminal, args: [argv.variables, argv.set] });
62905
+ return await env({ kernel: kernel2, shell, terminal, args: [argv.variables, argv.set] });
62906
62906
  }
62907
62907
  }),
62908
62908
  fetch: new TerminalCommand({
62909
62909
  command: "fetch",
62910
62910
  description: "Fetch a resource from the network",
62911
- kernel,
62911
+ kernel: kernel2,
62912
62912
  shell,
62913
62913
  terminal,
62914
62914
  options: [
@@ -62919,13 +62919,13 @@ const TerminalCommands = (kernel, shell, terminal) => {
62919
62919
  { name: "body", type: String, description: "The body to send with the request" }
62920
62920
  ],
62921
62921
  run: async (argv, process2) => {
62922
- return await fetch$1({ kernel, shell, terminal, process: process2, args: [argv.url, argv.filename, argv.method, argv.body] });
62922
+ return await fetch$1({ kernel: kernel2, shell, terminal, process: process2, args: [argv.url, argv.filename, argv.method, argv.body] });
62923
62923
  }
62924
62924
  }),
62925
62925
  install: new TerminalCommand({
62926
62926
  command: "install",
62927
62927
  description: "Install a package",
62928
- kernel,
62928
+ kernel: kernel2,
62929
62929
  shell,
62930
62930
  terminal,
62931
62931
  options: [
@@ -62934,13 +62934,13 @@ const TerminalCommands = (kernel, shell, terminal) => {
62934
62934
  { name: "repo", type: String, description: "The repository to use", defaultValue: "https://unpkg.com" }
62935
62935
  ],
62936
62936
  run: async (argv) => {
62937
- return await install({ kernel, shell, terminal, args: [argv.url] });
62937
+ return await install({ kernel: kernel2, shell, terminal, args: [argv.url] });
62938
62938
  }
62939
62939
  }),
62940
62940
  ls: new TerminalCommand({
62941
62941
  command: "ls",
62942
62942
  description: "List directory contents",
62943
- kernel,
62943
+ kernel: kernel2,
62944
62944
  shell,
62945
62945
  terminal,
62946
62946
  options: [
@@ -62948,13 +62948,13 @@ const TerminalCommands = (kernel, shell, terminal) => {
62948
62948
  { name: "path", type: String, typeLabel: "{underline path}", defaultOption: true, description: "The path to the directory to list" }
62949
62949
  ],
62950
62950
  run: async (argv) => {
62951
- return await ls({ kernel, shell, terminal, args: [argv.path || shell.cwd] });
62951
+ return await ls({ kernel: kernel2, shell, terminal, args: [argv.path || shell.cwd] });
62952
62952
  }
62953
62953
  }),
62954
62954
  mkdir: new TerminalCommand({
62955
62955
  command: "mkdir",
62956
62956
  description: "Create a directory",
62957
- kernel,
62957
+ kernel: kernel2,
62958
62958
  shell,
62959
62959
  terminal,
62960
62960
  options: [
@@ -62962,13 +62962,13 @@ const TerminalCommands = (kernel, shell, terminal) => {
62962
62962
  { name: "path", type: String, typeLabel: "{underline path}", defaultOption: true, description: "The path to the directory to create" }
62963
62963
  ],
62964
62964
  run: async (argv) => {
62965
- return await mkdir({ kernel, shell, terminal, args: [argv.path] });
62965
+ return await mkdir({ kernel: kernel2, shell, terminal, args: [argv.path] });
62966
62966
  }
62967
62967
  }),
62968
62968
  mount: new TerminalCommand({
62969
62969
  command: "mount",
62970
62970
  description: "Mount a filesystem",
62971
- kernel,
62971
+ kernel: kernel2,
62972
62972
  shell,
62973
62973
  terminal,
62974
62974
  options: [
@@ -62978,13 +62978,13 @@ const TerminalCommands = (kernel, shell, terminal) => {
62978
62978
  { name: "options", type: String, description: "The options to pass to the filesystem type", alias: "o" }
62979
62979
  ],
62980
62980
  run: async (argv) => {
62981
- return await mount({ kernel, shell, terminal, args: [argv.args, argv.type, argv.options] });
62981
+ return await mount({ kernel: kernel2, shell, terminal, args: [argv.args, argv.type, argv.options] });
62982
62982
  }
62983
62983
  }),
62984
62984
  mv: new TerminalCommand({
62985
62985
  command: "mv",
62986
62986
  description: "Move or rename files",
62987
- kernel,
62987
+ kernel: kernel2,
62988
62988
  shell,
62989
62989
  terminal,
62990
62990
  options: [
@@ -62992,24 +62992,24 @@ const TerminalCommands = (kernel, shell, terminal) => {
62992
62992
  { name: "args", type: String, multiple: true, defaultOption: true, description: "The source and destination paths" }
62993
62993
  ],
62994
62994
  run: async (argv) => {
62995
- return await mv({ kernel, shell, terminal, args: argv.args });
62995
+ return await mv({ kernel: kernel2, shell, terminal, args: argv.args });
62996
62996
  }
62997
62997
  }),
62998
62998
  observe: new TerminalCommand({
62999
62999
  command: "observe",
63000
63000
  description: "Observe piped streams",
63001
- kernel,
63001
+ kernel: kernel2,
63002
63002
  shell,
63003
63003
  terminal,
63004
63004
  options: [HelpOption],
63005
63005
  run: async (_, process2) => {
63006
- return await observe({ kernel, shell, terminal, process: process2, args: [] });
63006
+ return await observe({ kernel: kernel2, shell, terminal, process: process2, args: [] });
63007
63007
  }
63008
63008
  }),
63009
63009
  open: new TerminalCommand({
63010
63010
  command: "open",
63011
63011
  description: "Open a file or URL",
63012
- kernel,
63012
+ kernel: kernel2,
63013
63013
  shell,
63014
63014
  terminal,
63015
63015
  options: [
@@ -63017,13 +63017,13 @@ const TerminalCommands = (kernel, shell, terminal) => {
63017
63017
  { name: "path", type: String, typeLabel: "{underline path}", defaultOption: true, description: "The path to the file or URL to open" }
63018
63018
  ],
63019
63019
  run: async (argv) => {
63020
- return await open({ kernel, shell, terminal, args: [argv.path] });
63020
+ return await open({ kernel: kernel2, shell, terminal, args: [argv.path] });
63021
63021
  }
63022
63022
  }),
63023
63023
  passwd: new TerminalCommand({
63024
63024
  command: "passwd",
63025
63025
  description: "Change user password",
63026
- kernel,
63026
+ kernel: kernel2,
63027
63027
  shell,
63028
63028
  terminal,
63029
63029
  options: [
@@ -63031,13 +63031,13 @@ const TerminalCommands = (kernel, shell, terminal) => {
63031
63031
  { name: "password", type: String, multiple: true, defaultOption: true, description: "Old and new passwords (optional - will prompt if not provided)" }
63032
63032
  ],
63033
63033
  run: async (argv) => {
63034
- return await passwd({ kernel, shell, terminal, args: argv.password });
63034
+ return await passwd({ kernel: kernel2, shell, terminal, args: argv.password });
63035
63035
  }
63036
63036
  }),
63037
63037
  play: new TerminalCommand({
63038
63038
  command: "play",
63039
63039
  description: "Play a media file",
63040
- kernel,
63040
+ kernel: kernel2,
63041
63041
  shell,
63042
63042
  terminal,
63043
63043
  options: [
@@ -63045,46 +63045,46 @@ const TerminalCommands = (kernel, shell, terminal) => {
63045
63045
  { name: "file", type: String, typeLabel: "{underline file}", defaultOption: true, description: "The path to the media file to play" }
63046
63046
  ],
63047
63047
  run: async (argv) => {
63048
- return await play({ kernel, shell, terminal, args: [argv.file] });
63048
+ return await play({ kernel: kernel2, shell, terminal, args: [argv.file] });
63049
63049
  }
63050
63050
  }),
63051
63051
  ps: new TerminalCommand({
63052
63052
  command: "ps",
63053
63053
  description: "List all running processes",
63054
- kernel,
63054
+ kernel: kernel2,
63055
63055
  shell,
63056
63056
  terminal,
63057
63057
  options: [],
63058
63058
  run: async () => {
63059
- return await ps({ kernel, shell, terminal, args: [] });
63059
+ return await ps({ kernel: kernel2, shell, terminal, args: [] });
63060
63060
  }
63061
63061
  }),
63062
63062
  pwd: new TerminalCommand({
63063
63063
  command: "pwd",
63064
63064
  description: "Print the shell working directory",
63065
- kernel,
63065
+ kernel: kernel2,
63066
63066
  shell,
63067
63067
  terminal,
63068
63068
  options: [],
63069
63069
  run: async () => {
63070
- return await pwd({ kernel, shell, terminal, args: [] });
63070
+ return await pwd({ kernel: kernel2, shell, terminal, args: [] });
63071
63071
  }
63072
63072
  }),
63073
63073
  reboot: new TerminalCommand({
63074
63074
  command: "reboot",
63075
63075
  description: "Reboot the system",
63076
- kernel,
63076
+ kernel: kernel2,
63077
63077
  shell,
63078
63078
  terminal,
63079
63079
  options: [],
63080
63080
  run: async () => {
63081
- return await reboot({ kernel, shell, terminal, args: [] });
63081
+ return await reboot({ kernel: kernel2, shell, terminal, args: [] });
63082
63082
  }
63083
63083
  }),
63084
63084
  rm: new TerminalCommand({
63085
63085
  command: "rm",
63086
63086
  description: "Remove files or directories",
63087
- kernel,
63087
+ kernel: kernel2,
63088
63088
  shell,
63089
63089
  terminal,
63090
63090
  options: [
@@ -63092,13 +63092,13 @@ const TerminalCommands = (kernel, shell, terminal) => {
63092
63092
  { name: "path", type: String, typeLabel: "{underline path}", defaultOption: true, description: "The path to the file or directory to remove" }
63093
63093
  ],
63094
63094
  run: async (argv) => {
63095
- return await rm({ kernel, shell, terminal, args: [argv.path] });
63095
+ return await rm({ kernel: kernel2, shell, terminal, args: [argv.path] });
63096
63096
  }
63097
63097
  }),
63098
63098
  screensaver: new TerminalCommand({
63099
63099
  command: "screensaver",
63100
63100
  description: "Start the screensaver",
63101
- kernel,
63101
+ kernel: kernel2,
63102
63102
  shell,
63103
63103
  terminal,
63104
63104
  options: [
@@ -63107,24 +63107,24 @@ const TerminalCommands = (kernel, shell, terminal) => {
63107
63107
  { name: "set", type: Boolean, description: "Set the default screensaver" }
63108
63108
  ],
63109
63109
  run: async (argv) => {
63110
- return await screensaver({ kernel, shell, terminal, args: [argv.screensaver, argv.set] });
63110
+ return await screensaver({ kernel: kernel2, shell, terminal, args: [argv.screensaver, argv.set] });
63111
63111
  }
63112
63112
  }),
63113
63113
  snake: new TerminalCommand({
63114
63114
  command: "snake",
63115
63115
  description: "Play a simple snake game",
63116
- kernel,
63116
+ kernel: kernel2,
63117
63117
  shell,
63118
63118
  terminal,
63119
63119
  options: [],
63120
63120
  run: async () => {
63121
- await snake({ kernel, shell, terminal, args: [] });
63121
+ await snake({ kernel: kernel2, shell, terminal, args: [] });
63122
63122
  }
63123
63123
  }),
63124
63124
  socket: new TerminalCommand({
63125
63125
  command: "socket",
63126
63126
  description: "Send a message to the terminal socket",
63127
- kernel,
63127
+ kernel: kernel2,
63128
63128
  shell,
63129
63129
  terminal,
63130
63130
  options: [
@@ -63133,13 +63133,13 @@ const TerminalCommands = (kernel, shell, terminal) => {
63133
63133
  { name: "args", type: String, multiple: true, description: "The arguments to send to the command" }
63134
63134
  ],
63135
63135
  run: async () => {
63136
- return await socket();
63136
+ return await socket$1();
63137
63137
  }
63138
63138
  }),
63139
63139
  stat: new TerminalCommand({
63140
63140
  command: "stat",
63141
63141
  description: "Display information about a file or directory",
63142
- kernel,
63142
+ kernel: kernel2,
63143
63143
  shell,
63144
63144
  terminal,
63145
63145
  options: [
@@ -63147,13 +63147,13 @@ const TerminalCommands = (kernel, shell, terminal) => {
63147
63147
  { name: "path", type: String, typeLabel: "{underline path}", defaultOption: true, description: "The path to the file or directory to display" }
63148
63148
  ],
63149
63149
  run: async (argv) => {
63150
- return await stat({ kernel, shell, terminal, args: [argv.path] });
63150
+ return await stat({ kernel: kernel2, shell, terminal, args: [argv.path] });
63151
63151
  }
63152
63152
  }),
63153
63153
  su: new TerminalCommand({
63154
63154
  command: "su",
63155
63155
  description: "Switch user",
63156
- kernel,
63156
+ kernel: kernel2,
63157
63157
  shell,
63158
63158
  terminal,
63159
63159
  options: [
@@ -63161,13 +63161,13 @@ const TerminalCommands = (kernel, shell, terminal) => {
63161
63161
  { name: "user", type: String, defaultOption: true, description: "The user to switch to" }
63162
63162
  ],
63163
63163
  run: async (argv) => {
63164
- return await su({ kernel, shell, terminal, args: [argv.user] });
63164
+ return await su({ kernel: kernel2, shell, terminal, args: [argv.user] });
63165
63165
  }
63166
63166
  }),
63167
63167
  touch: new TerminalCommand({
63168
63168
  command: "touch",
63169
63169
  description: "Create an empty file",
63170
- kernel,
63170
+ kernel: kernel2,
63171
63171
  shell,
63172
63172
  terminal,
63173
63173
  options: [
@@ -63175,13 +63175,13 @@ const TerminalCommands = (kernel, shell, terminal) => {
63175
63175
  { name: "path", type: String, typeLabel: "{underline path}", defaultOption: true, description: "The path to the file to create" }
63176
63176
  ],
63177
63177
  run: async (argv) => {
63178
- return await touch({ kernel, shell, terminal, args: [argv.path] });
63178
+ return await touch({ kernel: kernel2, shell, terminal, args: [argv.path] });
63179
63179
  }
63180
63180
  }),
63181
63181
  umount: new TerminalCommand({
63182
63182
  command: "umount",
63183
63183
  description: "Unmount a filesystem",
63184
- kernel,
63184
+ kernel: kernel2,
63185
63185
  shell,
63186
63186
  terminal,
63187
63187
  options: [
@@ -63189,13 +63189,13 @@ const TerminalCommands = (kernel, shell, terminal) => {
63189
63189
  { name: "path", type: String, typeLabel: "{underline path}", defaultOption: true, description: "The path to the directory to unmount" }
63190
63190
  ],
63191
63191
  run: async (argv) => {
63192
- return await umount({ kernel, shell, terminal, args: [argv.path] });
63192
+ return await umount({ kernel: kernel2, shell, terminal, args: [argv.path] });
63193
63193
  }
63194
63194
  }),
63195
63195
  user: new TerminalCommand({
63196
63196
  command: "user",
63197
63197
  description: "Manage users",
63198
- kernel,
63198
+ kernel: kernel2,
63199
63199
  shell,
63200
63200
  terminal,
63201
63201
  options: [
@@ -63222,13 +63222,13 @@ const TerminalCommands = (kernel, shell, terminal) => {
63222
63222
  }
63223
63223
  ],
63224
63224
  run: async (argv) => {
63225
- return await user({ kernel, shell, terminal, args: [argv.command, argv.username, argv.password] });
63225
+ return await user({ kernel: kernel2, shell, terminal, args: [argv.command, argv.username, argv.password] });
63226
63226
  }
63227
63227
  }),
63228
63228
  unzip: new TerminalCommand({
63229
63229
  command: "unzip",
63230
63230
  description: "Unzip a file",
63231
- kernel,
63231
+ kernel: kernel2,
63232
63232
  shell,
63233
63233
  terminal,
63234
63234
  options: [
@@ -63236,13 +63236,13 @@ const TerminalCommands = (kernel, shell, terminal) => {
63236
63236
  { name: "path", type: String, typeLabel: "{underline path}", defaultOption: true, description: "The path to the file to unzip" }
63237
63237
  ],
63238
63238
  run: async (argv) => {
63239
- return await unzip({ kernel, shell, terminal, args: [argv.path] });
63239
+ return await unzip({ kernel: kernel2, shell, terminal, args: [argv.path] });
63240
63240
  }
63241
63241
  }),
63242
63242
  upload: new TerminalCommand({
63243
63243
  command: "upload",
63244
63244
  description: "Upload a file to the filesystem",
63245
- kernel,
63245
+ kernel: kernel2,
63246
63246
  shell,
63247
63247
  terminal,
63248
63248
  options: [
@@ -63250,13 +63250,13 @@ const TerminalCommands = (kernel, shell, terminal) => {
63250
63250
  { name: "path", type: String, typeLabel: "{underline path}", defaultOption: true, description: "The path to store the file" }
63251
63251
  ],
63252
63252
  run: async (argv) => {
63253
- return await upload({ kernel, shell, terminal, args: [argv.path] });
63253
+ return await upload({ kernel: kernel2, shell, terminal, args: [argv.path] });
63254
63254
  }
63255
63255
  }),
63256
63256
  video: new TerminalCommand({
63257
63257
  command: "video",
63258
63258
  description: "Play a video file",
63259
- kernel,
63259
+ kernel: kernel2,
63260
63260
  shell,
63261
63261
  terminal,
63262
63262
  options: [
@@ -63264,13 +63264,13 @@ const TerminalCommands = (kernel, shell, terminal) => {
63264
63264
  { name: "file", type: String, typeLabel: "{underline file}", defaultOption: true, description: "The path to the video file to play" }
63265
63265
  ],
63266
63266
  run: async (argv) => {
63267
- return await video({ kernel, shell, terminal, args: [argv.file] });
63267
+ return await video({ kernel: kernel2, shell, terminal, args: [argv.file] });
63268
63268
  }
63269
63269
  }),
63270
63270
  zip: new TerminalCommand({
63271
63271
  command: "zip",
63272
63272
  description: "Zip a directory",
63273
- kernel,
63273
+ kernel: kernel2,
63274
63274
  shell,
63275
63275
  terminal,
63276
63276
  options: [
@@ -63279,7 +63279,7 @@ const TerminalCommands = (kernel, shell, terminal) => {
63279
63279
  { name: "path", type: String, typeLabel: "{underline path}", multiple: true, description: "The paths to the files or directories to zip" }
63280
63280
  ],
63281
63281
  run: async (argv) => {
63282
- return await zip({ kernel, shell, terminal, args: [argv.output, argv.path] });
63282
+ return await zip({ kernel: kernel2, shell, terminal, args: [argv.output, argv.path] });
63283
63283
  }
63284
63284
  })
63285
63285
  };
@@ -63301,7 +63301,7 @@ const ai = async ({ process: process2, args }) => {
63301
63301
  writer == null ? void 0 : writer.releaseLock();
63302
63302
  return 0;
63303
63303
  };
63304
- const cat = async ({ kernel, shell, process: process2, args }) => {
63304
+ const cat = async ({ kernel: kernel2, shell, process: process2, args }) => {
63305
63305
  if (!process2) return 1;
63306
63306
  const writer = process2.stdout.getWriter();
63307
63307
  try {
@@ -63325,23 +63325,23 @@ const cat = async ({ kernel, shell, process: process2, args }) => {
63325
63325
  const interruptHandler = () => {
63326
63326
  interrupted = true;
63327
63327
  };
63328
- kernel.terminal.events.on(TerminalEvents.INTERRUPT, interruptHandler);
63328
+ kernel2.terminal.events.on(TerminalEvents.INTERRUPT, interruptHandler);
63329
63329
  try {
63330
63330
  if (!fullPath.startsWith("/dev")) {
63331
- const handle = await kernel.filesystem.fs.open(fullPath);
63332
- const stat2 = await kernel.filesystem.fs.stat(fullPath);
63331
+ const handle = await kernel2.filesystem.fs.open(fullPath);
63332
+ const stat2 = await kernel2.filesystem.fs.stat(fullPath);
63333
63333
  let bytesRead = 0;
63334
63334
  const chunkSize = 1024;
63335
63335
  while (bytesRead < stat2.size) {
63336
63336
  if (interrupted) break;
63337
63337
  const data = new Uint8Array(chunkSize);
63338
63338
  const readSize = Math.min(chunkSize, stat2.size - bytesRead);
63339
- await kernel.filesystem.fsSync.read(handle.fd, data, 0, readSize, bytesRead);
63339
+ await kernel2.filesystem.fsSync.read(handle.fd, data, 0, readSize, bytesRead);
63340
63340
  await writer.write(data.subarray(0, readSize));
63341
63341
  bytesRead += readSize;
63342
63342
  }
63343
63343
  } else {
63344
- const device = await kernel.filesystem.fs.open(fullPath);
63344
+ const device = await kernel2.filesystem.fs.open(fullPath);
63345
63345
  const maxBytes = bytes ? parseInt(bytes) : void 0;
63346
63346
  let totalBytesRead = 0;
63347
63347
  const chunkSize = 1024;
@@ -63361,7 +63361,7 @@ const cat = async ({ kernel, shell, process: process2, args }) => {
63361
63361
  } while (bytesRead > 0 && (!maxBytes || totalBytesRead < maxBytes));
63362
63362
  }
63363
63363
  } finally {
63364
- kernel.terminal.events.off(TerminalEvents.INTERRUPT, interruptHandler);
63364
+ kernel2.terminal.events.off(TerminalEvents.INTERRUPT, interruptHandler);
63365
63365
  }
63366
63366
  }
63367
63367
  return 0;
@@ -63369,13 +63369,13 @@ const cat = async ({ kernel, shell, process: process2, args }) => {
63369
63369
  writer.releaseLock();
63370
63370
  }
63371
63371
  };
63372
- const cd = async ({ kernel, shell, terminal, args }) => {
63372
+ const cd = async ({ kernel: kernel2, shell, terminal, args }) => {
63373
63373
  const destination = args[0];
63374
63374
  const fullPath = destination ? path.resolve(shell.cwd, destination) : shell.cwd;
63375
- if (await kernel.filesystem.fs.exists(fullPath)) shell.cwd = fullPath;
63375
+ if (await kernel2.filesystem.fs.exists(fullPath)) shell.cwd = fullPath;
63376
63376
  else terminal.writeln(chalk$1.red(`${fullPath} not found`));
63377
63377
  };
63378
- const chmod = async ({ kernel, shell, terminal, args }) => {
63378
+ const chmod = async ({ kernel: kernel2, shell, terminal, args }) => {
63379
63379
  if (!args || args.length === 0) {
63380
63380
  terminal.writeln(chalk$1.red("chmod: missing operand"));
63381
63381
  terminal.writeln("Try 'chmod --help' for more information.");
@@ -63384,30 +63384,30 @@ const chmod = async ({ kernel, shell, terminal, args }) => {
63384
63384
  const [mode2, target] = args;
63385
63385
  if (!mode2 || !target) return 1;
63386
63386
  const fullPath = path.resolve(shell.cwd, target);
63387
- await kernel.filesystem.fs.chmod(fullPath, mode2);
63387
+ await kernel2.filesystem.fs.chmod(fullPath, mode2);
63388
63388
  return 0;
63389
63389
  };
63390
- const chown = async ({ kernel, shell, args }) => {
63390
+ const chown = async ({ kernel: kernel2, shell, args }) => {
63391
63391
  const [user2, target, group] = args;
63392
63392
  if (!user2 || !target) return 1;
63393
63393
  const fullPath = path.resolve(shell.cwd, target);
63394
- kernel.filesystem.fsSync.chownSync(fullPath, parseInt(user2), parseInt(group ?? user2));
63394
+ kernel2.filesystem.fsSync.chownSync(fullPath, parseInt(user2), parseInt(group ?? user2));
63395
63395
  };
63396
63396
  const clear = async ({ terminal }) => {
63397
63397
  terminal.write("\x1B[2J\x1B[H");
63398
63398
  };
63399
- const cp = async ({ kernel, shell, args }) => {
63399
+ const cp = async ({ kernel: kernel2, shell, args }) => {
63400
63400
  const [source2, destination] = args.map((arg) => path.resolve(shell.cwd, arg));
63401
63401
  if (!source2 || !destination) return 1;
63402
- const destinationStats = await kernel.filesystem.fs.stat(destination).catch(() => null);
63402
+ const destinationStats = await kernel2.filesystem.fs.stat(destination).catch(() => null);
63403
63403
  const finalDestination = (destinationStats == null ? void 0 : destinationStats.isDirectory()) ? path.join(destination, path.basename(source2)) : destination;
63404
- await kernel.filesystem.fs.copyFile(source2, finalDestination);
63404
+ await kernel2.filesystem.fs.copyFile(source2, finalDestination);
63405
63405
  };
63406
- const download = async ({ kernel, shell, terminal, args }) => {
63406
+ const download = async ({ kernel: kernel2, shell, terminal, args }) => {
63407
63407
  const destination = args[0];
63408
63408
  const fullPath = destination ? path.resolve(shell.cwd, destination) : shell.cwd;
63409
- if (await kernel.filesystem.fs.exists(fullPath)) {
63410
- const data = await kernel.filesystem.fs.readFile(fullPath);
63409
+ if (await kernel2.filesystem.fs.exists(fullPath)) {
63410
+ const data = await kernel2.filesystem.fs.readFile(fullPath);
63411
63411
  const blob = new Blob([data], { type: "application/octet-stream" });
63412
63412
  const url = window.URL.createObjectURL(blob);
63413
63413
  const a = document.createElement("a");
@@ -63436,11 +63436,11 @@ const echo = async ({ process: process2, terminal, args }) => {
63436
63436
  }
63437
63437
  return 0;
63438
63438
  };
63439
- const edit = async ({ kernel, shell, terminal, args }) => {
63439
+ const edit = async ({ kernel: kernel2, shell, terminal, args }) => {
63440
63440
  const target = args[0];
63441
63441
  if (!target) return 1;
63442
63442
  const fullPath = path.resolve(shell.cwd, target);
63443
- const content = await kernel.filesystem.fs.readFile(fullPath, "utf-8").catch(() => "");
63443
+ const content = await kernel2.filesystem.fs.readFile(fullPath, "utf-8").catch(() => "");
63444
63444
  const lines = content.split("\n");
63445
63445
  let cursorX = 0;
63446
63446
  let cursorY = 0;
@@ -63548,7 +63548,7 @@ const edit = async ({ kernel, shell, terminal, args }) => {
63548
63548
  switch (command) {
63549
63549
  case "w":
63550
63550
  message = chalk$1.green(`Saved to ${fullPath}`);
63551
- await kernel.filesystem.fs.writeFile(fullPath, lines.join("\n"));
63551
+ await kernel2.filesystem.fs.writeFile(fullPath, lines.join("\n"));
63552
63552
  break;
63553
63553
  case "q":
63554
63554
  return true;
@@ -63717,7 +63717,7 @@ const env = async ({ shell, terminal, args }) => {
63717
63717
  }
63718
63718
  }
63719
63719
  };
63720
- const fetch$1 = async ({ kernel, shell, terminal, process: process2, args }) => {
63720
+ const fetch$1 = async ({ kernel: kernel2, shell, terminal, process: process2, args }) => {
63721
63721
  var _a3, _b2;
63722
63722
  const [url, filename, method, body2] = args;
63723
63723
  if (!url) {
@@ -63733,14 +63733,14 @@ const fetch$1 = async ({ kernel, shell, terminal, process: process2, args }) =>
63733
63733
  if (!reader) throw new Error("No response body");
63734
63734
  let writer;
63735
63735
  if (filename) {
63736
- const fullPath = path.resolve(kernel.shell.cwd, filename);
63737
- const fileHandle = await kernel.filesystem.fs.open(fullPath, "w");
63736
+ const fullPath = path.resolve(kernel2.shell.cwd, filename);
63737
+ const fileHandle = await kernel2.filesystem.fs.open(fullPath, "w");
63738
63738
  writer = {
63739
63739
  write: (chunk) => {
63740
- kernel.filesystem.fsSync.write(fileHandle.fd, chunk);
63740
+ kernel2.filesystem.fsSync.write(fileHandle.fd, chunk);
63741
63741
  },
63742
63742
  releaseLock: async () => {
63743
- await kernel.filesystem.fsSync.close(fileHandle.fd);
63743
+ await kernel2.filesystem.fsSync.close(fileHandle.fd);
63744
63744
  }
63745
63745
  };
63746
63746
  } else writer = (_b2 = process2 == null ? void 0 : process2.stdout) == null ? void 0 : _b2.getWriter();
@@ -63761,7 +63761,7 @@ const fetch$1 = async ({ kernel, shell, terminal, process: process2, args }) =>
63761
63761
  return 1;
63762
63762
  }
63763
63763
  };
63764
- const install = async ({ kernel, terminal, args }) => {
63764
+ const install = async ({ kernel: kernel2, terminal, args }) => {
63765
63765
  const [packageArg, repoArg] = args;
63766
63766
  if (!packageArg) {
63767
63767
  terminal.writeln(chalk$1.red("Usage: install <package-name>[@version]"));
@@ -63786,9 +63786,7 @@ const install = async ({ kernel, terminal, args }) => {
63786
63786
  let files = [data.module, data.main, data.types].filter(Boolean);
63787
63787
  const browserMappings = {};
63788
63788
  if (typeof data.browser === "object") {
63789
- Object.entries(data.browser).forEach(([key, value]) => {
63790
- browserMappings[key] = value;
63791
- });
63789
+ for (const [key, value] of Object.entries(data.browser)) browserMappings[key] = value;
63792
63790
  files = [...files, ...Object.keys(data.browser)];
63793
63791
  } else if (typeof data.browser === "string") {
63794
63792
  files.push(data.browser);
@@ -63805,11 +63803,11 @@ const install = async ({ kernel, terminal, args }) => {
63805
63803
  if (!dir) continue;
63806
63804
  currentPath += "/" + dir;
63807
63805
  try {
63808
- await kernel.filesystem.fs.mkdir(currentPath, 493);
63806
+ await kernel2.filesystem.fs.mkdir(currentPath, 493);
63809
63807
  } catch {
63810
63808
  }
63811
63809
  }
63812
- await kernel.filesystem.fs.writeFile(`${packagePath}/package.json`, JSON.stringify(data, null, 2), { mode: 493 });
63810
+ await kernel2.filesystem.fs.writeFile(`${packagePath}/package.json`, JSON.stringify(data, null, 2), { mode: 493 });
63813
63811
  terminal.writeln(chalk$1.green(`Downloaded package.json to ${packagePath}/package.json`));
63814
63812
  const processedFiles = /* @__PURE__ */ new Set();
63815
63813
  for (const file of files) {
@@ -63829,14 +63827,12 @@ const install = async ({ kernel, terminal, args }) => {
63829
63827
  if (!part) continue;
63830
63828
  dirPath += "/" + part;
63831
63829
  try {
63832
- await kernel.filesystem.fs.mkdir(dirPath, 493);
63830
+ await kernel2.filesystem.fs.mkdir(dirPath, 493);
63833
63831
  } catch {
63834
63832
  }
63835
63833
  }
63836
63834
  const fileUrl = `${repo}/${packageName}@${data.version}/${targetFile}`;
63837
- if (browserReplacement) {
63838
- terminal.writeln(chalk$1.blue(`Remapping ${file} to ${browserReplacement}`));
63839
- }
63835
+ if (browserReplacement) terminal.writeln(chalk$1.blue(`Remapping ${file} to ${browserReplacement}`));
63840
63836
  try {
63841
63837
  terminal.writeln(chalk$1.green(`Downloading ${targetFile} to ${filePath}`));
63842
63838
  const fileResponse = await globalThis.fetch(fileUrl);
@@ -63845,7 +63841,7 @@ const install = async ({ kernel, terminal, args }) => {
63845
63841
  continue;
63846
63842
  }
63847
63843
  const fileData = await fileResponse.text();
63848
- await kernel.filesystem.fs.writeFile(filePath, fileData, { mode: 493 });
63844
+ await kernel2.filesystem.fs.writeFile(filePath, fileData, { mode: 493 });
63849
63845
  } catch (error) {
63850
63846
  terminal.writeln(chalk$1.red(`Failed to download ${targetFile}: ${error instanceof Error ? error.message : "Unknown error"}`));
63851
63847
  }
@@ -63857,24 +63853,24 @@ const install = async ({ kernel, terminal, args }) => {
63857
63853
  try {
63858
63854
  let packages = [];
63859
63855
  try {
63860
- const packagesData = await kernel.filesystem.fs.readFile("/etc/packages", "utf-8");
63856
+ const packagesData = await kernel2.filesystem.fs.readFile("/etc/packages", "utf-8");
63861
63857
  if (packagesData) packages = JSON.parse(packagesData);
63862
63858
  } catch {
63863
63859
  }
63864
63860
  packages.push(packageEntry);
63865
- await kernel.filesystem.fs.writeFile("/etc/packages", JSON.stringify(packages, null, 2));
63861
+ await kernel2.filesystem.fs.writeFile("/etc/packages", JSON.stringify(packages, null, 2));
63866
63862
  terminal.writeln(chalk$1.green(`Added ${packageName}@${data.version} to /etc/packages`));
63867
63863
  } catch (error) {
63868
63864
  terminal.writeln(chalk$1.red(`Failed to update /etc/packages: ${error}`));
63869
63865
  }
63870
63866
  };
63871
- const ls = async ({ kernel, shell, terminal, args }) => {
63867
+ const ls = async ({ kernel: kernel2, shell, terminal, args }) => {
63872
63868
  var _a3;
63873
63869
  const target = args[0];
63874
63870
  const fullPath = target ? path.resolve(shell.cwd, target === "" ? "." : target) : shell.cwd;
63875
- const stats2 = await kernel.filesystem.fs.stat(fullPath);
63876
- const entries = stats2.isDirectory() ? await kernel.filesystem.fs.readdir(fullPath) : [fullPath];
63877
- const descriptions = kernel.filesystem.descriptions(kernel.i18n.t);
63871
+ const stats2 = await kernel2.filesystem.fs.stat(fullPath);
63872
+ const entries = stats2.isDirectory() ? await kernel2.filesystem.fs.readdir(fullPath) : [fullPath];
63873
+ const descriptions = kernel2.filesystem.descriptions(kernel2.i18n.t);
63878
63874
  const getModeType = (stats22) => {
63879
63875
  let type = "-";
63880
63876
  if (stats22.isDirectory()) type = "d";
@@ -63897,19 +63893,19 @@ const ls = async ({ kernel, shell, terminal, args }) => {
63897
63893
  else return chalk$1.gray(timestamp.toISOString().slice(0, 19).replace("T", " "));
63898
63894
  };
63899
63895
  const getOwnerString = (stats22) => {
63900
- const owner = kernel.users.all.get(stats22.uid) || kernel.users.all.get(0);
63896
+ const owner = kernel2.users.all.get(stats22.uid) || kernel2.users.all.get(0);
63901
63897
  if ((owner == null ? void 0 : owner.username) === shell.username) return chalk$1.green(`${(owner == null ? void 0 : owner.username) || stats22.uid}:${(owner == null ? void 0 : owner.username) || stats22.gid}`);
63902
63898
  else if (stats22.uid === 0) return chalk$1.red(`${(owner == null ? void 0 : owner.username) || stats22.uid}:${(owner == null ? void 0 : owner.username) || stats22.gid}`);
63903
63899
  else return chalk$1.gray(`${(owner == null ? void 0 : owner.username) || stats22.uid}:${(owner == null ? void 0 : owner.username) || stats22.gid}`);
63904
63900
  };
63905
- const mounts2 = Array.from(kernel.filesystem.fsSync.mounts.entries()).filter(([target2]) => path.dirname(target2) === fullPath && target2 !== "/");
63901
+ const mounts2 = Array.from(kernel2.filesystem.fsSync.mounts.entries()).filter(([target2]) => path.dirname(target2) === fullPath && target2 !== "/");
63906
63902
  const files = entries.map((entry) => {
63907
63903
  var _a4;
63908
63904
  const target2 = path.resolve(fullPath, entry);
63909
63905
  try {
63910
- return { target: target2, name: entry, stats: kernel.filesystem.fsSync.statSync(target2) };
63906
+ return { target: target2, name: entry, stats: kernel2.filesystem.fsSync.statSync(target2) };
63911
63907
  } catch (err2) {
63912
- (_a4 = kernel.log) == null ? void 0 : _a4.warn(err2);
63908
+ (_a4 = kernel2.log) == null ? void 0 : _a4.warn(err2);
63913
63909
  return null;
63914
63910
  }
63915
63911
  }).filter((entry) => entry !== null && entry !== void 0).filter((entry) => !entry.stats.isDirectory());
@@ -63917,9 +63913,9 @@ const ls = async ({ kernel, shell, terminal, args }) => {
63917
63913
  var _a4;
63918
63914
  const target2 = path.resolve(fullPath, entry);
63919
63915
  try {
63920
- return { target: target2, name: entry, stats: kernel.filesystem.fsSync.statSync(target2) };
63916
+ return { target: target2, name: entry, stats: kernel2.filesystem.fsSync.statSync(target2) };
63921
63917
  } catch (err2) {
63922
- (_a4 = kernel.log) == null ? void 0 : _a4.warn(err2);
63918
+ (_a4 = kernel2.log) == null ? void 0 : _a4.warn(err2);
63923
63919
  return null;
63924
63920
  }
63925
63921
  }).filter((entry) => entry && entry.stats.isDirectory()).concat(mounts2.map(([target2]) => ({
@@ -63957,8 +63953,8 @@ const ls = async ({ kernel, shell, terminal, args }) => {
63957
63953
  const ext = file.name.split(".").pop();
63958
63954
  if (ext && descriptions.has("." + ext)) return descriptions.get("." + ext);
63959
63955
  if (file.stats.isBlockDevice() || file.stats.isCharacterDevice()) {
63960
- const device = kernel.filesystem.devfs.devices.get(`/${file.name}`);
63961
- const kdevice = kernel.devices.get(file.name);
63956
+ const device = kernel2.filesystem.devfs.devices.get(`/${file.name}`);
63957
+ const kdevice = kernel2.devices.get(file.name);
63962
63958
  const description = ((_a4 = kdevice == null ? void 0 : kdevice.device.pkg) == null ? void 0 : _a4.description) || "";
63963
63959
  const version2 = ((_b2 = kdevice == null ? void 0 : kdevice.device.pkg) == null ? void 0 : _b2.version) || "";
63964
63960
  if (device) return `${description ? `${description}:` : ""}${version2 ? `v${version2}:` : ""}M${device.major ?? "?"},m${device.minor ?? "?"}`;
@@ -63985,11 +63981,11 @@ const ls = async ({ kernel, shell, terminal, args }) => {
63985
63981
  if (data.length > 1) terminal.writeln(line3);
63986
63982
  }
63987
63983
  };
63988
- const mount = async ({ kernel, shell, terminal, args }) => {
63984
+ const mount = async ({ kernel: kernel2, shell, terminal, args }) => {
63989
63985
  const [points, type, config2] = args;
63990
63986
  if (!points || !type || points.length !== 2) {
63991
63987
  terminal.writeln(chalk$1.red("Usage: mount -t <type> <source> <target>"));
63992
- const currentMounts = Array.from(kernel.filesystem.fsSync.mounts.entries()).map(([target2, mount2]) => {
63988
+ const currentMounts = Array.from(kernel2.filesystem.fsSync.mounts.entries()).map(([target2, mount2]) => {
63993
63989
  var _a3;
63994
63990
  return `${chalk$1.blue(target2)} (${((_a3 = mount2.store) == null ? void 0 : _a3.constructor.name) || mount2.constructor.name}/${mount2.metadata().name})`;
63995
63991
  });
@@ -64014,26 +64010,26 @@ const mount = async ({ kernel, shell, terminal, args }) => {
64014
64010
  const fullTargetPath = path.resolve(shell.cwd, target);
64015
64011
  switch (type.toLowerCase()) {
64016
64012
  case "fetch":
64017
- kernel.filesystem.fsSync.mount(fullTargetPath, await resolveMountConfig({ backend: Fetch, index: fullSourcePath, baseUrl: options == null ? void 0 : options.baseUrl }));
64013
+ kernel2.filesystem.fsSync.mount(fullTargetPath, await resolveMountConfig({ backend: Fetch, index: fullSourcePath, baseUrl: options == null ? void 0 : options.baseUrl }));
64018
64014
  break;
64019
64015
  case "indexeddb":
64020
- kernel.filesystem.fsSync.mount(fullTargetPath, await resolveMountConfig({ backend: IndexedDB, storeName: fullSourcePath }));
64016
+ kernel2.filesystem.fsSync.mount(fullTargetPath, await resolveMountConfig({ backend: IndexedDB, storeName: fullSourcePath }));
64021
64017
  break;
64022
64018
  case "memory":
64023
- kernel.filesystem.fsSync.mount(fullTargetPath, await resolveMountConfig({ backend: InMemory, name: fullSourcePath }));
64019
+ kernel2.filesystem.fsSync.mount(fullTargetPath, await resolveMountConfig({ backend: InMemory, name: fullSourcePath }));
64024
64020
  break;
64025
64021
  case "zip":
64026
- kernel.filesystem.fsSync.mount(fullTargetPath, await resolveMountConfig({ backend: Zip, name: fullSourcePath, data: new Uint8Array(await kernel.filesystem.fs.readFile(fullSourcePath)).buffer }));
64022
+ kernel2.filesystem.fsSync.mount(fullTargetPath, await resolveMountConfig({ backend: Zip, name: fullSourcePath, data: new Uint8Array(await kernel2.filesystem.fs.readFile(fullSourcePath)).buffer }));
64027
64023
  break;
64028
64024
  }
64029
64025
  return 0;
64030
64026
  };
64031
- const mkdir = async ({ kernel, shell, args }) => {
64027
+ const mkdir = async ({ kernel: kernel2, shell, args }) => {
64032
64028
  const target = args[0];
64033
64029
  const fullPath = target ? path.resolve(shell.cwd, target) : shell.cwd;
64034
- await kernel.filesystem.fs.mkdir(fullPath);
64030
+ await kernel2.filesystem.fs.mkdir(fullPath);
64035
64031
  };
64036
- const mv = async ({ kernel, shell, terminal, args }) => {
64032
+ const mv = async ({ kernel: kernel2, shell, terminal, args }) => {
64037
64033
  const [sourceInput, destinationInput] = args;
64038
64034
  if (!sourceInput || !destinationInput) {
64039
64035
  terminal.writeln(chalk$1.red("Usage: mv <source> <destination>"));
@@ -64047,15 +64043,15 @@ const mv = async ({ kernel, shell, terminal, args }) => {
64047
64043
  terminal.writeln(chalk$1.red("Cannot move disallowed paths"));
64048
64044
  return 2;
64049
64045
  }
64050
- if (await kernel.filesystem.fs.exists(destination)) {
64051
- if ((await kernel.filesystem.fs.stat(destination)).isDirectory()) {
64046
+ if (await kernel2.filesystem.fs.exists(destination)) {
64047
+ if ((await kernel2.filesystem.fs.stat(destination)).isDirectory()) {
64052
64048
  destination = path.resolve(destination, path.basename(source2));
64053
64049
  } else {
64054
64050
  terminal.writeln(chalk$1.red(`${destination} already exists`));
64055
64051
  return 1;
64056
64052
  }
64057
64053
  }
64058
- await kernel.filesystem.fs.rename(source2, destination);
64054
+ await kernel2.filesystem.fs.rename(source2, destination);
64059
64055
  return 0;
64060
64056
  };
64061
64057
  const observe = async ({ process: process2, terminal }) => {
@@ -64096,7 +64092,7 @@ const open = async ({ terminal, args }) => {
64096
64092
  terminal.writeln(chalk$1.red("Unsupported path"));
64097
64093
  }
64098
64094
  };
64099
- const passwd = async ({ kernel, terminal, args }) => {
64095
+ const passwd = async ({ kernel: kernel2, terminal, args }) => {
64100
64096
  let oldPass, newPass;
64101
64097
  if (!args || !Array.isArray(args) || args.length < 2) {
64102
64098
  oldPass = await terminal.readline(chalk$1.cyan("Enter current password: "), true);
@@ -64119,7 +64115,7 @@ const passwd = async ({ kernel, terminal, args }) => {
64119
64115
  }
64120
64116
  try {
64121
64117
  if (!oldPass || !newPass) throw new Error("Missing password");
64122
- await kernel.users.password(oldPass, newPass);
64118
+ await kernel2.users.password(oldPass, newPass);
64123
64119
  terminal.writeln(chalk$1.green("Password updated successfully"));
64124
64120
  return 0;
64125
64121
  } catch (error) {
@@ -64127,55 +64123,55 @@ const passwd = async ({ kernel, terminal, args }) => {
64127
64123
  return 1;
64128
64124
  }
64129
64125
  };
64130
- const play = async ({ kernel, shell, terminal, args }) => {
64126
+ const play = async ({ kernel: kernel2, shell, terminal, args }) => {
64131
64127
  const [file] = args;
64132
64128
  if (!file || file === "") {
64133
64129
  terminal.writeln(chalk$1.red("Usage: play <file>"));
64134
64130
  return 1;
64135
64131
  }
64136
64132
  const fullPath = path.resolve(shell.cwd, file);
64137
- const blob = new Blob([await kernel.filesystem.fs.readFile(fullPath)]);
64133
+ const blob = new Blob([await kernel2.filesystem.fs.readFile(fullPath)]);
64138
64134
  const url = URL.createObjectURL(blob);
64139
64135
  const audio = new Audio(url);
64140
64136
  audio.play();
64141
64137
  };
64142
- const ps = async ({ kernel, terminal }) => {
64138
+ const ps = async ({ kernel: kernel2, terminal }) => {
64143
64139
  terminal.writeln("PID COMMAND STATUS");
64144
- for (const [pid, process2] of kernel.processes.all.entries()) {
64140
+ for (const [pid, process2] of kernel2.processes.all.entries()) {
64145
64141
  terminal.writeln(`${chalk$1.yellow(pid)} ${chalk$1.green(process2.command)} ${chalk$1.blue(process2.status)}`);
64146
64142
  }
64147
64143
  };
64148
64144
  const pwd = async ({ shell, terminal }) => {
64149
64145
  terminal.writeln(shell.cwd);
64150
64146
  };
64151
- const reboot = async ({ kernel }) => {
64152
- kernel.reboot();
64147
+ const reboot = async ({ kernel: kernel2 }) => {
64148
+ kernel2.reboot();
64153
64149
  };
64154
- const rm = async ({ kernel, shell, args }) => {
64150
+ const rm = async ({ kernel: kernel2, shell, args }) => {
64155
64151
  const target = args[0];
64156
64152
  const fullPath = target ? path.resolve(shell.cwd, target) : shell.cwd;
64157
- if ((await kernel.filesystem.fs.stat(fullPath)).isDirectory()) await kernel.filesystem.fs.rmdir(fullPath);
64158
- else await kernel.filesystem.fs.unlink(fullPath);
64153
+ if ((await kernel2.filesystem.fs.stat(fullPath)).isDirectory()) await kernel2.filesystem.fs.rmdir(fullPath);
64154
+ else await kernel2.filesystem.fs.unlink(fullPath);
64159
64155
  return 0;
64160
64156
  };
64161
- const screensaver = async ({ kernel, terminal, args }) => {
64157
+ const screensaver = async ({ kernel: kernel2, terminal, args }) => {
64162
64158
  const [screensaver2, set] = args;
64163
64159
  if (screensaver2 === "off") {
64164
- kernel.storage.local.removeItem("screensaver");
64160
+ kernel2.storage.local.removeItem("screensaver");
64165
64161
  return 0;
64166
64162
  }
64167
64163
  let saverName = screensaver2;
64168
- if (!saverName) saverName = kernel.storage.local.getItem("screensaver") || "matrix";
64169
- const saver = kernel.screensavers.get(saverName);
64164
+ if (!saverName) saverName = kernel2.storage.local.getItem("screensaver") || "matrix";
64165
+ const saver = kernel2.screensavers.get(saverName);
64170
64166
  if (!saver) {
64171
64167
  terminal.writeln(chalk$1.red("Invalid screensaver"));
64172
64168
  return 1;
64173
64169
  }
64174
64170
  terminal.blur();
64175
64171
  saver.default({ terminal });
64176
- if (set) kernel.storage.local.setItem("screensaver", saverName);
64172
+ if (set) kernel2.storage.local.setItem("screensaver", saverName);
64177
64173
  };
64178
- const snake = ({ kernel, terminal }) => {
64174
+ const snake = ({ kernel: kernel2, terminal }) => {
64179
64175
  const width = 20;
64180
64176
  const height = 10;
64181
64177
  const snake2 = [{ x: 10, y: 5 }];
@@ -64192,7 +64188,7 @@ const snake = ({ kernel, terminal }) => {
64192
64188
  terminal.writeln(chalk$1.blue("┌" + "─".repeat(width) + "┐"));
64193
64189
  gameBoard.forEach((row) => terminal.writeln(chalk$1.blue("│" + row.join("") + "│")));
64194
64190
  terminal.writeln(chalk$1.blue(`└${"─".repeat(width)}┘`));
64195
- terminal.writeln(`Score: ${score} High Score: ${kernel.storage.local.getItem("snake-high-score") || 0}`);
64191
+ terminal.writeln(`Score: ${score} High Score: ${kernel2.storage.local.getItem("snake-high-score") || 0}`);
64196
64192
  if (!gameStarted) terminal.writeln("\nPress any key to start...");
64197
64193
  };
64198
64194
  const moveSnake = () => {
@@ -64203,8 +64199,8 @@ const snake = ({ kernel, terminal }) => {
64203
64199
  if (head.x === food.x && head.y === food.y) {
64204
64200
  score++;
64205
64201
  food = { x: Math.floor(Math.random() * width), y: Math.floor(Math.random() * height) };
64206
- if (!kernel.storage.local.getItem("snake-high-score") || Number(kernel.storage.local.getItem("snake-high-score")) < score)
64207
- kernel.storage.local.setItem("snake-high-score", score.toString());
64202
+ if (!kernel2.storage.local.getItem("snake-high-score") || Number(kernel2.storage.local.getItem("snake-high-score")) < score)
64203
+ kernel2.storage.local.setItem("snake-high-score", score.toString());
64208
64204
  } else snake2.pop();
64209
64205
  return;
64210
64206
  };
@@ -64264,33 +64260,33 @@ const snake = ({ kernel, terminal }) => {
64264
64260
  }, 100);
64265
64261
  });
64266
64262
  };
64267
- const socket = async () => {
64263
+ const socket$1 = async () => {
64268
64264
  return 0;
64269
64265
  };
64270
- const stat = async ({ kernel, shell, terminal, args }) => {
64266
+ const stat = async ({ kernel: kernel2, shell, terminal, args }) => {
64271
64267
  const argPath = args[0];
64272
64268
  const fullPath = argPath ? path.resolve(shell.cwd, argPath) : shell.cwd;
64273
- const stats2 = await kernel.filesystem.fs.stat(fullPath);
64269
+ const stats2 = await kernel2.filesystem.fs.stat(fullPath);
64274
64270
  terminal.writeln(JSON.stringify(stats2, null, 2));
64275
64271
  const extension = path.extname(fullPath);
64276
64272
  if (extension === ".zip") {
64277
- const blob = new Blob([await kernel.filesystem.fs.readFile(fullPath)]);
64273
+ const blob = new Blob([await kernel2.filesystem.fs.readFile(fullPath)]);
64278
64274
  const zipReader = new ZipReader(new BlobReader(blob));
64279
64275
  const entries = await zipReader.getEntries();
64280
64276
  terminal.writeln(chalk$1.bold("\nZIP Entries:"));
64281
64277
  for (const entry of entries) terminal.writeln(`${chalk$1.blue(entry.filename)} (${entry.uncompressedSize} bytes)`);
64282
64278
  }
64283
64279
  };
64284
- const su = async ({ kernel, terminal, args }) => {
64280
+ const su = async ({ kernel: kernel2, terminal, args }) => {
64285
64281
  const username = args[0];
64286
- const currentUser = kernel.users.get(credentials.suid);
64282
+ const currentUser = kernel2.users.get(credentials.suid);
64287
64283
  if (!currentUser || credentials.suid !== 0) {
64288
- terminal.writeln(chalk$1.red(kernel.i18n.t("Unauthorized")));
64284
+ terminal.writeln(chalk$1.red(kernel2.i18n.t("Unauthorized")));
64289
64285
  return 1;
64290
64286
  }
64291
- const user2 = Array.from(kernel.users.all.values()).find((user3) => user3.username === username);
64287
+ const user2 = Array.from(kernel2.users.all.values()).find((user3) => user3.username === username);
64292
64288
  if (!user2) {
64293
- terminal.writeln(chalk$1.red(kernel.i18n.t("User not found", { username })));
64289
+ terminal.writeln(chalk$1.red(kernel2.i18n.t("User not found", { username })));
64294
64290
  return 1;
64295
64291
  }
64296
64292
  Object.assign(credentials, {
@@ -64303,27 +64299,27 @@ const su = async ({ kernel, terminal, args }) => {
64303
64299
  });
64304
64300
  terminal.promptTemplate = `{user}:{cwd}${user2.uid === 0 ? "#" : "$"} `;
64305
64301
  };
64306
- const touch = async ({ kernel, shell, args }) => {
64302
+ const touch = async ({ kernel: kernel2, shell, args }) => {
64307
64303
  const target = args[0];
64308
64304
  const fullPath = target ? path.resolve(shell.cwd, target) : shell.cwd;
64309
- await kernel.filesystem.fs.appendFile(fullPath, "");
64305
+ await kernel2.filesystem.fs.appendFile(fullPath, "");
64310
64306
  };
64311
- const umount = async ({ kernel, shell, args }) => {
64307
+ const umount = async ({ kernel: kernel2, shell, args }) => {
64312
64308
  const target = args[0];
64313
64309
  const fullPath = target ? path.resolve(shell.cwd, target) : shell.cwd;
64314
64310
  console.log("umount", fullPath);
64315
- kernel.filesystem.fsSync.umount(fullPath);
64311
+ kernel2.filesystem.fsSync.umount(fullPath);
64316
64312
  };
64317
- const unzip = async ({ kernel, shell, terminal, args }) => {
64313
+ const unzip = async ({ kernel: kernel2, shell, terminal, args }) => {
64318
64314
  var _a3;
64319
64315
  const target = args[0];
64320
64316
  const fullPath = target ? path.resolve(shell.cwd, target) : shell.cwd;
64321
- const blob = new Blob([await kernel.filesystem.fs.readFile(fullPath)]);
64317
+ const blob = new Blob([await kernel2.filesystem.fs.readFile(fullPath)]);
64322
64318
  const zipReader = new ZipReader(new BlobReader(blob));
64323
64319
  for (const entry of await zipReader.getEntries()) {
64324
64320
  const entryPath = path.resolve(shell.cwd, entry.filename);
64325
64321
  if (entry.directory) {
64326
- await kernel.filesystem.fs.mkdir(entryPath);
64322
+ await kernel2.filesystem.fs.mkdir(entryPath);
64327
64323
  } else {
64328
64324
  const writer = new Uint8ArrayWriter();
64329
64325
  const data = await ((_a3 = entry.getData) == null ? void 0 : _a3.call(entry, writer));
@@ -64331,12 +64327,12 @@ const unzip = async ({ kernel, shell, terminal, args }) => {
64331
64327
  terminal.writeln(chalk$1.red(`Failed to read ${entryPath}`));
64332
64328
  return 1;
64333
64329
  }
64334
- await kernel.filesystem.fs.writeFile(entryPath, data);
64330
+ await kernel2.filesystem.fs.writeFile(entryPath, data);
64335
64331
  }
64336
64332
  }
64337
64333
  return 0;
64338
64334
  };
64339
- const upload = async ({ kernel, shell, terminal, args }) => {
64335
+ const upload = async ({ kernel: kernel2, shell, terminal, args }) => {
64340
64336
  const destination = path.resolve(args[0] || shell.cwd);
64341
64337
  if (!destination) {
64342
64338
  terminal.writeln(chalk$1.red("File path is required"));
@@ -64354,8 +64350,8 @@ const upload = async ({ kernel, shell, terminal, args }) => {
64354
64350
  reader.onload = async (event2) => {
64355
64351
  if (!event2.target) return terminal.writeln(chalk$1.red("No file selected"));
64356
64352
  const data = new Uint8Array(event2.target.result);
64357
- await kernel.filesystem.fs.writeFile(path.resolve(destination, file.name), data);
64358
- kernel.events.dispatch(KernelEvents.UPLOAD, { file: file.name, path: path.resolve(destination, file.name) });
64353
+ await kernel2.filesystem.fs.writeFile(path.resolve(destination, file.name), data);
64354
+ kernel2.events.dispatch(KernelEvents.UPLOAD, { file: file.name, path: path.resolve(destination, file.name) });
64359
64355
  };
64360
64356
  reader.readAsArrayBuffer(file);
64361
64357
  }
@@ -64363,7 +64359,7 @@ const upload = async ({ kernel, shell, terminal, args }) => {
64363
64359
  input.click();
64364
64360
  return 0;
64365
64361
  };
64366
- const user = async ({ kernel, shell, terminal, args }) => {
64362
+ const user = async ({ kernel: kernel2, shell, terminal, args }) => {
64367
64363
  var _a3, _b2;
64368
64364
  if (shell.credentials.suid !== 0) {
64369
64365
  terminal.writeln(chalk$1.red("Unauthorized"));
@@ -64383,7 +64379,7 @@ const user = async ({ kernel, shell, terminal, args }) => {
64383
64379
  }
64384
64380
  switch (command) {
64385
64381
  case "list": {
64386
- const users = Array.from(kernel.users.all.values());
64382
+ const users = Array.from(kernel2.users.all.values());
64387
64383
  const uidWidth = Math.max(3, ...users.map((u) => u.uid.toString().length));
64388
64384
  const usernameWidth = Math.max(8, ...users.map((u) => u.username.length));
64389
64385
  const gidWidth = Math.max(3, ...users.map((u) => {
@@ -64405,7 +64401,7 @@ const user = async ({ kernel, shell, terminal, args }) => {
64405
64401
  terminal.writeln(chalk$1.red("Username required"));
64406
64402
  return 1;
64407
64403
  }
64408
- if (Array.from(kernel.users.all.values()).some((u) => u.username === username)) {
64404
+ if (Array.from(kernel2.users.all.values()).some((u) => u.username === username)) {
64409
64405
  terminal.writeln(chalk$1.red(`User ${username} already exists`));
64410
64406
  return 1;
64411
64407
  }
@@ -64419,7 +64415,7 @@ const user = async ({ kernel, shell, terminal, args }) => {
64419
64415
  }
64420
64416
  }
64421
64417
  try {
64422
- await kernel.users.add({ username, password: userPassword });
64418
+ await kernel2.users.add({ username, password: userPassword });
64423
64419
  terminal.writeln(chalk$1.green(`User ${username} created successfully`));
64424
64420
  return 0;
64425
64421
  } catch (error) {
@@ -64432,7 +64428,7 @@ const user = async ({ kernel, shell, terminal, args }) => {
64432
64428
  terminal.writeln(chalk$1.red("Username required"));
64433
64429
  return 1;
64434
64430
  }
64435
- const user2 = Array.from(kernel.users.all.values()).find((u) => u.username === username);
64431
+ const user2 = Array.from(kernel2.users.all.values()).find((u) => u.username === username);
64436
64432
  if (!user2) {
64437
64433
  terminal.writeln(chalk$1.red(`User ${username} not found`));
64438
64434
  return 1;
@@ -64442,9 +64438,9 @@ const user = async ({ kernel, shell, terminal, args }) => {
64442
64438
  return 1;
64443
64439
  }
64444
64440
  try {
64445
- await kernel.users.remove(user2.uid);
64446
- await kernel.filesystem.fs.writeFile("/etc/passwd", (await kernel.filesystem.fs.readFile("/etc/passwd", "utf8")).split("\n").filter((line3) => !line3.startsWith(`${username}:`)).join("\n"));
64447
- await kernel.filesystem.fs.writeFile("/etc/shadow", (await kernel.filesystem.fs.readFile("/etc/shadow", "utf8")).split("\n").filter((line3) => !line3.startsWith(`${username}:`)).join("\n"));
64441
+ await kernel2.users.remove(user2.uid);
64442
+ await kernel2.filesystem.fs.writeFile("/etc/passwd", (await kernel2.filesystem.fs.readFile("/etc/passwd", "utf8")).split("\n").filter((line3) => !line3.startsWith(`${username}:`)).join("\n"));
64443
+ await kernel2.filesystem.fs.writeFile("/etc/shadow", (await kernel2.filesystem.fs.readFile("/etc/shadow", "utf8")).split("\n").filter((line3) => !line3.startsWith(`${username}:`)).join("\n"));
64448
64444
  terminal.writeln(chalk$1.green(`User ${username} deleted successfully`));
64449
64445
  return 0;
64450
64446
  } catch (error) {
@@ -64457,7 +64453,7 @@ const user = async ({ kernel, shell, terminal, args }) => {
64457
64453
  terminal.writeln(chalk$1.red("Username required"));
64458
64454
  return 1;
64459
64455
  }
64460
- const user2 = Array.from(kernel.users.all.values()).find((u) => u.username === username);
64456
+ const user2 = Array.from(kernel2.users.all.values()).find((u) => u.username === username);
64461
64457
  if (!user2) {
64462
64458
  terminal.writeln(chalk$1.red(`User ${username} not found`));
64463
64459
  return 1;
@@ -64469,7 +64465,7 @@ const user = async ({ kernel, shell, terminal, args }) => {
64469
64465
  return 1;
64470
64466
  }
64471
64467
  try {
64472
- await kernel.users.update(user2.uid, { password: newPassword });
64468
+ await kernel2.users.update(user2.uid, { password: newPassword });
64473
64469
  terminal.writeln(chalk$1.green(`Password updated for ${username}`));
64474
64470
  return 0;
64475
64471
  } catch (error) {
@@ -64482,10 +64478,10 @@ const user = async ({ kernel, shell, terminal, args }) => {
64482
64478
  return 1;
64483
64479
  }
64484
64480
  };
64485
- const video = async ({ kernel, shell, args }) => {
64481
+ const video = async ({ kernel: kernel2, shell, args }) => {
64486
64482
  const file = args[0];
64487
64483
  const fullPath = file ? path.resolve(shell.cwd, file) : shell.cwd;
64488
- const blob = new Blob([await kernel.filesystem.fs.readFile(fullPath)]);
64484
+ const blob = new Blob([await kernel2.filesystem.fs.readFile(fullPath)]);
64489
64485
  const url = URL.createObjectURL(blob);
64490
64486
  const video2 = document.createElement("video");
64491
64487
  video2.src = url;
@@ -64495,7 +64491,7 @@ const video = async ({ kernel, shell, args }) => {
64495
64491
  const { videoWidth, videoHeight } = video2;
64496
64492
  const { innerWidth, innerHeight } = window;
64497
64493
  const shouldMaximize = videoWidth > innerWidth || videoHeight > innerHeight;
64498
- kernel.windows.create({
64494
+ kernel2.windows.create({
64499
64495
  title: file,
64500
64496
  html: `<video src="${url}" autoplay controls style="width:100%;height:100%"></video>`,
64501
64497
  width: shouldMaximize ? innerWidth : videoWidth,
@@ -64503,7 +64499,7 @@ const video = async ({ kernel, shell, args }) => {
64503
64499
  maximized: shouldMaximize
64504
64500
  });
64505
64501
  };
64506
- const zip = async ({ kernel, shell, terminal, args }) => {
64502
+ const zip = async ({ kernel: kernel2, shell, terminal, args }) => {
64507
64503
  const [output, paths2 = []] = args;
64508
64504
  if (!output || paths2.length === 0) {
64509
64505
  terminal.writeln("Usage: zip <output> <paths...>");
@@ -64516,22 +64512,22 @@ const zip = async ({ kernel, shell, terminal, args }) => {
64516
64512
  for (const inputPath of paths2) {
64517
64513
  const fullPath = path.resolve(shell.cwd, inputPath);
64518
64514
  try {
64519
- const stat2 = await kernel.filesystem.fs.stat(fullPath);
64515
+ const stat2 = await kernel2.filesystem.fs.stat(fullPath);
64520
64516
  if (stat2.isFile()) {
64521
64517
  const relativePath = path.relative(shell.cwd, fullPath);
64522
- const fileData = await kernel.filesystem.fs.readFile(fullPath);
64518
+ const fileData = await kernel2.filesystem.fs.readFile(fullPath);
64523
64519
  const reader = new Uint8ArrayReader(fileData);
64524
64520
  await zipWriter.add(relativePath, reader);
64525
64521
  terminal.writeln(`Added file: ${relativePath}`);
64526
64522
  } else if (stat2.isDirectory()) {
64527
64523
  async function addDirectory(dirPath) {
64528
- const entries = await kernel.filesystem.fs.readdir(dirPath);
64524
+ const entries = await kernel2.filesystem.fs.readdir(dirPath);
64529
64525
  for (const entry of entries) {
64530
64526
  const entryPath = path.join(dirPath, entry);
64531
64527
  const relativePath = path.relative(shell.cwd, entryPath);
64532
- const entryStat = await kernel.filesystem.fs.stat(entryPath);
64528
+ const entryStat = await kernel2.filesystem.fs.stat(entryPath);
64533
64529
  if (entryStat.isFile()) {
64534
- const fileData = await kernel.filesystem.fs.readFile(entryPath);
64530
+ const fileData = await kernel2.filesystem.fs.readFile(entryPath);
64535
64531
  const reader = new Uint8ArrayReader(fileData);
64536
64532
  await (zipWriter == null ? void 0 : zipWriter.add(relativePath, reader));
64537
64533
  terminal.writeln(`Added file: ${relativePath}`);
@@ -64551,7 +64547,7 @@ const zip = async ({ kernel, shell, terminal, args }) => {
64551
64547
  }
64552
64548
  const blob = await zipWriter.close();
64553
64549
  zipWriter = null;
64554
- await kernel.filesystem.fs.writeFile(outputPath, new Uint8Array(await blob.arrayBuffer()));
64550
+ await kernel2.filesystem.fs.writeFile(outputPath, new Uint8Array(await blob.arrayBuffer()));
64555
64551
  terminal.writeln(`Created zip file: ${output}`);
64556
64552
  return 0;
64557
64553
  } catch (err2) {
@@ -68429,7 +68425,7 @@ class Shell {
68429
68425
  const finalCommand = await this.resolveCommand(commandName);
68430
68426
  if (!finalCommand) return -1;
68431
68427
  let inputStream = i === 0 ? this._terminal.getInputStream() : prevOutputStream;
68432
- const { env: env2, kernel } = this;
68428
+ const { env: env2, kernel: kernel2 } = this;
68433
68429
  for (const redirection of redirections) {
68434
68430
  if (redirection.type === "<") {
68435
68431
  const sourcePath = path.resolve(this.cwd, redirection.target);
@@ -68438,7 +68434,7 @@ class Shell {
68438
68434
  }
68439
68435
  inputStream = new ReadableStream({
68440
68436
  async start(controller) {
68441
- const fileHandle = await kernel.filesystem.fs.open(sourcePath, "r");
68437
+ const fileHandle = await kernel2.filesystem.fs.open(sourcePath, "r");
68442
68438
  const chunkSize = parseInt(env2.get("SHELL_INPUT_REDIRECTION_CHUNK_SIZE") || void 0 || "8192");
68443
68439
  const buffer2 = new Uint8Array(chunkSize);
68444
68440
  try {
@@ -68664,9 +68660,9 @@ class Users {
68664
68660
  */
68665
68661
  async load() {
68666
68662
  var _a3, _b2;
68667
- const { kernel } = this._options;
68668
- const passwd2 = await kernel.filesystem.fs.readFile("/etc/passwd", "utf-8");
68669
- const shadow = await kernel.filesystem.fs.readFile("/etc/shadow", "utf-8");
68663
+ const { kernel: kernel2 } = this._options;
68664
+ const passwd2 = await kernel2.filesystem.fs.readFile("/etc/passwd", "utf-8");
68665
+ const shadow = await kernel2.filesystem.fs.readFile("/etc/shadow", "utf-8");
68670
68666
  for (const line3 of passwd2.split("\n")) {
68671
68667
  if (line3.trim() === "" || line3.trim() === "\n" || line3.startsWith("#")) continue;
68672
68668
  const [username, uid, gid, home, shell] = line3.split(":");
@@ -68675,13 +68671,13 @@ class Users {
68675
68671
  if (shadowEntry) {
68676
68672
  const [, , , password, publicKey, encryptedPrivateKey] = shadowEntry.split(":");
68677
68673
  if (!publicKey || !encryptedPrivateKey) {
68678
- (_a3 = kernel.log) == null ? void 0 : _a3.warn(`User ${username} has no keypair`);
68674
+ (_a3 = kernel2.log) == null ? void 0 : _a3.warn(`User ${username} has no keypair`);
68679
68675
  continue;
68680
68676
  }
68681
68677
  const keypair = { publicKey: JSON.parse(atob(publicKey)), privateKey: encryptedPrivateKey };
68682
68678
  await this.add({ username, password, uid: parseInt(uid), gid: gid.split(",").map(Number), home, shell, keypair }, { noWrite: true, noHome: true, noHash: true });
68683
68679
  } else {
68684
- (_b2 = kernel.log) == null ? void 0 : _b2.warn(`User ${username} not found in /etc/shadow`);
68680
+ (_b2 = kernel2.log) == null ? void 0 : _b2.warn(`User ${username} not found in /etc/shadow`);
68685
68681
  }
68686
68682
  }
68687
68683
  }
@@ -68738,11 +68734,15 @@ class Users {
68738
68734
  }
68739
68735
  }
68740
68736
  class Wasm {
68741
- // private _wabt?: WabtModule
68742
68737
  constructor(options) {
68743
68738
  __publicField(this, "_kernel");
68739
+ __publicField(this, "_modules", /* @__PURE__ */ new Map());
68744
68740
  this._kernel = options.kernel;
68745
68741
  }
68742
+ // private _wabt?: WabtModule
68743
+ get modules() {
68744
+ return this._modules;
68745
+ }
68746
68746
  /**
68747
68747
  * Load an emscripten JS file compiled using -sSINGLE_FILE
68748
68748
  */
@@ -68752,6 +68752,20 @@ class Wasm {
68752
68752
  script.textContent = contents;
68753
68753
  document.head.appendChild(script);
68754
68754
  }
68755
+ /**
68756
+ * Load a WebAssembly module
68757
+ */
68758
+ async loadWasm(path2) {
68759
+ const importObject = {
68760
+ env: {
68761
+ log: console.log
68762
+ }
68763
+ };
68764
+ const wasm = await this._kernel.filesystem.fs.readFile(path2);
68765
+ const { module, instance: instance2 } = await WebAssembly.instantiate(wasm, importObject);
68766
+ this._modules.set(path2, { module, instance: instance2 });
68767
+ return { module, instance: instance2 };
68768
+ }
68755
68769
  }
68756
68770
  (function() {
68757
68771
  var e2, aa = document.createElement("style");
@@ -75936,7 +75950,7 @@ var createBIOS = (() => {
75936
75950
  return moduleRtn;
75937
75951
  };
75938
75952
  })();
75939
- const __vite_import_meta_env__ = { "AUTHOR": { "name": "Jay Mathis", "email": "code@mathis.network", "url": "https://github.com/mathiscode" }, "BASE_URL": "/", "DESCRIPTION": "ecmaOS: Micro-kernel and framework for web technologies", "DEV": false, "HOMEPAGE": "https://ecmaos.sh", "KNOWN_ISSUES": ["Don't expect any sort of POSIX compliance at this stage", "Most commands/devices are very basic implementations, not complete reproductions", "stdin/stdout/stderr streams and redirection can be wonky and don't work everywhere, but are coming along", "Newly created files on any IndexedDB-backed filesystem are not readable until the kernel is restarted", "Lots of unfinished work; watch your step"], "MODE": "production", "NAME": "@ecmaos/kernel", "PROD": true, "REPOSITORY": "https://github.com/ecmaos/ecmaos", "SSR": false, "TIPS": ["You can 'run' some devices that offer a CLI - for example, '/dev/battery --help'"], "VERSION": "0.1.0", "VITE_APP_SHOW_DEFAULT_LOGIN": "true", "VITE_PORT": "30443" };
75953
+ const __vite_import_meta_env__ = { "AUTHOR": { "name": "Jay Mathis", "email": "code@mathis.network", "url": "https://github.com/mathiscode" }, "BASE_URL": "/", "DESCRIPTION": "ecmaOS: Micro-kernel and framework for web technologies", "DEV": false, "HOMEPAGE": "https://ecmaos.sh", "KNOWN_ISSUES": ["Don't expect any sort of POSIX compliance at this stage", "Most commands/devices are very basic implementations, not complete reproductions", "stdin/stdout/stderr streams and redirection can be wonky and don't work everywhere, but are coming along", "Newly created files on any IndexedDB-backed filesystem are not readable until the kernel is restarted", "Lots of unfinished work; watch your step"], "MODE": "production", "NAME": "@ecmaos/kernel", "PROD": true, "REPOSITORY": "https://github.com/ecmaos/ecmaos", "SSR": false, "TIPS": ["You can 'run' some devices that offer a CLI - for example, '/dev/battery --help'"], "VERSION": "0.1.2", "VITE_APP_SHOW_DEFAULT_LOGIN": "true", "VITE_KERNEL_INTERVALS_PROC": "1000", "VITE_KERNEL_MODULES": "http://localhost:3000/build/release.js", "VITE_METAL_SOCKET": "ws://localhost:30445/socket", "VITE_PORT": "30443" };
75940
75954
  var define_import_meta_env_AUTHOR_default = { name: "Jay Mathis", email: "code@mathis.network", url: "https://github.com/mathiscode" };
75941
75955
  var define_import_meta_env_KNOWN_ISSUES_default = ["Don't expect any sort of POSIX compliance at this stage", "Most commands/devices are very basic implementations, not complete reproductions", "stdin/stdout/stderr streams and redirection can be wonky and don't work everywhere, but are coming along", "Newly created files on any IndexedDB-backed filesystem are not readable until the kernel is restarted", "Lots of unfinished work; watch your step"];
75942
75956
  var define_import_meta_env_TIPS_default = ["You can 'run' some devices that offer a CLI - for example, '/dev/battery --help'"];
@@ -75975,36 +75989,69 @@ const DefaultFigletFonts = [
75975
75989
  ];
75976
75990
  class Kernel {
75977
75991
  constructor(_options = DefaultKernelOptions) {
75992
+ /** Unique identifier for this kernel instance */
75978
75993
  __publicField(this, "id", crypto.randomUUID());
75994
+ /** Name of the kernel */
75979
75995
  __publicField(this, "name", "@ecmaos/kernel");
75980
- __publicField(this, "version", "0.1.0");
75996
+ /** Version string of the kernel */
75997
+ __publicField(this, "version", "0.1.2");
75998
+ /** Authentication and authorization service */
75981
75999
  __publicField(this, "auth");
76000
+ /** BIOS module providing low-level functionality */
75982
76001
  __publicField(this, "bios");
76002
+ /** Broadcast channel for inter-kernel communication */
75983
76003
  __publicField(this, "channel");
76004
+ /** Web Components manager */
75984
76005
  __publicField(this, "components");
76006
+ /** DOM manipulation service */
75985
76007
  __publicField(this, "dom");
76008
+ /** Map of registered devices and their drivers */
75986
76009
  __publicField(this, "devices", /* @__PURE__ */ new Map());
76010
+ /** Event management system */
75987
76011
  __publicField(this, "events");
76012
+ /** Virtual filesystem */
75988
76013
  __publicField(this, "filesystem");
76014
+ /** Internationalization service */
75989
76015
  __publicField(this, "i18n");
76016
+ /** Interval management service */
75990
76017
  __publicField(this, "intervals");
76018
+ /** Keyboard interface */
75991
76019
  __publicField(this, "keyboard");
76020
+ /** Logging system, null if disabled */
75992
76021
  __publicField(this, "log");
76022
+ /** Memory management service */
75993
76023
  __publicField(this, "memory");
76024
+ /** Map of loaded modules */
76025
+ __publicField(this, "modules", /* @__PURE__ */ new Map());
76026
+ /** Configuration options passed to the kernel */
75994
76027
  __publicField(this, "options");
76028
+ /** Map of loaded packages */
75995
76029
  __publicField(this, "packages", /* @__PURE__ */ new Map());
76030
+ /** Process management service */
75996
76031
  __publicField(this, "processes");
76032
+ /** Protocol handler service */
75997
76033
  __publicField(this, "protocol");
76034
+ /** Map of available screensavers */
75998
76035
  __publicField(this, "screensavers");
76036
+ /** Service management system */
75999
76037
  __publicField(this, "service");
76038
+ /** Shell for command interpretation and execution */
76000
76039
  __publicField(this, "shell");
76040
+ /** Storage provider interface */
76001
76041
  __publicField(this, "storage");
76042
+ /** Terminal interface for user interaction */
76002
76043
  __publicField(this, "terminal");
76044
+ /** Toast notification service */
76003
76045
  __publicField(this, "toast");
76046
+ /** User management service */
76004
76047
  __publicField(this, "users");
76048
+ /** WebAssembly service */
76005
76049
  __publicField(this, "wasm");
76050
+ /** Window management service */
76006
76051
  __publicField(this, "windows");
76052
+ /** Web Worker management service */
76007
76053
  __publicField(this, "workers");
76054
+ /** Current state of the kernel */
76008
76055
  __publicField(this, "_state", KernelState.BOOTING);
76009
76056
  this.options = { ...DefaultKernelOptions, ..._options };
76010
76057
  this.auth = new Auth();
@@ -76019,6 +76066,7 @@ class Kernel {
76019
76066
  this.keyboard = navigator.keyboard;
76020
76067
  this.log = this.options.log ? new Log(this.options.log) : null;
76021
76068
  this.memory = new Memory();
76069
+ this.modules = /* @__PURE__ */ new Map();
76022
76070
  this.processes = new ProcessManager();
76023
76071
  this.protocol = new Protocol({ kernel: this });
76024
76072
  this.screensavers = /* @__PURE__ */ new Map();
@@ -76040,9 +76088,11 @@ class Kernel {
76040
76088
  get state() {
76041
76089
  return this._state;
76042
76090
  }
76091
+ /** Add an event listener; alias for `events.on` */
76043
76092
  get addEventListener() {
76044
76093
  return this.events.on;
76045
76094
  }
76095
+ /** Remove an event listener; alias for `events.off` */
76046
76096
  get removeEventListener() {
76047
76097
  return this.events.off;
76048
76098
  }
@@ -76052,7 +76102,7 @@ class Kernel {
76052
76102
  * @throws {Error} If boot process fails
76053
76103
  */
76054
76104
  async boot(options = DefaultBootOptions) {
76055
- var _a3, _b2, _c, _d, _e, _f;
76105
+ var _a3, _b2, _c, _d, _e, _f, _g, _h, _i, _j;
76056
76106
  let spinner;
76057
76107
  const t2 = this.i18n.i18next.getFixedT(this.i18n.language, "kernel");
76058
76108
  try {
@@ -76098,7 +76148,7 @@ class Kernel {
76098
76148
  figlet.parseFont(figletFont || "Poison", loadedFont.default);
76099
76149
  const logoFiglet = figlet.textSync(__vite_import_meta_env__["FIGLET_TEXT"] || "ECMAOS", { font: figletFont });
76100
76150
  this.terminal.writeln(colorFiglet(figletColor, logoFiglet));
76101
- this.terminal.writeln(`${this.terminal.createSpecialLink("https://ecmaos.sh", "@ecmaos/kernel")} v${"0.1.0"}`);
76151
+ this.terminal.writeln(`${this.terminal.createSpecialLink("https://ecmaos.sh", "@ecmaos/kernel")} v${"0.1.2"}`);
76102
76152
  this.terminal.writeln(`${t2("kernel.madeBy")} ${this.terminal.createSpecialLink(
76103
76153
  (define_import_meta_env_AUTHOR_default == null ? void 0 : define_import_meta_env_AUTHOR_default.url) || "https://github.com/mathiscode",
76104
76154
  `${define_import_meta_env_AUTHOR_default == null ? void 0 : define_import_meta_env_AUTHOR_default.name} <${define_import_meta_env_AUTHOR_default == null ? void 0 : define_import_meta_env_AUTHOR_default.email}>`
@@ -76116,14 +76166,14 @@ class Kernel {
76116
76166
  spinner = this.terminal.spinner("arrow3", chalk$1.yellow(this.i18n.t("Booting")));
76117
76167
  spinner.start();
76118
76168
  console.log(`%c${logoFiglet}`, "color: green");
76119
- console.log("%chttps://github.com/ecmaos/kernel", "color: blue; text-decoration: underline; font-size: 16px");
76120
- this.log.info(`${"@ecmaos/kernel"} v${"0.1.0"}`);
76169
+ console.log(`%c${"https://github.com/ecmaos/ecmaos"}`, "color: blue; text-decoration: underline; font-size: 16px");
76170
+ this.log.info(`${"@ecmaos/kernel"} v${"0.1.2"}`);
76121
76171
  if ((Notification == null ? void 0 : Notification.permission) === "default") Notification.requestPermission();
76122
76172
  if ((Notification == null ? void 0 : Notification.permission) === "denied") (_b2 = this.log) == null ? void 0 : _b2.warn(t2("kernel.permissionNotificationDenied"));
76123
76173
  this.intervals.set("title-blink", () => {
76124
76174
  globalThis.document.title = globalThis.document.title.includes("_") ? "ecmaos# " : "ecmaos# _";
76125
76175
  }, 600);
76126
- this.toast.success(`${"@ecmaos/kernel"} v${"0.1.0"}`);
76176
+ this.toast.success(`${"@ecmaos/kernel"} v${"0.1.2"}`);
76127
76177
  }
76128
76178
  await this.configure({ filesystem: Filesystem.options() });
76129
76179
  const requiredPaths = [
@@ -76195,12 +76245,27 @@ class Kernel {
76195
76245
  await this.registerCommands();
76196
76246
  await this.registerProc();
76197
76247
  await this.registerPackages();
76198
- this.intervals.set("/proc", this.registerProc.bind(this), __vite_import_meta_env__["KERNEL_INTERVALS_PROC"] ?? 1e3);
76248
+ this.intervals.set("/proc", this.registerProc.bind(this), "1000");
76249
+ const modules = "http://localhost:3000/build/release.js";
76250
+ if (modules) {
76251
+ const mods = modules.split(",");
76252
+ for (const mod of mods) {
76253
+ (_d = this.log) == null ? void 0 : _d.info(`Loading module ${mod}`);
76254
+ try {
76255
+ const module = await import(mod);
76256
+ const name = ((_e = module.name) == null ? void 0 : _e.value) || mod;
76257
+ (_f = module.init) == null ? void 0 : _f.call(module, this.id);
76258
+ this.modules.set(name, module);
76259
+ } catch (error) {
76260
+ (_g = this.log) == null ? void 0 : _g.error(`Failed to load module ${mod}: ${error.message}`);
76261
+ }
76262
+ }
76263
+ }
76199
76264
  try {
76200
76265
  if (!await this.filesystem.fs.exists("/etc/passwd")) await this.users.add({ username: "root", password: "root", home: "/root" }, { noHome: true });
76201
76266
  else await this.users.load();
76202
76267
  } catch (err2) {
76203
- (_d = this.log) == null ? void 0 : _d.error(err2);
76268
+ (_h = this.log) == null ? void 0 : _h.error(err2);
76204
76269
  this.terminal.writeln(chalk$1.red(err2.message));
76205
76270
  throw err2;
76206
76271
  }
@@ -76210,12 +76275,23 @@ class Kernel {
76210
76275
  Object.assign(credentials, cred);
76211
76276
  } else {
76212
76277
  if (true) this.terminal.writeln("Default Login: root / root\n");
76278
+ this.terminal.writeln(`${Intl.DateTimeFormat(this.memory.config.get("locale") || "en-US", {
76279
+ year: "numeric",
76280
+ month: "2-digit",
76281
+ day: "2-digit",
76282
+ hour: "2-digit",
76283
+ minute: "2-digit",
76284
+ second: "2-digit"
76285
+ }).format(/* @__PURE__ */ new Date())}`);
76286
+ const issue = await this.filesystem.fs.exists("/etc/issue") ? await this.filesystem.fs.readFile("/etc/issue", "utf-8") : null;
76287
+ if (issue) this.terminal.writeln(issue);
76213
76288
  while (true) {
76214
76289
  try {
76215
76290
  const username = await this.terminal.readline(`👤 ${this.i18n.t("Username")}: `);
76216
76291
  const password = await this.terminal.readline(`🔒 ${this.i18n.t("Password")}: `, true);
76217
76292
  const { cred } = await this.users.login(username, password);
76218
76293
  Object.assign(credentials, cred);
76294
+ this.shell.credentials = cred;
76219
76295
  break;
76220
76296
  } catch (err2) {
76221
76297
  console.error(err2);
@@ -76223,6 +76299,8 @@ class Kernel {
76223
76299
  }
76224
76300
  }
76225
76301
  }
76302
+ const motd = await this.filesystem.fs.exists("/etc/motd") ? await this.filesystem.fs.readFile("/etc/motd", "utf-8") : null;
76303
+ if (motd) this.terminal.writeln("\n" + motd);
76226
76304
  const user2 = this.users.get(credentials.uid ?? 0);
76227
76305
  if (!user2) throw new Error(t2("kernel.userNotFound"));
76228
76306
  this.shell.cwd = user2.uid === 0 ? "/" : user2.home || "/";
@@ -76257,7 +76335,7 @@ class Kernel {
76257
76335
  args: [],
76258
76336
  command: "init",
76259
76337
  uid: user2.uid,
76260
- gid: ((_e = user2.gid) == null ? void 0 : _e[0]) ?? 0,
76338
+ gid: ((_i = user2.gid) == null ? void 0 : _i[0]) ?? 0,
76261
76339
  kernel: this,
76262
76340
  shell: this.shell,
76263
76341
  terminal: this.terminal,
@@ -76269,7 +76347,7 @@ class Kernel {
76269
76347
  this.terminal.focus();
76270
76348
  this.terminal.listen();
76271
76349
  } catch (error) {
76272
- (_f = this.log) == null ? void 0 : _f.error(error);
76350
+ (_j = this.log) == null ? void 0 : _j.error(error);
76273
76351
  this._state = KernelState.PANIC;
76274
76352
  this.events.dispatch(KernelEvents.PANIC, { error });
76275
76353
  this.toast.error({
@@ -76593,7 +76671,7 @@ class Kernel {
76593
76671
  memory: "?",
76594
76672
  platform: ((_a3 = navigator.userAgentData) == null ? void 0 : _a3.platform) || (navigator == null ? void 0 : navigator.platform) || navigator.userAgent,
76595
76673
  querystring: location.search,
76596
- version: `${"@ecmaos/kernel"} ${"0.1.0"}`,
76674
+ version: `${"@ecmaos/kernel"} ${"0.1.2"}`,
76597
76675
  language: navigator.language,
76598
76676
  host: location.host,
76599
76677
  userAgent: navigator.userAgent,
@@ -76647,14 +76725,19 @@ class Kernel {
76647
76725
  }
76648
76726
  }
76649
76727
  }
76650
- globalThis.kernel = new Kernel({
76728
+ const socket = "ws://localhost:30445/socket";
76729
+ const kernel = new Kernel({
76651
76730
  credentials: void 0,
76652
76731
  dom: { topbar: true },
76653
76732
  log: { name: `ecmaos:${"kernel"}` },
76654
- socket: new WebSocket("ws://localhost:30445/socket")
76733
+ socket: new WebSocket(socket)
76655
76734
  });
76656
- globalThis.kernel.terminal.mount(document.getElementById("terminal"));
76657
- globalThis.kernel.boot({ silent: false, figletFontRandom: false });
76735
+ globalThis.kernels = globalThis.kernels || /* @__PURE__ */ new Map();
76736
+ globalThis.kernels.set(kernel.id, kernel);
76737
+ const primaryKernel = globalThis.kernels.values().next().value;
76738
+ globalThis.kernel = primaryKernel;
76739
+ kernel.terminal.mount(document.getElementById("terminal"));
76740
+ kernel.boot({ silent: false, figletFontRandom: false });
76658
76741
  const __viteBrowserExternal = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
76659
76742
  __proto__: null
76660
76743
  }, Symbol.toStringTag, { value: "Module" }));
@@ -76664,4 +76747,4 @@ const empty = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.definePropert
76664
76747
  export {
76665
76748
  getDefaultExportFromCjs$2 as g
76666
76749
  };
76667
- //# sourceMappingURL=index-DUVr2hDS.js.map
76750
+ //# sourceMappingURL=index-BOrpzH3-.js.map