poe-code 15.0.9 → 15.0.10
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.
- package/dist/metafile.json +1 -1
- package/package.json +7 -1
- package/packages/safe-bash/dist/chunks/{chunk-L2GZSOSJ.js → chunk-4NMFAR4Z.js} +2 -16
- package/packages/safe-bash/dist/chunks/{chunk-L2GZSOSJ.js.map → chunk-4NMFAR4Z.js.map} +4 -4
- package/packages/safe-bash/dist/chunks/{chunk-UZELUFGF.js → chunk-54EWSIBL.js} +5 -5
- package/packages/safe-bash/dist/chunks/{chunk-NVUC5B2R.js → chunk-5FNFA5ZV.js} +9 -7
- package/packages/safe-bash/dist/chunks/{chunk-NVUC5B2R.js.map → chunk-5FNFA5ZV.js.map} +1 -1
- package/packages/safe-bash/dist/chunks/{chunk-M7KZ7V4P.js → chunk-5X2TAR25.js} +2 -2
- package/packages/safe-bash/dist/chunks/{chunk-XROAIPKA.js → chunk-67TENRTW.js} +7 -5
- package/packages/safe-bash/dist/chunks/{chunk-XROAIPKA.js.map → chunk-67TENRTW.js.map} +1 -1
- package/packages/safe-bash/dist/chunks/{chunk-5Y4AEZB2.js → chunk-7XJVLU37.js} +6 -4
- package/packages/safe-bash/dist/chunks/{chunk-5Y4AEZB2.js.map → chunk-7XJVLU37.js.map} +1 -1
- package/packages/safe-bash/dist/chunks/chunk-CI42NIWL.js +21 -0
- package/packages/safe-bash/dist/chunks/chunk-CI42NIWL.js.map +7 -0
- package/packages/safe-bash/dist/chunks/{chunk-JWUT4LBW.js → chunk-ELK3CQTQ.js} +47 -16
- package/packages/safe-bash/dist/chunks/chunk-ELK3CQTQ.js.map +7 -0
- package/packages/safe-bash/dist/chunks/{chunk-PY37EOPJ.js → chunk-GZH6ILJC.js} +50 -15
- package/packages/safe-bash/dist/chunks/chunk-GZH6ILJC.js.map +7 -0
- package/packages/safe-bash/dist/chunks/chunk-LUIEXTN5.js +527 -0
- package/packages/safe-bash/dist/chunks/chunk-LUIEXTN5.js.map +7 -0
- package/packages/safe-bash/dist/chunks/{chunk-AVXYPKV7.js → chunk-QQHMFJHF.js} +4 -4
- package/packages/safe-bash/dist/chunks/{chunk-QY2XHZTE.js → chunk-RDIJ6M2D.js} +3 -3
- package/packages/safe-bash/dist/chunks/{chunk-PPVCI2F2.js → chunk-UL4TNDNV.js} +2 -2
- package/packages/safe-bash/dist/commands/csplit/index.browser.js +5 -4
- package/packages/safe-bash/dist/commands/factor/command.d.ts +4 -0
- package/packages/safe-bash/dist/commands/factor/command.d.ts.map +1 -0
- package/packages/safe-bash/dist/commands/factor/command.js +121 -0
- package/packages/safe-bash/dist/commands/factor/command.js.map +1 -0
- package/packages/safe-bash/dist/commands/factor/factor.d.ts +4 -0
- package/packages/safe-bash/dist/commands/factor/factor.d.ts.map +1 -0
- package/packages/safe-bash/dist/commands/factor/factor.js +54 -0
- package/packages/safe-bash/dist/commands/factor/factor.js.map +1 -0
- package/packages/safe-bash/dist/commands/factor/index.browser.js +13 -0
- package/packages/safe-bash/dist/commands/factor/index.browser.js.map +7 -0
- package/packages/safe-bash/dist/commands/factor/index.d.ts +7 -0
- package/packages/safe-bash/dist/commands/factor/index.d.ts.map +1 -0
- package/packages/safe-bash/dist/commands/factor/index.js +13 -0
- package/packages/safe-bash/dist/commands/factor/index.js.map +1 -0
- package/packages/safe-bash/dist/commands/factor/internal.d.ts +51 -0
- package/packages/safe-bash/dist/commands/factor/internal.d.ts.map +1 -0
- package/packages/safe-bash/dist/commands/factor/internal.js +138 -0
- package/packages/safe-bash/dist/commands/factor/internal.js.map +1 -0
- package/packages/safe-bash/dist/commands/factor/io.d.ts +36 -0
- package/packages/safe-bash/dist/commands/factor/io.d.ts.map +1 -0
- package/packages/safe-bash/dist/commands/factor/io.js +207 -0
- package/packages/safe-bash/dist/commands/factor/io.js.map +1 -0
- package/packages/safe-bash/dist/commands/network/index.browser.js +6 -5
- package/packages/safe-bash/dist/commands/pr/index.browser.js +4 -3
- package/packages/safe-bash/dist/commands/pr/io.d.ts.map +1 -1
- package/packages/safe-bash/dist/commands/pr/io.js +46 -11
- package/packages/safe-bash/dist/commands/pr/io.js.map +1 -1
- package/packages/safe-bash/dist/commands/tsort/index.browser.js +4 -3
- package/packages/safe-bash/dist/commands/tsort/io.d.ts.map +1 -1
- package/packages/safe-bash/dist/commands/tsort/io.js +43 -12
- package/packages/safe-bash/dist/commands/tsort/io.js.map +1 -1
- package/packages/safe-bash/dist/commands/xml/index.browser.js +5 -4
- package/packages/safe-bash/dist/commands/yq/index.browser.js +6 -5
- package/packages/safe-bash/dist/core.browser.js +32 -20
- package/packages/safe-bash/dist/core.browser.js.map +2 -2
- package/packages/safe-bash/dist/core.d.ts +1 -0
- package/packages/safe-bash/dist/core.d.ts.map +1 -1
- package/packages/safe-bash/dist/core.js +1 -0
- package/packages/safe-bash/dist/core.js.map +1 -1
- package/packages/safe-bash/dist/plugins/composition.d.ts +2 -0
- package/packages/safe-bash/dist/plugins/composition.d.ts.map +1 -1
- package/packages/safe-bash/dist/plugins/composition.js +3 -1
- package/packages/safe-bash/dist/plugins/composition.js.map +1 -1
- package/packages/safe-bash/dist/chunks/chunk-JWUT4LBW.js.map +0 -7
- package/packages/safe-bash/dist/chunks/chunk-PY37EOPJ.js.map +0 -7
- /package/packages/safe-bash/dist/chunks/{chunk-UZELUFGF.js.map → chunk-54EWSIBL.js.map} +0 -0
- /package/packages/safe-bash/dist/chunks/{chunk-M7KZ7V4P.js.map → chunk-5X2TAR25.js.map} +0 -0
- /package/packages/safe-bash/dist/chunks/{chunk-AVXYPKV7.js.map → chunk-QQHMFJHF.js.map} +0 -0
- /package/packages/safe-bash/dist/chunks/{chunk-QY2XHZTE.js.map → chunk-RDIJ6M2D.js.map} +0 -0
- /package/packages/safe-bash/dist/chunks/{chunk-PPVCI2F2.js.map → chunk-UL4TNDNV.js.map} +0 -0
|
@@ -0,0 +1,527 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createOutputOperation
|
|
3
|
+
} from "./chunk-UL4TNDNV.js";
|
|
4
|
+
import {
|
|
5
|
+
FsError,
|
|
6
|
+
PublicDiagnostic,
|
|
7
|
+
getCommandArguments,
|
|
8
|
+
init_platform,
|
|
9
|
+
shellValueByteLength,
|
|
10
|
+
shellValueBytes,
|
|
11
|
+
yieldTurn
|
|
12
|
+
} from "./chunk-4NMFAR4Z.js";
|
|
13
|
+
|
|
14
|
+
// packages/safe-bash/src/commands/factor/index.ts
|
|
15
|
+
init_platform();
|
|
16
|
+
|
|
17
|
+
// packages/safe-bash/src/commands/factor/command.ts
|
|
18
|
+
init_platform();
|
|
19
|
+
|
|
20
|
+
// packages/safe-bash/src/commands/factor/internal.ts
|
|
21
|
+
init_platform();
|
|
22
|
+
function settings(options) {
|
|
23
|
+
const limits = {
|
|
24
|
+
maxValue: 4294967295,
|
|
25
|
+
maxArguments: 4096,
|
|
26
|
+
maxArgumentBytes: 65536,
|
|
27
|
+
maxInputBytes: 16777216,
|
|
28
|
+
maxTokenBytes: 65536,
|
|
29
|
+
maxNumbers: 65536,
|
|
30
|
+
maxBufferedBytes: 4194304,
|
|
31
|
+
maxOutputBytes: 16777216,
|
|
32
|
+
maxDiagnosticBytes: 65536,
|
|
33
|
+
maxWork: 8388608,
|
|
34
|
+
maxEmptyChunks: 4096,
|
|
35
|
+
...options.limits
|
|
36
|
+
};
|
|
37
|
+
for (const [name, value] of Object.entries(limits)) {
|
|
38
|
+
if (!Number.isSafeInteger(value) || value < 1) throw new RangeError(`Invalid factor limit: ${name}`);
|
|
39
|
+
}
|
|
40
|
+
if (limits.maxValue > 4294967295) throw new RangeError("factor maxValue cannot exceed 4294967295");
|
|
41
|
+
return Object.freeze(limits);
|
|
42
|
+
}
|
|
43
|
+
var FactorError = class extends PublicDiagnostic {
|
|
44
|
+
constructor(message, usage = false) {
|
|
45
|
+
super(message);
|
|
46
|
+
this.usage = usage;
|
|
47
|
+
}
|
|
48
|
+
usage;
|
|
49
|
+
};
|
|
50
|
+
function raw(value) {
|
|
51
|
+
let result = "";
|
|
52
|
+
for (let offset = 0; offset < value.length; offset += 4096) result += String.fromCharCode(...value.subarray(offset, offset + 4096));
|
|
53
|
+
return result;
|
|
54
|
+
}
|
|
55
|
+
function bytes(value) {
|
|
56
|
+
return Uint8Array.from(value, (character) => character.charCodeAt(0));
|
|
57
|
+
}
|
|
58
|
+
var escapes = { "\x07": "\\a", "\b": "\\b", "\f": "\\f", "\n": "\\n", "\r": "\\r", " ": "\\t", "\v": "\\v", "\\": "\\\\", "'": "\\'" };
|
|
59
|
+
function quote(value, budget, suffixLength) {
|
|
60
|
+
let length = 2;
|
|
61
|
+
for (const character of value) {
|
|
62
|
+
const code = character.charCodeAt(0);
|
|
63
|
+
length += escapes[character]?.length ?? (code >= 32 && code < 127 ? 1 : 4);
|
|
64
|
+
}
|
|
65
|
+
budget.diagnosticRoom(length + suffixLength);
|
|
66
|
+
let result = "'";
|
|
67
|
+
for (const character of value) {
|
|
68
|
+
const code = character.charCodeAt(0);
|
|
69
|
+
result += escapes[character] ?? (code >= 32 && code < 127 ? character : `\\${code.toString(8).padStart(3, "0")}`);
|
|
70
|
+
}
|
|
71
|
+
return `${result}'`;
|
|
72
|
+
}
|
|
73
|
+
var Budget = class {
|
|
74
|
+
constructor(context, limits, signal) {
|
|
75
|
+
this.context = context;
|
|
76
|
+
this.limits = limits;
|
|
77
|
+
this.signal = signal;
|
|
78
|
+
}
|
|
79
|
+
context;
|
|
80
|
+
limits;
|
|
81
|
+
signal;
|
|
82
|
+
work = 0;
|
|
83
|
+
checkpoint = 0;
|
|
84
|
+
retained = 0;
|
|
85
|
+
input = 0;
|
|
86
|
+
numbers = 0;
|
|
87
|
+
output = 0;
|
|
88
|
+
diagnostics = 0;
|
|
89
|
+
check(value, maximum, label) {
|
|
90
|
+
if (!Number.isSafeInteger(value) || value < 0 || value > maximum) throw new FactorError(`${label} limit exceeded`);
|
|
91
|
+
}
|
|
92
|
+
charge(amount = 1) {
|
|
93
|
+
this.signal.throwIfAborted();
|
|
94
|
+
this.check(this.work + amount, this.limits.maxWork, "work");
|
|
95
|
+
this.work += amount;
|
|
96
|
+
}
|
|
97
|
+
async checkpointWork() {
|
|
98
|
+
this.signal.throwIfAborted();
|
|
99
|
+
if (this.work - this.checkpoint >= 1024) {
|
|
100
|
+
this.checkpoint = this.work;
|
|
101
|
+
await yieldTurn(this.signal);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
retain(amount) {
|
|
105
|
+
this.check(this.retained + amount, this.limits.maxBufferedBytes, "buffered bytes");
|
|
106
|
+
this.retained += amount;
|
|
107
|
+
}
|
|
108
|
+
number() {
|
|
109
|
+
this.check(++this.numbers, this.limits.maxNumbers, "numbers");
|
|
110
|
+
this.charge();
|
|
111
|
+
}
|
|
112
|
+
inputBytes(amount) {
|
|
113
|
+
this.check(this.input + amount, this.limits.maxInputBytes, "input bytes");
|
|
114
|
+
this.input += amount;
|
|
115
|
+
}
|
|
116
|
+
outputRoom(amount) {
|
|
117
|
+
this.check(this.output + amount, this.limits.maxOutputBytes, "output bytes");
|
|
118
|
+
}
|
|
119
|
+
diagnosticRoom(amount) {
|
|
120
|
+
this.check(this.diagnostics + amount, this.limits.maxDiagnosticBytes, "diagnostic bytes");
|
|
121
|
+
}
|
|
122
|
+
emitted(amount, diagnostic) {
|
|
123
|
+
if (diagnostic) {
|
|
124
|
+
this.diagnosticRoom(amount);
|
|
125
|
+
this.diagnostics += amount;
|
|
126
|
+
} else {
|
|
127
|
+
this.outputRoom(amount);
|
|
128
|
+
this.charge(amount);
|
|
129
|
+
this.output += amount;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
arguments() {
|
|
133
|
+
this.check(this.context.args.length, this.limits.maxArguments, "argument count");
|
|
134
|
+
let total = 0;
|
|
135
|
+
for (const argument of this.context.args) {
|
|
136
|
+
total += argument.length;
|
|
137
|
+
this.check(total, this.limits.maxArgumentBytes, "argument bytes");
|
|
138
|
+
for (let offset = 0; offset < argument.length; offset++) {
|
|
139
|
+
const unit = argument.charCodeAt(offset);
|
|
140
|
+
if (unit >= 55296 && unit <= 56319) {
|
|
141
|
+
const next = argument.charCodeAt(++offset);
|
|
142
|
+
if (!(next >= 56320 && next <= 57343)) throw new FactorError("arguments must contain well-formed Unicode");
|
|
143
|
+
} else if (unit >= 56320 && unit <= 57343) throw new FactorError("arguments must contain well-formed Unicode");
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
total = 0;
|
|
147
|
+
const values = this.context.argumentValues === void 0 ? this.context.args : getCommandArguments(this.context).values;
|
|
148
|
+
for (const argument of values) {
|
|
149
|
+
total += shellValueByteLength(argument);
|
|
150
|
+
this.check(total, this.limits.maxArgumentBytes, "argument bytes");
|
|
151
|
+
}
|
|
152
|
+
this.charge(total);
|
|
153
|
+
this.retain(total * 8 + this.context.args.length * 64 + 128);
|
|
154
|
+
return getCommandArguments(this.context).values.map((argument) => {
|
|
155
|
+
const value = shellValueBytes(argument);
|
|
156
|
+
if (value.includes(0)) throw new FactorError("NUL is not supported in arguments");
|
|
157
|
+
return raw(value);
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
// packages/safe-bash/src/commands/factor/io.ts
|
|
163
|
+
init_platform();
|
|
164
|
+
var Lifecycle = class {
|
|
165
|
+
constructor(budget, output) {
|
|
166
|
+
this.budget = budget;
|
|
167
|
+
output.registerCleanup(() => this.close());
|
|
168
|
+
}
|
|
169
|
+
budget;
|
|
170
|
+
pending = /* @__PURE__ */ new Set();
|
|
171
|
+
cleanups = [];
|
|
172
|
+
closing;
|
|
173
|
+
cleanup(action) {
|
|
174
|
+
this.assertOpen();
|
|
175
|
+
this.cleanups.push(action);
|
|
176
|
+
}
|
|
177
|
+
assertOpen() {
|
|
178
|
+
this.budget.signal.throwIfAborted();
|
|
179
|
+
if (this.closing) throw new FactorError("command is closed");
|
|
180
|
+
}
|
|
181
|
+
async operation(action) {
|
|
182
|
+
this.assertOpen();
|
|
183
|
+
const pending = Promise.resolve().then(() => {
|
|
184
|
+
this.assertOpen();
|
|
185
|
+
return action();
|
|
186
|
+
});
|
|
187
|
+
this.pending.add(pending);
|
|
188
|
+
try {
|
|
189
|
+
const value = await pending;
|
|
190
|
+
this.assertOpen();
|
|
191
|
+
return value;
|
|
192
|
+
} finally {
|
|
193
|
+
this.pending.delete(pending);
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
close() {
|
|
197
|
+
return this.closing ??= Promise.resolve().then(async () => {
|
|
198
|
+
while (this.pending.size) await Promise.allSettled([...this.pending]);
|
|
199
|
+
const failures = [];
|
|
200
|
+
for (const cleanup of this.cleanups) {
|
|
201
|
+
try {
|
|
202
|
+
await cleanup();
|
|
203
|
+
} catch (error) {
|
|
204
|
+
failures.push(error);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
if (failures.length === 1) throw failures[0];
|
|
208
|
+
if (failures.length > 1) throw new AggregateError(failures, "factor cleanup failed");
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
async write(value, diagnostic = false) {
|
|
212
|
+
this.budget.emitted(value.length, diagnostic);
|
|
213
|
+
await this.operation(async () => {
|
|
214
|
+
const sink = diagnostic ? this.budget.context.stderr : this.budget.context.stdout;
|
|
215
|
+
this.assertOpen();
|
|
216
|
+
const destination = sink.ownedOutput ?? sink;
|
|
217
|
+
this.assertOpen();
|
|
218
|
+
const write = destination.write;
|
|
219
|
+
this.assertOpen();
|
|
220
|
+
await Reflect.apply(write, destination, [value]);
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
async diagnostic(value) {
|
|
224
|
+
this.budget.diagnosticRoom(value.length);
|
|
225
|
+
await this.write(bytes(value), true);
|
|
226
|
+
}
|
|
227
|
+
};
|
|
228
|
+
var TokenReader = class {
|
|
229
|
+
constructor(lifecycle) {
|
|
230
|
+
this.lifecycle = lifecycle;
|
|
231
|
+
lifecycle.cleanup(async () => {
|
|
232
|
+
try {
|
|
233
|
+
if (!this.ended) await this.iterator?.return?.();
|
|
234
|
+
} finally {
|
|
235
|
+
this.iterator = void 0;
|
|
236
|
+
lifecycle.budget.retain(-this.chunk.length - this.token.length);
|
|
237
|
+
this.chunk = new Uint8Array();
|
|
238
|
+
this.token = new Uint8Array();
|
|
239
|
+
}
|
|
240
|
+
});
|
|
241
|
+
}
|
|
242
|
+
lifecycle;
|
|
243
|
+
iterator;
|
|
244
|
+
chunk = new Uint8Array();
|
|
245
|
+
token = new Uint8Array();
|
|
246
|
+
offset = 0;
|
|
247
|
+
ended = false;
|
|
248
|
+
empties = 0;
|
|
249
|
+
async get() {
|
|
250
|
+
const { budget } = this.lifecycle;
|
|
251
|
+
budget.charge();
|
|
252
|
+
await budget.checkpointWork();
|
|
253
|
+
while (this.offset === this.chunk.length) {
|
|
254
|
+
if (this.ended) return -1;
|
|
255
|
+
let next;
|
|
256
|
+
try {
|
|
257
|
+
if (!this.iterator) await this.lifecycle.operation(() => {
|
|
258
|
+
const source = budget.context.stdin;
|
|
259
|
+
this.lifecycle.assertOpen();
|
|
260
|
+
const factory = source[Symbol.asyncIterator];
|
|
261
|
+
this.lifecycle.assertOpen();
|
|
262
|
+
this.iterator = Reflect.apply(factory, source, []);
|
|
263
|
+
});
|
|
264
|
+
budget.charge();
|
|
265
|
+
next = await this.lifecycle.operation(() => {
|
|
266
|
+
const iterator = this.iterator;
|
|
267
|
+
const advance = iterator.next;
|
|
268
|
+
this.lifecycle.assertOpen();
|
|
269
|
+
return Reflect.apply(advance, iterator, []);
|
|
270
|
+
});
|
|
271
|
+
} catch (error) {
|
|
272
|
+
if (error instanceof FsError) throw new FactorError(`standard input: ${error.code === "EIO" ? "Input/output error" : error.message}`);
|
|
273
|
+
throw error;
|
|
274
|
+
}
|
|
275
|
+
budget.retain(-this.chunk.length);
|
|
276
|
+
this.chunk = new Uint8Array();
|
|
277
|
+
this.offset = 0;
|
|
278
|
+
if (next.done) {
|
|
279
|
+
this.ended = true;
|
|
280
|
+
this.iterator = void 0;
|
|
281
|
+
return -1;
|
|
282
|
+
}
|
|
283
|
+
if (!(next.value instanceof Uint8Array)) throw new TypeError("factor input requires bytes");
|
|
284
|
+
budget.inputBytes(next.value.length);
|
|
285
|
+
budget.charge(next.value.length);
|
|
286
|
+
budget.retain(next.value.length);
|
|
287
|
+
this.chunk = Uint8Array.from(next.value);
|
|
288
|
+
if (!this.chunk.length) budget.check(++this.empties, budget.limits.maxEmptyChunks, "empty input chunks");
|
|
289
|
+
}
|
|
290
|
+
return this.chunk[this.offset++];
|
|
291
|
+
}
|
|
292
|
+
async next() {
|
|
293
|
+
const { budget } = this.lifecycle;
|
|
294
|
+
let length = 0, kept = 0;
|
|
295
|
+
let nul = false;
|
|
296
|
+
for (; ; ) {
|
|
297
|
+
const value = await this.get();
|
|
298
|
+
if (value < 0 || value === 32 || value === 9 || value === 10) {
|
|
299
|
+
if (length) {
|
|
300
|
+
budget.charge(kept);
|
|
301
|
+
budget.retain(kept * 4);
|
|
302
|
+
return raw(this.token.subarray(0, kept));
|
|
303
|
+
}
|
|
304
|
+
if (value < 0) return void 0;
|
|
305
|
+
} else {
|
|
306
|
+
budget.check(++length, budget.limits.maxTokenBytes, "token bytes");
|
|
307
|
+
if (value === 0) nul = true;
|
|
308
|
+
if (!nul) {
|
|
309
|
+
if (kept === this.token.length) {
|
|
310
|
+
const capacity = Math.min(budget.limits.maxTokenBytes, Math.max(64, this.token.length * 2));
|
|
311
|
+
budget.retain(capacity);
|
|
312
|
+
budget.charge(this.token.length);
|
|
313
|
+
const grown = new Uint8Array(capacity);
|
|
314
|
+
grown.set(this.token);
|
|
315
|
+
budget.retain(-this.token.length);
|
|
316
|
+
this.token = grown;
|
|
317
|
+
}
|
|
318
|
+
this.token[kept++] = value;
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
};
|
|
324
|
+
var RecordWriter = class {
|
|
325
|
+
constructor(lifecycle) {
|
|
326
|
+
this.lifecycle = lifecycle;
|
|
327
|
+
lifecycle.budget.retain(1024);
|
|
328
|
+
this.buffer = new Uint8Array(1024);
|
|
329
|
+
lifecycle.cleanup(async () => {
|
|
330
|
+
lifecycle.budget.retain(-this.buffer.length);
|
|
331
|
+
this.buffer = new Uint8Array();
|
|
332
|
+
});
|
|
333
|
+
}
|
|
334
|
+
lifecycle;
|
|
335
|
+
buffer;
|
|
336
|
+
used = 0;
|
|
337
|
+
async append(record) {
|
|
338
|
+
const { budget } = this.lifecycle;
|
|
339
|
+
this.lifecycle.assertOpen();
|
|
340
|
+
budget.outputRoom(this.used + record.length);
|
|
341
|
+
budget.charge(record.length);
|
|
342
|
+
for (let offset = 0; offset < record.length; offset++) this.buffer[this.used++] = record.charCodeAt(offset);
|
|
343
|
+
if (this.used >= 512) {
|
|
344
|
+
let end = 512;
|
|
345
|
+
while (this.buffer[end - 1] !== 10) end--;
|
|
346
|
+
await this.lifecycle.write(this.buffer.subarray(0, end));
|
|
347
|
+
this.buffer.copyWithin(0, end, this.used);
|
|
348
|
+
this.used -= end;
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
async finish() {
|
|
352
|
+
if (this.used) {
|
|
353
|
+
await this.lifecycle.write(this.buffer.subarray(0, this.used));
|
|
354
|
+
this.used = 0;
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
};
|
|
358
|
+
|
|
359
|
+
// packages/safe-bash/src/commands/factor/factor.ts
|
|
360
|
+
init_platform();
|
|
361
|
+
async function parseNumber(input, budget) {
|
|
362
|
+
let start = 0;
|
|
363
|
+
while (input[start] === " ") {
|
|
364
|
+
budget.charge();
|
|
365
|
+
start++;
|
|
366
|
+
await budget.checkpointWork();
|
|
367
|
+
}
|
|
368
|
+
if (input[start] === "+") start++;
|
|
369
|
+
if (start === input.length) return "invalid";
|
|
370
|
+
let result = 0, large = false;
|
|
371
|
+
for (let offset = start; offset < input.length; offset++) {
|
|
372
|
+
budget.charge();
|
|
373
|
+
const digit = input.charCodeAt(offset) - 48;
|
|
374
|
+
if (digit < 0 || digit > 9) return "invalid";
|
|
375
|
+
if (!large) {
|
|
376
|
+
if (result > Math.floor((budget.limits.maxValue - digit) / 10)) large = true;
|
|
377
|
+
else result = result * 10 + digit;
|
|
378
|
+
}
|
|
379
|
+
await budget.checkpointWork();
|
|
380
|
+
}
|
|
381
|
+
return large ? "large" : result;
|
|
382
|
+
}
|
|
383
|
+
async function factorRecord(value, budget) {
|
|
384
|
+
let remaining = value;
|
|
385
|
+
const factors = [];
|
|
386
|
+
budget.retain(512);
|
|
387
|
+
try {
|
|
388
|
+
for (let divisor = 2; divisor * divisor <= remaining; divisor = divisor === 2 ? 3 : divisor + 2) {
|
|
389
|
+
for (; ; ) {
|
|
390
|
+
budget.charge();
|
|
391
|
+
await budget.checkpointWork();
|
|
392
|
+
if (remaining % divisor !== 0) break;
|
|
393
|
+
budget.charge(2);
|
|
394
|
+
factors.push(divisor);
|
|
395
|
+
remaining /= divisor;
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
if (remaining > 1) factors.push(remaining);
|
|
399
|
+
budget.charge(1 + factors.length * 11);
|
|
400
|
+
return `${value}:${factors.map((factor) => ` ${factor}`).join("")}
|
|
401
|
+
`;
|
|
402
|
+
} finally {
|
|
403
|
+
budget.retain(-512);
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
// packages/safe-bash/src/commands/factor/command.ts
|
|
408
|
+
function createFactorCommand(options = {}) {
|
|
409
|
+
const limits = settings(options);
|
|
410
|
+
return { name: "factor", description: "Print prime factors of bounded nonnegative integers", async execute(context) {
|
|
411
|
+
const output = createOutputOperation(context, context.stdout);
|
|
412
|
+
const budget = new Budget(context, limits, output.signal);
|
|
413
|
+
let lifecycle;
|
|
414
|
+
let failure;
|
|
415
|
+
let primary;
|
|
416
|
+
let exitCode = 0;
|
|
417
|
+
try {
|
|
418
|
+
lifecycle = new Lifecycle(budget, output);
|
|
419
|
+
const operands = [];
|
|
420
|
+
let optionsEnded = false, debug = false;
|
|
421
|
+
let information;
|
|
422
|
+
for (const argument of budget.arguments()) {
|
|
423
|
+
if (!optionsEnded && argument === "--") {
|
|
424
|
+
optionsEnded = true;
|
|
425
|
+
continue;
|
|
426
|
+
}
|
|
427
|
+
if (!optionsEnded && argument.startsWith("--")) {
|
|
428
|
+
const equals = argument.indexOf("=");
|
|
429
|
+
const option = equals < 0 ? argument.slice(2) : argument.slice(2, equals);
|
|
430
|
+
const matches = ["-debug", "help", "version"].filter((name) => name.startsWith(option));
|
|
431
|
+
if (matches.length > 1) throw new FactorError(`option '${argument}' is ambiguous; possibilities: ${matches.map((name) => `'--${name}'`).join(" ")}`, true);
|
|
432
|
+
const matched = matches[0];
|
|
433
|
+
if (!matched) throw new FactorError(`unrecognized option '${argument}'`, true);
|
|
434
|
+
if (equals >= 0) throw new FactorError(`option '--${matched}' doesn't allow an argument`, true);
|
|
435
|
+
if (matched === "-debug") debug = true;
|
|
436
|
+
else {
|
|
437
|
+
information = matched;
|
|
438
|
+
break;
|
|
439
|
+
}
|
|
440
|
+
} else {
|
|
441
|
+
if (!optionsEnded && argument.length > 1 && argument.startsWith("-")) throw new FactorError(`invalid option -- '${argument[1]}'`, true);
|
|
442
|
+
operands.push(argument);
|
|
443
|
+
if (context.env.POSIXLY_CORRECT !== void 0) optionsEnded = true;
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
if (information) {
|
|
447
|
+
const message = information === "version" ? "factor (virtual-bash)\n" : `Usage: factor [NUMBER]...
|
|
448
|
+
Print prime factors; with no numbers, read standard input.
|
|
449
|
+
Options: --help --version
|
|
450
|
+
Maximum supported value: ${limits.maxValue}
|
|
451
|
+
`;
|
|
452
|
+
budget.outputRoom(message.length);
|
|
453
|
+
await lifecycle.write(bytes(message));
|
|
454
|
+
} else {
|
|
455
|
+
const writer = new RecordWriter(lifecycle);
|
|
456
|
+
const process = async (input) => {
|
|
457
|
+
budget.number();
|
|
458
|
+
budget.check(input.length, limits.maxTokenBytes, "token bytes");
|
|
459
|
+
const value = await parseNumber(input, budget);
|
|
460
|
+
if (typeof value === "string") {
|
|
461
|
+
exitCode = 1;
|
|
462
|
+
const suffix = value === "invalid" ? " is not a valid positive integer\n" : ` exceeds supported maximum ${limits.maxValue}
|
|
463
|
+
`;
|
|
464
|
+
await lifecycle.diagnostic(`factor: ${quote(input, budget, 8 + suffix.length)}${suffix}`);
|
|
465
|
+
} else {
|
|
466
|
+
if (debug) await lifecycle.diagnostic("[using single-precision arithmetic] ");
|
|
467
|
+
await writer.append(await factorRecord(value, budget));
|
|
468
|
+
}
|
|
469
|
+
};
|
|
470
|
+
if (operands.length) {
|
|
471
|
+
for (const operand of operands) await process(operand);
|
|
472
|
+
} else {
|
|
473
|
+
const reader = new TokenReader(lifecycle);
|
|
474
|
+
for (; ; ) {
|
|
475
|
+
const token = await reader.next();
|
|
476
|
+
if (token === void 0) break;
|
|
477
|
+
try {
|
|
478
|
+
await process(token);
|
|
479
|
+
} finally {
|
|
480
|
+
budget.retain(-token.length * 4);
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
await writer.finish();
|
|
485
|
+
}
|
|
486
|
+
} catch (error) {
|
|
487
|
+
primary = { reason: error };
|
|
488
|
+
if (error instanceof FactorError && !output.signal.aborted && lifecycle) {
|
|
489
|
+
exitCode = 1;
|
|
490
|
+
try {
|
|
491
|
+
await lifecycle.diagnostic(`factor: ${error.message}
|
|
492
|
+
${error.usage ? "Try 'factor --help' for more information.\n" : ""}`);
|
|
493
|
+
} catch (reporting) {
|
|
494
|
+
failure = { reason: new AggregateError([error, reporting], "factor failure reporting failed") };
|
|
495
|
+
}
|
|
496
|
+
} else failure = { reason: error };
|
|
497
|
+
}
|
|
498
|
+
try {
|
|
499
|
+
await output.close();
|
|
500
|
+
} catch (cleanup) {
|
|
501
|
+
const previous = failure ?? primary;
|
|
502
|
+
failure = { reason: previous ? new AggregateError([previous.reason, cleanup], "factor execution and cleanup failed") : cleanup };
|
|
503
|
+
}
|
|
504
|
+
context.signal.throwIfAborted();
|
|
505
|
+
output.signal.throwIfAborted();
|
|
506
|
+
if (failure) throw failure.reason;
|
|
507
|
+
return { exitCode };
|
|
508
|
+
} };
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
// packages/safe-bash/src/commands/factor/index.ts
|
|
512
|
+
function createFactorCommands(options = {}) {
|
|
513
|
+
return [createFactorCommand(options)];
|
|
514
|
+
}
|
|
515
|
+
function factorCommands(options = {}) {
|
|
516
|
+
const commands = createFactorCommands(options);
|
|
517
|
+
return { name: "factor-commands", setup(host) {
|
|
518
|
+
for (const command of commands) host.commands.register(command, { replace: options.replace ?? false });
|
|
519
|
+
} };
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
export {
|
|
523
|
+
createFactorCommand,
|
|
524
|
+
createFactorCommands,
|
|
525
|
+
factorCommands
|
|
526
|
+
};
|
|
527
|
+
//# sourceMappingURL=chunk-LUIEXTN5.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/commands/factor/index.ts", "../../src/commands/factor/command.ts", "../../src/commands/factor/internal.ts", "../../src/commands/factor/io.ts", "../../src/commands/factor/factor.ts"],
|
|
4
|
+
"sourcesContent": ["import type { CommandDefinition, VirtualShellPlugin } from \"../../contracts/index.js\";\nimport { createFactorCommand } from \"./command.js\";\nimport type { FactorCommandsOptions } from \"./internal.js\";\n\nexport { createFactorCommand } from \"./command.js\";\nexport type { FactorCommandsOptions, FactorLimits } from \"./internal.js\";\n\nexport function createFactorCommands(options: FactorCommandsOptions = {}): readonly CommandDefinition[] {\n return [createFactorCommand(options)];\n}\n\nexport function factorCommands(options: FactorCommandsOptions = {}): VirtualShellPlugin {\n const commands = createFactorCommands(options);\n return { name: \"factor-commands\", setup(host) {\n for (const command of commands) host.commands.register(command, { replace: options.replace ?? false });\n } };\n}\n", "import type { CommandDefinition } from \"../../contracts/index.js\";\nimport { createOutputOperation } from \"../../contracts/output.js\";\nimport { Budget, FactorError, bytes, quote, settings, type FactorCommandsOptions } from \"./internal.js\";\nimport { Lifecycle, RecordWriter, TokenReader } from \"./io.js\";\nimport { factorRecord, parseNumber } from \"./factor.js\";\n\nexport function createFactorCommand(options: FactorCommandsOptions = {}): CommandDefinition {\n const limits = settings(options);\n return { name: \"factor\", description: \"Print prime factors of bounded nonnegative integers\", async execute(context) {\n const output = createOutputOperation(context, context.stdout);\n const budget = new Budget(context, limits, output.signal);\n let lifecycle: Lifecycle | undefined;\n let failure: { reason: unknown } | undefined;\n let primary: { reason: unknown } | undefined;\n let exitCode = 0;\n try {\n lifecycle = new Lifecycle(budget, output);\n const operands: string[] = [];\n let optionsEnded = false, debug = false;\n let information: \"help\" | \"version\" | undefined;\n for (const argument of budget.arguments()) {\n if (!optionsEnded && argument === \"--\") { optionsEnded = true; continue; }\n if (!optionsEnded && argument.startsWith(\"--\")) {\n const equals = argument.indexOf(\"=\");\n const option = equals < 0 ? argument.slice(2) : argument.slice(2, equals);\n const matches = [\"-debug\", \"help\", \"version\"].filter(name => name.startsWith(option));\n if (matches.length > 1) throw new FactorError(`option '${argument}' is ambiguous; possibilities: ${matches.map(name => `'--${name}'`).join(\" \")}`, true);\n const matched = matches[0];\n if (!matched) throw new FactorError(`unrecognized option '${argument}'`, true);\n if (equals >= 0) throw new FactorError(`option '--${matched}' doesn't allow an argument`, true);\n if (matched === \"-debug\") debug = true;\n else { information = matched as \"help\" | \"version\"; break; }\n } else {\n if (!optionsEnded && argument.length > 1 && argument.startsWith(\"-\")) throw new FactorError(`invalid option -- '${argument[1]}'`, true);\n operands.push(argument);\n if (context.env.POSIXLY_CORRECT !== undefined) optionsEnded = true;\n }\n }\n if (information) {\n const message = information === \"version\" ? \"factor (virtual-bash)\\n\" : `Usage: factor [NUMBER]...\\nPrint prime factors; with no numbers, read standard input.\\nOptions: --help --version\\nMaximum supported value: ${limits.maxValue}\\n`;\n budget.outputRoom(message.length);\n await lifecycle.write(bytes(message));\n } else {\n const writer = new RecordWriter(lifecycle);\n const process = async (input: string): Promise<void> => {\n budget.number();\n budget.check(input.length, limits.maxTokenBytes, \"token bytes\");\n const value = await parseNumber(input, budget);\n if (typeof value === \"string\") {\n exitCode = 1;\n const suffix = value === \"invalid\" ? \" is not a valid positive integer\\n\" : ` exceeds supported maximum ${limits.maxValue}\\n`;\n await lifecycle!.diagnostic(`factor: ${quote(input, budget, 8 + suffix.length)}${suffix}`);\n } else {\n if (debug) await lifecycle!.diagnostic(\"[using single-precision arithmetic] \");\n await writer.append(await factorRecord(value, budget));\n }\n };\n if (operands.length) { for (const operand of operands) await process(operand); }\n else {\n const reader = new TokenReader(lifecycle);\n for (;;) {\n const token = await reader.next();\n if (token === undefined) break;\n try { await process(token); } finally { budget.retain(-token.length * 4); }\n }\n }\n await writer.finish();\n }\n } catch (error) {\n primary = { reason: error };\n if (error instanceof FactorError && !output.signal.aborted && lifecycle) {\n exitCode = 1;\n try { await lifecycle.diagnostic(`factor: ${error.message}\\n${error.usage ? \"Try 'factor --help' for more information.\\n\" : \"\"}`); }\n catch (reporting) { failure = { reason: new AggregateError([error, reporting], \"factor failure reporting failed\") }; }\n } else failure = { reason: error };\n }\n try { await output.close(); }\n catch (cleanup) {\n const previous = failure ?? primary;\n failure = { reason: previous ? new AggregateError([previous.reason, cleanup], \"factor execution and cleanup failed\") : cleanup };\n }\n context.signal.throwIfAborted();\n output.signal.throwIfAborted();\n if (failure) throw failure.reason;\n return { exitCode };\n } };\n}\n", "import { getCommandArguments, type CommandContext } from \"../../contracts/index.js\";\nimport { shellValueByteLength, shellValueBytes } from \"../../contracts/value.js\";\nimport { yieldTurn } from \"../../contracts/yield.js\";\nimport { PublicDiagnostic } from \"../../diagnostics.js\";\n\nexport interface FactorLimits {\n readonly maxValue: number;\n readonly maxArguments: number;\n readonly maxArgumentBytes: number;\n readonly maxInputBytes: number;\n readonly maxTokenBytes: number;\n readonly maxNumbers: number;\n readonly maxBufferedBytes: number;\n readonly maxOutputBytes: number;\n readonly maxDiagnosticBytes: number;\n readonly maxWork: number;\n readonly maxEmptyChunks: number;\n}\n\nexport interface FactorCommandsOptions {\n readonly replace?: boolean;\n readonly limits?: Partial<FactorLimits>;\n}\n\nexport function settings(options: FactorCommandsOptions): FactorLimits {\n const limits: FactorLimits = {\n maxValue: 4_294_967_295, maxArguments: 4096, maxArgumentBytes: 65_536,\n maxInputBytes: 16_777_216, maxTokenBytes: 65_536, maxNumbers: 65_536,\n maxBufferedBytes: 4_194_304, maxOutputBytes: 16_777_216,\n maxDiagnosticBytes: 65_536, maxWork: 8_388_608, maxEmptyChunks: 4096, ...options.limits,\n };\n for (const [name, value] of Object.entries(limits)) {\n if (!Number.isSafeInteger(value) || value < 1) throw new RangeError(`Invalid factor limit: ${name}`);\n }\n if (limits.maxValue > 4_294_967_295) throw new RangeError(\"factor maxValue cannot exceed 4294967295\");\n return Object.freeze(limits);\n}\n\nexport class FactorError extends PublicDiagnostic {\n constructor(message: string, readonly usage = false) { super(message); }\n}\n\nexport function raw(value: Uint8Array): string {\n let result = \"\";\n for (let offset = 0; offset < value.length; offset += 4096) result += String.fromCharCode(...value.subarray(offset, offset + 4096));\n return result;\n}\n\nexport function bytes(value: string): Uint8Array {\n return Uint8Array.from(value, character => character.charCodeAt(0));\n}\n\nconst escapes: Readonly<Record<string, string>> = { \"\\x07\": \"\\\\a\", \"\\b\": \"\\\\b\", \"\\f\": \"\\\\f\", \"\\n\": \"\\\\n\", \"\\r\": \"\\\\r\", \"\\t\": \"\\\\t\", \"\\v\": \"\\\\v\", \"\\\\\": \"\\\\\\\\\", \"'\": \"\\\\'\" };\n\nexport function quote(value: string, budget: Budget, suffixLength: number): string {\n let length = 2;\n for (const character of value) {\n const code = character.charCodeAt(0);\n length += escapes[character]?.length ?? (code >= 32 && code < 127 ? 1 : 4);\n }\n budget.diagnosticRoom(length + suffixLength);\n let result = \"'\";\n for (const character of value) {\n const code = character.charCodeAt(0);\n result += escapes[character] ?? (code >= 32 && code < 127 ? character : `\\\\${code.toString(8).padStart(3, \"0\")}`);\n }\n return `${result}'`;\n}\n\nexport class Budget {\n private work = 0;\n private checkpoint = 0;\n private retained = 0;\n private input = 0;\n private numbers = 0;\n private output = 0;\n private diagnostics = 0;\n constructor(readonly context: CommandContext, readonly limits: FactorLimits, readonly signal: AbortSignal) {}\n check(value: number, maximum: number, label: string): void {\n if (!Number.isSafeInteger(value) || value < 0 || value > maximum) throw new FactorError(`${label} limit exceeded`);\n }\n charge(amount = 1): void {\n this.signal.throwIfAborted();\n this.check(this.work + amount, this.limits.maxWork, \"work\");\n this.work += amount;\n }\n async checkpointWork(): Promise<void> {\n this.signal.throwIfAborted();\n if (this.work - this.checkpoint >= 1024) { this.checkpoint = this.work; await yieldTurn(this.signal); }\n }\n retain(amount: number): void {\n this.check(this.retained + amount, this.limits.maxBufferedBytes, \"buffered bytes\");\n this.retained += amount;\n }\n number(): void { this.check(++this.numbers, this.limits.maxNumbers, \"numbers\"); this.charge(); }\n inputBytes(amount: number): void {\n this.check(this.input + amount, this.limits.maxInputBytes, \"input bytes\");\n this.input += amount;\n }\n outputRoom(amount: number): void { this.check(this.output + amount, this.limits.maxOutputBytes, \"output bytes\"); }\n diagnosticRoom(amount: number): void { this.check(this.diagnostics + amount, this.limits.maxDiagnosticBytes, \"diagnostic bytes\"); }\n emitted(amount: number, diagnostic: boolean): void {\n if (diagnostic) { this.diagnosticRoom(amount); this.diagnostics += amount; }\n else { this.outputRoom(amount); this.charge(amount); this.output += amount; }\n }\n arguments(): string[] {\n this.check(this.context.args.length, this.limits.maxArguments, \"argument count\");\n let total = 0;\n for (const argument of this.context.args) {\n total += argument.length;\n this.check(total, this.limits.maxArgumentBytes, \"argument bytes\");\n for (let offset = 0; offset < argument.length; offset++) {\n const unit = argument.charCodeAt(offset);\n if (unit >= 0xd800 && unit <= 0xdbff) {\n const next = argument.charCodeAt(++offset);\n if (!(next >= 0xdc00 && next <= 0xdfff)) throw new FactorError(\"arguments must contain well-formed Unicode\");\n } else if (unit >= 0xdc00 && unit <= 0xdfff) throw new FactorError(\"arguments must contain well-formed Unicode\");\n }\n }\n total = 0;\n const values = this.context.argumentValues === undefined ? this.context.args : getCommandArguments(this.context).values;\n for (const argument of values) { total += shellValueByteLength(argument); this.check(total, this.limits.maxArgumentBytes, \"argument bytes\"); }\n this.charge(total);\n this.retain(total * 8 + this.context.args.length * 64 + 128);\n return getCommandArguments(this.context).values.map(argument => {\n const value = shellValueBytes(argument);\n if (value.includes(0)) throw new FactorError(\"NUL is not supported in arguments\");\n return raw(value);\n });\n }\n}\n", "import { FsError } from \"../../contracts/index.js\";\nimport type { OutputOperation } from \"../../contracts/output.js\";\nimport { Budget, FactorError, bytes, raw } from \"./internal.js\";\n\nexport class Lifecycle {\n private readonly pending = new Set<Promise<unknown>>();\n private readonly cleanups: (() => Promise<void>)[] = [];\n private closing: Promise<void> | undefined;\n constructor(readonly budget: Budget, output: OutputOperation) { output.registerCleanup(() => this.close()); }\n cleanup(action: () => Promise<void>): void { this.assertOpen(); this.cleanups.push(action); }\n assertOpen(): void {\n this.budget.signal.throwIfAborted();\n if (this.closing) throw new FactorError(\"command is closed\");\n }\n async operation<Value>(action: () => Value | Promise<Value>): Promise<Value> {\n this.assertOpen();\n const pending = Promise.resolve().then(() => { this.assertOpen(); return action(); });\n this.pending.add(pending);\n try { const value = await pending; this.assertOpen(); return value; }\n finally { this.pending.delete(pending); }\n }\n close(): Promise<void> {\n return this.closing ??= Promise.resolve().then(async () => {\n while (this.pending.size) await Promise.allSettled([...this.pending]);\n const failures: unknown[] = [];\n for (const cleanup of this.cleanups) { try { await cleanup(); } catch (error) { failures.push(error); } }\n if (failures.length === 1) throw failures[0];\n if (failures.length > 1) throw new AggregateError(failures, \"factor cleanup failed\");\n });\n }\n async write(value: Uint8Array, diagnostic = false): Promise<void> {\n this.budget.emitted(value.length, diagnostic);\n await this.operation(async () => {\n const sink = diagnostic ? this.budget.context.stderr : this.budget.context.stdout;\n this.assertOpen();\n const destination = sink.ownedOutput ?? sink;\n this.assertOpen();\n const write = destination.write;\n this.assertOpen();\n await Reflect.apply(write, destination, [value]);\n });\n }\n async diagnostic(value: string): Promise<void> {\n this.budget.diagnosticRoom(value.length);\n await this.write(bytes(value), true);\n }\n}\n\nexport class TokenReader {\n private iterator: AsyncIterator<Uint8Array> | undefined;\n private chunk: Uint8Array = new Uint8Array();\n private token: Uint8Array = new Uint8Array();\n private offset = 0;\n private ended = false;\n private empties = 0;\n constructor(readonly lifecycle: Lifecycle) {\n lifecycle.cleanup(async () => {\n try { if (!this.ended) await this.iterator?.return?.(); }\n finally {\n this.iterator = undefined;\n lifecycle.budget.retain(-this.chunk.length - this.token.length);\n this.chunk = new Uint8Array();\n this.token = new Uint8Array();\n }\n });\n }\n private async get(): Promise<number> {\n const { budget } = this.lifecycle;\n budget.charge();\n await budget.checkpointWork();\n while (this.offset === this.chunk.length) {\n if (this.ended) return -1;\n let next: IteratorResult<Uint8Array>;\n try {\n if (!this.iterator) await this.lifecycle.operation(() => {\n const source = budget.context.stdin;\n this.lifecycle.assertOpen();\n const factory = source[Symbol.asyncIterator];\n this.lifecycle.assertOpen();\n this.iterator = Reflect.apply(factory, source, []);\n });\n budget.charge();\n next = await this.lifecycle.operation(() => {\n const iterator = this.iterator!;\n const advance = iterator.next;\n this.lifecycle.assertOpen();\n return Reflect.apply(advance, iterator, []);\n });\n } catch (error) {\n if (error instanceof FsError) throw new FactorError(`standard input: ${error.code === \"EIO\" ? \"Input/output error\" : error.message}`);\n throw error;\n }\n budget.retain(-this.chunk.length);\n this.chunk = new Uint8Array();\n this.offset = 0;\n if (next.done) { this.ended = true; this.iterator = undefined; return -1; }\n if (!(next.value instanceof Uint8Array)) throw new TypeError(\"factor input requires bytes\");\n budget.inputBytes(next.value.length);\n budget.charge(next.value.length);\n budget.retain(next.value.length);\n this.chunk = Uint8Array.from(next.value);\n if (!this.chunk.length) budget.check(++this.empties, budget.limits.maxEmptyChunks, \"empty input chunks\");\n }\n return this.chunk[this.offset++]!;\n }\n async next(): Promise<string | undefined> {\n const { budget } = this.lifecycle;\n let length = 0, kept = 0;\n let nul = false;\n for (;;) {\n const value = await this.get();\n if (value < 0 || value === 32 || value === 9 || value === 10) {\n if (length) { budget.charge(kept); budget.retain(kept * 4); return raw(this.token.subarray(0, kept)); }\n if (value < 0) return undefined;\n } else {\n budget.check(++length, budget.limits.maxTokenBytes, \"token bytes\");\n if (value === 0) nul = true;\n if (!nul) {\n if (kept === this.token.length) {\n const capacity = Math.min(budget.limits.maxTokenBytes, Math.max(64, this.token.length * 2));\n budget.retain(capacity);\n budget.charge(this.token.length);\n const grown = new Uint8Array(capacity);\n grown.set(this.token);\n budget.retain(-this.token.length);\n this.token = grown;\n }\n this.token[kept++] = value;\n }\n }\n }\n }\n}\n\nexport class RecordWriter {\n private buffer: Uint8Array;\n private used = 0;\n constructor(readonly lifecycle: Lifecycle) {\n lifecycle.budget.retain(1024);\n this.buffer = new Uint8Array(1024);\n lifecycle.cleanup(async () => { lifecycle.budget.retain(-this.buffer.length); this.buffer = new Uint8Array(); });\n }\n async append(record: string): Promise<void> {\n const { budget } = this.lifecycle;\n this.lifecycle.assertOpen();\n budget.outputRoom(this.used + record.length);\n budget.charge(record.length);\n for (let offset = 0; offset < record.length; offset++) this.buffer[this.used++] = record.charCodeAt(offset);\n if (this.used >= 512) {\n let end = 512;\n while (this.buffer[end - 1] !== 10) end--;\n await this.lifecycle.write(this.buffer.subarray(0, end));\n this.buffer.copyWithin(0, end, this.used);\n this.used -= end;\n }\n }\n async finish(): Promise<void> {\n if (this.used) { await this.lifecycle.write(this.buffer.subarray(0, this.used)); this.used = 0; }\n }\n}\n", "import { Budget } from \"./internal.js\";\n\nexport async function parseNumber(input: string, budget: Budget): Promise<number | \"invalid\" | \"large\"> {\n let start = 0;\n while (input[start] === \" \") { budget.charge(); start++; await budget.checkpointWork(); }\n if (input[start] === \"+\") start++;\n if (start === input.length) return \"invalid\";\n let result = 0, large = false;\n for (let offset = start; offset < input.length; offset++) {\n budget.charge();\n const digit = input.charCodeAt(offset) - 48;\n if (digit < 0 || digit > 9) return \"invalid\";\n if (!large) {\n if (result > Math.floor((budget.limits.maxValue - digit) / 10)) large = true;\n else result = result * 10 + digit;\n }\n await budget.checkpointWork();\n }\n return large ? \"large\" : result;\n}\n\nexport async function factorRecord(value: number, budget: Budget): Promise<string> {\n let remaining = value;\n const factors: number[] = [];\n budget.retain(512);\n try {\n for (let divisor = 2; divisor * divisor <= remaining; divisor = divisor === 2 ? 3 : divisor + 2) {\n for (;;) {\n budget.charge();\n await budget.checkpointWork();\n if (remaining % divisor !== 0) break;\n budget.charge(2);\n factors.push(divisor);\n remaining /= divisor;\n }\n }\n if (remaining > 1) factors.push(remaining);\n budget.charge(1 + factors.length * 11);\n return `${value}:${factors.map(factor => ` ${factor}`).join(\"\")}\\n`;\n } finally { budget.retain(-512); }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;AAAA;;;ACAA;;;ACAA;AAwBO,SAAS,SAAS,SAA8C;AACrE,QAAM,SAAuB;AAAA,IAC3B,UAAU;AAAA,IAAe,cAAc;AAAA,IAAM,kBAAkB;AAAA,IAC/D,eAAe;AAAA,IAAY,eAAe;AAAA,IAAQ,YAAY;AAAA,IAC9D,kBAAkB;AAAA,IAAW,gBAAgB;AAAA,IAC7C,oBAAoB;AAAA,IAAQ,SAAS;AAAA,IAAW,gBAAgB;AAAA,IAAM,GAAG,QAAQ;AAAA,EACnF;AACA,aAAW,CAAC,MAAM,KAAK,KAAK,OAAO,QAAQ,MAAM,GAAG;AAClD,QAAI,CAAC,OAAO,cAAc,KAAK,KAAK,QAAQ,EAAG,OAAM,IAAI,WAAW,yBAAyB,IAAI,EAAE;AAAA,EACrG;AACA,MAAI,OAAO,WAAW,WAAe,OAAM,IAAI,WAAW,0CAA0C;AACpG,SAAO,OAAO,OAAO,MAAM;AAC7B;AAEO,IAAM,cAAN,cAA0B,iBAAiB;AAAA,EAChD,YAAY,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,SAAO,CAAC,oBAAoB,OAAO,CAAC;AACtC;AAEO,SAAS,eAAe,UAAiC,CAAC,GAAuB;AACtF,QAAM,WAAW,qBAAqB,OAAO;AAC7C,SAAO,EAAE,MAAM,mBAAmB,MAAM,MAAM;AAC5C,eAAW,WAAW,SAAU,MAAK,SAAS,SAAS,SAAS,EAAE,SAAS,QAAQ,WAAW,MAAM,CAAC;AAAA,EACvG,EAAE;AACJ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
interruptible
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-5X2TAR25.js";
|
|
4
4
|
import {
|
|
5
5
|
pathOf,
|
|
6
6
|
writeDiagnostic
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-7XJVLU37.js";
|
|
8
8
|
import {
|
|
9
9
|
FsError,
|
|
10
10
|
getCommandArguments,
|
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
toByteSource,
|
|
16
16
|
writeBytes,
|
|
17
17
|
yieldTurn
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-4NMFAR4Z.js";
|
|
19
19
|
|
|
20
20
|
// packages/safe-bash/src/commands/xml/index.ts
|
|
21
21
|
init_platform();
|
|
@@ -521,4 +521,4 @@ export {
|
|
|
521
521
|
createXmlCommands,
|
|
522
522
|
xmlCommands
|
|
523
523
|
};
|
|
524
|
-
//# sourceMappingURL=chunk-
|
|
524
|
+
//# sourceMappingURL=chunk-QQHMFJHF.js.map
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createOutputOperation
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-UL4TNDNV.js";
|
|
4
4
|
import {
|
|
5
5
|
FsError,
|
|
6
6
|
createBytePipe,
|
|
7
7
|
init_platform,
|
|
8
8
|
outputFailure
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-4NMFAR4Z.js";
|
|
10
10
|
|
|
11
11
|
// packages/safe-bash/src/contracts/filesystem-output.ts
|
|
12
12
|
init_platform();
|
|
@@ -189,4 +189,4 @@ export {
|
|
|
189
189
|
writeFileOutput,
|
|
190
190
|
openFileOutput
|
|
191
191
|
};
|
|
192
|
-
//# sourceMappingURL=chunk-
|
|
192
|
+
//# sourceMappingURL=chunk-RDIJ6M2D.js.map
|
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
init_platform,
|
|
3
3
|
outputFailure,
|
|
4
4
|
writeBytes
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-4NMFAR4Z.js";
|
|
6
6
|
|
|
7
7
|
// packages/safe-bash/src/contracts/output.ts
|
|
8
8
|
init_platform();
|
|
@@ -133,4 +133,4 @@ function createOutputOperation(context, destination) {
|
|
|
133
133
|
export {
|
|
134
134
|
createOutputOperation
|
|
135
135
|
};
|
|
136
|
-
//# sourceMappingURL=chunk-
|
|
136
|
+
//# sourceMappingURL=chunk-UL4TNDNV.js.map
|