@poe-platform/safe-bash 0.1.676 → 0.1.678
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/README.md +2 -1
- package/dist/safe-bash/chunks/{chunk-AJMYOERL.js → chunk-2RAAINWZ.js} +53 -26
- package/dist/safe-bash/chunks/{chunk-AJMYOERL.js.map → chunk-2RAAINWZ.js.map} +2 -2
- package/dist/safe-bash/commands/text-programs/awk-syntax.d.ts.map +1 -1
- package/dist/safe-bash/commands/text-programs/awk-syntax.js +5 -3
- package/dist/safe-bash/commands/text-programs/awk-syntax.js.map +1 -1
- package/dist/safe-bash/commands/yq/index.browser.js +1 -1
- package/dist/safe-bash/commands/yq/parser.d.ts.map +1 -1
- package/dist/safe-bash/commands/yq/parser.js +59 -36
- package/dist/safe-bash/commands/yq/parser.js.map +1 -1
- package/dist/safe-bash/core.browser.js +68 -19
- package/dist/safe-bash/core.browser.js.map +3 -3
- package/dist/safe-bash/shell/arithmetic.d.ts +1 -1
- package/dist/safe-bash/shell/arithmetic.d.ts.map +1 -1
- package/dist/safe-bash/shell/arithmetic.js +37 -2
- package/dist/safe-bash/shell/arithmetic.js.map +1 -1
- package/dist/safe-bash/shell/parser.d.ts +1 -0
- package/dist/safe-bash/shell/parser.d.ts.map +1 -1
- package/dist/safe-bash/shell/parser.js +10 -4
- package/dist/safe-bash/shell/parser.js.map +1 -1
- package/dist/safe-bash/shell/runtime.d.ts.map +1 -1
- package/dist/safe-bash/shell/runtime.js +15 -9
- package/dist/safe-bash/shell/runtime.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -49,7 +49,8 @@ filesystem changes persist in the supplied `fs`.
|
|
|
49
49
|
- Pipelines (`|`, `|&`), lists (`;`, `&&`, `||`, `!`), file redirection (`<`, `>`,
|
|
50
50
|
`>>`), descriptor redirection such as `2>&1`, here-documents, and here-strings.
|
|
51
51
|
- `if`/`elif`/`else`, `case`, `for name in …`, `while`, `until`, functions,
|
|
52
|
-
groups `{ …; }`, subshells `( … )
|
|
52
|
+
groups `{ …; }`, subshells `( … )` (including adjacent nested subshells),
|
|
53
|
+
`[[ … ]]`, arithmetic commands `(( … ))`, and indexed arrays.
|
|
53
54
|
- Virtual script files through `sh`, `bash`, or executable paths; `source`/`.`
|
|
54
55
|
runs a script in the current shell. `set -e`, `set -u`, and `set -o pipefail`
|
|
55
56
|
control failures; `shopt -s dotglob` includes dotfiles in globs.
|
|
@@ -2931,7 +2931,7 @@ function stripComment(text) {
|
|
|
2931
2931
|
return flowDepth > 0 ? text.trimEnd() : text.slice(0, index).trimEnd();
|
|
2932
2932
|
}
|
|
2933
2933
|
}
|
|
2934
|
-
return text.trimEnd();
|
|
2934
|
+
return single || double ? text : text.trimEnd();
|
|
2935
2935
|
}
|
|
2936
2936
|
function mappingColon(text, flow = false) {
|
|
2937
2937
|
let single = false;
|
|
@@ -3077,20 +3077,33 @@ function normalizeTag(raw) {
|
|
|
3077
3077
|
if (!["map", "seq", "str", "null", "bool", "int", "float"].includes(name)) throw schema("SCHEMA_UNSUPPORTED_TAG");
|
|
3078
3078
|
return name;
|
|
3079
3079
|
}
|
|
3080
|
+
function scanQuotedWhitespace(raw, start, end) {
|
|
3081
|
+
let position = start;
|
|
3082
|
+
let breaks = 0;
|
|
3083
|
+
while (position < end) {
|
|
3084
|
+
const character = raw[position];
|
|
3085
|
+
if (character === "\r" || character === "\n") {
|
|
3086
|
+
breaks++;
|
|
3087
|
+
if (character === "\r" && position + 1 < end && raw[position + 1] === "\n") position++;
|
|
3088
|
+
} else if (character !== " " && character !== " ") break;
|
|
3089
|
+
position++;
|
|
3090
|
+
}
|
|
3091
|
+
return { end: position, breaks };
|
|
3092
|
+
}
|
|
3080
3093
|
function decodeDouble(raw) {
|
|
3081
3094
|
let result = "";
|
|
3082
3095
|
for (let index = 1; index < raw.length - 1; index++) {
|
|
3083
3096
|
const character = raw[index];
|
|
3084
|
-
if (
|
|
3085
|
-
|
|
3086
|
-
|
|
3087
|
-
|
|
3097
|
+
if (" \r\n".includes(character)) {
|
|
3098
|
+
const whitespace = scanQuotedWhitespace(raw, index, raw.length - 1);
|
|
3099
|
+
result += whitespace.breaks === 0 ? raw.slice(index, whitespace.end) : whitespace.breaks === 1 ? " " : "\n".repeat(whitespace.breaks - 1);
|
|
3100
|
+
index = whitespace.end - 1;
|
|
3088
3101
|
continue;
|
|
3089
3102
|
}
|
|
3090
3103
|
if (character !== "\\") {
|
|
3091
|
-
const codePoint2 =
|
|
3104
|
+
const codePoint2 = raw.codePointAt(index);
|
|
3092
3105
|
if (codePoint2 === 0) throw syntax();
|
|
3093
|
-
result +=
|
|
3106
|
+
result += String.fromCodePoint(codePoint2);
|
|
3094
3107
|
if (codePoint2 > 65535) index++;
|
|
3095
3108
|
continue;
|
|
3096
3109
|
}
|
|
@@ -3121,8 +3134,9 @@ function decodeDouble(raw) {
|
|
|
3121
3134
|
continue;
|
|
3122
3135
|
}
|
|
3123
3136
|
if (escape === "\n" || escape === "\r") {
|
|
3124
|
-
|
|
3125
|
-
|
|
3137
|
+
const whitespace = scanQuotedWhitespace(raw, index, raw.length - 1);
|
|
3138
|
+
result += "\n".repeat(whitespace.breaks - 1);
|
|
3139
|
+
index = whitespace.end - 1;
|
|
3126
3140
|
continue;
|
|
3127
3141
|
}
|
|
3128
3142
|
const digits = escape === "x" ? 2 : escape === "u" ? 4 : escape === "U" ? 8 : 0;
|
|
@@ -3149,14 +3163,14 @@ function projectDoubleBytes(raw, start = 0, end = raw.length) {
|
|
|
3149
3163
|
let bytes = 0;
|
|
3150
3164
|
for (let index = start + 1; index < end - 1; index++) {
|
|
3151
3165
|
const character = raw[index];
|
|
3152
|
-
if (
|
|
3153
|
-
|
|
3154
|
-
|
|
3155
|
-
|
|
3166
|
+
if (" \r\n".includes(character)) {
|
|
3167
|
+
const whitespace = scanQuotedWhitespace(raw, index, end - 1);
|
|
3168
|
+
bytes += whitespace.breaks === 0 ? whitespace.end - index : Math.max(1, whitespace.breaks - 1);
|
|
3169
|
+
index = whitespace.end - 1;
|
|
3156
3170
|
continue;
|
|
3157
3171
|
}
|
|
3158
3172
|
if (character !== "\\") {
|
|
3159
|
-
const codePoint2 =
|
|
3173
|
+
const codePoint2 = raw.codePointAt(index);
|
|
3160
3174
|
if (codePoint2 === 0) throw syntax();
|
|
3161
3175
|
bytes += utf8Width(codePoint2);
|
|
3162
3176
|
if (codePoint2 > 65535) index++;
|
|
@@ -3189,8 +3203,9 @@ function projectDoubleBytes(raw, start = 0, end = raw.length) {
|
|
|
3189
3203
|
continue;
|
|
3190
3204
|
}
|
|
3191
3205
|
if (escape === "\n" || escape === "\r") {
|
|
3192
|
-
|
|
3193
|
-
|
|
3206
|
+
const whitespace = scanQuotedWhitespace(raw, index, end - 1);
|
|
3207
|
+
bytes += whitespace.breaks - 1;
|
|
3208
|
+
index = whitespace.end - 1;
|
|
3194
3209
|
continue;
|
|
3195
3210
|
}
|
|
3196
3211
|
const digits = escape === "x" ? 2 : escape === "u" ? 4 : escape === "U" ? 8 : 0;
|
|
@@ -3213,8 +3228,19 @@ function projectDoubleBytes(raw, start = 0, end = raw.length) {
|
|
|
3213
3228
|
return bytes;
|
|
3214
3229
|
}
|
|
3215
3230
|
function decodeSingle(raw) {
|
|
3216
|
-
|
|
3217
|
-
|
|
3231
|
+
let result = "";
|
|
3232
|
+
for (let index = 1; index < raw.length - 1; index++) {
|
|
3233
|
+
const character = raw[index];
|
|
3234
|
+
if (" \r\n".includes(character)) {
|
|
3235
|
+
const whitespace = scanQuotedWhitespace(raw, index, raw.length - 1);
|
|
3236
|
+
result += whitespace.breaks === 0 ? raw.slice(index, whitespace.end) : whitespace.breaks === 1 ? " " : "\n".repeat(whitespace.breaks - 1);
|
|
3237
|
+
index = whitespace.end - 1;
|
|
3238
|
+
} else {
|
|
3239
|
+
result += character;
|
|
3240
|
+
if (character === "'" && raw[index + 1] === "'") index++;
|
|
3241
|
+
}
|
|
3242
|
+
}
|
|
3243
|
+
return result;
|
|
3218
3244
|
}
|
|
3219
3245
|
function projectSingleBytes(raw, start = 0, end = raw.length) {
|
|
3220
3246
|
let bytes = 0;
|
|
@@ -3223,12 +3249,12 @@ function projectSingleBytes(raw, start = 0, end = raw.length) {
|
|
|
3223
3249
|
if (character === "'" && raw[index + 1] === "'") {
|
|
3224
3250
|
bytes++;
|
|
3225
3251
|
index++;
|
|
3226
|
-
} else if (
|
|
3227
|
-
|
|
3228
|
-
|
|
3229
|
-
|
|
3252
|
+
} else if (" \r\n".includes(character)) {
|
|
3253
|
+
const whitespace = scanQuotedWhitespace(raw, index, end - 1);
|
|
3254
|
+
bytes += whitespace.breaks === 0 ? whitespace.end - index : Math.max(1, whitespace.breaks - 1);
|
|
3255
|
+
index = whitespace.end - 1;
|
|
3230
3256
|
} else {
|
|
3231
|
-
const codePoint =
|
|
3257
|
+
const codePoint = raw.codePointAt(index);
|
|
3232
3258
|
bytes += utf8Width(codePoint);
|
|
3233
3259
|
if (codePoint > 65535) index++;
|
|
3234
3260
|
}
|
|
@@ -3818,8 +3844,9 @@ var BlockParser = class {
|
|
|
3818
3844
|
}
|
|
3819
3845
|
balanced = !single && !double && (negativeDepth || depth === 0);
|
|
3820
3846
|
if (balanced || this.#index >= this.lines.length) break;
|
|
3847
|
+
const continuation = this.lines[this.#index++].text;
|
|
3821
3848
|
fragment = `
|
|
3822
|
-
${
|
|
3849
|
+
${single || double ? continuation : continuation.trimStart()}`;
|
|
3823
3850
|
fragments.push(fragment);
|
|
3824
3851
|
}
|
|
3825
3852
|
if (!balanced) throw syntax(lineNumber, 1);
|
|
@@ -3960,7 +3987,7 @@ async function* parseYamlDocuments(text, work, ledger, admittedRawBytes, lineOff
|
|
|
3960
3987
|
let codePoints = 0;
|
|
3961
3988
|
for (let index = 0; index < line.text.length; index++) {
|
|
3962
3989
|
const character = line.text[index];
|
|
3963
|
-
const point =
|
|
3990
|
+
const point = line.text.codePointAt(index);
|
|
3964
3991
|
if (doubleQuoted) {
|
|
3965
3992
|
if (escaped) escaped = false;
|
|
3966
3993
|
else if (character === "\\") escaped = true;
|
|
@@ -5200,4 +5227,4 @@ export {
|
|
|
5200
5227
|
createYqCommands,
|
|
5201
5228
|
yqCommands
|
|
5202
5229
|
};
|
|
5203
|
-
//# sourceMappingURL=chunk-
|
|
5230
|
+
//# sourceMappingURL=chunk-2RAAINWZ.js.map
|