@mojir/lits 1.2.2-alpha.1 → 1.2.2-alpha.3
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 +58 -10
- package/dist/cli/src/Lits/Lits.d.ts +2 -0
- package/dist/cli/src/analyze/index.d.ts +1 -2
- package/dist/cli/src/index.d.ts +0 -1
- package/dist/cli/src/transformer/index.d.ts +2 -0
- package/dist/cli/src/untokenizer/index.d.ts +2 -0
- package/dist/index.esm.js +59 -31
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +58 -31
- package/dist/index.js.map +1 -1
- package/dist/lits.iife.js +58 -31
- package/dist/lits.iife.js.map +1 -1
- package/dist/src/Lits/Lits.d.ts +2 -0
- package/dist/src/analyze/index.d.ts +1 -2
- package/dist/src/index.d.ts +0 -1
- package/dist/src/transformer/index.d.ts +2 -0
- package/dist/src/untokenizer/index.d.ts +2 -0
- package/dist/testFramework.esm.js +58 -10
- package/dist/testFramework.esm.js.map +1 -1
- package/dist/testFramework.js +58 -10
- package/dist/testFramework.js.map +1 -1
- package/package.json +1 -1
package/dist/testFramework.js
CHANGED
|
@@ -2829,7 +2829,7 @@ var mathNormalExpression = {
|
|
|
2829
2829
|
},
|
|
2830
2830
|
};
|
|
2831
2831
|
|
|
2832
|
-
var version = "1.2.2-alpha.
|
|
2832
|
+
var version = "1.2.2-alpha.3";
|
|
2833
2833
|
|
|
2834
2834
|
var uuidTemplate = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx';
|
|
2835
2835
|
var xyRegexp = /[xy]/g;
|
|
@@ -6285,15 +6285,6 @@ function evaluateNumberAsFunction(fn, params, sourceCodeInfo) {
|
|
|
6285
6285
|
return toAny(param[fn]);
|
|
6286
6286
|
}
|
|
6287
6287
|
|
|
6288
|
-
// export function findUnresolvedIdentifiersInFunction(ast, contextStack, builtin: Builtin) => {
|
|
6289
|
-
// const astNodes = Array.isArray(ast) ? ast : ast.b
|
|
6290
|
-
// const unresolvedIdentifiers = new Set<UnresolvedIdentifier>()
|
|
6291
|
-
// for (const subNode of astNodes) {
|
|
6292
|
-
// findUnresolvedIdentifiersInAstNode(subNode, contextStack, builtin)
|
|
6293
|
-
// .forEach(symbol => unresolvedIdentifiers.add(symbol))
|
|
6294
|
-
// }
|
|
6295
|
-
// return unresolvedIdentifiers
|
|
6296
|
-
// }
|
|
6297
6288
|
var findUnresolvedIdentifiers = function (ast, contextStack, builtin) {
|
|
6298
6289
|
var e_1, _a;
|
|
6299
6290
|
var astNodes = Array.isArray(ast) ? ast : ast.b;
|
|
@@ -8024,6 +8015,12 @@ function assertNewLineToken(token) {
|
|
|
8024
8015
|
throw new LitsError("Expected newline token, got ".concat(token === null || token === void 0 ? void 0 : token.t, "."));
|
|
8025
8016
|
}
|
|
8026
8017
|
|
|
8018
|
+
function transformTokens(tokenStram, transformer) {
|
|
8019
|
+
return __assign(__assign({}, tokenStram), { tokens: tokenStram.tokens.map(function (token) {
|
|
8020
|
+
return __assign(__assign({}, token), { v: transformer(token.v) });
|
|
8021
|
+
}) });
|
|
8022
|
+
}
|
|
8023
|
+
|
|
8027
8024
|
var UnparseOptions = /** @class */ (function () {
|
|
8028
8025
|
function UnparseOptions(unparse, lineLength, col, inlined, locked) {
|
|
8029
8026
|
if (col === void 0) { col = 0; }
|
|
@@ -8542,6 +8539,51 @@ function unparseAst(ast, lineLength) {
|
|
|
8542
8539
|
return result.trim();
|
|
8543
8540
|
}
|
|
8544
8541
|
|
|
8542
|
+
function isNoSpaceNeededBefore(token) {
|
|
8543
|
+
switch (token.t) {
|
|
8544
|
+
case TokenType.Bracket:
|
|
8545
|
+
return [')', ']'].includes(token.v);
|
|
8546
|
+
case TokenType.CollectionAccessor:
|
|
8547
|
+
return true;
|
|
8548
|
+
case TokenType.NewLine:
|
|
8549
|
+
return true;
|
|
8550
|
+
default:
|
|
8551
|
+
return false;
|
|
8552
|
+
}
|
|
8553
|
+
}
|
|
8554
|
+
function isNoSpaceNeededAfter(token) {
|
|
8555
|
+
switch (token.t) {
|
|
8556
|
+
case TokenType.Bracket:
|
|
8557
|
+
return ['(', '['].includes(token.v);
|
|
8558
|
+
case TokenType.CollectionAccessor:
|
|
8559
|
+
return true;
|
|
8560
|
+
case TokenType.FnShorthand:
|
|
8561
|
+
return true;
|
|
8562
|
+
case TokenType.NewLine:
|
|
8563
|
+
return true;
|
|
8564
|
+
case TokenType.RegexpShorthand:
|
|
8565
|
+
return true;
|
|
8566
|
+
default:
|
|
8567
|
+
return false;
|
|
8568
|
+
}
|
|
8569
|
+
}
|
|
8570
|
+
function untokenize(tokenStream) {
|
|
8571
|
+
var lastToken;
|
|
8572
|
+
return tokenStream.tokens.reduce(function (acc, token) {
|
|
8573
|
+
var joiner = !lastToken || isNoSpaceNeededAfter(lastToken) || isNoSpaceNeededBefore(token) ? '' : ' ';
|
|
8574
|
+
lastToken = token;
|
|
8575
|
+
return "".concat(acc).concat(joiner).concat(untokenizeToken(token));
|
|
8576
|
+
}, '');
|
|
8577
|
+
}
|
|
8578
|
+
function untokenizeToken(token) {
|
|
8579
|
+
switch (token.t) {
|
|
8580
|
+
case TokenType.String:
|
|
8581
|
+
return "\"".concat(token.v, "\"");
|
|
8582
|
+
default:
|
|
8583
|
+
return token.v;
|
|
8584
|
+
}
|
|
8585
|
+
}
|
|
8586
|
+
|
|
8545
8587
|
var Cache = /** @class */ (function () {
|
|
8546
8588
|
function Cache(maxSize) {
|
|
8547
8589
|
this.cache = {};
|
|
@@ -8673,6 +8715,12 @@ var Lits = /** @class */ (function () {
|
|
|
8673
8715
|
var contextStack = createContextStack(params);
|
|
8674
8716
|
return evaluate(ast, contextStack);
|
|
8675
8717
|
};
|
|
8718
|
+
Lits.prototype.transform = function (tokenStream, transformer) {
|
|
8719
|
+
return transformTokens(tokenStream, transformer);
|
|
8720
|
+
};
|
|
8721
|
+
Lits.prototype.untokenize = function (tokenStream) {
|
|
8722
|
+
return untokenize(tokenStream);
|
|
8723
|
+
};
|
|
8676
8724
|
Lits.prototype.apply = function (fn, fnParams, params) {
|
|
8677
8725
|
var _a;
|
|
8678
8726
|
if (params === void 0) { params = {}; }
|