@poe-platform/safe-bash 0.1.434 → 0.1.435
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 +236 -90
- package/dist/safe-bash/browser.js.map +3 -3
- package/dist/safe-bash/commands/stream-format/nl.js +1 -1
- package/dist/safe-bash/commands/stream-format/nl.js.map +1 -1
- package/dist/safe-bash/commands/structured/interpreter.js +10 -10
- package/dist/safe-bash/commands/structured/interpreter.js.map +1 -1
- package/dist/safe-bash/commands/structured/limits.d.ts +3 -1
- package/dist/safe-bash/commands/structured/limits.d.ts.map +1 -1
- package/dist/safe-bash/commands/structured/limits.js +16 -5
- package/dist/safe-bash/commands/structured/limits.js.map +1 -1
- package/dist/safe-bash/commands/structured/values.d.ts +5 -3
- package/dist/safe-bash/commands/structured/values.d.ts.map +1 -1
- package/dist/safe-bash/commands/structured/values.js +73 -21
- package/dist/safe-bash/commands/structured/values.js.map +1 -1
- package/dist/safe-bash/commands/text-programs/awk-runtime.js +4 -4
- package/dist/safe-bash/commands/text-programs/awk-runtime.js.map +1 -1
- package/dist/safe-bash/commands/text-programs/regex.d.ts +2 -1
- package/dist/safe-bash/commands/text-programs/regex.d.ts.map +1 -1
- package/dist/safe-bash/commands/text-programs/regex.js +230 -93
- package/dist/safe-bash/commands/text-programs/regex.js.map +1 -1
- package/dist/safe-bash/commands/text-programs/sed.js +1 -1
- package/dist/safe-bash/commands/text-programs/sed.js.map +1 -1
- package/dist/safe-bash/portable.js +325 -125
- package/dist/safe-bash/portable.js.map +3 -3
- package/dist/safe-bash/shell/arrays/state.d.ts.map +1 -1
- package/dist/safe-bash/shell/arrays/state.js +8 -2
- package/dist/safe-bash/shell/arrays/state.js.map +1 -1
- package/dist/safe-bash/shell/cleanup.d.ts +1 -1
- package/dist/safe-bash/shell/cleanup.d.ts.map +1 -1
- package/dist/safe-bash/shell/cleanup.js +7 -3
- package/dist/safe-bash/shell/cleanup.js.map +1 -1
- package/dist/safe-bash/shell/runtime.d.ts.map +1 -1
- package/dist/safe-bash/shell/runtime.js +21 -6
- package/dist/safe-bash/shell/runtime.js.map +1 -1
- package/package.json +2 -2
|
@@ -9219,7 +9219,7 @@ var InvocationScope = class _InvocationScope {
|
|
|
9219
9219
|
failures;
|
|
9220
9220
|
parent;
|
|
9221
9221
|
#children = /* @__PURE__ */ new Set();
|
|
9222
|
-
#callbacks =
|
|
9222
|
+
#callbacks = /* @__PURE__ */ new Map();
|
|
9223
9223
|
#finalizers = [];
|
|
9224
9224
|
#work = /* @__PURE__ */ new Set();
|
|
9225
9225
|
#controller = new AbortController();
|
|
@@ -9246,7 +9246,11 @@ var InvocationScope = class _InvocationScope {
|
|
|
9246
9246
|
register(cleanup) {
|
|
9247
9247
|
this.assertOpen();
|
|
9248
9248
|
if (typeof cleanup !== "function") throw new TypeError("Cleanup must be callable");
|
|
9249
|
-
|
|
9249
|
+
const registration = /* @__PURE__ */ Symbol();
|
|
9250
|
+
this.#callbacks.set(registration, cleanup);
|
|
9251
|
+
return () => {
|
|
9252
|
+
this.#callbacks.delete(registration);
|
|
9253
|
+
};
|
|
9250
9254
|
}
|
|
9251
9255
|
run(operation) {
|
|
9252
9256
|
this.assertOpen();
|
|
@@ -9279,9 +9283,11 @@ var InvocationScope = class _InvocationScope {
|
|
|
9279
9283
|
close() {
|
|
9280
9284
|
if (!this.#drain) {
|
|
9281
9285
|
this.#drain = Promise.resolve().then(async () => {
|
|
9286
|
+
const callbacks = [...this.#callbacks.values()];
|
|
9287
|
+
this.#callbacks.clear();
|
|
9282
9288
|
try {
|
|
9283
9289
|
await Promise.all([
|
|
9284
|
-
...
|
|
9290
|
+
...callbacks.map((cleanup) => this.cleanup(cleanup)),
|
|
9285
9291
|
...[...this.#children].map((child) => child.close()),
|
|
9286
9292
|
...this.#work
|
|
9287
9293
|
]);
|
|
@@ -10603,7 +10609,7 @@ var StateMonitor = class {
|
|
|
10603
10609
|
monitors.set(raw, this);
|
|
10604
10610
|
monitors.set(this.proxy, this);
|
|
10605
10611
|
if (session.monitors) session.monitors.add(this);
|
|
10606
|
-
else session.scope.register(async () => {
|
|
10612
|
+
else this.#retireCleanup = session.scope.register(async () => {
|
|
10607
10613
|
await session.scope.drainWork();
|
|
10608
10614
|
this.closeValues();
|
|
10609
10615
|
});
|
|
@@ -10622,9 +10628,12 @@ var StateMonitor = class {
|
|
|
10622
10628
|
#internalEnrollment;
|
|
10623
10629
|
#restorations;
|
|
10624
10630
|
#overlays;
|
|
10631
|
+
#retireCleanup;
|
|
10625
10632
|
closeValues() {
|
|
10626
10633
|
this.values.close();
|
|
10627
10634
|
this.positionals.close();
|
|
10635
|
+
this.#retireCleanup?.();
|
|
10636
|
+
this.#retireCleanup = void 0;
|
|
10628
10637
|
}
|
|
10629
10638
|
changedValue(target, field, key) {
|
|
10630
10639
|
if (field === "state") {
|
|
@@ -12592,7 +12601,7 @@ var InvocationCancellationOwner = class {
|
|
|
12592
12601
|
this.finalized = new Promise((resolve) => {
|
|
12593
12602
|
this.#resolveFinalized = resolve;
|
|
12594
12603
|
});
|
|
12595
|
-
parent.register(async () => {
|
|
12604
|
+
this.#retireCleanup = parent.register(async () => {
|
|
12596
12605
|
this.requestClose();
|
|
12597
12606
|
await this.finalized;
|
|
12598
12607
|
});
|
|
@@ -12602,6 +12611,7 @@ var InvocationCancellationOwner = class {
|
|
|
12602
12611
|
#failures;
|
|
12603
12612
|
#outcomes;
|
|
12604
12613
|
#publicPromise;
|
|
12614
|
+
#retireCleanup;
|
|
12605
12615
|
#resolveFinalized;
|
|
12606
12616
|
#admissionOpen = true;
|
|
12607
12617
|
#boundary;
|
|
@@ -12678,6 +12688,7 @@ var InvocationCancellationOwner = class {
|
|
|
12678
12688
|
this.#outcomes.discard(this.#record);
|
|
12679
12689
|
this.#closeBoundary();
|
|
12680
12690
|
this.#resolveFinalized();
|
|
12691
|
+
this.#retireCleanup();
|
|
12681
12692
|
}
|
|
12682
12693
|
}
|
|
12683
12694
|
async #finishOnce(barrier, captured) {
|
|
@@ -12690,6 +12701,7 @@ var InvocationCancellationOwner = class {
|
|
|
12690
12701
|
return selection;
|
|
12691
12702
|
} finally {
|
|
12692
12703
|
this.#resolveFinalized();
|
|
12704
|
+
this.#retireCleanup();
|
|
12693
12705
|
}
|
|
12694
12706
|
}
|
|
12695
12707
|
#closeBoundary() {
|
|
@@ -14044,10 +14056,18 @@ var Runtime = class _Runtime {
|
|
|
14044
14056
|
if (--file.references === 0 && this.outputFiles.get(path) === file) this.outputFiles.delete(path);
|
|
14045
14057
|
};
|
|
14046
14058
|
let target2;
|
|
14059
|
+
let outputScope;
|
|
14047
14060
|
try {
|
|
14048
|
-
|
|
14061
|
+
outputScope = io[invocationScope].child();
|
|
14062
|
+
target2 = await openFileOutput({ fs: this.fs, signal: this.signal, registerCleanup: (cleanup) => {
|
|
14063
|
+
outputScope.register(cleanup);
|
|
14064
|
+
} }, path, append ? "a" : "w", random ? incremental : void 0);
|
|
14049
14065
|
} catch (error) {
|
|
14050
|
-
|
|
14066
|
+
try {
|
|
14067
|
+
await outputScope?.close();
|
|
14068
|
+
} finally {
|
|
14069
|
+
release();
|
|
14070
|
+
}
|
|
14051
14071
|
throw error;
|
|
14052
14072
|
}
|
|
14053
14073
|
outputs.add(async (completion) => {
|
|
@@ -14063,7 +14083,11 @@ var Runtime = class _Runtime {
|
|
|
14063
14083
|
}
|
|
14064
14084
|
}
|
|
14065
14085
|
} finally {
|
|
14066
|
-
|
|
14086
|
+
try {
|
|
14087
|
+
await outputScope?.close();
|
|
14088
|
+
} finally {
|
|
14089
|
+
release();
|
|
14090
|
+
}
|
|
14067
14091
|
}
|
|
14068
14092
|
});
|
|
14069
14093
|
const output2 = this.budget.sink(target2.sink, this.signal);
|
|
@@ -14304,7 +14328,9 @@ var Runtime = class _Runtime {
|
|
|
14304
14328
|
fs: this.fs,
|
|
14305
14329
|
signal: this.commandSignal,
|
|
14306
14330
|
executionScope: this.budget.executionScope,
|
|
14307
|
-
registerCleanup: (cleanup) =>
|
|
14331
|
+
registerCleanup: (cleanup) => {
|
|
14332
|
+
scope.register(cleanup);
|
|
14333
|
+
},
|
|
14308
14334
|
invoke: (name3, args, options3) => {
|
|
14309
14335
|
const invocation = this.invoke(name3, args, options3, context, state, scope);
|
|
14310
14336
|
void invocation.catch(() => void 0);
|
|
@@ -14911,7 +14937,9 @@ ${prefix2} line ${offset + line}: \`${source.split("\n")[line - 1] ?? ""}'
|
|
|
14911
14937
|
stdout: this.budget.sink(incoming.stdout, runtime.signal),
|
|
14912
14938
|
stderr: this.budget.sink(incoming.stderr, runtime.signal),
|
|
14913
14939
|
signal: this.commandSignal,
|
|
14914
|
-
registerCleanup: (cleanup) =>
|
|
14940
|
+
registerCleanup: (cleanup) => {
|
|
14941
|
+
scope.register(cleanup);
|
|
14942
|
+
},
|
|
14915
14943
|
invoke: (name2, args, options3) => {
|
|
14916
14944
|
const invocation = invocationOverride.current ? invocationOverride.current(name2, args, options3) : runtime.invoke(name2, args, options3, context, child, scope);
|
|
14917
14945
|
void invocation.catch(() => void 0);
|
|
@@ -18829,10 +18857,32 @@ function extendedSource(source) {
|
|
|
18829
18857
|
}
|
|
18830
18858
|
return result;
|
|
18831
18859
|
}
|
|
18860
|
+
var NfaStorage = class {
|
|
18861
|
+
constructor(budget) {
|
|
18862
|
+
this.budget = budget;
|
|
18863
|
+
}
|
|
18864
|
+
budget;
|
|
18865
|
+
used = 0;
|
|
18866
|
+
reserve(bytes2) {
|
|
18867
|
+
this.budget.step(0);
|
|
18868
|
+
if (!Number.isSafeInteger(bytes2) || bytes2 < 0 || bytes2 > this.budget.maxBufferBytes - this.used) {
|
|
18869
|
+
throw new ProgramError("regular expression state buffer limit exceeded");
|
|
18870
|
+
}
|
|
18871
|
+
this.used += bytes2;
|
|
18872
|
+
}
|
|
18873
|
+
release(bytes2) {
|
|
18874
|
+
if (!Number.isSafeInteger(bytes2) || bytes2 < 0 || bytes2 > this.used) throw new ProgramError("invalid regular expression state accounting");
|
|
18875
|
+
this.used -= bytes2;
|
|
18876
|
+
}
|
|
18877
|
+
clear() {
|
|
18878
|
+
this.used = 0;
|
|
18879
|
+
}
|
|
18880
|
+
};
|
|
18832
18881
|
var Pattern = class {
|
|
18833
18882
|
groupCount;
|
|
18834
18883
|
code = [];
|
|
18835
18884
|
anchored;
|
|
18885
|
+
linear;
|
|
18836
18886
|
constructor(source, extended = true, ignoreCase = false) {
|
|
18837
18887
|
if (source.length > 8192) throw new ProgramError("regular expression exceeds 8192 bytes");
|
|
18838
18888
|
if (!extended) source = extendedSource(source);
|
|
@@ -18999,92 +19049,188 @@ var Pattern = class {
|
|
|
18999
19049
|
};
|
|
19000
19050
|
compile(root);
|
|
19001
19051
|
emit({ kind: "match" });
|
|
19052
|
+
this.linear = this.code.every((instruction) => instruction.kind === "character" || instruction.kind === "begin" || instruction.kind === "end" || instruction.kind === "match");
|
|
19002
19053
|
}
|
|
19003
|
-
find(text, budget, from = 0) {
|
|
19004
|
-
|
|
19005
|
-
|
|
19006
|
-
|
|
19007
|
-
|
|
19008
|
-
|
|
19009
|
-
|
|
19010
|
-
|
|
19011
|
-
|
|
19012
|
-
|
|
19013
|
-
|
|
19014
|
-
|
|
19015
|
-
|
|
19016
|
-
|
|
19017
|
-
|
|
19018
|
-
|
|
19019
|
-
return false;
|
|
19020
|
-
};
|
|
19021
|
-
for (let position = start; positions.size && position <= text.length; position++) {
|
|
19022
|
-
budget.step();
|
|
19023
|
-
const pending = positions.get(position)?.reverse() ?? [];
|
|
19024
|
-
positions.delete(position);
|
|
19025
|
-
queued -= pending.length;
|
|
19026
|
-
const visited = /* @__PURE__ */ new Set();
|
|
19027
|
-
let stateBytes = 0;
|
|
19028
|
-
const enqueue = (destination, thread) => {
|
|
19029
|
-
if (destination === position) pending.push(thread);
|
|
19030
|
-
else {
|
|
19031
|
-
const waiting = positions.get(destination);
|
|
19032
|
-
if (waiting) waiting.push(thread);
|
|
19033
|
-
else positions.set(destination, [thread]);
|
|
19034
|
-
queued++;
|
|
19035
|
-
}
|
|
19036
|
-
if ((queued + pending.length) * (32 + this.groupCount * 16) > budget.maxBufferBytes) throw new ProgramError("regular expression state buffer limit exceeded");
|
|
19037
|
-
};
|
|
19038
|
-
while (pending.length) {
|
|
19039
|
-
budget.step();
|
|
19040
|
-
const thread = pending.pop();
|
|
19041
|
-
const state = this.groupCount ? `${thread.pc}:${thread.captures.join(",")}` : thread.pc;
|
|
19042
|
-
if (visited.has(state)) continue;
|
|
19043
|
-
visited.add(state);
|
|
19044
|
-
stateBytes += typeof state === "string" ? state.length * 2 + 32 : 16;
|
|
19045
|
-
if (stateBytes > budget.maxBufferBytes) throw new ProgramError("regular expression state buffer limit exceeded");
|
|
19046
|
-
const instruction = this.code[thread.pc];
|
|
19054
|
+
async find(text, budget, from = 0) {
|
|
19055
|
+
await budget.checkpoint();
|
|
19056
|
+
let units = 0;
|
|
19057
|
+
const work = (count2 = 1) => {
|
|
19058
|
+
budget.step(count2);
|
|
19059
|
+
units += count2;
|
|
19060
|
+
if (units < 64) return void 0;
|
|
19061
|
+
units %= 64;
|
|
19062
|
+
return budget.checkpoint();
|
|
19063
|
+
};
|
|
19064
|
+
if (this.linear) {
|
|
19065
|
+
for (let start = from; start <= text.length && (!this.anchored || start === 0); start++) {
|
|
19066
|
+
let position = start;
|
|
19067
|
+
for (const instruction of this.code) {
|
|
19068
|
+
const paused = work(2);
|
|
19069
|
+
if (paused) await paused;
|
|
19047
19070
|
if (instruction.kind === "character") {
|
|
19048
|
-
if (position
|
|
19049
|
-
|
|
19050
|
-
|
|
19051
|
-
|
|
19052
|
-
if (
|
|
19053
|
-
|
|
19054
|
-
|
|
19055
|
-
|
|
19056
|
-
|
|
19057
|
-
|
|
19058
|
-
|
|
19059
|
-
|
|
19060
|
-
|
|
19071
|
+
if (position >= text.length || !instruction.accepts(text[position])) break;
|
|
19072
|
+
position++;
|
|
19073
|
+
} else if (instruction.kind === "begin" && position !== 0 || instruction.kind === "end" && position !== text.length) break;
|
|
19074
|
+
else if (instruction.kind === "match") {
|
|
19075
|
+
if (position - start > budget.maxBufferBytes) throw new ProgramError("text buffer limit exceeded");
|
|
19076
|
+
const copied = work(position - start);
|
|
19077
|
+
if (copied) await copied;
|
|
19078
|
+
const match = { start, end: position, groups: [text.slice(start, position)] };
|
|
19079
|
+
await budget.checkpoint();
|
|
19080
|
+
return match;
|
|
19081
|
+
}
|
|
19082
|
+
}
|
|
19083
|
+
}
|
|
19084
|
+
return void 0;
|
|
19085
|
+
}
|
|
19086
|
+
const storage = new NfaStorage(budget);
|
|
19087
|
+
const positionDigits = String(text.length).length;
|
|
19088
|
+
const instructionDigits = String(this.code.length).length;
|
|
19089
|
+
try {
|
|
19090
|
+
for (let start = from; start <= text.length && (!this.anchored || start === 0); start++) {
|
|
19091
|
+
storage.reserve(256);
|
|
19092
|
+
const positions = /* @__PURE__ */ new Map([[start, [{ pc: 0, captures: [], bytes: 64 }]]]);
|
|
19093
|
+
let bestEnd;
|
|
19094
|
+
let bestCaptures = [];
|
|
19095
|
+
let bestBytes = 0;
|
|
19096
|
+
try {
|
|
19097
|
+
for (let position = start; positions.size && position <= text.length; position++) {
|
|
19098
|
+
const advanced = work();
|
|
19099
|
+
if (advanced) await advanced;
|
|
19100
|
+
const pending = positions.get(position);
|
|
19101
|
+
if (!pending) continue;
|
|
19102
|
+
const reversed = work(pending.length);
|
|
19103
|
+
if (reversed) await reversed;
|
|
19104
|
+
pending.reverse();
|
|
19105
|
+
positions.delete(position);
|
|
19106
|
+
const visited = /* @__PURE__ */ new Set();
|
|
19107
|
+
let stateBytes = 0;
|
|
19108
|
+
const enqueue = (destination, pc, captures, saveSlot) => {
|
|
19109
|
+
const length = saveSlot === void 0 ? captures.length : Math.max(captures.length, saveSlot + 1);
|
|
19110
|
+
const bytes2 = 64 + length * 8;
|
|
19111
|
+
const waiting = destination === position ? pending : positions.get(destination);
|
|
19112
|
+
storage.reserve(bytes2 + (waiting ? 0 : 64));
|
|
19113
|
+
const saved = saveSlot === void 0 ? captures : [...captures];
|
|
19114
|
+
if (saveSlot !== void 0) saved[saveSlot] = position;
|
|
19115
|
+
const thread = { pc, captures: saved, bytes: bytes2 };
|
|
19116
|
+
if (waiting) waiting.push(thread);
|
|
19117
|
+
else positions.set(destination, [thread]);
|
|
19118
|
+
};
|
|
19119
|
+
while (pending.length) {
|
|
19120
|
+
const paused = work();
|
|
19121
|
+
if (paused) await paused;
|
|
19122
|
+
const thread = pending.pop();
|
|
19123
|
+
try {
|
|
19124
|
+
let state = thread.pc;
|
|
19125
|
+
let bytes2 = 32;
|
|
19126
|
+
if (this.groupCount) {
|
|
19127
|
+
const joinedLength = Math.max(0, thread.captures.length - 1) + thread.captures.length * positionDigits;
|
|
19128
|
+
const stateLength = instructionDigits + 1 + joinedLength;
|
|
19129
|
+
const serialized = work(stateLength);
|
|
19130
|
+
if (serialized) await serialized;
|
|
19131
|
+
const reserved = 32 + joinedLength * 2 + 64 + stateLength * 2;
|
|
19132
|
+
storage.reserve(reserved);
|
|
19133
|
+
state = `${thread.pc}:${thread.captures.join(",")}`;
|
|
19134
|
+
bytes2 = 64 + state.length * 2;
|
|
19135
|
+
storage.release(reserved - bytes2);
|
|
19136
|
+
} else storage.reserve(bytes2);
|
|
19137
|
+
if (visited.has(state)) {
|
|
19138
|
+
storage.release(bytes2);
|
|
19139
|
+
continue;
|
|
19140
|
+
}
|
|
19141
|
+
visited.add(state);
|
|
19142
|
+
stateBytes += bytes2;
|
|
19143
|
+
const instruction = this.code[thread.pc];
|
|
19144
|
+
if (instruction.kind === "character") {
|
|
19145
|
+
if (position < text.length && instruction.accepts(text[position])) enqueue(position + 1, thread.pc + 1, thread.captures);
|
|
19146
|
+
} else if (instruction.kind === "backreference") {
|
|
19147
|
+
const begin = thread.captures[instruction.index * 2];
|
|
19148
|
+
const end = thread.captures[instruction.index * 2 + 1];
|
|
19149
|
+
if (begin === void 0 || end === void 0 || position + end - begin > text.length) continue;
|
|
19150
|
+
let matches = true;
|
|
19151
|
+
for (let offset = 0; offset < end - begin; offset++) {
|
|
19152
|
+
const compared = work();
|
|
19153
|
+
if (compared) await compared;
|
|
19154
|
+
const expected = text[begin + offset];
|
|
19155
|
+
const actual = text[position + offset];
|
|
19156
|
+
if (instruction.ignoreCase ? expected.toLowerCase() !== actual.toLowerCase() : expected !== actual) {
|
|
19157
|
+
matches = false;
|
|
19158
|
+
break;
|
|
19159
|
+
}
|
|
19160
|
+
}
|
|
19161
|
+
if (matches) enqueue(position + end - begin, thread.pc + 1, thread.captures);
|
|
19162
|
+
} else if (instruction.kind === "match") {
|
|
19163
|
+
let preferred2 = bestEnd === void 0 || position > bestEnd;
|
|
19164
|
+
if (position === bestEnd) for (let index = 1; index <= this.groupCount; index++) {
|
|
19165
|
+
const compared = work();
|
|
19166
|
+
if (compared) await compared;
|
|
19167
|
+
const begin = thread.captures[index * 2];
|
|
19168
|
+
const end = thread.captures[index * 2 + 1];
|
|
19169
|
+
const priorBegin = bestCaptures[index * 2];
|
|
19170
|
+
const priorEnd = bestCaptures[index * 2 + 1];
|
|
19171
|
+
const length = begin === void 0 || end === void 0 ? -1 : end - begin;
|
|
19172
|
+
const priorLength = priorBegin === void 0 || priorEnd === void 0 ? -1 : priorEnd - priorBegin;
|
|
19173
|
+
if (length !== priorLength) {
|
|
19174
|
+
preferred2 = length > priorLength;
|
|
19175
|
+
break;
|
|
19176
|
+
}
|
|
19177
|
+
}
|
|
19178
|
+
if (preferred2) {
|
|
19179
|
+
const retained = 32 + thread.captures.length * 8;
|
|
19180
|
+
storage.reserve(retained);
|
|
19181
|
+
bestEnd = position;
|
|
19182
|
+
bestCaptures = thread.captures;
|
|
19183
|
+
storage.release(bestBytes);
|
|
19184
|
+
bestBytes = retained;
|
|
19185
|
+
}
|
|
19186
|
+
} else if (instruction.kind === "split") {
|
|
19187
|
+
enqueue(position, instruction.second, thread.captures);
|
|
19188
|
+
enqueue(position, instruction.first, thread.captures);
|
|
19189
|
+
} else if (instruction.kind === "jump") enqueue(position, instruction.target, thread.captures);
|
|
19190
|
+
else if (instruction.kind === "save") {
|
|
19191
|
+
const copied = work(Math.max(thread.captures.length, instruction.slot + 1));
|
|
19192
|
+
if (copied) await copied;
|
|
19193
|
+
enqueue(position, thread.pc + 1, thread.captures, instruction.slot);
|
|
19194
|
+
} else if (instruction.kind === "begin" ? position === 0 : position === text.length) enqueue(position, thread.pc + 1, thread.captures);
|
|
19195
|
+
} finally {
|
|
19196
|
+
storage.release(thread.bytes);
|
|
19061
19197
|
}
|
|
19062
19198
|
}
|
|
19063
|
-
|
|
19064
|
-
|
|
19065
|
-
|
|
19066
|
-
|
|
19067
|
-
|
|
19068
|
-
|
|
19069
|
-
|
|
19070
|
-
|
|
19071
|
-
|
|
19072
|
-
|
|
19073
|
-
|
|
19199
|
+
visited.clear();
|
|
19200
|
+
storage.release(stateBytes + 64);
|
|
19201
|
+
}
|
|
19202
|
+
if (bestEnd !== void 0) {
|
|
19203
|
+
let characters = bestEnd - start;
|
|
19204
|
+
for (let index = 1; index <= this.groupCount; index++) {
|
|
19205
|
+
const counted = work();
|
|
19206
|
+
if (counted) await counted;
|
|
19207
|
+
const begin = bestCaptures[index * 2];
|
|
19208
|
+
const end = bestCaptures[index * 2 + 1];
|
|
19209
|
+
if (begin !== void 0 && end !== void 0) characters += end - begin;
|
|
19210
|
+
}
|
|
19211
|
+
const copied = work(characters);
|
|
19212
|
+
if (copied) await copied;
|
|
19213
|
+
storage.reserve(64 + (this.groupCount + 1) * 40 + characters * 2);
|
|
19214
|
+
const groups = [text.slice(start, bestEnd)];
|
|
19215
|
+
for (let index = 1; index <= this.groupCount; index++) {
|
|
19216
|
+
const materialized = work();
|
|
19217
|
+
if (materialized) await materialized;
|
|
19218
|
+
const begin = bestCaptures[index * 2];
|
|
19219
|
+
const end = bestCaptures[index * 2 + 1];
|
|
19220
|
+
groups.push(begin === void 0 || end === void 0 ? void 0 : text.slice(begin, end));
|
|
19074
19221
|
}
|
|
19075
|
-
|
|
19076
|
-
|
|
19077
|
-
}
|
|
19078
|
-
|
|
19079
|
-
|
|
19080
|
-
|
|
19081
|
-
pending.push({ pc: thread.pc + 1, captures });
|
|
19082
|
-
} else if (instruction.kind === "begin" ? position === 0 : position === text.length) pending.push({ pc: thread.pc + 1, captures: thread.captures });
|
|
19222
|
+
await budget.checkpoint();
|
|
19223
|
+
return { start, end: bestEnd, groups };
|
|
19224
|
+
}
|
|
19225
|
+
} finally {
|
|
19226
|
+
positions.clear();
|
|
19227
|
+
storage.clear();
|
|
19083
19228
|
}
|
|
19084
19229
|
}
|
|
19085
|
-
|
|
19230
|
+
return void 0;
|
|
19231
|
+
} finally {
|
|
19232
|
+
storage.clear();
|
|
19086
19233
|
}
|
|
19087
|
-
return void 0;
|
|
19088
19234
|
}
|
|
19089
19235
|
};
|
|
19090
19236
|
async function replacementLength(replacement, match, budget, available) {
|
|
@@ -19146,7 +19292,7 @@ async function substitute(text, pattern, replacement, budget, global, occurrence
|
|
|
19146
19292
|
while (search <= text.length) {
|
|
19147
19293
|
await budget.checkpoint();
|
|
19148
19294
|
budget.step();
|
|
19149
|
-
const match = pattern.find(text, budget, search);
|
|
19295
|
+
const match = await pattern.find(text, budget, search);
|
|
19150
19296
|
if (!match) break;
|
|
19151
19297
|
if (match.start === match.end && match.start === previousEnd) {
|
|
19152
19298
|
search = match.end + 1;
|
|
@@ -19479,7 +19625,7 @@ async function execute(program, context, files, quiet, budget, separator, output
|
|
|
19479
19625
|
if (terminated) outputState.unterminatedFiles.delete(path);
|
|
19480
19626
|
else outputState.unterminatedFiles.add(path);
|
|
19481
19627
|
};
|
|
19482
|
-
const matches = async (address) => address.kind === "number" ? number === address.number : address.kind === "last" ? (await peekNext()).done === true : getPattern(address.pattern).find(pattern, budget) !== void 0;
|
|
19628
|
+
const matches = async (address) => address.kind === "number" ? number === address.number : address.kind === "last" ? (await peekNext()).done === true : await getPattern(address.pattern).find(pattern, budget) !== void 0;
|
|
19483
19629
|
for (let pc = 0; pc < program.length; ) {
|
|
19484
19630
|
budget.step();
|
|
19485
19631
|
await budget.checkpoint();
|