@poe-platform/safe-bash 0.1.49 → 0.1.50
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/safe-bash/browser.js +61 -28
- package/dist/safe-bash/browser.js.map +2 -2
- package/dist/safe-bash/shell/input.d.ts.map +1 -1
- package/dist/safe-bash/shell/input.js +39 -16
- package/dist/safe-bash/shell/input.js.map +1 -1
- package/dist/safe-bash/shell/runtime.d.ts.map +1 -1
- package/dist/safe-bash/shell/runtime.js +25 -18
- package/dist/safe-bash/shell/runtime.js.map +1 -1
- package/package.json +2 -2
|
@@ -13801,21 +13801,31 @@ ${prefix2} line ${offset + line}: \`${source.split("\n")[line - 1] ?? ""}'
|
|
|
13801
13801
|
this.writeVariable(state, "REPLY", line.value);
|
|
13802
13802
|
} else {
|
|
13803
13803
|
const separators = exact ? "" : state.variables.IFS ?? " \n";
|
|
13804
|
-
|
|
13805
|
-
|
|
13806
|
-
|
|
13807
|
-
|
|
13808
|
-
|
|
13804
|
+
let end = 0;
|
|
13805
|
+
let offset = 0;
|
|
13806
|
+
let point = 0;
|
|
13807
|
+
for (const character of line.value) {
|
|
13808
|
+
offset += character.length;
|
|
13809
|
+
if (line.escaped.has(point) || !separators.includes(character) || !" \n".includes(character)) end = offset;
|
|
13810
|
+
point++;
|
|
13811
|
+
}
|
|
13809
13812
|
let position = 0;
|
|
13810
|
-
|
|
13813
|
+
point = 0;
|
|
13814
|
+
const separator = () => position < end && !line.escaped.has(point) && separators.includes(String.fromCodePoint(line.value.codePointAt(position)));
|
|
13815
|
+
const whitespace = () => separator() && " \n".includes(line.value[position]);
|
|
13816
|
+
const advance = () => {
|
|
13817
|
+
position += line.value.codePointAt(position) > 65535 ? 2 : 1;
|
|
13818
|
+
point++;
|
|
13819
|
+
};
|
|
13820
|
+
while (position < end && whitespace()) advance();
|
|
13811
13821
|
const fields = [];
|
|
13812
|
-
while (position < end) {
|
|
13822
|
+
while (position < end && fields.length < names.length) {
|
|
13813
13823
|
const start = position;
|
|
13814
|
-
while (position < end && !separator(
|
|
13824
|
+
while (position < end && !separator()) advance();
|
|
13815
13825
|
fields.push({ start, end: position });
|
|
13816
|
-
while (position < end && whitespace(
|
|
13817
|
-
if (position < end && separator(
|
|
13818
|
-
while (position < end && whitespace(
|
|
13826
|
+
while (position < end && whitespace()) advance();
|
|
13827
|
+
if (position < end && separator()) advance();
|
|
13828
|
+
while (position < end && whitespace()) advance();
|
|
13819
13829
|
}
|
|
13820
13830
|
for (let index = 0; index < names.length; index++) {
|
|
13821
13831
|
if (state.readonlyVariables?.has(names[index])) {
|
|
@@ -13823,7 +13833,7 @@ ${prefix2} line ${offset + line}: \`${source.split("\n")[line - 1] ?? ""}'
|
|
|
13823
13833
|
return index === names.length - 1 ? 1 : 2;
|
|
13824
13834
|
}
|
|
13825
13835
|
const field = fields[index];
|
|
13826
|
-
await this.assignVariable(state, names[index], field ?
|
|
13836
|
+
await this.assignVariable(state, names[index], field ? line.value.slice(field.start, index === names.length - 1 && position < end ? end : field.end) : "");
|
|
13827
13837
|
}
|
|
13828
13838
|
}
|
|
13829
13839
|
return line.terminated ? 0 : 1;
|
|
@@ -14575,6 +14585,21 @@ var InputCursor = class {
|
|
|
14575
14585
|
signal.throwIfAborted();
|
|
14576
14586
|
}
|
|
14577
14587
|
};
|
|
14588
|
+
var ReadText = class {
|
|
14589
|
+
#chunks = [];
|
|
14590
|
+
#pending = [];
|
|
14591
|
+
append(value2) {
|
|
14592
|
+
if (!value2) return;
|
|
14593
|
+
this.#pending.push(value2);
|
|
14594
|
+
if (this.#pending.length === 1024) {
|
|
14595
|
+
this.#chunks.push(this.#pending.join(""));
|
|
14596
|
+
this.#pending.length = 0;
|
|
14597
|
+
}
|
|
14598
|
+
}
|
|
14599
|
+
finish() {
|
|
14600
|
+
return this.#chunks.join("") + this.#pending.join("");
|
|
14601
|
+
}
|
|
14602
|
+
};
|
|
14578
14603
|
var ShellInput = class _ShellInput {
|
|
14579
14604
|
constructor(source, budget, signal = budget.signal) {
|
|
14580
14605
|
this.budget = budget;
|
|
@@ -14631,7 +14656,8 @@ var ShellInput = class _ShellInput {
|
|
|
14631
14656
|
return this.#cursor.consume(this.signal, () => options2 ? this.readBounded(raw, options2) : this.readLine(raw));
|
|
14632
14657
|
}
|
|
14633
14658
|
async readBounded(raw, options2) {
|
|
14634
|
-
const
|
|
14659
|
+
const text = new ReadText();
|
|
14660
|
+
let characters = 0;
|
|
14635
14661
|
const escaped = /* @__PURE__ */ new Set();
|
|
14636
14662
|
const decoder3 = new TextDecoder("utf-8", { fatal: true });
|
|
14637
14663
|
const delimiter = options2.delimiter ?? 10;
|
|
@@ -14676,18 +14702,21 @@ var ShellInput = class _ShellInput {
|
|
|
14676
14702
|
escapedCharacter = true;
|
|
14677
14703
|
}
|
|
14678
14704
|
const decoded = decoder3.decode(Uint8Array.of(byte), { stream: true });
|
|
14705
|
+
let decodedCharacters = 0;
|
|
14679
14706
|
for (const character of decoded) {
|
|
14680
14707
|
if (escapedCharacter) {
|
|
14681
14708
|
escapedCharacter = false;
|
|
14682
|
-
escaped.add(characters
|
|
14709
|
+
escaped.add(characters);
|
|
14683
14710
|
}
|
|
14684
|
-
|
|
14711
|
+
text.append(character);
|
|
14712
|
+
characters++;
|
|
14713
|
+
decodedCharacters++;
|
|
14685
14714
|
}
|
|
14686
|
-
units += options2.byteCount ? 1 :
|
|
14715
|
+
units += options2.byteCount ? 1 : decodedCharacters;
|
|
14687
14716
|
if (units === options2.count) terminated = true;
|
|
14688
14717
|
}
|
|
14689
14718
|
decoder3.decode();
|
|
14690
|
-
return { value:
|
|
14719
|
+
return { value: text.finish(), escaped, terminated };
|
|
14691
14720
|
} catch (error) {
|
|
14692
14721
|
if (error instanceof TypeError && error.message.includes("encoded data")) throw new Error("read: unsupported non-UTF-8 text boundary");
|
|
14693
14722
|
throw error;
|
|
@@ -14739,17 +14768,21 @@ var ShellInput = class _ShellInput {
|
|
|
14739
14768
|
}
|
|
14740
14769
|
const value2 = new TextDecoder().decode(bytes).replace(/\0/gu, "");
|
|
14741
14770
|
const escaped = /* @__PURE__ */ new Set();
|
|
14742
|
-
if (raw) return { value: value2, escaped, terminated };
|
|
14743
|
-
const
|
|
14744
|
-
|
|
14745
|
-
for (let index = 0; index <
|
|
14746
|
-
|
|
14747
|
-
|
|
14748
|
-
|
|
14749
|
-
|
|
14750
|
-
|
|
14751
|
-
|
|
14752
|
-
|
|
14771
|
+
if (raw || !value2.includes("\\")) return { value: value2, escaped, terminated };
|
|
14772
|
+
const text = new ReadText();
|
|
14773
|
+
let characters = 0;
|
|
14774
|
+
for (let index = 0; index < value2.length; ) {
|
|
14775
|
+
const slash = value2.indexOf("\\", index);
|
|
14776
|
+
const span = value2.slice(index, slash < 0 ? value2.length : slash);
|
|
14777
|
+
text.append(span);
|
|
14778
|
+
for (let pointOffset = 0; pointOffset < span.length; pointOffset += span.codePointAt(pointOffset) > 65535 ? 2 : 1) characters++;
|
|
14779
|
+
if (slash < 0 || slash + 1 === value2.length) break;
|
|
14780
|
+
const character = String.fromCodePoint(value2.codePointAt(slash + 1));
|
|
14781
|
+
escaped.add(characters++);
|
|
14782
|
+
text.append(character);
|
|
14783
|
+
index = slash + 1 + character.length;
|
|
14784
|
+
}
|
|
14785
|
+
return { value: text.finish(), escaped, terminated };
|
|
14753
14786
|
}
|
|
14754
14787
|
close() {
|
|
14755
14788
|
if (!this.#closing) {
|