@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
@@ -1,192 +0,0 @@
1
- import { r as x, d as C, c as U, f as A, h as L } from "./index-DccAPaZF.js";
2
- const S = new Uint32Array(256);
3
- for (let t = 0; t < 256; t++) {
4
- let e = t;
5
- for (let n = 0; n < 8; n++)
6
- e = e & 1 ? 3988292384 ^ e >>> 1 : e >>> 1;
7
- S[t] = e;
8
- }
9
- function F(t) {
10
- let e = 4294967295;
11
- for (let n = 0; n < t.length; n++)
12
- e = S[(e ^ t[n]) & 255] ^ e >>> 8;
13
- return (e ^ 4294967295) >>> 0;
14
- }
15
- async function I(t) {
16
- const e = new CompressionStream("gzip"), n = e.writable.getWriter();
17
- n.write(t), n.close();
18
- const r = e.readable.getReader(), c = [];
19
- for (; ; ) {
20
- const { done: s, value: i } = await r.read();
21
- if (s) break;
22
- c.push(i);
23
- }
24
- return U(...c);
25
- }
26
- async function M(t) {
27
- const e = new DecompressionStream("gzip"), n = e.writable.getWriter();
28
- n.write(t), n.close();
29
- const r = e.readable.getReader(), c = [];
30
- for (; ; ) {
31
- const { done: s, value: i } = await r.read();
32
- if (s) break;
33
- c.push(i);
34
- }
35
- return U(...c);
36
- }
37
- function w(t, e, n, r) {
38
- const c = A(n);
39
- t.set(c.subarray(0, r), e);
40
- }
41
- function f(t, e, n, r) {
42
- const c = n.toString(8).padStart(r - 1, "0");
43
- w(t, e, c, r - 1), t[e + r - 1] = 0;
44
- }
45
- function R(t) {
46
- let e = 0;
47
- for (let n = 0; n < 512; n++)
48
- e += n >= 148 && n < 156 ? 32 : t[n];
49
- return e;
50
- }
51
- function z(t, e, n) {
52
- let r = e;
53
- const c = e + n;
54
- for (; r < c && t[r] !== 0; ) r++;
55
- return L(t.subarray(e, r));
56
- }
57
- function D(t, e, n) {
58
- const r = z(t, e, n).trim();
59
- return r ? parseInt(r, 8) : 0;
60
- }
61
- function $(t) {
62
- const e = [];
63
- for (const n of t) {
64
- const r = new Uint8Array(512);
65
- let c = n.path;
66
- n.type === "directory" && !c.endsWith("/") && (c += "/"), c.startsWith("/") && (c = c.slice(1)), w(r, 0, c, 100), f(r, 100, n.mode, 8), f(r, 108, 0, 8), f(r, 116, 0, 8), f(r, 124, n.data.length, 12), f(r, 136, Math.floor(n.mtime / 1e3), 12), r[156] = n.type === "directory" ? 53 : 48, w(r, 257, "ustar", 6), w(r, 263, "00", 2), w(r, 265, "user", 32), w(r, 297, "user", 32);
67
- const s = R(r);
68
- if (f(r, 148, s, 7), r[155] = 32, e.push(r), n.type === "file" && n.data.length > 0) {
69
- const i = Math.ceil(n.data.length / 512) * 512, o = new Uint8Array(i);
70
- o.set(n.data), e.push(o);
71
- }
72
- }
73
- return e.push(new Uint8Array(1024)), U(...e);
74
- }
75
- function G(t) {
76
- const e = [];
77
- let n = 0;
78
- for (; n + 512 <= t.length; ) {
79
- const r = t.subarray(n, n + 512);
80
- let c = !0;
81
- for (let l = 0; l < 512; l++)
82
- if (r[l] !== 0) {
83
- c = !1;
84
- break;
85
- }
86
- if (c) break;
87
- let s = z(r, 0, 100);
88
- const i = D(r, 100, 8), o = D(r, 124, 12), p = D(r, 136, 12) * 1e3, m = r[156] === 53 || s.endsWith("/");
89
- s.endsWith("/") && (s = s.slice(0, -1)), n += 512;
90
- let u = new Uint8Array(0);
91
- o > 0 && (u = t.slice(n, n + o), n += Math.ceil(o / 512) * 512), e.push({
92
- path: s,
93
- data: u,
94
- type: m ? "directory" : "file",
95
- mode: i || (m ? 493 : 420),
96
- mtime: p
97
- });
98
- }
99
- return e;
100
- }
101
- function a(t, e, n) {
102
- t[e] = n & 255, t[e + 1] = n >>> 8 & 255;
103
- }
104
- function y(t, e, n) {
105
- t[e] = n & 255, t[e + 1] = n >>> 8 & 255, t[e + 2] = n >>> 16 & 255, t[e + 3] = n >>> 24 & 255;
106
- }
107
- function g(t, e) {
108
- return t[e] | t[e + 1] << 8;
109
- }
110
- function k(t, e) {
111
- return (t[e] | t[e + 1] << 8 | t[e + 2] << 16 | t[e + 3] << 24) >>> 0;
112
- }
113
- function b(t) {
114
- const e = [], n = [];
115
- let r = 0;
116
- for (const o of t) {
117
- let p = o.path;
118
- p.startsWith("/") && (p = p.slice(1)), o.isDirectory && !p.endsWith("/") && (p += "/");
119
- const d = A(p), m = o.isDirectory ? 0 : F(o.data), u = o.isDirectory ? 0 : o.data.length, l = new Uint8Array(30 + d.length);
120
- y(l, 0, 67324752), a(l, 4, 20), a(l, 6, 0), a(l, 8, 0), a(l, 10, 0), a(l, 12, 0), y(l, 14, m), y(l, 18, u), y(l, 22, u), a(l, 26, d.length), a(l, 28, 0), l.set(d, 30), e.push(l), u > 0 && e.push(o.data);
121
- const h = new Uint8Array(46 + d.length);
122
- y(h, 0, 33639248), a(h, 4, 20), a(h, 6, 20), a(h, 8, 0), a(h, 10, 0), a(h, 12, 0), a(h, 14, 0), y(h, 16, m), y(h, 20, u), y(h, 24, u), a(h, 28, d.length), a(h, 30, 0), a(h, 32, 0), a(h, 34, 0), a(h, 36, 0), y(h, 38, o.isDirectory ? 16 : 0), y(h, 42, r), h.set(d, 46), n.push(h), r += 30 + d.length + u;
123
- }
124
- const c = r;
125
- let s = 0;
126
- for (const o of n)
127
- e.push(o), s += o.length;
128
- const i = new Uint8Array(22);
129
- return y(i, 0, 101010256), a(i, 4, 0), a(i, 6, 0), a(i, 8, t.length), a(i, 10, t.length), y(i, 12, s), y(i, 16, c), a(i, 20, 0), e.push(i), U(...e);
130
- }
131
- function j(t) {
132
- const e = [];
133
- let n = -1;
134
- for (let s = t.length - 22; s >= 0; s--)
135
- if (k(t, s) === 101010256) {
136
- n = s;
137
- break;
138
- }
139
- if (n === -1) throw new Error("Invalid ZIP: EOCD not found");
140
- const r = g(t, n + 10);
141
- let c = k(t, n + 16);
142
- for (let s = 0; s < r && k(t, c) === 33639248; s++) {
143
- const i = g(t, c + 28), o = g(t, c + 30), p = g(t, c + 32), d = k(t, c + 42), m = t.subarray(c + 46, c + 46 + i);
144
- let u = L(m);
145
- const l = u.endsWith("/");
146
- l && (u = u.slice(0, -1));
147
- const h = g(t, d + 26), E = g(t, d + 28), O = k(t, d + 18), W = d + 30 + h + E, B = l ? new Uint8Array(0) : t.slice(W, W + O);
148
- e.push({ path: u, data: B, isDirectory: l }), c += 46 + i + o + p;
149
- }
150
- return e;
151
- }
152
- function H(t, e, n) {
153
- const r = [];
154
- function c(s, i) {
155
- const o = t.stat(s);
156
- if (o.type === "directory") {
157
- r.push({
158
- path: s.slice(i.length) || s,
159
- data: new Uint8Array(0),
160
- type: "directory",
161
- mode: o.mode,
162
- mtime: o.mtime
163
- });
164
- const p = t.readdir(s);
165
- for (const d of p) {
166
- const m = s === "/" ? `/${d.name}` : `${s}/${d.name}`;
167
- c(m, i);
168
- }
169
- } else
170
- r.push({
171
- path: s.slice(i.length) || s,
172
- data: t.readFile(s),
173
- type: "file",
174
- mode: o.mode,
175
- mtime: o.mtime
176
- });
177
- }
178
- for (const s of n) {
179
- const i = x(e, s), o = C(i), p = o === "/" ? "/" : o + "/";
180
- c(i, p);
181
- }
182
- return r;
183
- }
184
- export {
185
- $ as a,
186
- I as b,
187
- H as c,
188
- M as d,
189
- b as e,
190
- j as f,
191
- G as p
192
- };
@@ -1,118 +0,0 @@
1
- import { r as E, V as N } from "./index-DccAPaZF.js";
2
- function S(e) {
3
- const a = [];
4
- let t = e.trim();
5
- for (; t.length > 0 && (t = t.trim(), t.length !== 0); ) {
6
- let n = null, o = "";
7
- if (t.startsWith("BEGIN"))
8
- n = "BEGIN", t = t.slice(5).trim();
9
- else if (t.startsWith("END"))
10
- n = "END", t = t.slice(3).trim();
11
- else if (t.startsWith("/")) {
12
- const i = t.indexOf("/", 1);
13
- if (i > 0) {
14
- try {
15
- n = new RegExp(t.slice(1, i));
16
- } catch {
17
- n = null;
18
- }
19
- t = t.slice(i + 1).trim();
20
- }
21
- }
22
- if (t.startsWith("{")) {
23
- let i = 0, l = 0;
24
- for (; l < t.length; l++)
25
- if (t[l] === "{") i++;
26
- else if (t[l] === "}" && (i--, i === 0))
27
- break;
28
- o = t.slice(1, l).trim(), t = t.slice(l + 1).trim();
29
- } else n === null && (o = t, t = "");
30
- a.push({ pattern: n, action: o });
31
- }
32
- return a;
33
- }
34
- function m(e, a, t, n, o, i, l) {
35
- const f = [], p = e.split(";").map((r) => r.trim()).filter(Boolean);
36
- for (const r of p)
37
- if (r === "print" || r === "print $0")
38
- f.push(t);
39
- else if (r.startsWith("print ")) {
40
- const h = r.slice(6).trim().split(",").map((g) => g.trim()).map((g) => W(g, a, t, n, o, l));
41
- f.push(h.join(" "));
42
- }
43
- return f.join(`
44
- `);
45
- }
46
- function W(e, a, t, n, o, i) {
47
- if (e = e.trim(), e.startsWith('"') && e.endsWith('"'))
48
- return e.slice(1, -1).replace(/\\n/g, `
49
- `).replace(/\\t/g, " ");
50
- if (e.startsWith("$")) {
51
- const l = e.slice(1);
52
- if (l === "NF")
53
- return a[o - 1] || "";
54
- const f = parseInt(l, 10);
55
- return f === 0 ? t : a[f - 1] || "";
56
- }
57
- return e === "NR" ? String(n) : e === "NF" ? String(o) : i.has(e) ? i.get(e) : e;
58
- }
59
- const k = async (e) => {
60
- let a = /\s+/, t = " ", n = "";
61
- const o = [];
62
- for (let r = 0; r < e.args.length; r++) {
63
- const s = e.args[r];
64
- s === "-F" && r + 1 < e.args.length ? (t = e.args[++r], a = new RegExp(t.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"))) : s.startsWith("-F") && s.length > 2 ? (t = s.slice(2), a = new RegExp(t.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"))) : n ? o.push(s) : n = s;
65
- }
66
- if (!n)
67
- return e.stderr.write(`awk: missing program
68
- `), 1;
69
- let i = "";
70
- if (o.length === 0)
71
- if (e.stdin)
72
- i = await e.stdin.readAll();
73
- else
74
- return e.stderr.write(`awk: missing file operand
75
- `), 1;
76
- else
77
- for (const r of o) {
78
- const s = E(e.cwd, r);
79
- try {
80
- i += e.vfs.readFileString(s);
81
- } catch (c) {
82
- if (c instanceof N)
83
- return e.stderr.write(`awk: ${r}: ${c.message}
84
- `), 1;
85
- throw c;
86
- }
87
- }
88
- const l = S(n), f = i.replace(/\n$/, "").split(`
89
- `), p = /* @__PURE__ */ new Map();
90
- for (const r of l)
91
- if (r.pattern === "BEGIN") {
92
- const s = m(r.action, [], "", 0, 0, t, p);
93
- s && e.stdout.write(s + `
94
- `);
95
- }
96
- for (let r = 0; r < f.length; r++) {
97
- const s = f[r], c = s.split(a).filter((u) => u !== ""), h = r + 1, g = c.length;
98
- for (const u of l) {
99
- if (u.pattern === "BEGIN" || u.pattern === "END") continue;
100
- let d = !0;
101
- if (u.pattern instanceof RegExp && (d = u.pattern.test(s)), d) {
102
- const w = m(u.action, c, s, h, g, t, p);
103
- w && e.stdout.write(w + `
104
- `);
105
- }
106
- }
107
- }
108
- for (const r of l)
109
- if (r.pattern === "END") {
110
- const s = m(r.action, [], "", f.length, 0, t, p);
111
- s && e.stdout.write(s + `
112
- `);
113
- }
114
- return 0;
115
- };
116
- export {
117
- k as default
118
- };
@@ -1,60 +0,0 @@
1
- import { r as d, V as c } from "./index-DccAPaZF.js";
2
- function u(e) {
3
- const r = [];
4
- for (const n of e.split(",")) {
5
- const i = n.split("-");
6
- if (i.length === 2) {
7
- const l = parseInt(i[0], 10), f = parseInt(i[1], 10);
8
- if (!isNaN(l) && !isNaN(f))
9
- for (let a = l; a <= f; a++) r.push(a);
10
- } else {
11
- const l = parseInt(n, 10);
12
- isNaN(l) || r.push(l);
13
- }
14
- }
15
- return r;
16
- }
17
- const h = async (e) => {
18
- let r = " ", n = "";
19
- const i = [];
20
- for (let s = 0; s < e.args.length; s++) {
21
- const t = e.args[s];
22
- t === "-d" && s + 1 < e.args.length ? r = e.args[++s] : t === "-f" && s + 1 < e.args.length ? n = e.args[++s] : t.startsWith("-d") && t.length > 2 ? r = t.slice(2) : t.startsWith("-f") && t.length > 2 ? n = t.slice(2) : i.push(t);
23
- }
24
- if (!n)
25
- return e.stderr.write(`cut: you must specify a list of fields
26
- `), 1;
27
- const l = u(n);
28
- function f(s) {
29
- const t = s.split(r);
30
- return l.map((o) => t[o - 1] || "").join(r);
31
- }
32
- let a = "";
33
- if (i.length === 0)
34
- if (e.stdin)
35
- a = await e.stdin.readAll();
36
- else
37
- return e.stderr.write(`cut: missing file operand
38
- `), 1;
39
- else
40
- for (const s of i) {
41
- const t = d(e.cwd, s);
42
- try {
43
- a += e.vfs.readFileString(t);
44
- } catch (o) {
45
- if (o instanceof c)
46
- return e.stderr.write(`cut: ${s}: ${o.message}
47
- `), 1;
48
- throw o;
49
- }
50
- }
51
- const p = a.replace(/\n$/, "").split(`
52
- `);
53
- for (const s of p)
54
- e.stdout.write(f(s) + `
55
- `);
56
- return 0;
57
- };
58
- export {
59
- h as default
60
- };
@@ -1,129 +0,0 @@
1
- import { p as m } from "./args-CG6b9cZt.js";
2
- import { r as y, V as w } from "./index-DccAPaZF.js";
3
- const C = {
4
- unified: { type: "boolean", short: "u" }
5
- };
6
- function k(o, f) {
7
- const d = o.length, n = f.length, s = Array.from({ length: d + 1 }, () => new Array(n + 1).fill(0));
8
- for (let e = 1; e <= d; e++)
9
- for (let l = 1; l <= n; l++)
10
- o[e - 1] === f[l - 1] ? s[e][l] = s[e - 1][l - 1] + 1 : s[e][l] = Math.max(s[e - 1][l], s[e][l - 1]);
11
- const u = [];
12
- let i = d, r = n;
13
- for (; i > 0 || r > 0; )
14
- i > 0 && r > 0 && o[i - 1] === f[r - 1] ? (u.push({ type: "keep", oldLine: o[i - 1] }), i--, r--) : r > 0 && (i === 0 || s[i][r - 1] >= s[i - 1][r]) ? (u.push({ type: "insert", newLine: f[r - 1] }), r--) : (u.push({ type: "delete", oldLine: o[i - 1] }), i--);
15
- return u.reverse();
16
- }
17
- function S(o) {
18
- const f = [];
19
- let d = 0, n = 0, s = 0;
20
- for (; s < o.length; ) {
21
- if (o[s].type === "keep") {
22
- d++, n++, s++;
23
- continue;
24
- }
25
- const i = d, r = n, e = [], l = [];
26
- for (; s < o.length && o[s].type !== "keep"; )
27
- o[s].type === "delete" ? (e.push(o[s].oldLine), d++) : (l.push(o[s].newLine), n++), s++;
28
- const p = e.length === 1 ? `${i + 1}` : e.length > 0 ? `${i + 1},${i + e.length}` : `${i}`, t = l.length === 1 ? `${r + 1}` : l.length > 0 ? `${r + 1},${r + l.length}` : `${r}`;
29
- if (e.length > 0 && l.length > 0) {
30
- f.push(`${p}c${t}`);
31
- for (const a of e) f.push(`< ${a}`);
32
- f.push("---");
33
- for (const a of l) f.push(`> ${a}`);
34
- } else if (e.length > 0) {
35
- f.push(`${p}d${t}`);
36
- for (const a of e) f.push(`< ${a}`);
37
- } else {
38
- f.push(`${p}a${t}`);
39
- for (const a of l) f.push(`> ${a}`);
40
- }
41
- }
42
- return f.length > 0 ? f.join(`
43
- `) + `
44
- ` : "";
45
- }
46
- function L(o, f, d) {
47
- if (o.every((t) => t.type === "keep")) return "";
48
- const n = [];
49
- let s = 0, u = 0;
50
- for (const t of o)
51
- t.type === "keep" ? (n.push({ type: "keep", line: t.oldLine, oldIdx: s, newIdx: u }), s++, u++) : t.type === "delete" ? (n.push({ type: "delete", line: t.oldLine, oldIdx: s, newIdx: u }), s++) : (n.push({ type: "insert", line: t.newLine, oldIdx: s, newIdx: u }), u++);
52
- const i = 3, r = [];
53
- let e = null, l = -1 / 0;
54
- for (let t = 0; t < n.length; t++) {
55
- const a = n[t];
56
- if (a.type !== "keep") {
57
- if (!e || t - l > i * 2 + 1) {
58
- if (e) {
59
- for (let h = l + 1; h < Math.min(l + 1 + i, n.length); h++)
60
- n[h].type === "keep" && (e.lines.push(` ${n[h].line}`), e.oldCount++, e.newCount++);
61
- r.push(e);
62
- }
63
- const c = Math.max(0, t - i);
64
- let g = 0, $ = 0;
65
- for (let h = 0; h < c; h++)
66
- n[h].type !== "insert" && g++, n[h].type !== "delete" && $++;
67
- e = {
68
- oldStart: g + 1,
69
- newStart: $ + 1,
70
- oldCount: 0,
71
- newCount: 0,
72
- lines: []
73
- };
74
- for (let h = c; h < t; h++)
75
- n[h].type === "keep" && (e.lines.push(` ${n[h].line}`), e.oldCount++, e.newCount++);
76
- } else if (t - l > 1)
77
- for (let c = l + 1; c < t; c++)
78
- n[c].type === "keep" && (e.lines.push(` ${n[c].line}`), e.oldCount++, e.newCount++);
79
- a.type === "delete" ? (e.lines.push(`-${a.line}`), e.oldCount++) : (e.lines.push(`+${a.line}`), e.newCount++), l = t;
80
- }
81
- }
82
- if (e) {
83
- for (let t = l + 1; t < Math.min(l + 1 + i, n.length); t++)
84
- n[t].type === "keep" && (e.lines.push(` ${n[t].line}`), e.oldCount++, e.newCount++);
85
- r.push(e);
86
- }
87
- const p = [];
88
- p.push(`--- ${f}`), p.push(`+++ ${d}`);
89
- for (const t of r)
90
- p.push(`@@ -${t.oldStart},${t.oldCount} +${t.newStart},${t.newCount} @@`), p.push(...t.lines);
91
- return p.join(`
92
- `) + `
93
- `;
94
- }
95
- const v = async (o) => {
96
- const { flags: f, positional: d } = m(o.args, C);
97
- if (d.length < 2)
98
- return o.stderr.write(`diff: missing operand
99
- `), 2;
100
- const n = d[0], s = d[1];
101
- let u, i;
102
- try {
103
- u = o.vfs.readFileString(y(o.cwd, n));
104
- } catch (p) {
105
- if (p instanceof w)
106
- return o.stderr.write(`diff: ${n}: ${p.message}
107
- `), 2;
108
- throw p;
109
- }
110
- try {
111
- i = o.vfs.readFileString(y(o.cwd, s));
112
- } catch (p) {
113
- if (p instanceof w)
114
- return o.stderr.write(`diff: ${s}: ${p.message}
115
- `), 2;
116
- throw p;
117
- }
118
- if (u === i)
119
- return 0;
120
- const r = u.split(`
121
- `), e = i.split(`
122
- `);
123
- r.length > 0 && r[r.length - 1] === "" && r.pop(), e.length > 0 && e[e.length - 1] === "" && e.pop();
124
- const l = k(r, e);
125
- return f.unified ? o.stdout.write(L(l, n, s)) : o.stdout.write(S(l)), 1;
126
- };
127
- export {
128
- v as default
129
- };
@@ -1,48 +0,0 @@
1
- import { r as u, V as d } from "./index-DccAPaZF.js";
2
- import { d as p } from "./archive-nRHWNwjH.js";
3
- const w = async (e) => {
4
- let o = !1;
5
- const t = [];
6
- for (const r of e.args)
7
- switch (r) {
8
- case "-k":
9
- case "--keep":
10
- o = !0;
11
- break;
12
- case "--help":
13
- return e.stdout.write(`Usage: gunzip [-k] file.gz
14
- `), e.stdout.write(` -k, --keep keep original file
15
- `), 0;
16
- default:
17
- if (r.startsWith("-"))
18
- return e.stderr.write(`gunzip: unknown option: ${r}
19
- `), 1;
20
- t.push(r);
21
- }
22
- if (t.length === 0)
23
- return e.stderr.write(`gunzip: missing file operand
24
- `), 1;
25
- let n = 0;
26
- for (const r of t) {
27
- const i = u(e.cwd, r);
28
- try {
29
- if (!i.endsWith(".gz")) {
30
- e.stderr.write(`gunzip: ${r}: unknown suffix -- ignored
31
- `), n = 1;
32
- continue;
33
- }
34
- const s = e.vfs.readFile(i), a = await p(s), f = i.slice(0, -3);
35
- e.vfs.writeFile(f, a), o || e.vfs.unlink(i);
36
- } catch (s) {
37
- if (s instanceof d)
38
- e.stderr.write(`gunzip: ${r}: ${s.message}
39
- `), n = 1;
40
- else
41
- throw s;
42
- }
43
- }
44
- return n;
45
- };
46
- export {
47
- w as default
48
- };
@@ -1,48 +0,0 @@
1
- import { r as d, V as f } from "./index-DccAPaZF.js";
2
- const h = async (e) => {
3
- let r = 10;
4
- const i = [];
5
- for (let t = 0; t < e.args.length; t++) {
6
- const s = e.args[t];
7
- if (s === "-n" && t + 1 < e.args.length) {
8
- if (r = parseInt(e.args[++t], 10), isNaN(r))
9
- return e.stderr.write(`head: invalid number of lines
10
- `), 1;
11
- } else /^-\d+$/.test(s) ? r = parseInt(s.slice(1), 10) : i.push(s);
12
- }
13
- async function a(t) {
14
- const s = t.split(`
15
- `);
16
- let o = s.slice(0, r).join(`
17
- `);
18
- s.length > r && (o += `
19
- `), e.stdout.write(o);
20
- }
21
- if (i.length === 0) {
22
- if (e.stdin)
23
- await a(await e.stdin.readAll());
24
- else
25
- return e.stderr.write(`head: missing file operand
26
- `), 1;
27
- return 0;
28
- }
29
- let l = 0;
30
- for (const t of i) {
31
- const s = d(e.cwd, t);
32
- try {
33
- const n = e.vfs.readFileString(s);
34
- i.length > 1 && e.stdout.write(`==> ${t} <==
35
- `), await a(n);
36
- } catch (n) {
37
- if (n instanceof f)
38
- e.stderr.write(`head: ${t}: ${n.message}
39
- `), l = 1;
40
- else
41
- throw n;
42
- }
43
- }
44
- return l;
45
- };
46
- export {
47
- h as default
48
- };