@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,123 @@
1
+ import { r as E, i as N, c as S, V as $ } from "./index-CvsPTm3-.js";
2
+ function W(e) {
3
+ const o = [];
4
+ let t = e.trim();
5
+ for (; t.length > 0 && (t = t.trim(), t.length !== 0); ) {
6
+ let s = null, a = "";
7
+ if (t.startsWith("BEGIN"))
8
+ s = "BEGIN", t = t.slice(5).trim();
9
+ else if (t.startsWith("END"))
10
+ s = "END", t = t.slice(3).trim();
11
+ else if (t.startsWith("/")) {
12
+ const n = t.indexOf("/", 1);
13
+ if (n > 0) {
14
+ try {
15
+ s = new RegExp(t.slice(1, n));
16
+ } catch {
17
+ s = null;
18
+ }
19
+ t = t.slice(n + 1).trim();
20
+ }
21
+ }
22
+ if (t.startsWith("{")) {
23
+ let n = 0, l = 0;
24
+ for (; l < t.length; l++)
25
+ if (t[l] === "{") n++;
26
+ else if (t[l] === "}" && (n--, n === 0))
27
+ break;
28
+ a = t.slice(1, l).trim(), t = t.slice(l + 1).trim();
29
+ } else s === null && (a = t, t = "");
30
+ o.push({ pattern: s, action: a });
31
+ }
32
+ return o;
33
+ }
34
+ function m(e, o, t, s, a, n, 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) => k(g, o, t, s, a, l));
41
+ f.push(h.join(" "));
42
+ }
43
+ return f.join(`
44
+ `);
45
+ }
46
+ function k(e, o, t, s, a, n) {
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 o[a - 1] || "";
54
+ const f = parseInt(l, 10);
55
+ return f === 0 ? t : o[f - 1] || "";
56
+ }
57
+ return e === "NR" ? String(s) : e === "NF" ? String(a) : n.has(e) ? n.get(e) : e;
58
+ }
59
+ const B = async (e) => {
60
+ let o = /\s+/, t = " ", s = "";
61
+ const a = [];
62
+ for (let r = 0; r < e.args.length; r++) {
63
+ const i = e.args[r];
64
+ i === "-F" && r + 1 < e.args.length ? (t = e.args[++r], o = new RegExp(t.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"))) : i.startsWith("-F") && i.length > 2 ? (t = i.slice(2), o = new RegExp(t.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"))) : s ? a.push(i) : s = i;
65
+ }
66
+ if (!s)
67
+ return e.stderr.write(`awk: missing program
68
+ `), 1;
69
+ let n = "";
70
+ if (a.length === 0)
71
+ if (e.stdin)
72
+ n = await e.stdin.readAll();
73
+ else
74
+ return e.stderr.write(`awk: missing file operand
75
+ `), 1;
76
+ else
77
+ for (const r of a) {
78
+ const i = E(e.cwd, r);
79
+ try {
80
+ if (e.vfs.stat(i), N(S(i))) {
81
+ e.stderr.write(`awk: ${r}: binary file, skipping
82
+ `);
83
+ continue;
84
+ }
85
+ n += e.vfs.readFileString(i);
86
+ } catch (c) {
87
+ if (c instanceof $)
88
+ return e.stderr.write(`awk: ${r}: ${c.message}
89
+ `), 1;
90
+ throw c;
91
+ }
92
+ }
93
+ const l = W(s), f = n.replace(/\n$/, "").split(`
94
+ `), p = /* @__PURE__ */ new Map();
95
+ for (const r of l)
96
+ if (r.pattern === "BEGIN") {
97
+ const i = m(r.action, [], "", 0, 0, t, p);
98
+ i && e.stdout.write(i + `
99
+ `);
100
+ }
101
+ for (let r = 0; r < f.length; r++) {
102
+ const i = f[r], c = i.split(o).filter((u) => u !== ""), h = r + 1, g = c.length;
103
+ for (const u of l) {
104
+ if (u.pattern === "BEGIN" || u.pattern === "END") continue;
105
+ let d = !0;
106
+ if (u.pattern instanceof RegExp && (d = u.pattern.test(i)), d) {
107
+ const w = m(u.action, c, i, h, g, t, p);
108
+ w && e.stdout.write(w + `
109
+ `);
110
+ }
111
+ }
112
+ }
113
+ for (const r of l)
114
+ if (r.pattern === "END") {
115
+ const i = m(r.action, [], "", f.length, 0, t, p);
116
+ i && e.stdout.write(i + `
117
+ `);
118
+ }
119
+ return 0;
120
+ };
121
+ export {
122
+ B as default
123
+ };
@@ -1,4 +1,4 @@
1
- import { b as a } from "./index-DccAPaZF.js";
1
+ import { b as a } from "./index-CvsPTm3-.js";
2
2
  const t = async (s) => {
3
3
  if (s.args.length === 0)
4
4
  return s.stderr.write(`basename: missing operand
@@ -1,4 +1,4 @@
1
- import { r as o, V as a } from "./index-DccAPaZF.js";
1
+ import { r as o, V as a } from "./index-CvsPTm3-.js";
2
2
  const d = async (r) => {
3
3
  if (r.args.length === 0) {
4
4
  if (r.stdin) {
@@ -1,4 +1,4 @@
1
- import { r as u, V as l } from "./index-DccAPaZF.js";
1
+ import { r as u, V as l } from "./index-CvsPTm3-.js";
2
2
  function h(t, d) {
3
3
  if (/^[0-7]+$/.test(t))
4
4
  return parseInt(t, 8);
@@ -1,5 +1,5 @@
1
1
  import { p as i } from "./args-CG6b9cZt.js";
2
- import { r as c, V as f } from "./index-DccAPaZF.js";
2
+ import { r as c, V as f } from "./index-CvsPTm3-.js";
3
3
  const l = {
4
4
  recursive: { type: "boolean", short: "R" }
5
5
  }, d = async (s) => {
@@ -0,0 +1,11 @@
1
+ import { Command } from '../types.js';
2
+ import { CommandRegistry } from '../registry.js';
3
+ import { VFS } from '../../kernel/vfs/index.js';
4
+ import { ShellExecuteFn } from './npm.js';
5
+ export declare function createLifoPkgCommand(registry: CommandRegistry, shellExecute?: ShellExecuteFn): Command;
6
+ /**
7
+ * Boot-time loader: restores dev-linked commands + re-registers
8
+ * installed lifo packages with the lifo runtime.
9
+ */
10
+ export declare function bootLifoPackages(vfs: VFS, registry: CommandRegistry): void;
11
+ //# sourceMappingURL=lifo.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lifo.d.ts","sourceRoot":"","sources":["../../../src/commands/system/lifo.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAuC,MAAM,aAAa,CAAC;AAChF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACtD,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,2BAA2B,CAAC;AACrD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AA4X/C,wBAAgB,oBAAoB,CAClC,QAAQ,EAAE,eAAe,EACzB,YAAY,CAAC,EAAE,cAAc,GAC5B,OAAO,CAkCT;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,GAAG,EAAE,QAAQ,EAAE,eAAe,GAAG,IAAI,CAkC1E"}
@@ -1 +1 @@
1
- {"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../../../src/commands/system/node.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAS3C,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAuSnE,wBAAgB,iBAAiB,CAAC,YAAY,EAAE,GAAG,CAAC,MAAM,EAAE,qBAAqB,CAAC,GAAG,OAAO,CAE3F;AAGD,QAAA,MAAM,OAAO,EAAE,OAA0B,CAAC;AAE1C,eAAe,OAAO,CAAC"}
1
+ {"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../../../src/commands/system/node.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAS3C,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AA2ZnE,wBAAgB,iBAAiB,CAAC,YAAY,EAAE,GAAG,CAAC,MAAM,EAAE,qBAAqB,CAAC,GAAG,OAAO,CAE3F;AAGD,QAAA,MAAM,OAAO,EAAE,OAA0B,CAAC;AAE1C,eAAe,OAAO,CAAC"}
@@ -0,0 +1,5 @@
1
+ import { Command, CommandContext } from '../types.js';
2
+ import { CommandRegistry } from '../registry.js';
3
+ export type ShellExecuteFn = (cmd: string, ctx: CommandContext) => Promise<number>;
4
+ export declare function createNpmCommand(registry: CommandRegistry, shellExecute?: ShellExecuteFn): Command;
5
+ //# sourceMappingURL=npm.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"npm.d.ts","sourceRoot":"","sources":["../../../src/commands/system/npm.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,cAAc,EAAuB,MAAM,aAAa,CAAC;AAChF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAyCtD,MAAM,MAAM,cAAc,GAAG,CAC3B,GAAG,EAAE,MAAM,EACX,GAAG,EAAE,cAAc,KAChB,OAAO,CAAC,MAAM,CAAC,CAAC;AA2sBrB,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,eAAe,EAAE,YAAY,CAAC,EAAE,cAAc,GAAG,OAAO,CA+ClG"}
@@ -1 +1 @@
1
- {"version":3,"file":"awk.d.ts","sourceRoot":"","sources":["../../../src/commands/text/awk.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AA6G3C,QAAA,MAAM,OAAO,EAAE,OA4Fd,CAAC;AAEF,eAAe,OAAO,CAAC"}
1
+ {"version":3,"file":"awk.d.ts","sourceRoot":"","sources":["../../../src/commands/text/awk.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AA8G3C,QAAA,MAAM,OAAO,EAAE,OAiGd,CAAC;AAEF,eAAe,OAAO,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"cut.d.ts","sourceRoot":"","sources":["../../../src/commands/text/cut.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAsB3C,QAAA,MAAM,OAAO,EAAE,OA6Dd,CAAC;AAEF,eAAe,OAAO,CAAC"}
1
+ {"version":3,"file":"cut.d.ts","sourceRoot":"","sources":["../../../src/commands/text/cut.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAuB3C,QAAA,MAAM,OAAO,EAAE,OAkEd,CAAC;AAEF,eAAe,OAAO,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"diff.d.ts","sourceRoot":"","sources":["../../../src/commands/text/diff.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAoO3C,QAAA,MAAM,OAAO,EAAE,OAsDd,CAAC;AAEF,eAAe,OAAO,CAAC"}
1
+ {"version":3,"file":"diff.d.ts","sourceRoot":"","sources":["../../../src/commands/text/diff.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAqO3C,QAAA,MAAM,OAAO,EAAE,OAkFd,CAAC;AAEF,eAAe,OAAO,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"grep.d.ts","sourceRoot":"","sources":["../../../src/commands/text/grep.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAI3C,QAAA,MAAM,OAAO,EAAE,OA2Jd,CAAC;AAEF,eAAe,OAAO,CAAC"}
1
+ {"version":3,"file":"grep.d.ts","sourceRoot":"","sources":["../../../src/commands/text/grep.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAK3C,QAAA,MAAM,OAAO,EAAE,OAkKd,CAAC;AAEF,eAAe,OAAO,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"head.d.ts","sourceRoot":"","sources":["../../../src/commands/text/head.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAI3C,QAAA,MAAM,OAAO,EAAE,OAuDd,CAAC;AAEF,eAAe,OAAO,CAAC"}
1
+ {"version":3,"file":"head.d.ts","sourceRoot":"","sources":["../../../src/commands/text/head.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAK3C,QAAA,MAAM,OAAO,EAAE,OA4Dd,CAAC;AAEF,eAAe,OAAO,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"nl.d.ts","sourceRoot":"","sources":["../../../src/commands/text/nl.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAU3C,QAAA,MAAM,OAAO,EAAE,OAuDd,CAAC;AAEF,eAAe,OAAO,CAAC"}
1
+ {"version":3,"file":"nl.d.ts","sourceRoot":"","sources":["../../../src/commands/text/nl.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAW3C,QAAA,MAAM,OAAO,EAAE,OA4Dd,CAAC;AAEF,eAAe,OAAO,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"rev.d.ts","sourceRoot":"","sources":["../../../src/commands/text/rev.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAQ3C,QAAA,MAAM,OAAO,EAAE,OA6Bd,CAAC;AAEF,eAAe,OAAO,CAAC"}
1
+ {"version":3,"file":"rev.d.ts","sourceRoot":"","sources":["../../../src/commands/text/rev.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAS3C,QAAA,MAAM,OAAO,EAAE,OAkCd,CAAC;AAEF,eAAe,OAAO,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"sed.d.ts","sourceRoot":"","sources":["../../../src/commands/text/sed.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AA+D3C,QAAA,MAAM,OAAO,EAAE,OA0Fd,CAAC;AAEF,eAAe,OAAO,CAAC"}
1
+ {"version":3,"file":"sed.d.ts","sourceRoot":"","sources":["../../../src/commands/text/sed.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAgE3C,QAAA,MAAM,OAAO,EAAE,OA+Fd,CAAC;AAEF,eAAe,OAAO,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"sort.d.ts","sourceRoot":"","sources":["../../../src/commands/text/sort.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAI3C,QAAA,MAAM,OAAO,EAAE,OA2Ed,CAAC;AAEF,eAAe,OAAO,CAAC"}
1
+ {"version":3,"file":"sort.d.ts","sourceRoot":"","sources":["../../../src/commands/text/sort.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAK3C,QAAA,MAAM,OAAO,EAAE,OAgFd,CAAC;AAEF,eAAe,OAAO,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"tail.d.ts","sourceRoot":"","sources":["../../../src/commands/text/tail.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAI3C,QAAA,MAAM,OAAO,EAAE,OAkDd,CAAC;AAEF,eAAe,OAAO,CAAC"}
1
+ {"version":3,"file":"tail.d.ts","sourceRoot":"","sources":["../../../src/commands/text/tail.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAK3C,QAAA,MAAM,OAAO,EAAE,OAuDd,CAAC;AAEF,eAAe,OAAO,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"uniq.d.ts","sourceRoot":"","sources":["../../../src/commands/text/uniq.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAI3C,QAAA,MAAM,OAAO,EAAE,OAgEd,CAAC;AAEF,eAAe,OAAO,CAAC"}
1
+ {"version":3,"file":"uniq.d.ts","sourceRoot":"","sources":["../../../src/commands/text/uniq.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAK3C,QAAA,MAAM,OAAO,EAAE,OAqEd,CAAC;AAEF,eAAe,OAAO,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"wc.d.ts","sourceRoot":"","sources":["../../../src/commands/text/wc.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAI3C,QAAA,MAAM,OAAO,EAAE,OAkFd,CAAC;AAEF,eAAe,OAAO,CAAC"}
1
+ {"version":3,"file":"wc.d.ts","sourceRoot":"","sources":["../../../src/commands/text/wc.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAK3C,QAAA,MAAM,OAAO,EAAE,OAgGd,CAAC;AAEF,eAAe,OAAO,CAAC"}
@@ -1,4 +1,4 @@
1
- import { r as t, b as n, V as o } from "./index-DccAPaZF.js";
1
+ import { r as t, b as n, V as o } from "./index-CvsPTm3-.js";
2
2
  const f = async (s) => {
3
3
  if (s.args.length < 2)
4
4
  return s.stderr.write(`cp: missing operand
@@ -0,0 +1,65 @@
1
+ import { r as d, i as c, c as u, V as g } from "./index-CvsPTm3-.js";
2
+ function h(e) {
3
+ const i = [];
4
+ for (const r of e.split(",")) {
5
+ const n = r.split("-");
6
+ if (n.length === 2) {
7
+ const a = parseInt(n[0], 10), o = parseInt(n[1], 10);
8
+ if (!isNaN(a) && !isNaN(o))
9
+ for (let l = a; l <= o; l++) i.push(l);
10
+ } else {
11
+ const a = parseInt(r, 10);
12
+ isNaN(a) || i.push(a);
13
+ }
14
+ }
15
+ return i;
16
+ }
17
+ const w = async (e) => {
18
+ let i = " ", r = "";
19
+ const n = [];
20
+ for (let s = 0; s < e.args.length; s++) {
21
+ const t = e.args[s];
22
+ t === "-d" && s + 1 < e.args.length ? i = e.args[++s] : t === "-f" && s + 1 < e.args.length ? r = e.args[++s] : t.startsWith("-d") && t.length > 2 ? i = t.slice(2) : t.startsWith("-f") && t.length > 2 ? r = t.slice(2) : n.push(t);
23
+ }
24
+ if (!r)
25
+ return e.stderr.write(`cut: you must specify a list of fields
26
+ `), 1;
27
+ const a = h(r);
28
+ function o(s) {
29
+ const t = s.split(i);
30
+ return a.map((f) => t[f - 1] || "").join(i);
31
+ }
32
+ let l = "";
33
+ if (n.length === 0)
34
+ if (e.stdin)
35
+ l = await e.stdin.readAll();
36
+ else
37
+ return e.stderr.write(`cut: missing file operand
38
+ `), 1;
39
+ else
40
+ for (const s of n) {
41
+ const t = d(e.cwd, s);
42
+ try {
43
+ if (e.vfs.stat(t), c(u(t))) {
44
+ e.stderr.write(`cut: ${s}: binary file, skipping
45
+ `);
46
+ continue;
47
+ }
48
+ l += e.vfs.readFileString(t);
49
+ } catch (f) {
50
+ if (f instanceof g)
51
+ return e.stderr.write(`cut: ${s}: ${f.message}
52
+ `), 1;
53
+ throw f;
54
+ }
55
+ }
56
+ const p = l.replace(/\n$/, "").split(`
57
+ `);
58
+ for (const s of p)
59
+ e.stdout.write(o(s) + `
60
+ `);
61
+ return 0;
62
+ };
63
+ export {
64
+ w as default
65
+ };
@@ -0,0 +1,150 @@
1
+ import { p as k } from "./args-CG6b9cZt.js";
2
+ import { r as g, i as m, c as C, V as y } from "./index-CvsPTm3-.js";
3
+ const S = {
4
+ unified: { type: "boolean", short: "u" }
5
+ };
6
+ function L(n, f) {
7
+ const d = n.length, s = f.length, i = Array.from({ length: d + 1 }, () => new Array(s + 1).fill(0));
8
+ for (let e = 1; e <= d; e++)
9
+ for (let o = 1; o <= s; o++)
10
+ n[e - 1] === f[o - 1] ? i[e][o] = i[e - 1][o - 1] + 1 : i[e][o] = Math.max(i[e - 1][o], i[e][o - 1]);
11
+ const h = [];
12
+ let l = d, r = s;
13
+ for (; l > 0 || r > 0; )
14
+ l > 0 && r > 0 && n[l - 1] === f[r - 1] ? (h.push({ type: "keep", oldLine: n[l - 1] }), l--, r--) : r > 0 && (l === 0 || i[l][r - 1] >= i[l - 1][r]) ? (h.push({ type: "insert", newLine: f[r - 1] }), r--) : (h.push({ type: "delete", oldLine: n[l - 1] }), l--);
15
+ return h.reverse();
16
+ }
17
+ function j(n) {
18
+ const f = [];
19
+ let d = 0, s = 0, i = 0;
20
+ for (; i < n.length; ) {
21
+ if (n[i].type === "keep") {
22
+ d++, s++, i++;
23
+ continue;
24
+ }
25
+ const l = d, r = s, e = [], o = [];
26
+ for (; i < n.length && n[i].type !== "keep"; )
27
+ n[i].type === "delete" ? (e.push(n[i].oldLine), d++) : (o.push(n[i].newLine), s++), i++;
28
+ const c = e.length === 1 ? `${l + 1}` : e.length > 0 ? `${l + 1},${l + e.length}` : `${l}`, t = o.length === 1 ? `${r + 1}` : o.length > 0 ? `${r + 1},${r + o.length}` : `${r}`;
29
+ if (e.length > 0 && o.length > 0) {
30
+ f.push(`${c}c${t}`);
31
+ for (const p of e) f.push(`< ${p}`);
32
+ f.push("---");
33
+ for (const p of o) f.push(`> ${p}`);
34
+ } else if (e.length > 0) {
35
+ f.push(`${c}d${t}`);
36
+ for (const p of e) f.push(`< ${p}`);
37
+ } else {
38
+ f.push(`${c}a${t}`);
39
+ for (const p of o) f.push(`> ${p}`);
40
+ }
41
+ }
42
+ return f.length > 0 ? f.join(`
43
+ `) + `
44
+ ` : "";
45
+ }
46
+ function v(n, f, d) {
47
+ if (n.every((t) => t.type === "keep")) return "";
48
+ const s = [];
49
+ let i = 0, h = 0;
50
+ for (const t of n)
51
+ t.type === "keep" ? (s.push({ type: "keep", line: t.oldLine, oldIdx: i, newIdx: h }), i++, h++) : t.type === "delete" ? (s.push({ type: "delete", line: t.oldLine, oldIdx: i, newIdx: h }), i++) : (s.push({ type: "insert", line: t.newLine, oldIdx: i, newIdx: h }), h++);
52
+ const l = 3, r = [];
53
+ let e = null, o = -1 / 0;
54
+ for (let t = 0; t < s.length; t++) {
55
+ const p = s[t];
56
+ if (p.type !== "keep") {
57
+ if (!e || t - o > l * 2 + 1) {
58
+ if (e) {
59
+ for (let a = o + 1; a < Math.min(o + 1 + l, s.length); a++)
60
+ s[a].type === "keep" && (e.lines.push(` ${s[a].line}`), e.oldCount++, e.newCount++);
61
+ r.push(e);
62
+ }
63
+ const $ = Math.max(0, t - l);
64
+ let u = 0, w = 0;
65
+ for (let a = 0; a < $; a++)
66
+ s[a].type !== "insert" && u++, s[a].type !== "delete" && w++;
67
+ e = {
68
+ oldStart: u + 1,
69
+ newStart: w + 1,
70
+ oldCount: 0,
71
+ newCount: 0,
72
+ lines: []
73
+ };
74
+ for (let a = $; a < t; a++)
75
+ s[a].type === "keep" && (e.lines.push(` ${s[a].line}`), e.oldCount++, e.newCount++);
76
+ } else if (t - o > 1)
77
+ for (let $ = o + 1; $ < t; $++)
78
+ s[$].type === "keep" && (e.lines.push(` ${s[$].line}`), e.oldCount++, e.newCount++);
79
+ p.type === "delete" ? (e.lines.push(`-${p.line}`), e.oldCount++) : (e.lines.push(`+${p.line}`), e.newCount++), o = t;
80
+ }
81
+ }
82
+ if (e) {
83
+ for (let t = o + 1; t < Math.min(o + 1 + l, s.length); t++)
84
+ s[t].type === "keep" && (e.lines.push(` ${s[t].line}`), e.oldCount++, e.newCount++);
85
+ r.push(e);
86
+ }
87
+ const c = [];
88
+ c.push(`--- ${f}`), c.push(`+++ ${d}`);
89
+ for (const t of r)
90
+ c.push(`@@ -${t.oldStart},${t.oldCount} +${t.newStart},${t.newCount} @@`), c.push(...t.lines);
91
+ return c.join(`
92
+ `) + `
93
+ `;
94
+ }
95
+ const A = async (n) => {
96
+ const { flags: f, positional: d } = k(n.args, S);
97
+ if (d.length < 2)
98
+ return n.stderr.write(`diff: missing operand
99
+ `), 2;
100
+ const s = d[0], i = d[1];
101
+ let h, l;
102
+ const r = g(n.cwd, s), e = g(n.cwd, i), o = m(C(r)), c = m(C(e));
103
+ if (o || c) {
104
+ try {
105
+ n.vfs.stat(r);
106
+ } catch (u) {
107
+ if (u instanceof y)
108
+ return n.stderr.write(`diff: ${s}: ${u.message}
109
+ `), 2;
110
+ throw u;
111
+ }
112
+ try {
113
+ n.vfs.stat(e);
114
+ } catch (u) {
115
+ if (u instanceof y)
116
+ return n.stderr.write(`diff: ${i}: ${u.message}
117
+ `), 2;
118
+ throw u;
119
+ }
120
+ return n.stdout.write(`Binary files ${s} and ${i} differ
121
+ `), 2;
122
+ }
123
+ try {
124
+ h = n.vfs.readFileString(g(n.cwd, s));
125
+ } catch (u) {
126
+ if (u instanceof y)
127
+ return n.stderr.write(`diff: ${s}: ${u.message}
128
+ `), 2;
129
+ throw u;
130
+ }
131
+ try {
132
+ l = n.vfs.readFileString(g(n.cwd, i));
133
+ } catch (u) {
134
+ if (u instanceof y)
135
+ return n.stderr.write(`diff: ${i}: ${u.message}
136
+ `), 2;
137
+ throw u;
138
+ }
139
+ if (h === l)
140
+ return 0;
141
+ const t = h.split(`
142
+ `), p = l.split(`
143
+ `);
144
+ t.length > 0 && t[t.length - 1] === "" && t.pop(), p.length > 0 && p[p.length - 1] === "" && p.pop();
145
+ const $ = L(t, p);
146
+ return f.unified ? n.stdout.write(v($, s, i)) : n.stdout.write(j($)), 1;
147
+ };
148
+ export {
149
+ A as default
150
+ };
@@ -1,4 +1,4 @@
1
- import { d as a } from "./index-DccAPaZF.js";
1
+ import { k as a } from "./index-CvsPTm3-.js";
2
2
  const s = async (r) => {
3
3
  if (r.args.length === 0)
4
4
  return r.stderr.write(`dirname: missing operand
@@ -1,4 +1,4 @@
1
- import { r as y, V as g } from "./index-DccAPaZF.js";
1
+ import { r as y, V as g } from "./index-CvsPTm3-.js";
2
2
  function u(t) {
3
3
  return t < 1024 ? t + "B" : t < 1024 * 1024 ? (t / 1024).toFixed(1) + "K" : t < 1024 * 1024 * 1024 ? (t / (1024 * 1024)).toFixed(1) + "M" : (t / (1024 * 1024 * 1024)).toFixed(1) + "G";
4
4
  }
@@ -1,4 +1,4 @@
1
- import { r as d, e as c, V as f } from "./index-DccAPaZF.js";
1
+ import { r as d, e as c, V as f } from "./index-CvsPTm3-.js";
2
2
  const n = {
3
3
  ".txt": "ASCII text",
4
4
  ".md": "Markdown text",
@@ -1,4 +1,4 @@
1
- import { r as m, V as d, g as p } from "./index-DccAPaZF.js";
1
+ import { r as m, V as d, g as p } from "./index-CvsPTm3-.js";
2
2
  const c = async (t) => {
3
3
  let f = ".", i = "", a = "", l = 1 / 0;
4
4
  for (let e = 0; e < t.args.length; e++) {
@@ -1,13 +1,13 @@
1
- import { r as M, V } from "./index-DccAPaZF.js";
2
- const A = async (r) => {
1
+ import { r as W, i as E, c as S, V as j } from "./index-CvsPTm3-.js";
2
+ const C = async (r) => {
3
3
  const c = r.args;
4
4
  let w = !1, y = !1, b = !1, u = !1, k = !1, p = !1, m = !1, o = "";
5
5
  const f = [];
6
- let i = 0;
7
- for (; i < c.length; ) {
8
- const e = c[i];
6
+ let a = 0;
7
+ for (; a < c.length; ) {
8
+ const e = c[a];
9
9
  if (e === "--") {
10
- i++;
10
+ a++;
11
11
  break;
12
12
  }
13
13
  if (e.startsWith("-") && e.length > 1 && e[1] !== "-") {
@@ -38,14 +38,14 @@ const A = async (r) => {
38
38
  m = !0;
39
39
  break;
40
40
  }
41
- i++;
41
+ a++;
42
42
  } else if (!o)
43
- o = e, i++;
43
+ o = e, a++;
44
44
  else
45
45
  break;
46
46
  }
47
- for (; i < c.length; )
48
- f.push(c[i++]);
47
+ for (; a < c.length; )
48
+ f.push(c[a++]);
49
49
  if (!o)
50
50
  return r.stderr.write(`grep: missing pattern
51
51
  `), 2;
@@ -63,17 +63,17 @@ const A = async (r) => {
63
63
  async function h(e, t) {
64
64
  let n = 0;
65
65
  for (let s = 0; s < e.length; s++) {
66
- const a = e[s];
67
- if (v.test(a) !== y) {
66
+ const l = e[s];
67
+ if (v.test(l) !== y) {
68
68
  if ($ = !0, n++, k) {
69
69
  t && r.stdout.write(t + `
70
70
  `);
71
71
  return;
72
72
  }
73
73
  if (!u) {
74
- let l = "";
75
- d && t && (l += t + ":"), b && (l += s + 1 + ":"), l += a + `
76
- `, r.stdout.write(l);
74
+ let i = "";
75
+ d && t && (i += t + ":"), b && (i += s + 1 + ":"), i += l + `
76
+ `, r.stdout.write(i);
77
77
  }
78
78
  }
79
79
  }
@@ -88,8 +88,8 @@ const A = async (r) => {
88
88
  try {
89
89
  const n = r.vfs.readdir(e);
90
90
  for (const s of n) {
91
- const a = e === "/" ? "/" + s.name : e + "/" + s.name;
92
- s.type === "file" ? t.push(a) : s.type === "directory" && t.push(...F(a));
91
+ const l = e === "/" ? "/" + s.name : e + "/" + s.name;
92
+ s.type === "file" ? t.push(l) : s.type === "directory" && t.push(...F(l));
93
93
  }
94
94
  } catch {
95
95
  }
@@ -105,16 +105,18 @@ const A = async (r) => {
105
105
  `), 2;
106
106
  else
107
107
  for (const e of f) {
108
- const t = M(r.cwd, e);
108
+ const t = W(r.cwd, e);
109
109
  try {
110
110
  if (r.vfs.stat(t).type === "directory") {
111
111
  if (p) {
112
- const E = F(t);
113
- for (const l of E)
112
+ const M = F(t);
113
+ for (const i of M)
114
114
  try {
115
- const S = r.vfs.readFileString(l).replace(/\n$/, "").split(`
115
+ if (E(S(i)))
116
+ continue;
117
+ const V = r.vfs.readFileString(i).replace(/\n$/, "").split(`
116
118
  `);
117
- await h(S, l);
119
+ await h(V, i);
118
120
  } catch {
119
121
  }
120
122
  } else
@@ -122,11 +124,16 @@ const A = async (r) => {
122
124
  `);
123
125
  continue;
124
126
  }
125
- const a = r.vfs.readFileString(t).replace(/\n$/, "").split(`
127
+ if (E(S(t))) {
128
+ r.stderr.write(`grep: ${e}: binary file, skipping
126
129
  `);
127
- await h(a, d ? e : null);
130
+ continue;
131
+ }
132
+ const l = r.vfs.readFileString(t).replace(/\n$/, "").split(`
133
+ `);
134
+ await h(l, d ? e : null);
128
135
  } catch (n) {
129
- if (n instanceof V)
136
+ if (n instanceof j)
130
137
  r.stderr.write(`grep: ${e}: ${n.message}
131
138
  `);
132
139
  else
@@ -136,5 +143,5 @@ const A = async (r) => {
136
143
  return $ ? 0 : 1;
137
144
  };
138
145
  export {
139
- A as default
146
+ C as default
140
147
  };