@danielx/civet 0.5.16 → 0.5.18
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 +43 -27
- package/dist/civet +235 -49
- package/dist/main.js +43 -27
- package/package.json +1 -1
package/dist/browser.js
CHANGED
|
@@ -4970,7 +4970,7 @@ ${input.slice(result.pos)}
|
|
|
4970
4970
|
return result;
|
|
4971
4971
|
}
|
|
4972
4972
|
}
|
|
4973
|
-
var InlineObjectLiteral$0 = $TS($S(InsertInlineOpenBrace, SnugNamedProperty, ImplicitInlineObjectPropertyDelimiter, $Q($S(NamedProperty, ImplicitInlineObjectPropertyDelimiter)), InsertCloseBrace), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
|
|
4973
|
+
var InlineObjectLiteral$0 = $TS($S(InsertInlineOpenBrace, SnugNamedProperty, ImplicitInlineObjectPropertyDelimiter, $Q($S($C(Samedent, $Q(_)), NamedProperty, ImplicitInlineObjectPropertyDelimiter)), InsertCloseBrace), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
|
|
4974
4974
|
var open = $1;
|
|
4975
4975
|
var close = $5;
|
|
4976
4976
|
return [open, $2, $3, ...$4, close];
|
|
@@ -4994,7 +4994,7 @@ ${input.slice(result.pos)}
|
|
|
4994
4994
|
}
|
|
4995
4995
|
}
|
|
4996
4996
|
var ImplicitInlineObjectPropertyDelimiter$0 = $S($Q(TrailingComment), Comma);
|
|
4997
|
-
var ImplicitInlineObjectPropertyDelimiter$1 = $T($S($Y($S(
|
|
4997
|
+
var ImplicitInlineObjectPropertyDelimiter$1 = $T($S($Y($S($C(Samedent, $Q(_)), NamedProperty)), InsertComma), function(value) {
|
|
4998
4998
|
return value[1];
|
|
4999
4999
|
});
|
|
5000
5000
|
var ImplicitInlineObjectPropertyDelimiter$2 = $T($Y($S(__, $C($EXPECT($L29, fail, 'ImplicitInlineObjectPropertyDelimiter ":"'), $EXPECT($L15, fail, 'ImplicitInlineObjectPropertyDelimiter ")"'), $EXPECT($L28, fail, 'ImplicitInlineObjectPropertyDelimiter "]"'), $EXPECT($L17, fail, 'ImplicitInlineObjectPropertyDelimiter "}"'), ReservedWord))), function(value) {
|
|
@@ -5096,7 +5096,14 @@ ${input.slice(result.pos)}
|
|
|
5096
5096
|
value
|
|
5097
5097
|
};
|
|
5098
5098
|
});
|
|
5099
|
-
var PropertyDefinition$2 = NamedProperty
|
|
5099
|
+
var PropertyDefinition$2 = $TS($S(__, NamedProperty), function($skip, $loc, $0, $1, $2) {
|
|
5100
|
+
var ws = $1;
|
|
5101
|
+
var prop = $2;
|
|
5102
|
+
return {
|
|
5103
|
+
...prop,
|
|
5104
|
+
children: [...ws, ...prop.children]
|
|
5105
|
+
};
|
|
5106
|
+
});
|
|
5100
5107
|
var PropertyDefinition$3 = $TS($S(__, MethodDefinition), function($skip, $loc, $0, $1, $2) {
|
|
5101
5108
|
var ws = $1;
|
|
5102
5109
|
var def = $2;
|
|
@@ -5139,9 +5146,9 @@ ${input.slice(result.pos)}
|
|
|
5139
5146
|
return result;
|
|
5140
5147
|
}
|
|
5141
5148
|
}
|
|
5142
|
-
var NamedProperty$0 = $TS($S(
|
|
5143
|
-
var name = $
|
|
5144
|
-
var exp = $
|
|
5149
|
+
var NamedProperty$0 = $TS($S(PropertyName, __, Colon, ExtendedExpression), function($skip, $loc, $0, $1, $2, $3, $4) {
|
|
5150
|
+
var name = $1;
|
|
5151
|
+
var exp = $4;
|
|
5145
5152
|
return {
|
|
5146
5153
|
type: "Property",
|
|
5147
5154
|
children: $0,
|
|
@@ -5480,7 +5487,9 @@ ${input.slice(result.pos)}
|
|
|
5480
5487
|
var AssignmentOpSymbol$15 = $T($EXPECT($L45, fail, 'AssignmentOpSymbol "?="'), function(value) {
|
|
5481
5488
|
return "??=";
|
|
5482
5489
|
});
|
|
5483
|
-
var AssignmentOpSymbol$16 = $EXPECT($L26, fail, 'AssignmentOpSymbol "="')
|
|
5490
|
+
var AssignmentOpSymbol$16 = $T($S($EXPECT($L26, fail, 'AssignmentOpSymbol "="'), $N($EXPECT($L26, fail, 'AssignmentOpSymbol "="'))), function(value) {
|
|
5491
|
+
return value[0];
|
|
5492
|
+
});
|
|
5484
5493
|
var AssignmentOpSymbol$17 = $T($S(CoffeeWordAssignmentOp), function(value) {
|
|
5485
5494
|
return value[0];
|
|
5486
5495
|
});
|
|
@@ -5846,9 +5855,7 @@ ${input.slice(result.pos)}
|
|
|
5846
5855
|
return result;
|
|
5847
5856
|
}
|
|
5848
5857
|
}
|
|
5849
|
-
var ElseClause$0 = $
|
|
5850
|
-
return [value[1], value[2], value[3]];
|
|
5851
|
-
});
|
|
5858
|
+
var ElseClause$0 = $S(Samedent, Else, Block);
|
|
5852
5859
|
var ElseClause$1 = $S($Q(TrailingComment), Else, Block);
|
|
5853
5860
|
function ElseClause(state) {
|
|
5854
5861
|
if (state.events) {
|
|
@@ -11106,8 +11113,10 @@ ${input.slice(result.pos)}
|
|
|
11106
11113
|
return true;
|
|
11107
11114
|
});
|
|
11108
11115
|
if (classes.length) {
|
|
11109
|
-
let
|
|
11116
|
+
let isBraced = function(c) {
|
|
11110
11117
|
return c[0] === "{" || c[0]?.token === "{";
|
|
11118
|
+
}, unbrace = function(c) {
|
|
11119
|
+
return c.slice(1, -1);
|
|
11111
11120
|
}, parseClass = function(c) {
|
|
11112
11121
|
c = c.token || c;
|
|
11113
11122
|
if (c.startsWith("'")) {
|
|
@@ -11125,21 +11134,25 @@ ${input.slice(result.pos)}
|
|
|
11125
11134
|
}
|
|
11126
11135
|
return true;
|
|
11127
11136
|
});
|
|
11137
|
+
const strings = [], exprs = [];
|
|
11138
|
+
classes.forEach((c) => {
|
|
11139
|
+
if (isBraced(c)) {
|
|
11140
|
+
exprs.push(unbrace(c));
|
|
11141
|
+
exprs.push(", ");
|
|
11142
|
+
} else {
|
|
11143
|
+
strings.push(parseClass(c));
|
|
11144
|
+
}
|
|
11145
|
+
});
|
|
11146
|
+
const stringPart = strings.filter(Boolean).join(" ");
|
|
11128
11147
|
let classValue;
|
|
11129
|
-
if (
|
|
11130
|
-
|
|
11131
|
-
|
|
11132
|
-
|
|
11133
|
-
|
|
11134
|
-
|
|
11135
|
-
classValue.push("$", c);
|
|
11136
|
-
} else {
|
|
11137
|
-
classValue.push(parseClass(c));
|
|
11138
|
-
}
|
|
11139
|
-
});
|
|
11140
|
-
classValue.push("`}");
|
|
11148
|
+
if (exprs.length) {
|
|
11149
|
+
exprs.pop();
|
|
11150
|
+
if (stringPart) {
|
|
11151
|
+
exprs.unshift(JSON.stringify(stringPart), ", ");
|
|
11152
|
+
}
|
|
11153
|
+
classValue = ["{[", ...exprs, '].filter(Boolean).join(" ")}'];
|
|
11141
11154
|
} else {
|
|
11142
|
-
classValue = JSON.stringify(
|
|
11155
|
+
classValue = JSON.stringify(stringPart);
|
|
11143
11156
|
}
|
|
11144
11157
|
attrs.splice(0, 0, [" ", [className, ["=", classValue]]]);
|
|
11145
11158
|
}
|
|
@@ -12683,11 +12696,11 @@ ${input.slice(result.pos)}
|
|
|
12683
12696
|
return result;
|
|
12684
12697
|
}
|
|
12685
12698
|
}
|
|
12686
|
-
var CivetPrologue$0 = $T($S($EXPECT($R50, fail, "CivetPrologue /[\\t ]*/"), DoubleQuote, CivetPrologueContent, DoubleQuote, $TEXT(StatementDelimiter), EOS), function(value) {
|
|
12699
|
+
var CivetPrologue$0 = $T($S($EXPECT($R50, fail, "CivetPrologue /[\\t ]*/"), DoubleQuote, CivetPrologueContent, DoubleQuote, $TEXT(StatementDelimiter), $E(EOS)), function(value) {
|
|
12687
12700
|
var content = value[2];
|
|
12688
12701
|
return content;
|
|
12689
12702
|
});
|
|
12690
|
-
var CivetPrologue$1 = $T($S($EXPECT($R50, fail, "CivetPrologue /[\\t ]*/"), SingleQuote, CivetPrologueContent, SingleQuote, $TEXT(StatementDelimiter), EOS), function(value) {
|
|
12703
|
+
var CivetPrologue$1 = $T($S($EXPECT($R50, fail, "CivetPrologue /[\\t ]*/"), SingleQuote, CivetPrologueContent, SingleQuote, $TEXT(StatementDelimiter), $E(EOS)), function(value) {
|
|
12691
12704
|
var content = value[2];
|
|
12692
12705
|
return content;
|
|
12693
12706
|
});
|
|
@@ -15233,12 +15246,15 @@ ${input.slice(result.pos)}
|
|
|
15233
15246
|
({ prune } = gen = require_generate());
|
|
15234
15247
|
({ SourceMap, base64Encode } = util = require_util());
|
|
15235
15248
|
defaultOptions = {};
|
|
15236
|
-
uncacheable = /* @__PURE__ */ new Set(["TrackIndented", "Samedent", "IndentedFurther", "PushIndent", "PopIndent", "Nested", "InsertIndent", "Arguments", "ArgumentsWithTrailingCallExpressions", "ApplicationStart", "CallExpression", "CallExpressionRest", "LeftHandSideExpression", "ActualAssignment", "UpdateExpression", "UnaryExpression", "BinaryOpExpression", "BinaryOpRHS", "ConditionalExpression", "ShortCircuitExpression", "ImplicitNestedBlock", "ObjectLiteral", "NestedObject", "NestedImplicitObjectLiteral", "BracedObjectLiteralContent", "NestedPropertyDefinitions", "NestedImplicitPropertyDefinition", "NestedImplicitPropertyDefinitions", "NestedBlockStatement", "NestedElement", "NestedElementList", "NestedBindingElement", "NestedBindingElements", "NestedInterfaceProperty", "MemberExpression", "PrimaryExpression", "IndentedApplicationAllowed", "ExpressionWithIndentedApplicationSuppressed", "SuppressIndentedApplication", "AssignmentExpressionTail", "AssignmentExpression", "ExtendedExpression", "Expression", "MemberExpressionRest", "ElseClause", "CoffeeCommentEnabled", "SingleLineComment", "Debugger", "JSXElement", "TypedJSXElement", "JSXFragment", "TypedJSXFragment", "JSXChild", "JSXChildren", "JSXNestedChildren", "JSXMixedChildren"]);
|
|
15249
|
+
uncacheable = /* @__PURE__ */ new Set(["TrackIndented", "Samedent", "IndentedFurther", "PushIndent", "PopIndent", "Nested", "InsertIndent", "Arguments", "ArgumentsWithTrailingCallExpressions", "ApplicationStart", "CallExpression", "CallExpressionRest", "LeftHandSideExpression", "ActualAssignment", "UpdateExpression", "UnaryExpression", "BinaryOpExpression", "BinaryOpRHS", "ConditionalExpression", "ShortCircuitExpression", "InlineObjectLiteral", "ImplicitInlineObjectPropertyDelimiter", "ImplicitNestedBlock", "ObjectLiteral", "NestedObject", "NestedImplicitObjectLiteral", "BracedObjectLiteralContent", "NestedPropertyDefinitions", "NestedImplicitPropertyDefinition", "NestedImplicitPropertyDefinitions", "NestedBlockStatement", "NestedElement", "NestedElementList", "NestedBindingElement", "NestedBindingElements", "NestedInterfaceProperty", "MemberExpression", "PrimaryExpression", "IndentedApplicationAllowed", "ExpressionWithIndentedApplicationSuppressed", "SuppressIndentedApplication", "AssignmentExpressionTail", "AssignmentExpression", "ExtendedExpression", "Expression", "MemberExpressionRest", "ElseClause", "CoffeeCommentEnabled", "SingleLineComment", "Debugger", "JSXElement", "TypedJSXElement", "JSXFragment", "TypedJSXFragment", "JSXChild", "JSXChildren", "JSXNestedChildren", "JSXMixedChildren"]);
|
|
15237
15250
|
module.exports = {
|
|
15238
15251
|
parse,
|
|
15239
15252
|
compile: function(src, options = defaultOptions) {
|
|
15240
15253
|
var ast, code, events, filename, sm, srcMapJSON;
|
|
15241
15254
|
filename = options.filename || "unknown";
|
|
15255
|
+
if (filename.endsWith(".coffee") && !/^(#![^\r\n]*(\r\n|\n|\r))?\s*['"]civet/.test(src)) {
|
|
15256
|
+
src = `"civet coffeeCompat"; ${src}`;
|
|
15257
|
+
}
|
|
15242
15258
|
if (!options.noCache) {
|
|
15243
15259
|
events = makeCache();
|
|
15244
15260
|
}
|
package/dist/civet
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
"use strict";
|
|
3
|
-
var compile, encoding, fs, generate, parse, prune,
|
|
3
|
+
var cli, compile, encoding, fs, generate, parse, parseArgs, path, prune, readFiles, repl, version, splice = [].splice;
|
|
4
|
+
version = function() {
|
|
5
|
+
return require("../package.json").version;
|
|
6
|
+
};
|
|
4
7
|
if (process.argv.includes("--version")) {
|
|
5
|
-
|
|
8
|
+
console.log(version());
|
|
6
9
|
process.exit(0);
|
|
7
10
|
}
|
|
8
11
|
if (process.argv.includes("--help")) {
|
|
9
|
-
process.
|
|
12
|
+
process.stderr.write(` \u2584\u2584\xB7 \u25AA \u258C \u2590\xB7\u2584\u2584\u2584 .\u2584\u2584\u2584\u2584\u2584
|
|
10
13
|
\u2590\u2588 \u258C\u25AA\u2588\u2588 \u25AA\u2588\xB7\u2588\u258C\u2580\u2584.\u2580\xB7\u2022\u2588\u2588 _._ _,-'""\`-._
|
|
11
14
|
\u2588\u2588 \u2584\u2584\u2590\u2588\xB7\u2590\u2588\u2590\u2588\u2022\u2590\u2580\u2580\u25AA\u2584 \u2590\u2588.\u25AA (,-.\`._,'( |\\\`-/|
|
|
12
15
|
\u2590\u2588\u2588\u2588\u258C\u2590\u2588\u258C \u2588\u2588\u2588 \u2590\u2588\u2584\u2584\u258C \u2590\u2588\u258C\xB7 \`-.-' \\ )-\`( , o o)
|
|
@@ -15,14 +18,24 @@ if (process.argv.includes("--help")) {
|
|
|
15
18
|
|
|
16
19
|
Usage:
|
|
17
20
|
|
|
18
|
-
civet [options]
|
|
21
|
+
civet [options] # REPL
|
|
22
|
+
civet [options] -c input.civet # -> input.civet.tsx
|
|
23
|
+
civet [options] -c input.civet -o .ts # -> input.ts
|
|
24
|
+
civet [options] -c input.civet -o dir # -> dir/input.civet.tsx
|
|
25
|
+
civet [options] -c input.civet -o dir/.ts # -> dir/input.ts
|
|
26
|
+
civet [options] -c input.civet -o output.ts # -> output.ts
|
|
27
|
+
civet [options] < input.civet > output.ts # pipe form
|
|
19
28
|
|
|
20
29
|
Options:
|
|
21
|
-
--help
|
|
22
|
-
--version
|
|
23
|
-
--
|
|
24
|
-
|
|
25
|
-
--js
|
|
30
|
+
--help Show this help message
|
|
31
|
+
--version Show the version number
|
|
32
|
+
-o / --output XX Specify output directory and/or extension, or filename
|
|
33
|
+
-c / --compile Compile input files to TypeScript (or JavaScript)
|
|
34
|
+
--js Strip out all type annotations; default to .jsx extension
|
|
35
|
+
--ast Print the AST instead of the compiled code
|
|
36
|
+
--inline-map Generate a sourcemap
|
|
37
|
+
|
|
38
|
+
You can use - to read from stdin or (prefixed by -o) write to stdout.
|
|
26
39
|
|
|
27
40
|
`);
|
|
28
41
|
process.exit(0);
|
|
@@ -30,48 +43,221 @@ Options:
|
|
|
30
43
|
({ parse, compile, generate } = require("./main"));
|
|
31
44
|
({ prune } = generate);
|
|
32
45
|
encoding = "utf8";
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
46
|
+
fs = require("fs/promises");
|
|
47
|
+
path = require("path");
|
|
48
|
+
parseArgs = function(args = process.argv.slice(2)) {
|
|
49
|
+
var arg, char, filenames, i, options, ref;
|
|
50
|
+
options = {};
|
|
51
|
+
filenames = [];
|
|
52
|
+
i = 0;
|
|
53
|
+
while (i < args.length) {
|
|
54
|
+
arg = args[i];
|
|
55
|
+
if (/^-\w{2,}$/.test(arg)) {
|
|
56
|
+
splice.apply(args, [i, i - i + 1].concat(ref = function() {
|
|
57
|
+
var j, len, ref1, results;
|
|
58
|
+
ref1 = arg.slice(1);
|
|
59
|
+
results = [];
|
|
60
|
+
for (j = 0, len = ref1.length; j < len; j++) {
|
|
61
|
+
char = ref1[j];
|
|
62
|
+
results.push(`-${char}`);
|
|
63
|
+
}
|
|
64
|
+
return results;
|
|
65
|
+
}())), ref;
|
|
66
|
+
continue;
|
|
67
|
+
}
|
|
68
|
+
switch (arg) {
|
|
69
|
+
case "-c":
|
|
70
|
+
case "--compile":
|
|
71
|
+
options.compile = true;
|
|
72
|
+
break;
|
|
73
|
+
case "-o":
|
|
74
|
+
case "--output":
|
|
75
|
+
options.output = args[++i];
|
|
76
|
+
break;
|
|
77
|
+
case "--ast":
|
|
78
|
+
options.ast = true;
|
|
79
|
+
break;
|
|
80
|
+
case "--no-cache":
|
|
81
|
+
options.noCache = true;
|
|
82
|
+
break;
|
|
83
|
+
case "--inline-map":
|
|
84
|
+
options.inlineMap = true;
|
|
85
|
+
break;
|
|
86
|
+
case "--js":
|
|
87
|
+
options.js = true;
|
|
88
|
+
break;
|
|
89
|
+
case "--":
|
|
90
|
+
filenames.push(...args.slice(++i));
|
|
91
|
+
i = args.length;
|
|
92
|
+
break;
|
|
93
|
+
default:
|
|
94
|
+
filenames.push(arg);
|
|
95
|
+
}
|
|
96
|
+
i++;
|
|
40
97
|
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
98
|
+
return { filenames, options };
|
|
99
|
+
};
|
|
100
|
+
readFiles = async function* (filenames, options) {
|
|
101
|
+
var content, error, filename, j, len, lines, results, rl, stdin;
|
|
102
|
+
results = [];
|
|
103
|
+
for (j = 0, len = filenames.length; j < len; j++) {
|
|
104
|
+
filename = filenames[j];
|
|
105
|
+
stdin = filename === "-";
|
|
106
|
+
try {
|
|
107
|
+
if (stdin) {
|
|
108
|
+
process.stdin.setEncoding(encoding);
|
|
109
|
+
filename = "<stdin>";
|
|
110
|
+
try {
|
|
111
|
+
filename = await fs.realpath("/dev/stdin");
|
|
112
|
+
} catch (error1) {
|
|
113
|
+
}
|
|
114
|
+
lines = [];
|
|
115
|
+
rl = require("readline").createInterface(process.stdin, process.stdout);
|
|
116
|
+
rl.on("line", function(buffer) {
|
|
117
|
+
return lines.push(buffer + "\n");
|
|
118
|
+
});
|
|
119
|
+
content = await new Promise(function(resolve, reject) {
|
|
120
|
+
rl.on("SIGINT", function() {
|
|
121
|
+
return reject("^C");
|
|
122
|
+
});
|
|
123
|
+
return rl.on("close", function() {
|
|
124
|
+
return resolve(lines.join(""));
|
|
125
|
+
});
|
|
126
|
+
});
|
|
127
|
+
} else {
|
|
128
|
+
content = await fs.readFile(filename, { encoding });
|
|
129
|
+
}
|
|
130
|
+
results.push(yield { filename, content, stdin });
|
|
131
|
+
} catch (error1) {
|
|
132
|
+
error = error1;
|
|
133
|
+
results.push(yield { filename, error, stdin });
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
return results;
|
|
137
|
+
};
|
|
138
|
+
repl = function(options) {
|
|
139
|
+
var nodeRepl, r, vm;
|
|
140
|
+
console.log(`Civet ${version()} REPL. Enter a blank line to execute code.`);
|
|
141
|
+
global.quit = global.exit = function() {
|
|
142
|
+
return process.exit(0);
|
|
143
|
+
};
|
|
144
|
+
nodeRepl = require("repl");
|
|
145
|
+
vm = require("vm");
|
|
146
|
+
return r = nodeRepl.start({
|
|
147
|
+
prompt: "\u{1F431}> ",
|
|
148
|
+
eval: function(input, context, filename, callback) {
|
|
149
|
+
var error, output, result;
|
|
150
|
+
if (input === "\n") {
|
|
151
|
+
return callback(null);
|
|
152
|
+
} else if (input === "quit\n" || input === "exit\n" || input === "quit()\n" || input === "exit()\n") {
|
|
153
|
+
return process.exit(0);
|
|
154
|
+
} else if (input.endsWith("\n\n")) {
|
|
155
|
+
try {
|
|
156
|
+
output = compile(input, { ...options, filename });
|
|
157
|
+
} catch (error1) {
|
|
158
|
+
error = error1;
|
|
159
|
+
return callback(error);
|
|
160
|
+
}
|
|
161
|
+
try {
|
|
162
|
+
result = vm.runInContext(output, context, { filename });
|
|
163
|
+
} catch (error1) {
|
|
164
|
+
error = error1;
|
|
165
|
+
return callback(error);
|
|
166
|
+
}
|
|
167
|
+
return callback(null, result);
|
|
168
|
+
} else {
|
|
169
|
+
return callback(new nodeRepl.Recoverable("Enter a blank line to execute code."));
|
|
170
|
+
}
|
|
171
|
+
}
|
|
56
172
|
});
|
|
57
173
|
};
|
|
58
|
-
|
|
59
|
-
var
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
174
|
+
cli = async function() {
|
|
175
|
+
var content, error, filename, filenames, options, optionsPath, output, outputFilename, outputPath, ref, results, stat, stdin, x;
|
|
176
|
+
({ filenames, options } = parseArgs());
|
|
177
|
+
if (!filenames.length) {
|
|
178
|
+
options.compile = true;
|
|
179
|
+
if (process.stdin.isTTY) {
|
|
180
|
+
options.repl = true;
|
|
181
|
+
} else {
|
|
182
|
+
filenames = ["-"];
|
|
183
|
+
}
|
|
68
184
|
}
|
|
69
|
-
|
|
70
|
-
if (
|
|
71
|
-
|
|
185
|
+
options.run = !(options.ast || options.compile);
|
|
186
|
+
if (options.run) {
|
|
187
|
+
options.js = true;
|
|
188
|
+
options.inlineMap = true;
|
|
72
189
|
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
190
|
+
if (options.repl) {
|
|
191
|
+
return repl(options);
|
|
192
|
+
}
|
|
193
|
+
ref = readFiles(filenames, options);
|
|
194
|
+
results = [];
|
|
195
|
+
for await (x of ref) {
|
|
196
|
+
({ filename, error, content, stdin } = x);
|
|
197
|
+
if (error) {
|
|
198
|
+
console.error(`${filename} failed to load:`);
|
|
199
|
+
console.error(error);
|
|
200
|
+
continue;
|
|
201
|
+
}
|
|
202
|
+
try {
|
|
203
|
+
output = compile(content, { ...options, filename });
|
|
204
|
+
} catch (error1) {
|
|
205
|
+
error = error1;
|
|
206
|
+
console.error(error);
|
|
207
|
+
continue;
|
|
208
|
+
}
|
|
209
|
+
if (options.ast) {
|
|
210
|
+
results.push(process.stdout.write(JSON.stringify(output, null, 2)));
|
|
211
|
+
} else if (options.compile) {
|
|
212
|
+
if (stdin && !options.output || options.output === "-") {
|
|
213
|
+
results.push(process.stdout.write(output));
|
|
214
|
+
} else {
|
|
215
|
+
outputPath = path.parse(filename);
|
|
216
|
+
delete outputPath.base;
|
|
217
|
+
if (options.js) {
|
|
218
|
+
outputPath.ext += ".jsx";
|
|
219
|
+
} else {
|
|
220
|
+
outputPath.ext += ".tsx";
|
|
221
|
+
}
|
|
222
|
+
if (options.output) {
|
|
223
|
+
optionsPath = path.parse(options.output);
|
|
224
|
+
try {
|
|
225
|
+
stat = await fs.stat(options.output);
|
|
226
|
+
} catch (error1) {
|
|
227
|
+
stat = null;
|
|
228
|
+
}
|
|
229
|
+
if (stat != null ? stat.isDirectory() : void 0) {
|
|
230
|
+
outputPath.dir = options.output;
|
|
231
|
+
} else if (/^(\.[^.]+)+$/.test(optionsPath.base)) {
|
|
232
|
+
outputPath.ext = optionsPath.base;
|
|
233
|
+
if (optionsPath.dir) {
|
|
234
|
+
outputPath.dir = optionsPath.dir;
|
|
235
|
+
}
|
|
236
|
+
} else {
|
|
237
|
+
outputPath = optionsPath;
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
outputFilename = path.format(outputPath);
|
|
241
|
+
try {
|
|
242
|
+
results.push(await fs.writeFile(outputFilename, output));
|
|
243
|
+
} catch (error1) {
|
|
244
|
+
error = error1;
|
|
245
|
+
console.error(`${outputFilename} failed to write:`);
|
|
246
|
+
results.push(console.error(error));
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
} else {
|
|
250
|
+
try {
|
|
251
|
+
results.push(require.main._compile(output, filename));
|
|
252
|
+
} catch (error1) {
|
|
253
|
+
error = error1;
|
|
254
|
+
console.error(`${filename} crashed while running:`);
|
|
255
|
+
results.push(console.error(error));
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
return results;
|
|
260
|
+
};
|
|
261
|
+
if (require.main === module) {
|
|
262
|
+
cli();
|
|
263
|
+
}
|
package/dist/main.js
CHANGED
|
@@ -4969,7 +4969,7 @@ ${input.slice(result.pos)}
|
|
|
4969
4969
|
return result;
|
|
4970
4970
|
}
|
|
4971
4971
|
}
|
|
4972
|
-
var InlineObjectLiteral$0 = $TS($S(InsertInlineOpenBrace, SnugNamedProperty, ImplicitInlineObjectPropertyDelimiter, $Q($S(NamedProperty, ImplicitInlineObjectPropertyDelimiter)), InsertCloseBrace), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
|
|
4972
|
+
var InlineObjectLiteral$0 = $TS($S(InsertInlineOpenBrace, SnugNamedProperty, ImplicitInlineObjectPropertyDelimiter, $Q($S($C(Samedent, $Q(_)), NamedProperty, ImplicitInlineObjectPropertyDelimiter)), InsertCloseBrace), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
|
|
4973
4973
|
var open = $1;
|
|
4974
4974
|
var close = $5;
|
|
4975
4975
|
return [open, $2, $3, ...$4, close];
|
|
@@ -4993,7 +4993,7 @@ ${input.slice(result.pos)}
|
|
|
4993
4993
|
}
|
|
4994
4994
|
}
|
|
4995
4995
|
var ImplicitInlineObjectPropertyDelimiter$0 = $S($Q(TrailingComment), Comma);
|
|
4996
|
-
var ImplicitInlineObjectPropertyDelimiter$1 = $T($S($Y($S(
|
|
4996
|
+
var ImplicitInlineObjectPropertyDelimiter$1 = $T($S($Y($S($C(Samedent, $Q(_)), NamedProperty)), InsertComma), function(value) {
|
|
4997
4997
|
return value[1];
|
|
4998
4998
|
});
|
|
4999
4999
|
var ImplicitInlineObjectPropertyDelimiter$2 = $T($Y($S(__, $C($EXPECT($L29, fail, 'ImplicitInlineObjectPropertyDelimiter ":"'), $EXPECT($L15, fail, 'ImplicitInlineObjectPropertyDelimiter ")"'), $EXPECT($L28, fail, 'ImplicitInlineObjectPropertyDelimiter "]"'), $EXPECT($L17, fail, 'ImplicitInlineObjectPropertyDelimiter "}"'), ReservedWord))), function(value) {
|
|
@@ -5095,7 +5095,14 @@ ${input.slice(result.pos)}
|
|
|
5095
5095
|
value
|
|
5096
5096
|
};
|
|
5097
5097
|
});
|
|
5098
|
-
var PropertyDefinition$2 = NamedProperty
|
|
5098
|
+
var PropertyDefinition$2 = $TS($S(__, NamedProperty), function($skip, $loc, $0, $1, $2) {
|
|
5099
|
+
var ws = $1;
|
|
5100
|
+
var prop = $2;
|
|
5101
|
+
return {
|
|
5102
|
+
...prop,
|
|
5103
|
+
children: [...ws, ...prop.children]
|
|
5104
|
+
};
|
|
5105
|
+
});
|
|
5099
5106
|
var PropertyDefinition$3 = $TS($S(__, MethodDefinition), function($skip, $loc, $0, $1, $2) {
|
|
5100
5107
|
var ws = $1;
|
|
5101
5108
|
var def = $2;
|
|
@@ -5138,9 +5145,9 @@ ${input.slice(result.pos)}
|
|
|
5138
5145
|
return result;
|
|
5139
5146
|
}
|
|
5140
5147
|
}
|
|
5141
|
-
var NamedProperty$0 = $TS($S(
|
|
5142
|
-
var name = $
|
|
5143
|
-
var exp = $
|
|
5148
|
+
var NamedProperty$0 = $TS($S(PropertyName, __, Colon, ExtendedExpression), function($skip, $loc, $0, $1, $2, $3, $4) {
|
|
5149
|
+
var name = $1;
|
|
5150
|
+
var exp = $4;
|
|
5144
5151
|
return {
|
|
5145
5152
|
type: "Property",
|
|
5146
5153
|
children: $0,
|
|
@@ -5479,7 +5486,9 @@ ${input.slice(result.pos)}
|
|
|
5479
5486
|
var AssignmentOpSymbol$15 = $T($EXPECT($L45, fail, 'AssignmentOpSymbol "?="'), function(value) {
|
|
5480
5487
|
return "??=";
|
|
5481
5488
|
});
|
|
5482
|
-
var AssignmentOpSymbol$16 = $EXPECT($L26, fail, 'AssignmentOpSymbol "="')
|
|
5489
|
+
var AssignmentOpSymbol$16 = $T($S($EXPECT($L26, fail, 'AssignmentOpSymbol "="'), $N($EXPECT($L26, fail, 'AssignmentOpSymbol "="'))), function(value) {
|
|
5490
|
+
return value[0];
|
|
5491
|
+
});
|
|
5483
5492
|
var AssignmentOpSymbol$17 = $T($S(CoffeeWordAssignmentOp), function(value) {
|
|
5484
5493
|
return value[0];
|
|
5485
5494
|
});
|
|
@@ -5845,9 +5854,7 @@ ${input.slice(result.pos)}
|
|
|
5845
5854
|
return result;
|
|
5846
5855
|
}
|
|
5847
5856
|
}
|
|
5848
|
-
var ElseClause$0 = $
|
|
5849
|
-
return [value[1], value[2], value[3]];
|
|
5850
|
-
});
|
|
5857
|
+
var ElseClause$0 = $S(Samedent, Else, Block);
|
|
5851
5858
|
var ElseClause$1 = $S($Q(TrailingComment), Else, Block);
|
|
5852
5859
|
function ElseClause(state) {
|
|
5853
5860
|
if (state.events) {
|
|
@@ -11105,8 +11112,10 @@ ${input.slice(result.pos)}
|
|
|
11105
11112
|
return true;
|
|
11106
11113
|
});
|
|
11107
11114
|
if (classes.length) {
|
|
11108
|
-
let
|
|
11115
|
+
let isBraced = function(c) {
|
|
11109
11116
|
return c[0] === "{" || c[0]?.token === "{";
|
|
11117
|
+
}, unbrace = function(c) {
|
|
11118
|
+
return c.slice(1, -1);
|
|
11110
11119
|
}, parseClass = function(c) {
|
|
11111
11120
|
c = c.token || c;
|
|
11112
11121
|
if (c.startsWith("'")) {
|
|
@@ -11124,21 +11133,25 @@ ${input.slice(result.pos)}
|
|
|
11124
11133
|
}
|
|
11125
11134
|
return true;
|
|
11126
11135
|
});
|
|
11136
|
+
const strings = [], exprs = [];
|
|
11137
|
+
classes.forEach((c) => {
|
|
11138
|
+
if (isBraced(c)) {
|
|
11139
|
+
exprs.push(unbrace(c));
|
|
11140
|
+
exprs.push(", ");
|
|
11141
|
+
} else {
|
|
11142
|
+
strings.push(parseClass(c));
|
|
11143
|
+
}
|
|
11144
|
+
});
|
|
11145
|
+
const stringPart = strings.filter(Boolean).join(" ");
|
|
11127
11146
|
let classValue;
|
|
11128
|
-
if (
|
|
11129
|
-
|
|
11130
|
-
|
|
11131
|
-
|
|
11132
|
-
|
|
11133
|
-
|
|
11134
|
-
classValue.push("$", c);
|
|
11135
|
-
} else {
|
|
11136
|
-
classValue.push(parseClass(c));
|
|
11137
|
-
}
|
|
11138
|
-
});
|
|
11139
|
-
classValue.push("`}");
|
|
11147
|
+
if (exprs.length) {
|
|
11148
|
+
exprs.pop();
|
|
11149
|
+
if (stringPart) {
|
|
11150
|
+
exprs.unshift(JSON.stringify(stringPart), ", ");
|
|
11151
|
+
}
|
|
11152
|
+
classValue = ["{[", ...exprs, '].filter(Boolean).join(" ")}'];
|
|
11140
11153
|
} else {
|
|
11141
|
-
classValue = JSON.stringify(
|
|
11154
|
+
classValue = JSON.stringify(stringPart);
|
|
11142
11155
|
}
|
|
11143
11156
|
attrs.splice(0, 0, [" ", [className, ["=", classValue]]]);
|
|
11144
11157
|
}
|
|
@@ -12682,11 +12695,11 @@ ${input.slice(result.pos)}
|
|
|
12682
12695
|
return result;
|
|
12683
12696
|
}
|
|
12684
12697
|
}
|
|
12685
|
-
var CivetPrologue$0 = $T($S($EXPECT($R50, fail, "CivetPrologue /[\\t ]*/"), DoubleQuote, CivetPrologueContent, DoubleQuote, $TEXT(StatementDelimiter), EOS), function(value) {
|
|
12698
|
+
var CivetPrologue$0 = $T($S($EXPECT($R50, fail, "CivetPrologue /[\\t ]*/"), DoubleQuote, CivetPrologueContent, DoubleQuote, $TEXT(StatementDelimiter), $E(EOS)), function(value) {
|
|
12686
12699
|
var content = value[2];
|
|
12687
12700
|
return content;
|
|
12688
12701
|
});
|
|
12689
|
-
var CivetPrologue$1 = $T($S($EXPECT($R50, fail, "CivetPrologue /[\\t ]*/"), SingleQuote, CivetPrologueContent, SingleQuote, $TEXT(StatementDelimiter), EOS), function(value) {
|
|
12702
|
+
var CivetPrologue$1 = $T($S($EXPECT($R50, fail, "CivetPrologue /[\\t ]*/"), SingleQuote, CivetPrologueContent, SingleQuote, $TEXT(StatementDelimiter), $E(EOS)), function(value) {
|
|
12690
12703
|
var content = value[2];
|
|
12691
12704
|
return content;
|
|
12692
12705
|
});
|
|
@@ -15230,12 +15243,15 @@ var util;
|
|
|
15230
15243
|
({ prune } = gen = require_generate());
|
|
15231
15244
|
({ SourceMap, base64Encode } = util = require_util());
|
|
15232
15245
|
defaultOptions = {};
|
|
15233
|
-
uncacheable = /* @__PURE__ */ new Set(["TrackIndented", "Samedent", "IndentedFurther", "PushIndent", "PopIndent", "Nested", "InsertIndent", "Arguments", "ArgumentsWithTrailingCallExpressions", "ApplicationStart", "CallExpression", "CallExpressionRest", "LeftHandSideExpression", "ActualAssignment", "UpdateExpression", "UnaryExpression", "BinaryOpExpression", "BinaryOpRHS", "ConditionalExpression", "ShortCircuitExpression", "ImplicitNestedBlock", "ObjectLiteral", "NestedObject", "NestedImplicitObjectLiteral", "BracedObjectLiteralContent", "NestedPropertyDefinitions", "NestedImplicitPropertyDefinition", "NestedImplicitPropertyDefinitions", "NestedBlockStatement", "NestedElement", "NestedElementList", "NestedBindingElement", "NestedBindingElements", "NestedInterfaceProperty", "MemberExpression", "PrimaryExpression", "IndentedApplicationAllowed", "ExpressionWithIndentedApplicationSuppressed", "SuppressIndentedApplication", "AssignmentExpressionTail", "AssignmentExpression", "ExtendedExpression", "Expression", "MemberExpressionRest", "ElseClause", "CoffeeCommentEnabled", "SingleLineComment", "Debugger", "JSXElement", "TypedJSXElement", "JSXFragment", "TypedJSXFragment", "JSXChild", "JSXChildren", "JSXNestedChildren", "JSXMixedChildren"]);
|
|
15246
|
+
uncacheable = /* @__PURE__ */ new Set(["TrackIndented", "Samedent", "IndentedFurther", "PushIndent", "PopIndent", "Nested", "InsertIndent", "Arguments", "ArgumentsWithTrailingCallExpressions", "ApplicationStart", "CallExpression", "CallExpressionRest", "LeftHandSideExpression", "ActualAssignment", "UpdateExpression", "UnaryExpression", "BinaryOpExpression", "BinaryOpRHS", "ConditionalExpression", "ShortCircuitExpression", "InlineObjectLiteral", "ImplicitInlineObjectPropertyDelimiter", "ImplicitNestedBlock", "ObjectLiteral", "NestedObject", "NestedImplicitObjectLiteral", "BracedObjectLiteralContent", "NestedPropertyDefinitions", "NestedImplicitPropertyDefinition", "NestedImplicitPropertyDefinitions", "NestedBlockStatement", "NestedElement", "NestedElementList", "NestedBindingElement", "NestedBindingElements", "NestedInterfaceProperty", "MemberExpression", "PrimaryExpression", "IndentedApplicationAllowed", "ExpressionWithIndentedApplicationSuppressed", "SuppressIndentedApplication", "AssignmentExpressionTail", "AssignmentExpression", "ExtendedExpression", "Expression", "MemberExpressionRest", "ElseClause", "CoffeeCommentEnabled", "SingleLineComment", "Debugger", "JSXElement", "TypedJSXElement", "JSXFragment", "TypedJSXFragment", "JSXChild", "JSXChildren", "JSXNestedChildren", "JSXMixedChildren"]);
|
|
15234
15247
|
module.exports = {
|
|
15235
15248
|
parse,
|
|
15236
15249
|
compile: function(src, options = defaultOptions) {
|
|
15237
15250
|
var ast, code, events, filename, sm, srcMapJSON;
|
|
15238
15251
|
filename = options.filename || "unknown";
|
|
15252
|
+
if (filename.endsWith(".coffee") && !/^(#![^\r\n]*(\r\n|\n|\r))?\s*['"]civet/.test(src)) {
|
|
15253
|
+
src = `"civet coffeeCompat"; ${src}`;
|
|
15254
|
+
}
|
|
15239
15255
|
if (!options.noCache) {
|
|
15240
15256
|
events = makeCache();
|
|
15241
15257
|
}
|