@danielx/civet 0.4.19-pre.10 → 0.4.19-pre.11
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/browser.js +78 -4
- package/dist/civet +28 -7
- package/dist/main.js +78 -4
- package/package.json +2 -2
package/dist/browser.js
CHANGED
|
@@ -12470,6 +12470,7 @@ ${input.slice(result.pos)}
|
|
|
12470
12470
|
var base64Encode;
|
|
12471
12471
|
var defaultOptions;
|
|
12472
12472
|
var gen;
|
|
12473
|
+
var makeCache;
|
|
12473
12474
|
var parse;
|
|
12474
12475
|
var prune;
|
|
12475
12476
|
var util;
|
|
@@ -12480,11 +12481,12 @@ ${input.slice(result.pos)}
|
|
|
12480
12481
|
module.exports = {
|
|
12481
12482
|
parse,
|
|
12482
12483
|
compile: function(src, options = defaultOptions) {
|
|
12483
|
-
var ast, code, filename, sm, srcMapJSON;
|
|
12484
|
+
var ast, code, events, filename, sm, srcMapJSON;
|
|
12484
12485
|
filename = options.filename || "unknown";
|
|
12485
|
-
|
|
12486
|
-
|
|
12487
|
-
}
|
|
12486
|
+
if (options.cache) {
|
|
12487
|
+
events = makeCache();
|
|
12488
|
+
}
|
|
12489
|
+
ast = prune(parse(src, { filename, events }));
|
|
12488
12490
|
if (options.ast) {
|
|
12489
12491
|
return ast;
|
|
12490
12492
|
}
|
|
@@ -12509,6 +12511,78 @@ ${"//#"} sourceMappingURL=data:application/json;base64,${base64Encode(JSON.strin
|
|
|
12509
12511
|
generate: gen,
|
|
12510
12512
|
util
|
|
12511
12513
|
};
|
|
12514
|
+
makeCache = function() {
|
|
12515
|
+
var caches, events;
|
|
12516
|
+
caches = /* @__PURE__ */ new Map();
|
|
12517
|
+
events = {
|
|
12518
|
+
enter: function(ruleName, state) {
|
|
12519
|
+
var cache, result;
|
|
12520
|
+
cache = caches.get(ruleName);
|
|
12521
|
+
if (cache) {
|
|
12522
|
+
if (cache.has(state.pos)) {
|
|
12523
|
+
result = cache.get(state.pos);
|
|
12524
|
+
return {
|
|
12525
|
+
cache: result ? { ...result } : void 0
|
|
12526
|
+
};
|
|
12527
|
+
}
|
|
12528
|
+
}
|
|
12529
|
+
},
|
|
12530
|
+
exit: function(ruleName, state, result) {
|
|
12531
|
+
var cache;
|
|
12532
|
+
cache = caches.get(ruleName);
|
|
12533
|
+
if (!cache) {
|
|
12534
|
+
switch (ruleName) {
|
|
12535
|
+
case "TrackIndented":
|
|
12536
|
+
case "Samedent":
|
|
12537
|
+
case "IndentedFurther":
|
|
12538
|
+
case "PushIndent":
|
|
12539
|
+
case "PopIndent":
|
|
12540
|
+
case "Nested":
|
|
12541
|
+
case "InsertIndent":
|
|
12542
|
+
case "Arguments":
|
|
12543
|
+
case "ArgumentsWithTrailingCallExpressions":
|
|
12544
|
+
case "ImplicitApplication":
|
|
12545
|
+
case "IndentedApplicationAllowed":
|
|
12546
|
+
case "ApplicationStart":
|
|
12547
|
+
case "CallExpression":
|
|
12548
|
+
case "CallExpressionRest":
|
|
12549
|
+
case "LeftHandSideExpression":
|
|
12550
|
+
case "ActualAssignment":
|
|
12551
|
+
case "UpdateExpression":
|
|
12552
|
+
case "UnaryExpression":
|
|
12553
|
+
case "BinaryOpExpression":
|
|
12554
|
+
case "BinaryOpRHS":
|
|
12555
|
+
case "ConditionalExpression":
|
|
12556
|
+
case "ShortCircuitExpression":
|
|
12557
|
+
case "NestedPropertyDefinitions":
|
|
12558
|
+
case "NestedObject":
|
|
12559
|
+
case "NestedObjectLiteral":
|
|
12560
|
+
case "NestedBlockStatement":
|
|
12561
|
+
case "NestedInterfaceProperty":
|
|
12562
|
+
case "AssignmentExpressionTail":
|
|
12563
|
+
case "AssignmentExpression":
|
|
12564
|
+
case "ExtendedExpression":
|
|
12565
|
+
case "Expression":
|
|
12566
|
+
case "ElseClause":
|
|
12567
|
+
case "CoffeeCommentEnabled":
|
|
12568
|
+
case "SingleLineComment":
|
|
12569
|
+
break;
|
|
12570
|
+
default:
|
|
12571
|
+
cache = /* @__PURE__ */ new Map();
|
|
12572
|
+
caches.set(ruleName, cache);
|
|
12573
|
+
}
|
|
12574
|
+
}
|
|
12575
|
+
if (cache) {
|
|
12576
|
+
if (result) {
|
|
12577
|
+
cache.set(state.pos, { ...result });
|
|
12578
|
+
} else {
|
|
12579
|
+
cache.set(state.pos, result);
|
|
12580
|
+
}
|
|
12581
|
+
}
|
|
12582
|
+
}
|
|
12583
|
+
};
|
|
12584
|
+
return events;
|
|
12585
|
+
};
|
|
12512
12586
|
}
|
|
12513
12587
|
});
|
|
12514
12588
|
return require_main();
|
package/dist/civet
CHANGED
|
@@ -5,6 +5,28 @@ if (process.argv.includes("--version")) {
|
|
|
5
5
|
process.stdout.write(require("../package.json").version + "\n");
|
|
6
6
|
process.exit(0);
|
|
7
7
|
}
|
|
8
|
+
if (process.argv.includes("--help")) {
|
|
9
|
+
process.stdout.write(` \u2584\u2584\xB7 \u25AA \u258C \u2590\xB7\u2584\u2584\u2584 .\u2584\u2584\u2584\u2584\u2584
|
|
10
|
+
\u2590\u2588 \u258C\u25AA\u2588\u2588 \u25AA\u2588\xB7\u2588\u258C\u2580\u2584.\u2580\xB7\u2022\u2588\u2588 _._ _,-'""\`-._
|
|
11
|
+
\u2588\u2588 \u2584\u2584\u2590\u2588\xB7\u2590\u2588\u2590\u2588\u2022\u2590\u2580\u2580\u25AA\u2584 \u2590\u2588.\u25AA (,-.\`._,'( |\\\`-/|
|
|
12
|
+
\u2590\u2588\u2588\u2588\u258C\u2590\u2588\u258C \u2588\u2588\u2588 \u2590\u2588\u2584\u2584\u258C \u2590\u2588\u258C\xB7 \`-.-' \\ )-\`( , o o)
|
|
13
|
+
\xB7\u2580\u2580\u2580 \u2580\u2580\u2580. \u2580 \u2580\u2580\u2580 \u2580\u2580\u2580 \`- \\\`_\`"'-
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
Usage:
|
|
17
|
+
|
|
18
|
+
civet [options] < input.civet > output.ts
|
|
19
|
+
|
|
20
|
+
Options:
|
|
21
|
+
--help Show this help message
|
|
22
|
+
--version Show the version number
|
|
23
|
+
--ast Output the AST instead of the compiled code
|
|
24
|
+
--inline-map Generate a sourcemap
|
|
25
|
+
--js Strip out all type annotations
|
|
26
|
+
|
|
27
|
+
`);
|
|
28
|
+
process.exit(0);
|
|
29
|
+
}
|
|
8
30
|
({ parse, compile, generate } = require("./main"));
|
|
9
31
|
({ prune } = generate);
|
|
10
32
|
encoding = "utf8";
|
|
@@ -34,21 +56,20 @@ readLines = function(rl) {
|
|
|
34
56
|
});
|
|
35
57
|
};
|
|
36
58
|
readLines(readline.createInterface(process.stdin)).then(function(input) {
|
|
37
|
-
var ast, filename, inlineMap, js, output;
|
|
38
|
-
process.argv.includes("--ast");
|
|
39
|
-
|
|
59
|
+
var ast, cache, filename, inlineMap, js, output;
|
|
60
|
+
ast = process.argv.includes("--ast");
|
|
61
|
+
cache = !process.argv.includes("--no-cache");
|
|
40
62
|
inlineMap = process.argv.includes("--inline-map");
|
|
63
|
+
js = process.argv.includes("--js");
|
|
41
64
|
filename = "unknown";
|
|
42
65
|
try {
|
|
43
66
|
filename = fs.realpathSync("/dev/stdin");
|
|
44
67
|
} catch (error) {
|
|
45
68
|
}
|
|
69
|
+
output = compile(input, { ast, cache, filename, inlineMap, js });
|
|
46
70
|
if (ast) {
|
|
47
|
-
|
|
48
|
-
process.stdout.write(JSON.stringify(ast, null, 2));
|
|
49
|
-
process.exit(0);
|
|
71
|
+
output = JSON.stringify(output, null, 2);
|
|
50
72
|
}
|
|
51
|
-
output = compile(input, { filename, js, inlineMap });
|
|
52
73
|
return process.stdout.write(output);
|
|
53
74
|
}).catch(function(e) {
|
|
54
75
|
console.error(e);
|
package/dist/main.js
CHANGED
|
@@ -12467,6 +12467,7 @@ var SourceMap;
|
|
|
12467
12467
|
var base64Encode;
|
|
12468
12468
|
var defaultOptions;
|
|
12469
12469
|
var gen;
|
|
12470
|
+
var makeCache;
|
|
12470
12471
|
var parse;
|
|
12471
12472
|
var prune;
|
|
12472
12473
|
var util;
|
|
@@ -12477,11 +12478,12 @@ defaultOptions = {};
|
|
|
12477
12478
|
module.exports = {
|
|
12478
12479
|
parse,
|
|
12479
12480
|
compile: function(src, options = defaultOptions) {
|
|
12480
|
-
var ast, code, filename, sm, srcMapJSON;
|
|
12481
|
+
var ast, code, events, filename, sm, srcMapJSON;
|
|
12481
12482
|
filename = options.filename || "unknown";
|
|
12482
|
-
|
|
12483
|
-
|
|
12484
|
-
}
|
|
12483
|
+
if (options.cache) {
|
|
12484
|
+
events = makeCache();
|
|
12485
|
+
}
|
|
12486
|
+
ast = prune(parse(src, { filename, events }));
|
|
12485
12487
|
if (options.ast) {
|
|
12486
12488
|
return ast;
|
|
12487
12489
|
}
|
|
@@ -12506,3 +12508,75 @@ ${"//#"} sourceMappingURL=data:application/json;base64,${base64Encode(JSON.strin
|
|
|
12506
12508
|
generate: gen,
|
|
12507
12509
|
util
|
|
12508
12510
|
};
|
|
12511
|
+
makeCache = function() {
|
|
12512
|
+
var caches, events;
|
|
12513
|
+
caches = /* @__PURE__ */ new Map();
|
|
12514
|
+
events = {
|
|
12515
|
+
enter: function(ruleName, state) {
|
|
12516
|
+
var cache, result;
|
|
12517
|
+
cache = caches.get(ruleName);
|
|
12518
|
+
if (cache) {
|
|
12519
|
+
if (cache.has(state.pos)) {
|
|
12520
|
+
result = cache.get(state.pos);
|
|
12521
|
+
return {
|
|
12522
|
+
cache: result ? { ...result } : void 0
|
|
12523
|
+
};
|
|
12524
|
+
}
|
|
12525
|
+
}
|
|
12526
|
+
},
|
|
12527
|
+
exit: function(ruleName, state, result) {
|
|
12528
|
+
var cache;
|
|
12529
|
+
cache = caches.get(ruleName);
|
|
12530
|
+
if (!cache) {
|
|
12531
|
+
switch (ruleName) {
|
|
12532
|
+
case "TrackIndented":
|
|
12533
|
+
case "Samedent":
|
|
12534
|
+
case "IndentedFurther":
|
|
12535
|
+
case "PushIndent":
|
|
12536
|
+
case "PopIndent":
|
|
12537
|
+
case "Nested":
|
|
12538
|
+
case "InsertIndent":
|
|
12539
|
+
case "Arguments":
|
|
12540
|
+
case "ArgumentsWithTrailingCallExpressions":
|
|
12541
|
+
case "ImplicitApplication":
|
|
12542
|
+
case "IndentedApplicationAllowed":
|
|
12543
|
+
case "ApplicationStart":
|
|
12544
|
+
case "CallExpression":
|
|
12545
|
+
case "CallExpressionRest":
|
|
12546
|
+
case "LeftHandSideExpression":
|
|
12547
|
+
case "ActualAssignment":
|
|
12548
|
+
case "UpdateExpression":
|
|
12549
|
+
case "UnaryExpression":
|
|
12550
|
+
case "BinaryOpExpression":
|
|
12551
|
+
case "BinaryOpRHS":
|
|
12552
|
+
case "ConditionalExpression":
|
|
12553
|
+
case "ShortCircuitExpression":
|
|
12554
|
+
case "NestedPropertyDefinitions":
|
|
12555
|
+
case "NestedObject":
|
|
12556
|
+
case "NestedObjectLiteral":
|
|
12557
|
+
case "NestedBlockStatement":
|
|
12558
|
+
case "NestedInterfaceProperty":
|
|
12559
|
+
case "AssignmentExpressionTail":
|
|
12560
|
+
case "AssignmentExpression":
|
|
12561
|
+
case "ExtendedExpression":
|
|
12562
|
+
case "Expression":
|
|
12563
|
+
case "ElseClause":
|
|
12564
|
+
case "CoffeeCommentEnabled":
|
|
12565
|
+
case "SingleLineComment":
|
|
12566
|
+
break;
|
|
12567
|
+
default:
|
|
12568
|
+
cache = /* @__PURE__ */ new Map();
|
|
12569
|
+
caches.set(ruleName, cache);
|
|
12570
|
+
}
|
|
12571
|
+
}
|
|
12572
|
+
if (cache) {
|
|
12573
|
+
if (result) {
|
|
12574
|
+
cache.set(state.pos, { ...result });
|
|
12575
|
+
} else {
|
|
12576
|
+
cache.set(state.pos, result);
|
|
12577
|
+
}
|
|
12578
|
+
}
|
|
12579
|
+
}
|
|
12580
|
+
};
|
|
12581
|
+
return events;
|
|
12582
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@danielx/civet",
|
|
3
|
-
"version": "0.4.19-pre.
|
|
3
|
+
"version": "0.4.19-pre.11",
|
|
4
4
|
"description": "CoffeeScript style syntax for TypeScript",
|
|
5
5
|
"main": "dist/main.js",
|
|
6
6
|
"exports": {
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"author": "Daniel X. Moore",
|
|
29
29
|
"license": "SEE LICENSE IN 💖",
|
|
30
30
|
"devDependencies": {
|
|
31
|
-
"@danielx/hera": "0.
|
|
31
|
+
"@danielx/hera": "0.8.0",
|
|
32
32
|
"@types/assert": "^1.5.6",
|
|
33
33
|
"@types/coffeescript": "^2.5.2",
|
|
34
34
|
"@types/mocha": "^9.1.1",
|