@poe-platform/safe-bash 0.1.534 → 0.1.536

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 (123) hide show
  1. package/dist/safe-bash/chunks/chunk-5Y4AEZB2.js +517 -0
  2. package/dist/safe-bash/chunks/chunk-5Y4AEZB2.js.map +7 -0
  3. package/dist/safe-bash/chunks/{chunk-IKATLB4I.js → chunk-AVXYPKV7.js} +7 -5
  4. package/dist/safe-bash/chunks/{chunk-IKATLB4I.js.map → chunk-AVXYPKV7.js.map} +1 -1
  5. package/dist/safe-bash/chunks/chunk-FRSZDCZA.js +1236 -0
  6. package/dist/safe-bash/chunks/chunk-FRSZDCZA.js.map +7 -0
  7. package/dist/safe-bash/chunks/{chunk-LUJYX5H5.js → chunk-L2GZSOSJ.js} +245 -747
  8. package/dist/safe-bash/chunks/chunk-L2GZSOSJ.js.map +7 -0
  9. package/dist/safe-bash/chunks/{chunk-54Z5EUCW.js → chunk-M7KZ7V4P.js} +2 -2
  10. package/dist/safe-bash/chunks/{chunk-UGMUVHIY.js → chunk-NVUC5B2R.js} +10 -188
  11. package/dist/safe-bash/chunks/{chunk-UGMUVHIY.js.map → chunk-NVUC5B2R.js.map} +3 -3
  12. package/dist/safe-bash/chunks/{chunk-2GV4WO7O.js → chunk-PPVCI2F2.js} +2 -2
  13. package/dist/safe-bash/chunks/chunk-QY2XHZTE.js +192 -0
  14. package/dist/safe-bash/chunks/chunk-QY2XHZTE.js.map +7 -0
  15. package/dist/safe-bash/chunks/{chunk-6MHYEBAJ.js → chunk-UZELUFGF.js} +8 -6
  16. package/dist/safe-bash/chunks/{chunk-6MHYEBAJ.js.map → chunk-UZELUFGF.js.map} +1 -1
  17. package/dist/safe-bash/chunks/chunk-XROAIPKA.js +12095 -0
  18. package/dist/safe-bash/chunks/chunk-XROAIPKA.js.map +7 -0
  19. package/dist/safe-bash/commands/csplit/command.d.ts +6 -0
  20. package/dist/safe-bash/commands/csplit/command.d.ts.map +1 -0
  21. package/dist/safe-bash/commands/csplit/command.js +78 -0
  22. package/dist/safe-bash/commands/csplit/command.js.map +1 -0
  23. package/dist/safe-bash/commands/csplit/index.browser.js +14 -0
  24. package/dist/safe-bash/commands/csplit/index.browser.js.map +7 -0
  25. package/dist/safe-bash/commands/csplit/index.d.ts +7 -0
  26. package/dist/safe-bash/commands/csplit/index.d.ts.map +1 -0
  27. package/dist/safe-bash/commands/csplit/index.js +21 -0
  28. package/dist/safe-bash/commands/csplit/index.js.map +1 -0
  29. package/dist/safe-bash/commands/csplit/internal.d.ts +61 -0
  30. package/dist/safe-bash/commands/csplit/internal.d.ts.map +1 -0
  31. package/dist/safe-bash/commands/csplit/internal.js +147 -0
  32. package/dist/safe-bash/commands/csplit/internal.js.map +1 -0
  33. package/dist/safe-bash/commands/csplit/io.d.ts +52 -0
  34. package/dist/safe-bash/commands/csplit/io.d.ts.map +1 -0
  35. package/dist/safe-bash/commands/csplit/io.js +330 -0
  36. package/dist/safe-bash/commands/csplit/io.js.map +1 -0
  37. package/dist/safe-bash/commands/csplit/options.d.ts +16 -0
  38. package/dist/safe-bash/commands/csplit/options.d.ts.map +1 -0
  39. package/dist/safe-bash/commands/csplit/options.js +178 -0
  40. package/dist/safe-bash/commands/csplit/options.js.map +1 -0
  41. package/dist/safe-bash/commands/csplit/patterns.d.ts +19 -0
  42. package/dist/safe-bash/commands/csplit/patterns.d.ts.map +1 -0
  43. package/dist/safe-bash/commands/csplit/patterns.js +92 -0
  44. package/dist/safe-bash/commands/csplit/patterns.js.map +1 -0
  45. package/dist/safe-bash/commands/csplit/quoting.d.ts +2 -0
  46. package/dist/safe-bash/commands/csplit/quoting.d.ts.map +1 -0
  47. package/dist/safe-bash/commands/csplit/quoting.js +138 -0
  48. package/dist/safe-bash/commands/csplit/quoting.js.map +1 -0
  49. package/dist/safe-bash/commands/csplit/split.d.ts +18 -0
  50. package/dist/safe-bash/commands/csplit/split.d.ts.map +1 -0
  51. package/dist/safe-bash/commands/csplit/split.js +122 -0
  52. package/dist/safe-bash/commands/csplit/split.js.map +1 -0
  53. package/dist/safe-bash/commands/expr/bre-engine.d.ts +4 -1
  54. package/dist/safe-bash/commands/expr/bre-engine.d.ts.map +1 -1
  55. package/dist/safe-bash/commands/expr/bre-engine.js +724 -13
  56. package/dist/safe-bash/commands/expr/bre-engine.js.map +1 -1
  57. package/dist/safe-bash/commands/expr/bre-worker.d.ts +2 -1
  58. package/dist/safe-bash/commands/expr/bre-worker.d.ts.map +1 -1
  59. package/dist/safe-bash/commands/expr/bre-worker.js +10 -1
  60. package/dist/safe-bash/commands/expr/bre-worker.js.map +1 -1
  61. package/dist/safe-bash/commands/network/index.browser.js +5 -3
  62. package/dist/safe-bash/commands/pr/command.d.ts +4 -0
  63. package/dist/safe-bash/commands/pr/command.d.ts.map +1 -0
  64. package/dist/safe-bash/commands/pr/command.js +117 -0
  65. package/dist/safe-bash/commands/pr/command.js.map +1 -0
  66. package/dist/safe-bash/commands/pr/format.d.ts +52 -0
  67. package/dist/safe-bash/commands/pr/format.d.ts.map +1 -0
  68. package/dist/safe-bash/commands/pr/format.js +527 -0
  69. package/dist/safe-bash/commands/pr/format.js.map +1 -0
  70. package/dist/safe-bash/commands/pr/index.browser.js +13 -0
  71. package/dist/safe-bash/commands/pr/index.browser.js.map +7 -0
  72. package/dist/safe-bash/commands/pr/index.d.ts +7 -0
  73. package/dist/safe-bash/commands/pr/index.d.ts.map +1 -0
  74. package/dist/safe-bash/commands/pr/index.js +13 -0
  75. package/dist/safe-bash/commands/pr/index.js.map +1 -0
  76. package/dist/safe-bash/commands/pr/internal.d.ts +61 -0
  77. package/dist/safe-bash/commands/pr/internal.d.ts.map +1 -0
  78. package/dist/safe-bash/commands/pr/internal.js +181 -0
  79. package/dist/safe-bash/commands/pr/internal.js.map +1 -0
  80. package/dist/safe-bash/commands/pr/io.d.ts +37 -0
  81. package/dist/safe-bash/commands/pr/io.d.ts.map +1 -0
  82. package/dist/safe-bash/commands/pr/io.js +210 -0
  83. package/dist/safe-bash/commands/pr/io.js.map +1 -0
  84. package/dist/safe-bash/commands/pr/options.d.ts +36 -0
  85. package/dist/safe-bash/commands/pr/options.d.ts.map +1 -0
  86. package/dist/safe-bash/commands/pr/options.js +250 -0
  87. package/dist/safe-bash/commands/pr/options.js.map +1 -0
  88. package/dist/safe-bash/commands/regex-execution/bounded-provider.d.ts.map +1 -1
  89. package/dist/safe-bash/commands/regex-execution/bounded-provider.js +16 -5
  90. package/dist/safe-bash/commands/regex-execution/bounded-provider.js.map +1 -1
  91. package/dist/safe-bash/commands/regex-execution/portable.d.ts +3 -1
  92. package/dist/safe-bash/commands/regex-execution/portable.d.ts.map +1 -1
  93. package/dist/safe-bash/commands/regex-execution/portable.js +17 -4
  94. package/dist/safe-bash/commands/regex-execution/portable.js.map +1 -1
  95. package/dist/safe-bash/commands/regex-execution/protocol.d.ts +31 -0
  96. package/dist/safe-bash/commands/regex-execution/protocol.d.ts.map +1 -1
  97. package/dist/safe-bash/commands/regex-execution/protocol.js +83 -0
  98. package/dist/safe-bash/commands/regex-execution/protocol.js.map +1 -1
  99. package/dist/safe-bash/commands/regex-execution/provider.d.ts +2 -2
  100. package/dist/safe-bash/commands/regex-execution/provider.d.ts.map +1 -1
  101. package/dist/safe-bash/commands/regex-execution/worker.js +16 -2
  102. package/dist/safe-bash/commands/regex-execution/worker.js.map +1 -1
  103. package/dist/safe-bash/commands/xml/index.browser.js +4 -3
  104. package/dist/safe-bash/commands/yq/index.browser.js +5 -4
  105. package/dist/safe-bash/core.browser.js +1953 -4081
  106. package/dist/safe-bash/core.browser.js.map +4 -4
  107. package/dist/safe-bash/core.d.ts +2 -0
  108. package/dist/safe-bash/core.d.ts.map +1 -1
  109. package/dist/safe-bash/core.js +2 -0
  110. package/dist/safe-bash/core.js.map +1 -1
  111. package/dist/safe-bash/plugins/composition.d.ts +5 -0
  112. package/dist/safe-bash/plugins/composition.d.ts.map +1 -1
  113. package/dist/safe-bash/plugins/composition.js +7 -1
  114. package/dist/safe-bash/plugins/composition.js.map +1 -1
  115. package/dist/safe-bash/plugins/index.js +1 -1
  116. package/dist/safe-bash/plugins/index.js.map +1 -1
  117. package/dist/safe-bash/shell/runtime.d.ts.map +1 -1
  118. package/dist/safe-bash/shell/runtime.js +28 -3
  119. package/dist/safe-bash/shell/runtime.js.map +1 -1
  120. package/package.json +14 -2
  121. package/dist/safe-bash/chunks/chunk-LUJYX5H5.js.map +0 -7
  122. /package/dist/safe-bash/chunks/{chunk-54Z5EUCW.js.map → chunk-M7KZ7V4P.js.map} +0 -0
  123. /package/dist/safe-bash/chunks/{chunk-2GV4WO7O.js.map → chunk-PPVCI2F2.js.map} +0 -0
@@ -0,0 +1,517 @@
1
+ import {
2
+ FsError,
3
+ PublicDiagnostic,
4
+ import_buffer,
5
+ init_platform,
6
+ isAbsolutePath,
7
+ publicDiagnosticMessage,
8
+ readBytes,
9
+ toByteSource,
10
+ validatePath,
11
+ writeBytes,
12
+ yieldTurn
13
+ } from "./chunk-L2GZSOSJ.js";
14
+
15
+ // packages/safe-bash/src/contracts/command-requirements.ts
16
+ init_platform();
17
+ function evaluateMode(requirement, capabilities) {
18
+ const missing = requirement.capabilities.filter((name) => capabilities[name] === false);
19
+ const unknown = requirement.capabilities.filter((name) => capabilities[name] === void 0);
20
+ if (requirement.mutates && capabilities.readOnly === true) missing.push("readOnly");
21
+ const alternatives = requirement.anyOf;
22
+ if (alternatives && !alternatives.some((group) => group.every((name) => capabilities[name] === true))) {
23
+ if (alternatives.every((group) => group.some((name) => capabilities[name] === false))) {
24
+ missing.push(...alternatives.flatMap((group) => group.filter((name) => capabilities[name] === false)));
25
+ } else {
26
+ unknown.push(...alternatives.filter((group) => !group.some((name) => capabilities[name] === false)).flatMap((group) => group.filter((name) => capabilities[name] === void 0)));
27
+ }
28
+ }
29
+ return {
30
+ ...requirement,
31
+ status: missing.length ? "unsupported" : unknown.length ? "unknown" : "supported",
32
+ missing: [...new Set(missing)],
33
+ unknown: [...new Set(unknown)]
34
+ };
35
+ }
36
+ function evaluateCommandSupport(command, capabilities) {
37
+ const modes = (command.filesystemRequirements ?? []).map((requirement) => evaluateMode(requirement, capabilities));
38
+ return {
39
+ declared: command.filesystemRequirements !== void 0,
40
+ status: command.filesystemRequirements !== void 0 && modes.every((mode) => mode.status === "supported") ? "supported" : modes.length && modes.every((mode) => mode.status === "unsupported") ? "unsupported" : "partial",
41
+ modes
42
+ };
43
+ }
44
+ function assertCommandRequirements(context, requirements, selected, capabilities = context.fs.capabilities) {
45
+ context.signal.throwIfAborted();
46
+ for (const id of new Set(selected)) {
47
+ const requirement = requirements.find((mode) => mode.id === id);
48
+ if (!requirement) throw new TypeError(`Unknown filesystem requirement mode: ${id}`);
49
+ const support = evaluateMode(requirement, capabilities);
50
+ if (support.status === "unsupported") {
51
+ throw new FsError(support.missing.includes("readOnly") ? "EROFS" : "ENOTSUP", {
52
+ syscall: context.command,
53
+ message: `${requirement.description} requires unavailable filesystem capabilities: ${support.missing.join(", ")}`
54
+ });
55
+ }
56
+ }
57
+ }
58
+
59
+ // packages/safe-bash/src/escaping.ts
60
+ init_platform();
61
+ var controls = { 8: "\\b", 9: "\\t", 10: "\\n", 11: "\\v", 12: "\\f", 13: "\\r", 92: "\\\\" };
62
+ var encoder = new TextEncoder();
63
+ function* parts(value2, mode) {
64
+ for (const character of value2) {
65
+ const point = character.codePointAt(0);
66
+ if (mode === "diagnostic" && (point === 9 || point === 10 || point >= 32 && (point < 127 || point > 159))) {
67
+ yield character;
68
+ } else {
69
+ for (const byte of encoder.encode(character)) {
70
+ yield controls[byte] ?? (byte >= 32 && byte < 127 ? String.fromCharCode(byte) : `\\${byte.toString(8).padStart(3, "0")}`);
71
+ }
72
+ }
73
+ }
74
+ }
75
+ function escapeText(value2, mode, checkOutput) {
76
+ let result = "", bytes = 0;
77
+ for (const part of parts(value2, mode)) {
78
+ bytes += import_buffer.Buffer.byteLength(part);
79
+ checkOutput?.(bytes);
80
+ result += part;
81
+ }
82
+ return result;
83
+ }
84
+ async function writeDiagnostic(sink, value2, signal) {
85
+ signal?.throwIfAborted();
86
+ let chunk = "", bytes = 0, work = 0;
87
+ for (const part of parts(value2, "diagnostic")) {
88
+ signal?.throwIfAborted();
89
+ const size = import_buffer.Buffer.byteLength(part);
90
+ if (bytes + size > 16384) {
91
+ await writeBytes(sink, encoder.encode(chunk), signal);
92
+ chunk = "";
93
+ bytes = 0;
94
+ }
95
+ chunk += part;
96
+ bytes += size;
97
+ if (++work % 1024 === 0) await yieldTurn(signal);
98
+ }
99
+ if (bytes) await writeBytes(sink, encoder.encode(chunk), signal);
100
+ signal?.throwIfAborted();
101
+ }
102
+
103
+ // packages/safe-bash/src/commands/internal.ts
104
+ init_platform();
105
+
106
+ // packages/safe-bash/src/commands/portable-requirements.ts
107
+ init_platform();
108
+ var inputRequirements = [
109
+ { id: "stdin", description: "Read standard input", capabilities: [] },
110
+ { id: "file", description: "Read file operands", capabilities: [], anyOf: [["streamingRead"], ["read"]] }
111
+ ];
112
+ var textOutputRequirements = [
113
+ ...inputRequirements,
114
+ { id: "output", description: "Write or truncate an output file", capabilities: [], anyOf: [["streamingWrite"], ["write"]], mutates: true }
115
+ ];
116
+ var pwdRequirements = [
117
+ { id: "logical", description: "Print the logical working directory", capabilities: [] },
118
+ { id: "physical", description: "Resolve the physical working directory (-P)", capabilities: ["realpath"] }
119
+ ];
120
+ var predicateRequirements = [
121
+ { id: "expression", description: "Evaluate strings and integers", capabilities: [] },
122
+ { id: "metadata", description: "Inspect file metadata", capabilities: ["stat"] },
123
+ { id: "access", description: "Inspect path access permissions", capabilities: ["access"] }
124
+ ];
125
+
126
+ // packages/safe-bash/src/commands/record-buffer.ts
127
+ init_platform();
128
+ var segmentSize = 4096;
129
+ var RecordBuffer = class {
130
+ constructor(capacity, finalizationCapacity = capacity * 2) {
131
+ this.capacity = capacity;
132
+ this.finalizationCapacity = finalizationCapacity;
133
+ }
134
+ capacity;
135
+ finalizationCapacity;
136
+ #segments = [];
137
+ #size = 0;
138
+ #allocated = 0;
139
+ get size() {
140
+ return this.#size;
141
+ }
142
+ #admit(length) {
143
+ if (length > this.capacity - this.#size) {
144
+ throw new FsError("EFBIG", { message: "line buffer limit exceeded" });
145
+ }
146
+ }
147
+ append(bytes, start = 0, end = bytes.length) {
148
+ this.#admit(end - start);
149
+ let offset = start;
150
+ while (offset < end) {
151
+ let segment = this.#segments.at(-1);
152
+ const used = this.#size % segmentSize;
153
+ if (!segment || used === 0) {
154
+ segment = new Uint8Array(Math.min(segmentSize, this.capacity - this.#allocated));
155
+ this.#segments.push(segment);
156
+ this.#allocated += segment.length;
157
+ }
158
+ const length = Math.min(end - offset, segment.length - used);
159
+ segment.set(bytes.subarray(offset, offset + length), used);
160
+ this.#size += length;
161
+ offset += length;
162
+ }
163
+ }
164
+ finish(admit, bytes, start = 0, end = bytes?.length ?? 0) {
165
+ this.#admit(end - start);
166
+ const size = this.#size + end - start;
167
+ admit?.(size);
168
+ if (size > this.finalizationCapacity - this.#allocated) {
169
+ throw new FsError("EFBIG", { message: "line finalization buffer limit exceeded" });
170
+ }
171
+ const result = new Uint8Array(size);
172
+ let offset = 0;
173
+ for (const segment of this.#segments) {
174
+ const length = Math.min(segment.length, this.#size - offset);
175
+ result.set(segment.subarray(0, length), offset);
176
+ offset += length;
177
+ }
178
+ if (bytes && end > start) result.set(bytes.subarray(start, end), offset);
179
+ this.clear();
180
+ return result;
181
+ }
182
+ clear() {
183
+ this.#segments = [];
184
+ this.#size = 0;
185
+ this.#allocated = 0;
186
+ }
187
+ };
188
+
189
+ // packages/safe-bash/src/commands/internal.ts
190
+ var encoder2 = new TextEncoder();
191
+ var decoder = new TextDecoder();
192
+ var bufferLimit = 32 * 1024 * 1024;
193
+ var UsageError = class extends PublicDiagnostic {
194
+ };
195
+ function options(args, short, long = {}, stopAtOperand = false, onOperand) {
196
+ const flags = /* @__PURE__ */ new Set();
197
+ const values = /* @__PURE__ */ new Map();
198
+ const operands = [];
199
+ const specifications = /* @__PURE__ */ new Map();
200
+ for (let index = 0; index < short.length; index++) {
201
+ const key = short[index];
202
+ specifications.set(key, short[index + 1] === ":");
203
+ if (short[index + 1] === ":") index++;
204
+ }
205
+ let ended = false;
206
+ for (let index = 0; index < args.length; index++) {
207
+ const argument = args[index];
208
+ if (ended || argument === "-" || !argument.startsWith("-")) {
209
+ operands.push(argument);
210
+ onOperand?.(index);
211
+ if (stopAtOperand) ended = true;
212
+ continue;
213
+ }
214
+ if (argument === "--") {
215
+ ended = true;
216
+ continue;
217
+ }
218
+ if (argument.startsWith("--")) {
219
+ const equals = argument.indexOf("=");
220
+ const name = argument.slice(2, equals < 0 ? void 0 : equals);
221
+ const key = long[name];
222
+ if (!key || !specifications.has(key)) throw new UsageError(`unrecognized option '${argument}'`);
223
+ if (specifications.get(key)) {
224
+ const value2 = equals >= 0 ? argument.slice(equals + 1) : args[++index];
225
+ if (value2 === void 0) throw new UsageError(`option '--${name}' requires an argument`);
226
+ values.set(key, [...values.get(key) ?? [], value2]);
227
+ } else if (equals >= 0) throw new UsageError(`option '--${name}' does not take an argument`);
228
+ flags.add(key);
229
+ continue;
230
+ }
231
+ for (let offset = 1; offset < argument.length; offset++) {
232
+ const key = argument[offset];
233
+ if (!specifications.has(key)) throw new UsageError(`invalid option -- '${key}'`);
234
+ if (specifications.get(key)) {
235
+ const value2 = argument.slice(offset + 1) || args[++index];
236
+ if (value2 === void 0) throw new UsageError(`option requires an argument -- '${key}'`);
237
+ values.set(key, [...values.get(key) ?? [], value2]);
238
+ offset = argument.length;
239
+ }
240
+ flags.add(key);
241
+ }
242
+ }
243
+ return { flags, values, operands };
244
+ }
245
+ function value(parsed, key) {
246
+ return parsed.values.get(key)?.at(-1);
247
+ }
248
+ function integer(text, minimum = 0) {
249
+ if (!/^[+]?[0-9]+$/u.test(text)) throw new UsageError(`invalid number '${text}'`);
250
+ const number = Number(text);
251
+ if (!Number.isSafeInteger(number) || number < minimum) throw new UsageError(`invalid number '${text}'`);
252
+ return number;
253
+ }
254
+ function requireOperands(operands, minimum = 1, maximum = Infinity) {
255
+ if (operands.length < minimum) throw new UsageError("missing operand");
256
+ if (operands.length > maximum) throw new UsageError(`extra operand '${operands[maximum]}'`);
257
+ }
258
+ function pathOf(context, path) {
259
+ if (!path) throw new FsError("ENOENT", { path });
260
+ validatePath(path);
261
+ validatePath(context.cwd);
262
+ if (!isAbsolutePath(context.cwd)) throw new FsError("EINVAL", { path: context.cwd, message: "cwd must be absolute" });
263
+ return isAbsolutePath(path) ? path : `${context.cwd.replace(/\/$/u, "")}/${path}`;
264
+ }
265
+ function codeOf(error) {
266
+ return error instanceof Error && "code" in error ? String(error.code) : void 0;
267
+ }
268
+ async function output(context, text) {
269
+ context.signal.throwIfAborted();
270
+ await writeBytes(context.stdout, typeof text === "string" ? encoder2.encode(text) : text, context.signal);
271
+ }
272
+ async function diagnostic(context, error) {
273
+ context.signal.throwIfAborted();
274
+ await writeDiagnostic(context.stderr, `${context.command}: ${publicDiagnosticMessage(error, context.onInternalError)}
275
+ `, context.signal);
276
+ }
277
+ function define(name, handler, failureCode = 1) {
278
+ return {
279
+ name,
280
+ async execute(context) {
281
+ context.signal.throwIfAborted();
282
+ try {
283
+ return await handler(context);
284
+ } catch (error) {
285
+ context.signal.throwIfAborted();
286
+ await diagnostic(context, error);
287
+ return { exitCode: error instanceof UsageError ? 2 : failureCode };
288
+ }
289
+ }
290
+ };
291
+ }
292
+ async function eachOperand(context, operands, operation) {
293
+ let exitCode = 0;
294
+ for (const operand of operands) {
295
+ context.signal.throwIfAborted();
296
+ try {
297
+ await operation(operand);
298
+ } catch (error) {
299
+ await diagnostic(context, error);
300
+ exitCode = 1;
301
+ }
302
+ }
303
+ return { exitCode };
304
+ }
305
+ async function* input(context, name = "-") {
306
+ context.signal.throwIfAborted();
307
+ if (name === "-") {
308
+ yield* readBytes(context.stdin, context.signal);
309
+ } else {
310
+ await assertInputRequirements(context, [name]);
311
+ const path = pathOf(context, name);
312
+ const capabilities = await context.fs.capabilitiesFor?.(path, { signal: context.signal }) ?? context.fs.capabilities;
313
+ if (context.fs.readStream && capabilities.streamingRead !== false) {
314
+ let emitted = false;
315
+ let reading = true;
316
+ try {
317
+ for await (const chunk of readBytes(context.fs.readStream(path, { signal: context.signal }), context.signal)) {
318
+ reading = false;
319
+ if (chunk.byteLength) emitted = true;
320
+ yield chunk;
321
+ reading = true;
322
+ }
323
+ return;
324
+ } catch (error) {
325
+ context.signal.throwIfAborted();
326
+ if (!reading || emitted || !(error instanceof FsError) || error.code !== "ENOTSUP") throw error;
327
+ }
328
+ }
329
+ if (capabilities.read === false) throw new FsError("ENOTSUP", { syscall: "readFile", path });
330
+ yield* readBytes({
331
+ async *[Symbol.asyncIterator]() {
332
+ const bytes = await context.fs.readFile(path, { signal: context.signal, maxBytes: bufferLimit });
333
+ context.signal.throwIfAborted();
334
+ if (bytes.byteLength > bufferLimit) throw new FsError("EFBIG", { syscall: "readFile", path });
335
+ yield bytes;
336
+ }
337
+ }, context.signal);
338
+ }
339
+ }
340
+ async function assertInputRequirements(context, names) {
341
+ const files = names.filter((name) => name !== "-");
342
+ assertCommandRequirements(context, inputRequirements, [files.length ? "file" : "stdin"]);
343
+ if (!context.fs.capabilitiesFor) return;
344
+ for (const name of files) {
345
+ try {
346
+ const capabilities = await context.fs.capabilitiesFor(pathOf(context, name), { signal: context.signal });
347
+ assertCommandRequirements(context, inputRequirements, ["file"], capabilities);
348
+ } catch (error) {
349
+ context.signal.throwIfAborted();
350
+ if (codeOf(error) === "ENOTSUP" || codeOf(error) === "EROFS") throw error;
351
+ }
352
+ }
353
+ }
354
+ function concatenate(chunks, size = chunks.reduce((sum, chunk) => sum + chunk.length, 0)) {
355
+ const result = new Uint8Array(size);
356
+ let offset = 0;
357
+ for (const chunk of chunks) {
358
+ result.set(chunk, offset);
359
+ offset += chunk.length;
360
+ }
361
+ return result;
362
+ }
363
+ async function* lines(source, separator = 10, admit) {
364
+ const pending = new RecordBuffer(bufferLimit);
365
+ try {
366
+ for await (const chunk of source) {
367
+ let start = 0;
368
+ for (let offset = 0; offset < chunk.length; offset++) {
369
+ if (chunk[offset] !== separator) continue;
370
+ yield { bytes: pending.finish(admit, chunk, start, offset), terminated: true };
371
+ start = offset + 1;
372
+ }
373
+ pending.append(chunk, start);
374
+ }
375
+ if (pending.size) yield { bytes: pending.finish(admit), terminated: false };
376
+ } finally {
377
+ pending.clear();
378
+ }
379
+ }
380
+ function emptyInput() {
381
+ return toByteSource("");
382
+ }
383
+ function replaceArgument(source, pattern, replacement) {
384
+ if (typeof source === "string") return source.split(pattern).join(replacement);
385
+ const needle = encoder2.encode(pattern);
386
+ if (!needle.length) throw new UsageError("replacement string cannot be empty");
387
+ const substituted = encoder2.encode(replacement);
388
+ const chunks = [];
389
+ let start = 0;
390
+ for (let offset = 0; offset <= source.length - needle.length; ) {
391
+ if (needle.every((byte, index) => source[offset + index] === byte)) {
392
+ chunks.push(source.subarray(start, offset), substituted);
393
+ offset += needle.length;
394
+ start = offset;
395
+ } else offset++;
396
+ }
397
+ chunks.push(source.subarray(start));
398
+ return concatenate(chunks);
399
+ }
400
+ function escapeBytes(text, zeroOctal = false, bareOctal = false) {
401
+ if (typeof text === "string") {
402
+ const chunks = [];
403
+ const control2 = { a: 7, b: 8, e: 27, E: 27, f: 12, n: 10, r: 13, t: 9, v: 11, "\\": 92 };
404
+ for (let index = 0; index < text.length; ) {
405
+ if (text[index] !== "\\" || index + 1 === text.length) {
406
+ const character = String.fromCodePoint(text.codePointAt(index));
407
+ chunks.push(encoder2.encode(character));
408
+ index += character.length;
409
+ continue;
410
+ }
411
+ const next = text[index + 1];
412
+ if (next === "c") return { bytes: concatenate(chunks), stop: true };
413
+ if (control2[next] !== void 0) {
414
+ chunks.push(Uint8Array.of(control2[next]));
415
+ index += 2;
416
+ continue;
417
+ }
418
+ const rest = text.slice(index + 1);
419
+ const octal = zeroOctal ? (bareOctal ? /^(?:0([0-7]{0,3})|([1-7][0-7]{0,2}))/u : /^0([0-7]{0,3})/u).exec(rest) : /^([0-7]{1,3})/u.exec(rest);
420
+ if (octal) {
421
+ chunks.push(Uint8Array.of(parseInt(octal[1] || octal[2] || "0", 8) & 255));
422
+ index += 1 + octal[0].length;
423
+ continue;
424
+ }
425
+ const hexadecimal = /^x([0-9a-fA-F]{1,2})/u.exec(rest);
426
+ if (hexadecimal) {
427
+ chunks.push(Uint8Array.of(parseInt(hexadecimal[1], 16)));
428
+ index += 1 + hexadecimal[0].length;
429
+ continue;
430
+ }
431
+ chunks.push(encoder2.encode(`\\${next}`));
432
+ index += 2;
433
+ }
434
+ return { bytes: concatenate(chunks), stop: false };
435
+ }
436
+ const source = text;
437
+ const bytes = new Uint8Array(source.length);
438
+ const control = { 97: 7, 98: 8, 101: 27, 69: 27, 102: 12, 110: 10, 114: 13, 116: 9, 118: 11, 92: 92 };
439
+ let size = 0;
440
+ for (let index = 0; index < source.length; ) {
441
+ if (source[index] !== 92 || index + 1 === source.length) {
442
+ bytes[size++] = source[index++];
443
+ continue;
444
+ }
445
+ const next = source[index + 1];
446
+ if (next === 99) return { bytes: bytes.subarray(0, size), stop: true };
447
+ if (control[next] !== void 0) {
448
+ bytes[size++] = control[next];
449
+ index += 2;
450
+ continue;
451
+ }
452
+ if (zeroOctal ? next === 48 || bareOctal && next >= 49 && next <= 55 : next >= 48 && next <= 55) {
453
+ let offset = index + (zeroOctal && next === 48 ? 2 : 1);
454
+ const end = Math.min(source.length, offset + 3);
455
+ let value2 = 0;
456
+ while (offset < end && source[offset] >= 48 && source[offset] <= 55) value2 = value2 * 8 + source[offset++] - 48;
457
+ bytes[size++] = value2 & 255;
458
+ index = offset;
459
+ continue;
460
+ }
461
+ if (next === 120) {
462
+ let offset = index + 2;
463
+ const end = Math.min(source.length, offset + 2);
464
+ let value2 = 0;
465
+ while (offset < end) {
466
+ const digit = source[offset];
467
+ const number = digit >= 48 && digit <= 57 ? digit - 48 : digit >= 65 && digit <= 70 ? digit - 55 : digit >= 97 && digit <= 102 ? digit - 87 : -1;
468
+ if (number < 0) break;
469
+ value2 = value2 * 16 + number;
470
+ offset++;
471
+ }
472
+ if (offset > index + 2) {
473
+ bytes[size++] = value2;
474
+ index = offset;
475
+ continue;
476
+ }
477
+ }
478
+ bytes[size++] = 92;
479
+ bytes[size++] = next;
480
+ index += 2;
481
+ }
482
+ return { bytes: bytes.subarray(0, size), stop: false };
483
+ }
484
+
485
+ export {
486
+ evaluateCommandSupport,
487
+ assertCommandRequirements,
488
+ escapeText,
489
+ writeDiagnostic,
490
+ inputRequirements,
491
+ textOutputRequirements,
492
+ pwdRequirements,
493
+ predicateRequirements,
494
+ RecordBuffer,
495
+ encoder2 as encoder,
496
+ decoder,
497
+ bufferLimit,
498
+ UsageError,
499
+ options,
500
+ value,
501
+ integer,
502
+ requireOperands,
503
+ pathOf,
504
+ codeOf,
505
+ output,
506
+ diagnostic,
507
+ define,
508
+ eachOperand,
509
+ input,
510
+ assertInputRequirements,
511
+ concatenate,
512
+ lines,
513
+ emptyInput,
514
+ replaceArgument,
515
+ escapeBytes
516
+ };
517
+ //# sourceMappingURL=chunk-5Y4AEZB2.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/contracts/command-requirements.ts", "../../src/escaping.ts", "../../src/commands/internal.ts", "../../src/commands/portable-requirements.ts", "../../src/commands/record-buffer.ts"],
4
+ "sourcesContent": ["import type { CommandContext, CommandDefinition } from \"./command.js\";\nimport type { FileSystemCapabilities } from \"./filesystem.js\";\nimport { FsError } from \"./errors.js\";\n\nexport interface CommandFileSystemRequirement {\n readonly id: string;\n readonly description: string;\n readonly capabilities: readonly string[];\n readonly anyOf?: readonly (readonly string[])[];\n readonly mutates?: boolean;\n}\n\nexport interface CommandModeSupport extends CommandFileSystemRequirement {\n readonly status: \"supported\" | \"unsupported\" | \"unknown\";\n readonly missing: readonly string[];\n readonly unknown: readonly string[];\n}\n\nexport interface CommandSupport {\n readonly status: \"supported\" | \"partial\" | \"unsupported\";\n readonly declared: boolean;\n readonly modes: readonly CommandModeSupport[];\n}\n\nfunction evaluateMode(requirement: CommandFileSystemRequirement, capabilities: FileSystemCapabilities): CommandModeSupport {\n const missing = requirement.capabilities.filter(name => capabilities[name] === false);\n const unknown = requirement.capabilities.filter(name => capabilities[name] === undefined);\n if (requirement.mutates && capabilities.readOnly === true) missing.push(\"readOnly\");\n const alternatives = requirement.anyOf;\n if (alternatives && !alternatives.some(group => group.every(name => capabilities[name] === true))) {\n if (alternatives.every(group => group.some(name => capabilities[name] === false))) {\n missing.push(...alternatives.flatMap(group => group.filter(name => capabilities[name] === false)));\n } else {\n unknown.push(...alternatives.filter(group => !group.some(name => capabilities[name] === false))\n .flatMap(group => group.filter(name => capabilities[name] === undefined)));\n }\n }\n return {\n ...requirement,\n status: missing.length ? \"unsupported\" : unknown.length ? \"unknown\" : \"supported\",\n missing: [...new Set(missing)], unknown: [...new Set(unknown)],\n };\n}\n\nexport function evaluateCommandSupport(\n command: Pick<CommandDefinition, \"filesystemRequirements\"> | CommandDefinition,\n capabilities: FileSystemCapabilities,\n): CommandSupport {\n const modes = (command.filesystemRequirements ?? []).map(requirement => evaluateMode(requirement, capabilities));\n return {\n declared: command.filesystemRequirements !== undefined,\n status: command.filesystemRequirements !== undefined && modes.every(mode => mode.status === \"supported\") ? \"supported\"\n : modes.length && modes.every(mode => mode.status === \"unsupported\") ? \"unsupported\" : \"partial\",\n modes,\n };\n}\n\nexport function assertCommandRequirements(\n context: Pick<CommandContext, \"fs\" | \"command\" | \"signal\">,\n requirements: readonly CommandFileSystemRequirement[],\n selected: readonly string[],\n capabilities: FileSystemCapabilities = context.fs.capabilities,\n): void {\n context.signal.throwIfAborted();\n for (const id of new Set(selected)) {\n const requirement = requirements.find(mode => mode.id === id);\n if (!requirement) throw new TypeError(`Unknown filesystem requirement mode: ${id}`);\n const support = evaluateMode(requirement, capabilities);\n if (support.status === \"unsupported\") {\n throw new FsError(support.missing.includes(\"readOnly\") ? \"EROFS\" : \"ENOTSUP\", {\n syscall: context.command,\n message: `${requirement.description} requires unavailable filesystem capabilities: ${support.missing.join(\", \")}`,\n });\n }\n }\n}\n", "import { writeBytes, type ByteSink } from \"./contracts/index.js\";\nimport { yieldTurn } from \"./contracts/yield.js\";\n\nconst controls: Readonly<Record<number, string>> = { 8: \"\\\\b\", 9: \"\\\\t\", 10: \"\\\\n\", 11: \"\\\\v\", 12: \"\\\\f\", 13: \"\\\\r\", 92: \"\\\\\\\\\" };\nconst encoder = new TextEncoder();\n\nfunction* parts(value: string, mode: \"display\" | \"diagnostic\"): Generator<string> {\n for (const character of value) {\n const point = character.codePointAt(0)!;\n if (mode === \"diagnostic\" && (point === 9 || point === 10 || point >= 32 && (point < 127 || point > 159))) {\n yield character;\n } else {\n for (const byte of encoder.encode(character)) {\n yield controls[byte] ?? (byte >= 32 && byte < 127 ? String.fromCharCode(byte) : `\\\\${byte.toString(8).padStart(3, \"0\")}`);\n }\n }\n }\n}\n\nexport function escapeText(value: string, mode: \"display\" | \"diagnostic\", checkOutput?: (bytes: number) => void): string {\n let result = \"\", bytes = 0;\n for (const part of parts(value, mode)) {\n bytes += Buffer.byteLength(part);\n checkOutput?.(bytes);\n result += part;\n }\n return result;\n}\n\nexport async function writeDiagnostic(sink: ByteSink, value: string, signal?: AbortSignal): Promise<void> {\n signal?.throwIfAborted();\n let chunk = \"\", bytes = 0, work = 0;\n for (const part of parts(value, \"diagnostic\")) {\n signal?.throwIfAborted();\n const size = Buffer.byteLength(part);\n if (bytes + size > 16_384) {\n await writeBytes(sink, encoder.encode(chunk), signal);\n chunk = \"\"; bytes = 0;\n }\n chunk += part; bytes += size;\n if (++work % 1024 === 0) await yieldTurn(signal);\n }\n if (bytes) await writeBytes(sink, encoder.encode(chunk), signal);\n signal?.throwIfAborted();\n}\n", "import { PublicDiagnostic, publicDiagnosticMessage } from \"../diagnostics.js\";\nimport { assertCommandRequirements } from \"../contracts/command-requirements.js\";\nimport { writeDiagnostic } from \"../escaping.js\";\nimport { inputRequirements } from \"./portable-requirements.js\";\nimport { RecordBuffer } from \"./record-buffer.js\";\nimport {\n FsError, isAbsolutePath, readBytes, toByteSource, validatePath, writeBytes,\n type ByteSource, type CommandContext, type CommandDefinition, type CommandHandler,\n} from \"../contracts/index.js\";\n\nexport const encoder = new TextEncoder();\nexport const decoder = new TextDecoder();\nexport const bufferLimit = 32 * 1024 * 1024;\n\nexport class UsageError extends PublicDiagnostic {}\n\nexport interface ParsedOptions {\n readonly flags: Set<string>;\n readonly values: Map<string, string[]>;\n readonly operands: string[];\n}\n\nexport function options(\n args: readonly string[], short: string, long: Readonly<Record<string, string>> = {},\n stopAtOperand = false, onOperand?: (index: number) => void,\n): ParsedOptions {\n const flags = new Set<string>();\n const values = new Map<string, string[]>();\n const operands: string[] = [];\n const specifications = new Map<string, boolean>();\n for (let index = 0; index < short.length; index++) {\n const key = short[index]!;\n specifications.set(key, short[index + 1] === \":\");\n if (short[index + 1] === \":\") index++;\n }\n let ended = false;\n for (let index = 0; index < args.length; index++) {\n const argument = args[index]!;\n if (ended || argument === \"-\" || !argument.startsWith(\"-\")) {\n operands.push(argument);\n onOperand?.(index);\n if (stopAtOperand) ended = true;\n continue;\n }\n if (argument === \"--\") { ended = true; continue; }\n if (argument.startsWith(\"--\")) {\n const equals = argument.indexOf(\"=\");\n const name = argument.slice(2, equals < 0 ? undefined : equals);\n const key = long[name];\n if (!key || !specifications.has(key)) throw new UsageError(`unrecognized option '${argument}'`);\n if (specifications.get(key)) {\n const value = equals >= 0 ? argument.slice(equals + 1) : args[++index];\n if (value === undefined) throw new UsageError(`option '--${name}' requires an argument`);\n values.set(key, [...values.get(key) ?? [], value]);\n } else if (equals >= 0) throw new UsageError(`option '--${name}' does not take an argument`);\n flags.add(key);\n continue;\n }\n for (let offset = 1; offset < argument.length; offset++) {\n const key = argument[offset]!;\n if (!specifications.has(key)) throw new UsageError(`invalid option -- '${key}'`);\n if (specifications.get(key)) {\n const value = argument.slice(offset + 1) || args[++index];\n if (value === undefined) throw new UsageError(`option requires an argument -- '${key}'`);\n values.set(key, [...values.get(key) ?? [], value]);\n offset = argument.length;\n }\n flags.add(key);\n }\n }\n return { flags, values, operands };\n}\n\nexport function value(parsed: ParsedOptions, key: string): string | undefined {\n return parsed.values.get(key)?.at(-1);\n}\n\nexport function integer(text: string, minimum = 0): number {\n if (!/^[+]?[0-9]+$/u.test(text)) throw new UsageError(`invalid number '${text}'`);\n const number = Number(text);\n if (!Number.isSafeInteger(number) || number < minimum) throw new UsageError(`invalid number '${text}'`);\n return number;\n}\n\nexport function requireOperands(operands: readonly string[], minimum = 1, maximum = Infinity): void {\n if (operands.length < minimum) throw new UsageError(\"missing operand\");\n if (operands.length > maximum) throw new UsageError(`extra operand '${operands[maximum]}'`);\n}\n\nexport function pathOf(context: Pick<CommandContext, \"cwd\">, path: string): string {\n if (!path) throw new FsError(\"ENOENT\", { path });\n validatePath(path);\n validatePath(context.cwd);\n if (!isAbsolutePath(context.cwd)) throw new FsError(\"EINVAL\", { path: context.cwd, message: \"cwd must be absolute\" });\n return isAbsolutePath(path) ? path : `${context.cwd.replace(/\\/$/u, \"\")}/${path}`;\n}\n\nexport function codeOf(error: unknown): string | undefined {\n return error instanceof Error && \"code\" in error ? String(error.code) : undefined;\n}\n\nexport async function output(context: CommandContext, text: string | Uint8Array): Promise<void> {\n context.signal.throwIfAborted();\n await writeBytes(context.stdout, typeof text === \"string\" ? encoder.encode(text) : text, context.signal);\n}\n\nexport async function diagnostic(context: CommandContext, error: unknown): Promise<void> {\n context.signal.throwIfAborted();\n await writeDiagnostic(context.stderr, `${context.command}: ${publicDiagnosticMessage(error, context.onInternalError)}\\n`, context.signal);\n}\n\nexport function define(name: string, handler: CommandHandler, failureCode = 1): CommandDefinition {\n return {\n name,\n async execute(context) {\n context.signal.throwIfAborted();\n try { return await handler(context); }\n catch (error) {\n context.signal.throwIfAborted();\n await diagnostic(context, error);\n return { exitCode: error instanceof UsageError ? 2 : failureCode };\n }\n },\n };\n}\n\nexport async function eachOperand(\n context: CommandContext, operands: readonly string[], operation: (operand: string) => Promise<void>,\n): Promise<{ exitCode: number }> {\n let exitCode = 0;\n for (const operand of operands) {\n context.signal.throwIfAborted();\n try { await operation(operand); }\n catch (error) { await diagnostic(context, error); exitCode = 1; }\n }\n return { exitCode };\n}\n\nexport async function* input(context: CommandContext, name = \"-\"): ByteSource {\n context.signal.throwIfAborted();\n if (name === \"-\") {\n yield* readBytes(context.stdin, context.signal);\n } else {\n await assertInputRequirements(context, [name]);\n const path = pathOf(context, name);\n const capabilities = await context.fs.capabilitiesFor?.(path, { signal: context.signal }) ?? context.fs.capabilities;\n if (context.fs.readStream && capabilities.streamingRead !== false) {\n let emitted = false;\n let reading = true;\n try {\n for await (const chunk of readBytes(context.fs.readStream(path, { signal: context.signal }), context.signal)) {\n reading = false;\n if (chunk.byteLength) emitted = true;\n yield chunk;\n reading = true;\n }\n return;\n } catch (error) {\n context.signal.throwIfAborted();\n if (!reading || emitted || !(error instanceof FsError) || error.code !== \"ENOTSUP\") throw error;\n }\n }\n if (capabilities.read === false) throw new FsError(\"ENOTSUP\", { syscall: \"readFile\", path });\n yield* readBytes({\n async *[Symbol.asyncIterator]() {\n const bytes = await context.fs.readFile(path, { signal: context.signal, maxBytes: bufferLimit });\n context.signal.throwIfAborted();\n if (bytes.byteLength > bufferLimit) throw new FsError(\"EFBIG\", { syscall: \"readFile\", path });\n yield bytes;\n },\n }, context.signal);\n }\n}\n\nexport async function assertInputRequirements(context: CommandContext, names: readonly string[]): Promise<void> {\n const files = names.filter(name => name !== \"-\");\n assertCommandRequirements(context, inputRequirements, [files.length ? \"file\" : \"stdin\"]);\n if (!context.fs.capabilitiesFor) return;\n for (const name of files) {\n try {\n const capabilities = await context.fs.capabilitiesFor(pathOf(context, name), { signal: context.signal });\n assertCommandRequirements(context, inputRequirements, [\"file\"], capabilities);\n } catch (error) {\n context.signal.throwIfAborted();\n if (codeOf(error) === \"ENOTSUP\" || codeOf(error) === \"EROFS\") throw error;\n }\n }\n}\n\nexport function concatenate(chunks: readonly Uint8Array[], size = chunks.reduce((sum, chunk) => sum + chunk.length, 0)): Uint8Array {\n const result = new Uint8Array(size);\n let offset = 0;\n for (const chunk of chunks) { result.set(chunk, offset); offset += chunk.length; }\n return result;\n}\n\nexport async function collect(source: ByteSource, signal: AbortSignal, limit = bufferLimit): Promise<Uint8Array> {\n const chunks: Uint8Array[] = [];\n let size = 0;\n for await (const chunk of source) {\n signal.throwIfAborted();\n size += chunk.length;\n if (size > limit) throw new FsError(\"EFBIG\", { message: `buffer limit exceeded (${limit} bytes)` });\n chunks.push(new Uint8Array(chunk));\n }\n return concatenate(chunks, size);\n}\n\nexport interface Line { readonly bytes: Uint8Array; readonly terminated: boolean }\n\nexport async function* lines(source: ByteSource, separator = 10, admit?: (size: number) => void): AsyncGenerator<Line> {\n const pending = new RecordBuffer(bufferLimit);\n try {\n for await (const chunk of source) {\n let start = 0;\n for (let offset = 0; offset < chunk.length; offset++) {\n if (chunk[offset] !== separator) continue;\n yield { bytes: pending.finish(admit, chunk, start, offset), terminated: true };\n start = offset + 1;\n }\n pending.append(chunk, start);\n }\n if (pending.size) yield { bytes: pending.finish(admit), terminated: false };\n } finally { pending.clear(); }\n}\n\nexport function emptyInput(): ByteSource { return toByteSource(\"\"); }\n\nexport function replaceArgument(source: string | Uint8Array, pattern: string, replacement: string): string | Uint8Array {\n if (typeof source === \"string\") return source.split(pattern).join(replacement);\n const needle = encoder.encode(pattern);\n if (!needle.length) throw new UsageError(\"replacement string cannot be empty\");\n const substituted = encoder.encode(replacement);\n const chunks: Uint8Array[] = [];\n let start = 0;\n for (let offset = 0; offset <= source.length - needle.length;) {\n if (needle.every((byte, index) => source[offset + index] === byte)) {\n chunks.push(source.subarray(start, offset), substituted);\n offset += needle.length;\n start = offset;\n } else offset++;\n }\n chunks.push(source.subarray(start));\n return concatenate(chunks);\n}\n\nexport function escapeBytes(text: string | Uint8Array, zeroOctal = false, bareOctal = false): { bytes: Uint8Array; stop: boolean } {\n if (typeof text === \"string\") {\n const chunks: Uint8Array[] = [];\n const control: Record<string, number> = { a: 7, b: 8, e: 27, E: 27, f: 12, n: 10, r: 13, t: 9, v: 11, \"\\\\\": 92 };\n for (let index = 0; index < text.length;) {\n if (text[index] !== \"\\\\\" || index + 1 === text.length) {\n const character = String.fromCodePoint(text.codePointAt(index)!);\n chunks.push(encoder.encode(character)); index += character.length; continue;\n }\n const next = text[index + 1]!;\n if (next === \"c\") return { bytes: concatenate(chunks), stop: true };\n if (control[next] !== undefined) { chunks.push(Uint8Array.of(control[next])); index += 2; continue; }\n const rest = text.slice(index + 1);\n const octal = zeroOctal ? (bareOctal ? /^(?:0([0-7]{0,3})|([1-7][0-7]{0,2}))/u : /^0([0-7]{0,3})/u).exec(rest) : /^([0-7]{1,3})/u.exec(rest);\n if (octal) { chunks.push(Uint8Array.of(parseInt(octal[1] || octal[2] || \"0\", 8) & 255)); index += 1 + octal[0].length; continue; }\n const hexadecimal = /^x([0-9a-fA-F]{1,2})/u.exec(rest);\n if (hexadecimal) { chunks.push(Uint8Array.of(parseInt(hexadecimal[1]!, 16))); index += 1 + hexadecimal[0].length; continue; }\n chunks.push(encoder.encode(`\\\\${next}`)); index += 2;\n }\n return { bytes: concatenate(chunks), stop: false };\n }\n const source = text;\n const bytes = new Uint8Array(source.length);\n const control: Record<number, number> = { 97: 7, 98: 8, 101: 27, 69: 27, 102: 12, 110: 10, 114: 13, 116: 9, 118: 11, 92: 92 };\n let size = 0;\n for (let index = 0; index < source.length;) {\n if (source[index] !== 92 || index + 1 === source.length) { bytes[size++] = source[index++]!; continue; }\n const next = source[index + 1]!;\n if (next === 99) return { bytes: bytes.subarray(0, size), stop: true };\n if (control[next] !== undefined) { bytes[size++] = control[next]; index += 2; continue; }\n if (zeroOctal ? next === 48 || bareOctal && next >= 49 && next <= 55 : next >= 48 && next <= 55) {\n let offset = index + (zeroOctal && next === 48 ? 2 : 1);\n const end = Math.min(source.length, offset + 3);\n let value = 0;\n while (offset < end && source[offset]! >= 48 && source[offset]! <= 55) value = value * 8 + source[offset++]! - 48;\n bytes[size++] = value & 255;\n index = offset;\n continue;\n }\n if (next === 120) {\n let offset = index + 2;\n const end = Math.min(source.length, offset + 2);\n let value = 0;\n while (offset < end) {\n const digit = source[offset]!;\n const number = digit >= 48 && digit <= 57 ? digit - 48 : digit >= 65 && digit <= 70 ? digit - 55 : digit >= 97 && digit <= 102 ? digit - 87 : -1;\n if (number < 0) break;\n value = value * 16 + number;\n offset++;\n }\n if (offset > index + 2) { bytes[size++] = value; index = offset; continue; }\n }\n bytes[size++] = 92;\n bytes[size++] = next;\n index += 2;\n }\n return { bytes: bytes.subarray(0, size), stop: false };\n}\n", "import type { CommandFileSystemRequirement } from \"../contracts/command-requirements.js\";\n\nexport const inputRequirements: readonly CommandFileSystemRequirement[] = [\n { id: \"stdin\", description: \"Read standard input\", capabilities: [] },\n { id: \"file\", description: \"Read file operands\", capabilities: [], anyOf: [[\"streamingRead\"], [\"read\"]] },\n];\n\nexport const textOutputRequirements: readonly CommandFileSystemRequirement[] = [\n ...inputRequirements,\n { id: \"output\", description: \"Write or truncate an output file\", capabilities: [], anyOf: [[\"streamingWrite\"], [\"write\"]], mutates: true },\n];\n\nexport const pwdRequirements: readonly CommandFileSystemRequirement[] = [\n { id: \"logical\", description: \"Print the logical working directory\", capabilities: [] },\n { id: \"physical\", description: \"Resolve the physical working directory (-P)\", capabilities: [\"realpath\"] },\n];\n\nexport const predicateRequirements: readonly CommandFileSystemRequirement[] = [\n { id: \"expression\", description: \"Evaluate strings and integers\", capabilities: [] },\n { id: \"metadata\", description: \"Inspect file metadata\", capabilities: [\"stat\"] },\n { id: \"access\", description: \"Inspect path access permissions\", capabilities: [\"access\"] },\n];\n", "import { FsError } from \"../contracts/index.js\";\n\nconst segmentSize = 4096;\n\nexport class RecordBuffer {\n #segments: Uint8Array[] = [];\n #size = 0;\n #allocated = 0;\n\n constructor(readonly capacity: number, readonly finalizationCapacity = capacity * 2) {}\n\n get size(): number { return this.#size; }\n\n #admit(length: number): void {\n if (length > this.capacity - this.#size) {\n throw new FsError(\"EFBIG\", { message: \"line buffer limit exceeded\" });\n }\n }\n\n append(bytes: Uint8Array, start = 0, end = bytes.length): void {\n this.#admit(end - start);\n let offset = start;\n while (offset < end) {\n let segment = this.#segments.at(-1);\n const used = this.#size % segmentSize;\n if (!segment || used === 0) {\n segment = new Uint8Array(Math.min(segmentSize, this.capacity - this.#allocated));\n this.#segments.push(segment);\n this.#allocated += segment.length;\n }\n const length = Math.min(end - offset, segment.length - used);\n segment.set(bytes.subarray(offset, offset + length), used);\n this.#size += length;\n offset += length;\n }\n }\n\n finish(admit?: (size: number) => void, bytes?: Uint8Array, start = 0, end = bytes?.length ?? 0): Uint8Array {\n this.#admit(end - start);\n const size = this.#size + end - start;\n admit?.(size);\n if (size > this.finalizationCapacity - this.#allocated) {\n throw new FsError(\"EFBIG\", { message: \"line finalization buffer limit exceeded\" });\n }\n const result = new Uint8Array(size);\n let offset = 0;\n for (const segment of this.#segments) {\n const length = Math.min(segment.length, this.#size - offset);\n result.set(segment.subarray(0, length), offset);\n offset += length;\n }\n if (bytes && end > start) result.set(bytes.subarray(start, end), offset);\n this.clear();\n return result;\n }\n\n clear(): void {\n this.#segments = [];\n this.#size = 0;\n this.#allocated = 0;\n }\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;AAAA;AAwBA,SAAS,aAAa,aAA2C,cAA0D;AACzH,QAAM,UAAU,YAAY,aAAa,OAAO,UAAQ,aAAa,IAAI,MAAM,KAAK;AACpF,QAAM,UAAU,YAAY,aAAa,OAAO,UAAQ,aAAa,IAAI,MAAM,MAAS;AACxF,MAAI,YAAY,WAAW,aAAa,aAAa,KAAM,SAAQ,KAAK,UAAU;AAClF,QAAM,eAAe,YAAY;AACjC,MAAI,gBAAgB,CAAC,aAAa,KAAK,WAAS,MAAM,MAAM,UAAQ,aAAa,IAAI,MAAM,IAAI,CAAC,GAAG;AACjG,QAAI,aAAa,MAAM,WAAS,MAA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I,SAAS,KAAK;AAChB,UAAI,SAAS,QAAQ;AACrB,YAAM,MAAM,KAAK,IAAI,OAAO,QAAQ,SAAS,CAAC;AAC9C,UAAIA,SAAQ;AACZ,aAAO,SAAS,KAAK;AACnB,cAAM,QAAQ,OAAO,MAAM;AAC3B,cAAM,SAAS,SAAS,MAAM,SAAS,KAAK,QAAQ,KAAK,SAAS,MAAM,SAAS,KAAK,QAAQ,KAAK,SAAS,MAAM,SAAS,MAAM,QAAQ,KAAK;AAC9I,YAAI,SAAS,EAAG;AAChB,QAAAA,SAAQA,SAAQ,KAAK;AACrB;AAAA,MACF;AACA,UAAI,SAAS,QAAQ,GAAG;AAAE,cAAM,MAAM,IAAIA;AAAO,gBAAQ;AAAQ;AAAA,MAAU;AAAA,IAC7E;AACA,UAAM,MAAM,IAAI;AAChB,UAAM,MAAM,IAAI;AAChB,aAAS;AAAA,EACX;AACA,SAAO,EAAE,OAAO,MAAM,SAAS,GAAG,IAAI,GAAG,MAAM,MAAM;AACvD;",
6
+ "names": ["value", "encoder", "value", "encoder", "control", "value"]
7
+ }
@@ -1,19 +1,21 @@
1
1
  import {
2
2
  interruptible
3
- } from "./chunk-54Z5EUCW.js";
3
+ } from "./chunk-M7KZ7V4P.js";
4
+ import {
5
+ pathOf,
6
+ writeDiagnostic
7
+ } from "./chunk-5Y4AEZB2.js";
4
8
  import {
5
9
  FsError,
6
10
  getCommandArguments,
7
11
  import_buffer,
8
12
  init_platform,
9
- pathOf,
10
13
  readBytes,
11
14
  shellValueByteLength,
12
15
  toByteSource,
13
16
  writeBytes,
14
- writeDiagnostic,
15
17
  yieldTurn
16
- } from "./chunk-LUJYX5H5.js";
18
+ } from "./chunk-L2GZSOSJ.js";
17
19
 
18
20
  // packages/safe-bash/src/commands/xml/index.ts
19
21
  init_platform();
@@ -519,4 +521,4 @@ export {
519
521
  createXmlCommands,
520
522
  xmlCommands
521
523
  };
522
- //# sourceMappingURL=chunk-IKATLB4I.js.map
524
+ //# sourceMappingURL=chunk-AVXYPKV7.js.map