@replit/clui-input
Advanced tools
Comparing version 0.0.16 to 0.0.17
@@ -100,3 +100,3 @@ "use strict"; | ||
var processUpdates = function () { return __awaiter(void 0, void 0, void 0, function () { | ||
var valueStart, current, ast, atWhitespace, previousNode, search, result, search, result, currentNode, astCommands, last, args, parsedArgKeys, options, nodeStart, commonParams, getOptions, rootCommands, search, ref, argOptions, previousNode, search, optionsFn, token, prefix_1, suffix, searchValue_1, results, optionsFn, token, prefix_2, suffix, searchValue_2, results, ref, argOptions, ref, argOptions, run, commandsList, refRun_1; | ||
var valueStart, current, ast, atWhitespace, previousNode, search, result, search, result, currentNode, astCommands, last, args, parsedArgKeys, options, nodeStart, commonParams, getOptions, optionsFn, results, rootCommands, search, ref, argOptions, previousNode_1, search, optionsFn, token, prefix_1, suffix, searchValue_1, results, optionsFn, token, prefix_2, suffix, searchValue_2, results, ref, argOptions, ref, argOptions, run, commandsList, refRun_1; | ||
var _a, _b, _c, _d, _e, _f, _g; | ||
@@ -167,7 +167,26 @@ return __generator(this, function (_h) { | ||
}); | ||
if (!!value) return [3, 8]; | ||
if (!!value) return [3, 10]; | ||
if (!(typeof config.command.options === 'function')) return [3, 7]; | ||
optionsFn = config.command.options; | ||
return [4, optionsFn()]; | ||
case 6: | ||
results = _h.sent(); | ||
if (current !== updatedAt) { | ||
return [2]; | ||
} | ||
options.push.apply(options, __spread(results.map(function (result) { | ||
var inputValue = result.value; | ||
return { | ||
value: result.value, | ||
inputValue: inputValue, | ||
cursorTarget: inputValue.length, | ||
data: result, | ||
}; | ||
}))); | ||
_h.label = 7; | ||
case 7: | ||
rootCommands = commandsCache[''] || null; | ||
if (!!rootCommands) return [3, 7]; | ||
if (!!rootCommands) return [3, 9]; | ||
return [4, getRootCommands(ast, config.command)]; | ||
case 6: | ||
case 8: | ||
rootCommands = _h.sent(); | ||
@@ -177,4 +196,4 @@ if (rootCommands) { | ||
} | ||
_h.label = 7; | ||
case 7: | ||
_h.label = 9; | ||
case 9: | ||
if (current !== updatedAt) { | ||
@@ -190,11 +209,11 @@ return [2]; | ||
} | ||
return [3, 20]; | ||
case 8: | ||
if (!currentNode) return [3, 11]; | ||
if (!(currentNode.kind === 'ARG_VALUE')) return [3, 10]; | ||
return [3, 22]; | ||
case 10: | ||
if (!currentNode) return [3, 13]; | ||
if (!(currentNode.kind === 'ARG_VALUE')) return [3, 12]; | ||
search = value.slice(nodeStart, index); | ||
ref = currentNode.parent.ref; | ||
if (!(typeof ref.options === 'function' && !optionsCache[valueStart])) return [3, 10]; | ||
if (!(typeof ref.options === 'function' && !optionsCache[valueStart])) return [3, 12]; | ||
return [4, ref.options(search || undefined)]; | ||
case 9: | ||
case 11: | ||
argOptions = _h.sent(); | ||
@@ -207,10 +226,10 @@ if (argOptions) { | ||
} | ||
_h.label = 10; | ||
case 10: | ||
_h.label = 12; | ||
case 12: | ||
options.push.apply(options, __spread(getOptions(__assign({ currentNode: currentNode }, commonParams)))); | ||
return [3, 20]; | ||
case 11: | ||
previousNode = ast_1.closestPrevious(ast, index); | ||
if (!atWhitespace && previousNode && 'token' in previousNode) { | ||
nodeStart = previousNode.token.start; | ||
return [3, 22]; | ||
case 13: | ||
previousNode_1 = ast_1.closestPrevious(ast, index); | ||
if (!atWhitespace && previousNode_1 && 'token' in previousNode_1) { | ||
nodeStart = previousNode_1.token.start; | ||
} | ||
@@ -223,7 +242,7 @@ else { | ||
: undefined; | ||
if (!previousNode) return [3, 20]; | ||
if (!(previousNode.kind === 'COMMAND' && | ||
typeof ((_d = previousNode) === null || _d === void 0 ? void 0 : _d.ref.options) === 'function')) return [3, 13]; | ||
optionsFn = previousNode.ref.options; | ||
token = previousNode.token; | ||
if (!previousNode_1) return [3, 22]; | ||
if (!(previousNode_1.kind === 'COMMAND' && | ||
typeof ((_d = previousNode_1) === null || _d === void 0 ? void 0 : _d.ref.options) === 'function')) return [3, 15]; | ||
optionsFn = previousNode_1.ref.options; | ||
token = previousNode_1.token; | ||
prefix_1 = ast.source.slice(0, token.end); | ||
@@ -233,3 +252,3 @@ suffix = ast.source.slice(token.end); | ||
return [4, optionsFn(searchValue_1)]; | ||
case 12: | ||
case 14: | ||
results = _h.sent(); | ||
@@ -249,8 +268,8 @@ if (current !== updatedAt) { | ||
}))); | ||
_h.label = 13; | ||
case 13: | ||
if (!('cmdNodeCtx' in previousNode && | ||
typeof ((_e = previousNode.cmdNodeCtx) === null || _e === void 0 ? void 0 : _e.ref.options) === 'function')) return [3, 15]; | ||
optionsFn = previousNode.cmdNodeCtx.ref.options; | ||
token = previousNode.cmdNodeCtx.token; | ||
_h.label = 15; | ||
case 15: | ||
if (!('cmdNodeCtx' in previousNode_1 && | ||
typeof ((_e = previousNode_1.cmdNodeCtx) === null || _e === void 0 ? void 0 : _e.ref.options) === 'function')) return [3, 17]; | ||
optionsFn = previousNode_1.cmdNodeCtx.ref.options; | ||
token = previousNode_1.cmdNodeCtx.token; | ||
prefix_2 = ast.source.slice(0, token.end); | ||
@@ -260,3 +279,3 @@ suffix = ast.source.slice(token.end); | ||
return [4, optionsFn(searchValue_2)]; | ||
case 14: | ||
case 16: | ||
results = _h.sent(); | ||
@@ -267,3 +286,5 @@ if (current !== updatedAt) { | ||
options.push.apply(options, __spread(results.map(function (result) { | ||
var inputValue = prefix_2 + " " + result.value; | ||
var inputValue = previousNode_1.token.start === 0 | ||
? result.value | ||
: prefix_2 + " " + result.value; | ||
return { | ||
@@ -277,9 +298,9 @@ value: result.value, | ||
}))); | ||
_h.label = 15; | ||
case 15: | ||
if (!(previousNode.kind === 'ARG_VALUE')) return [3, 17]; | ||
ref = previousNode.parent.ref; | ||
if (!(typeof ref.options === 'function' && !optionsCache[valueStart])) return [3, 17]; | ||
_h.label = 17; | ||
case 17: | ||
if (!(previousNode_1.kind === 'ARG_VALUE')) return [3, 19]; | ||
ref = previousNode_1.parent.ref; | ||
if (!(typeof ref.options === 'function' && !optionsCache[valueStart])) return [3, 19]; | ||
return [4, ref.options(search || undefined)]; | ||
case 16: | ||
case 18: | ||
argOptions = _h.sent(); | ||
@@ -292,9 +313,9 @@ if (current !== updatedAt) { | ||
} | ||
_h.label = 17; | ||
case 17: | ||
if (!(previousNode.kind === 'ARG_KEY')) return [3, 19]; | ||
ref = previousNode.parent.ref; | ||
if (!(typeof ref.options === 'function' && !optionsCache[valueStart])) return [3, 19]; | ||
_h.label = 19; | ||
case 19: | ||
if (!(previousNode_1.kind === 'ARG_KEY')) return [3, 21]; | ||
ref = previousNode_1.parent.ref; | ||
if (!(typeof ref.options === 'function' && !optionsCache[valueStart])) return [3, 21]; | ||
return [4, ref.options(search || undefined)]; | ||
case 18: | ||
case 20: | ||
argOptions = _h.sent(); | ||
@@ -307,7 +328,7 @@ if (current !== updatedAt) { | ||
} | ||
_h.label = 19; | ||
case 19: | ||
options.push.apply(options, __spread(getOptions(__assign({ previousNode: previousNode }, commonParams)))); | ||
_h.label = 20; | ||
case 20: | ||
_h.label = 21; | ||
case 21: | ||
options.push.apply(options, __spread(getOptions(__assign({ previousNode: previousNode_1 }, commonParams)))); | ||
_h.label = 22; | ||
case 22: | ||
commandsList = astCommands.map(function (c) { | ||
@@ -314,0 +335,0 @@ var cargs = ast_1.toArgs(c); |
{ | ||
"name": "@replit/clui-input", | ||
"version": "0.0.16", | ||
"version": "0.0.17", | ||
"description": "A utility library for building CLI style interfaces with autocomplete", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
97215
1533