@poe-platform/safe-bash 0.1.107 → 0.1.109

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.
@@ -15392,21 +15392,48 @@ ${prefix2} line ${offset + line}: \`${source.split("\n")[line - 1] ?? ""}'
15392
15392
  field.present ||= present;
15393
15393
  };
15394
15394
  const appendSplit = async (value2) => {
15395
+ this.budget.cpuCheckpoint();
15396
+ if (shellValueByteLength(value2) === 0) return;
15395
15397
  const separators = state.variables.IFS ?? " \n";
15396
- let boundary = false;
15397
- for await (const piece of this.splitValue(value2, separators, io, scratch)) {
15398
- if (typeof piece === "string" && separators.includes(piece)) {
15399
- if (!" \n".includes(piece)) {
15400
- fields.at(-1).present = true;
15401
- addField();
15402
- } else if (fields.at(-1).present) boundary = true;
15403
- } else {
15404
- if (boundary) addField();
15405
- boundary = false;
15406
- append(piece, true, true);
15398
+ const separatorScope = this.budget.values.scope();
15399
+ try {
15400
+ separatorScope.reserve(64, 0);
15401
+ const points = /* @__PURE__ */ new Set();
15402
+ const addSeparator = (point) => {
15403
+ if (points.has(point)) return;
15404
+ separatorScope.reserve(32, 0);
15405
+ points.add(point);
15406
+ };
15407
+ let asciiSeparators = true;
15408
+ const work = this.splitWork ??= { scanned: 0 };
15409
+ for (let index = 0; index < separators.length; index++) {
15410
+ const unit = separators.charCodeAt(index);
15411
+ asciiSeparators &&= unit <= 127;
15412
+ addSeparator(unit);
15413
+ addSeparator(separators.codePointAt(index));
15414
+ if (++work.scanned >= 4096) {
15415
+ work.scanned = 0;
15416
+ await yieldTurn(this.signal);
15417
+ }
15407
15418
  }
15419
+ let boundary = false;
15420
+ for await (const piece of this.splitValue(value2, points, asciiSeparators, io, scratch)) {
15421
+ const point = typeof piece === "string" ? piece.codePointAt(0) : void 0;
15422
+ if (typeof piece === "string" && point !== void 0 && piece.length === (point > 65535 ? 2 : 1) && points.has(point)) {
15423
+ if (!" \n".includes(piece)) {
15424
+ fields.at(-1).present = true;
15425
+ addField();
15426
+ } else if (fields.at(-1).present) boundary = true;
15427
+ } else {
15428
+ if (boundary) addField();
15429
+ boundary = false;
15430
+ append(piece, true, true);
15431
+ }
15432
+ }
15433
+ if (boundary) addField();
15434
+ } finally {
15435
+ separatorScope.close();
15408
15436
  }
15409
- if (boundary) addField();
15410
15437
  };
15411
15438
  const parts = word.parts.map((part) => ({ part, splitText: false, io }));
15412
15439
  for (let index = 0; index < parts.length; index++) {
@@ -15484,10 +15511,10 @@ ${prefix2} line ${offset + line}: \`${source.split("\n")[line - 1] ?? ""}'
15484
15511
  }
15485
15512
  }
15486
15513
  splitWork;
15487
- async *splitValue(value2, separators, io, scratch) {
15514
+ async *splitValue(value2, separators, asciiSeparators, io, scratch) {
15488
15515
  this.budget.cpuCheckpoint();
15489
15516
  const work = this.splitWork ??= { scanned: 0 };
15490
- if (typeof value2 === "string" || Array.from(separators).some((character) => character.charCodeAt(0) > 127)) {
15517
+ if (typeof value2 === "string" || !asciiSeparators) {
15491
15518
  const text = shellValueText(value2);
15492
15519
  const slice = (start3, end) => {
15493
15520
  if (start3 === 0 && end === text.length) return text;
@@ -15496,9 +15523,10 @@ ${prefix2} line ${offset + line}: \`${source.split("\n")[line - 1] ?? ""}'
15496
15523
  };
15497
15524
  let start2 = 0;
15498
15525
  for (let index = 0; index < text.length; ) {
15499
- const character = String.fromCodePoint(text.codePointAt(index));
15526
+ const point = text.codePointAt(index);
15527
+ const character = String.fromCodePoint(point);
15500
15528
  const end = index + character.length;
15501
- if (separators.includes(character)) {
15529
+ if (separators.has(point)) {
15502
15530
  if (start2 < index) yield slice(start2, index);
15503
15531
  yield character;
15504
15532
  start2 = end;
@@ -15524,7 +15552,7 @@ ${prefix2} line ${offset + line}: \`${source.split("\n")[line - 1] ?? ""}'
15524
15552
  await yieldTurn(this.signal);
15525
15553
  }
15526
15554
  const byte = bytes2[index];
15527
- if (byte > 127 || !separators.includes(String.fromCharCode(byte))) continue;
15555
+ if (byte > 127 || !separators.has(byte)) continue;
15528
15556
  if (start < index) yield shellValueFromBytes(bytes2.subarray(start, index), io[valueScope]);
15529
15557
  yield String.fromCharCode(byte);
15530
15558
  start = index + 1;