@lifo-sh/core 0.2.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (117) hide show
  1. package/dist/awk-CI8X5kVy.js +123 -0
  2. package/dist/{basename-C2v8jn7p.js → basename-D8VowKZK.js} +1 -1
  3. package/dist/{cat-B2exoWlk.js → cat-BPj_LHfi.js} +1 -1
  4. package/dist/{chmod-CQS63aP7.js → chmod-pNQSdBnq.js} +1 -1
  5. package/dist/{chown-rgGwZwu9.js → chown-BzpeyVqg.js} +1 -1
  6. package/dist/commands/system/lifo.d.ts +11 -0
  7. package/dist/commands/system/lifo.d.ts.map +1 -0
  8. package/dist/commands/system/node.d.ts.map +1 -1
  9. package/dist/commands/system/npm.d.ts +5 -0
  10. package/dist/commands/system/npm.d.ts.map +1 -0
  11. package/dist/commands/text/awk.d.ts.map +1 -1
  12. package/dist/commands/text/cut.d.ts.map +1 -1
  13. package/dist/commands/text/diff.d.ts.map +1 -1
  14. package/dist/commands/text/grep.d.ts.map +1 -1
  15. package/dist/commands/text/head.d.ts.map +1 -1
  16. package/dist/commands/text/nl.d.ts.map +1 -1
  17. package/dist/commands/text/rev.d.ts.map +1 -1
  18. package/dist/commands/text/sed.d.ts.map +1 -1
  19. package/dist/commands/text/sort.d.ts.map +1 -1
  20. package/dist/commands/text/tail.d.ts.map +1 -1
  21. package/dist/commands/text/uniq.d.ts.map +1 -1
  22. package/dist/commands/text/wc.d.ts.map +1 -1
  23. package/dist/{cp-C8mNek36.js → cp-_rhci8W9.js} +1 -1
  24. package/dist/cut-Q5nQyrUo.js +65 -0
  25. package/dist/diff-Dvc96Xgm.js +150 -0
  26. package/dist/{dirname-BY_Gu5i2.js → dirname-B9Rm-O9I.js} +1 -1
  27. package/dist/{du-D25egSeK.js → du-Cv4zAsqm.js} +1 -1
  28. package/dist/{file-BPs1dqg5.js → file-Cxgmm1Vo.js} +1 -1
  29. package/dist/{find-CRUAXbhO.js → find-BJNOna6S.js} +1 -1
  30. package/dist/{grep-B9pTCSNY.js → grep-vdjjGK6g.js} +33 -26
  31. package/dist/gunzip-AmY9PUj2.js +47 -0
  32. package/dist/{gzip-DgE-9PzE.js → gzip-C_08tX3p.js} +4 -5
  33. package/dist/head-DGXxKqPE.js +53 -0
  34. package/dist/index-CvsPTm3-.js +8450 -0
  35. package/dist/index.d.ts +17 -4
  36. package/dist/index.d.ts.map +1 -1
  37. package/dist/index.js +69 -44
  38. package/dist/kernel/index.d.ts +2 -1
  39. package/dist/kernel/index.d.ts.map +1 -1
  40. package/dist/kernel/persistence/PersistenceManager.d.ts +3 -1
  41. package/dist/kernel/persistence/PersistenceManager.d.ts.map +1 -1
  42. package/dist/kernel/persistence/backends.d.ts +22 -0
  43. package/dist/kernel/persistence/backends.d.ts.map +1 -0
  44. package/dist/kernel/persistence/index.d.ts +6 -0
  45. package/dist/kernel/persistence/index.d.ts.map +1 -0
  46. package/dist/kernel/persistence/serializer.d.ts +8 -0
  47. package/dist/kernel/persistence/serializer.d.ts.map +1 -1
  48. package/dist/kernel/storage/BlobStore.d.ts +31 -0
  49. package/dist/kernel/storage/BlobStore.d.ts.map +1 -0
  50. package/dist/kernel/storage/ContentStore.d.ts +52 -0
  51. package/dist/kernel/storage/ContentStore.d.ts.map +1 -0
  52. package/dist/kernel/storage/index.d.ts +7 -0
  53. package/dist/kernel/storage/index.d.ts.map +1 -0
  54. package/dist/kernel/vfs/VFS.d.ts +31 -3
  55. package/dist/kernel/vfs/VFS.d.ts.map +1 -1
  56. package/dist/kernel/vfs/index.d.ts +4 -1
  57. package/dist/kernel/vfs/index.d.ts.map +1 -1
  58. package/dist/kernel/vfs/providers/NativeFsProvider.d.ts +63 -0
  59. package/dist/kernel/vfs/providers/NativeFsProvider.d.ts.map +1 -0
  60. package/dist/kernel/vfs/types.d.ts +27 -0
  61. package/dist/kernel/vfs/types.d.ts.map +1 -1
  62. package/dist/{ls-BiT10kLm.js → ls-BOMe19Ls.js} +1 -1
  63. package/dist/{mkdir-DgzJ2JLj.js → mkdir-DE5ZBdl1.js} +1 -1
  64. package/dist/{mktemp-Sh5DWxvc.js → mktemp-De1K5WCb.js} +1 -1
  65. package/dist/{mv-Kp6DjQ8n.js → mv-Cw8pg9wR.js} +1 -1
  66. package/dist/{nl-DBLFdpfC.js → nl-C-osPl2N.js} +13 -10
  67. package/dist/node-compat/buffer.d.ts +29 -2
  68. package/dist/node-compat/buffer.d.ts.map +1 -1
  69. package/dist/node-compat/fs.d.ts +62 -0
  70. package/dist/node-compat/fs.d.ts.map +1 -1
  71. package/dist/node-compat/index.d.ts.map +1 -1
  72. package/dist/node-compat/string_decoder.d.ts +11 -0
  73. package/dist/node-compat/string_decoder.d.ts.map +1 -0
  74. package/dist/node-compat/zlib.d.ts +66 -0
  75. package/dist/node-compat/zlib.d.ts.map +1 -0
  76. package/dist/pkg/lifo-dev.d.ts +32 -0
  77. package/dist/pkg/lifo-dev.d.ts.map +1 -0
  78. package/dist/pkg/lifo-runtime.d.ts +35 -0
  79. package/dist/pkg/lifo-runtime.d.ts.map +1 -0
  80. package/dist/{realpath-BOeYN6nD.js → realpath-BSWdZLjf.js} +1 -1
  81. package/dist/rev-3C5MtCkc.js +39 -0
  82. package/dist/{rm-DA2w3xTR.js → rm-CR560cHz.js} +1 -1
  83. package/dist/{rmdir-BiGbNDOT.js → rmdir-BO4Jz3r5.js} +3 -3
  84. package/dist/sandbox/Sandbox.d.ts +31 -0
  85. package/dist/sandbox/Sandbox.d.ts.map +1 -1
  86. package/dist/sandbox/SandboxFs.d.ts +4 -0
  87. package/dist/sandbox/SandboxFs.d.ts.map +1 -1
  88. package/dist/sandbox/types.d.ts +19 -0
  89. package/dist/sandbox/types.d.ts.map +1 -1
  90. package/dist/sed-DCUgJWcA.js +95 -0
  91. package/dist/{sort-CSzSGTdB.js → sort-or-F_iEY.js} +19 -14
  92. package/dist/{stat-D0i1gTKB.js → stat-MGHvbiS7.js} +1 -1
  93. package/dist/tail-DheqHGe2.js +52 -0
  94. package/dist/{tar-DkyzTzmT.js → tar-DhLtWtBV.js} +15 -16
  95. package/dist/{tee-RqoZ3qG-.js → tee-D47GOzfR.js} +1 -1
  96. package/dist/{touch-k2NomRzL.js → touch-D7Xd2vNM.js} +1 -1
  97. package/dist/{tree-B_j2_PsZ.js → tree-CRpLFDhe.js} +1 -1
  98. package/dist/uniq-DwHCe--v.js +54 -0
  99. package/dist/{unzip-FwYCTDEZ.js → unzip-DPEg74Aq.js} +18 -19
  100. package/dist/utils/mime.d.ts +4 -0
  101. package/dist/utils/mime.d.ts.map +1 -0
  102. package/dist/wc-BUIoLfSN.js +69 -0
  103. package/dist/{wget-2NAABIHc.js → wget-BwmpusXQ.js} +1 -1
  104. package/dist/{zip--0ncHv0q.js → zip-B4jRyQ7B.js} +11 -12
  105. package/package.json +10 -9
  106. package/dist/archive-nRHWNwjH.js +0 -192
  107. package/dist/awk-CchAsBzt.js +0 -118
  108. package/dist/cut-BZez9bS1.js +0 -60
  109. package/dist/diff-tWPvmikU.js +0 -129
  110. package/dist/gunzip-BYlJhPf7.js +0 -48
  111. package/dist/head-DzP_T5Wx.js +0 -48
  112. package/dist/index-DccAPaZF.js +0 -6010
  113. package/dist/rev-CWRUIXWp.js +0 -34
  114. package/dist/sed-ClWZ06zX.js +0 -90
  115. package/dist/tail-tcIJLQnB.js +0 -47
  116. package/dist/uniq-hzJnHQOm.js +0 -51
  117. package/dist/wc-Jp7nOops.js +0 -60
@@ -0,0 +1,95 @@
1
+ import { r as c, i as g, c as h, V as m } from "./index-CvsPTm3-.js";
2
+ function w(e) {
3
+ if (e === "d")
4
+ return { type: "d" };
5
+ if (e === "p")
6
+ return { type: "p" };
7
+ if (e.startsWith("s")) {
8
+ const p = e[1];
9
+ if (!p) return null;
10
+ const n = [];
11
+ let l = "", f = !1;
12
+ for (let r = 2; r < e.length; r++)
13
+ f ? (l += e[r], f = !1) : e[r] === "\\" ? (f = !0, l += "\\") : e[r] === p ? (n.push(l), l = "") : l += e[r];
14
+ if (n.push(l), n.length < 2) return null;
15
+ const u = n[0], d = n[1], s = n[2] || "", t = s.includes("g"), i = s.includes("i");
16
+ let o;
17
+ try {
18
+ let r = "";
19
+ t && (r += "g"), i && (r += "i"), o = new RegExp(u, r);
20
+ } catch {
21
+ return null;
22
+ }
23
+ return { type: "s", pattern: o, replacement: d, global: t };
24
+ }
25
+ return null;
26
+ }
27
+ const v = async (e) => {
28
+ let p = !1;
29
+ const n = [], l = [];
30
+ for (let s = 0; s < e.args.length; s++) {
31
+ const t = e.args[s];
32
+ t === "-i" ? p = !0 : t === "-e" && s + 1 < e.args.length ? n.push(e.args[++s]) : n.length === 0 && !t.startsWith("-") ? n.push(t) : l.push(t);
33
+ }
34
+ if (n.length === 0)
35
+ return e.stderr.write(`sed: missing expression
36
+ `), 1;
37
+ const f = [];
38
+ for (const s of n) {
39
+ const t = w(s);
40
+ if (!t)
41
+ return e.stderr.write(`sed: invalid expression: ${s}
42
+ `), 1;
43
+ f.push(t);
44
+ }
45
+ function u(s) {
46
+ const t = s.replace(/\n$/, "").split(`
47
+ `), i = [];
48
+ for (let o of t) {
49
+ let r = !1;
50
+ for (const a of f)
51
+ if (a.type === "s" && a.pattern && a.replacement !== void 0)
52
+ o = o.replace(a.pattern, a.replacement);
53
+ else if (a.type === "d") {
54
+ r = !0;
55
+ break;
56
+ } else a.type === "p" && i.push(o);
57
+ r || i.push(o);
58
+ }
59
+ return i.join(`
60
+ `) + `
61
+ `;
62
+ }
63
+ if (l.length === 0) {
64
+ if (e.stdin) {
65
+ const s = await e.stdin.readAll();
66
+ e.stdout.write(u(s));
67
+ } else
68
+ return e.stderr.write(`sed: missing file operand
69
+ `), 1;
70
+ return 0;
71
+ }
72
+ let d = 0;
73
+ for (const s of l) {
74
+ const t = c(e.cwd, s);
75
+ try {
76
+ if (e.vfs.stat(t), g(h(t))) {
77
+ e.stderr.write(`sed: ${s}: binary file, skipping
78
+ `);
79
+ continue;
80
+ }
81
+ const i = e.vfs.readFileString(t), o = u(i);
82
+ p ? e.vfs.writeFile(t, o) : e.stdout.write(o);
83
+ } catch (i) {
84
+ if (i instanceof m)
85
+ e.stderr.write(`sed: ${s}: ${i.message}
86
+ `), d = 1;
87
+ else
88
+ throw i;
89
+ }
90
+ }
91
+ return d;
92
+ };
93
+ export {
94
+ v as default
95
+ };
@@ -1,7 +1,7 @@
1
- import { r as p, V as h } from "./index-DccAPaZF.js";
2
- const k = async (s) => {
1
+ import { r as c, i as h, c as m, V as k } from "./index-CvsPTm3-.js";
2
+ const y = async (s) => {
3
3
  let f = !1, u = !1, g = !1, a = 0;
4
- const i = [];
4
+ const l = [];
5
5
  for (let e = 0; e < s.args.length; e++) {
6
6
  const r = s.args[e];
7
7
  if (r === "-k" && e + 1 < s.args.length)
@@ -20,40 +20,45 @@ const k = async (s) => {
20
20
  break;
21
21
  }
22
22
  else
23
- i.push(r);
23
+ l.push(r);
24
24
  }
25
25
  let o = "";
26
- if (i.length === 0)
26
+ if (l.length === 0)
27
27
  if (s.stdin)
28
28
  o = await s.stdin.readAll();
29
29
  else
30
30
  return s.stderr.write(`sort: missing file operand
31
31
  `), 1;
32
32
  else
33
- for (const e of i) {
34
- const r = p(s.cwd, e);
33
+ for (const e of l) {
34
+ const r = c(s.cwd, e);
35
35
  try {
36
+ if (s.vfs.stat(r), h(m(r))) {
37
+ s.stderr.write(`sort: ${e}: binary file, skipping
38
+ `);
39
+ continue;
40
+ }
36
41
  o += s.vfs.readFileString(r);
37
42
  } catch (t) {
38
- if (t instanceof h)
43
+ if (t instanceof k)
39
44
  return s.stderr.write(`sort: ${e}: ${t.message}
40
45
  `), 1;
41
46
  throw t;
42
47
  }
43
48
  }
44
- let l = o.replace(/\n$/, "").split(`
49
+ let i = o.replace(/\n$/, "").split(`
45
50
  `);
46
- function c(e) {
51
+ function p(e) {
47
52
  return a > 0 ? e.split(/\s+/)[a - 1] || "" : e;
48
53
  }
49
- return l.sort((e, r) => {
50
- const t = c(e), d = c(r);
54
+ return i.sort((e, r) => {
55
+ const t = p(e), d = p(r);
51
56
  let n;
52
57
  return u ? n = (parseFloat(t) || 0) - (parseFloat(d) || 0) : n = t.localeCompare(d), f ? -n : n;
53
- }), g && (l = l.filter((e, r) => r === 0 || e !== l[r - 1])), s.stdout.write(l.join(`
58
+ }), g && (i = i.filter((e, r) => r === 0 || e !== i[r - 1])), s.stdout.write(i.join(`
54
59
  `) + `
55
60
  `), 0;
56
61
  };
57
62
  export {
58
- k as default
63
+ y as default
59
64
  };
@@ -1,4 +1,4 @@
1
- import { r as n, V as d } from "./index-DccAPaZF.js";
1
+ import { r as n, V as d } from "./index-CvsPTm3-.js";
2
2
  const w = async (t) => {
3
3
  if (t.args.length === 0)
4
4
  return t.stderr.write(`stat: missing operand
@@ -0,0 +1,52 @@
1
+ import { r as o, i as f, c as d, V as g } from "./index-CvsPTm3-.js";
2
+ const u = async (e) => {
3
+ let n = 10;
4
+ const r = [];
5
+ for (let i = 0; i < e.args.length; i++) {
6
+ const s = e.args[i];
7
+ if (s === "-n" && i + 1 < e.args.length) {
8
+ if (n = parseInt(e.args[++i], 10), isNaN(n))
9
+ return e.stderr.write(`tail: invalid number of lines
10
+ `), 1;
11
+ } else /^-\d+$/.test(s) ? n = parseInt(s.slice(1), 10) : r.push(s);
12
+ }
13
+ async function a(i) {
14
+ const t = i.replace(/\n$/, "").split(`
15
+ `).slice(-n);
16
+ e.stdout.write(t.join(`
17
+ `) + `
18
+ `);
19
+ }
20
+ if (r.length === 0) {
21
+ if (e.stdin)
22
+ await a(await e.stdin.readAll());
23
+ else
24
+ return e.stderr.write(`tail: missing file operand
25
+ `), 1;
26
+ return 0;
27
+ }
28
+ let l = 0;
29
+ for (const i of r) {
30
+ const s = o(e.cwd, i);
31
+ try {
32
+ if (e.vfs.stat(s), f(d(s))) {
33
+ e.stderr.write(`tail: ${i}: binary file, skipping
34
+ `);
35
+ continue;
36
+ }
37
+ const t = e.vfs.readFileString(s);
38
+ r.length > 1 && e.stdout.write(`==> ${i} <==
39
+ `), await a(t);
40
+ } catch (t) {
41
+ if (t instanceof g)
42
+ e.stderr.write(`tail: ${i}: ${t.message}
43
+ `), l = 1;
44
+ else
45
+ throw t;
46
+ }
47
+ }
48
+ return l;
49
+ };
50
+ export {
51
+ u as default
52
+ };
@@ -1,6 +1,5 @@
1
- import { r as v, d as b, V as F } from "./index-DccAPaZF.js";
2
- import { c as z, a as $, b as C, d as m, p as y } from "./archive-nRHWNwjH.js";
3
- const P = async (e) => {
1
+ import { r as p, d as b, f as F, h as z, j as y, p as m, k as $, V as C } from "./index-CvsPTm3-.js";
2
+ const D = async (e) => {
4
3
  let f = !1, l = !1, c = !1, n = !1, d = !1, u = "", o = "";
5
4
  const h = [];
6
5
  let a = 0;
@@ -61,36 +60,36 @@ const P = async (e) => {
61
60
  if (!u)
62
61
  return e.stderr.write(`tar: -f is required
63
62
  `), 1;
64
- const w = v(e.cwd, u), p = o ? v(e.cwd, o) : e.cwd;
63
+ const w = p(e.cwd, u), v = o ? p(e.cwd, o) : e.cwd;
65
64
  try {
66
65
  if (f) {
67
66
  if (h.length === 0)
68
67
  return e.stderr.write(`tar: no files to archive
69
68
  `), 1;
70
- const r = z(e.vfs, p, h);
71
- let s = $(r);
72
- if (n && (s = await C(s)), e.vfs.writeFile(w, s), d)
69
+ const r = b(e.vfs, v, h);
70
+ let s = F(r);
71
+ if (n && (s = await z(s)), e.vfs.writeFile(w, s), d)
73
72
  for (const t of r)
74
73
  e.stdout.write(`${t.path}
75
74
  `);
76
75
  } else if (l) {
77
76
  let r = e.vfs.readFile(w);
78
- n && (r = await m(r));
79
- const s = y(r);
77
+ n && (r = await y(r));
78
+ const s = m(r);
80
79
  if (o)
81
80
  try {
82
- e.vfs.mkdir(p, { recursive: !0 });
81
+ e.vfs.mkdir(v, { recursive: !0 });
83
82
  } catch {
84
83
  }
85
84
  for (const t of s) {
86
- const i = v(p, t.path);
85
+ const i = p(v, t.path);
87
86
  if (t.type === "directory")
88
87
  try {
89
88
  e.vfs.mkdir(i, { recursive: !0 });
90
89
  } catch {
91
90
  }
92
91
  else {
93
- const k = b(i);
92
+ const k = $(i);
94
93
  try {
95
94
  e.vfs.mkdir(k, { recursive: !0 });
96
95
  } catch {
@@ -102,14 +101,14 @@ const P = async (e) => {
102
101
  }
103
102
  } else if (c) {
104
103
  let r = e.vfs.readFile(w);
105
- n && (r = await m(r));
106
- const s = y(r);
104
+ n && (r = await y(r));
105
+ const s = m(r);
107
106
  for (const t of s)
108
107
  e.stdout.write(`${t.path}${t.type === "directory" ? "/" : ""}
109
108
  `);
110
109
  }
111
110
  } catch (r) {
112
- if (r instanceof F)
111
+ if (r instanceof C)
113
112
  return e.stderr.write(`tar: ${r.message}
114
113
  `), 2;
115
114
  throw r;
@@ -117,5 +116,5 @@ const P = async (e) => {
117
116
  return 0;
118
117
  };
119
118
  export {
120
- P as default
119
+ D as default
121
120
  };
@@ -1,4 +1,4 @@
1
- import { r as f } from "./index-DccAPaZF.js";
1
+ import { r as f } from "./index-CvsPTm3-.js";
2
2
  const l = async (e) => {
3
3
  let a = !1;
4
4
  const o = [];
@@ -1,4 +1,4 @@
1
- import { r as a, V as n } from "./index-DccAPaZF.js";
1
+ import { r as a, V as n } from "./index-CvsPTm3-.js";
2
2
  const f = async (r) => {
3
3
  if (r.args.length === 0)
4
4
  return r.stderr.write(`touch: missing operand
@@ -1,4 +1,4 @@
1
- import { r as v, V as C } from "./index-DccAPaZF.js";
1
+ import { r as v, V as C } from "./index-CvsPTm3-.js";
2
2
  const P = async (t) => {
3
3
  let f = 1 / 0, a = !1, o = ".";
4
4
  for (let e = 0; e < t.args.length; e++) {
@@ -0,0 +1,54 @@
1
+ import { r as f, i as c, c as g, V as d } from "./index-CvsPTm3-.js";
2
+ const h = async (t) => {
3
+ let o = !1, l = !1, a = !1;
4
+ const s = [];
5
+ for (const e of t.args)
6
+ if (e.startsWith("-") && e.length > 1)
7
+ for (let r = 1; r < e.length; r++)
8
+ switch (e[r]) {
9
+ case "c":
10
+ o = !0;
11
+ break;
12
+ case "d":
13
+ l = !0;
14
+ break;
15
+ case "u":
16
+ a = !0;
17
+ break;
18
+ }
19
+ else
20
+ s.push(e);
21
+ let i = "";
22
+ if (s.length === 0)
23
+ if (t.stdin)
24
+ i = await t.stdin.readAll();
25
+ else
26
+ return t.stderr.write(`uniq: missing file operand
27
+ `), 1;
28
+ else {
29
+ const e = f(t.cwd, s[0]);
30
+ if (c(g(e)))
31
+ return t.stderr.write(`uniq: ${s[0]}: binary file, skipping
32
+ `), 1;
33
+ try {
34
+ i = t.vfs.readFileString(e);
35
+ } catch (r) {
36
+ if (r instanceof d)
37
+ return t.stderr.write(`uniq: ${s[0]}: ${r.message}
38
+ `), 1;
39
+ throw r;
40
+ }
41
+ }
42
+ const u = i.replace(/\n$/, "").split(`
43
+ `), n = [];
44
+ for (const e of u)
45
+ n.length > 0 && n[n.length - 1].line === e ? n[n.length - 1].count++ : n.push({ line: e, count: 1 });
46
+ for (const e of n)
47
+ l && e.count < 2 || a && e.count > 1 || (o ? t.stdout.write(`${String(e.count).padStart(7)} ${e.line}
48
+ `) : t.stdout.write(e.line + `
49
+ `));
50
+ return 0;
51
+ };
52
+ export {
53
+ h as default
54
+ };
@@ -1,5 +1,4 @@
1
- import { r as d, d as h, V as p } from "./index-DccAPaZF.js";
2
- import { f as w } from "./archive-nRHWNwjH.js";
1
+ import { r as d, m as f, k as p, V as w } from "./index-CvsPTm3-.js";
3
2
  const v = async (t) => {
4
3
  let u = !1, a = "", o = "";
5
4
  for (let r = 0; r < t.args.length; r++) {
@@ -27,23 +26,23 @@ const v = async (t) => {
27
26
  if (!o)
28
27
  return t.stderr.write(`unzip: missing archive operand
29
28
  `), 1;
30
- const f = d(t.cwd, o), l = a ? d(t.cwd, a) : t.cwd;
29
+ const c = d(t.cwd, o), l = a ? d(t.cwd, a) : t.cwd;
31
30
  try {
32
- const r = t.vfs.readFile(f), e = w(r);
31
+ const r = t.vfs.readFile(c), e = f(r);
33
32
  if (u) {
34
33
  t.stdout.write(` Length Name
35
34
  `), t.stdout.write(`--------- ----
36
35
  `);
37
- let i = 0;
38
- for (const s of e) {
39
- const n = s.data.length;
40
- i += n;
41
- const c = s.isDirectory ? s.path + "/" : s.path;
42
- t.stdout.write(`${String(n).padStart(9)} ${c}
36
+ let s = 0;
37
+ for (const i of e) {
38
+ const n = i.data.length;
39
+ s += n;
40
+ const h = i.isDirectory ? i.path + "/" : i.path;
41
+ t.stdout.write(`${String(n).padStart(9)} ${h}
43
42
  `);
44
43
  }
45
44
  return t.stdout.write(`--------- ----
46
- `), t.stdout.write(`${String(i).padStart(9)} ${e.length} file(s)
45
+ `), t.stdout.write(`${String(s).padStart(9)} ${e.length} file(s)
47
46
  `), 0;
48
47
  }
49
48
  if (a)
@@ -51,26 +50,26 @@ const v = async (t) => {
51
50
  t.vfs.mkdir(l, { recursive: !0 });
52
51
  } catch {
53
52
  }
54
- for (const i of e) {
55
- const s = d(l, i.path);
56
- if (i.isDirectory)
53
+ for (const s of e) {
54
+ const i = d(l, s.path);
55
+ if (s.isDirectory)
57
56
  try {
58
- t.vfs.mkdir(s, { recursive: !0 });
57
+ t.vfs.mkdir(i, { recursive: !0 });
59
58
  } catch {
60
59
  }
61
60
  else {
62
- const n = h(s);
61
+ const n = p(i);
63
62
  try {
64
63
  t.vfs.mkdir(n, { recursive: !0 });
65
64
  } catch {
66
65
  }
67
- t.vfs.writeFile(s, i.data);
66
+ t.vfs.writeFile(i, s.data);
68
67
  }
69
- t.stdout.write(` extracting: ${i.path}${i.isDirectory ? "/" : ""}
68
+ t.stdout.write(` extracting: ${s.path}${s.isDirectory ? "/" : ""}
70
69
  `);
71
70
  }
72
71
  } catch (r) {
73
- if (r instanceof p)
72
+ if (r instanceof w)
74
73
  return t.stderr.write(`unzip: ${r.message}
75
74
  `), 1;
76
75
  throw r;
@@ -0,0 +1,4 @@
1
+ export declare function getMimeType(filename: string): string;
2
+ export declare function getFileCategory(mime: string): 'text' | 'image' | 'video' | 'audio' | 'archive' | 'binary';
3
+ export declare function isBinaryMime(mime: string): boolean;
4
+ //# sourceMappingURL=mime.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mime.d.ts","sourceRoot":"","sources":["../../src/utils/mime.ts"],"names":[],"mappings":"AAoFA,wBAAgB,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAKpD;AAED,wBAAgB,eAAe,CAC7B,IAAI,EAAE,MAAM,GACX,MAAM,GAAG,OAAO,GAAG,OAAO,GAAG,OAAO,GAAG,SAAS,GAAG,QAAQ,CAgB7D;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAElD"}
@@ -0,0 +1,69 @@
1
+ import { r as p, i as y, c as b, V as m } from "./index-CvsPTm3-.js";
2
+ const v = async (s) => {
3
+ let i = !1, o = !1, a = !1;
4
+ const l = [];
5
+ for (const t of s.args)
6
+ if (t.startsWith("-") && t.length > 1)
7
+ for (let e = 1; e < t.length; e++)
8
+ switch (t[e]) {
9
+ case "l":
10
+ i = !0;
11
+ break;
12
+ case "w":
13
+ o = !0;
14
+ break;
15
+ case "c":
16
+ a = !0;
17
+ break;
18
+ }
19
+ else
20
+ l.push(t);
21
+ !i && !o && !a && (i = o = a = !0);
22
+ function u(t) {
23
+ const e = t === "" ? 0 : t.split(`
24
+ `).length - (t.endsWith(`
25
+ `) ? 1 : 0), n = t.trim() === "" ? 0 : t.trim().split(/\s+/).length, r = new TextEncoder().encode(t).length;
26
+ return { lines: e, words: n, bytes: r };
27
+ }
28
+ function f(t, e) {
29
+ const n = [];
30
+ return i && n.push(String(t.lines).padStart(8)), o && n.push(String(t.words).padStart(8)), a && n.push(String(t.bytes).padStart(8)), e && n.push(" " + e), n.join("") + `
31
+ `;
32
+ }
33
+ if (l.length === 0) {
34
+ if (s.stdin) {
35
+ const t = await s.stdin.readAll(), e = u(t);
36
+ s.stdout.write(f(e));
37
+ } else
38
+ return s.stderr.write(`wc: missing file operand
39
+ `), 1;
40
+ return 0;
41
+ }
42
+ let c = 0, w = 0, h = 0, d = 0;
43
+ for (const t of l) {
44
+ const e = p(s.cwd, t);
45
+ try {
46
+ if (s.vfs.stat(e), y(b(e))) {
47
+ if (a && !i && !o) {
48
+ const g = { lines: 0, words: 0, bytes: s.vfs.readFile(e).byteLength };
49
+ d += g.bytes, s.stdout.write(f(g, t));
50
+ } else
51
+ s.stderr.write(`wc: ${t}: binary file, skipping
52
+ `);
53
+ continue;
54
+ }
55
+ const n = s.vfs.readFileString(e), r = u(n);
56
+ w += r.lines, h += r.words, d += r.bytes, s.stdout.write(f(r, t));
57
+ } catch (n) {
58
+ if (n instanceof m)
59
+ s.stderr.write(`wc: ${t}: ${n.message}
60
+ `), c = 1;
61
+ else
62
+ throw n;
63
+ }
64
+ }
65
+ return l.length > 1 && s.stdout.write(f({ lines: w, words: h, bytes: d }, "total")), c;
66
+ };
67
+ export {
68
+ v as default
69
+ };
@@ -1,4 +1,4 @@
1
- import { r as l } from "./index-DccAPaZF.js";
1
+ import { r as l } from "./index-CvsPTm3-.js";
2
2
  const w = async (e) => {
3
3
  let i, n = !1, s;
4
4
  const a = e.args;
@@ -1,28 +1,27 @@
1
- import { r as c, V as d } from "./index-DccAPaZF.js";
2
- import { c as f, e as p } from "./archive-nRHWNwjH.js";
3
- const m = async (r) => {
1
+ import { r as d, d as c, l as f, V as h } from "./index-CvsPTm3-.js";
2
+ const g = async (r) => {
4
3
  if (r.args.length === 0 || r.args[0] === "--help")
5
4
  return r.stdout.write(`Usage: zip archive.zip file1 [file2 ...]
6
5
  `), r.args.length === 0 ? 1 : 0;
7
- const a = r.args[0], i = r.args.slice(1);
8
- if (i.length === 0)
6
+ const a = r.args[0], s = r.args.slice(1);
7
+ if (s.length === 0)
9
8
  return r.stderr.write(`zip: no files to archive
10
9
  `), 1;
11
- const o = c(r.cwd, a);
10
+ const n = d(r.cwd, a);
12
11
  try {
13
- const s = f(r.vfs, r.cwd, i).map((e) => ({
12
+ const i = c(r.vfs, r.cwd, s).map((e) => ({
14
13
  path: e.path,
15
14
  data: e.data,
16
15
  isDirectory: e.type === "directory"
17
- })), n = p(s);
18
- r.vfs.writeFile(o, n);
19
- for (const e of s) {
16
+ })), o = f(i);
17
+ r.vfs.writeFile(n, o);
18
+ for (const e of i) {
20
19
  const l = (e.isDirectory, "adding:");
21
20
  r.stdout.write(` ${l} ${e.path}${e.isDirectory ? "/" : ""}
22
21
  `);
23
22
  }
24
23
  } catch (t) {
25
- if (t instanceof d)
24
+ if (t instanceof h)
26
25
  return r.stderr.write(`zip: ${t.message}
27
26
  `), 1;
28
27
  throw t;
@@ -30,5 +29,5 @@ const m = async (r) => {
30
29
  return 0;
31
30
  };
32
31
  export {
33
- m as default
32
+ g as default
34
33
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lifo-sh/core",
3
- "version": "0.2.0",
3
+ "version": "0.4.0",
4
4
  "description": "Linux-like OS engine for JavaScript -- kernel, shell, VFS, and 60+ commands",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -35,8 +35,15 @@
35
35
  "publishConfig": {
36
36
  "access": "public"
37
37
  },
38
+ "scripts": {
39
+ "build": "vite build",
40
+ "typecheck": "tsc --noEmit",
41
+ "test": "vitest run",
42
+ "test:watch": "vitest"
43
+ },
44
+ "dependencies": {},
38
45
  "peerDependencies": {
39
- "@lifo-sh/ui": "0.2.0"
46
+ "@lifo-sh/ui": "workspace:*"
40
47
  },
41
48
  "peerDependenciesMeta": {
42
49
  "@lifo-sh/ui": {
@@ -48,11 +55,5 @@
48
55
  "vite": "^6.0.0",
49
56
  "vite-plugin-dts": "^4.5.0",
50
57
  "vitest": "^3.0.0"
51
- },
52
- "scripts": {
53
- "build": "vite build",
54
- "typecheck": "tsc --noEmit",
55
- "test": "vitest run",
56
- "test:watch": "vitest"
57
58
  }
58
- }
59
+ }