@poe-platform/safe-bash 0.1.44 → 0.1.46
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 +53 -31
- package/dist/safe-bash/browser.js.map +3 -3
- package/dist/safe-bash/commands/metadata/stat.d.ts.map +1 -1
- package/dist/safe-bash/commands/metadata/stat.js +32 -9
- package/dist/safe-bash/commands/metadata/stat.js.map +1 -1
- package/dist/safe-bash/shell/arrays/state.js +2 -2
- package/dist/safe-bash/shell/arrays/state.js.map +1 -1
- package/dist/safe-bash/shell/runtime.d.ts.map +1 -1
- package/dist/safe-bash/shell/runtime.js +28 -15
- package/dist/safe-bash/shell/runtime.js.map +1 -1
- package/dist/safe-bash/shell/value-state.d.ts +2 -2
- package/dist/safe-bash/shell/value-state.d.ts.map +1 -1
- package/dist/safe-bash/shell/value-state.js +20 -18
- package/dist/safe-bash/shell/value-state.js.map +1 -1
- package/package.json +2 -2
|
@@ -6216,6 +6216,15 @@ var ValueArena = class {
|
|
|
6216
6216
|
}
|
|
6217
6217
|
hold(value2) {
|
|
6218
6218
|
this.assertOpen();
|
|
6219
|
+
if (typeof value2 === "string") {
|
|
6220
|
+
const payload2 = this.allocate(value2.length * 2, 0);
|
|
6221
|
+
let released2 = false;
|
|
6222
|
+
return { value: value2, release: () => {
|
|
6223
|
+
if (released2) return;
|
|
6224
|
+
released2 = true;
|
|
6225
|
+
this.release(payload2);
|
|
6226
|
+
} };
|
|
6227
|
+
}
|
|
6219
6228
|
const reference = this.allocate(32, 1);
|
|
6220
6229
|
let payload;
|
|
6221
6230
|
try {
|
|
@@ -6285,9 +6294,7 @@ var ValueScope = class {
|
|
|
6285
6294
|
}
|
|
6286
6295
|
hold(value2) {
|
|
6287
6296
|
this.assertOpen();
|
|
6288
|
-
if (typeof value2
|
|
6289
|
-
} };
|
|
6290
|
-
this.#enrollment ??= this.arena.allocate(64, 1);
|
|
6297
|
+
if (typeof value2 !== "string") this.#enrollment ??= this.arena.allocate(64, 1);
|
|
6291
6298
|
const held = this.arena.hold(value2);
|
|
6292
6299
|
const owner = { scope: this };
|
|
6293
6300
|
const result = { value: value2, release: () => {
|
|
@@ -6304,7 +6311,7 @@ var ValueScope = class {
|
|
|
6304
6311
|
const validate = () => {
|
|
6305
6312
|
this.arena.assertRetained();
|
|
6306
6313
|
const owner = this.#holds.get(held);
|
|
6307
|
-
if (!owner || this.#closed || destination.#closed || this.arena !== destination.arena || !destination.#enrollment) throw new Error("Shell value restoration ownership is not prepared");
|
|
6314
|
+
if (!owner || this.#closed || destination.#closed || this.arena !== destination.arena || typeof held.value !== "string" && !destination.#enrollment) throw new Error("Shell value restoration ownership is not prepared");
|
|
6308
6315
|
return owner;
|
|
6309
6316
|
};
|
|
6310
6317
|
validate();
|
|
@@ -6336,18 +6343,18 @@ var ValueStore = class _ValueStore {
|
|
|
6336
6343
|
return this.#values.get(name2)?.value ?? text;
|
|
6337
6344
|
}
|
|
6338
6345
|
publish(name2, value2, action) {
|
|
6339
|
-
const held =
|
|
6346
|
+
const held = this.scope.hold(value2);
|
|
6340
6347
|
try {
|
|
6341
6348
|
if (!action()) {
|
|
6342
|
-
held
|
|
6349
|
+
held.release();
|
|
6343
6350
|
return false;
|
|
6344
6351
|
}
|
|
6345
6352
|
} catch (error) {
|
|
6346
|
-
held
|
|
6353
|
+
held.release();
|
|
6347
6354
|
throw error;
|
|
6348
6355
|
}
|
|
6349
6356
|
this.invalidate(name2);
|
|
6350
|
-
|
|
6357
|
+
this.#values.set(name2, held);
|
|
6351
6358
|
return true;
|
|
6352
6359
|
}
|
|
6353
6360
|
invalidate(name2) {
|
|
@@ -6373,14 +6380,9 @@ var ValueStore = class _ValueStore {
|
|
|
6373
6380
|
const staged = /* @__PURE__ */ new Map();
|
|
6374
6381
|
try {
|
|
6375
6382
|
for (const [name2, value2] of entries) {
|
|
6376
|
-
|
|
6377
|
-
|
|
6378
|
-
|
|
6379
|
-
staged.set(name2, held);
|
|
6380
|
-
} else {
|
|
6381
|
-
staged.get(name2)?.release();
|
|
6382
|
-
staged.delete(name2);
|
|
6383
|
-
}
|
|
6383
|
+
const held = this.scope.hold(value2);
|
|
6384
|
+
staged.get(name2)?.release();
|
|
6385
|
+
staged.set(name2, held);
|
|
6384
6386
|
}
|
|
6385
6387
|
action();
|
|
6386
6388
|
} catch (error) {
|
|
@@ -8464,7 +8466,10 @@ function trackState(state, budget, scope) {
|
|
|
8464
8466
|
await registered.scope.drainWork();
|
|
8465
8467
|
await registered.owner?.close();
|
|
8466
8468
|
});
|
|
8467
|
-
scope.register(() =>
|
|
8469
|
+
scope.register(async () => {
|
|
8470
|
+
await registered.scope.drainWork();
|
|
8471
|
+
values.close();
|
|
8472
|
+
});
|
|
8468
8473
|
sessions.set(budget, session);
|
|
8469
8474
|
}
|
|
8470
8475
|
return new StateMonitor(state, session).proxy;
|
|
@@ -8498,7 +8503,10 @@ var StateMonitor = class {
|
|
|
8498
8503
|
this.proxy = this.wrap(raw, "state");
|
|
8499
8504
|
monitors.set(raw, this);
|
|
8500
8505
|
monitors.set(this.proxy, this);
|
|
8501
|
-
session.scope.register(() =>
|
|
8506
|
+
session.scope.register(async () => {
|
|
8507
|
+
await session.scope.drainWork();
|
|
8508
|
+
this.closeValues();
|
|
8509
|
+
});
|
|
8502
8510
|
}
|
|
8503
8511
|
raw;
|
|
8504
8512
|
session;
|
|
@@ -9874,7 +9882,7 @@ function cloneGetoptsBinding(state) {
|
|
|
9874
9882
|
function saveVariable(state, name2) {
|
|
9875
9883
|
const monitor = stateMonitor(state);
|
|
9876
9884
|
const value2 = monitor?.values.get(name2, state.variables[name2] ?? "");
|
|
9877
|
-
const heldValue =
|
|
9885
|
+
const heldValue = state.variables[name2] !== void 0 && value2 !== void 0 ? monitor.values.scope.hold(value2) : void 0;
|
|
9878
9886
|
return { value: state.variables[name2], ...heldValue ? { heldValue } : {}, exported: state.exported.has(name2), readOnly: state.readonlyVariables?.has(name2) ?? false, ...name2 === "OPTIND" ? { getopts: cloneGetoptsBinding(state) } : {} };
|
|
9879
9887
|
}
|
|
9880
9888
|
function publishVariable(state, name2, value2) {
|
|
@@ -10857,7 +10865,7 @@ var Runtime = class _Runtime {
|
|
|
10857
10865
|
const tickets = publications.get(key);
|
|
10858
10866
|
stateMonitor(state).publish(tickets, key, () => {
|
|
10859
10867
|
void store.remove(key, tickets);
|
|
10860
|
-
state
|
|
10868
|
+
publishVariable(state, key, env[key]);
|
|
10861
10869
|
});
|
|
10862
10870
|
}
|
|
10863
10871
|
} finally {
|
|
@@ -11823,7 +11831,7 @@ var Runtime = class _Runtime {
|
|
|
11823
11831
|
for (const [name2, saved] of previous) {
|
|
11824
11832
|
saved.value = variables[name2];
|
|
11825
11833
|
const value2 = stateMonitor(redirectState).values.get(name2, saved.value ?? "");
|
|
11826
|
-
const held =
|
|
11834
|
+
const held = saved.value === void 0 ? void 0 : stateMonitor(state).values.scope.hold(value2);
|
|
11827
11835
|
saved.heldValue?.release();
|
|
11828
11836
|
if (held) saved.heldValue = held;
|
|
11829
11837
|
else delete saved.heldValue;
|
|
@@ -11981,7 +11989,7 @@ var Runtime = class _Runtime {
|
|
|
11981
11989
|
delete state.variables[key];
|
|
11982
11990
|
state.exported.delete(key);
|
|
11983
11991
|
} else {
|
|
11984
|
-
state
|
|
11992
|
+
publishVariable(state, key, saved.overlay);
|
|
11985
11993
|
state.exported.add(key);
|
|
11986
11994
|
}
|
|
11987
11995
|
if (key === "OPTIND") this.reconcileGetopts(state, saved.value);
|
|
@@ -12007,7 +12015,7 @@ var Runtime = class _Runtime {
|
|
|
12007
12015
|
delete state.variables[key];
|
|
12008
12016
|
state.exported.delete(key);
|
|
12009
12017
|
} else {
|
|
12010
|
-
state
|
|
12018
|
+
publishVariable(state, key, value2);
|
|
12011
12019
|
state.exported.add(key);
|
|
12012
12020
|
}
|
|
12013
12021
|
if (key === "OPTIND") this.reconcileGetopts(state, previous.get(key).value);
|
|
@@ -12134,7 +12142,10 @@ var Runtime = class _Runtime {
|
|
|
12134
12142
|
else await this.discardVariable(saved);
|
|
12135
12143
|
return;
|
|
12136
12144
|
}
|
|
12137
|
-
if (saved.superseded || state.variables[key] !== saved.overlay)
|
|
12145
|
+
if (saved.superseded || state.variables[key] !== saved.overlay) {
|
|
12146
|
+
await this.discardVariable(saved);
|
|
12147
|
+
return;
|
|
12148
|
+
}
|
|
12138
12149
|
await restoreVariable(state, key, saved);
|
|
12139
12150
|
});
|
|
12140
12151
|
await scope.cleanup(() => stateMonitor(state)?.closeOverlay(previous));
|
|
@@ -12832,14 +12843,18 @@ ${prefix2} line ${offset + line}: \`${source.split("\n")[line - 1] ?? ""}'
|
|
|
12832
12843
|
const sourceDepth = state.sourceDepth ?? 0;
|
|
12833
12844
|
const monitor = stateMonitor(state);
|
|
12834
12845
|
const restoration = monitor?.restoration(true);
|
|
12846
|
+
let savedPositionals;
|
|
12835
12847
|
try {
|
|
12848
|
+
if (args.length) savedPositionals = monitor.positionals.clone();
|
|
12836
12849
|
const owner = arrayStore(state)?.owner;
|
|
12837
12850
|
if (owner) {
|
|
12838
12851
|
owner.reserve({ metadata: 64 + args.length * 32, allocatedSlots: args.length, work: args.length + 4 });
|
|
12839
12852
|
monitor.prepareCollection(args, "positional");
|
|
12840
12853
|
}
|
|
12841
12854
|
const entry = () => {
|
|
12842
|
-
if (args.length) state.
|
|
12855
|
+
if (args.length) this.replacePositionals(state, getCommandArguments(context).values.slice(context.args.length - args.length), () => {
|
|
12856
|
+
state.positional = args;
|
|
12857
|
+
});
|
|
12843
12858
|
state.sourceDepth = (state.sourceDepth ?? 0) + 1;
|
|
12844
12859
|
state.depth++;
|
|
12845
12860
|
};
|
|
@@ -12849,6 +12864,7 @@ ${prefix2} line ${offset + line}: \`${source.split("\n")[line - 1] ?? ""}'
|
|
|
12849
12864
|
tickets.release();
|
|
12850
12865
|
} else entry();
|
|
12851
12866
|
} catch (error) {
|
|
12867
|
+
savedPositionals?.close();
|
|
12852
12868
|
restoration?.close();
|
|
12853
12869
|
throw error;
|
|
12854
12870
|
}
|
|
@@ -12861,13 +12877,19 @@ ${prefix2} line ${offset + line}: \`${source.split("\n")[line - 1] ?? ""}'
|
|
|
12861
12877
|
const restore = () => {
|
|
12862
12878
|
state.depth--;
|
|
12863
12879
|
state.sourceDepth = sourceDepth;
|
|
12864
|
-
if (
|
|
12865
|
-
|
|
12866
|
-
|
|
12880
|
+
if (savedPositionals && (state.functionDepth > 0 || (state.positionalSetVersion ?? 0) === version)) {
|
|
12881
|
+
monitor.positionals.restore(savedPositionals, () => {
|
|
12882
|
+
state.positional = positional;
|
|
12883
|
+
state.positionalSetVersion = version;
|
|
12884
|
+
});
|
|
12867
12885
|
}
|
|
12868
12886
|
};
|
|
12869
|
-
|
|
12870
|
-
|
|
12887
|
+
try {
|
|
12888
|
+
if (restoration) restoration.apply(restore);
|
|
12889
|
+
else restore();
|
|
12890
|
+
} finally {
|
|
12891
|
+
savedPositionals?.close();
|
|
12892
|
+
}
|
|
12871
12893
|
}
|
|
12872
12894
|
}
|
|
12873
12895
|
invoke(name2, args, options2 = {}, context, state, parent) {
|
|
@@ -12891,7 +12913,7 @@ ${prefix2} line ${offset + line}: \`${source.split("\n")[line - 1] ?? ""}'
|
|
|
12891
12913
|
for (const key of child.exported) delete child.variables[key];
|
|
12892
12914
|
for (const [key, value2] of Object.entries(env)) {
|
|
12893
12915
|
if (key.includes("\0") || key.includes("=") || typeof value2 !== "string" || value2.includes("\0")) throw new TypeError("Invalid invoke environment entry");
|
|
12894
|
-
child
|
|
12916
|
+
publishVariable(child, key, value2);
|
|
12895
12917
|
}
|
|
12896
12918
|
child.exported = new Set(Object.keys(env));
|
|
12897
12919
|
}
|