@mojir/dvala 0.0.27 → 0.0.29
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/cli/cli.js +40 -7
- package/package.json +1 -1
package/dist/cli/cli.js
CHANGED
|
@@ -478,7 +478,7 @@ function findAllOccurrences(input, pattern) {
|
|
|
478
478
|
}
|
|
479
479
|
//#endregion
|
|
480
480
|
//#region package.json
|
|
481
|
-
var version = "0.0.
|
|
481
|
+
var version = "0.0.29";
|
|
482
482
|
//#endregion
|
|
483
483
|
//#region src/typeGuards/string.ts
|
|
484
484
|
function isString(value, options = {}) {
|
|
@@ -26010,10 +26010,12 @@ const dvalaCommands = new Set([
|
|
|
26010
26010
|
...specialExpressionKeys,
|
|
26011
26011
|
...Object.keys(reservedSymbolRecord)
|
|
26012
26012
|
]);
|
|
26013
|
+
const DOT_PREFIX_RE = /((?:[a-zA-Z][a-zA-Z0-9_-]*\.)+)$/;
|
|
26013
26014
|
var AutoCompleter = class {
|
|
26014
26015
|
prefixProgram = "";
|
|
26015
26016
|
suffixProgram = "";
|
|
26016
26017
|
searchString = "";
|
|
26018
|
+
dotPrefix = "";
|
|
26017
26019
|
suggestions = [];
|
|
26018
26020
|
suggestionIndex = null;
|
|
26019
26021
|
constructor(originalProgram, originalPosition, params = {}) {
|
|
@@ -26026,6 +26028,12 @@ var AutoCompleter = class {
|
|
|
26026
26028
|
this.prefixProgram = this.originalProgram.slice(0, this.originalPosition - this.searchString.length);
|
|
26027
26029
|
this.suffixProgram = this.originalProgram.slice(this.prefixProgram.length + this.searchString.length);
|
|
26028
26030
|
this.originalProgram.slice(this.prefixProgram.length + this.searchString.length);
|
|
26031
|
+
if (lastToken[0] === "Operator" && this.searchString === ".") {
|
|
26032
|
+
this.prefixProgram = this.originalProgram.slice(0, this.originalPosition);
|
|
26033
|
+
this.suffixProgram = this.originalProgram.slice(this.originalPosition);
|
|
26034
|
+
this.searchString = "";
|
|
26035
|
+
}
|
|
26036
|
+
this.dotPrefix = DOT_PREFIX_RE.exec(this.prefixProgram)?.[1] ?? "";
|
|
26029
26037
|
this.suggestions = this.generateSuggestions(params);
|
|
26030
26038
|
}
|
|
26031
26039
|
getNextSuggestion() {
|
|
@@ -26067,6 +26075,8 @@ var AutoCompleter = class {
|
|
|
26067
26075
|
}
|
|
26068
26076
|
generateSuggestions(params) {
|
|
26069
26077
|
const blacklist = new Set(["0_defn", "0_lambda"]);
|
|
26078
|
+
const fullSearch = this.dotPrefix + this.searchString;
|
|
26079
|
+
if (this.dotPrefix) return this.generateDottedEffectSuggestions(params.effectNames ?? [], fullSearch);
|
|
26070
26080
|
const startsWithCaseSensitive = this.generateWithPredicate(params, (suggestion) => !blacklist.has(suggestion) && suggestion.startsWith(this.searchString));
|
|
26071
26081
|
startsWithCaseSensitive.forEach((suggestion) => blacklist.add(suggestion));
|
|
26072
26082
|
const startsWithCaseInsensitive = this.generateWithPredicate(params, (suggestion) => !blacklist.has(suggestion) && suggestion.toLowerCase().startsWith(this.searchString.toLowerCase()));
|
|
@@ -26082,12 +26092,33 @@ var AutoCompleter = class {
|
|
|
26082
26092
|
...includesCaseInsensitive
|
|
26083
26093
|
];
|
|
26084
26094
|
}
|
|
26095
|
+
generateDottedEffectSuggestions(effectNames, fullSearch) {
|
|
26096
|
+
const seen = /* @__PURE__ */ new Set();
|
|
26097
|
+
const results = [];
|
|
26098
|
+
const predicates = [
|
|
26099
|
+
(name) => name.startsWith(fullSearch),
|
|
26100
|
+
(name) => name.toLowerCase().startsWith(fullSearch.toLowerCase()),
|
|
26101
|
+
(name) => name.includes(fullSearch),
|
|
26102
|
+
(name) => name.toLowerCase().includes(fullSearch.toLowerCase())
|
|
26103
|
+
];
|
|
26104
|
+
for (const pred of predicates) for (const name of effectNames) {
|
|
26105
|
+
const insertText = name.slice(this.dotPrefix.length);
|
|
26106
|
+
if (insertText && !seen.has(insertText) && pred(name)) {
|
|
26107
|
+
results.push(insertText);
|
|
26108
|
+
seen.add(insertText);
|
|
26109
|
+
}
|
|
26110
|
+
}
|
|
26111
|
+
return results;
|
|
26112
|
+
}
|
|
26085
26113
|
generateWithPredicate(params, shouldInclude) {
|
|
26086
26114
|
const suggestions = /* @__PURE__ */ new Set();
|
|
26087
26115
|
dvalaCommands.forEach((suggestion) => {
|
|
26088
26116
|
if (shouldInclude(suggestion)) suggestions.add(suggestion);
|
|
26089
26117
|
});
|
|
26090
26118
|
Object.keys(params.bindings ?? {}).filter(shouldInclude).forEach((suggestion) => suggestions.add(suggestion));
|
|
26119
|
+
params.effectNames?.forEach((name) => {
|
|
26120
|
+
if (shouldInclude(name)) suggestions.add(name);
|
|
26121
|
+
});
|
|
26091
26122
|
return [...suggestions].sort((a, b) => a.localeCompare(b));
|
|
26092
26123
|
}
|
|
26093
26124
|
};
|
|
@@ -31819,9 +31850,9 @@ function evaluate(ast, contextStack) {
|
|
|
31819
31850
|
* is passed to every host handler. Used for `race()` cancellation (Phase 6)
|
|
31820
31851
|
* and host-side timeouts.
|
|
31821
31852
|
*/
|
|
31822
|
-
async function evaluateWithEffects(ast, contextStack, handlers, maxSnapshots, deserializeOptions, autoCheckpoint) {
|
|
31853
|
+
async function evaluateWithEffects(ast, contextStack, handlers, maxSnapshots, deserializeOptions, autoCheckpoint, terminalSnapshot) {
|
|
31823
31854
|
const signal = new AbortController().signal;
|
|
31824
|
-
return runEffectLoop(buildInitialStep(ast.body, contextStack), handlers, signal, void 0, maxSnapshots, deserializeOptions, autoCheckpoint);
|
|
31855
|
+
return runEffectLoop(buildInitialStep(ast.body, contextStack), handlers, signal, void 0, maxSnapshots, deserializeOptions, autoCheckpoint, terminalSnapshot);
|
|
31825
31856
|
}
|
|
31826
31857
|
/**
|
|
31827
31858
|
* Evaluate an AST synchronously with effect handler support.
|
|
@@ -31851,18 +31882,19 @@ function evaluateWithSyncEffects(ast, contextStack, effectHandlers) {
|
|
|
31851
31882
|
* to fire a `perform(dvala.debug.step, stepInfo)` after evaluation,
|
|
31852
31883
|
* enabling the time-travel debugger.
|
|
31853
31884
|
*/
|
|
31854
|
-
async function runEffectLoop(initial, handlers, signal, initialSnapshotState, maxSnapshots, deserializeOptions, autoCheckpoint) {
|
|
31885
|
+
async function runEffectLoop(initial, handlers, signal, initialSnapshotState, maxSnapshots, deserializeOptions, autoCheckpoint, terminalSnapshot) {
|
|
31855
31886
|
const debugMode = Array.isArray(handlers) && handlers.some((h) => h.pattern === "dvala.debug.step");
|
|
31856
31887
|
const snapshotState = {
|
|
31857
31888
|
snapshots: initialSnapshotState ? initialSnapshotState.snapshots : [],
|
|
31858
31889
|
nextSnapshotIndex: initialSnapshotState ? initialSnapshotState.nextSnapshotIndex : 0,
|
|
31859
31890
|
executionId: generateUUID(),
|
|
31860
31891
|
...maxSnapshots !== void 0 ? { maxSnapshots } : {},
|
|
31861
|
-
...autoCheckpoint ? { autoCheckpoint } : {}
|
|
31892
|
+
...autoCheckpoint ? { autoCheckpoint } : {},
|
|
31893
|
+
...terminalSnapshot ? { terminalSnapshot } : {}
|
|
31862
31894
|
};
|
|
31863
31895
|
let step = initial;
|
|
31864
31896
|
function createTerminalSnapshot(options) {
|
|
31865
|
-
if (!snapshotState.autoCheckpoint) return;
|
|
31897
|
+
if (!snapshotState.autoCheckpoint && !snapshotState.terminalSnapshot) return;
|
|
31866
31898
|
const continuation = serializeTerminalSnapshot(snapshotState.snapshots, snapshotState.nextSnapshotIndex);
|
|
31867
31899
|
const meta = {};
|
|
31868
31900
|
if (options?.error) meta.error = options.error.toJSON();
|
|
@@ -32194,10 +32226,11 @@ function createDvala(options) {
|
|
|
32194
32226
|
}
|
|
32195
32227
|
const ast = buildAst(isDvalaBundle(source) ? source.program : source);
|
|
32196
32228
|
const disableAutoCheckpoint = runOptions?.disableAutoCheckpoint ?? factoryDisableTimeTravel;
|
|
32229
|
+
const terminalSnapshot = runOptions?.terminalSnapshot;
|
|
32197
32230
|
const result = await evaluateWithEffects(ast, contextStack, effectHandlers, runOptions?.maxSnapshots, {
|
|
32198
32231
|
values: bindings,
|
|
32199
32232
|
modules
|
|
32200
|
-
}, !disableAutoCheckpoint);
|
|
32233
|
+
}, !disableAutoCheckpoint, terminalSnapshot);
|
|
32201
32234
|
if (result.type === "completed") return {
|
|
32202
32235
|
...result,
|
|
32203
32236
|
definedBindings: contextStack.getModuleScopeBindings()
|
package/package.json
CHANGED