@mojir/lits 2.1.37 → 2.1.38
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 +28 -5
- package/dist/cli/src/tokenizer/token.d.ts +4 -6
- package/dist/cli/src/tokenizer/tokenizers.d.ts +1 -0
- package/dist/index.esm.js +27 -4
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +27 -4
- package/dist/index.js.map +1 -1
- package/dist/lits.iife.js +27 -4
- package/dist/lits.iife.js.map +1 -1
- package/dist/src/tokenizer/token.d.ts +4 -6
- package/dist/src/tokenizer/tokenizers.d.ts +1 -0
- package/dist/testFramework.esm.js +27 -4
- package/dist/testFramework.esm.js.map +1 -1
- package/dist/testFramework.js +27 -4
- package/dist/testFramework.js.map +1 -1
- package/package.json +1 -1
package/dist/cli/cli.js
CHANGED
|
@@ -93,7 +93,7 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
|
|
|
93
93
|
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
94
94
|
};
|
|
95
95
|
|
|
96
|
-
var version = "2.1.
|
|
96
|
+
var version = "2.1.38";
|
|
97
97
|
|
|
98
98
|
function getCodeMarker(sourceCodeInfo) {
|
|
99
99
|
if (!sourceCodeInfo.position || !sourceCodeInfo.code)
|
|
@@ -13537,10 +13537,10 @@ var tokenizeMultiLineComment = function (input, position) {
|
|
|
13537
13537
|
}
|
|
13538
13538
|
return NO_MATCH;
|
|
13539
13539
|
};
|
|
13540
|
-
var
|
|
13541
|
-
if (input[position] === '
|
|
13540
|
+
var tokenizeShebang = function (input, position) {
|
|
13541
|
+
if (input[position] === '#' && input[position + 1] === '!') {
|
|
13542
13542
|
var length_3 = 2;
|
|
13543
|
-
var value = '
|
|
13543
|
+
var value = '#!';
|
|
13544
13544
|
while (input[position + length_3] !== '\n' && position + length_3 < input.length) {
|
|
13545
13545
|
value += input[position + length_3];
|
|
13546
13546
|
length_3 += 1;
|
|
@@ -13549,6 +13549,18 @@ var tokenizeSingleLineComment = function (input, position) {
|
|
|
13549
13549
|
}
|
|
13550
13550
|
return NO_MATCH;
|
|
13551
13551
|
};
|
|
13552
|
+
var tokenizeSingleLineComment = function (input, position) {
|
|
13553
|
+
if (input[position] === '/' && input[position + 1] === '/') {
|
|
13554
|
+
var length_4 = 2;
|
|
13555
|
+
var value = '//';
|
|
13556
|
+
while (input[position + length_4] !== '\n' && position + length_4 < input.length) {
|
|
13557
|
+
value += input[position + length_4];
|
|
13558
|
+
length_4 += 1;
|
|
13559
|
+
}
|
|
13560
|
+
return [length_4, ['SingleLineComment', value]];
|
|
13561
|
+
}
|
|
13562
|
+
return NO_MATCH;
|
|
13563
|
+
};
|
|
13552
13564
|
// All tokenizers, order matters!
|
|
13553
13565
|
var tokenizers = [
|
|
13554
13566
|
tokenizeWhitespace,
|
|
@@ -13614,10 +13626,17 @@ function createSourceCodeInfo(input, position, filePath) {
|
|
|
13614
13626
|
function getCurrentToken(input, position) {
|
|
13615
13627
|
var e_1, _a;
|
|
13616
13628
|
var initialPosition = position;
|
|
13629
|
+
if (position === 0) {
|
|
13630
|
+
var _b = __read(tokenizeShebang(input, position), 2), nbrOfCharacters = _b[0], token = _b[1];
|
|
13631
|
+
position += nbrOfCharacters;
|
|
13632
|
+
if (nbrOfCharacters > 0) {
|
|
13633
|
+
return [position - initialPosition, token];
|
|
13634
|
+
}
|
|
13635
|
+
}
|
|
13617
13636
|
try {
|
|
13618
13637
|
for (var tokenizers_1 = __values(tokenizers), tokenizers_1_1 = tokenizers_1.next(); !tokenizers_1_1.done; tokenizers_1_1 = tokenizers_1.next()) {
|
|
13619
13638
|
var tokenizer = tokenizers_1_1.value;
|
|
13620
|
-
var
|
|
13639
|
+
var _c = __read(tokenizer(input, position), 2), nbrOfCharacters = _c[0], token = _c[1];
|
|
13621
13640
|
position += nbrOfCharacters;
|
|
13622
13641
|
if (nbrOfCharacters === 0) {
|
|
13623
13642
|
continue;
|
|
@@ -13671,6 +13690,9 @@ function asReservedSymbolToken(token, symbolName) {
|
|
|
13671
13690
|
assertReservedSymbolToken(token, symbolName);
|
|
13672
13691
|
return token;
|
|
13673
13692
|
}
|
|
13693
|
+
function isShebangToken(token) {
|
|
13694
|
+
return (token === null || token === void 0 ? void 0 : token[0]) === 'Shebang';
|
|
13695
|
+
}
|
|
13674
13696
|
function isSingleLineCommentToken(token) {
|
|
13675
13697
|
return (token === null || token === void 0 ? void 0 : token[0]) === 'SingleLineComment';
|
|
13676
13698
|
}
|
|
@@ -13770,6 +13792,7 @@ function minifyTokenStream(tokenStream, _a) {
|
|
|
13770
13792
|
.filter(function (token) {
|
|
13771
13793
|
if (isSingleLineCommentToken(token)
|
|
13772
13794
|
|| isMultiLineCommentToken(token)
|
|
13795
|
+
|| isShebangToken(token)
|
|
13773
13796
|
|| (removeWhiteSpace && isWhitespaceToken(token))) {
|
|
13774
13797
|
return false;
|
|
13775
13798
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ReservedSymbol } from './reservedNames';
|
|
2
2
|
import { type SymbolicBinaryOperator, type SymbolicOperator } from './operators';
|
|
3
|
-
export declare const tokenTypes: readonly ["LBrace", "LBracket", "RBrace", "RBracket", "LParen", "RParen", "BasePrefixedNumber", "DocString", "Error", "MultiLineComment", "Number", "Operator", "RegexpShorthand", "ReservedSymbol", "SingleLineComment", "String", "Symbol", "Whitespace"];
|
|
3
|
+
export declare const tokenTypes: readonly ["LBrace", "LBracket", "RBrace", "RBracket", "LParen", "RParen", "BasePrefixedNumber", "DocString", "Error", "MultiLineComment", "Number", "Operator", "RegexpShorthand", "ReservedSymbol", "SingleLineComment", "Shebang", "String", "Symbol", "Whitespace"];
|
|
4
4
|
export type TokenType = typeof tokenTypes[number];
|
|
5
5
|
declare const modifierNames: readonly ["&rest", "&let", "&when", "&while"];
|
|
6
6
|
export type ModifierName = typeof modifierNames[number];
|
|
@@ -19,11 +19,12 @@ export type OperatorToken<T extends SymbolicOperator = SymbolicOperator> = Gener
|
|
|
19
19
|
export type RegexpShorthandToken = GenericToken<'RegexpShorthand'>;
|
|
20
20
|
export type ReservedSymbolToken<T extends ReservedSymbol = ReservedSymbol> = GenericToken<'ReservedSymbol', T>;
|
|
21
21
|
export type SingleLineCommentToken = GenericToken<'SingleLineComment'>;
|
|
22
|
+
export type ShebangToken = GenericToken<'Shebang'>;
|
|
22
23
|
export type StringToken = GenericToken<'String'>;
|
|
23
24
|
export type DocStringToken = GenericToken<'DocString'>;
|
|
24
25
|
export type SymbolToken<T extends string = string> = GenericToken<'Symbol', T>;
|
|
25
26
|
export type WhitespaceToken = GenericToken<'Whitespace'>;
|
|
26
|
-
export type Token = LBraceToken | LBracketToken | LParenToken | RBraceToken | RBracketToken | RParenToken | BasePrefixedNumberToken | DocStringToken | ErrorToken | MultiLineCommentToken | NumberToken | OperatorToken | RegexpShorthandToken | ReservedSymbolToken | SingleLineCommentToken | StringToken | SymbolToken | WhitespaceToken;
|
|
27
|
+
export type Token = LBraceToken | LBracketToken | LParenToken | RBraceToken | RBracketToken | RParenToken | BasePrefixedNumberToken | DocStringToken | ErrorToken | MultiLineCommentToken | NumberToken | OperatorToken | RegexpShorthandToken | ReservedSymbolToken | SingleLineCommentToken | ShebangToken | StringToken | SymbolToken | WhitespaceToken;
|
|
27
28
|
export type TokenDescriptor<T extends Token> = [length: number, token?: T];
|
|
28
29
|
export interface SourceCodeInfo {
|
|
29
30
|
position: {
|
|
@@ -39,12 +40,9 @@ export declare function asSymbolToken<T extends string>(token: Token | undefined
|
|
|
39
40
|
export declare function isReservedSymbolToken<T extends ReservedSymbol>(token: Token | undefined | undefined, symbolName?: T): token is ReservedSymbolToken<T>;
|
|
40
41
|
export declare function assertReservedSymbolToken<T extends ReservedSymbol>(token: Token | undefined | undefined, symbolName?: T): asserts token is ReservedSymbolToken<T>;
|
|
41
42
|
export declare function asReservedSymbolToken<T extends ReservedSymbol>(token: Token | undefined | undefined, symbolName?: T): ReservedSymbolToken<T>;
|
|
43
|
+
export declare function isShebangToken(token: Token | undefined): token is SingleLineCommentToken;
|
|
42
44
|
export declare function isSingleLineCommentToken(token: Token | undefined): token is SingleLineCommentToken;
|
|
43
|
-
export declare function assertSingleLineCommentToken(token: Token | undefined): asserts token is SingleLineCommentToken;
|
|
44
|
-
export declare function asSingleLineCommentToken(token: Token | undefined): SingleLineCommentToken;
|
|
45
45
|
export declare function isMultiLineCommentToken(token: Token | undefined): token is MultiLineCommentToken;
|
|
46
|
-
export declare function assertMultiLineCommentToken(token: Token | undefined): asserts token is MultiLineCommentToken;
|
|
47
|
-
export declare function asMultiLineCommentToken(token: Token | undefined): MultiLineCommentToken;
|
|
48
46
|
export declare function isOperatorToken<T extends SymbolicOperator>(token: Token | undefined | undefined, operatorName?: T): token is OperatorToken<T>;
|
|
49
47
|
export declare function assertOperatorToken<T extends SymbolicOperator>(token: Token | undefined | undefined, operatorName?: T): asserts token is OperatorToken<T>;
|
|
50
48
|
export declare function asOperatorToken<T extends SymbolicOperator>(token: Token | undefined | undefined, operatorName?: T): OperatorToken<T>;
|
|
@@ -9,5 +9,6 @@ export declare const tokenizeSymbol: Tokenizer<SymbolToken>;
|
|
|
9
9
|
export declare const tokenizeReservedSymbolToken: Tokenizer<ReservedSymbolToken>;
|
|
10
10
|
export declare const tokenizeOperator: Tokenizer<OperatorToken>;
|
|
11
11
|
export declare const tokenizeMultiLineComment: Tokenizer<MultiLineCommentToken>;
|
|
12
|
+
export declare const tokenizeShebang: Tokenizer<SingleLineCommentToken>;
|
|
12
13
|
export declare const tokenizeSingleLineComment: Tokenizer<SingleLineCommentToken>;
|
|
13
14
|
export declare const tokenizers: [Tokenizer<WhitespaceToken>, Tokenizer<MultiLineCommentToken>, Tokenizer<SingleLineCommentToken>, Tokenizer<ReservedSymbolToken>, Tokenizer<LParenToken>, Tokenizer<RParenToken>, Tokenizer<LBracketToken>, Tokenizer<RBracketToken>, Tokenizer<LBraceToken>, Tokenizer<RBraceToken>, Tokenizer<DocStringToken>, Tokenizer<StringToken>, Tokenizer<RegexpShorthandToken>, Tokenizer<BasePrefixedNumberToken>, Tokenizer<NumberToken>, Tokenizer<OperatorToken>, Tokenizer<SymbolToken>];
|
package/dist/index.esm.js
CHANGED
|
@@ -13562,10 +13562,10 @@ var tokenizeMultiLineComment = function (input, position) {
|
|
|
13562
13562
|
}
|
|
13563
13563
|
return NO_MATCH;
|
|
13564
13564
|
};
|
|
13565
|
-
var
|
|
13566
|
-
if (input[position] === '
|
|
13565
|
+
var tokenizeShebang = function (input, position) {
|
|
13566
|
+
if (input[position] === '#' && input[position + 1] === '!') {
|
|
13567
13567
|
var length_3 = 2;
|
|
13568
|
-
var value = '
|
|
13568
|
+
var value = '#!';
|
|
13569
13569
|
while (input[position + length_3] !== '\n' && position + length_3 < input.length) {
|
|
13570
13570
|
value += input[position + length_3];
|
|
13571
13571
|
length_3 += 1;
|
|
@@ -13574,6 +13574,18 @@ var tokenizeSingleLineComment = function (input, position) {
|
|
|
13574
13574
|
}
|
|
13575
13575
|
return NO_MATCH;
|
|
13576
13576
|
};
|
|
13577
|
+
var tokenizeSingleLineComment = function (input, position) {
|
|
13578
|
+
if (input[position] === '/' && input[position + 1] === '/') {
|
|
13579
|
+
var length_4 = 2;
|
|
13580
|
+
var value = '//';
|
|
13581
|
+
while (input[position + length_4] !== '\n' && position + length_4 < input.length) {
|
|
13582
|
+
value += input[position + length_4];
|
|
13583
|
+
length_4 += 1;
|
|
13584
|
+
}
|
|
13585
|
+
return [length_4, ['SingleLineComment', value]];
|
|
13586
|
+
}
|
|
13587
|
+
return NO_MATCH;
|
|
13588
|
+
};
|
|
13577
13589
|
// All tokenizers, order matters!
|
|
13578
13590
|
var tokenizers = [
|
|
13579
13591
|
tokenizeWhitespace,
|
|
@@ -13639,10 +13651,17 @@ function createSourceCodeInfo(input, position, filePath) {
|
|
|
13639
13651
|
function getCurrentToken(input, position) {
|
|
13640
13652
|
var e_1, _a;
|
|
13641
13653
|
var initialPosition = position;
|
|
13654
|
+
if (position === 0) {
|
|
13655
|
+
var _b = __read(tokenizeShebang(input, position), 2), nbrOfCharacters = _b[0], token = _b[1];
|
|
13656
|
+
position += nbrOfCharacters;
|
|
13657
|
+
if (nbrOfCharacters > 0) {
|
|
13658
|
+
return [position - initialPosition, token];
|
|
13659
|
+
}
|
|
13660
|
+
}
|
|
13642
13661
|
try {
|
|
13643
13662
|
for (var tokenizers_1 = __values(tokenizers), tokenizers_1_1 = tokenizers_1.next(); !tokenizers_1_1.done; tokenizers_1_1 = tokenizers_1.next()) {
|
|
13644
13663
|
var tokenizer = tokenizers_1_1.value;
|
|
13645
|
-
var
|
|
13664
|
+
var _c = __read(tokenizer(input, position), 2), nbrOfCharacters = _c[0], token = _c[1];
|
|
13646
13665
|
position += nbrOfCharacters;
|
|
13647
13666
|
if (nbrOfCharacters === 0) {
|
|
13648
13667
|
continue;
|
|
@@ -13696,6 +13715,9 @@ function asReservedSymbolToken(token, symbolName) {
|
|
|
13696
13715
|
assertReservedSymbolToken(token, symbolName);
|
|
13697
13716
|
return token;
|
|
13698
13717
|
}
|
|
13718
|
+
function isShebangToken(token) {
|
|
13719
|
+
return (token === null || token === void 0 ? void 0 : token[0]) === 'Shebang';
|
|
13720
|
+
}
|
|
13699
13721
|
function isSingleLineCommentToken(token) {
|
|
13700
13722
|
return (token === null || token === void 0 ? void 0 : token[0]) === 'SingleLineComment';
|
|
13701
13723
|
}
|
|
@@ -13795,6 +13817,7 @@ function minifyTokenStream(tokenStream, _a) {
|
|
|
13795
13817
|
.filter(function (token) {
|
|
13796
13818
|
if (isSingleLineCommentToken(token)
|
|
13797
13819
|
|| isMultiLineCommentToken(token)
|
|
13820
|
+
|| isShebangToken(token)
|
|
13798
13821
|
|| (removeWhiteSpace && isWhitespaceToken(token))) {
|
|
13799
13822
|
return false;
|
|
13800
13823
|
}
|