@mojir/lits 2.1.19 → 2.1.20
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 +48 -39
- package/dist/cli/src/AutoCompleter/AutoCompleter.d.ts +13 -7
- package/dist/cli/src/Lits/Lits.d.ts +1 -1
- package/dist/index.esm.js +47 -38
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +47 -38
- package/dist/index.js.map +1 -1
- package/dist/lits.iife.js +47 -38
- package/dist/lits.iife.js.map +1 -1
- package/dist/src/AutoCompleter/AutoCompleter.d.ts +13 -7
- package/dist/src/Lits/Lits.d.ts +1 -1
- package/dist/testFramework.esm.js +47 -38
- package/dist/testFramework.esm.js.map +1 -1
- package/dist/testFramework.js +47 -38
- package/dist/testFramework.js.map +1 -1
- package/package.json +1 -1
package/dist/cli/cli.js
CHANGED
|
@@ -92,7 +92,7 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
|
|
|
92
92
|
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
93
93
|
};
|
|
94
94
|
|
|
95
|
-
var version = "2.1.
|
|
95
|
+
var version = "2.1.20";
|
|
96
96
|
|
|
97
97
|
function getCodeMarker(sourceCodeInfo) {
|
|
98
98
|
if (!sourceCodeInfo.position || !sourceCodeInfo.code)
|
|
@@ -14822,18 +14822,25 @@ var Parser = /** @class */ (function () {
|
|
|
14822
14822
|
return Parser;
|
|
14823
14823
|
}());
|
|
14824
14824
|
|
|
14825
|
-
var autoCompleteTokenTypes = [
|
|
14826
|
-
'Operator',
|
|
14827
|
-
'ReservedSymbol',
|
|
14828
|
-
'Symbol',
|
|
14829
|
-
];
|
|
14830
14825
|
var litsCommands = new Set(__spreadArray(__spreadArray([], __read(normalExpressionKeys), false), __read(specialExpressionKeys), false));
|
|
14831
14826
|
// TODO: replace with get suggestions function
|
|
14832
14827
|
var AutoCompleter = /** @class */ (function () {
|
|
14833
|
-
function AutoCompleter(
|
|
14834
|
-
this.
|
|
14828
|
+
function AutoCompleter(originalProgram, originalPosition, lits, params) {
|
|
14829
|
+
this.originalProgram = originalProgram;
|
|
14830
|
+
this.originalPosition = originalPosition;
|
|
14831
|
+
this.prefixProgram = '';
|
|
14832
|
+
this.suffixProgram = '';
|
|
14833
|
+
this.searchString = '';
|
|
14835
14834
|
this.suggestions = [];
|
|
14836
14835
|
this.suggestionIndex = null;
|
|
14836
|
+
var partialProgram = this.originalProgram.slice(0, this.originalPosition);
|
|
14837
|
+
var tokenStream = null;
|
|
14838
|
+
try {
|
|
14839
|
+
tokenStream = lits.tokenize(partialProgram);
|
|
14840
|
+
}
|
|
14841
|
+
catch (_a) {
|
|
14842
|
+
// do nothing
|
|
14843
|
+
}
|
|
14837
14844
|
if (!tokenStream) {
|
|
14838
14845
|
return;
|
|
14839
14846
|
}
|
|
@@ -14841,14 +14848,28 @@ var AutoCompleter = /** @class */ (function () {
|
|
|
14841
14848
|
if (!lastToken) {
|
|
14842
14849
|
return;
|
|
14843
14850
|
}
|
|
14844
|
-
|
|
14845
|
-
|
|
14846
|
-
|
|
14847
|
-
|
|
14848
|
-
this.
|
|
14849
|
-
this.generateSuggestions(params);
|
|
14851
|
+
this.searchString = lastToken[1];
|
|
14852
|
+
this.prefixProgram = this.originalProgram.slice(0, this.originalPosition - this.searchString.length);
|
|
14853
|
+
this.suffixProgram = this.originalProgram.slice(this.prefixProgram.length + this.searchString.length);
|
|
14854
|
+
this.originalProgram.slice(this.prefixProgram.length + this.searchString.length);
|
|
14855
|
+
this.suggestions = this.generateSuggestions(params);
|
|
14850
14856
|
}
|
|
14851
14857
|
AutoCompleter.prototype.getNextSuggestion = function () {
|
|
14858
|
+
return this.getAutoCompleteSuggestionResult(this.getNextSuggestionSymbol());
|
|
14859
|
+
};
|
|
14860
|
+
AutoCompleter.prototype.getPreviousSuggestion = function () {
|
|
14861
|
+
return this.getAutoCompleteSuggestionResult(this.getPreviousSuggestionSymbol());
|
|
14862
|
+
};
|
|
14863
|
+
AutoCompleter.prototype.getAutoCompleteSuggestionResult = function (suggestion) {
|
|
14864
|
+
if (suggestion === null) {
|
|
14865
|
+
return null;
|
|
14866
|
+
}
|
|
14867
|
+
return {
|
|
14868
|
+
program: this.prefixProgram + suggestion + this.suffixProgram,
|
|
14869
|
+
position: this.prefixProgram.length + suggestion.length,
|
|
14870
|
+
};
|
|
14871
|
+
};
|
|
14872
|
+
AutoCompleter.prototype.getNextSuggestionSymbol = function () {
|
|
14852
14873
|
if (this.suggestions.length === 0) {
|
|
14853
14874
|
return null;
|
|
14854
14875
|
}
|
|
@@ -14861,12 +14882,9 @@ var AutoCompleter = /** @class */ (function () {
|
|
|
14861
14882
|
this.suggestionIndex = 0;
|
|
14862
14883
|
}
|
|
14863
14884
|
}
|
|
14864
|
-
return
|
|
14865
|
-
suggestion: this.suggestions[this.suggestionIndex],
|
|
14866
|
-
searchPattern: this.searchPrefix,
|
|
14867
|
-
};
|
|
14885
|
+
return this.suggestions[this.suggestionIndex];
|
|
14868
14886
|
};
|
|
14869
|
-
AutoCompleter.prototype.
|
|
14887
|
+
AutoCompleter.prototype.getPreviousSuggestionSymbol = function () {
|
|
14870
14888
|
if (this.suggestions.length === 0) {
|
|
14871
14889
|
return null;
|
|
14872
14890
|
}
|
|
@@ -14879,41 +14897,38 @@ var AutoCompleter = /** @class */ (function () {
|
|
|
14879
14897
|
this.suggestionIndex = this.suggestions.length - 1;
|
|
14880
14898
|
}
|
|
14881
14899
|
}
|
|
14882
|
-
return
|
|
14883
|
-
suggestion: this.suggestions[this.suggestionIndex],
|
|
14884
|
-
searchPattern: this.searchPrefix,
|
|
14885
|
-
};
|
|
14900
|
+
return this.suggestions[this.suggestionIndex];
|
|
14886
14901
|
};
|
|
14887
14902
|
AutoCompleter.prototype.getSuggestions = function () {
|
|
14888
14903
|
return __spreadArray([], __read(this.suggestions), false);
|
|
14889
14904
|
};
|
|
14890
|
-
AutoCompleter.prototype.
|
|
14891
|
-
return this.
|
|
14905
|
+
AutoCompleter.prototype.getSearchString = function () {
|
|
14906
|
+
return this.searchString;
|
|
14892
14907
|
};
|
|
14893
14908
|
AutoCompleter.prototype.generateSuggestions = function (params) {
|
|
14894
14909
|
var _this = this;
|
|
14895
14910
|
var _a, _b, _c, _d;
|
|
14896
14911
|
var suggestions = new Set();
|
|
14897
14912
|
litsCommands.forEach(function (name) {
|
|
14898
|
-
if (name.startsWith(_this.
|
|
14913
|
+
if (name.startsWith(_this.searchString)) {
|
|
14899
14914
|
suggestions.add(name);
|
|
14900
14915
|
}
|
|
14901
14916
|
});
|
|
14902
14917
|
Object.keys((_a = params.globalContext) !== null && _a !== void 0 ? _a : {})
|
|
14903
|
-
.filter(function (name) { return name.startsWith(_this.
|
|
14918
|
+
.filter(function (name) { return name.startsWith(_this.searchString); })
|
|
14904
14919
|
.forEach(function (name) { return suggestions.add(name); });
|
|
14905
14920
|
(_b = params.contexts) === null || _b === void 0 ? void 0 : _b.forEach(function (context) {
|
|
14906
14921
|
Object.keys(context)
|
|
14907
|
-
.filter(function (name) { return name.startsWith(_this.
|
|
14922
|
+
.filter(function (name) { return name.startsWith(_this.searchString); })
|
|
14908
14923
|
.forEach(function (name) { return suggestions.add(name); });
|
|
14909
14924
|
});
|
|
14910
14925
|
Object.keys((_c = params.jsFunctions) !== null && _c !== void 0 ? _c : {})
|
|
14911
|
-
.filter(function (name) { return name.startsWith(_this.
|
|
14926
|
+
.filter(function (name) { return name.startsWith(_this.searchString); })
|
|
14912
14927
|
.forEach(function (name) { return suggestions.add(name); });
|
|
14913
14928
|
Object.keys((_d = params.values) !== null && _d !== void 0 ? _d : {})
|
|
14914
|
-
.filter(function (name) { return name.startsWith(_this.
|
|
14929
|
+
.filter(function (name) { return name.startsWith(_this.searchString); })
|
|
14915
14930
|
.forEach(function (name) { return suggestions.add(name); });
|
|
14916
|
-
|
|
14931
|
+
return __spreadArray([], __read(suggestions), false).sort(function (a, b) { return a.localeCompare(b); });
|
|
14917
14932
|
};
|
|
14918
14933
|
return AutoCompleter;
|
|
14919
14934
|
}());
|
|
@@ -15093,15 +15108,9 @@ var Lits = /** @class */ (function () {
|
|
|
15093
15108
|
(_a = this.astCache) === null || _a === void 0 ? void 0 : _a.set(program, ast);
|
|
15094
15109
|
return ast;
|
|
15095
15110
|
};
|
|
15096
|
-
Lits.prototype.getAutoCompleter = function (
|
|
15111
|
+
Lits.prototype.getAutoCompleter = function (program, position, params) {
|
|
15097
15112
|
if (params === void 0) { params = {}; }
|
|
15098
|
-
|
|
15099
|
-
var tokenStream = this.tokenize(partialProgram);
|
|
15100
|
-
return new AutoCompleter(tokenStream, params);
|
|
15101
|
-
}
|
|
15102
|
-
catch (_a) {
|
|
15103
|
-
return new AutoCompleter(null, params);
|
|
15104
|
-
}
|
|
15113
|
+
return new AutoCompleter(program, position, this, params);
|
|
15105
15114
|
};
|
|
15106
15115
|
return Lits;
|
|
15107
15116
|
}());
|
|
@@ -1,17 +1,23 @@
|
|
|
1
|
-
import type { ContextParams } from '../Lits/Lits';
|
|
2
|
-
import type { TokenStream } from '../tokenizer/tokenize';
|
|
1
|
+
import type { ContextParams, Lits } from '../Lits/Lits';
|
|
3
2
|
export type AutoCompleteSuggestion = {
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
program: string;
|
|
4
|
+
position: number;
|
|
6
5
|
};
|
|
7
6
|
export declare class AutoCompleter {
|
|
8
|
-
|
|
7
|
+
readonly originalProgram: string;
|
|
8
|
+
readonly originalPosition: number;
|
|
9
|
+
private prefixProgram;
|
|
10
|
+
private suffixProgram;
|
|
11
|
+
private searchString;
|
|
9
12
|
private suggestions;
|
|
10
13
|
private suggestionIndex;
|
|
11
|
-
constructor(
|
|
14
|
+
constructor(originalProgram: string, originalPosition: number, lits: Lits, params: ContextParams);
|
|
12
15
|
getNextSuggestion(): AutoCompleteSuggestion | null;
|
|
13
16
|
getPreviousSuggestion(): AutoCompleteSuggestion | null;
|
|
17
|
+
private getAutoCompleteSuggestionResult;
|
|
18
|
+
private getNextSuggestionSymbol;
|
|
19
|
+
private getPreviousSuggestionSymbol;
|
|
14
20
|
getSuggestions(): string[];
|
|
15
|
-
|
|
21
|
+
getSearchString(): string;
|
|
16
22
|
private generateSuggestions;
|
|
17
23
|
}
|
|
@@ -47,6 +47,6 @@ export declare class Lits {
|
|
|
47
47
|
apply(fn: LitsFunction, fnParams: unknown[], params?: ContextParams): Any;
|
|
48
48
|
private generateApplyFunctionCall;
|
|
49
49
|
private generateAst;
|
|
50
|
-
getAutoCompleter(
|
|
50
|
+
getAutoCompleter(program: string, position: number, params?: ContextParams): AutoCompleter;
|
|
51
51
|
}
|
|
52
52
|
export {};
|
package/dist/index.esm.js
CHANGED
|
@@ -14859,18 +14859,25 @@ var Parser = /** @class */ (function () {
|
|
|
14859
14859
|
return Parser;
|
|
14860
14860
|
}());
|
|
14861
14861
|
|
|
14862
|
-
var autoCompleteTokenTypes = [
|
|
14863
|
-
'Operator',
|
|
14864
|
-
'ReservedSymbol',
|
|
14865
|
-
'Symbol',
|
|
14866
|
-
];
|
|
14867
14862
|
var litsCommands = new Set(__spreadArray(__spreadArray([], __read(normalExpressionKeys), false), __read(specialExpressionKeys), false));
|
|
14868
14863
|
// TODO: replace with get suggestions function
|
|
14869
14864
|
var AutoCompleter = /** @class */ (function () {
|
|
14870
|
-
function AutoCompleter(
|
|
14871
|
-
this.
|
|
14865
|
+
function AutoCompleter(originalProgram, originalPosition, lits, params) {
|
|
14866
|
+
this.originalProgram = originalProgram;
|
|
14867
|
+
this.originalPosition = originalPosition;
|
|
14868
|
+
this.prefixProgram = '';
|
|
14869
|
+
this.suffixProgram = '';
|
|
14870
|
+
this.searchString = '';
|
|
14872
14871
|
this.suggestions = [];
|
|
14873
14872
|
this.suggestionIndex = null;
|
|
14873
|
+
var partialProgram = this.originalProgram.slice(0, this.originalPosition);
|
|
14874
|
+
var tokenStream = null;
|
|
14875
|
+
try {
|
|
14876
|
+
tokenStream = lits.tokenize(partialProgram);
|
|
14877
|
+
}
|
|
14878
|
+
catch (_a) {
|
|
14879
|
+
// do nothing
|
|
14880
|
+
}
|
|
14874
14881
|
if (!tokenStream) {
|
|
14875
14882
|
return;
|
|
14876
14883
|
}
|
|
@@ -14878,14 +14885,28 @@ var AutoCompleter = /** @class */ (function () {
|
|
|
14878
14885
|
if (!lastToken) {
|
|
14879
14886
|
return;
|
|
14880
14887
|
}
|
|
14881
|
-
|
|
14882
|
-
|
|
14883
|
-
|
|
14884
|
-
|
|
14885
|
-
this.
|
|
14886
|
-
this.generateSuggestions(params);
|
|
14888
|
+
this.searchString = lastToken[1];
|
|
14889
|
+
this.prefixProgram = this.originalProgram.slice(0, this.originalPosition - this.searchString.length);
|
|
14890
|
+
this.suffixProgram = this.originalProgram.slice(this.prefixProgram.length + this.searchString.length);
|
|
14891
|
+
this.originalProgram.slice(this.prefixProgram.length + this.searchString.length);
|
|
14892
|
+
this.suggestions = this.generateSuggestions(params);
|
|
14887
14893
|
}
|
|
14888
14894
|
AutoCompleter.prototype.getNextSuggestion = function () {
|
|
14895
|
+
return this.getAutoCompleteSuggestionResult(this.getNextSuggestionSymbol());
|
|
14896
|
+
};
|
|
14897
|
+
AutoCompleter.prototype.getPreviousSuggestion = function () {
|
|
14898
|
+
return this.getAutoCompleteSuggestionResult(this.getPreviousSuggestionSymbol());
|
|
14899
|
+
};
|
|
14900
|
+
AutoCompleter.prototype.getAutoCompleteSuggestionResult = function (suggestion) {
|
|
14901
|
+
if (suggestion === null) {
|
|
14902
|
+
return null;
|
|
14903
|
+
}
|
|
14904
|
+
return {
|
|
14905
|
+
program: this.prefixProgram + suggestion + this.suffixProgram,
|
|
14906
|
+
position: this.prefixProgram.length + suggestion.length,
|
|
14907
|
+
};
|
|
14908
|
+
};
|
|
14909
|
+
AutoCompleter.prototype.getNextSuggestionSymbol = function () {
|
|
14889
14910
|
if (this.suggestions.length === 0) {
|
|
14890
14911
|
return null;
|
|
14891
14912
|
}
|
|
@@ -14898,12 +14919,9 @@ var AutoCompleter = /** @class */ (function () {
|
|
|
14898
14919
|
this.suggestionIndex = 0;
|
|
14899
14920
|
}
|
|
14900
14921
|
}
|
|
14901
|
-
return
|
|
14902
|
-
suggestion: this.suggestions[this.suggestionIndex],
|
|
14903
|
-
searchPattern: this.searchPrefix,
|
|
14904
|
-
};
|
|
14922
|
+
return this.suggestions[this.suggestionIndex];
|
|
14905
14923
|
};
|
|
14906
|
-
AutoCompleter.prototype.
|
|
14924
|
+
AutoCompleter.prototype.getPreviousSuggestionSymbol = function () {
|
|
14907
14925
|
if (this.suggestions.length === 0) {
|
|
14908
14926
|
return null;
|
|
14909
14927
|
}
|
|
@@ -14916,41 +14934,38 @@ var AutoCompleter = /** @class */ (function () {
|
|
|
14916
14934
|
this.suggestionIndex = this.suggestions.length - 1;
|
|
14917
14935
|
}
|
|
14918
14936
|
}
|
|
14919
|
-
return
|
|
14920
|
-
suggestion: this.suggestions[this.suggestionIndex],
|
|
14921
|
-
searchPattern: this.searchPrefix,
|
|
14922
|
-
};
|
|
14937
|
+
return this.suggestions[this.suggestionIndex];
|
|
14923
14938
|
};
|
|
14924
14939
|
AutoCompleter.prototype.getSuggestions = function () {
|
|
14925
14940
|
return __spreadArray([], __read(this.suggestions), false);
|
|
14926
14941
|
};
|
|
14927
|
-
AutoCompleter.prototype.
|
|
14928
|
-
return this.
|
|
14942
|
+
AutoCompleter.prototype.getSearchString = function () {
|
|
14943
|
+
return this.searchString;
|
|
14929
14944
|
};
|
|
14930
14945
|
AutoCompleter.prototype.generateSuggestions = function (params) {
|
|
14931
14946
|
var _this = this;
|
|
14932
14947
|
var _a, _b, _c, _d;
|
|
14933
14948
|
var suggestions = new Set();
|
|
14934
14949
|
litsCommands.forEach(function (name) {
|
|
14935
|
-
if (name.startsWith(_this.
|
|
14950
|
+
if (name.startsWith(_this.searchString)) {
|
|
14936
14951
|
suggestions.add(name);
|
|
14937
14952
|
}
|
|
14938
14953
|
});
|
|
14939
14954
|
Object.keys((_a = params.globalContext) !== null && _a !== void 0 ? _a : {})
|
|
14940
|
-
.filter(function (name) { return name.startsWith(_this.
|
|
14955
|
+
.filter(function (name) { return name.startsWith(_this.searchString); })
|
|
14941
14956
|
.forEach(function (name) { return suggestions.add(name); });
|
|
14942
14957
|
(_b = params.contexts) === null || _b === void 0 ? void 0 : _b.forEach(function (context) {
|
|
14943
14958
|
Object.keys(context)
|
|
14944
|
-
.filter(function (name) { return name.startsWith(_this.
|
|
14959
|
+
.filter(function (name) { return name.startsWith(_this.searchString); })
|
|
14945
14960
|
.forEach(function (name) { return suggestions.add(name); });
|
|
14946
14961
|
});
|
|
14947
14962
|
Object.keys((_c = params.jsFunctions) !== null && _c !== void 0 ? _c : {})
|
|
14948
|
-
.filter(function (name) { return name.startsWith(_this.
|
|
14963
|
+
.filter(function (name) { return name.startsWith(_this.searchString); })
|
|
14949
14964
|
.forEach(function (name) { return suggestions.add(name); });
|
|
14950
14965
|
Object.keys((_d = params.values) !== null && _d !== void 0 ? _d : {})
|
|
14951
|
-
.filter(function (name) { return name.startsWith(_this.
|
|
14966
|
+
.filter(function (name) { return name.startsWith(_this.searchString); })
|
|
14952
14967
|
.forEach(function (name) { return suggestions.add(name); });
|
|
14953
|
-
|
|
14968
|
+
return __spreadArray([], __read(suggestions), false).sort(function (a, b) { return a.localeCompare(b); });
|
|
14954
14969
|
};
|
|
14955
14970
|
return AutoCompleter;
|
|
14956
14971
|
}());
|
|
@@ -15130,15 +15145,9 @@ var Lits = /** @class */ (function () {
|
|
|
15130
15145
|
(_a = this.astCache) === null || _a === void 0 ? void 0 : _a.set(program, ast);
|
|
15131
15146
|
return ast;
|
|
15132
15147
|
};
|
|
15133
|
-
Lits.prototype.getAutoCompleter = function (
|
|
15148
|
+
Lits.prototype.getAutoCompleter = function (program, position, params) {
|
|
15134
15149
|
if (params === void 0) { params = {}; }
|
|
15135
|
-
|
|
15136
|
-
var tokenStream = this.tokenize(partialProgram);
|
|
15137
|
-
return new AutoCompleter(tokenStream, params);
|
|
15138
|
-
}
|
|
15139
|
-
catch (_a) {
|
|
15140
|
-
return new AutoCompleter(null, params);
|
|
15141
|
-
}
|
|
15150
|
+
return new AutoCompleter(program, position, this, params);
|
|
15142
15151
|
};
|
|
15143
15152
|
return Lits;
|
|
15144
15153
|
}());
|